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

Status
Not open for further replies.
Level 8
Joined
Feb 17, 2007
Messages
368
Anyone know why this spell is lagging and how to fix it?:

  • Unit - A unit Starts the effect of an ability
  • (Ability being cast) Equal to Fire Spiral
  • Actions
    • Set FireSpiralUNI[100] = (Casting unit)
    • Unit - Add WepFire to FireSpiralUNI[100]
    • Set FireSpiralUNI[101] = FireSpiralUNI[100]
    • Set FireSpiralINT = 0
    • Set FireSpiralUNI[101] = No unit
    • Custom script: call SetUnitAnimationByIndex(udg_FireSpiralUNI[100], 5)
    • Wait 0.50 seconds
    • Set locspiral[1] = (Position of FireSpiralUNI[100])
    • Set locspiral[2] = (locspiral[1] offset by 100.00 towards (Facing of FireSpiralUNI[100]) degrees)
    • Special Effect - Create a special effect at locspiral[2] using Abilities\Spells\Orc\WarStomp\WarStompCaster.mdl
    • Special Effect - Destroy (Last created special effect)
    • For each (Integer FireSpiralInt) from 1 to 10, do (Actions)
      • Loop - Actions
        • Unit - Create 1 FireDummy for (Owner of FireSpiralUNI[100]) at locspiral[2] facing (36.00 x (Real(FireSpiralInt))) degrees
        • Set FireSpiralINT = (FireSpiralINT + 1)
        • Set FireSpiralUNI[FireSpiralINT] = (Last created unit)
    • Custom script: call RemoveLocation (udg_locspiral[1])
    • Custom script: call RemoveLocation (udg_locspiral[2])
    • Unit - Remove WepFire from FireSpiralUNI[100]
    • Wait 1.50 seconds
    • For each (Integer FireSpiralInt) from 1 to 10, do (Actions)
      • Loop - Actions
        • Set locspiral[1] = (Position of FireSpiralUNI[FireSpiralInt])
        • Special Effect - Create a special effect at locspiral[1] using Objects\Spawnmodels\Other\NeutralBuildingExplosion\NeutralBuildingExplosion.mdl
        • Special Effect - Destroy (Last created special effect)
        • Special Effect - Create a special effect at locspiral[1] using Abilities\Spells\Orc\WarStomp\WarStompCaster.mdl
        • Special Effect - Destroy (Last created special effect)
        • Set locreal = 5000.00
        • Set TempUnitGroup = (Units within 300.00 of locspiral[1] matching ((((Owner of (Matching unit)) is an enemy of Player 12 (Brown)) Equal to True) and ((((Matching unit) is A structure) Not equal to True) and (((Matching unit) is alive) Equal to True))))
        • Unit Group - Pick every unit in TempUnitGroup and do (Actions)
          • Loop - Actions
            • Unit - Cause FireSpiralUNI[100] to damage (Picked unit), dealing locreal damage of attack type Spells and damage type Normal
        • Custom script: call DestroyGroup (udg_TempUnitGroup)
        • For each (Integer FireSpiralInt2) from 1 to 5, do (Actions)
          • Loop - Actions
            • Unit - Create 1 FireDummy for (Owner of FireSpiralUNI[100]) at locspiral[1] facing (72.00 x (Real(FireSpiralInt2))) degrees
            • Set FireSpiralINT = (FireSpiralINT + 1)
            • Set FireSpiralUNI[FireSpiralINT] = (Last created unit)
        • Unit - Remove FireSpiralUNI[FireSpiralInt] from the game
        • Custom script: call RemoveLocation (udg_locspiral[1])
    • Wait 1.50 seconds
    • For each (Integer FireSpiralInt) from 10 to 60, do (Actions)
      • Loop - Actions
        • Set locspiral[1] = (Position of FireSpiralUNI[FireSpiralInt])
        • Special Effect - Create a special effect at locspiral[1] using Objects\Spawnmodels\Other\NeutralBuildingExplosion\NeutralBuildingExplosion.mdl
        • Special Effect - Destroy (Last created special effect)
        • Special Effect - Create a special effect at locspiral[1] using Abilities\Spells\Orc\WarStomp\WarStompCaster.mdl
        • Special Effect - Destroy (Last created special effect)
        • Set locreal = 5000.00
        • Set TempUnitGroup = (Units within 500.00 of locspiral[1] matching ((((Owner of (Matching unit)) is an enemy of Player 12 (Brown)) Equal to True) and ((((Matching unit) is A structure) Not equal to True) and (((Matching unit) is alive) Equal to True))))
        • Unit Group - Pick every unit in TempUnitGroup and do (Actions)
          • Loop - Actions
            • Unit - Cause FireSpiralUNI[100] to damage (Picked unit), dealing locreal damage of attack type Spells and damage type Normal
        • Custom script: call DestroyGroup (udg_TempUnitGroup)
        • Unit - Remove FireSpiralUNI[FireSpiralInt] from the game
        • Custom script: call RemoveLocation (udg_locspiral[1])
    • Set FireSpiralUNI[100] = No unit
  • Time - Every 0.04 seconds of game time
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • FireSpiralUNI[100] Not equal to No unit
      • Then - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • FireSpiralUNI[101] Not equal to No unit
          • Then - Actions
            • Special Effect - Create a special effect attached to the weapon of FireSpiralUNI[101] using Abilities\Weapons\RedDragonBreath\RedDragonMissile.mdl
            • Special Effect - Destroy (Last created special effect)
          • Else - Actions
        • For each (Integer FireSpiralInt) from 1 to FireSpiralINT, do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • FireSpiralUNI[FireSpiralInt] Not equal to No unit
              • Then - Actions
                • Set locspiral[1] = (Position of FireSpiralUNI[FireSpiralInt])
                • Set locspiral[2] = (locspiral[1] offset by 15.00 towards (Facing of FireSpiralUNI[FireSpiralInt]) degrees)
                • Unit - Move FireSpiralUNI[FireSpiralInt] instantly to locspiral[2]
                • Special Effect - Create a special effect at locspiral[1] using Environment\LargeBuildingFire\LargeBuildingFire1.mdl
                • Special Effect - Destroy (Last created special effect)
                • Custom script: call RemoveLocation (udg_locspiral[1])
                • Custom script: call RemoveLocation (udg_locspiral[2])
              • Else - Actions
      • Else - Actions
 
Use 1% of the special effects you're using now and you're good to go.
Also, you're doing tons of Group enumerations ("Pick every unit in ...")
I wouldn't dare use more than 1 or 2 enumerations 32x a second.

You're also creating way too many units. 50 units can cause quite a bit of lag.
Use 5 or 10 and you'll be ok.

If you still have lag, then reduce the periodic interval to 0.05 or 0.06


If the lag still continues, I'll code this in vJass for you.
 
Status
Not open for further replies.
Top