Frost Step Problem.

Status
Not open for further replies.
Level 1
Joined
Nov 28, 2014
Messages
4
So I'm trying to create an ability similar to a dash, It should send my Hero a few points forward and I have no clue where I'm wrong, I'm certain its like a spelling error or a NULL function.. Any Help?

Main Trigger-

  • FrostStepMAIN
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Frost Step
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • FrostStepINT[0] Equal to 0
        • Then - Actions
          • Trigger - Turn on FrostStepLOOP <gen>
        • Else - Actions
          • Set FrostStepINT[0] = (FrostStepINT[0] + 1)
          • Set FrostStepINT[1] = (FrostStepINT[1] + 1)
          • Set FrostStepCaster[FrostStepINT[1]] = (Triggering unit)
          • Unit - Pause (Triggering unit)
          • Set FrostStepReal1[FrostStepINT[1]] = (Facing of FrostStepCaster[FrostStepINT[1]])
          • Set FrostStepFrostbite[FrostStepINT[1]] = (Level of (Ability being cast) for FrostStepCaster[FrostStepINT[1]])
          • Set FrostStepSpeed[FrostStepINT[1]] = 70.00
          • Set FrostStepDistance[FrostStepINT[1]] = 130
          • Custom script: call SetUnitAnimationByIndex (udg_FrostStepCaster[udg_FrostStepINT[1]] , 2)
          • Animation - Play FrostStepCaster[FrostStepINT[1]]'s walk animation
          • Unit - Turn collision for FrostStepCaster[FrostStepINT[1]] Off
