destroy_units
-------------
This is quite a powerful command in the wrong hands.
However with some care it can be a useful tool, especially for AI armies.
Here's three sample uses - you can clone for all relevant factions in your mod.
They are for the AI, rather than human players, but you can include them by omitting the "not FactionIsLocal"
1) Disbanding crusading / jihadi units after a crusade ends.
Here is an example:
monitor_event FactionTurnStart not FactionIsLocal
and FactionType aragon
and I_TurnsSinceLastCrusade = 3
destroy_units aragon, crusading_unit
end_monitor
As you can see the command requires a faction and attribute and the "crusading_unit" isn't part of the normal attribute list.
However, there's nothing stopping us adding to the attributes, providing we don't use anything that might cause confusion to the game engine.
To choose which units should qualify go the descr_mercenaries.txt file - probably in your campaign folder - and check to see which have the crusading qualifier. Add the relevant "crusading_unit" (or "jihad_unit") attribute to those unit entries in the EDU and you're ready to go.
The rationale here is that the AI can get lumbered with units it can't replenish, which take up space that would be better used with units that can be replenished after battles. (Especially if they are sucessful target garrison units.) Also those armies that fail to make it to the crusade / jihad target can spend a long time getting back home - if they ever do. All soak up upkeep for no reward for the AI. Even if this doesn't remove all the units in such armies it should make then easier to destroy
----
2) Disbanding mercenary units the AI can't afford to keep.
Here is an example;
monitor_event FactionTurnStart not FactionIsLocal
and FactionType aragon
and not I_CrusadeInProgress
and Treasury < 25,000
destroy_units aragon, generic_mercenary_unit
end_monitor
Again this version is for the AI factions.
We add the bit about a crusade (or jihad) not being in progress to allow AI Factions to keep recruited mercenary units en route to targets (as these won't be costing the AI any upkeep.)
The value for Treasury you can set to whatever value you think is best for your Mod.
This time we are using the new attribute "generic_mercenary_unit". Aagin not one currently in the EDU, so you add to relevant units.
Note some Mods use mercenary_unit to cover Area of Recruitment units and we don't want to include those, so you have to be careful which mercenary units you give the attribute to.
Hopefully this will help AI factions balance their books better- the AI seems better at deciding what to recruit as opposed to what it can afford in terms of recurring upkeep costs.
----
3) Disbanding obsolete units.
Here is an example:
monitor_event FactionTurnStart not FactionIsLocal
and FactionType aragon
and I_TurnNumber > 320
destroy_units aragon, obsolete_by_1260
end_monitor
Many Mods, especially those with long time spans, put date limits on when certain units can be recruited. However, there's nothing then to clear up all the bits and pieces of units that get left once the recruitment time has ended.
Again alter the dates and turns to suit your particular Mod.
The one above is for a 2 TPY Mod, starting in the year 1100. The units stop being recruitable around 1210 - 1215. We give the AI plenty of time to get lots of usage out of the units, but by 1260 any recruits would be past retirement age so it's time to disband what's left of any remaining units.
So you check in the EDB this time to see what conditions are put on recruiting units. Cross-reference with the descr_events.txt file, if the conditions relate to events. (Most do.) You can also check the descr_mercenaries.txt file to see if which mercenary units also have date limited recruitment. It's probably best to limit the attribute "obsolete_by_xxxx" to a few dates and apply them across the board rather than try work out different dates for every unit / faction combination.
Here the hope is that the AI will be encouraged to recruit more modern units to replace the disbanded ones. Which should give the human player a better gaming experience. Possibly.
----
Here's a simple way to remove unwanted pirate ships.
add pirate_ships to the pirate ship attributes.
then either:
monitor_event FactionTurnEnd FactionType slave
and I_TurnNumber = 50
destroy_units, slave, pirate_ships
terminate_monitor
end_monitor
and clone for the required turns
or
monitor_event FactionTurnEnd FactionType slave
destroy_units, slave, pirate_ships
end_monitor
to remove them at the end of the slave turn throughout the game.
----
I am sure people can come up with even better uses for the command.
(Maybe if the FactionLeader offends the nobility, they go on strike and leave the army? using the knight attribute.)
(Mods -feel free to move tutorials if this is better placed there.)



Reply With Quote














































