• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Action when no units left in region

Status
Not open for further replies.
Level 17
Joined
Apr 24, 2005
Messages
762
I want to do a trigger which gives a cinematic when there are no units alive owned by a specific player in a region. I tried the count units in unit group condition but it didnt work. And doing conditions which check if a specific unit is alive would be a pain in the *** since there are lots of units in that region.
 
Level 9
Joined
Jun 26, 2007
Messages
659
You may use a variable array to count in real time the number of units int the region for each player:

Map init > for every unit in region { if (unit owned by player x) unit_count[x] = unit_count[x]+1 }
Unit enters region (owned by player x) > unit_count[x] = unit_count[x]+1
Unit leaves region (owned by player x) > unit_count[x] = unit_count[x]-1
Unit dies (owned by player x, unit is in region) > unit_count[x] = unit_count[x]-1

or something like this

and after, you'll only have to check the variable value to lauch your cinematic

(and with this, you can also display a sort of countdown for each player)
 
Last edited:
Level 21
Joined
Aug 21, 2005
Messages
3,699
[Trigger=Untitled Trigger 001]
Events
An event
Conditions
(Number of units in (Units in (Region 001) matching (((Owner of (Matching unit)) Equal to Player 1 (Red)) and (((Matching unit) is alive) Equal to True)))) Equal to 0
Actions
-------- Do some stuff --------
[/Trigger]
 
Status
Not open for further replies.
Top