• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

Flying Scorpion

Sergeant
16 Badges
Oct 11, 2020
83
158
  • Magicka
  • Cities: Skylines
  • Stellaris
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Leviathans Story Pack
  • Stellaris - Path to Destruction bundle
  • Stellaris: Synthetic Dawn
  • Stellaris: Humanoids Species Pack
  • Stellaris: Apocalypse
  • Stellaris: Distant Stars
  • Stellaris: Megacorp
  • Stellaris: Ancient Relics
  • Stellaris: Lithoids
  • Stellaris: Federations
  • Stellaris: Necroids
  • Stellaris: Nemesis
Hi there, I'm building a mod for the first time. I'm sure I'll make a lot of mistakes and it will take me awhile to learn everything.

The goal of this mod is create an added effect to the reanimated armies civic.

The effect is a trait called "necromancer" being applied to your primary species' generals (army leaders). The trait is a passive special effect that triggers whenever that general leads an army to victory. After a successful ground assault, the necromancer will reanimate the bodies of the enemies that died during the battle, turning them into....reanimated armies! Cool eh? So even if you're in the late game, you can still get value out of the civic and your necromancers by passively generating undead armies that serve as morale killers :) "hey guess what! Here's what's left of the last empire!"

So far, the mod is able to spawn undead armies upon a successful ground assault. The undead armies are of the same species as the defender, and this only triggers if the attacker has the reanimated armies civic. (temporary until it's tied to the "necromancer" trait on the assault army leader)


Here's the trigger:
# Triggers country_event for the attacker upon victory
# (Before controller is switched)
# This = country, leader attacker
# From = country, planet owner
# FromFrom = planet
# IDENTITIES: attacker is the side that "IsHostile" to
# the planet controller; e.g. spawned monster armies
# are attackers, but if they win and the player attempts
# to retake the planet, the player is the attacker

on_planet_attackers_win = {
events = {
reward_undead_army.10 #the id of the event that should be fired
}
}


And here's the event

#########################################
#
# reanimated_army_event
#
#########################################


namespace = reward_undead_army #we need to have a namespace for this

country_event = {
id = reward_undead_army.10 #This is the event's id, the on_action trigger calls the event by this id.
hide_window = yes #We don't want a pop-up window for this event
is_triggered_only = yes
trigger = { #This is a sub-trigger
has_valid_civic = civic_reanimated_armies #trying to restrict this to reanimated armies civic only
}
immediate = {
# we are currently in country scope
fromfrom = {
# we are now in the planet scope
change_variable = { which = defenders_necro value = 1 } #this will make sure at least 1 army spawns so we know this part of the mod is working
while = { #while defenders_necro is more than 1, we keep running the following loop
limit = {
check_variable = {
which = defenders_necro
value > 0 #when all defenders_necro reaches 0, we'll limit the loop to stop there.
}
}
create_army = {
name = "undead army"
owner = root # the attacker country
species = prev.from.owner_species # the species of the defender
type = "undead_army"
}
subtract_variable = { which = defenders_necro value = 1 } #each time an army is created, the variable is reduced by 1.
}
remove_planet_flag = armies_counted #this flag was left behind by the query event
}
}
}

So far it's working.

The next step is to make the number of armies that are created to be equal to the number of defending armies that died. To do this, I'm performing a query into the number of defending armies at the start of combat.

I'll save you the massive copy/paste, because it seems that the only way to get a value from the game into a variable, is to repeat the following:

limit = { count_planet_army = 1 }
set_variable = { which = defenders_necro value = 1 }
else_if = {
limit = { count_planet_army = 2 }
set_variable = { which = defenders_necro value = 2 }
}
....repeat
This seems to work, but I'm getting errors in the log file and it's kind of buggy.

I also tried

every_planet_army = {
PREV = {
change_variable = {
which = defenders_necro
value = 1
}
}
}

The idea here is to iterate a +1 to the variable for every defending army on the planet, but this didn't seem to do anything.
 
Last edited: