HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Mass Units from one building

09-21-2008, 10:36 AM#1
Kabel
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-21-2008, 11:20 AM#2
Tide-Arc Ephemera
NumberOfUnits is an integer variable (no array)
TempGroup is a unit group variable (no array)
TempPoint is a point/location variable (no array)

I'm using UMSWE, so don't worry about the (==) or rect stuff, rect is what normal WE would call a region...

Trigger:
Mass Training
Collapse Events
Unit - A unit enters (Playable map area)
Collapse Conditions
(Unit-type of (Triggering unit)) Equal to (==) DUMMY FOOTMAN
Collapse Actions
Set TempGroup = (Units of type Farm)
Set TempPoint = (Position of (Triggering unit))
Set NumberOfUnits = 0
Collapse Unit Group - Pick every unit in TempGroup and do (Actions)
Collapse Loop - Actions
Set NumberOfUnits = (NumberOfUnits + 1)
Unit - Create NumberOfUnits Footman for (Owner of (Triggering unit)) at TempPoint facing Default building facing (270.0) degrees
Custom script: call DestroyGroup(udg_TempGroup) //This is for cleaning leaks
Custom script: call RemoveLocation(udg_TempPoint) //and this, too.
Unit - Kill (Triggering unit) //and this, too.
09-24-2008, 08:31 PM#3
Askhati
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
Anopob
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
Anitarf
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
chobibo
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

Collapse 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