• 🏆 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] Improving performance of this spell

Status
Not open for further replies.
Level 12
Joined
May 16, 2020
Messages
660
Hi all,

This spell is based on Spectral Dagger from Dota. The trigger below is functional, but the following part of the description causes huge framerate drops if several units are hit by the dagger:

The Spectre launches a deadly dagger that trails a Shadow Path. Deals damage to the targets in its path. Units hit by the dagger will also trail a Shadow Path. The Spectre becomes phased (gains zero collision) while on the path.

The way the spell does it is by checking all units in Group A (units who were hit by the initial dagger) and then every 0.5 sec create a "shadow dummy" (= unit with special model) on the location of the picked units. As you can imagine, if 15 units get hit, every 0.5 seconds up to 15 units are created... and I think that is what causes the lag.

Is there any way to reduce the lag?


FYI: Because I use Reforged and units without model no longer use a shadow, I'm using the following model HeroPaladin. It's filesize is already quite small, so I don't think using another model would help a lot.

***

1) Initiating the spell:
  • Spectral Dagger
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Spectral Dagger
    • Actions
      • Set VariableSet SpectralDagger_Caster = (Triggering unit)
      • Set VariableSet SpectralDagger_Caster_Position = (Position of SpectralDagger_Caster)
      • Set VariableSet SpectralDagger_Damage = (50.00 x (Real((Level of Spectral Dagger for SpectralDagger_Caster))))
      • Set VariableSet SpectralDagger_Distance = 2000.00
      • Set VariableSet SpectralDagger_AOE = 125.00
      • Set VariableSet SpectralDagger_Target_Unit = No unit
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Target unit of ability being cast) Equal to No unit
        • Then - Actions
          • Set VariableSet SpectralDagger_Target_Point = (Target point of ability being cast)
        • Else - Actions
          • -------- TO FIX POINT / UNIT DEFINITION LATER --------
          • Set VariableSet SpectralDagger_Target_Point = (Position of (Target unit of ability being cast))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Target unit of ability being cast) is A Hero) Equal to True
            • Then - Actions
              • Set VariableSet SpectralDagger_Target_Unit = (Target unit of ability being cast)
            • Else - Actions
      • -------- Create first shadow to immediately grant boost --------
      • Unit - Create 1 Spectral Dagger (Shadow) for (Owner of SpectralDagger_Caster) at SpectralDagger_Caster_Position facing Default building facing degrees
      • Unit - Add Spectral Dagger (Aura) to (Last created unit)
      • Unit - Set level of Spectral Dagger (Aura) for (Last created unit) to (Level of Spectral Dagger for SpectralDagger_Caster)
      • Unit - Add a 12.00 second Generic expiration timer to (Last created unit)
      • Unit Group - Add (Last created unit) to SpectralDagger_Shadow_Group
      • Trigger - Turn on Spectral Dagger Shadows Slow <gen>
      • -------- Missile --------
      • Set VariableSet SpectralDagger_Angle = (Angle from SpectralDagger_Caster_Position to SpectralDagger_Target_Point)
      • Unit - Create 1 Dummy (Speed 0) for (Owner of SpectralDagger_Caster) at SpectralDagger_Caster_Position facing SpectralDagger_Target_Point
      • Set VariableSet SpectralDagger_Missile = (Last created unit)
      • Unit - Add Crow Form to SpectralDagger_Missile
      • Unit - Remove Crow Form from SpectralDagger_Missile
      • Animation - Change SpectralDagger_Missile flying height to 125.00 at 0.00
      • Special Effect - Create a special effect attached to the origin of SpectralDagger_Missile using war3mapImported\MeatHookHead.mdx
      • Set VariableSet SpectralDagger_Effect[1] = (Last created special effect)
      • Special Effect - Create a special effect attached to the origin of SpectralDagger_Missile using Abilities\Spells\NightElf\shadowstrike\ShadowStrikeMissile.mdl
      • Set VariableSet SpectralDagger_Effect[2] = (Last created special effect)
      • -------- Create the Master Caster --------
      • Unit - Create 1 Dummy (Speed 0) for (Owner of SpectralDagger_Caster) at SpectralDagger_Caster_Position facing Default building facing degrees
      • Set VariableSet SpectralDagger_MasterCaster = (Last created unit)
      • Unit - Add Spectral Dagger Slow to (Last created unit)
      • Unit - Set level of Spectral Dagger Slow for (Last created unit) to (Level of Spectral Dagger for SpectralDagger_Caster)
      • Unit - Add Spectral Dagger Vision to (Last created unit)
      • Unit - Add a 13.00 second Generic expiration timer to (Last created unit)
      • -------- Turn off collision --------
      • Unit - Turn collision for SpectralDagger_Caster Off.
      • Unit Group - Add SpectralDagger_Caster to SpectralDagger_Collision_Group
      • Trigger - Turn on Spectral Dagger Collision Check <gen>
      • -------- Finish Set-up --------
      • Custom script: set udg_SpectralDagger_TempGroup = CreateGroup()
      • Trigger - Turn on Spectral Dagger Loop <gen>
      • Trigger - Turn on Spectral Dagger Dummy Effect Death <gen>
      • Custom script: call RemoveLocation(udg_SpectralDagger_Caster_Position)
      • Custom script: call RemoveLocation(udg_SpectralDagger_Target_Point)


