HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Subtraction Problem

12-23-2004, 06:20 PM#1
pappi.chullo
The game bases the "population" by the total ammount of mana in certain buildings. When a building is destroyed or casts "Demolish", the ammount from the building would subtract from the total population. The trigger does work, only that it does not subtract when there is one building left, and when it does get destroyed, the "population" doesn't go down.

Example:

1 farm has a mana cap of 8.
6 farms would sum up to 48.
When 5 are destroyed, remainer should be 8.
When 6 are destroyed, remainer should be 0, but results as 8.

Code:
Game Demolish
    Events
        Unit - A unit Begins casting an ability
    Conditions
        (Ability being cast) Equal to Demolish 
    Actions
        Set temp_citizenbuilding = (Casting unit)
        Player - Add (((Custom value of temp_citizenbuilding) x diff_refund) / 100) to (Owner of temp_citizenbuilding) Current gold
        Game - Display to (Player group((Owner of temp_citizenbuilding))) for 0.50 seconds the text: (|cffffcc00Refunded  + ((String((((Custom value of temp_citizenbuilding) x diff_refund) / 100))) + ( gold for demolishing  + ((Name of temp_citizenbuilding) + .|r))))
        Unit - Set mana of temp_citizenbuilding to 0.00
        Special Effect - Create a special effect at (Position of temp_citizenbuilding) using Objects\Spawnmodels\Human\HCancelDeath\HCancelDeath.mdl
        Unit - Remove temp_citizenbuilding from the game
        Set temp_citizenbuilding = No unit
        Trigger - Run Citi Update <gen> (ignoring conditions)

Citi Update
    Events
    Conditions
    Actions
        Set temp_population = (Units in (Playable map area) matching ((((Matching unit) is A structure) Equal to True) and ((((Matching unit) is Undead) Equal to True) and (((Matching unit) is alive) Equal to True))))
        Unit Group - Pick every unit in temp_population and do (Actions)
            Loop - Actions
                Set player_population[(Player number of (Owner of (Picked unit)))] = (player_population[(Player number of (Owner of (Picked unit)))] + (Integer((Mana of (Picked unit)))))
                Set temp_citizenbuildingcount = (Picked unit)
                Player - Set (Owner of temp_citizenbuildingcount) Current lumber to player_population[(Player number of (Owner of temp_citizenbuildingcount))]
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Unit-type of temp_citizenbuildingcount) Equal to Small Residential Zone
                        (Percentage mana of temp_citizenbuildingcount) Greater than or equal to 85.00
                    Then - Actions
                        Player - Make Small Home Available for training/construction by (Owner of temp_citizenbuildingcount)
                        Unit - Order temp_citizenbuildingcount to train/upgrade to a Small Home
                        Player - Make Small Home Unavailable for training/construction by (Owner of temp_citizenbuildingcount)
                    Else - Actions
                        Do nothing
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        ((Owner of temp_citizenbuildingcount) Current lumber) Greater than or equal to 3500
                    Then - Actions
                        Unit - Replace player_population_dummy[(Player number of (Owner of temp_citizenbuildingcount))] with a Population: 3500 using The new unit's default life and mana
                    Else - Actions
                        Unit - Replace player_population_dummy[(Player number of (Owner of temp_citizenbuildingcount))] with a Population: 0 using The new unit's default life and mana
        Set player_population[(Player number of (Owner of temp_citizenbuildingcount))] = 0
        Set temp_citizenbuildingcount = No unit
12-25-2004, 12:51 AM#2
pappi.chullo
Bump...... :\
12-25-2004, 02:11 AM#3
AntJAB
Sorry Pappi, I keep meaning to look at it but I've just never had time.
I promise after x-mas I'll give it look over.

Happy hollidays.