🏆 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!
I have 5 items placed on the ground(hidden) for each player(6). When a player's gold reaches 100 or more, one of the 5 items should become visible. When it reaches 200 or more gold, two of the items should be visible.. and so on ..
When a player's gold gets bellow 100, all items should become invisible. If for example: the player has 250 gold and then spends 100g remaining with 150g, then only 1 item should remain visible.
This is what I got so far ..
Untitled Trigger 012
Events
Player - Player 1 (Red)'s Current gold becomes Greater than or equal to 0.00
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Player 1 (Red) Current gold) Greater than or equal to 100
Then - Actions
Item - Show 'item'
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Player 1 (Red) Current gold) Less than 200
Then - Actions
Item - Hide 'item'
Else - Actions
I know this trigger doesn't make much sense, but I just can't figure out how to do this properly.
I think your idea is a good starting point but I would only use it to reveal items. In order to hide them, that depends on what ways players can spend their gold in your map. Here's an example:
Hide Items
Events
Unit - A unit Finishes training a unit
Unit - A unit Finishes an upgrade
Unit - A unit Pawns an item (to shop)
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Owner of (Triggering unit)) Current gold) Less than 200
Then - Actions
Item - Hide YourItem
Else - Actions
Etc. I think you get the idea. You'd need to consider all possible events that might lead to a player losing gold, then you can easily hide their items based on the amount remaining
There’s no need to account for every way to lose gold. You can just check the player’s current gold every 0.5s. This is an integer-returning function that is called “Player - Property” instead of something that directly references gold/lumber/food.
How many players should this work for? If more than one, do they all have the same set of items or a separate one for each player? The items could be hidden locally as long as no units can directly interact with them (that includes attacking them to kill them or targeting them in any way).
The item is of the same type (Gold Coin) as you can see in the image I attached above. Each player has a set of 5 items for a total of 30.
Also, I think the event might be relevant only lag wise in this case. I'm fine with every 0.5s event or every 1.0 so long it doesn't lag too much.
I'm not actually sure how to make the whole trigger or how many triggers are needed.
Set VariableSet GoldItem[11] = Gold Coins 0027 <gen>
Set VariableSet GoldItem[12] = Gold Coins 0028 <gen>
Set VariableSet GoldItem[13] = Gold Coins 0029 <gen>
Set VariableSet GoldItem[14] = Gold Coins 0030 <gen>
Set VariableSet GoldItem[15] = Gold Coins 0031 <gen>
-------- Player 2 Items --------
Set VariableSet GoldItem[21] = Gold Coins 0027 <gen>
Set VariableSet GoldItem[22] = Gold Coins 0028 <gen>
Set VariableSet GoldItem[23] = Gold Coins 0029 <gen>
Set VariableSet GoldItem[24] = Gold Coins 0030 <gen>
Set VariableSet GoldItem[25] = Gold Coins 0031 <gen>
-------- and so on --------
Player Group - Pick every player in YourPlayerGroup and do (Actions)
Loop - Actions
Set VariableSet PN = (Player number of (Picked player))
-------- Set to the gold amount the players start with --------
Set VariableSet PrevGoldL[PN] = ((Player(PN)) Current gold)
-------- MdaPN = Multi-dimensional array Player Number --------
Set VariableSet MdaPN = (PN x 10)
For each (Integer GoldL) from 1 to 5, do (Actions)
Loop - Actions
Item - Hide GoldItem[(MdaPN + GoldL)]
-------- Set to True since its not used otherwise it causes a minor issue --------
Set VariableSet IsGoldShown[MdaPN] = True
Current gold is divided by 100 which is the amount each gold coin is suppose to indicate.
MdaPN is a multi-dimensional array. You can read about it on chapter 16 here, along with a lot of other useful stuff Things You Should Know When Using Triggers / GUI The number 10 is the size each players has in the array. In this system it needs to be higher than the amount of gold coins for each player (5).
The system only changes the relevant coin/s so you can track the exact coin/s that is/are shown/hidden. If no change are to be done the system doesnt do many unneeded actions but if the gold amount changes a lot its probably still better to use a player group in conjunction with a periodic event.
I didnt try it in multiplayer but I dont see why it shouldnt work.
Hopefully there arnt any bugs I didnt find.
Gold Indicator
Events
Player - Player 1 (Red)'s Current gold becomes Greater than or equal to 0.00
Player - Player 2 (Blue)'s Current gold becomes Greater than or equal to 0.00
Player - Player 3 (Teal)'s Current gold becomes Greater than or equal to 0.00
Player - Player 4 (Purple)'s Current gold becomes Greater than or equal to 0.00
Player - Player 5 (Yellow)'s Current gold becomes Greater than or equal to 0.00
Player - Player 6 (Orange)'s Current gold becomes Greater than or equal to 0.00
Conditions
Actions
Set VariableSet PN = (Player number of (Triggering player))
Set VariableSet CurrGoldL = (((Player(PN)) Current gold) / 100)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CurrGoldL Equal to PrevGoldL[PN]
Then - Actions
-------- no change --------
Else - Actions
Set VariableSet MdaPN = (PN x 10)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CurrGoldL Greater than PrevGoldL[PN]
Then - Actions
-------- show gold --------
For each (Integer GoldL) from PrevGoldL[PN] to CurrGoldL, do (Actions)
Loop - Actions
Custom script: exitwhen udg_GoldL > 5
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
IsGoldShown[(MdaPN + GoldL)] Equal to False
Then - Actions
Set VariableSet IsGoldShown[(MdaPN + GoldL)] = True
Item - Show GoldItem[(MdaPN + GoldL)]
Game - Display to (All players) the text: (Show item + (String((MdaPN + GoldL))))
Else - Actions
Else - Actions
-------- hide gold --------
For each (Integer GoldL) from (CurrGoldL + 1) to (PrevGoldL[PN] + 1), do (Actions)
Loop - Actions
Custom script: exitwhen udg_GoldL > 5
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
IsGoldShown[(MdaPN + GoldL)] Equal to True
Then - Actions
Set VariableSet IsGoldShown[(MdaPN + GoldL)] = False
Item - Hide GoldItem[(MdaPN + GoldL)]
Game - Display to (All players) the text: (Hide item + (String((MdaPN + GoldL))))
Thank you, I'll try to remake the trigger and replay here after test. It looks very promising.
Edit:
Gold indicator Setup
Events
Time - Elapsed game time is 0.00 seconds
Conditions
Actions
-------- Player 1 --------
Set VariableSet ItemArrayGold[1] = Gold Coins 0179 <gen>
Set VariableSet ItemArrayGold[2] = Gold Coins 0176 <gen>
Set VariableSet ItemArrayGold[3] = Gold Coins 0177 <gen>
Set VariableSet ItemArrayGold[4] = Gold Coins 0180 <gen>
Set VariableSet ItemArrayGold[5] = Gold Coins 0178 <gen>
-------- Player 2 --------
Set VariableSet ItemArrayGold[6] = Gold Coins 0174 <gen>
Set VariableSet ItemArrayGold[7] = Gold Coins 0171 <gen>
Set VariableSet ItemArrayGold[8] = Gold Coins 0172 <gen>
Set VariableSet ItemArrayGold[9] = Gold Coins 0175 <gen>
Set VariableSet ItemArrayGold[10] = Gold Coins 0173 <gen>
-------- Player 3 --------
Set VariableSet ItemArrayGold[11] = Gold Coins 0169 <gen>
Set VariableSet ItemArrayGold[12] = Gold Coins 0166 <gen>
Set VariableSet ItemArrayGold[13] = Gold Coins 0167 <gen>
Set VariableSet ItemArrayGold[14] = Gold Coins 0170 <gen>
Set VariableSet ItemArrayGold[15] = Gold Coins 0168 <gen>
-------- Player 4 --------
Set VariableSet ItemArrayGold[16] = Gold Coins 0154 <gen>
Set VariableSet ItemArrayGold[17] = Gold Coins 0151 <gen>
Set VariableSet ItemArrayGold[18] = Gold Coins 0152 <gen>
Set VariableSet ItemArrayGold[19] = Gold Coins 0155 <gen>
Set VariableSet ItemArrayGold[20] = Gold Coins 0153 <gen>
-------- Player 5 --------
Set VariableSet ItemArrayGold[21] = Gold Coins 0149 <gen>
Set VariableSet ItemArrayGold[22] = Gold Coins 0145 <gen>
Set VariableSet ItemArrayGold[23] = Gold Coins 0146 <gen>
Set VariableSet ItemArrayGold[24] = Gold Coins 0150 <gen>
Set VariableSet ItemArrayGold[25] = Gold Coins 0147 <gen>
-------- Player 6 --------
Set VariableSet ItemArrayGold[26] = Gold Coins 0144 <gen>
Set VariableSet ItemArrayGold[27] = Gold Coins 0143 <gen>
Set VariableSet ItemArrayGold[28] = Gold Coins 0141 <gen>
Set VariableSet ItemArrayGold[29] = Gold Coins 0142 <gen>
Set VariableSet ItemArrayGold[30] = Gold Coins 0139 <gen>
-------- --------
Player Group - Pick every player in (All players) and do (Actions)
Loop - Actions
Set VariableSet PN = (Player number of (Picked player))
-------- Set to the gold amount the players start with --------
Set VariableSet PrevGold[PN] = ((Player(PN)) Current gold)
-------- Multi dimentional array Player number --------
Set VariableSet MdaPN = (PN x 10)
For each (Integer GoldL) from 1 to 5, do (Actions)
Loop - Actions
Item - Hide ItemArrayGold[(MdaPN + GoldL)]
Set VariableSet IsGoldShown[MdaPN] = True
Gold Indicator
Events
Player - Player 1 (Red)'s Current gold becomes Greater than or equal to 0.00
Player - Player 2 (Blue)'s Current gold becomes Greater than or equal to 0.00
Player - Player 3 (Teal)'s Current gold becomes Greater than or equal to 0.00
Player - Player 4 (Purple)'s Current gold becomes Greater than or equal to 0.00
Player - Player 5 (Yellow)'s Current gold becomes Greater than or equal to 0.00
Player - Player 6 (Orange)'s Current gold becomes Greater than or equal to 0.00
Conditions
Actions
Set VariableSet PN = (Player number of (Triggering player))
Set VariableSet CurrentGold = (((Player(PN)) Current gold) / 100)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CurrentGold Equal to PrevGold[PN]
Then - Actions
-------- Nothing --------
Else - Actions
Set VariableSet MdaPN = (PN x 10)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CurrentGold Greater than PrevGold[PN]
Then - Actions
-------- Show Gold --------
For each (Integer GoldL) from PrevGold[PN] to CurrentGold, do (Actions)
Loop - Actions
Custom script: exitwhen udg_GoldL > 5
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
IsGoldShown[(MdaPN + GoldL)] Equal to False
Then - Actions
Set VariableSet IsGoldShown[(MdaPN + GoldL)] = True
Item - Show GoldItem[(MdaPN + GoldL)]
Else - Actions
Else - Actions
-------- Hide Gold --------
For each (Integer GoldL) from (CurrentGold + 1) to (PrevGold[PN] + 1), do (Actions)
Loop - Actions
Custom script: exitwhen udg_GoldL > 5
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
IsGoldShown[(MdaPN + GoldL)] Equal to True
Then - Actions
Set VariableSet IsGoldShown[(MdaPN + GoldL)] = False
Item - Hide GoldItem[(MdaPN + GoldL)]
Else - Actions
Set VariableSet PrevGold[PN] = CurrentGold
So, I managed to reproduce the triggers and test in my map as well as in a new map(just in case it was messing with other triggers), unfortunately it doesn't seem to work.At map initialization I start with 0 gold. If I gain gold after that It doesn't show/hide any coins.
Could you please let me know if I'm missing anything?
It just seems that you missed how the multi dimensional array works.
MdaPN gets set to PN x 10
That means that inside the loop, MdaPN + GoldL (if Player number is 1 and GoldL is 1) will be 11.
So when you set up the ItemArrayGold the array must be set with this in mind.
Player 1 has array 11-15
Player 2 has array 21-25
Player 3 has array 31-35
and so on
I forgot to mention that the Custom script: exitwhen udg_GoldL > 5 inside the loop is used to limit the loop to the 5 arrays available for each player, so if you wanted to add more gold coins you should change that to the amount of gold coins available for each player.
I forgot to mention that the Custom script: exitwhen udg_GoldL > 5 inside the loop is used to limit the loop to the 5 arrays available for each player, so if you wanted to add more gold coins you should change that to the amount of gold coins available for each player.
I will keep that in mind but for now 5 of them is enough.
I'll test it a bit and later add it to my map to check for any bad interactions. (just in case)
Thanks for pointing this out, also for the map. It's much appreciated!
This seems to work as well but is it more lag efficient? By the way, when I try to test it in world editor, I only have 2 (players/computer).. So, I can only test it for 2 no matter what, and I don't know why. I tried to change this in player properties/ forces .. but it doesn't seem to work.
Also, as an off topic ..
I'm trying to make a trigger that adds 10 gold for each gold coin you have(visible) every 5 seconds.
So, if you have for example: 340 gold, then you should have a 30 gold income every 5 seconds.
Events
Player - Player 1 (Red)'s Current gold becomes Greater than or equal to 100.00
Player - Player 2 (Blue)'s Current gold becomes Greater than or equal to 100.00
Player - Player 3 (Teal)'s Current gold becomes Greater than or equal to 100.00
Player - Player 4 (Purple)'s Current gold becomes Greater than or equal to 100.00
Player - Player 5 (Yellow)'s Current gold becomes Greater than or equal to 100.00
Player - Player 6 (Orange)'s Current gold becomes Greater than or equal to 100.00
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
And - All (Conditions) are true
Conditions
((Triggering player) Current gold) Greater than or equal to 100
((Triggering player) Current gold) Less than 200
Then - Actions
Player - Add 10 to (Triggering player).Current gold
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
And - All (Conditions) are true
Conditions
((Triggering player) Current gold) Greater than or equal to 200
((Triggering player) Current gold) Less than 300
Then - Actions
Player - Add 20 to (Triggering player).Current gold
Else - Actions
I was thinking to make it like this but seeing as it has the same event as the trigger you made I was thinking to incorporate it somehow to futher avoid lag. Do you think it's better to make this trigger separately or is it better to try to incorporate them together? And as it is right now, would you change anything about it? Also, I haven't tested this yet but i'm guessing it works.
There should be no concerns about latency or visual lag for anything used in this thread. You could do all of these things 100 times a second and never notice an effect on the game performance.
Why are you not using a 5s periodic event to add gold? What you are have done is add gold every time they gain gold, which is an infinite loop and will crash the game. You will need to check PrevGold[] to figure out how many coins are currently visible to the player and then multiply that by 10 to add:
Events
Time - Every 5.00 seconds of game-time
Conditions
Actions
Player Group - Pick every player in (All Players) and do (Actions)
Loop - Actions
Player - Add (PrevGold[(Player number of (Picked Player))] x 10) to (Picked Player) Current Gold
In player properties you should be able to change players controller status. Did you change players to Computers and it still doesnt work? Additional User slots will be empty when you test the map in world editor.
You can do what Pyrogasm said but PrevGold[] can be greater than 5 so youd need a boolean check to make sure no more than 50 gold is added.
if PrevGold is greater than 5 then
add 50 gold to Player
else
add PrevGold x 10 to Player
endif
I seems to work with the trigger you suggested and it even caps at 50, which is great.
In player properties you should be able to change players controller status. Did you change players to Computers and it still doesnt work? Additional User slots will be empty when you test the map in world editor.
As you can see it only loads 2 players. This happens when I test in editor. I'm guessing it would be different if I were to open the map normally but in editor at least, it only shows 2 players.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.