• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Need help with a trigger

Status
Not open for further replies.
Level 1
Joined
Jun 13, 2010
Messages
3
Hi, I am trying to create a custom map with different races(than the normal ones). One problem I can't fix, however, is that I want a specific unit to be trained at each town hall, but I want to limit the training of that unit to just one per town hall, keep or castle. Help will be much appreciated. Thanks in advance.
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
You can detect when a building is ordered to train a unit. For example for peasant you woul check for "peasant" order string. Find out the order string for your unit with Game - display message.

Train your unit and use
Unit gets order with no target -> Game - display issued order

When a unit is given the train order, you can save a boolean into a hashtable. Always check if the boolean exists, if it does then order the unit to cancel the training by using 851976 order id. When the unit finishes training, save the handle id of the trained unit for the training unit. When the trained unit dies, clear to boolean.

If a user cancels the training manually, the boolean should be cleared also.
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
There's also this:
  • Custom script: set bj_wantDestroyGroup = true
  • Player - Limit training of Footman to (Number of units in (Units owned by Player 1 (Red) matching (((Matching unit) is A town-hall-type unit) Equal to True))) for Player 1 (Red)
(replace player red with triggering player whenever a town hall is built or destroyed)
 
Status
Not open for further replies.
Top