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

Leap spell lagging?

Status
Not open for further replies.
Level 8
Joined
Feb 17, 2007
Messages
368
I'm not sure why this is lagging and causing noticeable slowdown for a few seconds when its in progress and slightly after, does anyone see any leaks or something wrong? Oh and the weird thing is the lag does not seem to happen to all units who are targeted.

  • Actions
    • -------- Stores into variables Caster and Target --------
    • Set LeapCaster = (Triggering unit)
    • Set LeapTarget = (Target unit of ability being cast)
    • -------- Finds the Distance between the Caster and Target --------
    • Set LeapPoints[1] = (Position of LeapCaster)
    • Set LeapPoints[2] = (Position of LeapTarget)
    • Set LeapReal[1] = (Distance between LeapPoints[1] and LeapPoints[2])
    • -------- Counts up the range at which the Caster shall start landing --------
    • Set LeapReal[2] = (LeapReal[1] / 2.00)
    • -------- Creates a trail SFX and instantly destroys it, removing leak --------
    • -------- Stores target into Hashtable --------
    • Hashtable - Save Handle OfLeapTarget as 0 of (Key (Triggering unit)) in LeapHashtable
    • -------- Stores the Distance-to-jump and distance at which the Caster shall start landing --------
    • Hashtable - Save LeapReal[1] as 1 of (Key (Triggering unit)) in LeapHashtable
    • Hashtable - Save LeapReal[2] as 2 of (Key (Triggering unit)) in LeapHashtable
    • Unit - Turn collision for LeapCaster Off
    • -------- Checks if there is any instance of spell already in effect --------
    • -------- If not, turns the Loop trigger on --------
    • If ((Leapers is empty) Equal to True) then do (Trigger - Turn on Leap Loop <gen>) else do (Do nothing)
    • -------- Adds the Caster into Leapers' group --------
    • Unit Group - Add LeapCaster to Leapers
    • -------- Removes leaks --------
    • Custom script: call RemoveLocation(udg_LeapPoints[1])
    • Custom script: call RemoveLocation(udg_LeapPoints[2])
  • Actions
    • Unit Group - Pick every unit in Leapers and do (Actions)
      • Loop - Actions
        • -------- Stores Target and Caster into variables --------
        • Set LeapTarget = (Load 0 of (Key (Picked unit)) in LeapHashtable)
        • Set LeapCaster = (Picked unit)
        • -------- Finds the locations of Caster and Target --------
        • Set LeapPoints[1] = (Position of LeapCaster)
        • Set LeapPoints[2] = (Position of LeapTarget)
        • -------- Finds a location to which the Caster would be moved --------
        • -------- NOTE 1: Here change your speed --------
        • -------- NOTE 2: Speed is counted by dividing your real number into trigger's loop interval --------
        • -------- NOTE 3: My speed is 40/0.04=1000 units per second --------
        • Set LeapPoints[3] = (LeapPoints[1] offset by 50.00 towards (Angle from LeapPoints[1] to LeapPoints[2]) degrees)
        • -------- Loads the Distance at which caster would start landing --------
        • Set LeapReal[1] = (Load 2 of (Key (Picked unit)) from LeapHashtable)
        • -------- Counts the Distance between caster and target --------
        • Set LeapReal[2] = (Distance between LeapPoints[1] and LeapPoints[2])
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • LeapReal[2] Greater than or equal to 120.00
          • Then - Actions
            • -------- If distance between caster and target is greater than 120, then... --------
            • -------- Moves caster to Points[3] --------
            • Unit - Move LeapCaster instantly to LeapPoints[3], facing LeapPoints[2]
            • -------- Increases/decreases the flying heigh of Caster --------
            • -------- NOTE 4: Here it checks if the Distance between Caster and Target is greater than Distance at which Caster should start landing --------
            • -------- If yes, then it increases the flying height of the caster, else reduces it by equal amount --------
            • If (LeapReal[2] Greater than or equal to LeapReal[1]) then do (Set LeapReal[1] = 8.00) else do (Set LeapReal[1] = -8.00)
            • Unit - Add Storm Crow Form to LeapCaster
            • Unit - Remove Storm Crow Form from LeapCaster
            • Animation - Change LeapCaster flying height to ((Current flying height of LeapCaster) + LeapReal[1]) at 1000000000.00
          • Else - Actions
            • -------- Else... --------
            • -------- Resets the Flying height of Caster --------
            • Animation - Change LeapCaster flying height to 0.00 at 100000000.00
            • Unit - Turn collision for LeapCaster On
            • -------- Orders caster to attack target --------
            • Unit - Order LeapCaster to Attack LeapTarget
            • -------- Creates the Thunderclap --------
            • -------- NOTE 5: Change damage at dummy ability in Object Editor --------
            • Unit - Create 1 Leap Dummy Unit for (Owner of LeapCaster) at LeapPoints[1] facing Default building facing degrees
            • Unit - Add a 3.00 second Generic expiration timer to (Last created unit)
            • Unit - Add Dummy Thunder Clap to (Last created unit)
            • Unit - Set level of Dummy Thunder Clap for (Last created unit) to (Level of Leap for LeapCaster)
            • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
            • -------- Clears the Hashtable and Removes caster from Leapers' group --------
            • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in LeapHashtable
            • Unit Group - Remove (Picked unit) from Leapers
        • -------- Clears leaks --------
        • Custom script: call RemoveLocation(udg_LeapPoints[1])
        • Custom script: call RemoveLocation(udg_LeapPoints[2])
        • Custom script: call RemoveLocation(udg_LeapPoints[3])
    • -------- Checks if there is any instance left after loop --------
    • -------- If not, turns this trigger off --------
    • If ((Leapers is empty) Equal to True) then do (Trigger - Turn off (This trigger)) else do (Do nothing)
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,188
You cut off the events and conditions...

Unit - Add Storm Crow Form to LeapCaster
Unit - Remove Storm Crow Form from LeapCaster
This only ever needs to be done once per unit. Move it to be part of the cast code and not perodic code as it wastes many clcles needlessly.

Create 1 Leap Dummy Unit for (Owner of LeapCaster) at LeapPoints[1] facing Default building facing degrees
Make sure the dummy is an air unit. If it is a ground unit the frame drops can easilly be caused by WC3's doggy displacement algerthim going crazy.

Switching to locals instead of globals would yeild some speed boost due to quicker acceses from stack instead of from memory.
 
Level 8
Joined
Feb 17, 2007
Messages
368
Well the event for the second trigger is:
  • Time - Every 0.03 seconds of game time
For the first it's:
  • Unit - A unit Starts the effect of an ability
It has a 0 second casting time, so where else would I insert those actions? The duration is 2 seconds however.
 
Level 8
Joined
Feb 17, 2007
Messages
368
But the begins and finishes casting wouldn't work since it has a 0 second casting time, correct? Those two events only register casting time, not the effects or duration of the spell, right? I can add it to the first trigger, at the bottom, but where would I remove it other than the loop trigger. Because it needs to be removed when the unit reaches the 120 range of the target unit.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,188
You are making no sense...

Spell gets cast, you add ability, your remove ability.
This has nothing to do with perodic code as the flying trick once performed works for the entire duration of the unit's life (heroes I think need it after getting revived).
 
Status
Not open for further replies.
Top