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

[Trigger] Dying Units Have Buffs?

Status
Not open for further replies.
Level 7
Joined
Jun 1, 2006
Messages
375
Can anyone help me with this trigger also? What's supposed to happen is units with the buff "Righteous Persecution" heal all nearby ally units for 100 hp that are in 900 range of the dying unit. I think it doesnt work because dying units dont have buffs : /.

  • Righteous Persecution 2
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set RPText = True
      • Set RPHealRange = 900.00
      • Set RPPoint = (Position of (Dying unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Dying unit) has buff Righteous Persecution) Equal to True
        • Then - Actions
          • Set RPGroup = (Units within RPHealRange of RPPoint)
          • Unit Group - Pick every unit in RPGroup and do (Actions)
            • Loop - Actions
              • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + 100.00)
              • Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Spells\Human\Resurrect\ResurrectTarget.mdl
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • RPText Equal to True
                • Then - Actions
                  • Floating Text - Create floating text that reads 100 above (Picked unit) with Z offset 0.00, using font size 9.00, color (10.00%, 100.00%, 10.00%), and 0.00% transparency
                  • Floating Text - Change (Last created floating text): Disable permanence
                  • Floating Text - Set the velocity of (Last created floating text) to 128.00 towards 90.00 degrees
                  • Floating Text - Change the fading age of (Last created floating text) to 0.40 seconds
                  • Floating Text - Change the lifespan of (Last created floating text) to 1.20 seconds
                • Else - Actions
                  • Do nothing
        • Else - Actions
          • Do nothing
 
Level 10
Joined
Jun 1, 2008
Messages
485
How a unit get "Righteous Persecution" buff? If it added with aura, then just check if there's nearby unit have that aura.
If unit have it with a spell, just use some indexing method and check if that unit already dies or not every 0.03 second.
 
Level 10
Joined
Jun 1, 2008
Messages
485
0.03 loop won't cause problem, but below cause it. If you use 0.03 loop carefully, leakless and not use it heavily (like create 10 unit ever 0.03 sec.), it won't cause problem.
0.03 sec. won't cause problem just because check if unit that have buff is dies or not.
 
Level 10
Joined
Jun 1, 2008
Messages
485
Then add that unit to group. Every 0.03 second, you check if unit in that group is dead or not. If yes, then start your spell action. If the duration of spell has end, remove it from group.

Gonna post the trigger ASAP.

EDIT: Here's the trigger. I make it simple.
  • Spell Start
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to <Your ability>
    • Actions
      • Unit Group - Add (Target unit of ability being cast) to Group
  • Spell Periodic
    • 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
              • ((Picked unit) is dead) Equal to True
            • Then - Actions
              • -------- Do Your Spell Here --------
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) has buff <Spell Buff>) Equal to False
                • Then - Actions
                  • Unit Group - Remove (Picked unit) from Group
                • Else - Actions
It use just one Unit Group
 
Last edited:
Level 7
Joined
Jun 1, 2006
Messages
375
mm ty for the advice, still having troubles getting it to work. I tired making it an aura with the 0.03 check but wc3 crashed. anyhelp?
 
Level 4
Joined
Jun 10, 2009
Messages
67
Why don't u just make a dummy at the location of where the unit died, and add the buff to it? Or something like that...
 
Level 4
Joined
Jun 10, 2009
Messages
67
Okay, it should work...
Make it look something like this:
  • Your Trigger
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Dying unit) Equal to (YOUR UNIT)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Dying unit) has buff YOUR BUFF) Equal to True
        • Then - Actions
          • Set Death_Loc = (Position of (Dying unit))
          • Unit - Create 1 Dummy for (Owner of (Dying unit)) at Death_Loc facing Default building facing degrees
          • Set Dummy = (Last created unit)
          • Unit - Add a 1.00 second Generic expiration timer to Dummy
          • Set Healed_Units = (Units within 900.00 of Death_Loc matching (((Matching unit) belongs to an ally of (Owner of Dummy)) Equal to True))
          • Unit Group - Pick every unit in Healed_Units and do (Actions)
            • Loop - Actions
              • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + 100.00)
              • -------- Add your floating text and the special effects here --------
          • Custom script: call DestroyGroup(udg_Healed_Units)
          • Custom script: call RemoveLocation(udg_Death_Loc)
        • Else - Actions
You don't need those "Else - Do Nothing" actions, they do Nothing... They just make the trigger larger lol
 
Level 10
Joined
Jun 1, 2008
Messages
485
BaraBura, Dying Unit will lost all buff it have when still living...
Your trigger won't work.

