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

HEAVY LAG on spellcasting triggered spell

Status
Not open for further replies.
Level 5
Joined
Oct 2, 2013
Messages
95
I made this spell where the user selects a target point and his hero throws a boomerang ( glaive ) at that point and, upon reaching its destination, the boomerang returns to its owner. All targets hit take damage and are poisoned. Also, if the caster uses silence when the blade is out flying, the blade will go to that target location before returning to it's owner.

Problem is, when I cast it and the glaive hits a unit, the game starts freezing really bad. My computer is very good and it's surely not the problem. Other spells with the same trigger idea ( dummy projectile, scan nearby units to deal damage ) do not cause such lag, even ones who use 5 projectiles. This one uses only one dummy + the temporary ones to poison enemies hit by the glaive.

Anyway, here are the triggers. I use an Indexing method to make it MUI.

  • VorpalBladeAct
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Vorpal Blade
    • Actions
      • Set VorpalBlade_Index = (VorpalBlade_Index + 1)
      • Set VorpalBlade_HasEnd[VorpalBlade_Index] = False
      • Set VorpalBlade_HasRelocate[VorpalBlade_Index] = False
      • Set VorpalBlade_Caster[VorpalBlade_Index] = (Triggering unit)
      • Set VorpalBlade_TargetPoint = (Target point of ability being cast)
      • Set VorpalBlade_CasterPoint = (Position of VorpalBlade_Caster[VorpalBlade_Index])
      • Set VorpalBlade_Level[VorpalBlade_Index] = (Level of Vorpal Blade for VorpalBlade_Caster[VorpalBlade_Index])
      • Unit - Create 1 Dummy for (Owner of VorpalBlade_Caster[VorpalBlade_Index]) at VorpalBlade_TargetPoint facing Default building facing degrees
      • Set VorpalBlade_TargetUnit[VorpalBlade_Index] = (Last created unit)
      • Unit - Create 1 VorpalBlade for (Owner of VorpalBlade_Caster[VorpalBlade_Index]) at VorpalBlade_CasterPoint facing VorpalBlade_TargetPoint
      • Set VorpalBlade_FlyBlade[VorpalBlade_Index] = (Last created unit)
      • Unit - Remove Vorpal Blade from VorpalBlade_Caster[VorpalBlade_Index]
      • Unit - Add Vorpal Blade Return to VorpalBlade_Caster[VorpalBlade_Index]
      • Trigger - Turn on VorpalBladeLoop <gen>
      • Trigger - Turn on VorpalBladeDisarm <gen>
      • Custom script: call RemoveLocation(udg_VorpalBlade_TargetPoint)
      • Custom script: call RemoveLocation(udg_VorpalBlade_CasterPoint)
  • VorpalBladeLoop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer VorpalBlade_LoopInteger) from 1 to VorpalBlade_Index, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • VorpalBlade_HasEnd[VorpalBlade_LoopInteger] Equal to False
            • Then - Actions
              • Set VorpalBlade_BladePoint = (Position of VorpalBlade_FlyBlade[VorpalBlade_LoopInteger])
              • Set VorpalBlade_MovePoint = (VorpalBlade_BladePoint offset by 50.00 towards (Facing of VorpalBlade_FlyBlade[VorpalBlade_LoopInteger]) degrees)
              • Set VorpalBlade_EndPoint = (Position of VorpalBlade_TargetUnit[VorpalBlade_LoopInteger])
              • Unit - Move VorpalBlade_FlyBlade[VorpalBlade_LoopInteger] instantly to VorpalBlade_MovePoint
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units within 200.00 of VorpalBlade_MovePoint matching (((Owner of (Matching unit)) is an ally of (Owner of VorpalBlade_Caster[VorpalBlade_LoopInteger])) Equal to False)) and do (Actions)
                • Loop - Actions
                  • Set VorpalBlade_PickedUnit = (Picked unit)
                  • Unit - Cause VorpalBlade_Caster[VorpalBlade_LoopInteger] to damage VorpalBlade_PickedUnit, dealing ((Real((Agility of VorpalBlade_Caster[VorpalBlade_LoopInteger] (Include bonuses)))) x (1.00 + (0.25 x (Real(VorpalBlade_Level[VorpalBlade_LoopInteger]))))) damage of attack type Spells and damage type Normal
                  • Unit - Create 1 Dummy for (Owner of VorpalBlade_Caster[VorpalBlade_LoopInteger]) at VorpalBlade_BladePoint facing Default building facing degrees
                  • Set VorpalBlade_Dummy = (Last created unit)
                  • Unit - Add Vorpal Blade [Effect Slow] to VorpalBlade_Dummy
                  • Unit - Set level of Vorpal Blade [Effect Slow] for VorpalBlade_Dummy to VorpalBlade_Level[VorpalBlade_LoopInteger]
                  • Unit - Order VorpalBlade_Dummy to Night Elf Warden - Shadow Strike VorpalBlade_PickedUnit
                  • Unit - Add a 0.50 second Generic expiration timer to VorpalBlade_Dummy
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Distance between VorpalBlade_MovePoint and VorpalBlade_EndPoint) Less than 50.00
                • Then - Actions
                  • Set VorpalBlade_HasEnd[VorpalBlade_LoopInteger] = True
                • Else - Actions
              • Custom script: call RemoveLocation(udg_VorpalBlade_BladePoint)
              • Custom script: call RemoveLocation(udg_VorpalBlade_MovePoint)
              • Custom script: call RemoveLocation(udg_VorpalBlade_EndPoint)
            • Else - Actions
              • Set VorpalBlade_BladePoint = (Position of VorpalBlade_FlyBlade[VorpalBlade_LoopInteger])
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • VorpalBlade_HasRelocate[VorpalBlade_LoopInteger] Equal to True
                • Then - Actions
                  • Set VorpalBlade_EndPoint = (Position of Silence_TargetUnit[VorpalBlade_LoopInteger])
                • Else - Actions
                  • Set VorpalBlade_EndPoint = (Position of VorpalBlade_Caster[VorpalBlade_LoopInteger])
              • Unit - Make VorpalBlade_FlyBlade[VorpalBlade_LoopInteger] face VorpalBlade_EndPoint over 0.00 seconds
              • Set VorpalBlade_MovePoint = (VorpalBlade_BladePoint offset by 50.00 towards (Facing of VorpalBlade_FlyBlade[VorpalBlade_LoopInteger]) degrees)
              • Unit - Move VorpalBlade_FlyBlade[VorpalBlade_LoopInteger] instantly to VorpalBlade_MovePoint
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units within 200.00 of VorpalBlade_MovePoint matching (((Owner of (Matching unit)) is an ally of (Owner of VorpalBlade_Caster[VorpalBlade_LoopInteger])) Equal to False)) and do (Actions)
                • Loop - Actions
                  • Set VorpalBlade_PickedUnit = (Picked unit)
                  • Unit - Cause VorpalBlade_Caster[VorpalBlade_LoopInteger] to damage VorpalBlade_PickedUnit, dealing ((Real((Agility of VorpalBlade_Caster[VorpalBlade_LoopInteger] (Include bonuses)))) x (1.00 + (0.25 x (Real(VorpalBlade_Level[VorpalBlade_LoopInteger]))))) damage of attack type Spells and damage type Normal
                  • Unit - Create 1 Dummy for (Owner of VorpalBlade_Caster[VorpalBlade_LoopInteger]) at VorpalBlade_BladePoint facing Default building facing degrees
                  • Set VorpalBlade_Dummy = (Last created unit)
                  • Unit - Add Vorpal Blade [Effect Slow] to VorpalBlade_Dummy
                  • Unit - Set level of Vorpal Blade [Effect Slow] for VorpalBlade_Dummy to VorpalBlade_Level[VorpalBlade_LoopInteger]
                  • Unit - Order VorpalBlade_Dummy to Night Elf Warden - Shadow Strike VorpalBlade_PickedUnit
                  • Unit - Add a 1.50 second Generic expiration timer to VorpalBlade_Dummy
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Distance between VorpalBlade_MovePoint and VorpalBlade_EndPoint) Less than 50.00
                  • VorpalBlade_HasRelocate[VorpalBlade_LoopInteger] Equal to True
                • Then - Actions
                  • Set VorpalBlade_HasRelocate[VorpalBlade_LoopInteger] = False
                  • Unit - Kill Silence_TargetUnit[VorpalBlade_LoopInteger]
                  • Set VorpalBlade_EndPoint = (Position of VorpalBlade_Caster[VorpalBlade_LoopInteger])
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Distance between VorpalBlade_MovePoint and VorpalBlade_EndPoint) Less than 50.00
                  • VorpalBlade_HasRelocate[VorpalBlade_LoopInteger] Equal to False
                • Then - Actions
                  • Unit - Remove Vorpal Blade Return from VorpalBlade_Caster[VorpalBlade_LoopInteger]
                  • Unit - Add Vorpal Blade to VorpalBlade_Caster[VorpalBlade_LoopInteger]
                  • Unit - Set level of Vorpal Blade for VorpalBlade_Caster[VorpalBlade_LoopInteger] to VorpalBlade_Level[VorpalBlade_LoopInteger]
                  • Set VorpalBlade_Caster[VorpalBlade_LoopInteger] = VorpalBlade_Caster[VorpalBlade_LoopInteger]
                  • Set VorpalBlade_HasEnd[VorpalBlade_LoopInteger] = VorpalBlade_HasEnd[VorpalBlade_Index]
                  • Set VorpalBlade_HasRelocate[VorpalBlade_LoopInteger] = VorpalBlade_HasRelocate[VorpalBlade_Index]
                  • Set VorpalBlade_Level[VorpalBlade_LoopInteger] = VorpalBlade_Level[VorpalBlade_Index]
                  • Set Silence_TargetUnit[VorpalBlade_LoopInteger] = Silence_TargetUnit[VorpalBlade_LoopInteger]
                  • Unit - Kill VorpalBlade_TargetUnit[VorpalBlade_LoopInteger]
                  • Unit - Kill VorpalBlade_FlyBlade[VorpalBlade_LoopInteger]
                  • Set VorpalBlade_TargetUnit[VorpalBlade_LoopInteger] = VorpalBlade_TargetUnit[VorpalBlade_Index]
                  • Set VorpalBlade_FlyBlade[VorpalBlade_LoopInteger] = VorpalBlade_FlyBlade[VorpalBlade_Index]
                  • Set VorpalBlade_Index = (VorpalBlade_Index - 1)
                  • Set VorpalBlade_LoopInteger = (VorpalBlade_LoopInteger - 1)
                • Else - Actions
              • Custom script: call RemoveLocation(udg_VorpalBlade_EndPoint)
              • Custom script: call RemoveLocation(udg_VorpalBlade_BladePoint)
              • Custom script: call RemoveLocation(udg_VorpalBlade_MovePoint)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • VorpalBlade_Index Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
  • VorpalBladeReturn
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Vorpal Blade Return
    • Actions
      • Set VorpalBlade_ReturnCaster = (Triggering unit)
      • For each (Integer VorpalBlade_LoopInteger) from 1 to VorpalBlade_Index, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • VorpalBlade_ReturnCaster Equal to VorpalBlade_Caster[VorpalBlade_LoopInteger]
            • Then - Actions
              • Unit - Remove Vorpal Blade Return from VorpalBlade_Caster[VorpalBlade_LoopInteger]
              • Unit - Add Vorpal Blade to VorpalBlade_Caster[VorpalBlade_LoopInteger]
              • Unit - Set level of Vorpal Blade for VorpalBlade_Caster[VorpalBlade_LoopInteger] to VorpalBlade_Level[VorpalBlade_LoopInteger]
              • Set VorpalBlade_Caster[VorpalBlade_LoopInteger] = VorpalBlade_Caster[VorpalBlade_LoopInteger]
              • Set VorpalBlade_HasEnd[VorpalBlade_LoopInteger] = VorpalBlade_HasEnd[VorpalBlade_Index]
              • Set VorpalBlade_HasRelocate[VorpalBlade_LoopInteger] = VorpalBlade_HasRelocate[VorpalBlade_Index]
              • Set VorpalBlade_Level[VorpalBlade_LoopInteger] = VorpalBlade_Level[VorpalBlade_Index]
              • Set Silence_TargetUnit[VorpalBlade_LoopInteger] = Silence_TargetUnit[VorpalBlade_LoopInteger]
              • Unit - Kill VorpalBlade_TargetUnit[VorpalBlade_LoopInteger]
              • Unit - Kill VorpalBlade_FlyBlade[VorpalBlade_LoopInteger]
              • Set VorpalBlade_TargetUnit[VorpalBlade_LoopInteger] = VorpalBlade_TargetUnit[VorpalBlade_Index]
              • Set VorpalBlade_FlyBlade[VorpalBlade_LoopInteger] = VorpalBlade_FlyBlade[VorpalBlade_Index]
              • Set VorpalBlade_Index = (VorpalBlade_Index - 1)
              • Set VorpalBlade_LoopInteger = (VorpalBlade_LoopInteger - 1)
            • Else - Actions
 
