• 🏆 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!

[General] how can i create a victory and defeat condition that leaves out 1 building

Status
Not open for further replies.
Level 21
Joined
Mar 2, 2010
Messages
3,069
i am working on a project where i need a victory and defeat condition, where players lose when the lose all units and buildings and where 2 players wins when all others are defeated.(player 6 and 1 of the others. no alliances.) how can i accomplish that in an easy and unleaky way.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,178
And where does the 1 building come in?

In any case I would manage the separate win and defeat conditions in parallel so that every 10 seconds of game time it enumerates all living units (unless decay is instant) a player owns into a constant group and checks if the group is empty. If the group is empty it marks the player as defeated. Only applies to the appropriate players (you can use a force (GUI player group) for this).

The other players (another force) check the defeat status of all appropriate players (maybe yet another force?) for their win condition. If all those players are defeated and all players have a result (so players are not booted from the game before it ends) then you win the appropriate players (you can use a force to hold these) and defeat the others (another force).

AI players and neutral players can both win and be defeated but since they are not human it makes little difference next to the impact on the players.
 
Level 21
Joined
Mar 2, 2010
Messages
3,069
isnt it best to check when a unit dies. the project i am working on have massive armies so checking all units would case massive lag. i had already ruled out timer however. is there a way to check the number of units and buildings excluding blood forge and then defeat a player.
 
Level 25
Joined
May 11, 2007
Messages
4,651
Have an integer for each player in an a array.
Then simply:
Have a trigger or two:
Event: A unit finishes training
Event: A building finishes construction

Actions:
Set tempInt = Player Number of owner of trained unit/building;
Set PlayerUnits[tempInt] = Player[tempInt] + 1;

Then another trigger for checking when a unit/building dies:
Event: A unit dies
Condition: Boolean(Unit classification not equal to summoned unit)
Condition: UnitType of unit not Equal to Blood Forge
Actions:
Set tempInt = Player Number of owner of triggering unit;
Set PlayerUnits[tempInt] = Player[tempInt] - 1;
if (playerUnits < 1)
defeat player[tempInt];

Or, set the food given by the blood forge to 0, then check the food property given and used by each player, if both are 0, defeat the player.
 
Status
Not open for further replies.
Top