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

[Trigger] Life Drain ability

Status
Not open for further replies.
Level 9
Joined
Jun 10, 2013
Messages
473
Despite the name the spell I want to isn't based off life drain it works like this:
unit with Lifedrain buff will Drain 2 hit points a second from enemies within 200 aoe of itself a second however I just can't figure out how to trigger this.

what I've done so far:

  • Fel Energy
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set TempUnit = (Triggering unit)
      • Set TempPoint = (Position of TempUnit)
      • Set TempOwner = (Owner of TempUnit)
      • Set tempReal = 200.00
      • Set tempGroup1 = (Units within tempReal of TempPoint matching (((Picked unit) belongs to an enemy of TempOwner) Equal to True))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (TempUnit has buff Fel Energy ) Equal to True
        • Then - Actions
          • Unit - Set life of TempUnit to ((Life of TempUnit) + 2.00)
          • Unit Group - Pick every unit in tempGroup1 and do (Actions)
            • Loop - Actions
              • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - 2.00)
        • Else - Actions
      • Custom script: call RemoveLocation (udg_TempPoint)
      • Custom script: call DestroyGroup (udg_tempGroup1)
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,225
Maintain a unit group of all units with the buff. For each unit in that group you search for all hostile units around them. For each hostile unit found you deal 2 damage (important for kill credit) and add 2 life to the buff owner. The life to add could be stored in a variable and added after the victim search ends with a single life modification action for better speed.
 
Level 9
Joined
Jun 10, 2013
Messages
473
Maintain a unit group of all units with the buff. For each unit in that group you search for all hostile units around them. For each hostile unit found you deal 2 damage (important for kill credit) and add 2 life to the buff owner. The life to add could be stored in a variable and added after the victim search ends with a single life modification action for better speed.

Like this?

  • Fel Energy
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set TempPoint = (Position of (Random unit from tempGroup1))
      • Set tempGroup1 = (Units in (Playable map area) matching (((Picked unit) has buff Fel Energy ) Equal to True))
      • Unit Group - Pick every unit in (Units within 200.00 of TempPoint) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) belongs to an enemy of (Owner of (Random unit from tempGroup1))) Equal to True
            • Then - Actions
              • Unit - Cause (Random unit from tempGroup1) to damage (Picked unit), dealing 2.00 damage of attack type Spells and damage type Universal
              • Unit - Set life of (Random unit from tempGroup1) to ((Life of (Random unit from tempGroup1)) + 2.00)
            • Else - Actions
      • Custom script: call RemoveLocation (udg_TempPoint)
      • Custom script: call DestroyGroup (udg_tempGroup1)
 
Level 20
Joined
Aug 13, 2013
Messages
1,696
Do you want this spell to be multicasted by units? Or MUI?

Edit: The tempgroup1 must be on the top of the action func
( before the TempPoint ) and enum the units it contains so you can easily use "picked unit" instead of "random unit" :p.
You are still leaking a group "Units within range".
The spell structure is not correct, you may need 2 triggers for this.
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,225
You cannot pick every unit on the map every second for an ability like this. If you do chances are your map will perform quite badly.

You need another trigger with events like "unit learns an ability" or "unit enters map" or "gains item". If they give off the buff you then add them to a group. You pick all units in that group every second and then for each picked unit you pick units in a group of enemies around the outer picked unit and do the appropriate actions. Remember to turn off the periodic trigger if the group is empty. Units are not automatically removed from groups upon removal, as such before the unit gets removed it must be removed from the group to prevent a leak.
 
Level 9
Joined
Jun 10, 2013
Messages
473
You cannot pick every unit on the map every second for an ability like this. If you do chances are your map will perform quite badly.

You need another trigger with events like "unit learns an ability" or "unit enters map" or "gains item". If they give off the buff you then add them to a group. You pick all units in that group every second and then for each picked unit you pick units in a group of enemies around the outer picked unit and do the appropriate actions. Remember to turn off the periodic trigger if the group is empty. Units are not automatically removed from groups upon removal, as such before the unit gets removed it must be removed from the group to prevent a leak.
Sorry I've recently entered college so I haven't had mush time to mod lately but just to some up want i'm asking because I feel I asked it quite poorly so here ya go;

