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

Shared Team Resource System

Status
Not open for further replies.
Level 4
Joined
Aug 14, 2007
Messages
66
Im trying to incorporate a system in my map that makes a computer controlled player serve as the pool of resources that every player on the same team withdraws from. Its pretty much that instead of 1 player controlling a base in a melee game, multiple Players on the same team control a base against another team of Players.

Each team has 5 players and 2 computers.

Main Computer - Owns workers and town hall types/barracks types. Shares resources, and vision with Players
Shared Computer - Owns blacksmith types/altar types. Shares resources with Main Computer. Also shares vision, and advanced unit control with Players.

So far I have each Players gold set to their Main Computer's resources divided by 5 (the number of players on the team) and the Shared Computer's resources set to the Main Computer's resources.

  • Resources
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Player - Set Team 1 (Player 1) Current gold to ((Team 1 Main Computer (Player 11) Current gold) / 5)
      • Player - Set Team 1 (Player 1) Current lumber to ((Team 1 Main Computer (Player 11) Current lumber) / 5)
      • Player - Set Team 2 (Player 6) Current gold to ((Team 2 Main Computer (Player 12) Current gold) / 5)
      • Player - Set Team 2 (Player 6) Current lumber to ((Team 2 Main Computer (Player 12) Current lumber) / 5)
      • Player - Set Team 1 Shared Computer (Neutral Extra) Current gold to ((Team 1 Main Computer (Player 11) Current gold) + 0)
      • Player - Set Team 1 Shared Computer (Neutral Extra) Current lumber to ((Team 1 Main Computer (Player 11) Current lumber) + 0)
      • Player - Set Team 2 Shared Computer (Neutral Victim) Current gold to ((Team 2 Main Computer (Player 12) Current gold) + 0)
      • Player - Set Team 2 Shared Computer (Neutral Victim) Current lumber to ((Team 2 Main Computer (Player 12) Current lumber) + 0)
*trigger edited for size

Now players can gain control of any one unit that isn't a building or a hero at any time. So they can grab a worker thats currently harvesting and build a tower somewhere.

Im having some issues with the pricing of this. So far the trigger looks like this:


  • Construction
    • Events
      • Unit - A unit Begins construction
      • Unit - A unit Cancels construction
      • Unit - A unit Begins an upgrade
      • Unit - A unit Cancels an upgrade
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Owner of (Triggering unit)) Equal to Team 1(Player 1)
              • (Owner of (Triggering unit)) Equal to Team 1(Player 2)
              • (Owner of (Triggering unit)) Equal to Team 1(Player 3)
              • (Owner of (Triggering unit)) Equal to Team 1(Player 4)
              • (Owner of (Triggering unit)) Equal to Team 1(Player 5)
        • Then - Actions
          • Player - Set Team 1 Main Computer (Player 11) Current gold to ((Team 1(Player 1) Current gold) + (Team 1(Player 2) Current gold) + ((Team 1(Player 3) Current gold) + ((Team 1(Player 4) Current gold) + (Team 1(Player 5) Current gold)))))
          • Player - Set Team 1 Main Computer (Player 11) Current lumber to ((Team 1(Player 1) Current lumber) + ((Team 1(Player 2) Current lumber) + ((Team 1(Player 3) Current lumber) + ((Team 1(Player 4) Current lumber) + (Team 1(Player 5) Current lumber)))))
        • Else - Actions
          • Do nothing
      • Trigger - Run Resources <gen> (checking conditions)
**Note**
The event Unit begins an upgrade or cancels an upgrade refers to a building upgrading into another building like a town hall becoming a keep. Not a research tech from say a blacksmith.


Now this works swimmingly for beginning upgrades and construction but when I cancel it for some reason there is a net gain in resources. Im not sure why that happens so if you know please post for +reps.


Now for my shared computer problem. The shared computer is where players buy heroes for their Team's Main Computer and upgrades for everyone. For purchasing heroes I am going to use an upgrade system with custom upgrades for each hero. The problem lies within the pricing of upgrades.

