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

Leak Clearing/Optimizing/Fixing my (Mostly GUI) Triggers

Status
Not open for further replies.
Level 30
Joined
Jan 31, 2010
Messages
3,551
I need if someone can clear all the leaks and optimize them for me. I also need some things to be changed in them.

Okay, tell me if this can be optimized, or it leaks. How to make player leaver's gold split in equal parts and send it to allies (not AI ones (Red and Yellow)) every 5 seconds of game, not only at beginning?
  • Player Leavers
    • Events
      • Player - Player 2 (Blue) leaves the game
      • Player - Player 3 (Teal) leaves the game
      • Player - Player 4 (Purple) leaves the game
      • Player - Player 6 (Orange) leaves the game
      • Player - Player 7 (Green) leaves the game
      • Player - Player 8 (Pink) leaves the game
    • Conditions
    • Actions
      • Quest - Display to (All players) the Warning message: ((Name of (Triggering player)) + has left the game.)
      • Player - Set name of (Triggering player) to (|cff4e504b + (player_name_raw[(Player number of (Triggering player))] + |r))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering player) is in PlayersElvesPlaying) Equal to True
        • Then - Actions
          • Set TempInteger = ((((Triggering player) Current gold) / (Number of players in PlayersElvesPlaying)) + 1)
          • Player Group - Remove (Triggering player) from PlayersElvesPlaying
          • Player Group - Pick every player in PlayersElvesPlaying and do (Actions)
            • Loop - Actions
              • Player - Add TempInteger to (Picked player) Current gold
              • Player - Make (Triggering player) treat (Picked player) as an Ally with shared vision and shared units
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering player) is in PlayersOrcPlaying) Equal to True
        • Then - Actions
          • Set TempInteger = ((((Triggering player) Current gold) / (Number of players in PlayersOrcPlaying)) + 1)
          • Player Group - Remove (Triggering player) from PlayersOrcPlaying
          • Player Group - Pick every player in PlayersOrcPlaying and do (Actions)
            • Loop - Actions
              • Player - Add TempInteger to (Picked player) Current gold
              • Player - Make (Triggering player) treat (Picked player) as an Ally with shared vision and shared units
        • Else - Actions
Many more is to come, I just started with this one.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Still, the question stays: Trigger to make leaver's gold split between allied units every 5 seconds?

You can add the leaving player into a player group, like PlayersElvesLeavers PlayersOrcsLeavers.

Then periodically, pick all players in PlayersElvesLeavers. Get their current gold and divide it by number of players in PlayersElvesPlaying. Pick all players in PlayersElvesPlaying and give them the divided amount of gold. Set the current gold of the owner of the original gold to 0.

And the same for the Orcs.

Your trigger should be organized like this:
  • Untitled Trigger 001
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
        • Then - Actions
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
            • Then - Actions
            • Else - Actions
not like this:
  • Untitled Trigger 001
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
        • Then - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
        • Then - Actions
        • Else - Actions
 
Btw, just in case you need to add MPI events in the future;
  • Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • For each (Integer A) from 2 to 8, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Integer A) Not equal to 5
            • Then - Actions
              • Trigger - Add to Player Leaves <gen> the event (Player - (Player((Integer A))) leaves the game)
            • Else - Actions
      • Custom script: call DestroyTrigger(GetTriggeringTrigger())
It will save some time.
 
Status
Not open for further replies.
Top