• 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.

[Spell] Spells Activated by Movement

Status
Not open for further replies.
Level 3
Joined
Jan 13, 2011
Messages
33
Okay, so what I'm trying to do is create a couple of passive abilities with an effect that is only active while moving.

For example, one of the spells I'm trying to create is an Evasion that only works while you're moving. That means whenever you move, there is a chance for your opponents to miss when attacking you, but while sitting still, that chance is 0%.

Another one I'd like to make which should work in the same way is a Tornado Aura (Passive Slow Aura) that operates in the same way (on while moving, off while standing).

I have tried a couple of things and none worked... I have no idea if what I'm asking is possible (which I hope it is) but I will deeply appreciate any help.
Thanks to all in advance.
 
He is a piece of code for GUI users that should satisfy you.
Customize periodic for smoother effect. Attacked map, with added trigger when hero is revived.
Remember to create hashtable and fill rawcode of ability you want to be added. See initialization trigger for those.
NOTE: Learn Devotion Aura to run.

  • GetUnit
    • Events
      • Unit - A unit Gains new ability
    • Conditions
      • (Learned Hero Skill) Equal to Devotion Aura
    • Actions
      • Set unit = (Triggering unit)
      • Set temp_point = (Position of (Triggering unit))
      • Set locX = (X of temp_point)
      • Set locY = (Y of temp_point)
      • Hashtable - Save locX as (Key X) of (Key (Triggering unit)) in MoveHash
      • Hashtable - Save locY as (Key Y) of (Key (Triggering unit)) in MoveHash
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (MoveGroup is empty) Equal to True
        • Then - actions
          • Trigger - Turn on MoveDetect <gen>
        • Else - Actions
      • Unit Group - Add (Triggering unit) to MoveGroup
      • Custom script: call RemoveLocation (udg_temp_point)
Now we run core trigger:
  • MoveDetect
    • Events
      • Time - Every 0.25 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in MoveGroup and do (Actions)
        • Loop - Actions
          • Set unit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (unit is dead) Not equal to True
            • Then - Actions
              • Set temp_point = (Position of unit)
              • Set temp_point2 = (Point((Load (Key X) of (Key (Picked unit)) from MoveHash), (Load (Key Y) of (Key (Picked unit)) from MoveHash)))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Distance between temp_point and temp_point2) Greater than 0.00
                • Then - Actions
                  • Custom script: if ( GetUnitAbilityLevel(udg_unit, udg_ability) < 1 ) then
                  • Custom script: call UnitAddAbility(udg_unit, udg_ability)
                  • Custom script: endif
                • Else - Actions
                  • Custom script: call UnitRemoveAbility(udg_unit, udg_ability)
              • Set locX = (X of temp_point)
              • Set locY = (Y of temp_point)
              • Hashtable - Save locX as (Key X) of (Key (Picked unit)) in MoveHash
              • Hashtable - Save locY as (Key Y) of (Key (Picked unit)) in MoveHash
              • Custom script: call RemoveLocation (udg_temp_point)
              • Custom script: call RemoveLocation (udg_temp_point2)
            • Else - Actions
              • Unit Group - Remove unit from MoveGroup
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (MoveGroup is empty) Equal to True
        • Then - actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
 

Attachments

  • DetectMove.w3x
    18.8 KB · Views: 40
That GUI script you're running really could be simplified if you were using better custom script. You also don't need devotion aura to do this.

Here, this is a script that runs off of http://www.hiveworkshop.com/forums/spells-569/gui-unit-indexer-1-0-1-1-a-197329/

  • Is Unit Moving
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set UDex = UDexNext[0]
      • Custom script: loop
      • Custom script: exitwhen udg_UDex == 0
      • Custom script: set udg_TempX = GetUnitX(udg_UDexUnits[udg_UDex])
      • Custom script: set udg_TempY = GetUnitY(udg_UDexUnits[udg_UDex])
      • If (All conditions are true) then do (Then - Actions) else do (Else - actions)
        • If - Conditions
          • TempX Equal to UnitMovingX[UDex]
          • TempY Equal to UnitMovingY[UDex]
        • Then - Actions
          • Set UnitMoving[UDex] = False
        • Else - Actions
          • Set UnitMoving[UDex] = True
          • Set UnitMovingX[UDex] = TempX
          • Set UnitMovingY[UDex] = TempY
      • Set UDex = UDexNext[UDex]
      • Custom script: endloop
You can check if a unit is moving like this:

  • UnitMoving[(Custom value of (Triggering unit))] Equal to True
I'll put it into a map later today. Basically you copy this on trigger into the map and it starts working. The 0.03 seconds is adjustable (it should be as slow as the slowest movement-based timer in your map, so if you have a knockback that runs every 0.5 this should run every 0.5).
 
That GUI script you're running really could be simplified if you were using better custom script. You also don't need devotion aura to do this.
It (aura) was made only for testing purposes.
I'm sure it can be improve yet it's fine.

Here, this is a script that runs off of http://www.hiveworkshop.com/forums/spells-569/gui-unit-indexer-1-0-1-1-a-197329/

  • Is Unit Moving
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set UDex = UDexNext[0]
      • Custom script: loop
      • Custom script: exitwhen udg_UDex == 0
      • Custom script: set udg_TempX = GetUnitX(udg_UDexUnits[udg_UDex])
      • Custom script: set udg_TempY = GetUnitY(udg_UDexUnits[udg_UDex])
      • If (All conditions are true) then do (Then - Actions) else do (Else - actions)
        • If - Conditions
          • TempX Equal to UnitMovingX[UDex]
          • TempY Equal to UnitMovingY[UDex]
        • Then - Actions
          • Set UnitMoving[UDex] = False
        • Else - Actions
          • Set UnitMoving[UDex] = True
          • Set UnitMovingX[UDex] = TempX
          • Set UnitMovingY[UDex] = TempY
      • Set UDex = UDexNext[UDex]
      • Custom script: endloop
You can check if a unit is moving like this:

  • UnitMoving[(Custom value of (Triggering unit))] Equal to True
I'll put it into a map later today. Basically you copy this on trigger into the map and it starts working. The 0.03 seconds is adjustable.

I'm using your indexer too in my maps, since it's amazing tool.
However, just for this request it wasn't worth doing it immidiately beacuse I'm unsure if it will be clarify enough to put this trigger and system at the same time. As i said, he can customize periodic as he wants, for sure it can be 0.03.
 
Status
Not open for further replies.
Top