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

[Spell] Removing Locations not working.

Status
Not open for further replies.
Level 4
Joined
Jun 30, 2014
Messages
72
It seems like the call: RemoveLocation doesn't recognize the point array set by using the Integer A Loop. Can someone confirm that that's the problem?

(Can someone confirm that setting each of an array's index slots in this way will work?)

I mean, this worked just fine until I added the "Clean Leaks" part and wanted a fast way to set 10 or so "Point with Polar Offset" to a variable so I can remove those locations, otherwise repeated use of this spell might make tons of leaks.

Leap Skill 1
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Leap (Dummy, channel, Crow transition
Actions
-------- Faces Caster Toward Target --------
Unit - Make (Casting unit) face (Target point of ability being cast) over 0.00 seconds
-------- Set Variables --------
Set Leaper = (Casting unit)
Set LeapOrigin = (Position of (Casting unit))
Set LeapTarget = (Target point of ability being cast)
Set LeapFacing = (Facing of Leaper)
Set LeapMoveAngle = (LeapFacing + 180.00)
Set LeapDist = (Distance between LeapOrigin and LeapTarget)
Set LeapStep[0] = (LeapDist / 10.00)
Set LeapStep[1] = (LeapStep[0] + LeapStep[1])
Set LeapStep[2] = (LeapStep[1] + LeapStep[1])
Set LeapStep[3] = (LeapStep[2] + LeapStep[1])
Set LeapStep[4] = (LeapStep[3] + LeapStep[1])
Set LeapStep[5] = (LeapStep[4] + LeapStep[1])
Set LeapStep[6] = (LeapStep[5] + LeapStep[1])
Set LeapStep[7] = (LeapStep[6] + LeapStep[1])
Set LeapStep[8] = (LeapStep[7] + LeapStep[1])
Set LeapStep[9] = (LeapStep[8] + LeapStep[1])
Set LeapStep[10] = (LeapStep[9] + LeapStep[1])
For each (Integer A) from 1 to 10, do (Actions)
Loop - Actions
Set LeapTemps[(Integer A)] = (LeapTarget offset by LeapStep[(Integer A)] towards LeapMoveAngle degrees)
-------- Leap Action --------
Unit - Pause Leaper
Unit - Turn collision for Leaper Off
Unit - Add Crow Form to Leaper
-------- Repeat These 3 Actions For Each "Step" --------
Animation - Change Leaper flying height to Leap_Height_Increment at 900.00
Unit - Move Leaper instantly to LeapTemps[10], facing LeapFacing degrees
Wait 0.01 seconds
Animation - Change Leaper flying height to (Leap_Height_Increment x 2.00) at 900.00
Unit - Move Leaper instantly to LeapTemps[9], facing LeapFacing degrees
Wait 0.01 seconds
Animation - Change Leaper flying height to (Leap_Height_Increment x 3.00) at 900.00
Unit - Move Leaper instantly to LeapTemps[8], facing LeapFacing degrees
Wait 0.01 seconds
Animation - Change Leaper flying height to (Leap_Height_Increment x 4.00) at 950.00
Unit - Move Leaper instantly to LeapTemps[7], facing LeapFacing degrees
Wait 0.01 seconds
Animation - Change Leaper flying height to (Leap_Height_Increment x 5.00) at 950.00
Unit - Move Leaper instantly to LeapTemps[6], facing LeapFacing degrees
Wait 0.20 seconds
Animation - Change Leaper flying height to 600.00 at 950.00
Wait 0.20 seconds
Animation - Change Leaper flying height to (Leap_Height_Increment x 5.00) at 950.00
Unit - Move Leaper instantly to LeapTemps[5], facing LeapFacing degrees
Wait 0.01 seconds
Animation - Change Leaper flying height to (Leap_Height_Increment x 4.00) at 950.00
Unit - Move Leaper instantly to LeapTemps[4], facing LeapFacing degrees
Wait 0.01 seconds
Animation - Change Leaper flying height to (Leap_Height_Increment x 3.00) at 900.00
Unit - Move Leaper instantly to LeapTemps[3], facing LeapFacing degrees
Wait 0.01 seconds
Animation - Change Leaper flying height to (Leap_Height_Increment x 3.00) at 900.00
Unit - Move Leaper instantly to LeapTemps[2], facing LeapFacing degrees
Wait 0.01 seconds
Animation - Change Leaper flying height to (Leap_Height_Increment x 2.00) at 900.00
Unit - Move Leaper instantly to LeapTemps[1], facing LeapFacing degrees
Wait 0.01 seconds
Animation - Change Leaper flying height to Leap_Height_Increment at 950.00
Unit - Move Leaper instantly to LeapTemps[0], facing LeapFacing degrees
Wait 0.01 seconds
Animation - Change Leaper flying height to 0.00 at 950.00
Unit - Move Leaper instantly to LeapTarget, facing LeapFacing degrees
Wait 0.20 seconds
Unit - Remove Crow Form from Leaper
Unit - Unpause Leaper
Unit - Turn collision for Leaper On
-------- Clean Leaks --------
Custom script: call RemoveLocation(udg_LeapTarget)
Custom script: call RemoveLocation(udg_LeapOrigin)
Custom script: call RemoveLocation(udg_LeapTemps[udg_1])
Custom script: call RemoveLocation(udg_LeapTemps[udg_2])
Custom script: call RemoveLocation(udg_LeapTemps[udg_3])
Custom script: call RemoveLocation(udg_LeapTemps[udg_4])
Custom script: call RemoveLocation(udg_LeapTemps[udg_5])
Custom script: call RemoveLocation(udg_LeapTemps[udg_6])
Custom script: call RemoveLocation(udg_LeapTemps[udg_7])
Custom script: call RemoveLocation(udg_LeapTemps[udg_8])
Custom script: call RemoveLocation(udg_LeapTemps[udg_9])
Custom script: call RemoveLocation(udg_LeapTemps[udg_10])


Edit: Should this be re-posted to "Triggers&Scripts"?
 
Last edited:
Level 18
Joined
May 11, 2012
Messages
2,103
  • Leap Skill 1
  • Events
  • Unit - A unit Starts the effect of an ability
  • Conditions
  • (Ability being cast) Equal to Leap (Dummy, channel, Crow transition
  • Actions
  • -------- Faces Caster Toward Target --------
  • Unit - Make (Casting unit) face (Target point of ability being cast) over 0.00 seconds
  • -------- Set Variables --------
  • Set Leaper = (Casting unit)
  • Set LeapOrigin = (Position of (Casting unit))
  • Set LeapTarget = (Target point of ability being cast)
  • Set LeapFacing = (Facing of Leaper)
  • Set LeapMoveAngle = (LeapFacing + 180.00)
  • Set LeapDist = (Distance between LeapOrigin and LeapTarget)
  • Set LeapStep[0] = (LeapDist / 10.00)
  • Set LeapStep[1] = (LeapStep[0] + LeapStep[1])
  • Set LeapStep[2] = (LeapStep[1] + LeapStep[1])
  • Set LeapStep[3] = (LeapStep[2] + LeapStep[1])
  • Set LeapStep[4] = (LeapStep[3] + LeapStep[1])
  • Set LeapStep[5] = (LeapStep[4] + LeapStep[1])
  • Set LeapStep[6] = (LeapStep[5] + LeapStep[1])
  • Set LeapStep[7] = (LeapStep[6] + LeapStep[1])
  • Set LeapStep[8] = (LeapStep[7] + LeapStep[1])
  • Set LeapStep[9] = (LeapStep[8] + LeapStep[1])
  • Set LeapStep[10] = (LeapStep[9] + LeapStep[1])
  • For each (Integer A) from 1 to 10, do (Actions)
  • Loop - Actions
  • Set LeapTemps[(Integer A)] = (LeapTarget offset by LeapStep[(Integer A)] towards LeapMoveAngle degrees)
  • -------- Leap Action --------
  • Unit - Pause Leaper
  • Unit - Turn collision for Leaper Off
  • Unit - Add Crow Form to Leaper
  • -------- Repeat These 3 Actions For Each "Step" --------
  • Animation - Change Leaper flying height to Leap_Height_Increment at 900.00
  • Unit - Move Leaper instantly to LeapTemps[10], facing LeapFacing degrees
  • Wait 0.01 seconds
  • Animation - Change Leaper flying height to (Leap_Height_Increment x 2.00) at 900.00
  • Unit - Move Leaper instantly to LeapTemps[9], facing LeapFacing degrees
  • Wait 0.01 seconds
  • Animation - Change Leaper flying height to (Leap_Height_Increment x 3.00) at 900.00
  • Unit - Move Leaper instantly to LeapTemps[8], facing LeapFacing degrees
  • Wait 0.01 seconds
  • Animation - Change Leaper flying height to (Leap_Height_Increment x 4.00) at 950.00
  • Unit - Move Leaper instantly to LeapTemps[7], facing LeapFacing degrees
  • Wait 0.01 seconds
  • Animation - Change Leaper flying height to (Leap_Height_Increment x 5.00) at 950.00
  • Unit - Move Leaper instantly to LeapTemps[6], facing LeapFacing degrees
  • Wait 0.20 seconds
  • Animation - Change Leaper flying height to 600.00 at 950.00
  • Wait 0.20 seconds
  • Animation - Change Leaper flying height to (Leap_Height_Increment x 5.00) at 950.00
  • Unit - Move Leaper instantly to LeapTemps[5], facing LeapFacing degrees
  • Wait 0.01 seconds
  • Animation - Change Leaper flying height to (Leap_Height_Increment x 4.00) at 950.00
  • Unit - Move Leaper instantly to LeapTemps[4], facing LeapFacing degrees
  • Wait 0.01 seconds
  • Animation - Change Leaper flying height to (Leap_Height_Increment x 3.00) at 900.00
  • Unit - Move Leaper instantly to LeapTemps[3], facing LeapFacing degrees
  • Wait 0.01 seconds
  • Animation - Change Leaper flying height to (Leap_Height_Increment x 3.00) at 900.00
  • Unit - Move Leaper instantly to LeapTemps[2], facing LeapFacing degrees
  • Wait 0.01 seconds
  • Animation - Change Leaper flying height to (Leap_Height_Increment x 2.00) at 900.00
  • Unit - Move Leaper instantly to LeapTemps[1], facing LeapFacing degrees
  • Wait 0.01 seconds
  • Animation - Change Leaper flying height to Leap_Height_Increment at 950.00
  • Unit - Move Leaper instantly to LeapTemps[0], facing LeapFacing degrees
  • Wait 0.01 seconds
  • Animation - Change Leaper flying height to 0.00 at 950.00
  • Unit - Move Leaper instantly to LeapTarget, facing LeapFacing degrees
  • Wait 0.20 seconds
  • Unit - Remove Crow Form from Leaper
  • Unit - Unpause Leaper
  • Unit - Turn collision for Leaper On
  • -------- Clean Leaks --------
  • For each (Integer A) from 1 to 10, do (Actions)
  • Loop - Actions
  • Custom script: call RemoveLocation(udg_LeapTarget)
  • Custom script: call RemoveLocation(udg_LeapOrigin)
  • Custom script: call RemoveLocation(udg_LeapTemps[GetForLoopAIndex()])
  • Custom script: set udg_LeapTemps[GetForLoopAIndex()] = null
This should clean your leaks, and also I recommend creating custom int variable and use that instead of Integer A. It's faster and more efficient.

Custom int example:
  • For each (tempInt) from 1 to 10, do (Actions)
  • Loop - Actions
  • Set LeapTemps[tempInt] = (LeapTarget offset by LeapStep[tempInt] towards LeapMoveAngle degrees)
And then you will use:
  • Custom script: call RemoveLocation(udg_LeapTemps[udg_tempInt])
And yes, this should go to T&S's.
Next time when posting triggers, wrap them in tags.
 
Level 4
Joined
Jun 30, 2014
Messages
72
Um...

Still gives error message for this trigger. What is obvious to you is not always obvious to me.

  • Leap Skill 1
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Leap (Dummy, channel, Crow transition
    • Actions
      • -------- Faces Caster Toward Target --------
      • Unit - Make (Casting unit) face (Target point of ability being cast) over 0.00 seconds
      • -------- Set Variables --------
      • Set Leaper = (Casting unit)
      • Set LeapOrigin = (Position of (Casting unit))
      • Set LeapTarget = (Target point of ability being cast)
      • Set LeapFacing = (Facing of Leaper)
      • Set LeapMoveAngle = (LeapFacing + 180.00)
      • Set LeapDist = (Distance between LeapOrigin and LeapTarget)
      • Set LeapStep[0] = (LeapDist / 10.00)
      • Set LeapStep[1] = (LeapStep[0] + LeapStep[1])
      • Set LeapStep[2] = (LeapStep[1] + LeapStep[1])
      • Set LeapStep[3] = (LeapStep[2] + LeapStep[1])
      • Set LeapStep[4] = (LeapStep[3] + LeapStep[1])
      • Set LeapStep[5] = (LeapStep[4] + LeapStep[1])
      • Set LeapStep[6] = (LeapStep[5] + LeapStep[1])
      • Set LeapStep[7] = (LeapStep[6] + LeapStep[1])
      • Set LeapStep[8] = (LeapStep[7] + LeapStep[1])
      • Set LeapStep[9] = (LeapStep[8] + LeapStep[1])
      • Set LeapStep[10] = (LeapStep[9] + LeapStep[1])
      • For each (Integer LeapInt) from 1 to 10, do (Actions)
        • Loop - Actions
          • Set LeapTemps[LeapInt] = (LeapTarget offset by LeapStep[LeapInt] towards LeapMoveAngle degrees)
      • -------- Leap Action --------
      • Unit - Pause Leaper
      • Unit - Turn collision for Leaper Off
      • Unit - Add Crow Form to Leaper
      • -------- Repeat These 3 Actions For Each "Step" --------
      • Animation - Change Leaper flying height to Leap_Height_Increment at 900.00
      • Unit - Move Leaper instantly to LeapTemps[10], facing LeapFacing degrees
      • Wait 0.01 seconds
      • Animation - Change Leaper flying height to (Leap_Height_Increment x 2.00) at 900.00
      • Unit - Move Leaper instantly to LeapTemps[9], facing LeapFacing degrees
      • Wait 0.01 seconds
      • Animation - Change Leaper flying height to (Leap_Height_Increment x 3.00) at 900.00
      • Unit - Move Leaper instantly to LeapTemps[8], facing LeapFacing degrees
      • Wait 0.01 seconds
      • Animation - Change Leaper flying height to (Leap_Height_Increment x 4.00) at 950.00
      • Unit - Move Leaper instantly to LeapTemps[7], facing LeapFacing degrees
      • Wait 0.01 seconds
      • Animation - Change Leaper flying height to (Leap_Height_Increment x 5.00) at 950.00
      • Unit - Move Leaper instantly to LeapTemps[6], facing LeapFacing degrees
      • Wait 0.20 seconds
      • Animation - Change Leaper flying height to 600.00 at 950.00
      • Wait 0.20 seconds
      • Animation - Change Leaper flying height to (Leap_Height_Increment x 5.00) at 950.00
      • Unit - Move Leaper instantly to LeapTemps[5], facing LeapFacing degrees
      • Wait 0.01 seconds
      • Animation - Change Leaper flying height to (Leap_Height_Increment x 4.00) at 950.00
      • Unit - Move Leaper instantly to LeapTemps[4], facing LeapFacing degrees
      • Wait 0.01 seconds
      • Animation - Change Leaper flying height to (Leap_Height_Increment x 3.00) at 900.00
      • Unit - Move Leaper instantly to LeapTemps[3], facing LeapFacing degrees
      • Wait 0.01 seconds
      • Animation - Change Leaper flying height to (Leap_Height_Increment x 3.00) at 900.00
      • Unit - Move Leaper instantly to LeapTemps[2], facing LeapFacing degrees
      • Wait 0.01 seconds
      • Animation - Change Leaper flying height to (Leap_Height_Increment x 2.00) at 900.00
      • Unit - Move Leaper instantly to LeapTemps[1], facing LeapFacing degrees
      • Wait 0.01 seconds
      • Animation - Change Leaper flying height to Leap_Height_Increment at 950.00
      • Unit - Move Leaper instantly to LeapTemps[0], facing LeapFacing degrees
      • Wait 0.01 seconds
      • Animation - Change Leaper flying height to 0.00 at 950.00
      • Unit - Move Leaper instantly to LeapTarget, facing LeapFacing degrees
      • Wait 0.20 seconds
      • Unit - Remove Crow Form from Leaper
      • Unit - Unpause Leaper
      • Unit - Turn collision for Leaper On
      • -------- Clean Leaks --------
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
      • Custom script: call RemoveLocation(udg_LeapTarget)
      • Custom script: call RemoveLocation(udg_LeapOrigin)
      • Custom script: call RemoveLocation(udg_LeapTemps[LeapInt])
      • Custom script: call RemoveLocation(udg_LeapTemps[GetForLoopAIndex()])
      • Custom script: set udg_LeapTemps[GetForLoopAIndex()] = null
 
Level 18
Joined
May 11, 2012
Messages
2,103
You forgot udg_ inside.

(udg_LeapTemps[udg_LeapInt])

Yeah, tempInt is global, so it needs to be udg_tempInt inside [] brackets.
  • Custom script: call RemoveLocation(udg_LeapTarget)
    • Custom script: call RemoveLocation(udg_LeapOrigin)
Put this outside your loop in the end of your trigger. Also, change that loop so it uses tempInt, and change both of [GetForLoopAIndex()] into [udg_tempInt].
 
Level 19
Joined
Jul 14, 2011
Messages
875
  • For each (LeapInt) from 1 to 10, do (Actions)
    • Loop - Actions
      • Custom script: call RemoveLocation(udg_LeapTemps[udg_LeapInt])
      • Custom script: set udg_LeapTemps[udg_LeapInt] = null
  • Custom script: call RemoveLocation(udg_LeapTarget)
  • Custom script: call RemoveLocation(udg_LeapOrigin)
  • You hadnt put anything in the loop.
  • You were missing an 'udg_' before LeapInt.
  • You were still using GetForLoopAIndex().
  • You were still using (Integer A) instead of (LeapInt) in your loop.
  • You were removing a location twice.

E:You could also compact this:
  • Set LeapStep[0] = (LeapDist / 10.00)
  • Set LeapStep[1] = (LeapStep[0] + LeapStep[1])
  • Set LeapStep[2] = (LeapStep[1] + LeapStep[1])
  • Set LeapStep[3] = (LeapStep[2] + LeapStep[1])
  • Set LeapStep[4] = (LeapStep[3] + LeapStep[1])
  • Set LeapStep[5] = (LeapStep[4] + LeapStep[1])
  • Set LeapStep[6] = (LeapStep[5] + LeapStep[1])
  • Set LeapStep[7] = (LeapStep[6] + LeapStep[1])
  • Set LeapStep[8] = (LeapStep[7] + LeapStep[1])
  • Set LeapStep[9] = (LeapStep[8] + LeapStep[1])
  • Set LeapStep[10] = (LeapStep[9] + LeapStep[1])
Into this:
  • Set LeapStep[0] = (LeapDist / 10.00)
  • For each (LeapInt) from 1 to 10, do (Actions)
    • Loop - Actions
      • Set LeapStep[LeapInt] = (LeapStep[LeapInt - 1] + LeapStep[1])
 
Level 4
Joined
Jun 30, 2014
Messages
72
Just to clear something up...

Do I really need to set this to null?
LeapTemps and LeapInt are both globals (if global means set up in the variable editor as part of the map itself, then all my variables I can think of are. The rest are <gen> variables, as in things pre-placed on the map.)
  • Custom script: set udg_LeapTemps[udg_LeapInt] = null
I'm sure I've read somewhere on this site that global variables don't need to be set to null.

EDIT: Finally, no error messages! Thanks Hivers! Oh yeah, and a +rep for the help. (Just a note: Those LeapOrigin and LeapTarget removes have always been outside the loop, but what does Gismo mean by removing twice? They aren't the same point, if that's what was meant.)
 
Last edited:
Status
Not open for further replies.
Top