• 🏆 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] Damage upon position change

Status
Not open for further replies.
Level 10
Joined
Jun 10, 2007
Messages
557
I have a spell for an as-of-yet incomplete AoS that isn't working properly.

Basically, what is supposed to happen is that you cast the spell at the target area and it puts a debuff on enemies in the area. When an enemy with this debuff changes position in any way (i.e. it moves, teleports, is knocked back, etc.) it will take damage. How this is suppose to work here is that it checks every second and if the unit's current position is different from what it was last interval, the damage is dealt.

What actually happens is that the damage is dealt to the unit even if it's completely stationary and hasn't moved or otherwise changed position at all. Anybody have any idea how to fix this?

  • Mind War Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mind War (Kineticist)
    • Actions
      • Set Location = (Target point of ability being cast)
      • Set Group = (Units within 200.00 of Location matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True)))
      • Unit Group - Pick every unit in Group and do (Actions)
        • Loop - Actions
          • Set MindWarPosition = (Position of (Picked unit))
          • Unit Group - Add (Picked unit) to MindWarGroup
          • Hashtable - Save (Real((Level of Mind War (Kineticist) for (Triggering unit)))) as 0 of (Key (Picked unit)) in MindWar
          • Hashtable - Save 8.00 as 1 of (Key (Picked unit)) in MindWar
          • Hashtable - Save Handle OfMindWarPosition as 2 of (Key (Picked unit)) in MindWar
          • Hashtable - Save Handle Of(Triggering unit) as 3 of (Key (Picked unit)) in MindWar
          • Custom script: call RemoveLocation (udg_MindWarPosition)
      • Unit - Create 1 Dummy for (Owner of (Triggering unit)) at Location facing (Random real number between 1.00 and 360.00) degrees
      • Unit - Add Mental War to (Last created unit)
      • Unit - Order (Last created unit) to Neutral Pit Lord - Howl Of Terror
      • Custom script: call RemoveLocation (udg_Location)
      • Custom script: call DestroyGroup (udg_Group)
  • Mind War FX
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in MindWarGroup and do (Actions)
        • Loop - Actions
          • Set MindWarLevel = (Load 0 of (Key (Picked unit)) from MindWar)
          • Set MindWarTime = (Load 1 of (Key (Picked unit)) from MindWar)
          • Set MindWarPosition = (Load 2 of (Key (Picked unit)) in MindWar)
          • Set MindWarCaster = (Load 3 of (Key (Picked unit)) in MindWar)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • MindWarTime Greater than 0.00
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is alive) Equal to True
                  • ((Picked unit) has buff Mind War (Black Arrow)) Equal to True
                • Then - Actions
                  • Set Location = (Position of (Picked unit))
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Distance between Location and MindWarPosition) Greater than or equal to 25.00
                    • Then - Actions
                      • Unit - Cause MindWarCaster to damage (Picked unit), dealing (14.00 + (3.00 x MindWarLevel)) damage of attack type Spells and damage type Normal
                      • Special Effect - Create a special effect attached to the head of (Picked unit) using Abilities\Weapons\DragonHawkMissile\DragonHawkMissile.mdl
                      • Special Effect - Destroy (Last created special effect)
                    • Else - Actions
                  • Hashtable - Save Handle OfLocation as 2 of (Key (Picked unit)) in MindWar
                  • Hashtable - Save (MindWarTime - 1.00) as 1 of (Key (Picked unit)) in MindWar
                  • Custom script: call RemoveLocation (udg_Location)
                • Else - Actions
                  • Hashtable - Save 0.00 as 1 of (Key (Picked unit)) in MindWar
            • Else - Actions
              • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in MindWar
              • Unit Group - Remove (Picked unit) from MindWarGroup
          • Custom script: call RemoveLocation (udg_MindWarPosition)
Those are my triggers involved. A couple points of clarification:

- Yes, the Hashtable is being created and saved to the proper variable at map initialization.
- The dummy unit casting Howl of Terror isn't being given an expiration timer because it has negative life regeneration and another trigger removes dummies when they die.
- The Howl of Terror-like ability is only to give affected units the buff for the ability.

+rep will be involved for helpful answers, of course. :wink:
 
Level 4
Joined
Jul 30, 2010
Messages
57
I am not sure but have you already tried to change this part
  • Distance between Location and MindWarPosition) Greater than or equal to 25.00
to some other value higher than 25 because maybe 25 is a small number and the game can't see the difference between the point 0 and the point 25. Well like i've said it's just a hypothesis.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
First you store the location into the hashtable, and clear it right away. So the hashtable returns null, and defaults to center of the map.

Remove this line from the first trigger, and in the looping trigger, set it to right before you clear the hashtable.
  • Custom script: call RemoveLocation (udg_MindWarPosition)
Also remove this line from the second trigger:
  • Hashtable - Save Handle OfLocation as 2 of (Key (Picked unit)) in MindWar
After you remove unit from the group, ad a check to see whether the group is empty or not. Turn the looping trigger off if it's empty. In the first trigger, turn on the looping trigger.
 
Level 5
Joined
Nov 30, 2010
Messages
184
There is one part that says
Hashtable - Save (Real((Level of Mind War (Kineticist) for (Triggering unit)...
You should change the triggering unit to casting unit as I think wc3 engine thinks you are referring to the picked unit
 
Level 10
Joined
Jun 10, 2007
Messages
557
First you store the location into the hashtable, and clear it right away. So the hashtable returns null, and defaults to center of the map.

Remove this line from the first trigger, and in the looping trigger, set it to right before you clear the hashtable.
  • Custom script: call RemoveLocation (udg_MindWarPosition)
Also remove this line from the second trigger:
  • Hashtable - Save Handle OfLocation as 2 of (Key (Picked unit)) in MindWar
After you remove unit from the group, ad a check to see whether the group is empty or not. Turn the looping trigger off if it's empty. In the first trigger, turn on the looping trigger.

Aha! That did the trick. Thank you so much! :grin:
 
Status
Not open for further replies.
Top