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.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top