This is my trigger so far:
  • Research Cost
    • Events
      • Unit - A unit Begins research
      • Unit - A unit Cancels research
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Researching unit)) Equal to Team 1 Shared Computer (Neutral Extra)
        • Then - Actions
          • Player - Set Team 1 Main Computer (Player 11) Current gold to (Team 1 Shared Computer (Neutral Extra) Current gold)
          • Player - Set Player 11 (Dark Green) Current lumber to (Team 1 Shared Computer (Neutral Extra) Current lumber)
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Researching unit)) Equal to Neutral Victim
        • Then - Actions
          • Player - Set Team 2 Main Computer (Player 11) Current gold to (Team 2 Shared Computer (Neutral Victim) Current gold)
          • Player - Set Team 2 Main Computer (Player 11) Current lumber to (Team 2 Shared Computer (Neutral Victim) Current lumber)
        • Else - Actions
          • Do nothing
So since each team's Shared Computer controls the blacksmith type units, and it always has resources equal to the Main Computer, whenever a player uses a Shared Computer controlled blacksmith type unit, the Shared Computer loses resources, then sets the Main Computers resources to its own resources. After that it runs the resources trigger to set each players resources to the Main Computers resources.

Now this works swimmingly as long as the blacksmith type unit only purchases one research throughout the time that the research is being researched.

The events only allow the actions to occur when a player cancels a research being researched, or when a unit begins researching a research.

So if a player purchases a research the unit will start to research and they will lose resources correctly. But when they purchase other researches while the first one is being researched the trigger does not work making each additional research purchased free of charge.

So I need to either prevent players from purchasing multiple researches on a single unit or allow the trigger to fire when multiple researches are purchased from a single unit.

+reps for help
 
Level 10
Joined
Oct 31, 2009
Messages
352
I'm still looking this over and don't have a full grasp of what your doing here atm but just a few things caught my eye:

1. why do you run the resource trigger in your construction trigger if it runs every second anyways?
2. If your doing it this way you really should have that periodic be less than 1 in the first trigger to avoid problems
3. you can remove the "do nothings" and (+0) arithmetic at the end of resource trigger calculations


EDIT - the net gain in resources is because your adding gold to the main computer which is then distributed evenly amongst the players by the periodic


EDIT -
So if a player purchases a research the unit will start to research and they will lose resources correctly. But when they purchase other researches while the first one is being researched the trigger does not work making each additional research purchased free of charge.

I guess you could set something up using the upgrade-finished event. I am really tired atm and will try to address your issues tommorrow if they have not been solved, but honestly i'm sure there are better ways to get this desired effect. The way your doing it now is just asking for well-timed player clicks to disrupt the system.


EDIT (again) - I just figured out a much simpler way to do this which will require just two simple triggers and will even be in GUI :). Will make and post later when I have more energy


__________________________________________________________

