Tutorial The use of destroy_units in the campaign script

Tutorial The use of destroy_units in the campaign script

Re: destroy_units - 4 sample uses

Seems the problem with my not removing pirate ships is due to a terminate_monitor after the first instance of the destroy pirate ships
(or some other problem as no line after it fires in the campaign script!!)

will need to re-check the code on that!
 
Re: destroy_units - 4 sample uses

You need to put the terminate before the end, like you neglected to do here.

Just swap them around. I hope that helps :)
 
Re: destroy_units - 4 sample uses

The other way around it, which is a little hard to exaplin... is what is called a 'Dummy' faction. Its not really a faction as it does not take up a faction slot. But you can have as many 'dummy' factions as you like. Basically, Every unit (or a select few) is available to this dummy faction, All units available to the dummy faction are available to every other faction, thus creating a super 'dummy' faction. (A faction that in essence could have every unit at its disposal). In that sense, you would/could make English Longbow available to Egypt. The trick, however, is that egypt will never be able to train this unit, because it isnt specified in the EDB. But the unit can be spawned via script. The dummy faction idea simply removes the silver surfer effect you get when a unit spawns for a faction it is not otherwise meant to have.

That same idea, except a select few uinits that are available to every faction, thus creating your dummy 'garrison' faction. These units are given the attribute to be able to destroy them. The units would only be available through script so would only be on the map at your choosing.

The reason you would have multiple dummy factions (possibly with different units) is because there can be multiple sieges going on at once and you dont want to remove the units until after the siege. So multiple dummy factions solve that problem.

But it is as Rozanov pointed out. If its not very well thought out, you will take up a lot of unit slots in the EDU quickly.

The concept makes sense, but what exactly do you mean when you say 'dummy faction'. Adding a name to the ownership line which doesn't exist in sm_factions? And how would this mitigate EDU needs; as in, are the units being spawned under this dummy faction, rather than the faction which owns the settlement, which in turn would allow for any units to be killed off since they're localized to that faction?
 
Re: destroy_units - 4 sample uses

I think he means that you spawn units that the faction owns (EDU ownership) but cannot build (EDB). That way when you destroy this unit for the faction you can be assured that you will only destroy previously spawned units.
 
Re: destroy_units - 4 sample uses

Correct. The dummy faction is just like a place holder. A place for said units to call home. Even though they are in every other factions unit roster (or atleast the factions you want to be able to spawn them). They dont appear in the EDB as no one can racruit them, and you are assured that when you kill the units via script that no other units other then the ones spawned will be removed.

I guess 'dummy' faction is kind of misleading because it isnt really a faction. Its just a place holder.
 
Re: destroy_units - 4 sample uses

I just thought of some very nice ways to use it; set up catholic religious order troops with a common attribute, and then destroy them when the faction gets excommunicated.

And also for destroying crusading mercenaries when the crusade is over.

I think they're both great ideas and I might use them (if I can work out how :P). Thanks for the inspiration, Rozanov! :thumbsup2 +rep

Both scripts now in place, complete with recruit restriction for holy orders :thumbsup2

Here, if you're interested:

Code:
;crusaders go home

monitor_event FactionTurnStart FactionIsLocal
	and I_TurnsSinceLastCrusade = 4
		destroy_units venice crusader
		destroy_units elo crusader
		destroy_units milan crusader
		destroy_units sicily crusader
		destroy_units spain crusader
		destroy_units portugal crusader
		destroy_units norway crusader
		destroy_units scotland crusader
		destroy_units denmark crusader
		destroy_units ireland crusader
		destroy_units poland crusader
		destroy_units hungary crusader
		destroy_units hre crusader
		destroy_units flanders crusader
		destroy_units england crusader
		destroy_units france crusader
		destroy_units teutons crusader
end_monitor

;excommunication? Goodbye holy troops

declare_counter xcom
set_event_counter xcom 0

monitor_event FactionTurnStart FactionType france
	and FactionExcommunicated

		destroy_units france xcom
end_monitor

monitor_event FactionTurnStart FactionType england
	and FactionExcommunicated

		destroy_units england xcom
