Moderator
M
Moderator
02:25, 30th Aug 2012
Magtheridon96:
Approved.
Well done.
The comments make it very readable too.
Magtheridon96:
Approved.
Well done.
The comments make it very readable too.
Initialization

Events


Map initialization

Conditions

Actions


Visibility - Create an initially Enabled visibility modifier for Player 1 (Red) emitting Visibility across (Entire map)


-------- ^ ^ ^PURELY FOR MAP TESTING ^ ^ ^ --------


-------- ----------------------------------------------------------------------------------------------------- --------


-------- ---------------------------------------------------------------------UNIT TYPE 1------------------------------------------------------------------------------------------- --------


-------- This is the Unit-Type which can enter the bunker --------


Set TempUnitType = Archer


-------- ----------------------------------------------------------------------------------------------------- --------


-------- And its coresponding dummy --------


Set TempUnitType2 = Archer (Dummy)


-------- ----------------------------------------------------------------------------------------------------- --------


-------- The next line runs the UnitRegister trigger which registers the Unit-Type to the system --------


Trigger - Run UnitRegister <gen> (ignoring conditions)


-------- ----------------------------------------------------------------------------------------------------- --------


-------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------


-------- ---------------------------------------------------------------------UNIT TYPE 2------------------------------------------------------------------------------------------- --------


-------- And now the second Unit-Type --------


Set TempUnitType = Advanced Archer


-------- ----------------------------------------------------------------------------------------------------- --------


-------- And its coresponding dummy --------


Set TempUnitType2 = Advanced Archer (Dummy)


-------- ----------------------------------------------------------------------------------------------------- --------


-------- And again we register the unit. --------


Trigger - Run UnitRegister <gen> (ignoring conditions)


-------- ----------------------------------------------------------------------------------------------------- --------


-------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------


-------- ---------------------------------------------------------------------UNIT TYPE 3------------------------------------------------------------------------------------------- --------


-------- And now the third Unit-Type --------


Set TempUnitType = Fire Archer


-------- ----------------------------------------------------------------------------------------------------- --------


-------- And its coresponding dummy --------


Set TempUnitType2 = Fire Archer (Dummy)


-------- ----------------------------------------------------------------------------------------------------- --------


-------- And again we register the unit. --------


Trigger - Run UnitRegister <gen> (ignoring conditions)


-------- ----------------------------------------------------------------------------------------------------- --------


-------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------


-------- ---------------------------------------------------------------------You can continue to 8192 unit types but I doubt you'd need that much------------------------------------------------------------------------------------------- --------
BunkerUnitRegister

Events

Conditions

Actions


-------- This sets the index of the unit-type and the number of unit-types which can shoot from a bunker, each time +1 --------


Set BunkerMaxUnits = (BunkerMaxUnits + 1)


-------- ----------------------------------------------------------------------------------------------------- --------


-------- This registers the unit-type to the system --------


Set BunkerUnits[BunkerMaxUnits] = TempUnitType


-------- ----------------------------------------------------------------------------------------------------- --------


-------- This registers its coresponding dummy to the system --------


Set BunkerDummies[BunkerMaxUnits] = TempUnitType2


-------- ----------------------------------------------------------------------------------------------------- --------
BunkerLoad

Events


Unit - A unit Is loaded into a transport

Conditions


Or - Any (Conditions) are true



Conditions




(Unit-type of (Transporting unit)) Equal to Bunker




(Unit-type of (Transporting unit)) Equal to Bunker Wooden

Actions


-------- Setting the entering unit and the bunker to variable --------


Set TempUnit = (Triggering unit)


Set TempUnit2 = (Transporting unit)


-------- ----------------------------------------------------------------------------------------------------- --------


-------- Setting the unit-type of the entering unit and the bunker to variable --------


Set TempUnitType = (Unit-type of TempUnit)


Set TempUnitType2 = (Unit-type of TempUnit2)


-------- ----------------------------------------------------------------------------------------------------- --------


-------- This makes the fire archer unable to fire form wooden bunker. --------


If ((TempUnitType Equal to Fire Archer) and (TempUnitType2 Equal to Bunker Wooden)) then do (Skip remaining actions) else do (Do nothing)


