• 🏆 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] Passive Skill that detects Low HP Units

Status
Not open for further replies.
Level 7
Joined
Sep 2, 2011
Messages
350
I have a passive spell. The AoE of the spell is 900. If an enemy within that area has less than or equal to 100 hit points, that unit will be revealed or will be casted a faerie fire.

  • Hunger
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Learned Hero Skill) Equal to Hunger (Fear)
    • Actions
      • Set Hunger_MainUnit = (Learning Hero)
      • Set Hunger_MainUnitPoint = (Position of (Learning Hero))
--

  • Hunger Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set Hunger_UnitGroup = (Units within 900.00 of Hunger_MainUnitPoint matching ((((Matching unit) is A Hero) Equal to True) and ((((Matching unit) belongs to an enemy of (Owner of Hunger_MainUnit)) Equal to True) and (((Matching unit) has buff Hunger (Fear)) Equal to True))))
      • Unit Group - Pick every unit in Hunger_UnitGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Life of (Picked unit)) Less than or equal to 50.00
            • Then - Actions
              • Unit - Create 1 Dummy (Datu Voodoo) for (Owner of Hunger_MainUnit) at (Position of (Picked unit)) facing Default building facing degrees
              • Unit - Add Hunger (Dummy) to (Last created unit)
              • Unit - Set level of Hunger (Dummy) for (Last created unit) to (Level of Hunger (Fear) for Hunger_MainUnit)
              • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
              • Unit - Order (Last created unit) to Night Elf Druid Of The Talon - Faerie Fire (Picked unit)
            • Else - Actions
              • Custom script: call DestroyGroup(udg_Hunger_UnitGroup)
              • Custom script: call RemoveLocation(udg_Hunger_MainUnitPoint)
I can't think of another easier way of doing this spell.
If you have a better idea, please do suggest.
 
Last edited by a moderator:
Every 0.5 seconds should be enough for this kind of effect.

You need to update the location of the hero in the loop trigger.

  • Set Hunger_MainUnitPoint = (Position of Hunger_MainUnit)
  • Set Hunger_UnitGroup = (Units within 900.00 of Hunger_MainUnitPoint matching (...)
  • Custom script: call RemoveLocation (udg_Hunger_MainUnitPoint)
  • Custom script: call DestroyGroup(udg_Hunger_UnitGroup)
Your triggers leak currently, make sure you destroy the group and remove the location outside of the if/then/else branch.

I suggest detecting percent of life, not static values, e.g.
  • (Percentage life of (Picked unit)) Less than or equal to 10.00
 
Level 7
Joined
Sep 2, 2011
Messages
350
Wow. It worked. But how can I make it MUI because I want to post this on the spells section but I think it's too simple. Btw, Does it leak?


  • Hunger
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Learned Hero Skill) Equal to Hunger (Fear)
    • Actions
      • Set Hunger_MainUnit = (Learning Hero)
      • Trigger - Turn on Hunger Loop <gen>
--

  • Hunger Loop
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Set Hunger_MainUnitPoint = (Position of Hunger_MainUnit)
      • Set Hunger_UnitGroup = (Units within 1500.00 of Hunger_MainUnitPoint matching ((((Matching unit) is A Hero) Equal to True) and ((((Matching unit) belongs to an enemy of (Owner of Hunger_MainUnit)) Equal to True) and (((Matching unit) is A structure) Equal to False))))
      • Unit Group - Pick every unit in Hunger_UnitGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Percentage life of (Picked unit)) Less than or equal to 75.00
            • Then - Actions
              • Unit - Create 1 Dummy (Datu Voodoo) for (Owner of Hunger_MainUnit) at (Position of (Picked unit)) facing Default building facing degrees
              • Unit - Add Hunger (Dummy) to (Last created unit)
              • Unit - Set level of Hunger (Dummy) for (Last created unit) to (Level of Hunger (Fear) for Hunger_MainUnit)
              • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
              • Unit - Order (Last created unit) to Night Elf Druid Of The Talon - Faerie Fire (Picked unit)
            • Else - Actions
      • Custom script: call DestroyGroup(udg_Hunger_UnitGroup)
      • Custom script: call RemoveLocation(udg_Hunger_MainUnitPoint)
 
Last edited by a moderator:
Level 37
Joined
Mar 6, 2006
Messages
9,240
Instead of setting unit = learning hero, add the unit into a unit group.

In the periodic trigger, pick all units in the group, and do the actions for them.

Make sure to check that the unit is alive.

Leak: (Position of (Picked unit))

And yes, it would be too simple for a spell submission.
 
Level 7
Joined
Sep 2, 2011
Messages
350
@Maker
I don't quite understand the "Add the unit into a unit group" can you make an example for that?
Oh, you're right, I have to check if the unit is alive.

How can I remove the position leak without making a variable if that is possible?
 
Level 37
Joined
Mar 6, 2006
Messages
9,240

  • Untitled Trigger 035
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Learned Hero Skill) Equal to (==) Human Archmage - Blizzard
    • Actions
      • Unit Group - Add (Triggering unit) to group
      • Trigger - Turn on Untitled Trigger 036 <gen>

  • Untitled Trigger 036
    • Events
      • Time - Every 0.25 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in group and do (Actions)
        • Loop - Actions
          • Set u = (Picked unit)
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (u is alive) Equal to (==) True
              • Then - Actions
                • Set point = (Position of u)
                • Custom script: set bj_wantDestroyGroup = true
                • Unit Group - Pick every unit in (Units within 512.00 of point matching (((Triggering unit) is A structure) Equal to (==) True)) and do (Actions)
                  • Loop - Actions
                • Custom script: call RemoveLocation(udg_point)
              • Else - Actions


You must use a variable to get rid of the location leak.
 
Level 7
Joined
Sep 2, 2011
Messages
350
And remove the group to get rid of the leaks, right?
In order to make it MUI, I have to add them to the group.
It makes sense now. I have to make a creative spell next time.

Thanks. [Solved]
 
Status
Not open for further replies.
Top