• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] charge laggs, why?

Status
Not open for further replies.
My Charge Spell works fine and all and i think it doesnt leak but after a certain numbers of uses it begins to lagg like hell, so i think it leakes....

i' ll post the full trigger here and i would be happy if u find the time to help me :grin::grin::grin:

so here is the first one

initialization
  • ChargeCast
    • Events
      • Unit - A unit starts the effect of an ability
    • Conditions
      • (Ability being cast) equal to (==) Charge!!
    • Actions
      • Set CustomValue = (CustomValue + 1)
      • Set Charger[CustomValue] = (Triggering unit)
      • Set Victim[CustomValue] = (Target unit of ability being cast)
      • Set Charge_Point_01[CustomValue] = (Position of Charger[CustomValue])
      • Set Charge_Point_02[CustomValue] = (Position of Victim[CustomValue])
      • Set Charge_Point_03[CustomValue] = (Charge_Point_01[CustomValue] offset by 50.00 towards (Angle from Charge_Point_01[CustomValue] to Charge_Point_02[CustomValue]) degrees)
      • -------- This Special effect is not nessessary for the spell and was made by me, just for fun, if u dont want it, delete it here and the remove specialeffect in the chargefinal as well as the pointi n this trigger where u set the variable! --------
      • Specialeffect - Create a special effect attached to the weapon of Charger[CustomValue] using Abilities\Weapons\PhoenixMissile\Phoenix_Missile_mini.mdl
      • Set SpecialEffect[CustomValue] = (Last created special effect)
      • Unit - Turn collision for Charger[CustomValue] Off
      • Unit - Hide Charger[CustomValue]
      • Unit - Move Charger[CustomValue] instantly to Charge_Point_03[CustomValue]
      • Trigger - Turn on ChargeDummy <gen>
      • Custom script: call RemoveLocation(udg_Charge_Point_01[udg_CustomValue])
      • Custom script: call RemoveLocation(udg_Charge_Point_02[udg_CustomValue])
      • Custom script: call RemoveLocation(udg_Charge_Point_03[udg_CustomValue])
so this works fine, eh, nothing should leak here, only possibility would be the special effect but i remove it later, lol.

so here is the second trigger
  • ChargeDummy
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • -------- u can change the interval by changing the periodic event as u want, u can also increase the space between the spawning points by increasing the distance named in chargepoint3 --------
      • Set Charge_Point_01[CustomValue] = (Position of Charger[CustomValue])
      • Set Charge_Point_02[CustomValue] = (Position of Victim[CustomValue])
      • Set Charge_Point_03[CustomValue] = (Charge_Point_01[CustomValue] offset by 20.00 towards (Angle from Charge_Point_01[CustomValue] to Charge_Point_02[CustomValue]) degrees)
      • -------- If u want to have a special effect at the position where the dummy spawns, just set it here and destroy it in an instant, or at the end of the trigger --------
      • Unit - Create 1 TimeChargeDummy for (Owner of Charger[CustomValue]) at Charge_Point_03[CustomValue] facing (Angle from Charge_Point_03[CustomValue] to Charge_Point_02[CustomValue]) degrees
      • Unit - Turn collision for (Last created unit) Off
      • Set Dummy[Dummyinteger] = (Last created unit)
      • Animation - Play Dummy[Dummyinteger]'s walk animation
      • Set DummyGroup[CustomValue] = (Create Unit Group)
      • Unitgroup - Add Dummy[Dummyinteger] to DummyGroup[CustomValue]
      • Trigger - Turn on ChargeDummyCounter <gen>
      • Set Dummyinteger = (Dummyinteger + 1)
      • Unit - Move Charger[CustomValue] instantly to Charge_Point_03[CustomValue]
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Conditions
            • CheckInteger equal to (==) 1
          • 'THEN'-Actions
            • Trigger - Run ChargeFinal <gen> (ignoring conditions)
            • Trigger - Turn off (This trigger)
          • 'ELSE'-Actions
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Conditions
            • (Distance between Charge_Point_02[CustomValue] and Charge_Point_03[CustomValue]) smaller or equal (<=) 200.00
          • 'THEN'-Actions
            • Set CheckInteger = 1
          • 'ELSE'-Actions
      • Custom script: call RemoveLocation(udg_Charge_Point_01[udg_CustomValue])
      • Custom script: call RemoveLocation(udg_Charge_Point_02[udg_CustomValue])
      • Custom script: call RemoveLocation(udg_Charge_Point_03[udg_CustomValue])
