• 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!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[B]Limiting Resources[/B]

Status
Not open for further replies.
Level 11
Joined
Aug 24, 2009
Messages
706
I would like to know how you can have a limit to resources like gold and lumber. For example if you build a stockpile your limit goes up by 3000 and cant go over the limit when gathering your resources. Is there any way to do this...
 
Level 6
Joined
May 31, 2008
Messages
218
Maybe make a variable that stores a number, and everytime you make one of those buildings the number of the variable increases. So then you can check the variable each time resources are dropped off, and if your variable shows the right number of stockpiles the resources can be stored. Else they are thrown away or w/e. This was just a thought i had, no idea if it works^^
 
Level 6
Joined
Jul 24, 2008
Messages
180
Create a formula to suit your needs. To make it easy, provided its a linear gain, you can set the 'Point Value' for said building to the amount you want it to increase. Then your formula could be (2500+(point value of units of type)+(point value of units of different type)) etc... Theres a plethera of ways to approach this so do what works for you. Variables, custom values, hashtables, point values, etc. Anything that can store an integer/real can essentially work. Hope I helped and didn't confuse you further.
 
Take a look at a map called "Missile command" in the epicwar database, if you find the oldest one it's not protected and it has exactly what you need.

Also, you'd have to find a way to disable "Shift + Clicking" as this would make it so you could just order a unit to shift build a whole bunch of stuff then order it to stop when you want the extra resources.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
I'm going to make a quick system right now that handles this - by the way there is a "best" way of doing this, and that is by using the player properties events.

Okay, here's some useful information I have found:

If you have an event that responds when a player's gold is above 0, then every time the player's gold changes it will fire the event. This means you can detect every single change made to the player's gold, and adjust it accordingly so that it never exceeds a certain limit (same for lumber). I suggest you store the player's gold/lumber limit in integer arrays which you modify with various different triggers. Here's an example:

  • Untitled Trigger 001
    • Events
      • Player - Player 1 (Red)'s Current gold becomes Greater than -1.00
      • Player - Player 2 (Blue)'s Current gold becomes Greater than -1.00
      • Player - Player 3 (Teal)'s Current gold becomes Greater than -1.00
      • Player - Player 4 (Purple)'s Current gold becomes Greater than -1.00
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering player) Current gold) Greater than PlayerGoldLimit[((Player number of (Triggering player)) - 1)]
        • Then - Actions
          • -------- Subtracting one from the player-number will normalize the result, giving you a "starting" index of 0 for player 1 (which is how arrays work). --------
          • Player - Set (Triggering player) Current gold to PlayerGoldLimit[((Player number of (Triggering player)) - 1)]
        • Else - Actions
Create an integer array (of size 16) named "PlayerGoldLimit" and copy this script into your map. It will completely disable the player from obtaining any gold (since the initial value of the array indexes are 0). Use the "greedisgood ####" cheat to test it out, you'll find that the player will gain lumber, but no gold (players 1-4 that is).
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Actually there is strange bug with mine. If player 1's gold changes then for some reason it will execute the trigger as if every player's gold has changed. It seems more like a bug on blizzard's part, since a trigger should never be executed multiple times from just a single event.

** You would also have to disable the trigger before changing the player's gold, or the event will respond to its own actions.

Yea, its definitely a bug on blizzard's part. If you have two completely separate triggers that respond when two different players' gold amounts change (no matter what comparison) then both of the triggers will run, even though only one of them has had its events satisfied.

Never-mind, its not as bugged as I thought. I forgot that the cheats I was using to test this are applied for all players, which is why all of the events were firing.

It will work as it is supposed to, but you should still disable/enable the trigger before/after changing the player's gold state. Yay!
 
Status
Not open for further replies.
Top