Level 17
Joined
Mar 21, 2011
Messages
1,597
well it could be a problem with the "base" ability.
using crater deformations could cause heavy problems.
If you use either thunderclap/warstomp or shockwave as base ability.. then it could be the problem.
just replace the shockwave with the carrion swarm ability
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
I don't think this will work.

  • Set VorpalBlade_Caster[VorpalBlade_LoopInteger] = VorpalBlade_Caster[VorpalBlade_LoopInteger]
It is probably not leaking. But it is creating so many units that it is causing lag.

  • Unit - Create 1 Dummy for (Owner of VorpalBlade_Caster[VorpalBlade_LoopInteger]) at VorpalBlade_BladePoint facing Default building facing degrees
Reduce the amount of units created and it should stop the lag.
 
Level 5
Joined
Oct 2, 2013
Messages
95
@GIMLI 2
I am already using carrion swarm.

@edo494
Whenever I cast it, doesn't matter.

@The_blood
Sure thing! i will create a demo map tomorrow if I have time ;D

@deathismyfriend
Removing all unit create triggers removed the lag, yeah, so i kinda know how to fix it... check if the unit has already been hit by the glaive, and if it was, don't spawn the unit.

But i have a few questions still: I have a spell in my map that also lags as hell. When cast, it creates a ring of fire around the caster that deals damage to enemies touched by the ring. The ring then expands and, upon reaching an distance of 1000, starts contracting back to the caster, disappearing when in contact with the caster, very similar to DotA's RAZOR - Plasma Field spell.

The triggers behind this spell are rather simple - i create 90 units using the firepawn missile model, all facing a different direction opposing the caster. I then set an increasing distance var, and move those units by a polar offset point being the casters position offset by the distance var towards the facing of the missile unit. That also lags as hell. But is there any way to do this without using unit's or, any method that would decrease lag? Would turn the units invisible ( no model ) and creating Special effects at their positions instead reduce lag?
 
Status
Not open for further replies.
Top