again there should be no problem, right? so here is the fade trigger
  • ChargeDummyCounter
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • -------- if u wish to, u can smooth the fading by setting the time interval to 0.01 and setting the addition in fadeinteger to 1, or 2 (just an example, just play around with those two values a bit) --------
        • Do Multiple ActionsFor each (Integer A) from 1 to Dummyinteger, do (Actions)
          • Loop - Actions
            • Set fadeinteger[(Integer A)] = (fadeinteger[(Integer A)] + 4.00)
            • Animation - Change Dummy[(Integer A)]'s vertex coloring to (100.00%, 100.00%, 100.00%) with fadeinteger[(Integer A)]% transparency
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • 'IF'-Conditions
                  • fadeinteger[(Integer A)] Größer als (>) 90.00
                • 'THEN'-Actions
                  • Animation - Reset Dummy[(Integer A)]'s animation
                  • Unitgroup - Remove Dummy[(Integer A)] from DummyGroup[CustomValue]
                  • Unit - Remove Dummy[(Integer A)] from the game
                  • Custom script: set udg_Dummy[bj_forLoopAIndex] = null
                • 'ELSE'-Actions
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • 'IF'-Conditions
                  • (DummyGroup[CustomValue] is empty) equal to (==) True
                • 'THEN'-Actions
                  • Custom script: call DestroyGroup(udg_DummyGroup[udg_CustomValue])
                  • Trigger - Turn off (This trigger)
                • 'ELSE'-Actions
hm, i gues that the problem is within these triggers but here is the last
  • ChargeFinal
    • Events
    • Conditions
    • Actions
      • Unit - Move Charger[CustomValue] instantly to Charge_Point_03[CustomValue]
      • Unit - Unhide Charger[CustomValue]
      • Unit - Turn collision for Charger[CustomValue] On
      • Unit - Cause Charger[CustomValue] to damage Victim[CustomValue], dealing 100.00 damage of attack type Spells and damage type Unknown
      • -------- i have a problem with the animation set here, it doesnt really show but i try to fix it in the future, u can change it by giving another anim name, here) --------
      • Animation - Play Charger[CustomValue]'s attack slam animation
      • Set KBA_Caster = Charger[CustomValue]
      • Set KBA_TargetUnit = Victim[CustomValue]
      • Set KBA_StartingPosition = Charge_Point_03[CustomValue]
      • Set KBA_Level = 1
      • Set KBA_Speed = 5.00
      • Set KBA_DistancePerLevel = 140.00
      • Set KBA_SpecialEffects[2] = Objects\Spawnmodels\Human\HumanBlood\HumanBloodLarge0.mdl
      • Set KBA_SpecialEffects[1] = Abilities\Spells\Human\FlakCannons\FlakTarget.mdl
      • Set KBA_DestroyTrees = True
      • Trigger - Run Cast A Knockback <gen> (checking conditions)
      • Specialeffect - Destroy SpecialEffect[CustomValue]
      • Selection - Select Charger[CustomValue] for (Owner of Charger[CustomValue])
      • Unit - Order Charger[CustomValue] to Attack Victim[CustomValue]
      • Set CheckInteger = 0
      • Custom script: call RemoveLocation(udg_Charge_Point_03[udg_CustomValue])
      • Custom script: set udg_Charger[udg_CustomValue] = null
      • Custom script: set udg_Victim[udg_CustomValue] = null
so thats all, i hope that u r able to help me...

+rep if u r!!! good luck!!!
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
this works fine, it is the knockback system of paladon, only problem is in my triggers, and custom value is just an integer and not the custom value of the unit, eh

I know, the problem is that your arrays aren't infinite. If you KEEP increasing CustomValue each time charge is used, you keep using more and more array indices.

In fact, every 0,02 seconds of the game you do this:

Set Dummyinteger = (Dummyinteger + 1)

DummyInteger is NEVER reset. Thus, after 1 second DummyInteger is 50. That means in your ChargeDummyCounter trigger you have a For loop from 1 to 50.

After 10 seconds, your for loop is from 1 to 500.
After 100 seconds (not nearly 2 minutes), your for loop is from 1 to 5000.
After 3 minutes, you start exceeding 8191, which is the maximum allowed index for arrays. So technically, I even think your map should crash after 3 minutes.
 
sry for doubleposting, i delete my old post, but i have a new problem....

if i do the thing with resetting the integer it works perfect the first time i use it, but the second time no dummys spawn and it becomes a simple blink strike, lol.

i inserted it at two different places, first was the final trigger, and this leaks totally because it interfers with the trigger chargecounter.

now i put it inside the countertrigger and it is how i said before, i can give u the exact line

  • here
  • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • 'IF'-Conditions
      • (DummyGroup[CustomValue] is empty) equal to (==) True
    • 'THEN'-Actions
      • THIS IS THE PLACE IT SHOULD RESET AFTER EVERYTHING WAS DONE, RIGHT?
      • Custom script: call DestroyGroup(udg_DummyGroup[udg_CustomValue])
      • Trigger - Turn off (This trigger)
well, without this, it works fine but laggs ^^
 
Status
Not open for further replies.
Top