2) Moving the dagger to its target location:
  • Spectral Dagger Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set VariableSet SpectralDagger_Loop_Counter = (SpectralDagger_Loop_Counter + 35.00)
      • Set VariableSet SpectralDagger_Loop_Effect = (SpectralDagger_Loop_Effect + 35.00)
      • Set VariableSet SpectralDagger_Loop_Position[1] = (Position of SpectralDagger_Missile)
      • Set VariableSet SpectralDagger_Loop_Position[2] = (SpectralDagger_Loop_Position[1] offset by 35.00 towards SpectralDagger_Angle degrees.)
      • Unit - Move SpectralDagger_Missile instantly to SpectralDagger_Loop_Position[2]
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SpectralDagger_Loop_Effect Greater than or equal to 140.00
        • Then - Actions
          • Set VariableSet SpectralDagger_Loop_Effect = 0.00
          • Unit - Create 1 Spectral Dagger (Shadow) for (Owner of SpectralDagger_Caster) at SpectralDagger_Loop_Position[2] facing Default building facing degrees
          • Unit - Add Spectral Dagger (Aura) to (Last created unit)
          • Unit - Set level of Spectral Dagger (Aura) for (Last created unit) to (Level of Spectral Dagger for SpectralDagger_Caster)
          • Unit - Add a 12.00 second Generic expiration timer to (Last created unit)
          • Unit Group - Add (Last created unit) to SpectralDagger_Shadow_Group
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in SpectralDagger_Shadow_Group) Equal to 1
            • Then - Actions
              • Trigger - Turn on Spectral Dagger Shadows Slow <gen>
            • Else - Actions
        • Else - Actions
      • -------- Damage and slow hit units --------
      • Custom script: set bj_wantDestroyGroup=true
      • Unit Group - Pick every unit in (Units within SpectralDagger_AOE of SpectralDagger_Loop_Position[2].) and do (Actions)
        • Loop - Actions
          • Set VariableSet SpectralDagger_TempUnit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (SpectralDagger_TempUnit is in SpectralDagger_TempGroup.) Equal to False
              • (SpectralDagger_TempUnit belongs to an enemy of (Owner of SpectralDagger_Caster).) Equal to True
              • (SpectralDagger_TempUnit is A structure) Equal to False
              • (SpectralDagger_TempUnit is Magic Immune) Equal to False
              • (SpectralDagger_TempUnit is alive) Equal to True
            • Then - Actions
              • Unit - Cause SpectralDagger_Caster to damage SpectralDagger_TempUnit, dealing SpectralDagger_Damage damage of attack type Spells and damage type Normal
              • Unit - Order SpectralDagger_MasterCaster to Human Sorceress - Slow SpectralDagger_TempUnit
              • Custom script: call IssueTargetOrderById( udg_SpectralDagger_MasterCaster, 852570, udg_SpectralDagger_TempUnit)
              • Unit Group - Add (Picked unit) to SpectralDagger_MarkedbyDagger
              • Unit Group - Add (Picked unit) to SpectralDagger_TempGroup
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Spectral Dagger Marked more Shadows <gen> is on) Equal to False
                • Then - Actions
                  • Trigger - Turn on Spectral Dagger Marked more Shadows <gen>
                • Else - Actions
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SpectralDagger_Loop_Counter Greater than or equal to SpectralDagger_Distance
        • Then - Actions
          • Custom script: call RemoveLocation(udg_SpectralDagger_Loop_Position[1])
          • Custom script: call RemoveLocation(udg_SpectralDagger_Loop_Position[2])
          • Custom script: call DestroyGroup (udg_SpectralDagger_TempGroup)
          • Set VariableSet SpectralDagger_Loop_Counter = 0.00
          • Unit - Kill SpectralDagger_Missile
          • Special Effect - Destroy SpectralDagger_Effect[1]
          • Special Effect - Destroy SpectralDagger_Effect[2]
          • Trigger - Turn off (This trigger)
        • Else - Actions


