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

Total gold earned by a player [GUI]

Status
Not open for further replies.
Level 1
Joined
Oct 9, 2019
Messages
5
I'm trying to make a trigger which increases tech level of some upgrade every X gold a player has earned. I have tried using Total gold gathered field but it doesn't work as it (probably) is total gold harvested from goldmines. The other approach I tried was trying to use event "current gold is greater than previous gold stored in a variable" but it seems I can't compare current gold to a variable in an event as the list of variables available is empty.
 
Every time the player gains gold through any means you need to track how much gold the player received, save that amount to a real variable and just keep tracking it.

Then you have other triggers with the event "Value of real variable becomes equal to X" that fires when the total gold earned exceeds your preferred targets.
 
Level 1
Joined
Oct 9, 2019
Messages
5
Every time the player gains gold through any means you need to track how much gold the player received, save that amount to a real variable and just keep tracking it.

Then you have other triggers with the event "Value of real variable becomes equal to X" that fires when the total gold earned exceeds your preferred targets.
I get this part but I'm not sure how to determine when does the player gets gold. If I try to check every a fraction of a second whether player's gold amount increased there's a possibility his gold will decrease and increase between event checks.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,510
Here's a system I found that will monitor your gold/lumber changes. This system is made in Jass but it's designed to be used in GUI. So you don't need to use any Custom Scripts or have any knowledge of Jass in order to use it. Player Resource Monitoring v1.01 Give credits to ZiBitheWand3r3r if you use it.

I also attached a map that shows you how to use the system and has an example of how you could research upgrades using the system. Here's a trigger from the map:
PRM_EVENT becomes Equal to 1.00 is a custom event that fires whenever a Player gains or loses gold. PRM_Change is the amount of gold that was gained/lost. If PRM_Change is greater than 0 then we know that the gold was gained and not lost. Once we have confirmed that the gold was gained we can add in our own Actions to do things like check if we should increase the level of an upgrade. PRM_Player = The player that gained/lost gold.
  • Upgrade
    • Events
      • Game - PRM_EVENT becomes Equal to 1.00
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PRM_Change Greater than 0
        • Then - Actions
          • -------- Put your Actions here: --------
          • Set PlayerNumber = (Player number of PRM_Player)
          • Set TotalGoldEarned[PlayerNumber] = (TotalGoldEarned[PlayerNumber] + PRM_Change)
          • Game - Display to (Player group(PRM_Player)) for 10.00 seconds the text: (Total Gold Earned: + (String(TotalGoldEarned[PlayerNumber])))
          • -------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current research level of Iron Forged Swords for PRM_Player) Less than 3
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current research level of Iron Forged Swords for PRM_Player) Not equal to 1
                  • TotalGoldEarned[PlayerNumber] Greater than or equal to 100
                  • TotalGoldEarned[PlayerNumber] Less than 200
                • Then - Actions
                  • Player - Set the current research level of Iron Forged Swords to 1 for PRM_Player
                  • Game - Display to (Player group(PRM_Player)) for 10.00 seconds the text: |cff00ff00Iron Forg...
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Current research level of Iron Forged Swords for PRM_Player) Not equal to 2
                      • TotalGoldEarned[PlayerNumber] Greater than or equal to 200
                      • TotalGoldEarned[PlayerNumber] Less than 300
                    • Then - Actions
                      • Player - Set the current research level of Iron Forged Swords to 2 for PRM_Player
                      • Game - Display to (Player group(PRM_Player)) for 10.00 seconds the text: |cff00ff00Iron Forg...
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • TotalGoldEarned[PlayerNumber] Greater than or equal to 300
                        • Then - Actions
                          • Player - Set the current research level of Iron Forged Swords to 3 for PRM_Player
                          • Game - Display to (Player group(PRM_Player)) for 10.00 seconds the text: |cff00ff00Iron Forg...
                        • Else - Actions
            • Else - Actions
        • Else - Actions
As you can see, this trigger will increase the level of Iron Forged Swords by 1 for every 100 total gold earned, up to a maximum level of 3. Note that this isn't a very pretty solution using 4 If Then Else statements but it's just an example. Maybe someone else can come up with a better method of doing this.
How to import into your map:
1) Enable "automatically create unknown variables" in your World Editor preferences if you haven't already.
2) Copy and paste the "Upgrade" folder into your map.
3) Edit the "Upgrade" trigger to suit your needs.
Here's the trigger without some of the stuff I added in. So where it says "Put your Actions here:" you would add in your own Actions referencing the variables used in the system. I explain it in greater detail inside of the map.
  • Upgrade
    • Events
      • Game - PRM_EVENT becomes Equal to 1.00
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PRM_Change Greater than 0
        • Then - Actions
          • -------- Put your Actions here: --------
          • Set PlayerNumber = (Player number of PRM_Player)
          • Set TotalGoldEarned[PlayerNumber] = (TotalGoldEarned[PlayerNumber] + PRM_Change)
        • Else - Actions
 

Attachments

  • Gold Earned Example 2.w3x
    21.5 KB · Views: 22
Last edited:
Status
Not open for further replies.
Top