end_monitor

monitor_event FactionTurnStart FactionType flanders
	and FactionExcommunicated

		destroy_units flanders xcom
end_monitor
	
monitor_event FactionTurnStart FactionType hre
	and FactionExcommunicated

		destroy_units hre xcom
end_monitor

monitor_event FactionTurnStart FactionType hungary
	and FactionExcommunicated

		destroy_units hungary xcom
end_monitor

monitor_event FactionTurnStart FactionType poland
	and FactionExcommunicated

		destroy_units poland xcom
end_monitor

monitor_event FactionTurnStart FactionType ireland
	and FactionExcommunicated

		destroy_units ireland xcom
end_monitor

monitor_event FactionTurnStart FactionType denmark
	and FactionExcommunicated

		destroy_units denmark xcom
end_monitor

monitor_event FactionTurnStart FactionType scotland
	and FactionExcommunicated

		destroy_units scotland xcom
end_monitor

monitor_event FactionTurnStart FactionType norway
	and FactionExcommunicated

		destroy_units norway xcom
end_monitor

monitor_event FactionTurnStart FactionType portugal
	and FactionExcommunicated

		destroy_units portugal xcom
end_monitor

monitor_event FactionTurnStart FactionType spain
	and FactionExcommunicated

		destroy_units spain xcom
end_monitor

monitor_event FactionTurnStart FactionType sicily
	and FactionExcommunicated

		destroy_units sicily xcom
end_monitor

monitor_event FactionTurnStart FactionType milan
	and FactionExcommunicated

		destroy_units milan xcom
end_monitor

monitor_event FactionTurnStart FactionType venice
	and FactionExcommunicated
	
		destroy_units venice xcom
end_monitor

;Preventing recruit of holy troops

monitor_event FactionTurnStart FactionExcommunicated

		set_event_counter xcom 1
end_monitor

monitor_event FactionTurnEnd I_EventCounter xcom 1

		set_event_counter xcom 0
end_monitor
The EDB event restricting recruitment, 'xcom', I've set up using 'and not event_counter xcom 1' as the condition.

Perhaps I could have used a series of if's instead of making so many monitors for the xcom script... But it looked like a bad option. I'd rather have small monitor scripts firing in each instance than a large if statement that covers all of them firing each time. Perhaps I misunderstand something but it seems like the if statement route for this would cause a performance loss.
 
Last edited:
Re: destroy_units - 4 sample uses

maybe a stupid question but here it goes..

I'm trying to make a unique mision for third age total war.. the idea is to use the reinforce region script to let the player collect elven units in grey haven.. when the conditions are met the collected units must be disbanded in order to recreate the "elven are leaving middle earth idea".. as a reward i was thinking of then giving some units of unique elven soldiers..

i know that most of it is possible but i'm wondering if it's possible to disband all units in a certain settlement?
and with the trigger as a certain total of units and not interfering with the reinforce region script.. so actually first trigger the reinforce region succeeded and then clean out the settlement, is this possible?

I've been looking into this a lot but it's hard to find an answer and since i'm only a beginner in scripting it's really hard to figure this out by starting testing right away

thx in advance :)
 
Re: destroy_units - 4 sample uses

When you disband a unit, it will disband ALL instances of that unit faction wide (or maybe it is world wide). Which means you cant just disband a single settlement of units unless those units were ONLY in that settlement.

It is a shame we cant give 'tags' to units once they are recruited/spawned, then we could simply disband individual untis as we please. if only...
 
Re: destroy_units - 4 sample uses

It is a shame we cant give 'tags' to units once they are recruited/spawned, then we could simply disband individual untis as we please. if only...
Why can't we?

