Tracking number of units in a transport

Evoroth

New Member
Reaction score
11
Is there a way to count or track how many units are inside a specific transport unit? Or even how many units of a specific type?

The best way I have found this late, is creating 8 dummy units, order them all to get into the transport, and then check how many of them are still outside it. 8 - that number is the number of taken spots. But there *should* be something easier, cause I will have to make this check quite often.

Thank you.
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
just use a variable to count everytime someone gets loaded you add 1 to the variable and when someone or everyone gets unloaded you decrease one or set to 0
and also im not sure cause i don't have WE open but i think there might be a way to just pick them up in unit group and check their number.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
FWIW, you can ask the transport for a list of loaded units:

Code:
Events
    Unit - A unit Finishes casting an ability
Conditions
    (Ability being cast) Equal to Load (Goblin Zeppelin)
Actions
    Game - Display to (All players) the text: Currently loaded:
    Unit Group - Pick every unit in (Units owned by (Owner of (Triggering unit)) matching (((Matching unit) is loaded into (Triggering unit)) Equal to True)) and do (Actions)
        Loop - Actions
            Game - Display to (All players) the text: (-  + (Name of (Picked unit)))
 

Romek

Super Moderator
Reaction score
964
use the units custom value to keep track of how many units there are.
When a unit is loaded, increase it. Otherwise, decrease it.

Do what Acehart said for the unit Types.
 

Evoroth

New Member
Reaction score
11
FWIW, you can ask the transport for a list of loaded units:

Code:
Events
    Unit - A unit Finishes casting an ability
Conditions
    (Ability being cast) Equal to Load (Goblin Zeppelin)
Actions
    Game - Display to (All players) the text: Currently loaded:
    Unit Group - Pick every unit in (Units owned by (Owner of (Triggering unit)) matching (((Matching unit) is loaded into (Triggering unit)) Equal to True)) and do (Actions)
        Loop - Actions
            Game - Display to (All players) the text: (-  + (Name of (Picked unit)))

Awesome, didn't know that you could do that. Thanks!
 

Evoroth

New Member
Reaction score
11
use the units custom value to keep track of how many units there are.

OK, I have tried a bit and have one problem, the trigger isn't activated when you click on its portrait to unload it. Is there any way to register that, or prevent players from doing it? I don't want to make this check with a periodic event if I don't have to.

Code:
Untitled Trigger 001
    Events
        Unit - A unit Finishes casting an ability
    Conditions
        ((Ability being cast) Equal to Load (Goblin Zeppelin)) or ((Ability being cast) Equal to Unload (Air Transports))
    Actions
        Unit - Set the custom value of (Triggering unit) to 0
        Game - Display to (All players) the text: Currently Loaded:
        Unit Group - Pick every unit in (Units owned by (Owner of (Triggering unit)) matching (((Matching unit) is loaded into (Triggering unit)) Equal to True)) and do (Actions)
            Loop - Actions
                Game - Display to (All players) the text: (Name of (Picked unit))
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Unit-type of (Picked unit)) Equal to Rifleman
                    Then - Actions
                        Unit - Set the custom value of (Triggering unit) to ((Custom value of (Triggering unit)) + 1)
                    Else - Actions
        Game - Display to (All players) the text: (Riflemen in transport:  + (String((Custom value of (Triggering unit)))))
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
Try with orders:

Events
- Unit - A unit Is issued an order targeting an object
Conditions
- (Issued order) Equal to (Order(unload))
Actions
- Game - Display to (All players) the text: "Unloading: " + (Name of (Target unit of issued order))
 
General chit-chat
Help Users

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top