• 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] does this custom script solve this leak?

Status
Not open for further replies.
Level 4
Joined
Oct 15, 2008
Messages
77
  • Set player_group = (All players)
  • Player Group - Pick every player in player_group and do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Current research level of Researching |cffFFD400I|rncome for (Picked player)) Greater than or equal to 1
        • Then - Actions
          • Player - Add 5 to (Picked player) Current gold
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current research level of Researching |cffFFD400I|rncome for (Picked player)) Greater than or equal to 2
            • Then - Actions
              • Player - Add 10 to (Picked player) Current gold
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current research level of Researching |cffFFD400I|rncome for (Picked player)) Greater than or equal to 3
                • Then - Actions
                  • Player - Add 15 to (Picked player) Current gold
                • Else - Actions
  • Custom script: call DestroyForce (udg_player_group)
as the title says, does
  • Custom script: call DestroyForce (udg_player_group)
remove the leak from the player_group?
 
Level 4
Joined
Oct 15, 2008
Messages
77
ok well. other then that. this trigger isnt even working. the tech is right. its in the right building blah blah everything is set up. although every 20 seconds of game time its not even giving the extra gold.
 
Last edited:
Level 11
Joined
Dec 31, 2007
Messages
780
i would make it this way

  • Player Group - Pick every player in All players and do (Actions)
    • Loop - actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Current research level of Researching |cffFFD400I|rncome for (Picked player)) Greater than or equal to 1
        • Then - Actions
          • Player - Add (5x(current research level of Researching |cffFFD400I|rncome for picked player)) to (Picked player) Current gold
        • Else - Actions
 
Level 4
Joined
Oct 15, 2008
Messages
77
what would be different of doing it that way, other then the way i had it? besides the 5xcurrent level which equals out to the exact same as a static number rather then running extra process?
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
Formulas may not be the efficient in the aspects of speed if it is used in a short loop. However, 'elseifs' are only efficient at the first condition. The longer it becomes the less efficient it is. In this case a for loop is actually faster since it will not have to check through any ifs. Also, it avoids leaking at all. Players are static and will have a total of X in every game. Player Groups are not. Also, like GhostWolf said, destroying "All Players" is a bad idea since it has a great risk of screwing things up and create complications. (I mean, you will not be able to access the 'All Players' again since it is destroyed.)

Oh and, for-loops also makes the code shorter...

Edit: I just realised he didnt use a for loop...
 
Level 11
Joined
Dec 31, 2007
Messages
780
what would be different of doing it that way, other then the way i had it? besides the 5xcurrent level which equals out to the exact same as a static number rather then running extra process?

as eccho said mi code is shorter, it has only 1 IF condition so your trigger checks for it only ONCE per player(which means that it makes only 1 logical calculation, improving execution), loads faster(coz code is shorter), it is LEAKLESS (you dont have to mess with custom scripts and all players variable or constants) and it works xD

another difference would be that if you want to add more levels to the upgrade you will have to make more static number of IFs for every upgrade... the way i did you may have 500 levels of upgrades in just 4 lines of code


OH!. BTW guys... he is not destroying all players CONSTANT... he is destroying a player group VARIABLE that has all players stored (destroying it will cause problems anyways?)
 
Level 4
Joined
Oct 15, 2008
Messages
77
awesome thanks. i wish everyone could take 3 seconds to help explain stuff like this. i understand exactly what u guys said. thanks a ton!
 
Status
Not open for further replies.
Top