-------- ----------------------------------------------------------------------------------------------------- --------


-------- Custom values of the entering unit and the bunker --------


Set TempInteger = (Custom value of TempUnit)


Set TempInteger2 = (Custom value of TempUnit2)


-------- ----------------------------------------------------------------------------------------------------- --------


-------- The number of units who can enter the bunker --------


For each (Integer TempInteger3) from 1 to BunkerMaxUnits, do (Actions)



Loop - Actions




-------- ----------------------------------------------------------------------------------------------------- --------




-------- Then check if the unit can fire from the bunker --------




If (All Conditions are True) then do (Then Actions) else do (Else Actions)





If - Conditions






TempUnitType Equal to BunkerUnits[TempInteger3]





Then - Actions






-------- ----------------------------------------------------------------------------------------------------- --------






-------- The point of the bunker --------






Set TempPoint = (Position of TempUnit2)






-------- ----------------------------------------------------------------------------------------------------- --------






-------- Creating a dummy unit --------






Unit - Create 1 BunkerDummies[TempInteger3] for (Triggering player) at TempPoint facing Default building facing degrees






-------- ----------------------------------------------------------------------------------------------------- --------






-------- This makes the dummy not to run after the targes and stay in the bunker --------






Custom script: call SetUnitPropWindow(bj_lastCreatedUnit, 0)






-------- ----------------------------------------------------------------------------------------------------- --------






-------- Set variable for the dummy unit so we can destroy it in the unload trigger --------






Set BunkerDummy[TempInteger] = (Last created unit)






-------- ----------------------------------------------------------------------------------------------------- --------






-------- Add the unit to unit group so we can issue it an atack order --------






Unit Group - Add BunkerDummy[TempInteger] to BunkerUnitGroup[TempInteger2]






-------- ----------------------------------------------------------------------------------------------------- --------






-------- Mooving the dummy to the center of the bunker --------






Unit - Move BunkerDummy[TempInteger] instantly to TempPoint






-------- ----------------------------------------------------------------------------------------------------- --------






-------- Setting the mana of a unit if it has (as the fire archer here) --------






Unit - Set mana of BunkerDummy[TempInteger] to (Mana of TempUnit)






-------- ----------------------------------------------------------------------------------------------------- --------






-------- Clearing Leaks --------






Custom script: call RemoveLocation(udg_TempPoint)






-------- ----------------------------------------------------------------------------------------------------- --------






-------- Skiping all reamining actions so it dont repeat and make more unneeded units :) --------






Skip remaining actions






-------- ----------------------------------------------------------------------------------------------------- --------





Else - Actions
Unload

Events


Game - CargoEvent becomes Equal to 2.00

Conditions

Actions


-------- Custom values of the entering unit and the bunker --------


-------- For more information check Unit Event System --------


Set TempInteger = (Custom value of UDexUnits[UDex])


Set TempInteger2 = (Custom value of CargoTransportUnit[UDex])


-------- ----------------------------------------------------------------------------------------------------- --------


-------- Setting the mana of a unit if it has (as the fire archer here) --------


Unit - Set mana of UDexUnits[UDex] to (Mana of Dummy[TempInteger])


-------- ----------------------------------------------------------------------------------------------------- --------


-------- Removing the dummy from the game --------


Unit - Remove Dummy[TempInteger] from the game


-------- ----------------------------------------------------------------------------------------------------- --------
Atack

Events


Unit - A unit Starts the effect of an ability

Conditions


(Ability being cast) Equal to Atack !

Actions


-------- Setting the bunker and the atack target into variables --------


Set TempUnit = (Casting unit)


Set TempUnit2 = (Target unit of ability being cast)


-------- ----------------------------------------------------------------------------------------------------- --------


-------- Setting the custom value of the bunker --------


Set TempInteger = (Custom value of TempUnit)


-------- ----------------------------------------------------------------------------------------------------- --------


-------- Picking all the units in the bunker and ordering them to atack --------


Unit Group - Pick every unit in BunkerUnitGroup[TempInteger] and do (Actions)



Loop - Actions




Unit - Order (Picked unit) to Attack TempUnit2


-------- ----------------------------------------------------------------------------------------------------- --------