Loop-
  • FrostStepLOOP
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer FrostStepINT[2]) from 1 to FrostStepINT[1], do (Actions)
        • Loop - Actions
          • Set FrostStepDistance[FrostStepINT[2]] = FrostStepDistance[(FrostStepINT[2] - 1)]
          • Set FrostStepPoint3[FrostStepINT[2]] = (Position of FrostStepCaster[FrostStepINT[2]])
          • Set FrostStepPoint4[FrostStepINT[2]] = (FrostStepPoint3[FrostStepINT[2]] offset by FrostStepSpeed[FrostStepINT[2]] towards FrostStepReal1[FrostStepINT[2]] degrees)
          • Unit - Move FrostStepCaster[FrostStepINT[2]] instantly to FrostStepPoint4[FrostStepINT[2]], facing (Facing of FrostStepCaster[FrostStepINT[2]]) degrees
          • Unit - Create 1 SneedyDummy for (Owner of FrostStepCaster[FrostStepINT[2]]) at FrostStepPoint4[FrostStepINT[2]] facing (Facing of FrostStepCaster[FrostStepINT[2]]) degrees
          • Unit - Add a 0.50 second Generic expiration timer to (Last created unit)
          • Unit Group - Add (Last created unit) to FrostStepGroup3
          • Animation - Play (Last created unit)'s walk animation
          • Custom script: set bj_wantDestroyGroup=true
          • Unit Group - Pick every unit in FrostStepGroup3 and do (Actions)
            • Loop - Actions
              • Set FrostStepPoint5[FrostStepINT[2]] = (Position of (Picked unit))
              • Set FrostStepReal2[FrostStepINT[2]] = ((Distance between FrostStepPoint3[FrostStepINT[2]] and FrostStepPoint5[FrostStepINT[2]]) / 5.00)
              • Animation - Change (Picked unit)'s vertex coloring to (50.00%, 50.00%, 100.00%) with FrostStepReal2[FrostStepINT[2]]% transparency
          • Set FrostStepGroup1 = (Units within 200.00 of FrostStepPoint4[FrostStepINT[2]] matching ((((Matching unit) belongs to an enemy of (Owner of FrostStepCaster[FrostStepINT[2]])) Equal to True) and (((Matching unit) is in FrostStepGroup2) Equal to False)))
          • Unit Group - Pick every unit in FrostStepGroup1 and do (Actions)
            • Loop - Actions
              • Unit Group - Add (Picked unit) to FrostStepGroup2
          • Unit Group - Pick every unit in FrostStepGroup2 and do (Actions)
            • Loop - Actions
              • Unit - Create 1 SneedyDummy for (Owner of FrostStepCaster[FrostStepINT[2]]) at (Position of (Picked unit)) facing Default building facing degrees
              • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
              • Unit - Add Frostbite to (Last created unit)
              • Unit - Order (Last created unit) to Night Elf Keeper Of The Grove - Entangling Roots (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • FrostStepDistance[FrostStepINT[2]] Less than or equal to 0
                  • (Terrain pathing at FrostStepPoint3[FrostStepINT[2]] of type Walkability is off) Equal to True
            • Then - Actions
              • For each (Integer FrostStepINT[2]) from 1 to FrostStepINT[1], do (Actions)
                • Loop - Actions
                  • Unit - Turn collision for FrostStepCaster[FrostStepINT[2]] On
                  • Unit - Unpause FrostStepCaster[FrostStepINT[2]]
              • Set FrostStepINT[1] = 0
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • FrostStepINT[0] Equal to 0
                • Then - Actions
                  • Set FrostStepINT[1] = 0
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
              • Custom script: call RemoveLocation (udg_FrostStepPoint3[udg_FrostStepINT[2]])
              • Custom script: call RemoveLocation (udg_FrostStepPoint4[udg_FrostStepINT[2]])
              • Custom script: call DestroyGroup (udg_FrostStepGroup1)
I know this might not be the correct place to post this Thread, my Base Spell is based on Thunder Clap.
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
  • FrostStepMAIN
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Frost Step
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • FrostStepINT[0] Equal to 0
        • Then - Actions
          • Trigger - Turn on FrostStepLOOP <gen>
        • Else - Actions
      • Set FrostStepINT[0] = (FrostStepINT[0] + 1)
      • Set FrostStepINT[1] = (FrostStepINT[1] + 1)
      • Set FrostStepCaster[FrostStepINT[1]] = (Triggering unit)
      • ...

You are leaking locations badly in the looping trigger. I also suggest not using an array within an array for point 3 and 4. Just use two non array variables.
 
Level 7
Joined
May 11, 2010
Messages
278
I see a "slight" issue with the main trigger.
It EITHER turns on the loop OR sets the variables.
Move the actions currently under "else" to be outside of the "if/then/else" section.

Edit: oops, maker had already pointed this out.
 
Level 1
Joined
Nov 28, 2014
Messages
4
How would I Fix the Location leak? Sorry I'm still learning.

I fixed the main trigger and now I only go a short distance.
 
Level 29
Joined
Sep 26, 2009
Messages
2,594
You already are destroying those locations. The problem is that you destroy only part of them.

You leak FrostStepPoint3[] and FrostStepPoint4[] when the instance ends. If you look at your code then it is:
Code:
If (Conditions)
    Distance is 0.00 or walkability at location is off
Then (Actions)
    Turn collision for caster and unpause caster
Else (Actions)
    Destroy locations FrostStepPoint3[] and FrostStepPoit4[]
As you can see, itbecomes a problem if the conditions are true, since then you don't destroy those locations.

Now the main problem is this: The location FrostStepPoint5[FrostStepINT[2]] will leak really bad.
For each active instance of the spell you pick units in FrostStepGroup3 and for each picked unit you create location (saved in FrostStepPoint5[]) without destroying it. Let's say you have 5 instances of the spell. The instances have this number of units in FrostStepGroup3 group: 3, 2, 5, 4, 4.
The trigger creates location for each of the picked units in the group. So basically every 0.03 seconds you make 3+2+5+4+4 = 18 location leaks which is 600 memory leaks per second. That is a lot!
The worst thing about this part is that each instance can have up to 16 units in the unit group! (And that is only if the unit is immediately removed after death, else the number raises)
So the total amount of units for three instances would be 48! That's 1600 memory leaks per second!
I also don't see you decreasing FrostStepINT[0] variable anywhere - you only increase its value, so the conditions "FrostStepINT[0] == 0" should never be true, hence the loop should never end.

You probably don't want to turn collision off for each and every instance if only one instance (= one caster) got to a location with walkability off.
I also don't see you deindexing anything anywhere, nor checking if an instance is active or not.

It's really messily done ATM with you rewriting various variables that you still use elsewhere, etc.
I would advise complete rework :x
 
Status
Not open for further replies.
Top