Does thig Trigger leak and can it be Improved

R 3 T R O

New Member
Reaction score
12
Thanks for your attention.

Ive got 5 triggers but i want to make sure they don't leak and as well try to improve the trigger mostly so it don't lag. any help would be greatly appreciated.

Trigger:
  • Fire
    • Events
      • Unit - A unit owned by Neutral Victim Is attacked
      • Unit - A unit owned by Neutral Extra Is attacked
    • Conditions
      • ((Attacking unit) is A Hero) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Attacking unit)) Current gold) Greater than 0
          • Safty[(Player number of (Owner of (Attacking unit)))] Equal to False
        • Then - Actions
          • Player - Add -1 to (Owner of (Attacking unit)) Current gold
        • Else - Actions
          • Set CurrentlyReloading[(Player number of (Owner of (Attacking unit)))] = True
          • Unit - Order (Attacking unit) to Stop


Trigger:
  • Toggle Safty
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Toggle Safety (Marine Actions)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Safty[(Player number of (Owner of (Attacking unit)))] Equal to False
        • Then - Actions
          • Set Safty[(Player number of (Owner of (Casting unit)))] = True
        • Else - Actions
          • Set Safty[(Player number of (Owner of (Casting unit)))] = False


Trigger:
  • Drop Magazine
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Drop Magazine (Marine Actions)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Casting unit)) Current lumber) Greater than or equal to 3
        • Then - Actions
          • Player - Add -3 to (Owner of (Casting unit)) Current lumber
          • Hero - Create |c009aad3dAmmunition Case|r and give it to (Casting unit)
        • Else - Actions
          • Game - Display to (Player group((Owner of (Casting unit)))) the text: You do not have eno...


Trigger:
  • Reload
    • Events
      • Unit - A unit owned by Neutral Victim Is attacked
      • Unit - A unit owned by Neutral Extra Is attacked
    • Conditions
      • ((Owner of (Attacking unit)) Current gold) Equal to 0
      • ((Owner of (Attacking unit)) Current lumber) Greater than or equal to 1
      • CurrentlyReloading[(Player number of (Owner of (Attacking unit)))] Equal to False
    • Actions
      • Set CurrentlyReloading[(Player number of (Owner of (Attacking unit)))] = True
      • Sound - Play clipout <gen> at 100.00% volume, attached to Hero[(Player number of (Owner of (Attacking unit)))]
      • Player - Add -1 to (Owner of (Attacking unit)) Current lumber
      • Wait 3.50 seconds
      • Sound - Play clipin <gen> at 100.00% volume, attached to Hero[(Player number of (Owner of (Attacking unit)))]
      • Player - Set (Owner of (Attacking unit)) Current gold to Bullets[(Player number of (Owner of (Attacking unit)))]
      • Wait 1.00 seconds
      • Sound - Play m4a1_boltpull <gen> at 100.00% volume, attached to Hero[(Player number of (Triggering player))]
      • Set CurrentlyReloading[(Player number of (Owner of (Attacking unit)))] = False


Trigger:
  • Manual Reload
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Drop Magazine (Marine Actions)
      • ((Owner of (Casting unit)) Current lumber) Greater than or equal to 1
      • CurrentlyReloading[(Player number of (Owner of (Casting unit)))] Equal to False
    • Actions
      • Set CurrentlyReloading[(Player number of (Owner of (Casting unit)))] = True
      • Sound - Play clipout <gen> at 100.00% volume, attached to Hero[(Player number of (Owner of (Casting unit)))]
      • Player - Add -1 to (Owner of (Casting unit)) Current lumber
      • Wait 3.50 seconds
      • Sound - Play clipin <gen> at 100.00% volume, attached to Hero[(Player number of (Owner of (Casting unit)))]
      • Player - Set (Owner of (Casting unit)) Current gold to Bullets[(Player number of (Owner of (Casting unit)))]
      • Wait 1.00 seconds
      • Sound - Play m4a1_boltpull <gen> at 100.00% volume, attached to Hero[(Player number of (Owner of (Casting unit)))]
      • Set CurrentlyReloading[(Player number of (Owner of (Casting unit)))] = False
 

TBear

New Member
Reaction score
3
The sounds should be added to variables. Also, if I'm not wrong, (Owner of (...)) might cause leaks. Throw in some Player-variables instead :]

Edit: Even though the player-actions won't cause leak, variables will make your triggers way more lucid (;
 

Ayanami

칼리
Reaction score
288
I can't see any leaks.

Try use "A unit Starts the effect on an ability" instead of "A unit Begins casting an ability". And replace Casting unit to Triggering unit.

@TBear I'm quite sure that Player Group, Player and sounds don't leak
 

Im_On_56k

Hm...
Reaction score
116
Owner of ... does not leak so do not worry about that.

Your first trigger has no leaks.
Second trigger has no leaks.
Third trigger leaks a player group in your Display to Player Group. Create a tmp player force variable and set the player group to that. Then after your display message do a custom script:
JASS:
call DestroyForce(udg_MyVariableName)

Fourth trigger does not leak.
Fifth trigger also does not leak.

Hopefully I haven't missed anything.
 

Ayanami

칼리
Reaction score
288
Didn't know Player Group leaks. Usually, if I remove player group, strange things occur when the trigger is fired again.
 

Im_On_56k

Hm...
Reaction score
116
Yes, say we do:
Trigger:
  • Game - Display to (Player group(Player 1 (Red))) the text: hello

After we convert that to jass the function that is converting the player group is this:

Which is actually:
JASS:
function GetForceOfPlayer takes player whichPlayer returns force
    local force f = CreateForce()
    call ForceAddPlayer(f, whichPlayer)
    return f
endfunction

We are creating a force, but never destroying it anywhere.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Im_On_56k is right :D Player Groups do leak, and also converting a player to a player group, an he stated above :D

Though, one thing to remember is... "All player" don't leak !!! If you remove this one, it won't be usable anymore in the map :(

EDIT: Just noticed something:
Code:
Sound - Play m4a1_boltpull <gen> at 100.00% volume, attached to Hero[(Player number of ([COLOR="Red"]Triggering player[/COLOR]))]

Needs to be changed to (Owner of (Attacking unit)) :D
 

R 3 T R O

New Member
Reaction score
12
thansk guys, but is there a way i can make my triggers better more i feel like by using event unit attacked so often is messy....... i feel like all my triigs are messy one more thing my toggle safty isnt working for some reason when i click the ability safty it still shoots
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top