docudemons:
Code:
Identifier:	create_unit
Parameters:	<character/settlement name>, <unit label>[, num <number of units>, exp <experience>, arm <armour level>, wep <weapon level>
Description:	creates one or more units of the specified type
Sample use:	create_unit Foedus Chaerea, English_Knights, num 5, exp 1, arm 1, wep 2
Class:	CREATE_UNIT


Identifier:	label_unit
Parameters:	alliance, army, unit, label
Description:	Label a particular unit
Sample use:	label_unit 0 2 4 julii_hastati_2
Class:	LABEL_UNIT

According to the docudemons it should be possible to label a certain unit when created by a script.
Hence, for example for the garrison script, it should be possible to label the units of every city differently, shouldn't it?
 
Re: destroy_units - 4 sample uses

The label_unit command only works within a battle script I believe. Germanicu5 Stakes script for TATW is a brilliant example, but this is how the script starts:

monitor_event BattleConflictPhaseCommenced FactionIsLocal
prepare_for_battle
 
Re: destroy_units - 4 sample uses

Fantastic discovery... a while ago I wrote a saxon fyrd script and used destroy_units to disband all the fyrd units, either by player action (monitoring UnitDisbanded) or script after a number of turns had passed since the fyrd had been called. But I had to make do with an existing unit attribute to use as the dummy (and try to find one that I wasn't using, like can_sap), which severely limited the script's application.

The ability to create your own dummy attributes means that I can have separate fyrds for each region, all of which can be disbanded at different times.
 
Re: destroy_units - 4 sample uses

this could be used to have a maximum number of certain units available at any time
just have the game check every turn how many units with the xyz-unit atribute there are and disable recruiting them via a triggered event if there is the given number or more

great find btw

oh and shouldn't this be moved to the tutorials section of the forum?
 
Last edited:
They can be used where the docudemons specifies 'unit attribute' as a parameter.

Thanks Taiji. As far as I can see destroy_units is the only command with such a parameter. Plus - I think - these conditions:

I_BattlePlayerArmyNumberOfAttribute
I_BattleEnemyArmyNumberOfAttribute
I_BattlePlayerArmyPercentageOfAttribute
I_BattleEnemyArmyPercentageOfAttribute
PercentageUnitAttribute
 
And it would be possible to destroy units under a % of their original strength, or without a minimum number of soldiers? This would kill characters?
 
destroy_units cannot be restricted in the sense of defining other attributes ( % of original strength) - either all the units with that attribute get removed\destroyed or none.
 
So if you wanted to kill a Faction leader how would one go about wording it?
I want him to be executed to follow a story line so need it to happen whether its AI or Local.


monitor_event FactionTurnStart FactionType scotland and and I_SettlementOwner Edinburgh = scotland and I_TurnNumber >= 1 destroy_named_character "John Smith" end_monitor
monitor_event FactionTurnStart FactionType scotland and IsFactionAIControlled and I_SettlementOwner Edinburgh = scotland and I_TurnNumber >= 1 destroy_named_character "John Smith" end_monitor
 
Sorry bout that wouldn't let me edit my last post. But how do I fix this syntax to work with killing named characters?

monitor_event FactionTurnStart FactionType scotland
and IsFactionAIControlled
and I_SettlementOwner Edinburgh = scotland
and I_TurnNumber >= 1
destroy_named_character XX
end_monitor

monitor_event FactionTurnStart FactionType scotland
and IsFactionLocal
and I_SettlementOwner Edinburgh = scotland
and I_TurnNumber >= 1
destroy_named_character XX
end_monitor
 
Thank you, that's exactly what I was looking for as I'm trying to kill a named general after a certain number of turns and that works nicely.
 
16:44:03.299 [game.script] [error] Script parsing error at line 3373, column 1 in The_Long_Road/data/world/maps/campaign/imperial_campaign/campaign_script.txt
don't recognise this token: destroy_units

I did a copy/paste of the OP script about removing pirate ships at turn 50. I gave the pirate ship unit in EDU the pirate_ship attribute, but if it can't recognize the command...
Any idea what I might have done wrong? Would like to have this as part of my campaign.
Thanks
 

Recent posts

Members Online Now

Site News

Thread Statistics

Created
Gorrrrrn,
Last reply from
Withwnar,
Replies
75
Views
18,347

Site Polls

  • Axis & Allies

  • Battleship

  • Checkers

  • Chess

  • Clue

  • Go

  • Monopoly

  • Risk

  • Stratego

  • Other


Results are only viewable after voting.
Back
Top Bottom