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

[Trigger] Does anyboy here have any clue of what this lags?

Status
Not open for further replies.
Level 11
Joined
May 13, 2010
Messages
167
Does anyboy here have any clue of why this lags?

I submitted this spell a while ago. Maker moderated it and said it was ok, but for some reason it causes heavy fps drop after casting it a few times.

At first i though it was the dummy unit not clearing propperly, or some sort of missed memory leak, so i didn't worry. After a couple of days, i just couldn't crack it, the spells does drop de fps with every cast. Does anyboy here have any clue of why this is happen and maybe some way to fix it?

Maker said that his library wasn't the problem.

I tried to test the spell wiothout pressing ESC to reset cooldown and yet, lag appeared. Here is some utility info:

Deploys the awesome laser feature of the goblin invention. Once the laser is launch, it will seek for enemies in a straight line, damaging every enemy target it hits. Since the ability is very hard to properly aim, the goblin engineer designed the device to deal bonus damage every 0.1 seconds, meaning that the targets that are far away from the start point will take bonus damage. Cannot affect structures.

Level 1 - Deals 95 base damage to every target it hits. Lasts 0.6 seconds and gets 5 bonus damage every 0.1 seconds.

Level 2 - Deals 170 base damage to every target it hits. Lasts 1.2 seconds and gets 7 bonus damage every 0.1 seconds.