3) Here the lag (probably) - creating more shadows for units that are initially hit by the dagger:
  • Spectral Dagger Marked more Shadows
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in SpectralDagger_MarkedbyDagger) Greater than 0
        • Then - Actions
          • Unit Group - Pick every unit in SpectralDagger_MarkedbyDagger and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • ((Picked unit) has buff Spectral Dagger (Vision)) Equal to False
                      • ((Picked unit) is dead) Equal to True
                • Then - Actions
                  • Unit Group - Remove (Picked unit) from SpectralDagger_MarkedbyDagger.
                • Else - Actions
                  • Set VariableSet SpectralDagger_Marked_Point = (Position of (Picked unit))
                  • Unit - Create 1 Spectral Dagger (Shadow) for (Owner of SpectralDagger_Caster) at SpectralDagger_Marked_Point facing Default building facing degrees
                  • Unit - Add Spectral Dagger (Aura) to (Last created unit)
                  • Unit - Set level of Spectral Dagger (Aura) for (Last created unit) to (Level of Spectral Dagger for SpectralDagger_Caster)
                  • Unit - Add a 7.00 second Generic expiration timer to (Last created unit)
                  • Unit Group - Add (Last created unit) to SpectralDagger_Shadow_Group
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Number of units in SpectralDagger_Shadow_Group) Equal to 1
                    • Then - Actions
                      • Trigger - Turn on Spectral Dagger Shadows Slow <gen>
                    • Else - Actions
                  • Custom script: call RemoveLocation(udg_SpectralDagger_Marked_Point)
        • Else - Actions
          • Trigger - Turn off (This trigger)


4) Or potentially here - Slowing enemies who come into range of the shadow trail:
  • Spectral Dagger Shadows Slow
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in SpectralDagger_Shadow_Group) Not equal to 0
        • Then - Actions
          • Unit Group - Pick every unit in SpectralDagger_Shadow_Group and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is dead) Equal to True
                • Then - Actions
                  • Unit Group - Remove (Picked unit) from SpectralDagger_Shadow_Group.
                • Else - Actions
                  • Set VariableSet SpectralDagger_Shadow_Point = (Position of (Picked unit))
                  • Set VariableSet SpectralDagger_Shadow_SlowGrp = (Units within SpectralDagger_AOE of SpectralDagger_Shadow_Point.)
                  • Unit Group - Pick every unit in SpectralDagger_Shadow_SlowGrp and do (Actions)
                    • Loop - Actions
                      • Set VariableSet SpectralDagger_TempUnit = (Picked unit)
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (SpectralDagger_TempUnit belongs to an enemy of (Owner of SpectralDagger_Caster).) Equal to True
                          • (SpectralDagger_TempUnit is A structure) Equal to False
                        • Then - Actions
                          • Unit - Order SpectralDagger_MasterCaster to Human Sorceress - Slow (Picked unit)
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • ((Picked unit) is in SpectralDagger_MarkedbyDagger.) Equal to True
                            • Then - Actions
                              • Custom script: call IssueTargetOrderById( udg_SpectralDagger_MasterCaster, 852570, udg_SpectralDagger_TempUnit)
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • (Spectral Dagger Marked more Shadows <gen> is on) Equal to False
                                • Then - Actions
                                  • Trigger - Turn on Spectral Dagger Marked more Shadows <gen>
                                • Else - Actions
                            • Else - Actions
                        • Else - Actions
                      • Unit Group - Remove (Picked unit) from SpectralDagger_Shadow_SlowGrp.
                  • Custom script: call RemoveLocation(udg_SpectralDagger_Shadow_Point)
        • Else - Actions
          • Trigger - Turn off (This trigger)


5) Turning off collision for the caster when having the buff from the shadow trail:
  • Spectral Dagger Collision Check
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in SpectralDagger_Collision_Group) Greater than 0
        • Then - Actions
          • Unit Group - Pick every unit in SpectralDagger_Collision_Group and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) has buff Spectral Dagger (Aura)) Equal to False
                • Then - Actions
                  • Unit - Turn collision for (Picked unit) On.
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Number of units in SpectralDagger_Shadow_Group) Equal to 0
                    • Then - Actions
                      • Unit Group - Remove (Picked unit) from SpectralDagger_Collision_Group.
                    • Else - Actions
                • Else - Actions
                  • Unit - Turn collision for (Picked unit) Off.
        • Else - Actions
          • Trigger - Turn off (This trigger)
 
Last edited:
Status
Not open for further replies.
Top