• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[Trigger] Wait Until All Units of Group Are Loaded Into Transport

Status
Not open for further replies.
Level 3
Joined
Jun 29, 2015
Messages
9
I'm working on a trigger which spawns a group of Footmen and Riflemen, and a Transport Ship, and sends them to a location using the ship. So far, I have managed to make the infantry units spawn and go to the shoreline, where a transport ship spawns and is boarded by the group of infantry.

I want the ship to wait until all the soldiers are loaded before it departs, but I can't figure out how to do it. I could do it if a single unit were boarding the ship, using

Wait until (((unit) is being transported) equal to (true))

but there doesn't seem to be an equivalent "wait for condition" function for Unit Groups. I considered using "Wait For Condition - (And, Multiple Conditions)" to wait for each soldier individually, but not only would it be a bit messy, unfortunately the Wait For Condition function also only allows an "And" with two conditions. That makes it possible for two units loading into a transport. I have five in this trigger.
 
Are you by any chance using GUI Unit Event? The transport event provided by it can help you determine when to move the transport out. Simply put, you already know the maximum amount of units stored in the transport.

All you need to know is if the number of units in the transport is equal to the maximum amount. Once that is satisfied, issue away with your order.

Edit:

I suppose I interpreted the question wrongly. You have control over the creation of units, and you can know exactly how many units of a certain unit type spawn.

Store the number of units of a certain type in a hashtable using the unit type of your desired unit as a key. Once you detect a transport order, decrement the entry above by 1.

Here are some custom scripts that can help you with it:

JASS:
call SaveInteger(<hash_var>, <your_key>, GetUnitTypeId(<your_unit>), <amount_of_units>)
    // Store data here
call LoadInteger(<hash_var>, <your_key>, GetUnitTypeId(<your_unit>))
    // Load data here
 
Last edited:
Status
Not open for further replies.
Top