• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[General] how can i kill a unit that runs out of mana

Status
Not open for further replies.
Level 13
Joined
Jul 16, 2012
Messages
679
  • Untitled Trigger 001
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Group and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Mana of (Picked unit)) Equal to 0.00
            • Then - Actions
              • Unit - Kill (Picked unit)
            • Else - Actions
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
the trigger just dont have that option.
Really? Then what are these?
  • Actions
    • -------- --------------------------------------------------------------- --------
    • -------- Way #1 --------
    • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • ((Picked unit) is A structure) Equal to False
          • Then - Actions
            • -------- some actions... --------
          • Else - Actions
    • -------- --------------------------------------------------------------- --------
    • -------- --------------------------------------------------------------- --------
    • -------- Way #2 --------
    • Unit Group - Pick every unit in (Units in (Playable map area) matching (((Matching unit) is A structure) Equal to False)) and do (Actions)
      • Loop - Actions
        • -------- some actions... --------
When you deny something do you at least take a look at the editor to back up what you write?
I mean - you won't get the answer "use this or that condition" from so many people if it weren't possible...

Not to mention that AKA.GywGod133 already posted how to sort units using ITE many posts back.
 
Level 12
Joined
May 20, 2009
Messages
822
  • Untitled Trigger 001
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Max mana of (Picked unit)) Less than or equal to 0.00
            • Then - Actions
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Max mana of (Picked unit)) Greater than 0.00
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Mana of (Picked unit)) Less than 1.00
                    • Then - Actions
                      • Unit - Kill (Picked unit)
                    • Else - Actions
                • Else - Actions
Tested. Works. Does not kill buildings. Does not kill units with no mana. Kills units who's actual mana is less then 1.

EDIT: NOT leak-checked, though. Also probably not the best way, but it works.
 
  • Untitled Trigger 001
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Max mana of (Picked unit)) Less than or equal to 0.00
            • Then - Actions
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Max mana of (Picked unit)) Greater than 0.00
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Mana of (Picked unit)) Less than 1.00
                    • Then - Actions
                      • Unit - Kill (Picked unit)
                    • Else - Actions
                • Else - Actions
Tested. Works. Does not kill buildings. Does not kill units with no mana. Kills units who's actual mana is less then 1.

EDIT: NOT leak-checked, though. Also probably not the best way, but it works.

This is very inefficient. Constantly creating a unit group adding all units in map into it then looping is very costly. Also it can miss units that are healing mana since it runs at a 0.10 second delay rather than the event that detects mana amount. Which runs at a specific value. Thus it is more efficient and a lot more accurate.

Also you can easily combine all of those ITEs.
Here are the simple triggers I have explained multiple times above.

If you add more conditions store triggering unit into a temp variable for best efficiency.
  • Add Unit To kill when no mana
    • Events
      • Unit - A unit enters (Entire map)
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Max mana of (Triggering unit)) Greater than 0.00
        • Then - Actions
          • Trigger - Add to Kill units with no mana <gen> the event (Unit - (Triggering unit)'s mana becomes Equal to 0.00)
        • Else - Actions
  • Kill units with no mana
    • Events
    • Conditions
    • Actions
      • Unit - Kill (Triggering unit)
 
Level 12
Joined
May 20, 2009
Messages
822
deathismyfriend said:
Also it can miss units that are healing mana since it runs at a 0.10 second delay rather than the event that detects mana amount.

That's kind of the point. If their mana even drops below 1, they die. No time to let them regen mana. If their mana happens to get just above 1 before this picks up that they have no mana, then they get to live.

This way, if a unit has say 0.99 mana they'll die. But if they have 1.99 mana, use a spell that costs 1 mana, and just as they cast the spell they regen .01 mana, they have a pretty big window to survive.
 
I thought about this:
  • Trigger - Add to Kill units with no mana <gen> the event (Unit - (Triggering unit)'s mana becomes Equal to 0.00)
as well, but won't this cause same issues like with "Unit takes damage" event for every unit in the map?

No the 2 are not related.

The trigger kills units when mana becomes equal to zero.

They are separate triggers.
 
Status
Not open for further replies.
Top