Fel Energies

The target unit is infused with fel energies making it drain 2 hit points from every enemy unit within 200 aoe ( cumulative ) of it's position for 30 seconds. If there are no enemies in range, no hit points will be drained.
 
Level 9
Joined
Jun 10, 2013
Messages
473
Visualize: Dynamic Indexing

Have a read of this tutorial. Coincidentally it's demo spell is very similar to what you want.

ok so it kinda works perfectly but i'm not sure If I did it right?

  • Untitled Trigger 001
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Fel Energy
    • Actions
      • Set Fe_Index = (Fe_Index + 1)
      • Set Fe_Caster[Fe_Index] = (Triggering unit)
      • Set Fe_BuffedUnit[Fe_Index] = (Target unit of ability being cast)
      • Set Fe_Counter[Fe_Index] = 0
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Fe_Index Equal to 1
        • Then - Actions
          • Trigger - Turn on Fel Energy <gen>
        • Else - Actions

  • Fel Energy
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Fe_Loop_Interger) from 1 to Fe_Index, do (Actions)
        • Loop - Actions
          • Set TempPoint = (Position of Fe_BuffedUnit[Fe_Loop_Interger])
          • Set tempGroup2 = (Units within 200.00 of TempPoint matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of Fe_BuffedUnit[Fe_Loop_Interger])) Equal to True)))
          • Unit Group - Pick every unit in tempGroup2 and do (Actions)
            • Loop - Actions
              • Unit - Cause Fe_BuffedUnit[Fe_Loop_Interger] to damage (Picked unit), dealing 2.00 damage of attack type Spells and damage type Universal
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Fe_BuffedUnit[Fe_Loop_Interger] has buff Fel Energy ) Equal to True
              • (Number of units in tempGroup2) Greater than or equal to 1
            • Then - Actions
              • Unit - Set life of Fe_BuffedUnit[Fe_Loop_Interger] to ((Life of Fe_BuffedUnit[Fe_Loop_Interger]) + (2.00 x (Real((Number of units in tempGroup2)))))
            • Else - Actions
          • Set Fe_Counter[Fe_Loop_Interger] = (Fe_Counter[Fe_Loop_Interger] + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Fe_Counter[Fe_Loop_Interger] Greater than or equal to 60
            • Then - Actions
              • Set Fe_Caster[Fe_Loop_Interger] = Fe_Caster[Fe_Index]
              • Set Fe_BuffedUnit[Fe_Loop_Interger] = Fe_BuffedUnit[Fe_Index]
              • Set Fe_Counter[Fe_Loop_Interger] = Fe_Counter[Fe_Index]
              • Set Fe_Index = (Fe_Index - 1)
              • Set Fe_Loop_Interger = (Fe_Loop_Interger - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Fe_Index Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
      • Custom script: call RemoveLocation (udg_TempPoint)
      • Custom script: call DestroyGroup (udg_tempGroup2)
 
Last edited:
Level 13
Joined
Mar 24, 2013
Messages
1,105
In the periodic trigger:
You want to increment the counter first, then check to see if it is at 60.
If it has reached 60 then you deindex else create your temp point and group etc.

Also in your unit group you need to use a temp integer and count up each time. Because the action "number of units in tempgroup2" leaks a group.

Although you might as well just put that if inside the loop and add 2 each time rather than at the end.
 
Level 9
Joined
Jun 10, 2013
Messages
473
In the periodic trigger:
You want to increment the counter first, then check to see if it is at 60.
If it has reached 60 then you deindex else create your temp point and group etc.

Also in your unit group you need to use a temp integer and count up each time. Because the action "number of units in tempgroup2" leaks a group.

Although you might as well just put that if inside the loop and add 2 each time rather than at the end.

Like this?

  • Fel Energy
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Fe_Loop_Interger) from 1 to Fe_Index, do (Actions)
        • Loop - Actions
          • Set Fe_Counter[Fe_Loop_Interger] = (Fe_Counter[Fe_Loop_Interger] + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Fe_Counter[Fe_Loop_Interger] Greater than or equal to 60
            • Then - Actions
              • Set Fe_Caster[Fe_Loop_Interger] = Fe_Caster[Fe_Index]
              • Set Fe_BuffedUnit[Fe_Loop_Interger] = Fe_BuffedUnit[Fe_Index]
              • Set Fe_Counter[Fe_Loop_Interger] = Fe_Counter[Fe_Index]
              • Set Fe_Index = (Fe_Index - 1)
              • Set Fe_Loop_Interger = (Fe_Loop_Interger - 1)
              • Set TempPoint = (Position of Fe_BuffedUnit[Fe_Loop_Interger])
              • Set tempGroup2 = (Units within 200.00 of TempPoint matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of Fe_BuffedUnit[Fe_Loop_Interger])) Equal to True)))
              • Set TempInteger = (Number of units in tempGroup2)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Fe_BuffedUnit[Fe_Loop_Interger] has buff Fel Energy ) Equal to True
                  • TempInteger Greater than or equal to 1
                • Then - Actions
                  • Unit - Set life of Fe_BuffedUnit[Fe_Loop_Interger] to ((Life of Fe_BuffedUnit[Fe_Loop_Interger]) + (2.00 x (Real((Number of units in tempGroup2)))))
                • Else - Actions
              • Unit Group - Pick every unit in tempGroup2 and do (Actions)
                • Loop - Actions
                  • Unit - Cause Fe_BuffedUnit[Fe_Loop_Interger] to damage (Picked unit), dealing 2.00 damage of attack type Spells and damage type Universal
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Fe_Index Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
      • Custom script: call RemoveLocation (udg_TempPoint)
      • Custom script: call DestroyGroup (udg_tempGroup2)
 
