Hello, I just started using the map editor not long ago, and I'm wondering how to count the number of a specific type of unit inside a bunker. I want to set a variable based on the number of marines inside of a bunker, and I can't for the life of me figure it out.
I've been working with it a bit. I have a local variable set up and a text message to display the variable in game whenever I load a marine in the bunker. But it keeps saying 0.
Nah, that doesn't work. I need this to be multi instanceable.. so I can use multiple bunkers. So I have to use local variables only.. and I tried +1 already, it just resets after you load in a marine.
What I have so far is..
Events
Unit - Any Unit Loads Cargo
Local Variables
Bunker = 0 <integer>
Conditions
(Unit Type of(Triggering Cargo Unit)) == Marine
Actions
Set Bunker = (Transport Number of Units Carried of (Triggering Unit))
See... I just need the type also and I'm set. I'm looking to count unit type carried.
Variable - Set Bunker = (Number of Any units in (Marine units in (Cargo units in (Triggering unit)) owned by player (Triggering player) matching No Unit Filter, with at most Any Amount))
This does it incase any of you were wanting to do this.
Bunker = Integer Variable
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hello, I just started using the map editor not long ago, and I'm wondering how to count the number of a specific type of unit inside a bunker. I want to set a variable based on the number of marines inside of a bunker, and I can't for the life of me figure it out.
Try the function - Transport property of unit - that might work
I've been working with it a bit. I have a local variable set up and a text message to display the variable in game whenever I load a marine in the bunker. But it keeps saying 0.
Okay, yeah it's the Transport Property of Unit function, thanks. But I can't get it to count the number of marines, just the number of all units.
Another one to try then is:
Event:
Unit loads cargo
Condition:
Triggering unit = bunker
Unit type of Triggering cargo unit = marine
Action:
Modify bunkerMarines + 1
Nah, that doesn't work. I need this to be multi instanceable.. so I can use multiple bunkers. So I have to use local variables only.. and I tried +1 already, it just resets after you load in a marine.
What I have so far is..
Events Unit - Any Unit Loads Cargo Local Variables Bunker = 0 <integer> Conditions (Unit Type of(Triggering Cargo Unit)) == Marine Actions Set Bunker = (Transport Number of Units Carried of (Triggering Unit))
See... I just need the type also and I'm set. I'm looking to count unit type carried.
I figured it out.
Variable - Set Bunker = (Number of Any units in (Marine units in (Cargo units in (Triggering unit)) owned by player (Triggering player) matching No Unit Filter, with at most Any Amount))
This does it incase any of you were wanting to do this.
Bunker = Integer Variable