HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Limiting units, after upgrade possible?

03-07-2011, 04:39 AM#1
galinth
I'm wondering if there is a way to limit the construction of a particular unit (to 1 in this case), while this unit is alive, but has been upgraded into a new (different) unit.

IE: If someone wanted to limit the construction of 1x Town Hall per player, even after they have upgrade it to a Keep/Castle (different units) etc. I can't seem to find a way to do this with triggers but i'm still pretty new..
03-10-2011, 06:12 PM#2
MLB
Use a trigger with the generic unit event, with 'unit finishes upgrading' or so,
and make it limit the building count of the town hall to 0 then. When the upgraded one is destroyed, set it to 1 again.
03-12-2011, 04:23 AM#3
galinth
Thanks! This worked, but I had to make 3 triggers for this.. Seems like there should be a more simplified way though. I'll paste the trigger info if anyone else was curious about this.

Trigger:
Structure_A Initial Rule
Collapse Events
Map initialization
Conditions
Collapse Actions
Player - Limit training of Structure_A to 1 for Player 1 (Red)
First trigger limits default structure to limit of 1

Trigger:
Structure_A Constructed
Collapse Events
Unit - A unit owned by Player 1 (Red) Finishes construction
Collapse Conditions
(Unit-type of (Triggering unit)) Equal to Structure_A
Collapse Actions
Player - Limit training of Structure_A to 0 for Player 1 (Red)
Second trigger prevents more Structure_A's from being built after it has been upgraded into a different structure

Trigger:
Structure Dies
Collapse Events
Unit - A unit owned by Player 1 (Red) Dies
Collapse Conditions
Collapse Or - Any (Conditions) are true
Collapse Conditions
(Unit-type of (Triggering unit)) Equal to Structure_A
(Unit-type of (Triggering unit)) Equal to Structure_B
(Unit-type of (Triggering unit)) Equal to Structure_C
(Unit-type of (Triggering unit)) Equal to Structure_D
Collapse Actions
Player - Limit training of Structure_A to 1 for Player 1 (Red)
Third trigger allows reconstruction of original structure, if destroyed in any original/upgraded form
03-12-2011, 04:24 PM#4
tooltiperror
What if it's removed by trigger? I don't think RemoveUnit fires off a unit dies event.

It'd be better to use an indexer to track when a unit leaves the map. You could also base a dummy ability on that footman spell like an indexer will internally, because a unit will deactivate it when it is removed, dies, et cetera.