| 09-21-2008, 10:36 AM | #1 |
Here is the scenario: I click on a barrack to train a unit. The number of units that pops out from the building is equal to the number of farms you have. Example, I train a footman in a barrack. I control 5 farms, when the footman is finished, 5 footmen pops out from the barrack, equal to the number of farms I have. I thought of haveing the footman as a dummy unit that instantly dies when it pops out and spawns a certain number of units upon its death. Any ideas how to do solve this problem? |
| 09-24-2008, 08:31 PM | #3 |
What about the Footman's price though - any way of changing it to reflect the number of units you'll get? |
| 09-24-2008, 10:43 PM | #4 |
What do you mean? If you still want it to cost (Price of Footmen) x (Number of Footmen), then you will have to add a condition to check if the player has that much money, and then spawn units accordingly (of course, if you do it this way you can't spawn then all at the start and have to keep checking with conditions). |
| 09-25-2008, 09:27 AM | #5 |
Why don't you just make farms able to train units, if you want to be able to train one unit per farm? |
| 09-25-2008, 11:03 AM | #6 |
A.) Give the single footman the price of N footmen. B.) Total Gold - Footman price * 4 C.) 1.) Get Total Gold 2.) Deduct X gold for every footman Sample only:function Sample takes nothing returns nothing local integer GOLD=GetPlayerState( GetTriggerPlayer(), ConvertPlayerState(1) ) local integer price=135 local integer footmen_max=4 local integer n=0 loop exitwhen GOLD<price or n==footmen_max set GOLD=GOLD-price // create your footman endloop call SetPlayerState(GetTriggerPlayer(), ConvertPlayerState(1), GOLD) //constant playerstate PLAYER_STATE_RESOURCE_GOLD=ConvertPlayerState(1) endfunction |
