HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Help with triggers...

02-13-2004, 09:51 PM#1
Octabrain
Yes, i am making a map that spawns armies.
Now the catch is the computer must spawn every 120 seconds
and the food limit must not be all used up.
If the limit is used up, then there should be text saying build
more farms.
If there is enough food, then create the army.

Now how do I make a condition? I searched integer comarison but found no player - food limit.

Help would be appreciated.
02-13-2004, 09:56 PM#2
TitanRevamped
check for number of units. add all the food suply used by the army
02-13-2004, 10:02 PM#3
Octabrain
Yes please explain a bit more - where do you find food count? i cant find it.
02-14-2004, 06:23 PM#4
tay714man
EDIT:

Okay, here is the more clearly organized and "better" way of doing it. There may still be an even better way, but I do not know what it is or if it exists.

First, create your 3 variables. Use integers for all of them. I would use the names "foodcap" (max allowed on the map), "foodmax" (max food a players current farms provide) and "foodused" (food used by players units) simply because I think it is the least confusing. I recommend setting them all to be arrays so you can use one variable for all players. If it is a one player map, this doesn't apply.

Next, make a trigger that runs every time a unit is created or destroyed. Have the trigger see if the unit provides any food (like a farm), or costs any food (like a footman), or doesn't do either (like a barracks).
For unit creation: If it costs food, add the food cost to "foodused".
If it provides food, have it add that amount of food to "foodmax". Add an If-Then that makes sure that "foodmax" can not be greater than "foodcap".
For unit destruction: If it costs food, subtract the food cost from "foodused". If it provides food, subtract the food from "foodmax". You may want to set an if-then that makes sure "foodmax" doesn't go below zero, but unless you are stealing enemy units with charm or possession or something like that, it shouldn't go below zero anyway.

Go to the trigger that creates the unit(s) at every timed interval. Add a condition that checks to see if the food used by the created unit(s) is greater than "foodmax" - "foodused". If it isn't greater than the result of that subtraction, have it create the units. If it is greater, have it display text saying "make more farms" or whatever you want it to say. If you create a lot of units at once, you may have to make individual triggers for each unit created (otherwise it wont create ANY units even if you have the food for some of them).

That should do it. If you have an questions just reply and ask.
02-14-2004, 07:13 PM#5
Octabrain
Now it works. Thanks! :) :infth:
02-15-2004, 12:07 AM#6
tay714man
No problem.