• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Need help with win and lose Condition =0

Status
Not open for further replies.
Level 5
Joined
Jun 13, 2012
Messages
113
I Need help making my win and lose condition. In order for the player to lose the player must have control no units excluding structure units.

For the win Condition The player must be the only one controlling units exluding
Building.

I tried different things but i can seem to make the lose or win condition work

I would highly appreciated if u help me =D
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
Use 2 triggers to do this.
An integer array.
Index the integer array based on players number.

One with the event unit enters map.
One with the event unit leaves map.

In the unit enters map trigger increase the integer for the player who owns the new unit.

In the unit leaves map decrease the integer for the player that owns the unit. Then check to see if that number is == 0 by using an ITE. Then do actions in then block
 
Unit enters/leave is not the best I think.

Enter(cons): Pre-placed unit, or custom abilites could fake it.
Leave(cons):If a unit dies this wont fire, also when a unit gets removed via trigger.

You could just set TmpUnitGroup (variable) to "UnitsOwnedByPlayer" and then check conditions with If/Then/Else.
And do this with each player that is playing.
Run this trigger for example each second, no need to fire it too often.

Read Things That Leak. It's a tutorial how to prevent memory leaks.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
Unit enters/leave is not the best I think.

Enter(cons): Pre-placed unit, or custom abilites could fake it.
Leave(cons):If a unit dies this wont fire, also when a unit gets removed via trigger.

You could just set TmpUnitGroup (variable) to "UnitsOwnedByPlayer" and then check conditions with If/Then/Else.
And do this with each player that is playing.
Run this trigger for example each second, no need to fire it too often.

Read Things That Leak. It's a tutorial how to prevent memory leaks.

You have to register preplaced units at map start. ( forgot about that)
With leave map yes unit dies and unit being removed does fire this event.
Unit remove triggers it immediately. Unit kill or unit dies triggers it after the corpse has disappeared.
Setting tempUnitGroup to a variable is very inefficient that is why I suggested a method that I use all the time.
 
Enter(cons): Pre-placed unit, or custom abilites could fake it.
For the pre-placed people, have an init pick. For the custom abilities, example please?

Leave(cons):If a unit dies this wont fire, also when a unit gets removed via trigger.
That would be troublesome indeed.
 
Create 2 unit group variables (assuming there are only two players)

At map initialization add every unit not equal to structure owned by player 1 to unit_groupA. And do the same with the other unit group but for player 2.

Make trigger that tracks units dying, trained and so on, with a condition checking who the owner is and then add/remove the triggering unit from the correct unit group.
 
As i have said above that does not happen.
The post was an hour late, I forgot to click 'Post'.

Create 2 unit group variables
Arrayed variables.
Make trigger that tracks units dying, trained and so on, with a condition checking who the owner is and then add/remove the triggering unit from the correct unit group.
That is exactly what Dimf said, you just translated it into something rather open-ended.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
Create 2 unit group variables (assuming there are only two players)

At map initialization add every unit not equal to structure owned by player 1 to unit_groupA. And do the same with the other unit group but for player 2.

Make trigger that tracks units dying, trained and so on, with a condition checking who the owner is and then add/remove the triggering unit from the correct unit group.

This is less efficient than mine. Do not use unit groups use an integer array keyed to each player to do the counting. This way you don't need to count the units in the unit group you simply do an integer comparison to check if all players units are dead.
 
Status
Not open for further replies.
Top