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!
Not sure what you mean by a local player resource leaderboard.
Do you mean a leaderboard which is specific to each player?
What you probably need to do is create all the leaderboard variables in a global block, but display information differently based on each player in a local player block. This way all the agents exist on all clients, but they simply show different information. I haven't worked with leaderboards yet and am unfamiliar with their API, but since MineralZ does it, this is more than possible.
In fact you probably only need one leaderboard, but the information it shows is done in a local player block. So everyone only sees their own resources.
Er, what I mean is I want basically a Leaderboard that displays different information per player. I'm going to use it to display 4 resources, Gold, Lumber, Oil, and Food, and use the Leaderboard to show the count instead of the built-in.
Hopefully what you've mentioned will help. But I think I may need a better explanation then that.
Okay, maybe I should start this from the top before even bothering with Local Player. I'm not quite sure how to set up this custom resource system.
What i needs to do is when a Worker is ordered to harvest from a Gold Mine, he goes in and comes out as normal, and then when he returns the gold it needs to reset the gold and then instead modify the Leaderboard.
It might be better to make a separate thread for your question about how to get a leaderboard working at all, which is a much different (albeit related) question from the OP and the thread title.
I would first checked leaderboard tutorials first and try them out.
Once you get it working then revisit this topic (which requires you know how to get the leaderboard working).
Custom resources are easy to do--just assign each player an real or integer corresponding to the resource and modify it accordingly. Update the leaderboard whenever one of those resources get modified.
Thankfully that won't be a problem for me, because I never plan on removing the Leaderboard.
EDIT2: I'm going to bed for the night. I'm also attempting to make a Harvesting system myself. I'll update this thread if I need any help or make any significant progress.
For detecting a change in resources, simply use a player state event.
native TriggerRegisterPlayerStateEvent trigger whichTrigger, player whichPlayer, playerstate whichState, limitop opcode, real limitval
So to use this to detect someone's gold increasing, your code might look like this
JASS:
local trigger t = CreateTrigger()
local integer playerGold = playerGolds[0]
call TriggerRegisterPlayerStateEvent(t, Player(0), PLAYER_STATE_RESOURCE_GOLD, NOT_EQUAL, playerGold)
call TriggerAddCondition(t, Condition(function main))
Use the limit op NOT_EQUAL so whenever the player's gold isn't equal to what you have stored in your separate variable, the event will fire off. In your main you will need detect by how much the gold changed, change the variable/array member accordingly, and then apply the changes (locally) to the player's leader board.
For detecting a change in resources, simply use a player state event.
native TriggerRegisterPlayerStateEvent trigger whichTrigger, player whichPlayer, playerstate whichState, limitop opcode, real limitval
So to use this to detect someone's gold increasing, your code might look like this
JASS:
local trigger t = CreateTrigger()
local integer playerGold = playerGolds[0]
call TriggerRegisterPlayerStateEvent(t, Player(0), PLAYER_STATE_RESOURCE_GOLD, NOT_EQUAL, playerGold)
call TriggerAddCondition(t, Condition(function main))
Use the limit op NOT_EQUAL so whenever the player's gold isn't equal to what you have stored in your separate variable, the event will fire off. In your main you will need detect by how much the gold changed, change the variable/array member accordingly, and then apply the changes (locally) to the player's leader board.
But then I have to have one of those for all 12 players....Right?
Anyway, okay, so here's what I got so far for the system:
When a unit is ordered to Harvest from a Gold Mine via my fake harvesting ability that is based off of Shadow Strike, and he uses the ability, that's how I pick up on the Worker "Entering" the Gold Mine. Via trigger, I morph the unit into an invisible unit with no movement and no attack, and remove them from the players selection, then after a timer I morph them back into the original unit, remove the dummy Harvest (Shadow Strike) ability, and order them to return to the closest Town Hall, once the dummy Return Resources ability goes off I can pick up on that as a "Unit Starts the Effect of an Ability" event, and set the amount of gold accordingly, without the actual Gold count in the UI being modified at all.
This is what I got so far:
Ordered To Mine
Events
Unit - A unit Starts the effect of an ability
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of (Triggering unit)) Equal to Peasant
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Shadow Strike
Then - Actions
Unit - Add Peasant Morph to (Triggering unit)
Unit - Remove Peasant Morph from GoldMorpherUnit
Selection - Remove (Triggering unit) from selection for (Owner of (Triggering unit))
Set GoldMorpherUnit = (Triggering unit)
Else - Actions
Else - Actions
Timer Order Return
Events
Time - Every 0.03 seconds of game time
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
GoldMorpherTimer Less than 201
Then - Actions
Set GoldMorpherTimer = (GoldMorpherTimer + 1)
Unit - Order GoldMorpherUnit to Undead Crypt Fiend - Web Gold Mine 0013 <gen> //They will be ordered this until the timer goes off, so that way they aren't showing up as an Idle Worker.
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
GoldMorpherTimer Equal to 201
Then - Actions
Unit - Add Return Resources to GoldMorpherUnit
Unit - Remove Shadow Strike from GoldMorpherUnit
Unit - Add Peasant Remorph to GoldMorpherUnit
Unit - Order GoldMorpherUnit to Human Blood Mage - Banish Great Hall 0008 <gen>
Set GoldMorpherUnit = No unit
Else - Actions
Ordered to Return
Events
Unit - A unit Starts the effect of an ability
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Return Resources
Then - Actions
Selection - Remove (Triggering unit) from selection
Unit - Add Peasant Morph to (Triggering unit)
Unit - Add Shadow Strike to (Triggering unit)
Unit - Remove Return Resources from (Triggering unit)
Else - Actions
NOTE: I am not working on making this MUI just yet. I want to get everything functioning first, then make it MUI.
Return Resources is based off of Channel using Banish order.
When this is 100% working (Which it's not right now), it will be so much easier to catch the Gold Returned event via this then other suggested methods...
The first problem I'm having is that it doesn't want to Remove Shadow Strike or add the Return Resources ability, and the order does not matter as I've swapped them back and forth a lot.
The range on the Shadow Strike and Return Resources abilities are extremely short, so these casting events will only go off if they are in the right place.
Okay, I finished the base of the system and now I need to make it MUI. I still have some stuff I need to fix but now that I figured everything else out it won't be hard to fix. Once I get it 100% done, cleaned up, and working flawlessly, I'll post it.
There is ONE problem that I'm not quite sure how to fix, though, and that's this:
Timer Order Harvest
Events
Time - Every 0.03 seconds of game time
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
GoldReturningUpdate Equal to 1
GoldReturnedTimer Less than 67
Then - Actions
Set GoldReturnedTimer = (GoldReturnedTimer + 1)
Selection - Remove GoldReturningUnit from selection
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
GoldReturningUpdate Equal to 1
GoldReturnedTimer Equal to 66
Then - Actions
Unit - Remove Peasant Morph from GoldReturningUnit
Unit - Add Peasant Remorph to GoldReturningUnit
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
GoldReturningUpdate Equal to 1
GoldReturnedTimer Equal to 67
Then - Actions
Set GoldReturningUpdate = 0
Unit - Remove Peasant Remorph from GoldReturningUnit
Unit - Add Shadow Strike to GoldReturningUnit
Unit - Remove Return Resources from GoldReturningUnit
Animation - Remove the gold animation tag to GoldReturningUnit
Set GoldReturnedFinished = 1
Set PlayerGold[1] = (PlayerGold[1] + 100)
Multiboard - Set the text for PlayerResources item in column 1, row 1 to (|c00BBAA00Gold:|r + (String(PlayerGold[1])))
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
GoldPointOrder Equal to False
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
GoldMineInRange Equal to True
Then - Actions
Unit - Order GoldReturningUnit to Night Elf Warden - Shadow Strike TargetGoldMine
Set GoldMineInRange = False
Else - Actions
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
GoldPointOrder Equal to False
GoldMineInRange Equal to False
GoldReturnedFinished Equal to 1
Then - Actions
Game - Display to (All players) the text: FIRED!
Unit - Remove Shadow Strike from GoldReturningUnit
Unit - Add Harvest (Point Order) to GoldReturningUnit
Unit - Order GoldReturningUnit to Orc Far Seer - Earthquake (Position of TargetGoldMine)
Set GoldPointOrder = True
Set GoldReturnedFinished = 0
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
GoldPointOrder Equal to True
GoldMineInRange Equal to False
Then - Actions
Custom script: set bj_wantDestroyGroup = true
Unit Group - Pick every unit in (Units within 500.00 of (Position of GoldReturningUnit)) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Picked unit) Equal to TargetGoldMine
Then - Actions
Set GoldMineInRange = True
Set GoldPointOrder = False
Unit - Remove Harvest (Point Order) from GoldReturningUnit
Unit - Add Shadow Strike to GoldReturningUnit
Else - Actions
Else - Actions
The part I'm having a problem with is near the bottom, "Unit - Order GoldReturningUnit to Orc Far Seer - Earthquake (Position of TargetGoldMine)"
The Position of the Target Gold Mine seems to go a bit off course, heading in an almost different direction. It's not much of a deviation of the course it should take, but it's enough to where lets say if it's going half-way across the map, the worker may never find the Gold Mine....
EDIT2: Okay, I'm going to leave this thread to making the Leaderboard LocalPlayer-able, and make a new thread for working with my Resource Harvesting System.
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.