Level 3 - Deals 245 base damage to every target it hits. Lasts 1.8 seconds and gets 9 bonus damage every 0.1 seconds.


  • Sharp Laser Start
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Sharp Laser
    • Actions
      • -------- ---------------------------------------------------------------- --------
      • -------- Don't touch this settings --------
      • -------- ---------------------------------------------------------------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SL_Skip Equal to 0
        • Then - Actions
          • Trigger - Turn on Sharp Laser Loop <gen>
        • Else - Actions
      • Set SL_Skip = (SL_Skip + 1)
      • Set SL_Times = (SL_Times + 1)
      • Set SL_Off[SL_Times] = True
      • Set SL_Timer[SL_Times] = 0.00
      • Set SL_Caster[SL_Times] = (Triggering unit)
      • Set SL_Player[SL_Times] = (Owner of SL_Caster[SL_Times])
      • Set SL_Location1[SL_Times] = (Target point of ability being cast)
      • Set SL_Location2[SL_Times] = (Position of SL_Caster[SL_Times])
      • Set SL_AbilityLevel[SL_Times] = (Level of Sharp Laser for SL_Caster[SL_Times])
      • Set SL_Offset[SL_Times] = 40.00
      • -------- ---------------------------------------------------------------- --------
      • -------- Set the base damage here --------
      • -------- ---------------------------------------------------------------- --------
      • Set SL_Damage[SL_Times] = (((Real(SL_AbilityLevel[SL_Times])) x 75.00) + 20.00)
      • -------- ---------------------------------------------------------------- --------
      • -------- For each damage interval, there is a bonus damage added to the total, configure the ammount below --------
      • -------- ---------------------------------------------------------------- --------
      • Set SL_DamageIncrease[SL_Times] = (((Real(SL_AbilityLevel[SL_Times])) x 2.00) + 3.00)
      • -------- ---------------------------------------------------------------- --------
      • -------- This is the area of effect in wich enemy units are hit by the laser --------
      • -------- ---------------------------------------------------------------- --------
      • Set SL_AoE[SL_Times] = 100.00
      • -------- ---------------------------------------------------------------- --------
      • -------- How much time (seconds) should the hero be executing the spell? --------
      • -------- ---------------------------------------------------------------- --------
      • Set SL_Duration[SL_Times] = ((Real(SL_AbilityLevel[SL_Times])) x 0.60)
      • -------- ---------------------------------------------------------------- --------
      • -------- Every X interval of spell time, the target units gets damaged. Configure X below --------
      • -------- ---------------------------------------------------------------- --------
      • Set SL_DamageInterval[SL_Times] = 0.10
      • -------- ---------------------------------------------------------------- --------
      • -------- Special effect shown when laser hits --------
      • -------- ---------------------------------------------------------------- --------
      • Set SL_SFX = Abilities\Spells\Other\Incinerate\FireLordDeathExplode.mdl
      • -------- ---------------------------------------------------------------- --------
      • -------- Below this line are the Min and Max lifetime of each lightning effect (A lightning gets created at every damage interval). I heavily recommend leaving this at it is --------
      • -------- ---------------------------------------------------------------- --------
      • Set DurMin = 0.30
      • Set DurMax = 0.50
      • -------- ---------------------------------------------------------------- --------
      • -------- Don't touch this settings --------
      • -------- ---------------------------------------------------------------- --------
      • Set SL_3[SL_Times] = (Random real number between 0.00 and 100.00)
      • Set SL_4[SL_Times] = (Random real number between 0.00 and 100.00)
      • Set SL_Angle[SL_Times] = ((Angle from SL_Location1[SL_Times] to SL_Location2[SL_Times]) + 300.00)
      • Unit - Pause SL_Caster[SL_Times]
      • Unit - Create 1 Dummy for SL_Player[SL_Times] at SL_Location1[SL_Times] facing Default building facing degrees
      • Set SL_Dummy[SL_Times] = (Last created unit)
      • Unit - Add a SL_Duration[SL_Times] second Generic expiration timer to SL_Dummy[SL_Times]
      • Custom script: call RemoveLocation(udg_SL_Location1[udg_SL_Times])
      • Custom script: call RemoveLocation(udg_SL_Location2[udg_SL_Times])

  • Sharp Laser Loop
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • -------- ---------------------------------------------------------------- --------
      • -------- Don't touch this settings --------
      • -------- ---------------------------------------------------------------- --------
      • For each (Integer SL) from 1 to SL_Times, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SL_Off[SL] Equal to True
            • Then - Actions
              • Set SL_Timer[SL] = (SL_Timer[SL] + 0.02)
              • Set SL_Duration[SL] = (SL_Duration[SL] - 0.02)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • SL_Duration[SL] Less than or equal to 0.00
                • Then - Actions
                  • Unit - Unpause SL_Caster[SL]
                  • Set SL_Skip = (SL_Skip - 1)
                  • Set SL_Off[SL] = False
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • SL_Skip Equal to 0
                    • Then - Actions
                      • Set SL_Times = 0
                      • Trigger - Turn off (This trigger)
                    • Else - Actions
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • SL_Timer[SL] Greater than or equal to SL_DamageInterval[SL]
                    • Then - Actions
                      • Set SL_Timer[SL] = 0.00
                      • Set SL_DamageIncrease[SL] = (SL_DamageIncrease[SL] x 2.00)
                      • Set SL_Location1[SL] = (Position of SL_Dummy[SL])
                      • Set SL_Location2[SL] = (SL_Location1[SL] offset by SL_Offset[SL] towards SL_Angle[SL] degrees)
                      • Set SL_1[SL] = (X of SL_Location1[SL])
                      • Set SL_2[SL] = (Y of SL_Location1[SL])
                      • Unit - Move SL_Dummy[SL] instantly to SL_Location2[SL]
                      • Animation - Play SL_Caster[SL]'s spell animation
                      • Unit - Make SL_Caster[SL] face SL_Location1[SL] over 0.00 seconds
                      • Custom script: set bj_lastCreatedLightning = AddLightningEx("AFOD", true, GetUnitX(udg_SL_Caster[udg_SL]), GetUnitY(udg_SL_Caster[udg_SL]), udg_SL_3[udg_SL], udg_SL_1[udg_SL], udg_SL_2[udg_SL], udg_SL_4[udg_SL])
                      • Custom script: call TimedL.U2P(bj_lastCreatedLightning, udg_SL_Caster[udg_SL], GetRandomReal(udg_DurMin,udg_DurMax), GetUnitX(udg_SL_Caster[udg_SL]), GetUnitY(udg_SL_Caster[udg_SL]), udg_SL_1[udg_SL], udg_SL_2[udg_SL], udg_SL_3[udg_SL], udg_SL_4[udg_SL], 1, 0)
                      • Special Effect - Create a special effect at SL_Location2[SL] using SL_SFX
                      • Special Effect - Destroy (Last created special effect)
                      • Custom script: set bj_wantDestroyGroup = true
                      • Unit Group - Pick every unit in (Units within SL_AoE[SL] of SL_Location2[SL] matching (((((Matching unit) is A structure) Equal to False) and (((Matching unit) is alive) Equal to True)) and (((Matching unit) belongs to an enemy of SL_Player[SL]) Equal to True))) and do (Actions)
                        • Loop - Actions
                          • Unit - Cause SL_Caster[SL] to damage (Picked unit), dealing (SL_Damage[SL] + SL_DamageIncrease[SL]) damage of attack type Spells and damage type Normal
                      • Custom script: call RemoveLocation(udg_SL_Location1[udg_SL])
                      • Custom script: call RemoveLocation(udg_SL_Location2[udg_SL])
                    • Else - Actions
            • Else - Actions
:goblin_boom:
 
