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

Shockwave not working?

Status
Not open for further replies.
Level 2
Joined
Aug 2, 2010
Messages
14
So I tried making a shockwave spell with triggers, and it doesn't work. I have no idea how to fix it, hope someone can help me.
  • Shockwave init
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Shockwave
    • Actions
      • Custom script: call RemoveLocation(udg_ShockLoc)
      • Custom script: call RemoveLocation(udg_ShockTarget)
      • Set ShockCaster = (Triggering unit)
      • Set ShockDamage = (Real((Level of Shockwave for ShockCaster)))
      • Set ShockDistance = 5.00
      • Set ShockTime = 2.00
      • Set ShockLoc = (Position of ShockCaster)
      • Set ShockTarget = (Target point of ability being cast)
      • Set ShockAngle = (Angle from ShockLoc to ShockTarget)
      • Unit - Create 1 ShockEffect for (Owner of ShockCaster) at (ShockLoc offset by 5.00 towards ShockAngle degrees) facing ShockAngle degrees
      • Unit Group - Add (Last created unit) to ShockEffect
      • Hashtable - Save ShockAngle as 0 of (Key (Last created unit)) in Hashtable
      • Hashtable - Save ShockDamage as 1 of (Key (Last created unit)) in Hashtable
      • Hashtable - Save ShockDistance as 2 of (Key (Last created unit)) in Hashtable
      • Hashtable - Save Handle OfShockCaster as 3 of (Key (Last created unit)) in Hashtable
      • Hashtable - Save ShockTime as 4 of (Key (Last created unit)) in Hashtable
      • Trigger - Turn on Shockwave Loop <gen>
  • Shockwave Loop
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in ShockEffect and do (Actions)
        • Loop - Actions
          • Custom script: call RemoveLocation(udg_ShockLoc)
          • Custom script: call DestroyGroup(udg_ShockVictims)
          • Set ShockAngle = (Load 0 of (Key (Picked unit)) from Hashtable)
          • Set ShockDamage = (Load 1 of (Key (Picked unit)) from Hashtable)
          • Set ShockDistance = (Load 2 of (Key (Picked unit)) from Hashtable)
          • Set ShockCaster = (Load 3 of (Key (Picked unit)) in Hashtable)
          • Set ShockLoc = (Position of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ShockTime Greater than or equal to 0.04
            • Then - Actions
              • Unit - Move (Picked unit) instantly to (ShockLoc offset by ShockDistance towards ShockAngle degrees), facing ShockAngle degrees
              • Hashtable - Save (ShockDistance + 5.00) as 2 of (Key (Picked unit)) in (Last created hashtable)
              • Hashtable - Save (ShockTime - 0.04) as 4 of (Key (Picked unit)) in (Last created hashtable)
              • Set ShockVictims = (Units within 100.00 of ShockLoc matching (((Matching unit) belongs to an enemy of (Owner of ShockCaster)) Equal to True))
              • Unit Group - Pick every unit in ShockVictims and do (Actions)
                • Loop - Actions
                  • Unit - Cause ShockCaster to damage (Picked unit), dealing ShockDamage damage of attack type Spells and damage type Normal
            • Else - Actions
              • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in Hashtable
              • Unit Group - Remove (Picked unit) from ShockEffect
I attached the map and I hope someone can help me.
 

Attachments

  • Shockwave.w3x
    18.9 KB · Views: 65
It should be like this:
  • Trigger
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • Hashtable - Create a hashtable
    • Set Hashtable = (Last created hashtable)
    • Set ShockDistance = 5.00
    • Set ShockTime = 2.00
  • Shockwave init
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Shockwave
  • Actions
    • Set ShockCaster = (Triggering unit)
    • Set ShockDamage = (Real((Level of Shockwave for ShockCaster)))
    • Set Points[1] = (Position of ShockCaster)
    • Set Points[2] = (Target point of ability being cast)
    • Set Points[3] = (Points[1] offset by 128.00 towards (Angle from Points[1] to Points[2]))
    • Unit - Create 1 ShockEffect for (Owner of ShockCaster) at Points[3] facing (Angle from Points[1] to Points[2]) degrees
    • Unit Group - Add (Last created unit) to ShockEffect
    • Hashtable - Save ShockAngle as 0 of (Key (Last created unit)) in Hashtable
    • Hashtable - Save ShockDamage as 1 of (Key (Last created unit)) in Hashtable
    • Hashtable - Save Handle OfShockCaster as 3 of (Key (Last created unit)) in Hashtable
    • Hashtable - Save ShockTime as 4 of (Key (Last created unit)) in Hashtable
    • Custom script: call RemoveLocation (udg_Points[1])
    • Custom script: call RemoveLocation (udg_Points[2])
    • Custom script: call RemoveLocation (udg_Points[3])
    • Trigger - Turn on Shockwave Loop <gen>
  • Shockwave Loop
  • Events
    • Time - Every 0.04 seconds of game time
  • Conditions
  • Actions
    • If (All conditions are true) then do (Actions) else do (Actions)
      • If - Conditions
        • (ShockEffect is empty) Equal to False
      • Then - Actions
        • Unit Group - Pick every unit in ShockEffect and do (Actions)
          • Loop - Actions
            • Set ShockLoadTime = (Load 4 of (Key (Picked unit)) in Hashtable)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • ShockLoadTime Not Equal to 0
              • Then - Actions
                • Set ShockAngle = (Load 0 of (Key (Picked unit)) from Hashtable)
                • Set ShockDamage = (Load 1 of (Key (Picked unit)) from Hashtable)
                • Set ShockCaster = (Load 3 of (Key (Picked unit)) in Hashtable)
                • Set Points[4] = (Position of (Picked unit))
                • Set Points[5] = (Points[4] offset by ShockDistance towards (Facing of (Picked unit)))
                • Unit - Move (Picked unit) instantly to Points[5]
                • Hashtable - Save (ShockTime - 0.04) as 4 of (Key (Picked unit)) in Hashtable
                • Set ShockVictims = (Units within 100.00 of Points[4] matching (((Matching unit) belongs to an enemy of (Owner of (Picked unit)) Equal to True))
                • Unit Group - Pick every unit in ShockVictims and do (Actions)
                  • Loop - Actions
                    • Unit - Cause ShockCaster to damage (Picked unit), dealing ShockDamage damage of attack type Spells and damage type Normal
                • Custom script: call RemoveLocation (udg_Points[4])
                • Custom script: call RemoveLocation (udg_Points[5])
                • Custom script: call DestroyGroup (udg_ShockVictims)
              • Else - Actions
                • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in Hashtable
                • Unit Group - Remove (Picked unit) from ShockEffect
      • Else - Actions
        • Trigger - Turn off (This trigger)
• You are using ShockDistance and ShockTime as certain global values, with constant data: "5.00" for example. Non constant data would be (3 * (Level of (Ability being cast) for (Triggering unit))). This has to be set in the trigger, where the spell is casted, because level of ability can be different from unit to unit. When you are having static data though, like "5.00", you can set it in the Map Initialization.

• Since the constant data is constant, and cannot be changed, you do not need to save it to the dummy through the hashtable, because referring to this data will always result the same value, so it's just another useless bit of memory.

• In the second trigger, you suddenly stopped using "Hashtable", by replacing it with "Last created hashtable".

• You don't destroy the group you create (ShockVictims)

• When you are using many locations, use one location variable with array ticked: it's easier and takes less space in your Variable editor (Ctrl + B in the Triggers Editor).

• You never turn off the looping trigger. This might cause lag, after some point of the game.


And here is the map, fixed:
View attachment Shockwave2.w3x
 
Last edited:
Status
Not open for further replies.
Top