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

[Trigger] Food system

Status
Not open for further replies.
Level 6
Joined
May 31, 2008
Messages
218
I'm trying to make a system which should work something like this: once every 60 seconds you get a unit that once it has traveled to a specific point will add 4 food to you food cap(if food cap is the right thing to use) Then when you buy a unit you lose one food from the food cap, so if you would get a unit that gives you 4 food, then you buy a unit you just have 3 food left. And if you buy another 3 units your food cap is 0 and then you can't buy more units, these parts are easy. But i need to solve the problem that you can have 1 in food cap, but you can still start producing maybe 4 units in a house. Once the first unit is done you can't put more units into the production queue, but the units still in production will be produced and this results in your food being under 0, so if you had 0/1 when you started production, you now got a odd number like 0/-3, and this fucks things up for me. You shouldn't be able to produce units when food is 0/0.

So if any1 could give me a few hints how to do this, if i need variables or anything.
 
Level 9
Joined
Nov 4, 2007
Messages
931
So maybe do an if/then/else that checks for an integer comparison before you use the action to make the food cap go down by one that checks to see if the food cap # is greater than 0, that way it shouldn't lower the food cap into the negatives, I assume thats what you were asking to solve.
 
Level 6
Joined
May 31, 2008
Messages
218
I need a little more help, since i can still produce units in the production queue considering the foodcap is 0. I need the units to be stopped trained if the foodcap is 0. At the moment the ability to put more units in the production queue is oki, since i have made it so you can't make units once foodcap is 0 but as i said, they still finish traning units in the production queue.
 
Last edited:
Level 9
Joined
Nov 4, 2007
Messages
931
Hmmm, the only thing that really comes to mind is that, if its just a single building per player thats producing your units would be to do a Unit Replacement action, and replace the building structure with itself, that way the production que for units being built in it will be cleared.
 
Level 6
Joined
May 31, 2008
Messages
218
Well, i need to stop production in several buildings which might be different buildings. And you will lose and build new structures during the whole game. But i could try something with replace, since it could work but might be useless when thinking about that 12 players might need to do it with 10 buildings each, but not really familiar with how much lagg that could create.
 
Level 9
Joined
Nov 4, 2007
Messages
931
Heh, replacing a unit with itself shouldn't really cause that much lag in my opinion, it should run fine but if it doesnt you may have to find a different way to cancel your units or just set a maximum availability of units based on food cap, I'm not sure if that would work though since it looks like you may have already tried it
 
Level 6
Joined
May 31, 2008
Messages
218
It seems to work with the replace command, just that i have to exclude a few structes.
But then shouldn't i be able to have a event that a building is starting to train something, and if the foodcap for the player is 0 then just replace that specific unit?
 
Level 9
Joined
Nov 4, 2007
Messages
931
That might work, but I wouldn't bet on it, I think replace command if for units that are currently on the map, not for units in progress, and I don't think you can replace a training unit, only trained units
 
Level 6
Joined
May 31, 2008
Messages
218
I meant the structure that is traning the unit^^ But i found one flaw atm, If you are upgrading something in the house, you might lose the progress on upgrade, or if you are upgrading a keep to a castle aswell, but then i should be able to place a few if/then/else actions right?
 
Status
Not open for further replies.
Top