Last edited:
Level 7
Joined
Jan 28, 2012
Messages
266
what is the base ability that you are using?
why are using a .02 period rather then a .03(there is such a slight difference in smoothness that you can't tell the difference)

also, you could do a better indexing method...

like a last of line method(where it takes the last in first and index's down)
  • Set SL = SL_Times
  • Custom script: loop
  • ....
  • if (unit finished) then
    • --- clear all leaks, ie destroy the things that need to be destroyed here.--
    • if Unit NOT last
      • --- move everything from last index to this index---
  • --null the last instance(ie, set things like units, and points to null)
    • else
      • if SL == 1 then
        • ---- turn off etc..
    • Set SL_Times = SL_Times-1
  • ...
  • exitwhen SL == 1
  • Set SL = (SL-1)
  • Custom script: endloop
but that aside, i see no reason for lag, it looks like it should be able to do more then 10 casts with out a problem
you are clearing all memory leaks, and you are not doing any actions that would require a lot of CPU(other then the pick every, but you aren't doing that that often)

so again, what ability are you using for the base? there are some abilities that if you set certain values to the wrong thing, they cause massive lag.

Sorry i can't help more but the triggering looks good(despite your indexing method)
 
Level 11
Joined
May 13, 2010
Messages
167
Yup! i know indexing kinda sucks, but it was the very first version. I will definetly update that once i get over the laggy thing, among with the 0.02 loop timer (OMG i really didn't know there was a difference!).

I am using Shockwave as base ability, with the following changes from default data:

Missile Speed - 0
Damage - 0
Distance - 0
Maximum Damage - 0
Final Area - 0
Area of Effect - 0
Cast Range - 350

I can provide the test map, btw. And thanks for replying!
 
Level 7
Joined
Jan 28, 2012
Messages
266
looked at your spells test map, using the link. There is lag? I am not experiencing lag for 28 casts

but I did notice that if you set the cooldown to zero it bugs, it will continue casting until the unit runs out of mana.

your spell has very nice effects.
 
Level 11
Joined
May 13, 2010
Messages
167
looked at your spells test map, using the link. There is lag? I am not experiencing lag for 28 casts

but I did notice that if you set the cooldown to zero it bugs, it will continue casting until the unit runs out of mana.

your spell has very nice effects.

Try to keep casting, it is fucked up.

Yep, but that is not a problem, actually. And thanks!
 
Level 7
Joined
Jan 28, 2012
Messages
266
Here is a test map,(just has your spell and makes it create units and cast the spell) i get to 40 units before I experience lag.

a way to reduce the lag would be to switch from using PickEvery unit in range, to using a Tempgroup and First of Loop unit enumeration,

also switching from locations to x/y coords would help reduce lag too.
 

Attachments

  • Test_1.w3x
    57.8 KB · Views: 86
Level 26
Joined
Aug 18, 2009
Messages
4,097
The shockwave base ability causes lag. You have made some settings that hinders it from completing. Set missile speed to something greater than 0 for example. Shockwave is costly to begin with because it deforms the terrain and therefore has to check all the doodads and widgets for adjusting roll/pitch.

Also, you should not pause the caster on spell effect event because the order and ability are not finished at this moment. When unpausing the caster, it will issue the order again. You should easily notice this in your testmap because each of your sorceress keeps casting over and over.
 
Level 11
Joined
May 13, 2010
Messages
167
The shockwave base ability causes lag. You have made some settings that hinders it from completing. Set missile speed to something greater than 0 for example. Shockwave is costly to begin with because it deforms the terrain and therefore has to check all the doodads and widgets for adjusting roll/pitch.

Also, you should not pause the caster on spell effect event because the order and ability are not finished at this moment. When unpausing the caster, it will issue the order again. You should easily notice this in your testmap because each of your sorceress keeps casting over and over.

Well this turne ou to be really usefull! I will switch te base ability, maybe. Do you have any suggestions on the pause stuff? Like for example when should i do it?
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
I personally do not use the spell effect event much anymore but instead save the event responses there and deliver them to the endcast event to run my stuff from that point. This way, I do not get in conflict with standard spell stuff. This won't work for channeling spells though, which is one more reason why I have customized channeling in my current project.
 
Level 11
Joined
May 13, 2010
Messages
167
I personally never use "Unit - pause unit" with spells.

I see, but i didn't want the caster to stop the spell when it alredy started.. How would you do it? I thinking using yet another trigger to emulate some sort of channeling ability could work, i am right? Well i definetly will look up to some way to avoid pausing units since lots of people says it is kinda bad idea. :goblin_jawdrop:
 
Status
Not open for further replies.
Top