HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

My Shop Sharing Upgrade System - Might Help People

04-27-2008, 07:23 AM#1
Furion
Hey everybody. I promised in my project thread I would post my upgrade system triggers in case they proved helpful to anybody. Here they are:

Trigger:
Upgrades Purchase
Collapse Events
Unit - A unit Sells a unit
Collapse Conditions
((Selling unit) Equal to Altar of Kings 0027 <gen>) or ((Selling unit) Equal to Hall of Upgrades 0164 <gen>)
Collapse Actions
Unit - Hide (Sold unit)
Set UpgradesBought[(Player number of (Owner of (Sold unit)))] = (UpgradesBought[(Player number of (Owner of (Sold unit)))] + 1)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Selling unit) Equal to Altar of Kings 0027 <gen>
Collapse Then - Actions
Game - Display to Alliance the text: ((Name of (Owner of (Sold unit))) + ( has bought + (Name of (Sold unit))))
Unit Group - Add (Sold unit) to UpgradeUnits[1]
Unit - Set the custom value of (Sold unit) to (Number of units in UpgradeUnits[1])
Collapse Else - Actions
Game - Display to Scourge the text: ((Name of (Owner of (Sold unit))) + ( has bought + (Name of (Sold unit))))
Unit Group - Add (Sold unit) to UpgradeUnits[2]
Unit - Set the custom value of (Sold unit) to (Number of units in UpgradeUnits[2])
For each (Integer A) from 1 to 9, do (If ((Unit-type of (Sold unit)) Equal to UpgradeUnitType[(Integer A)]) then do (Set TempInt = (Integer A)) else do (Do nothing))
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
TempInt Equal to 4
Collapse Then - Actions
Set TempUnitGroup = (Units of type (Unit-type of (Sold unit)))
Unit Group - Pick every unit in TempUnitGroup and do (If (((Owner of (Picked unit)) is an enemy of (Owner of (Sold unit))) Equal to True) then do (Unit Group - Remove (Picked unit) from TempUnitGroup) else do (Do nothing))
If (((Number of units in TempUnitGroup) + (Current research level of UpgradeType[TempInt] for (Owner of (Selling unit)))) Equal to 4) then do (Neutral Building - Remove (Unit-type of (Sold unit)) from (Selling unit)) else do (Do nothing)
Custom script: call DestroyGroup( udg_TempUnitGroup )
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
CurrentlyUpgrading[1] Equal to False
(Selling unit) Equal to Altar of Kings 0027 <gen>
Collapse Then - Actions
Unit Group - Pick every unit in UpgradeUnits[1] and do (If ((Custom value of (Picked unit)) Equal to 1) then do (Set TempUnit = (Picked unit)) else do (Do nothing))
For each (Integer A) from 1 to 9, do (If ((Unit-type of TempUnit) Equal to UpgradeUnitType[(Integer A)]) then do (Unit - Order Altar of Kings 0165 <gen> to research UpgradeType[(Integer A)]) else do (Do nothing))
Set CurrentlyUpgrading[1] = True
Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
CurrentlyUpgrading[2] Equal to False
(Selling unit) Equal to Hall of Upgrades 0164 <gen>
Collapse Then - Actions
Unit Group - Pick every unit in UpgradeUnits[2] and do (If ((Custom value of (Picked unit)) Equal to 1) then do (Set TempUnit = (Picked unit)) else do (Do nothing))
For each (Integer A) from 1 to 9, do (If ((Unit-type of TempUnit) Equal to UpgradeUnitType[(Integer A)]) then do (Unit - Order Hall of Upgrades 0166 <gen> to research UpgradeType[(Integer A)]) else do (Do nothing))
Set CurrentlyUpgrading[2] = True
Else - Actions
Collapse Else - Actions
Set TempUnitGroup = (Units of type (Unit-type of (Sold unit)))
Unit Group - Pick every unit in TempUnitGroup and do (If (((Owner of (Picked unit)) is an enemy of (Owner of (Sold unit))) Equal to True) then do (Unit Group - Remove (Picked unit) from TempUnitGroup) else do (Do nothing))
If (((Number of units in TempUnitGroup) + (Current research level of UpgradeType[TempInt] for (Owner of (Selling unit)))) Equal to 3) then do (Neutral Building - Remove (Unit-type of (Sold unit)) from (Selling unit)) else do (Do nothing)
Custom script: call DestroyGroup( udg_TempUnitGroup )
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
CurrentlyUpgrading[1] Equal to False
(Selling unit) Equal to Altar of Kings 0027 <gen>
Collapse Then - Actions
Unit Group - Pick every unit in UpgradeUnits[1] and do (If ((Custom value of (Picked unit)) Equal to 1) then do (Set TempUnit = (Picked unit)) else do (Do nothing))
For each (Integer A) from 1 to 9, do (If ((Unit-type of TempUnit) Equal to UpgradeUnitType[(Integer A)]) then do (Unit - Order Altar of Kings 0165 <gen> to research UpgradeType[(Integer A)]) else do (Do nothing))
Set CurrentlyUpgrading[1] = True
Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
CurrentlyUpgrading[2] Equal to False
(Selling unit) Equal to Hall of Upgrades 0164 <gen>
Collapse Then - Actions
Unit Group - Pick every unit in UpgradeUnits[2] and do (If ((Custom value of (Picked unit)) Equal to 1) then do (Set TempUnit = (Picked unit)) else do (Do nothing))
For each (Integer A) from 1 to 9, do (If ((Unit-type of TempUnit) Equal to UpgradeUnitType[(Integer A)]) then do (Unit - Order Hall of Upgrades 0166 <gen> to research UpgradeType[(Integer A)]) else do (Do nothing))
Set CurrentlyUpgrading[2] = True
Else - Actions

