Shared Resources (Gold and Lumber)

jedi8955

New Member
Reaction score
4
I'm working on a map where during the course of play, a player might switch sides to join the enemy.

I'm trying to figure out how to get this new player to have access to the enemy team's resources. All the players on that team now have to have the same amount of gold shown and when one person spends gold, have that updated on all of the team.

I don't want to use unit sharing at all for this. I don't want people to move around their allies units. That would lead to griefing far too easily (I can easily imagine players who switch over simply grabbing the army and moving it away from their original allies. I don't mind resource subterfuge, but that's way too frustrating.)

I can't find any way to do this. Any help would be appreciated :)
 

the_ideal

user title
Reaction score
61
You'll have to trigger the cost of everything, and trigger everyone's resources. You can store each team's resources in a variable and constantly set their gold and lumber amount to that variable, so they can see that amount their team has. (And since the cost of everything will be triggered and not actually cost gold and lumber, there won't be a problem with people buying stuff and messing up the system.)

That being said, because you would have to trigger the cost of everything, this would be a LOT of work.

To trigger the prices, you would have to include the prices in the tooltips, and make every item free. (cost 0 lumber, 0 gold) Then, when an item is purchased, check to see if a player's team has enough resources for it. If the team has enough resources, then subtract the cost of the item from the team's resources. If the team does not have the required cost of the item, then remove the item from the game.

Hope this helps!
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
wat, ideal is wrong don't listen to him


you need to make a system like this:

1). Store your team's gold in a variable.
2). Set team member's gold to the stored number.
3). If a team member's gold changes, the difference between the stored number and the team member's gold is how much was spent / earned. You should then modify the stored number with the difference, and then update all the team's gold again.
 

jedi8955

New Member
Reaction score
4
wat, ideal is wrong don't listen to him


you need to make a system like this:

1). Store your team's gold in a variable.
2). Set team member's gold to the stored number.
3). If a team member's gold changes, the difference between the stored number and the team member's gold is how much was spent / earned. You should then modify the stored number with the difference, and then update all the team's gold again.

I had a feeling it would end up something like this. I was hoping for something a bit more elegant, but oh well.

So I just implemented a system like this and everything went bloody insane. Let me put in the trigger before I explain the problem, hopefully things will be clearer.

Trigger:
  • Events
    • Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set GoldMod_Int = (SharedGold_Int - (Player 10 (Light Blue) Current gold))
      • Set GoldMod_Int = (GoldMod_Int + (SharedGold_Int - (Soul1_Player) Current gold))
    • Set GoldMod_Int = (GoldMod_Int + (SharedGold_Int - (Soul2_Player) Current gold))
    • Set SharedGold_Int = (SharedGold_Int - GoldMod_Int)
    • Player Group - Pick every player in Attacker_PlayerGroup and do (Actions)
      • Loop - Actions
        • Player - Set (Picked player) Current gold to SharedGold_Int
    • Set GoldMod_Int = 0


Explanation of variables-

SharedGold_Int: This stores how much gold the team overall has.
GoldMod_Int: This stores how much the team's gold has changed.
Soul#_Player: These are slots where a player might end up changing sides during the course of the game. These variables start off null.

So, I fire this up and test it out. Single player, just me as Player 10. The first gold Player 10 gets is 100g during the setup phase of my map.

Every 1.00 seconds thereafter, the gold freaks the hell out. It alternates between 0 and doubling of the previous number.

Example:

Second 1: 100g
Second 2: 0g
Second 3: 200g
Second 4: 0g
Second 5: 400g
etc.

I obviously screwed something up, hard. I don't know if it's syntax or timing or what. I'm hoping that WC3 can handle negative numbers, this system won't work without them.

Thanks for the help, always appreciated.
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
Do you use Jass NewGen Pack? I'll make something for you in vJASS if you like.

what are these two lines:
Trigger:
  • Set GoldMod_Int = (GoldMod_Int + (SharedGold_Int - (Soul1_Player) Current gold))
    • Set GoldMod_Int = (GoldMod_Int + (SharedGold_Int - (Soul2_Player) Current gold))
 

jedi8955

New Member
Reaction score
4
Do you use Jass NewGen Pack? I'll make something for you in vJASS if you like.

what are these two lines:
Trigger:
  • Set GoldMod_Int = (GoldMod_Int + (SharedGold_Int - (Soul1_Player) Current gold))
    • Set GoldMod_Int = (GoldMod_Int + (SharedGold_Int - (Soul2_Player) Current gold))


I don't have NewGen, I actually don't have a single thing in this map JASS style yet. I'd appreciate the help, but I don't know how NewGen works and how it would impact testing and playing.

Those two lines take into account a player who might end up becoming allied to Player 10. When they activate a special ability, they're assigned to those Player variables and added to Attacker_PlayerGroup.
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
Get JNGP. Trust me on that - it is in every way superior to an unmodded World Editor, and will have no impact on testing (although some settings might affect things, like enabling Reinventing the Craft).

Also, this is your problem:

Trigger:
  • Set GoldMod_Int = (GoldMod_Int + (SharedGold_Int - (Soul1_Player) Current gold))


If Soul1_Player is not set, then the amount of gold Soul1 has is 0. Add an if statement that only runs that line if Soul1_Player is actually a player (not null).
 

jedi8955

New Member
Reaction score
4
I finally got to implement that change and test it last night, worked perfectly.

Thanks a bunch for the help, I'd rep, but it won't let me give it to ya again =)
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top