I waited till really late to do this again and i'm running on red bulls and 5-hour energies so i'm not entirely sure this will work but it seems logical to conclude that it will (obviously you'll need to expand this to include team 2 and lumber but the idea should remains the same):

  • Gold Comp Change Team 1
    • Events
      • Player - Player 11 (Dark Green)'s Current gold becomes Greater than (Real((Neutral Extra Current gold)))
      • Player - Player 11 (Dark Green)'s Current gold becomes Less than (Real((Neutral Extra Current gold)))
      • Player - Neutral Extra's Current gold becomes Greater than (Real((Player 11 (Dark Green) Current gold)))
      • Player - Neutral Extra's Current gold becomes Less than (Real((Player 11 (Dark Green) Current gold)))
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • GoldChange_Boolean Equal to False
    • Actions
      • Set GoldChange_Boolean = True
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Triggering player) Equal to Player 11 (Dark Green)
        • Then - Actions
          • Player - Set Neutral Extra Current gold to (Player 11 (Dark Green) Current gold)
          • For each (Integer A) from 1 to 5, do (Actions)
            • Loop - Actions
              • Player - Add (((Player 11 (Dark Green) Current gold) - (Neutral Extra Current gold)) / 5) to (Player((Integer A))) Current gold
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Triggering player) Equal to Neutral Extra
        • Then - Actions
          • Player - Set Player 11 (Dark Green) Current gold to (Neutral Extra Current gold)
          • For each (Integer A) from 1 to 5, do (Actions)
            • Loop - Actions
              • Player - Add (((Neutral Extra Current gold) - (Player 11 (Dark Green) Current gold)) / 5) to (Player((Integer A))) Current gold
        • Else - Actions
      • Set GoldChange_Boolean = False
  • Gold Player Change Team 1
    • Events
      • Player - Player 1 (Red)'s Current gold becomes Greater than ((Real((Player 11 (Dark Green) Current gold))) / 5.00)
      • Player - Player 2 (Blue)'s Current gold becomes Greater than ((Real((Player 11 (Dark Green) Current gold))) / 5.00)
      • Player - Player 3 (Teal)'s Current gold becomes Greater than ((Real((Player 11 (Dark Green) Current gold))) / 5.00)
      • Player - Player 4 (Purple)'s Current gold becomes Greater than ((Real((Player 11 (Dark Green) Current gold))) / 5.00)
      • Player - Player 5 (Yellow)'s Current gold becomes Greater than ((Real((Player 11 (Dark Green) Current gold))) / 5.00)
      • Player - Player 1 (Red)'s Current gold becomes Less than ((Real((Player 11 (Dark Green) Current gold))) / 5.00)
      • Player - Player 2 (Blue)'s Current gold becomes Less than ((Real((Player 11 (Dark Green) Current gold))) / 5.00)
      • Player - Player 3 (Teal)'s Current gold becomes Less than ((Real((Player 11 (Dark Green) Current gold))) / 5.00)
      • Player - Player 4 (Purple)'s Current gold becomes Less than ((Real((Player 11 (Dark Green) Current gold))) / 5.00)
      • Player - Player 5 (Yellow)'s Current gold becomes Less than ((Real((Player 11 (Dark Green) Current gold))) / 5.00)
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • GoldChange_Boolean Equal to False
    • Actions
      • Set GoldChange_Boolean = True
      • Player - Set Neutral Extra Current gold to (((Triggering player) Current gold) x 5)
      • Player - Set Player 11 (Dark Green) Current gold to (((Triggering player) Current gold) x 5)
      • Set GoldChange_Boolean = False

Oh and you'll want to keep this off and only turn them on AFTER you've set start-game gold/lumber values
 
Last edited:
Level 4
Joined
Aug 14, 2007
Messages
66
why do you run the resource trigger in your construction trigger if it runs every second anyways?
It runs the trigger to immediately make the changes in the resources.

EDIT - the net gain in resources is because your adding gold to the main computer which is then distributed evenly amongst the players by the periodic
Yes but the player who starts construction loses gold so ultimately it should come out even. The computers gold is being set to the sum of all players gold after a player loses gold.

Oh and you'll want to keep this off and only turn them on AFTER you've set start-game gold/lumber values

All players start with 0 gold, it isnt untill the computer recieves gold/lumber from a worker that anybody has any resources. Why is it a problem?


Thanks for the response Ill try out these triggers!
 
Level 10
Joined
Oct 31, 2009
Messages
352
All players start with 0 gold, it isnt untill the computer recieves gold/lumber from a worker that anybody has any resources. Why is it a problem?

They just shouldn't run until after start values were set otherwise the starting gold/lumber would be evened out among the players. But if your starting at 0 then theres no need to have them off in the beginning.

If theres a problem with the triggers just give me a heads up, I think they should work fine though.
 
Status
Not open for further replies.
Top