Try this trigger.
  • Add Buff
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to <Your Spell>
    • Actions
      • -------- Set the Index --------
      • Set SP_CurrentIndex = SP_FreeIndex
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SP_CurrentIndex Equal to 0
        • Then - Actions
          • Set SP_MaxIndex = (SP_MaxIndex + 1)
          • Set SP_CurrentIndex = SP_MaxIndex
        • Else - Actions
          • Set SP_FreeIndex = SP_AvaliableIndexes[SP_CurrentIndex]
      • Set SP_AvaliableIndexes[SP_CurrentIndex] = -1
      • -------- Set the Periodic Index --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SP_MaxInstance Equal to 0
        • Then - Actions
          • Trigger - Turn on Check Buff <gen>
        • Else - Actions
      • Set SP_Instances[SP_MaxInstance] = SP_CurrentIndex
      • -------- Set Variable --------
      • Set SP_Unit[SP_CurrentIndex] = (Target unit of ability being cast)
      • Set SP_Duration[SP_CurrentIndex] = 10.00
      • Set SP_Heal[SP_CurrentIndex] = (100.00 + (25.00 x (Real((Level of (Ability being cast) for (Triggering unit))))))
      • Set SP_Range[SP_CurrentIndex] = (400.00 + (50.00 x (Real((Level of (Ability being cast) for (Triggering unit))))))
      • Set SP_Effect[SP_CurrentIndex] = Abilities\Spells\Human\Resurrect\ResurrectTarget.mdl
      • Set SP_Text[SP_CurrentIndex] = True
      • -------- Increase Periodic Index --------
      • Set SP_MaxInstance = (SP_MaxInstance + 1)
  • Check Buff
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set SP_Loop[2] = (SP_MaxInstance - 1)
      • For each (Integer SP_Loop[1]) from 0 to SP_Loop[2], do (Actions)
        • Loop - Actions
          • -------- Get Current Index --------
          • Set SP_CurrentIndex = SP_Instances[SP_Loop[1]]
          • -------- Reduce Duration --------
          • Set SP_Duration[SP_CurrentIndex] = (SP_Duration[SP_CurrentIndex] - 0.03)
          • -------- Check if unit is dead --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (SP_Unit[SP_CurrentIndex] is dead) Equal to True
            • Then - Actions
              • -------- Set Location --------
              • Set SP_Point[1] = (Position of SP_Unit[SP_CurrentIndex])
              • -------- Pick Allies --------
              • Custom script: set bj_wantDestroyGroup =true
              • Unit Group - Pick every unit in (Units within SP_Range[SP_CurrentIndex] of SP_Point[1] matching ((((Matching unit) belongs to an ally of (Owner of SP_Unit[SP_CurrentIndex])) Equal to True) and (((Matching unit) is alive) Equal to True))) and do (Actions)
                • Loop - Actions
                  • -------- Heal Allies --------
                  • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + SP_Heal[SP_CurrentIndex])
                  • -------- Create Effect --------
                  • Special Effect - Create a special effect attached to the origin of (Picked unit) using SP_Effect[SP_CurrentIndex]
                  • Special Effect - Destroy (Last created special effect)
                  • -------- Create Floating Text --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • SP_Text[SP_CurrentIndex] Equal to True
                    • Then - Actions
                      • Floating Text - Create floating text that reads (String((Integer(SP_Heal[SP_CurrentIndex])))) above (Picked unit) with Z offset 0.00, using font size 9.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
                      • Floating Text - Change (Last created floating text): Disable permanence
                      • Floating Text - Set the velocity of (Last created floating text) to 128.00 towards 90.00 degrees
                      • Floating Text - Change the fading age of (Last created floating text) to 0.40 seconds
                      • Floating Text - Change the lifespan of (Last created floating text) to 1.20 seconds
                    • Else - Actions
                  • -------- Remove Leak --------
                  • Custom script: call RemoveLocation(udg_SP_Point[1])
              • -------- End Duration --------
              • Set SP_Duration[SP_CurrentIndex] = 0.00
            • Else - Actions
          • -------- Check if duration is end --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SP_Duration[SP_CurrentIndex] Less than or equal to 0.00
            • Then - Actions
              • -------- Reduce Instance --------
              • Set SP_MaxInstance = (SP_MaxInstance - 1)
              • -------- Allocate Instance --------
              • Set SP_Instances[SP_Loop[1]] = SP_Instances[SP_MaxInstance]
              • -------- Save Free Index --------
              • Set SP_AvaliableIndexes[SP_CurrentIndex] = SP_FreeIndex
              • -------- Set Free Index --------
              • Set SP_FreeIndex = SP_CurrentIndex
              • -------- Reduce Loop --------
              • Set SP_Loop[1] = (SP_Loop[1] - 1)
              • Set SP_Loop[2] = (SP_Loop[2] - 1)
              • -------- Check if no instance running --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • SP_MaxInstance Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                  • Custom script: exitwhen true
                • Else - Actions
            • Else - Actions
You can change the Variable below "Set Variable" comment. It use PurplePoot Indexing system, I modified it a bit.
I attach the map, it's empty but have the trigger.
 

Attachments

  • Campir's Spell.w3x
    19.5 KB · Views: 31
Status
Not open for further replies.
Top