Level 13
Joined
Mar 24, 2013
Messages
1,105
Everything from the temppoint to the pick every unit in unit group needs to be the Else actions of the first If.
You need to also move the removeloc and dest group inside the same Else actions.

You also need to do this order.
Set TempGroup
Pick Every Unit in TempGroup
cause caster to dmg picked unit
Set life of caster = to life of caster +2

Currently that If after the TempInteger is useless and it doesnt check anything relevant so you probably should just remove it.

Edit: Just got to a comp so it should look like this:
  • Fel Energy
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Fe_Loop_Interger) from 1 to Fe_Index, do (Actions)
        • Loop - Actions
          • Set Fe_Counter[Fe_Loop_Interger] = (Fe_Counter[Fe_Loop_Interger] + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Fe_Counter[Fe_Loop_Interger] Greater than or equal to 60
            • Then - Actions
              • Set Fe_Caster[Fe_Loop_Interger] = Fe_Caster[Fe_Index]
              • Set Fe_BuffedUnit[Fe_Loop_Interger] = Fe_BuffedUnit[Fe_Index]
              • Set Fe_Counter[Fe_Loop_Interger] = Fe_Counter[Fe_Index]
              • Set Fe_Index = (Fe_Index - 1)
              • Set Fe_Loop_Interger = (Fe_Loop_Interger - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Fe_Index Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
              • Set TempPoint = (Position of Fe_BuffedUnit[Fe_Loop_Interger])
              • Set tempGroup2 = (Units within 200.00 of TempPoint matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of Fe_BuffedUnit[Fe_Loop_Interger])) Equal to True)))
              • Unit Group - Pick every unit in tempGroup2 and do (Actions)
                • Loop - Actions
                  • Unit - Cause Fe_BuffedUnit[Fe_Loop_Interger] to damage (Picked unit), dealing 2.00 damage of attack type Spells and damage type Universal
                  • Unit - Set life of Fe_BuffedUnit[Fe_Loop_Interger] to ((Life of Fe_BuffedUnit[Fe_Loop_Interger]) + (2.00
              • Custom script: call RemoveLocation (udg_TempPoint)
              • Custom script: call DestroyGroup (udg_tempGroup2)
 
Last edited:
Status
Not open for further replies.
Top