Trigger:
Alliance Upgrades
Collapse Events
Unit - A unit Finishes research
Collapse Conditions
(Triggering unit) Equal to Altar of Kings 0165 <gen>
Collapse Actions
If ((Researched tech-type) Equal to Additional Melee Spawn) then do (For each (Integer A) from 1 to 4, do (If ((Current research level of Additional Melee Spawn for Player 6 (Orange)) Equal to (Integer A)) then do (Set UpgradeSpawn[(Integer A)] = 1) else do (Do nothing))) else do (Do nothing)
Unit Group - Pick every unit in UpgradeUnits[1] and do (If ((Custom value of (Picked unit)) Equal to 1) then do (Set TempUnit = (Picked unit)) else do (Do nothing))
Unit - Remove TempUnit from the game
Unit Group - Remove TempUnit from UpgradeUnits[1]
Unit Group - Pick every unit in UpgradeUnits[1] and do (Unit - Set the custom value of (Picked unit) to ((Custom value of (Picked unit)) - 1))
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(UpgradeUnits[1] is empty) Equal to True
Collapse Then - Actions
Set CurrentlyUpgrading[1] = False
Collapse Else - Actions
Unit Group - Pick every unit in UpgradeUnits[1] and do (If ((Custom value of (Picked unit)) Equal to 1) then do (Set TempUnit = (Picked unit)) else do (Do nothing))
For each (Integer A) from 1 to 9, do (If ((Unit-type of TempUnit) Equal to UpgradeUnitType[(Integer A)]) then do (Unit - Order Altar of Kings 0165 <gen> to research UpgradeType[(Integer A)]) else do (Do nothing))
Set CurrentlyUpgrading[1] = True

Trigger:
Scourge Upgrades
Collapse Events
Unit - A unit Finishes research
Collapse Conditions
(Triggering unit) Equal to Hall of Upgrades 0166 <gen>
Collapse Actions
If ((Researched tech-type) Equal to Additional Melee Spawn) then do (For each (Integer A) from 5 to 8, do (If ((Current research level of Additional Melee Spawn for Player 12 (Brown)) Equal to ((Integer A) - 4)) then do (Set UpgradeSpawn[(Integer A)] = 1) else do (Do nothing))) else do (Do nothing)
Unit Group - Pick every unit in UpgradeUnits[2] and do (If ((Custom value of (Picked unit)) Equal to 1) then do (Set TempUnit = (Picked unit)) else do (Do nothing))
Unit - Remove TempUnit from the game
Unit Group - Remove TempUnit from UpgradeUnits[2]
Unit Group - Pick every unit in UpgradeUnits[2] and do (Unit - Set the custom value of (Picked unit) to ((Custom value of (Picked unit)) - 1))
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(UpgradeUnits[2] is empty) Equal to True
Collapse Then - Actions
Set CurrentlyUpgrading[2] = False
Collapse Else - Actions
Unit Group - Pick every unit in UpgradeUnits[2] and do (If ((Custom value of (Picked unit)) Equal to 1) then do (Set TempUnit = (Picked unit)) else do (Do nothing))
For each (Integer A) from 1 to 9, do (If ((Unit-type of TempUnit) Equal to UpgradeUnitType[(Integer A)]) then do (Unit - Order Hall of Upgrades 0166 <gen> to research UpgradeType[(Integer A)]) else do (Do nothing))
Set CurrentlyUpgrading[2] = True

UpgradesBought is an integer array I'm using to keep track of how many upgrades a player has bought so I can reward them.
UpgradeSpawn is an integer array I'm using to increase the number of spawns that appear each round (my map is an AoS map).
UpgradeType is a tech-type array.
UpgradeUnits is a unit group array used to hold the queue of upgrades for each team.
UpgradeUnitType is a unit-type array I use to keep track of which units correspond to which upgrades. Since you cannot use shop sharing to sell upgrades, I sell units as pseudo-upgrades instead.

This system was made to emulate the upgrade system from Rival Nations.