• 🏆 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] Death's Respite (WoW NPC spell); need help

Status
Not open for further replies.
Level 6
Joined
Sep 9, 2006
Messages
92
The idea of the spell is that it lifts the target up into the air for up to 2 seconds dealing damage. Moving stops you from raising the target. Once the target stops being raised, it is thrown from its position back a distance depending on the height it was raised (or rather how long it was being raised). It's composed of 4 total triggers plus an init to set some variables and create the hash: (would've had the triggers hide defaultly but I'm not sure how o_O)

  • init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set DR_Hash = (Last created hashtable)
      • Set DR_MaxTime = 2.00
      • Set DR_DmgConst = 0.90
      • Visibility - Disable fog of war
      • Visibility - Disable black mask
  • DR Init
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Death's Respite
    • Actions
      • Set DR_Index = (DR_Index + 1)
      • Hashtable - Save Handle Of(Target unit of ability being cast) as (Key Target) of DR_Index in DR_Hash
      • Hashtable - Save Handle Of(Triggering unit) as (Key Caster) of DR_Index in DR_Hash
      • Hashtable - Save 0.00 as (Key Time) of DR_Index in DR_Hash
      • Hashtable - Save False as (Key Throw) of DR_Index in DR_Hash
      • Hashtable - Save True as (Key Lifting) of DR_Index in DR_Hash
      • Hashtable - Save (Strength of (Triggering unit) (Include bonuses)) as (Key Str) of DR_Index in DR_Hash
      • Hashtable - Save (Intelligence of (Triggering unit) (Include bonuses)) as (Key Int) of DR_Index in DR_Hash
      • Hashtable - Save (Level of Death's Respite for (Triggering unit)) as (Key Lvl) of DR_Index in DR_Hash
      • Trigger - Turn on DR Lift <gen>
      • Trigger - Turn on DR Throw <gen>
      • Trigger - Turn on DR StopChanneling <gen>
      • Unit - Pause (Target unit of ability being cast)
  • DR Lift
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to DR_Index, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Load (Key Lifting) of (Integer A) from DR_Hash) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Load (Key Time) of (Integer A) from DR_Hash) Greater than DR_MaxTime
                • Then - Actions
                  • Hashtable - Save False as (Key Lifting) of (Integer A) in DR_Hash
                  • Unit - Unpause (Load (Key Target) of (Integer A) in DR_Hash)
                  • -------- Throw --------
                  • Hashtable - Save True as (Key Throw) of (Integer A) in DR_Hash
                  • Hashtable - Save (400.00 x (Load (Key Time) of (Integer A) from DR_Hash)) as (Key MaxDist) of (Integer A) in DR_Hash
                  • Hashtable - Save ((Load (Key MaxDist) of (Integer A) from DR_Hash) / 2.00) as (Key CurDist) of (Integer A) in DR_Hash
                  • Hashtable - Save (100.00 x (Load (Key Time) of (Integer A) from DR_Hash)) as (Key MaxHeight) of (Integer A) in DR_Hash
                  • Set TempPt = (Position of (Load (Key Target) of (Integer A) in DR_Hash))
                  • Set TempPt2 = (Position of (Load (Key Caster) of (Integer A) in DR_Hash))
                  • Hashtable - Save Handle Of(TempPt offset by (200.00 x (Load (Key Time) of (Integer A) from DR_Hash)) towards (Angle from TempPt2 to TempPt) degrees) as (Key EndPt) of (Integer A) in DR_Hash
                  • Hashtable - Save Handle OfTempPt as (Key TargetPt) of (Integer A) in DR_Hash
                  • Custom script: call RemoveLocation(udg_TempPt)
                  • Custom script: call RemoveLocation(udg_TempPt2)
                • Else - Actions
                  • Hashtable - Save ((Load (Key Time) of (Integer A) from DR_Hash) + 0.02) as (Key Time) of (Integer A) in DR_Hash
                  • Unit - Add Storm Crow Form to (Load (Key Target) of (Integer A) in DR_Hash)
                  • Animation - Change (Load (Key Target) of (Integer A) in DR_Hash) flying height to ((Current flying height of (Load (Key Target) of (Integer A) in DR_Hash)) + 2.00) at 1000000000.00
                  • Unit - Remove Storm Crow Form from (Load (Key Target) of (Integer A) in DR_Hash)
                  • Unit - Cause (Load (Key Caster) of (Integer A) in DR_Hash) to damage (Load (Key Target) of (Integer A) in DR_Hash), dealing ((((Real((Load (Key Int) of (Integer A) from DR_Hash))) + (Real((Load (Key Str) of (Integer A) from DR_Hash)))) x ((Real((Load (Key Lvl) of (Integer A) from DR_Hash))) x DR_DmgConst)) x 0.02) damage of attack type Magic and damage type Normal
            • Else - Actions
  • DR StopChanneling
    • Events
      • Unit - A unit Stops casting an ability
    • Conditions
      • (Ability being cast) Equal to Death's Respite
    • Actions
      • For each (Integer A) from 1 to DR_Index, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Triggering unit) Equal to (Load (Key Caster) of (Integer A) in DR_Hash)
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Load (Key Lifting) of (Integer A) from DR_Hash) Equal to True
                • Then - Actions
                  • Hashtable - Save False as (Key Lifting) of (Integer A) in DR_Hash
                  • Unit - Unpause (Load (Key Target) of (Integer A) in DR_Hash)
                  • -------- Throw --------
                  • Hashtable - Save True as (Key Throw) of (Integer A) in DR_Hash
                  • Hashtable - Save (400.00 x (Load (Key Time) of (Integer A) from DR_Hash)) as (Key MaxDist) of (Integer A) in DR_Hash
                  • Hashtable - Save ((Load (Key MaxDist) of (Integer A) from DR_Hash) / 2.00) as (Key CurDist) of (Integer A) in DR_Hash
                  • Hashtable - Save (100.00 x (Load (Key Time) of (Integer A) from DR_Hash)) as (Key MaxHeight) of (Integer A) in DR_Hash
                  • Set TempPt = (Position of (Load (Key Target) of (Integer A) in DR_Hash))
                  • Set TempPt2 = (Position of (Load (Key Caster) of (Integer A) in DR_Hash))
                  • Hashtable - Save Handle Of(TempPt offset by (200.00 x (Load (Key Time) of (Integer A) from DR_Hash)) towards (Angle from TempPt2 to TempPt) degrees) as (Key EndPt) of (Integer A) in DR_Hash
                  • Hashtable - Save Handle OfTempPt as (Key TargetPt) of (Integer A) in DR_Hash
                  • Custom script: call RemoveLocation(udg_TempPt)
                  • Custom script: call RemoveLocation(udg_TempPt2)
                • Else - Actions
            • Else - Actions
  • DR Throw
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to DR_Index, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Load (Key Throw) of (Integer A) from DR_Hash) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Load (Key MaxDist) of (Integer A) from DR_Hash) Greater than (Load (Key CurDist) of (Integer A) from DR_Hash)
                • Then - Actions
                  • Set TempPt = (Load (Key TargetPt) of (Integer A) in DR_Hash)
                  • Set TempPt2 = (TempPt offset by 6.00 towards (Angle from (Load (Key TargetPt) of (Integer A) in DR_Hash) to (Load (Key EndPt) of (Integer A) in DR_Hash)) degrees)
                  • Hashtable - Save Handle OfTempPt2 as (Key TargetPt) of (Integer A) in DR_Hash
                  • Hashtable - Save ((Load (Key CurDist) of (Integer A) from DR_Hash) + 6.00) as (Key CurDist) of (Integer A) in DR_Hash
                  • Set DR_TempReal = (((4.00 x (Load (Key MaxHeight) of (Integer A) from DR_Hash)) / (Load (Key MaxDist) of (Integer A) from DR_Hash)) x (((Load (Key MaxDist) of (Integer A) from DR_Hash) - (Load (Key CurDist) of (Integer A) from DR_Hash)) x ((Load (Key CurDist) of (Integer A) fr
                  • Unit - Move (Load (Key Target) of (Integer A) in DR_Hash) instantly to (Load (Key TargetPt) of (Integer A) in DR_Hash)
                  • Unit - Add Storm Crow Form to (Load (Key Target) of (Integer A) in DR_Hash)
                  • Animation - Change (Load (Key Target) of (Integer A) in DR_Hash) flying height to DR_TempReal at 1000000000.00
                  • Unit - Remove Storm Crow Form from (Load (Key Target) of (Integer A) in DR_Hash)
                  • Custom script: call RemoveLocation(udg_TempPt)
                  • Custom script: call RemoveLocation(udg_TempPt2)
                • Else - Actions
                  • Unit - Add Storm Crow Form to (Load (Key Target) of (Integer A) in DR_Hash)
                  • Animation - Change (Load (Key Target) of (Integer A) in DR_Hash) flying height to 0.00 at 1000000000.00
                  • Unit - Remove Storm Crow Form from (Load (Key Target) of (Integer A) in DR_Hash)
                  • Hashtable - Clear all child hashtables of child (Integer A) in DR_Hash
                  • Set TempBool = False
                  • For each (Integer B) from 1 to DR_Index, do (Actions)
                    • Loop - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Load (Key Caster) of (Integer B) in DR_Hash) Not equal to No unit
                        • Then - Actions
                          • Set TempBool = True
                        • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • TempBool Equal to True
                    • Then - Actions
                    • Else - Actions
                      • Set DR_Index = 0
            • Else - Actions
(Last 3 triggers are default off) So, what the trigger DOES do is it lifts the target for up to 2 seconds and is canceled when the caster stops channeling. Once that happens, its supposed to toss the unit back from where it is, starting the unit's travel path parallel to the ground and going down towards the ground like half of a parabola. It DOES reduce the target's height over time, however it does NOT toss the unit back; instead the unit is tossed to the center of the map (aka undefined point?).
How do i fix it so it gets tossed back? (also, does my way of resetting the index make sense/work? I threw it together last minuite just to give it something; i thought the only other way would be to have 2 indices)
 
Level 9
Joined
Dec 12, 2007
Messages
489
from what I can tell about your problem for now is that:
in trigger DR Lift
  • Hashtable - Save Handle OfTempPt as (Key TargetPt) of (Integer A) in DR_Hash
  • Custom script: call RemoveLocation(udg_TempPt)
you save the location in hashtable but then remove it, that makes it return null value when you load it on DR Throw.
 
Level 6
Joined
Sep 9, 2006
Messages
92
Just a small hint:

  • Animation - Change (Load (Key Target) of (Integer A) in DR_Hash) flying height to 0.00 at 1000000000.00
...at 0 is instant.

kk ill use that now, and at the above poster, do i not need to create temp points and create the hash based off of it? (since the hash is destroyed anyway, according to whats happening any temp point removed destroys the hash too because it'd dependent on it; it seems that would leak though)
 
Level 9
Joined
Dec 12, 2007
Messages
489
sorry for reply late...
well, you can just not remove the location TempPt in the DR Lift or set it to null...
the temp variable itself can be assigned to new value because the hashtable has already save the reference of the old value...
or in simple way: just don't remove the location or handle when it is still used, even though it has been saved to hashtable.
 
Level 8
Joined
Apr 30, 2009
Messages
338
sorry for reply late...
well, you can just not remove the location TempPt in the DR Lift or set it to null...
the temp variable itself can be assigned to new value because the hashtable has already save the reference of the old value...
or in simple way: just don't remove the location or handle when it is still used, even though it has been saved to hashtable.

So the handle is destroyed when he clears the hashtable, preventing leaks even though he doesn't use RemoveLocation?
 
Status
Not open for further replies.
Top