1. Are you planning to upload your awesome map to Hive? Please review the rules here.
    Dismiss Notice
  2. Find your way through the deepest dungeon in the 18th Mini Mapping Contest Poll.
    Dismiss Notice
  3. A brave new world lies beyond the seven seas. Join the 34th Modeling Contest today!
    Dismiss Notice
  4. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
Hive 3 Remoosed BETA - NOW LIVE. Go check it out at BETA Hive Workshop! Post your feedback in this new forum BETA Feedback.
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Trigger Viewer

Empire Earth V.1.81.w3x
Variables
MyResourceBar
MyResourceBar
MyResourceBarInit
Ressource StartSelect
WESTRING_VARIABLESCATEGORY
Merveille
merveille
caputre
speed up
speed up2
double
cooldown
Nuclear
Constants
Nuclear Strike Cast
Nuclear Strike Loop
select
arrow nuke
Space
destroy planet
spell battleship
CreateSpace
space
space Copier
CreateSpace Copier
systeme solaire
megastructure
Warning
dyson income
dyson
dyson mort
build
satellites
no sat
satellite
planet
finit build
Avion Path
AutoIndex
ListModule
Airplane Library
avion2
Rank
rank player
Pollution
Pollution Event
pollute
building pollute
pollute death
Spy
spy
spy no
hacker
hackerloop
PorteAvion
porteavion change
capture
capture
son
son
intro
intro
intro2
Hint
elapse
destroy
no tk
spawn
spaw
move Planet
move Terre
move Espace
init
date
choix alien
choix go
choix date
choit date fin
choix ressource
autoproduce
train
autoproduce
capital
random
Capital fall
repop
Période
At 0s
Change of Era
techno
techno
villager fake
mass attack
mass
switch
change
Fuel Use
add group
move
Seasons
Starting year and date
Days Months Years
Mulitboard
economie
transport
unload
unload2
unload3
Storage Spell
finit
Essence
ressource planet
Gold
Essence
Uranium
Trade
TradeInit
MarketOrShipyard Constructed
CaravanOrShip Trained
Caravan Gets to a Market
Ship Gets to a Market
invest
invest
Bitcoin
farme
ferme
ferme re
food chain
food
pop
fish
fish
Trees Rebirth
Regrow Trees Setup
RegrowTrees
Grew Trees
Market
Trade Gold to Wood
Trade Wood to Gold
Check prices
Change value
Names
Player Enters Name
Local Files Example
table
Autodestroyleak
leave
leave
Alliances System
teleport
temps
temps Copier
Show Alliances Menu
function LoadToc takes string s returns nothing
	if BlzLoadTOCFile(s) then
		call PlayMusicBJ("Boss.mp3")
	else
		call PlayMusicBJ("Boss.mp3")
	endif	
endfunction
function UpdateCam takes nothing returns nothing
	call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, BlzFrameGetValue(BlzGetFrameByName("EscMenuSliderTemplate", 0)), 0)
	call BlzFrameSetText(BlzGetFrameByName("EscMenuLabelTextTemplate", 0), "Distance: " + R2SW(BlzFrameGetValue(BlzGetFrameByName("EscMenuSliderTemplate", 0)), 1, 1))
endfunction

function CreateSliderDistance takes nothing returns nothing
	local framehandle fh = BlzCreateFrame("EscMenuSliderTemplate",  BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), 0, 0)
	local framehandle label = BlzCreateFrame("EscMenuLabelTextTemplate",  fh, 0, 0)
	call BlzFrameSetPoint(label, FRAMEPOINT_LEFT, fh, FRAMEPOINT_RIGHT, 0, 0)
	call BlzFrameSetAbsPoint(fh, FRAMEPOINT_LEFT, 0.01, 0.56) //below the menu, quest buttons
	
	//call BlzFrameSetSize(fh, 0.139, 0.012) //default size in the fdf.
	
	call BlzFrameSetMinMaxValue(fh, 600, 6000) //limits user can choose
	call BlzFrameSetValue(fh, 4500) //starting value, should be used after one changed min max
	call BlzFrameSetStepSize(fh, 50) //
	
endfunction
function CreateCamControl takes nothing returns nothing
	call LoadToc("war3mapimported\\templates.toc") //use the custom function to load the Toc, the custom function prints success/fail loading the toc.
	call CreateSliderDistance()
	call TimerStart(CreateTimer(), 0.4, true, function UpdateCam)
endfunction
function ChangeLumberTextBox takes nothing returns nothing
   local framehandle fh = BlzGetFrameByName("ResourceBarUpkeepText" , 0) //Load "ResourceBarLumberText" with creationcontext 0
   call BlzFrameSetText(fh , "|Cffffff00Prehistory") //Change the text to Lumber
   set fh = null
endfunction
Name Type Is Array Initial Value
agent integer Yes
Aleatoire real No
AleoLivre integer No
annee_roi integer Yes
ArmorItem integer Yes
AutoProduce group No
batiment1 unitcode No
batiment2 unitcode No
batiment3 unitcode Yes
Bitcoin integer Yes
Bitcoin2 real Yes
BitcoinTotal integer No
BitcoinTotal2 real No
BitcoinTotal3 integer No
Boom timer No
Boom2 timerdialog No
BootsType integer Yes
build location Yes
C_SG_NS_Ability abilcode No
C_SG_NS_AOE_Add real No
C_SG_NS_AOE_Base real No
C_SG_NS_Blink_Interval integer No
C_SG_NS_Calldown_Sound sound No
C_SG_NS_Channel_Add integer No
C_SG_NS_Channel_Base integer No
C_SG_NS_Delay integer No
C_SG_NS_DMG_Max_Percent_Add real No
C_SG_NS_DMG_Max_Percent_Base real No
C_SG_NS_DMG_Min_Flat_Add real No
C_SG_NS_DMG_Min_Flat_Base real No
C_SG_NS_DMG_Structure_Add real No
C_SG_NS_DMG_Structure_Base real No
C_SG_NS_Loop_Interval real No
C_SG_NS_SFX_Hit string No
C_SG_NS_SFX_Nuke string No
Capital unit No
caravan1 unit Yes
caravan1_Copier boolean Yes
caravan2 unit Yes
caravan2_Copier boolean Yes
caravan3 unit Yes
caravan3_Copier boolean Yes
caravan4 unit Yes
caravan4_Copier boolean Yes
caravan5 unit Yes
caravan5_Copier boolean Yes
Caravans group No
CargoEvent real No
CargoTransportGroup group Yes
CargoTransportUnit unit Yes
CheckDeathInList boolean Yes
CheckDeathList integer Yes
CheckDeathTimer timer No
choix timerdialog No
choix_Copier timer No
continent button Yes
Currentplayer player No
Date string No
Date2 string No
Date3 string No
Date4 string No
Day integer No
DaysInEachMonth integer Yes
DeathEvent real No
Degre real Yes
Degre2 real Yes
demande1 string No
demande2 string No
Destination hashtable No
DetectRemoveAbility abilcode No
DetectTransformAbility abilcode No
distance1 real Yes
distance1_Copier real Yes
distance2 real Yes
distance2_Copier real Yes
distance3 real Yes
distance3_Copier real Yes
distance4 real Yes
distance4_Copier real Yes
distance5 real Yes
distance5_Copier real Yes
donne unit No
donne_Copier_1 button No
donne_Copier_10 button No
donne_Copier_11 button No
donne_Copier_12 button No
donne_Copier_2 button No
donne_Copier_3 button No
donne_Copier_4 button No
donne_Copier_5 button No
donne_Copier_6 button No
donne_Copier_7 button No
donne_Copier_8 button No
donne_Copier_9 button No
donner button Yes
Dyson unit No
ENTIER integer No
ENTIER2 integer No
ENTIER_ARRAY1 integer Yes
ENTIER_ARRAY2 integer Yes
faveur integer Yes
Ferme integer Yes
fh string No
floatingtext texttag No
fofo1 unit Yes
fofo2 unit Yes
fofo3 unit Yes
fofo4 unit Yes
fofo5 unit Yes
Food_Change integer No
Food_Value integer No 100
Fuel_Change integer No
Fuel_Value integer No 300
GlovesItem integer Yes
Gold integer Yes
Handle handle Yes
HashtableCaravans hashtable No
HashtableTradeShips hashtable No
Hints string No
imposition1 button Yes
imposition2 button Yes
imposition3 button Yes
imposition_Copier dialog No
inter player Yes
IsUnitAlive boolean Yes
IsUnitBeingUnloaded boolean Yes
IsUnitNew boolean Yes
IsUnitPreplaced boolean Yes
IsUnitReincarnating boolean Yes
IsUnitRemoved boolean Yes
IsUnitTransforming boolean Yes
KillerOfUnit unit Yes
Lieu location Yes
Lieu2 location Yes
lieutenant dialog No
LimitePanneau integer Yes
mariage dialog No
MarketsGroup group No
Message string No
meteo weathereffect No
meveille boolean Yes
mob integer No
money integer Yes
monnaie1 integer No
monnaie2 integer No
Month integer No
mort integer No
MusicAleo integer Yes
MusicTime timer Yes
MyResourceBarCount integer No
MyResourceBarIcons imagefile Yes
MyResourceBarTooltipText string Yes
MyResourceBarTooltipTitle string Yes
MyResourceValue string Yes
nation button Yes
nation2 button Yes
nation3 button Yes
nation4 button Yes
nationalite player Yes
navire1 unit Yes
navire1_Copier boolean Yes
navire2 unit Yes
navire2_Copier boolean Yes
navire3 unit Yes
navire3_Copier boolean Yes
navire4 unit Yes
navire4_Copier boolean Yes
navire5 unit Yes
navire5_Copier boolean Yes
nom string Yes
nom_roi string Yes
nomm string No
nonagression force Yes
NumberOfCaravans integer No
NumberOfTradeShips integer No
NumeroBateau integer No 1
Oil integer Yes
OrderAttack group Yes
OrderBank group Yes
OrderVillager group Yes
Parametre_afrique dialog No
Parametre_amerique dialog No
Parametre_asie dialog No
Parametre_continent dialog No
Parametre_europe dialog No
Parametre_nom2 dialog No
Parametre_Tuto dialog No
period integer Yes
pla player No
player player No
Player_Colour integer Yes
PlayerIndex integer No
POINT location No
Point location No
Point2 location No
POINT2 location No
Point_of_Path location No
pollute real No
Pollution real No
Port group No
port1 unit Yes
port2 unit Yes
port3 unit Yes
port4 unit Yes
port5 unit Yes
pris boolean Yes
REAL real No
regence boolean Yes
regence_Copier force Yes
regime string Yes
relation real Yes
religion string Yes
roi_nom force No
satellite integer No 0
satelliteN unit Yes
Saying_Player force No
SG_NS_AOE real Yes
SG_NS_Caster unit Yes
SG_NS_Completed boolean Yes
SG_NS_Counter integer Yes
SG_NS_DMG_Flat real Yes
SG_NS_DMG_Percent real Yes
SG_NS_DMG_Structure real Yes
SG_NS_Floating_Text texttag Yes
SG_NS_Floating_Text_Dot texttag Yes
SG_NS_MUI_Index_A integer No
SG_NS_Nuke_SFX effect Yes
SG_NS_Order ordercode Yes
SG_NS_Point location Yes
SG_NS_Temp_Integer_A integer No
SG_NS_Temp_Integer_B integer No
SG_NS_Vision fogmodifier Yes
ShieldType integer Yes
ShipyardsGroup group No
son sound Yes
SortieBateau location Yes
SpaceMaxX real No
SpaceMaxY real No
SpaceMinX real No
SpaceMinY real No
SpaceObject string Yes
SpaceObjectMaxSize real Yes
SpaceObjectMinSize real Yes
SpaceObjectsMax integer No
SpaceObjectsMax2 integer No
SpaceObjectSpawnChance real Yes
spawn_mob location No
start force No
street1 unit Yes
street2 unit Yes
SummonerOfUnit unit Yes
Target player No
tele group No
Tem group Yes
Temp group No
Temp_Group group No
Temp_PickedUnit unit No
Text string No
time integer No
TimeOfYear multiboard No
titre string Yes
TradeShips group No
Tutorial_button button Yes
UDex integer No
UDexGen integer No
UDexLastRecycled integer No
UDexMax integer No
UDexNext integer Yes
UDexPrev integer Yes
UDexRecycle integer No
UDexUnits unit Yes
UDexWasted integer No
Ugroup group No
UMovNext integer Yes
UMovPrev integer Yes
UNIT unit No
Unit_test unit No
Unit_test2 unit No
UnitInAction boolean Yes
UnitInActionEvent real No
UnitIndexerEnabled boolean No
UnitIndexEvent real No
UnitMovementInterval real No
UnitMoving boolean Yes
UnitMovingEvent real No
UnitMovingX real Yes
UnitMovingY real Yes
UnitName string Yes
UnitTypeEvent real No
UnitTypeOf unitcode Yes
Uranium integer Yes
Uranium_Change integer No
Uranium_Value integer No 500
vassals force No
visibilite fogmodifier Yes
WeaponItem integer Yes
Wood_Change integer No
Wood_Value integer No 100
woodcut string No
WorldMaxX real No
WorldMaxY real No
Year integer Yes
//MyResourceBar 1.2c
//By Tasyen

function MyResourceBarPlayerSize takes nothing returns integer
    return 100 //each player has 100 slots allwing upto 9 additional bars (on default). MyResourceBarAutoCreateCount * MyResourceBarDataSize should not reach that number
endfunction
function MyResourceBarDataSize takes nothing returns integer
    return 10 //each Bar takes that amount of slots
endfunction
function MyResourceBarAutoCreateCount takes nothing returns integer
    return 1 //Create this amount of addtional Bars automatically.
endfunction

//Allow and Pos the checkbox hidding the additional Bars.
function MyResourceBarCreateCheckBox takes nothing returns boolean
    return false //(true) create a checkbox to tooggle visiblity of the additional ResourceBarFrames
endfunction
function MyResourceBarCheckBoxLabelText takes nothing returns string
    return "Hide Resources"
endfunction

function MyResourceBarCheckBoxX takes nothing returns real
    return 0.1
endfunction
function MyResourceBarCheckBoxY takes nothing returns real
    return 0.57
endfunction

//Where is the tooltip of this Bars placed.
function MyResourceBarTooltipX takes nothing returns real
    return 0.8
endfunction
function MyResourceBarTooltipY takes nothing returns real
    return 0.16
endfunction
function MyResourceBarTooltipPoint takes nothing returns framepointtype
    return FRAMEPOINT_BOTTOMRIGHT  
endfunction

function MyResourceBarAnchor takes nothing returns framepointtype
//Poses the first Bar where in the world Frame?
//I suggest to use a y-offset when using any Bottom Point.

    //return FRAMEPOINT_TOPLEFT
    //return FRAMEPOINT_TOP
    return FRAMEPOINT_TOPRIGHT
   
    //return FRAMEPOINT_BOTTOMLEFT
    //return FRAMEPOINT_BOTTOM
    //return FRAMEPOINT_BOTTOMRIGHT
   
    //return FRAMEPOINT_LEFT
    //return FRAMEPOINT_RIGHT
    //return FRAMEPOINT_CENTER
endfunction
function MyResourceBarAnchor1OffsetX takes nothing returns real
    return 0.0 //Offset the first bar by that amount from its FramePoint
endfunction
function MyResourceBarAnchor1OffsetY takes nothing returns real
    return 0.0
endfunction

function MyResourceBarCreateTooltip takes framehandle targetFrameLeft, framehandle targetFrameRight, string title, string text, integer index returns nothing
    local framehandle box = BlzGetFrameByName("MyResourceBarBoss",0)
    local framehandle fhHover = BlzCreateFrameByType("FRAME", "MyResourceHover", box, "", index)
    local framehandle tooltipBox = BlzCreateFrame("MyResourceBarBoxedText", box,0, index)
    call BlzFrameSetPoint(fhHover, FRAMEPOINT_BOTTOMLEFT, targetFrameLeft, FRAMEPOINT_BOTTOMLEFT, 0, 0)
    call BlzFrameSetPoint(fhHover, FRAMEPOINT_TOPRIGHT, targetFrameRight, FRAMEPOINT_TOPRIGHT, 0, 0)
    call BlzFrameSetTooltip(fhHover, tooltipBox)
   
    call BlzFrameSetAbsPoint(tooltipBox, MyResourceBarTooltipPoint(), MyResourceBarTooltipX(), MyResourceBarTooltipY())
    call BlzFrameSetSize(tooltipBox, 0.285, 0.06)
   
    call BlzFrameSetText(BlzGetFrameByName("MyResourceBarBoxedTextTitle", index), title)
    call BlzFrameSetText(BlzGetFrameByName("MyResourceBarBoxedTextValue", index), text)
   
    set box = null
    set fhHover = null
    set tooltipBox = null
endfunction

function MyResourceBarSetup takes integer barIndex returns nothing //create an additonal ResourceBar between the orginal one.
    local integer playerIndex = GetConvertedPlayerId(GetLocalPlayer()) * MyResourceBarPlayerSize()
    local integer dataIndex = barIndex*MyResourceBarDataSize()
    local integer loopIndex = 1
   
    call MyResourceBarCreateTooltip(BlzGetFrameByName("MyResourceBar1Icon", barIndex), BlzGetFrameByName("MyResourceBar1Text", barIndex), udg_MyResourceBarTooltipTitle[dataIndex + 1], udg_MyResourceBarTooltipText[dataIndex +1], dataIndex + 1)
    call MyResourceBarCreateTooltip(BlzGetFrameByName("MyResourceBar2Icon", barIndex), BlzGetFrameByName("MyResourceBar2Text", barIndex), udg_MyResourceBarTooltipTitle[dataIndex + 2], udg_MyResourceBarTooltipText[dataIndex +2], dataIndex + 2)
    call MyResourceBarCreateTooltip(BlzGetFrameByName("MyResourceBar3Icon", barIndex), BlzGetFrameByName("MyResourceBar3Text", barIndex), udg_MyResourceBarTooltipTitle[dataIndex + 3], udg_MyResourceBarTooltipText[dataIndex +3], dataIndex + 3)
    call MyResourceBarCreateTooltip(BlzGetFrameByName("MyResourceBar4Icon", barIndex), BlzGetFrameByName("MyResourceBar4Text", barIndex), udg_MyResourceBarTooltipTitle[dataIndex + 4], udg_MyResourceBarTooltipText[dataIndex +4], dataIndex + 4)
   
    loop
        if udg_MyResourceBarIcons[playerIndex + dataIndex + loopIndex] == null or udg_MyResourceBarIcons[playerIndex + dataIndex + loopIndex] == "" then
            call BlzFrameSetTexture(BlzGetFrameByName("MyResourceBar"+I2S(loopIndex)+"Icon", barIndex), udg_MyResourceBarIcons[dataIndex + loopIndex], 0 ,true)
        else
            call BlzFrameSetTexture(BlzGetFrameByName("MyResourceBar"+I2S(loopIndex)+"Icon", barIndex), udg_MyResourceBarIcons[playerIndex + dataIndex + loopIndex], 0 ,true)          
        endif
       
        if udg_MyResourceBarTooltipTitle[playerIndex + dataIndex + loopIndex] != null then //player specific Tooltip?
            call BlzFrameSetText(BlzGetFrameByName("MyResourceBarBoxedTextTitle", dataIndex + loopIndex), udg_MyResourceBarTooltipTitle[playerIndex + dataIndex + loopIndex])
        endif
       
        if udg_MyResourceBarTooltipText[playerIndex + dataIndex + loopIndex] != null then //player specific TooltipText?
            call BlzFrameSetText(BlzGetFrameByName("MyResourceBarBoxedTextValue", dataIndex + loopIndex), udg_MyResourceBarTooltipText[playerIndex + dataIndex + loopIndex])
        endif
       
        set loopIndex = loopIndex + 1
        exitwhen loopIndex == 5
    endloop
endfunction

function CreateMyResourceBar takes nothing returns nothing
    local framehandle bar = BlzCreateSimpleFrame("MyResourceBarFrame", BlzGetFrameByName("MyResourceBarBoss2",0), udg_MyResourceBarCount + 1)
    set udg_MyResourceBarCount = udg_MyResourceBarCount + 1
    if udg_MyResourceBarCount == 1 then //if this is the first create one Pos it below the default one
        call BlzFrameSetPoint(bar, MyResourceBarAnchor(), BlzGetOriginFrame(ORIGIN_FRAME_WORLD_FRAME,0), MyResourceBarAnchor(), MyResourceBarAnchor1OffsetX(), MyResourceBarAnchor1OffsetY())
    else
        if MyResourceBarAnchor() == FRAMEPOINT_TOPRIGHT or MyResourceBarAnchor() == FRAMEPOINT_TOPLEFT or MyResourceBarAnchor() == FRAMEPOINT_TOP then
            call BlzFrameSetPoint(bar, FRAMEPOINT_TOP, BlzGetFrameByName("MyResourceBarFrame", udg_MyResourceBarCount - 1), FRAMEPOINT_BOTTOM, 0, 0)
        elseif MyResourceBarAnchor() == FRAMEPOINT_BOTTOMLEFT or MyResourceBarAnchor() == FRAMEPOINT_BOTTOM or MyResourceBarAnchor() == FRAMEPOINT_BOTTOMRIGHT then
            call BlzFrameSetPoint(bar, FRAMEPOINT_BOTTOMLEFT, BlzGetFrameByName("MyResourceBarFrame", udg_MyResourceBarCount - 1), FRAMEPOINT_TOPLEFT, 0, 0)
        else
            call BlzFrameSetPoint(bar, FRAMEPOINT_TOP, BlzGetFrameByName("MyResourceBarFrame", udg_MyResourceBarCount - 1), FRAMEPOINT_BOTTOM, 0, 0)
        endif
    endif
    call MyResourceBarSetup(udg_MyResourceBarCount)
   
    set bar = null
endfunction
function MyResourceBarUpdateBarsReplay takes nothing returns nothing
    local integer playerIndex = (R2I(BlzFrameGetValue(BlzGetFrameByName("ReplayVisionMenu",0))) + 1) * MyResourceBarPlayerSize()
    local integer i
    local integer barIndex = 1
    local integer dataIndex
   
    //Takes over all udg_MyResourceValue data into the MyResourceBarFrames also updates the title
    //The outher Loop are the Bars, the inner Loop handles the tooltipTitle update
    loop
        set dataIndex = barIndex*MyResourceBarDataSize()
        call BlzFrameSetText(BlzGetFrameByName("MyResourceBar1Text", barIndex), udg_MyResourceValue[playerIndex + dataIndex + 1])
        call BlzFrameSetText(BlzGetFrameByName("MyResourceBar2Text", barIndex), udg_MyResourceValue[playerIndex + dataIndex + 2])
        call BlzFrameSetText(BlzGetFrameByName("MyResourceBar3Text", barIndex), udg_MyResourceValue[playerIndex + dataIndex + 3])
        call BlzFrameSetText(BlzGetFrameByName("MyResourceBar4Text", barIndex), udg_MyResourceValue[playerIndex + dataIndex + 4])
        set i = 1
        loop
       
            if udg_MyResourceBarTooltipTitle[playerIndex + dataIndex + i] == null then
                call BlzFrameSetText(BlzGetFrameByName("MyResourceBarBoxedTextTitle", dataIndex + i), udg_MyResourceBarTooltipTitle[dataIndex + i]+": "+udg_MyResourceValue[playerIndex  +dataIndex + i])
            else
                call BlzFrameSetText(BlzGetFrameByName("MyResourceBarBoxedTextTitle", dataIndex + i), udg_MyResourceBarTooltipTitle[playerIndex + dataIndex + i]+": "+udg_MyResourceValue[playerIndex  +dataIndex + i])
            endif
            if udg_MyResourceBarTooltipText[playerIndex + dataIndex + i] == null then
                call BlzFrameSetText(BlzGetFrameByName("MyResourceBarBoxedTextValue", dataIndex + i), udg_MyResourceBarTooltipText[dataIndex + i])
            else
                call BlzFrameSetText(BlzGetFrameByName("MyResourceBarBoxedTextValue", dataIndex + i), udg_MyResourceBarTooltipText[playerIndex + dataIndex + i])
            endif
            if udg_MyResourceBarIcons[playerIndex + dataIndex + i] == null or udg_MyResourceBarIcons[playerIndex + dataIndex + i] == "" then
                call BlzFrameSetTexture(BlzGetFrameByName("MyResourceBar"+I2S(i)+"Icon", barIndex), udg_MyResourceBarIcons[dataIndex + i], 0 ,true)
            else
                call BlzFrameSetTexture(BlzGetFrameByName("MyResourceBar"+I2S(i)+"Icon", barIndex), udg_MyResourceBarIcons[playerIndex + dataIndex + i], 0 ,true)
            endif
            set i = i + 1
            exitwhen i == 5
        endloop
        set barIndex = barIndex + 1
        exitwhen barIndex > udg_MyResourceBarCount
    endloop

endfunction

function MyResourceBarUpdateBars takes nothing returns nothing
    local integer playerIndex = GetConvertedPlayerId(GetLocalPlayer()) * MyResourceBarPlayerSize()
    local integer i
    local integer barIndex = 1
    local integer dataIndex

    //Takes over all udg_MyResourceValue data into the MyResourceBarFrames also updates the title
    //The outher Loop are the Bars, the inner Loop handles the tooltipTitle update
    loop
        set dataIndex = barIndex*MyResourceBarDataSize()
        call BlzFrameSetText(BlzGetFrameByName("MyResourceBar1Text", barIndex), udg_MyResourceValue[playerIndex + dataIndex + 1])
        call BlzFrameSetText(BlzGetFrameByName("MyResourceBar2Text", barIndex), udg_MyResourceValue[playerIndex + dataIndex + 2])
        call BlzFrameSetText(BlzGetFrameByName("MyResourceBar3Text", barIndex), udg_MyResourceValue[playerIndex + dataIndex + 3])
        call BlzFrameSetText(BlzGetFrameByName("MyResourceBar4Text", barIndex), udg_MyResourceValue[playerIndex + dataIndex + 4])
       
        set i = 1
        loop
            if udg_MyResourceBarTooltipTitle[playerIndex + dataIndex + i] == null then
                call BlzFrameSetText(BlzGetFrameByName("MyResourceBarBoxedTextTitle", dataIndex + i), udg_MyResourceBarTooltipTitle[dataIndex + i]+": "+udg_MyResourceValue[playerIndex  +dataIndex + i])
            else
                call BlzFrameSetText(BlzGetFrameByName("MyResourceBarBoxedTextTitle", dataIndex + i), udg_MyResourceBarTooltipTitle[playerIndex + dataIndex + i]+": "+udg_MyResourceValue[playerIndex  +dataIndex + i])
            endif
            set i = i + 1
            exitwhen i == 5
        endloop
        set barIndex = barIndex + 1
        exitwhen barIndex > udg_MyResourceBarCount
    endloop

endfunction
function MyResourceBarsFitFrames takes nothing returns nothing
    local framehandle leadbor = BlzGetFrameByName("Leaderboard",0)
    local framehandle multi = BlzGetFrameByName("Multiboard",0)
    local framehandle time = BlzGetFrameByName("TimerDialog",0)
    local framehandle prev = BlzGetFrameByName("MyResourceBarFrame", udg_MyResourceBarCount)
    local framehandle resourcebar = BlzGetFrameByName("ResourceBarFrame", 0)
    local real yPlus = -0.005
    if MyResourceBarAnchor() == FRAMEPOINT_TOPRIGHT then
        if not BlzFrameIsVisible(BlzGetFrameByName("MyResourceBarFrame", udg_MyResourceBarCount)) then
            set prev = resourcebar
            set yPlus = -0.0165
        endif
        if time != null then //bugs if the 1. timer window is destroyed
            call BlzFrameSetPoint(time, FRAMEPOINT_TOPRIGHT, prev, FRAMEPOINT_BOTTOMRIGHT, 0, -0.005 + yPlus)
            set yPlus = 0
            set prev = time
        endif
        if multi != null then //bugs if the current shown multiboard is not the last created one
            call BlzFrameSetPoint(multi, FRAMEPOINT_TOPRIGHT, prev, FRAMEPOINT_BOTTOMRIGHT, 0, -0.005 + yPlus)
            set yPlus = 0
            set prev = multi
        endif
        if leadbor != null then//bugs if the current shown leaderboard is not the last created one
            call BlzFrameSetPoint(leadbor, FRAMEPOINT_TOPRIGHT, prev, FRAMEPOINT_BOTTOMRIGHT, 0, -0.005 + yPlus)
            set yPlus = 0
            set prev = leadbor
        endif
    endif
    set leadbor = null
    set multi = null
    set time = null
    set prev = null
    set resourcebar = null
endfunction

function MyResourceBarsCheckBox takes nothing returns nothing
//In some test BlzGetFrameByName could disconnect the game hence done for all players
    local framehandle fh = BlzGetFrameByName("MyResourceBarBoss",0)
    local framehandle fh2 = BlzGetFrameByName("MyResourceBarBoss2",0)

    if GetTriggerPlayer() == GetLocalPlayer() then //only do something for the player having pressed the checkbox
        call BlzFrameSetVisible(fh, BlzGetTriggerFrameEvent() == FRAMEEVENT_CHECKBOX_UNCHECKED)
        call BlzFrameSetVisible(fh2, BlzGetTriggerFrameEvent() == FRAMEEVENT_CHECKBOX_UNCHECKED)
    endif
   
    set fh = null
    set fh2 = null
    call MyResourceBarsFitFrames()
endfunction
function MyResourceBarCreateCheckBoxAction takes nothing returns nothing
    local trigger trig = CreateTrigger()
    local framehandle fh = BlzCreateFrameByType("GLUECHECKBOX", "MyResourceBarCheckBox", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0),"QuestCheckBox",0)
    local framehandle fhText = BlzCreateFrameByType("TEXT", "MyResourceBarCheckBoxLabel", fh, "", 0)
   
    call BlzFrameSetAbsPoint(fh, FRAMEPOINT_TOPLEFT, MyResourceBarCheckBoxX(), MyResourceBarCheckBoxY())
    call BlzFrameSetPoint(fhText, FRAMEPOINT_TOP, fh, FRAMEPOINT_BOTTOM, 0.0, 0.0)
    call BlzFrameSetEnable(fhText, false)
   
    call BlzFrameSetText(fhText, MyResourceBarCheckBoxLabelText())
    call BlzTriggerRegisterFrameEvent(trig, fh, FRAMEEVENT_CHECKBOX_CHECKED)
    call BlzTriggerRegisterFrameEvent(trig, fh, FRAMEEVENT_CHECKBOX_UNCHECKED)
   
    call TriggerAddAction(trig, function MyResourceBarsCheckBox)
   
    set fh = null
    set fhText = null
    set trig = null
endfunction

function MyResourceBarsCreate takes nothing returns nothing
//Create Hide ResourceBar checkbox
    local integer i = MyResourceBarAutoCreateCount()
    if MyResourceBarCreateCheckBox() and not BlzFrameIsVisible(BlzGetFrameByName("SimpleReplayPanel",0)) then
        call MyResourceBarCreateCheckBoxAction()
    endif
   
   
//Create Parents of the ResourceBarFrames, one needs a SIMPLEFRAME and a FRAME. They allow to easyly hide/show the ResourceBarFrames
    call BlzCreateFrameByType("FRAME", "MyResourceBarBoss", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0),"",0) //Parent of Frames (tooltips stuff)
    call BlzCreateFrameByType("SIMPLEFRAME", "MyResourceBarBoss2", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0),"",0) //Parent of SimpleFrames (bar and its content)

//Create ResourceBarFrames
    loop
        exitwhen i <= 0
        call CreateMyResourceBar()
        set i = i - 1
    endloop
   
//CleanUP
    call DestroyTimer(GetExpiredTimer())
   
    if not BlzFrameIsVisible(BlzGetFrameByName("SimpleReplayPanel",0)) then
        call TriggerAddAction( gg_trg_MyResourceBar, function MyResourceBarUpdateBars)
    else
        call TriggerAddAction( gg_trg_MyResourceBar, function MyResourceBarUpdateBarsReplay)
    endif
endfunction
//===========================================================================
function InitTrig_MyResourceBar takes nothing returns nothing
    set gg_trg_MyResourceBar = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_MyResourceBar , 0.2)
    call TimerStart(CreateTimer(),0.0, false, function MyResourceBarsCreate)
    call BlzLoadTOCFile("war3mapImported\\MyResourceBar.toc")
endfunction

 
MyResourceBarInit
  Events
    Map initialization
  Conditions
  Actions
    -------- Icons of Custom Resource Bars --------
    -------- 11 is the icon for the 1. Resource of the 1. Custom ResourceBar --------
    -------- 12 is the icon for the 2. Resource of the 1. Custom ResourceBar --------
    -------- 23 is the icon for the 3. Resource of the 2. Custom ResourceBar --------
    Set VariableSet MyResourceBarIcons[11] = ReplaceableTextures\CommandButtons\BTNINV_Misc_Coin_02.blp
    Set VariableSet MyResourceBarIcons[12] = ReplaceableTextures\CommandButtons\BTNOil.blp
    Set VariableSet MyResourceBarIcons[13] = ReplaceableTextures\CommandButtons\BTNAuraNuke.blp
    Set VariableSet MyResourceBarIcons[14] = ReplaceableTextures\CommandButtons\BTNPollution.blp
    -------- Icons of Custom Resource Bar 2 --------
    -------- Tooltips of Custom Bar 1 --------
    Set VariableSet MyResourceBarTooltipTitle[11] = Gold
    Set VariableSet MyResourceBarTooltipTitle[12] = Fuel
    Set VariableSet MyResourceBarTooltipTitle[13] = Uranium
    Set VariableSet MyResourceBarTooltipTitle[14] = Pollution
    Set VariableSet MyResourceBarTooltipText[11] = Banks and Capitals provide Gold.
    Set VariableSet MyResourceBarTooltipText[12] = Oil Platform provide Fuel.
    Set VariableSet MyResourceBarTooltipText[13] = Nuclear Plant provide uranium.
    Set VariableSet MyResourceBarTooltipText[14] = The pollution affects the trees regrow rate, the max food in the farms and the frequency of natural climatic disasters.
    -------- Tooltips of Custom Bar 2 --------
    -------- One could define player specific Icons and Tooltips by using an offset 100 * Number of Player (Red uses 1) --------
    -------- The 100 is the playerArraySize, it should match MyResourceBarPlayerSize() --------
    -------- The next Line would Let player Red have unique Icon and tooltips for Reosurce 1 of Bar 1 --------
Ressource StartSelect
  Events
    Player - Player 1 (Red) Selects a unit
    Player - Player 2 (Blue) Selects a unit
    Player - Player 3 (Teal) Selects a unit
    Player - Player 4 (Purple) Selects a unit
    Player - Player 5 (Yellow) Selects a unit
    Player - Player 6 (Orange) Selects a unit
    Player - Player 7 (Green) Selects a unit
    Player - Player 8 (Pink) Selects a unit
    Player - Player 9 (Gray) Selects a unit
    Player - Player 10 (Light Blue) Selects a unit
    Player - Player 11 (Dark Green) Selects a unit
    Player - Player 12 (Brown) Selects a unit
    Player - Player 13 (Maroon) Selects a unit
    Player - Player 14 (Navy) Selects a unit
    Player - Player 15 (Turquoise) Selects a unit
    Player - Player 16 (Violet) Selects a unit
    Player - Player 17 (Wheat) Selects a unit
    Player - Player 18 (Peach) Selects a unit
    Player - Player 19 (Mint) Selects a unit
    Player - Player 20 (Lavender) Selects a unit
    Player - Player 21 (Coal) Selects a unit
    Player - Player 22 (Snow) Selects a unit
    Player - Player 23 (Emerald) Selects a unit
    Player - Player 24 (Peanut) Selects a unit
  Conditions
  Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        ((Triggering player) is in start.) Equal to False
      Then - Actions
        Player Group - Add (Triggering player) to start
        Set VariableSet PlayerIndex = (100 x (Player number of (Owner of (Triggering unit))))
        Set VariableSet MyResourceValue[(PlayerIndex + 11)] = 0
        Set VariableSet MyResourceValue[(PlayerIndex + 12)] = 0
        Set VariableSet MyResourceValue[(PlayerIndex + 13)] = 0
        Set VariableSet MyResourceValue[(PlayerIndex + 14)] = 0%
        Player - Make Stonehenge 1 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Coliseum 2 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Notre Dame 3 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Forbidden City 4 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Eiffel Tower 5 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Citadel of Verdun 6 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Pentagon 7 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Burj Khalifa 8 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Great Firewall 9 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Fusion Reactor 10 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Barracks 1 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Barracks 2 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Barracks 3 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Barracks 4 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Barracks 5 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Barracks 6 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Barracks 7 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Barracks 8 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Barracks 9 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Barracks 10 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Stable 1 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Stable 2 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Stable 3 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Stable 4 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Stable 5 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Airfield 1 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Airfield 2 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Airfield 3 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Airfield 4 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Airfield 5 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Siege Workshop 1 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Siege Workshop 2 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Siege Workshop 3 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Siege Workshop 4 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Siege Workshop 5 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Tank Factory 6 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Tank Factory 7 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Tank Factory 8 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Tank Factory 9 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Tank Factory 10 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Tower 1 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Tower 2 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Tower 3 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Tower 4 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Tower 5 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Bunker 6 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Bunker 7 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Bunker 8 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Bunker 9 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Bunker 10 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Anti-Air Cannon 1 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Anti-Air Cannon 2 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Anti-Air Cannon 3 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Anti-Air Cannon 4 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Anti-Air Cannon 5 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall - 1 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall / 1 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall \ 1 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall | 1 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall - 2 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall | 2 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall \ 2 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall / 2 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall - 3 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall / 3 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall \ 3 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall | 3 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall / 4 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall | 4 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall - 4 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall \ 4 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall | 5 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall - 5 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall \ 5 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall / 5 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall - 6 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall / 6 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall \ 6 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall | 6 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall - 7 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall | 7 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall \ 7 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall / 7 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall | 8 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall \ 8 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall / 8 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall - 8 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall | 9 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall \ 9 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall - 9 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall / 9 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall / 10 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall - 10 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall | 10 Unavailable for training/construction by (Owner of (Triggering unit))
        Player - Make Wall \ 10 Unavailable for training/construction by (Owner of (Triggering unit))
      Else - Actions
merveille
  Events
    Unit - A unit Finishes construction
  Conditions
    (Point-value of (Constructed structure)) Equal to 400
  Actions
    Player Group - Pick every player in (All players) and do (Actions)
      Loop - Actions
        Player - Limit training of (Unit-type of (Constructed structure)) to 0 for (Picked player)
    Unit Group - Pick every unit in (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to (Unit-type of (Constructed structure))) and ((Owner of (Matching unit)) Not equal to (Owner of (Constructed structure))))) and do (Actions)
      Loop - Actions
        Unit - Remove (Picked unit) from the game
    Game - Display to (All players) for 10.00 seconds the text: (((|cff008080 + titre[(Player number of (Owner of (Triggering unit)))]) + |r has completed the |cff008080) + ((Name of (Constructed structure)) + |r.))
    Sound - Play QuestNew <gen>
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Unit-type of (Constructed structure)) Equal to Stonehenge 1
      Then - Actions
        Set VariableSet meveille[1] = True
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Unit-type of (Constructed structure)) Equal to Coliseum 2
      Then - Actions
        Set VariableSet meveille[2] = True
        Unit - Add Panem et circenses to (Constructed structure)
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Unit-type of (Constructed structure)) Equal to Notre Dame 3
      Then - Actions
        Set VariableSet meveille[3] = True
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Unit-type of (Constructed structure)) Equal to Forbidden City 4
      Then - Actions
        Set VariableSet meveille[4] = True
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Unit-type of (Constructed structure)) Equal to Eiffel Tower 5
      Then - Actions
        Set VariableSet meveille[5] = True
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Unit-type of (Constructed structure)) Equal to Citadel of Verdun 6
      Then - Actions
        Set VariableSet meveille[6] = True
        Unit - Add Verdun to (Constructed structure)
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Unit-type of (Constructed structure)) Equal to Pentagon 7
      Then - Actions
        Set VariableSet meveille[7] = True
        Unit - Add Pentagon to (Constructed structure)
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Unit-type of (Constructed structure)) Equal to Burj Khalifa 8
      Then - Actions
        Set VariableSet meveille[8] = True
        Unit Group - Pick every unit in (Units in (Playable map area) owned by (Owner of (Triggering unit))) and do (Disable supply usage for (Picked unit).)
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Unit-type of (Constructed structure)) Equal to Great Firewall 9
      Then - Actions
        Set VariableSet meveille[9] = True
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Unit-type of (Constructed structure)) Equal to Fusion Reactor 10
      Then - Actions
        Set VariableSet meveille[10] = True
      Else - Actions
caputre
  Events
    Unit - A unit Dies
  Conditions
    (Point-value of (Triggering unit)) Equal to 400
  Actions
    Game - Display to (All players) for 10.00 seconds the text: (((|cff008080 + titre[(Player number of (Owner of (Killing unit)))]) + |r has captured the |cff008080) + ((Name of (Triggering unit)) + |r.))
    Sound - Play QuestNew <gen>
    Unit - Change ownership of (Triggering unit) to (Owner of (Killing unit)) and Change color
    Set VariableSet spawn_mob = (Position of (Triggering unit))
    Unit - Create 1.(Unit-type of (Triggering unit)) for (Owner of (Killing unit)) at spawn_mob facing Default building facing degrees
    Custom script: call RemoveLocation(udg_spawn_mob)
    Unit Group - Pick every unit in (Units in (Playable map area) owned by (Owner of (Killing unit))) and do (Disable supply usage for (Picked unit).)
    Unit Group - Pick every unit in (Units in (Playable map area) owned by (Owner of (Triggering unit))) and do (Enable supply usage for (Picked unit).)
speed up
  Events
    Unit - A unit Begins construction
  Conditions
    (Number of units in (Units owned by (Owner of (Triggering unit)) of type Eiffel Tower 5)) Equal to 1
    meveille[5] Equal to True
    (Point-value of (Triggering unit)) Not equal to 400
  Actions
    Wait 0.10 seconds
    Unit - Set (Triggering unit) construction progress to 25%
speed up2
  Events
    Unit - A unit Finishes training a unit
  Conditions
    (Number of units in (Units owned by (Owner of (Triggering unit)) of type Burj Khalifa 8)) Equal to 1
    meveille[8] Equal to True
  Actions
    Unit - Disable supply usage for (Trained unit).
double
  Events
    Unit - A unit Finishes training a unit
  Conditions
    (Number of units in (Units owned by (Owner of (Triggering unit)) of type Stonehenge 1)) Equal to 1
    meveille[1] Equal to True
    (Unit-type of (Trained unit)) Not equal to Caravan 1
    (Unit-type of (Trained unit)) Not equal to Caravan 2
    (Unit-type of (Trained unit)) Not equal to Merchant Ship 6
    (Unit-type of (Trained unit)) Not equal to Merchant Ship 1
    (Unit-type of (Trained unit)) Not equal to Villager fake10
    (Unit-type of (Trained unit)) Not equal to Villager fake3
    (Unit-type of (Trained unit)) Not equal to Villager fake4
    (Unit-type of (Trained unit)) Not equal to Villager fake5
    (Unit-type of (Trained unit)) Not equal to Villager fake6
    (Unit-type of (Trained unit)) Not equal to Villager fake7
    (Unit-type of (Trained unit)) Not equal to Villager fake8
    (Unit-type of (Trained unit)) Not equal to Villager fake9
    (Unit-type of (Trained unit)) Not equal to Observation Satellite
    (Unit-type of (Trained unit)) Not equal to Orbital AttackSatellite
  Actions
    Set VariableSet AleoLivre = (Random integer number between 1 and 2)
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        AleoLivre Equal to 1
      Then - Actions
        Set VariableSet Point_of_Path = (Rally-Point of (Triggering unit) as a point)
        Unit - Create 1.(Unit-type of (Trained unit)) for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Default building facing degrees
        Unit - Order (Last created unit) to Move To.Point_of_Path
        Custom script: call RemoveLocation (udg_Point_of_Path)
      Else - Actions
cooldown
  Events
    Unit - A unit Starts the effect of an ability
  Conditions
    meveille[4] Equal to True
    (Number of units in (Units owned by (Owner of (Triggering unit)) of type Forbidden City 4)) Equal to 1
  Actions
    Unit - For Unit (Triggering unit), end cooldown of ability (Ability being cast)
This is the only place you should be messing around if you don't know how to code.

NOTE:

ADD = This is the value added per level, even at Lv1.
BASE = This is the base Value

So at Lv1, if you wanted an 80 damage, with 20 increase per level. BASE should be 60, and ADD should be 20.

Disregard the "C_SG_NS" just consider what is afterwards.

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

Loop Interval - This is the interval of the execution of loop. 0.04s is 25 execution per second.

Channel: This is the time for the unit to channel the spell. You have to edit the one from the Object Editor; change the cast time to fit your channeling needs (+ 0.01). Also 25 = 1s, if your interval is 0.04. If you adjust your interval, then you have to recalculate the channeling time as well.

AOE: This is how big is your AOE.

DMG_Min_Flat: This here is the flat damage, the minimum damage done when the HP of your target is really low. So if your target's hp is 20, then your damage will be invariably 480, should you set it that way.

DMG_Max_Percent: This here is the percentile damage, essentially when the targets have high HP. The damage will reference a percentage of their HP, rather than flat amount to deal damage. So if your target has 20000 HP, with 60% percentile damage, the damage dealt is 12000.

DMG_Structure: This is of the same essense calculated like the flat damage. However, this is instead what is dealt to structures. Should you want to deal percentile damage to structures, you have to change it from the Nuclear Strike Loop.

Delay: This is how long for the nuke to land.

Blink Interval: This is the interval of your dot's blinking. (Loop Interval) * (Blink interval), Currently it's 3 so, the blink interval is 0.12s.

Calldown Sound: This is the sound played when casting the ability. Currently there is 2 types of alert that is loaded. Now a SC1 variant is used, but a SC2 variant is also available.
Constants
  Events
    Map initialization
  Conditions
  Actions
    -------- --------------- --------
    -------- =============== --------
    -------- Nuclear Missile --------
    -------- =============== --------
    -------- --------------- --------
    Custom script: set udg_C_SG_NS_Loop_Interval = 0.04
    -------- --------------- --------
    Set VariableSet C_SG_NS_Ability = Nuclear Strike yes
    -------- --------------- --------
    Set VariableSet C_SG_NS_Channel_Add = 0
    Set VariableSet C_SG_NS_Channel_Base = 100
    -------- --------------- --------
    Set VariableSet C_SG_NS_AOE_Add = 100.00
    Set VariableSet C_SG_NS_AOE_Base = 300.00
    -------- --------------- --------
    Set VariableSet C_SG_NS_DMG_Min_Flat_Add = 120.00
    Set VariableSet C_SG_NS_DMG_Min_Flat_Base = 120.00
    -------- --------------- --------
    Set VariableSet C_SG_NS_DMG_Max_Percent_Add = 0.90
    Set VariableSet C_SG_NS_DMG_Max_Percent_Base = 0.00
    -------- --------------- --------
    Set VariableSet C_SG_NS_DMG_Structure_Add = 5000.00
    Set VariableSet C_SG_NS_DMG_Structure_Base = 5000.00
    -------- --------------- --------
    Set VariableSet SG_NS_MUI_Index_A = 0
    Set VariableSet C_SG_NS_Delay = 10
    Set VariableSet C_SG_NS_Blink_Interval = 3
    Set VariableSet C_SG_NS_Calldown_Sound = Nuclear <gen>
    -------- --------------- --------
    -------- Below are SFX, these are the nuke calldown, and then the impact sfx. These are strings, you put the file location. --------
    -------- --------------- --------
    Set VariableSet C_SG_NS_SFX_Nuke = NuclearExplosion.mdx
    Set VariableSet C_SG_NS_SFX_Hit = Abilities\Weapons\RedDragonBreath\RedDragonMissile.mdl
    -------- --------------- --------
    Trigger - Add to Nuclear_Strike_Loop <gen> the event (Every C_SG_NS_Loop_Interval seconds of game time)
NOTE:

If you wanted to have a special Nuke-Launching Silo, you have to make one.
Nuclear Strike Cast
  Events
    Unit - A unit Begins casting an ability
  Conditions
    (Ability being cast) Equal to C_SG_NS_Ability
  Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        Uranium[(Player number of (Owner of (Triggering unit)))] Greater than or equal to 1000
      Then - Actions
        Set VariableSet Uranium[(Player number of (Owner of (Triggering unit)))] = (Uranium[(Player number of (Owner of (Triggering unit)))] - 1000)
        Set VariableSet MyResourceValue[((100 x (Player number of (Owner of (Triggering unit)))) + 13)] = (String(Uranium[(Player number of (Owner of (Triggering unit)))]))
        Set VariableSet SG_NS_MUI_Index_A = (SG_NS_MUI_Index_A + 1)
        Set VariableSet SG_NS_Caster[SG_NS_MUI_Index_A] = (Triggering unit)
        Set VariableSet SG_NS_Counter[SG_NS_MUI_Index_A] = (C_SG_NS_Delay + (C_SG_NS_Channel_Base + (C_SG_NS_Channel_Add x (Level of C_SG_NS_Ability for SG_NS_Caster[SG_NS_MUI_Index_A]))))
        Set VariableSet SG_NS_Point[SG_NS_MUI_Index_A] = (Target point of ability being cast)
        Set VariableSet SG_NS_DMG_Percent[SG_NS_MUI_Index_A] = (C_SG_NS_DMG_Max_Percent_Base + (C_SG_NS_DMG_Max_Percent_Add x (Real((Level of C_SG_NS_Ability for SG_NS_Caster[SG_NS_MUI_Index_A])))))
        Set VariableSet SG_NS_DMG_Flat[SG_NS_MUI_Index_A] = (C_SG_NS_DMG_Min_Flat_Base + (C_SG_NS_DMG_Min_Flat_Add x (Real((Level of C_SG_NS_Ability for SG_NS_Caster[SG_NS_MUI_Index_A])))))
        Set VariableSet SG_NS_DMG_Structure[SG_NS_MUI_Index_A] = (C_SG_NS_DMG_Structure_Base + (C_SG_NS_DMG_Structure_Add x (Real((Level of C_SG_NS_Ability for SG_NS_Caster[SG_NS_MUI_Index_A])))))
        Set VariableSet SG_NS_AOE[SG_NS_MUI_Index_A] = (C_SG_NS_AOE_Base + (C_SG_NS_AOE_Add x (Real((Level of C_SG_NS_Ability for SG_NS_Caster[SG_NS_MUI_Index_A])))))
        Set VariableSet SG_NS_Order[SG_NS_MUI_Index_A] = (Current order of SG_NS_Caster[SG_NS_MUI_Index_A])
        Floating Text - Create floating text that reads at SG_NS_Point[SG_NS_MUI_Index_A] with Z offset 128.00, using font size 12.00, color (100%, 0.00%, 0.00%), and 0% transparency
        Set VariableSet SG_NS_Floating_Text[SG_NS_MUI_Index_A] = (Last created floating text)
        Floating Text - Hide SG_NS_Floating_Text[SG_NS_MUI_Index_A] for (All players)
        Floating Text - Show SG_NS_Floating_Text[SG_NS_MUI_Index_A] for (All players matching (((Matching player) is an ally of (Owner of SG_NS_Caster[SG_NS_MUI_Index_A]).) Equal to True).)
        Floating Text - Create floating text that reads . at SG_NS_Point[SG_NS_MUI_Index_A] with Z offset 128.00, using font size 12.00, color (100%, 0.00%, 0.00%), and 0% transparency
        Set VariableSet SG_NS_Floating_Text_Dot[SG_NS_MUI_Index_A] = (Last created floating text)
        Set VariableSet SG_NS_Completed[SG_NS_Temp_Integer_A] = True
        Sound - Stop C_SG_NS_Calldown_Sound Immediately
        Sound - Play C_SG_NS_Calldown_Sound
        Visibility - Create an initially Enabled visibility modifier for (Owner of SG_NS_Caster[SG_NS_MUI_Index_A]) emitting Visibility from SG_NS_Point[SG_NS_MUI_Index_A] to a radius of SG_NS_AOE[SG_NS_MUI_Index_A].
        Set VariableSet SG_NS_Vision[SG_NS_MUI_Index_A] = (Last created visibility modifier)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            SG_NS_MUI_Index_A Equal to 1
          Then - Actions
            Trigger - Turn on Nuclear_Strike_Loop <gen>
          Else - Actions
      Else - Actions
Nuclear Strike Loop
  Events
  Conditions
  Actions
    For each (Integer SG_NS_Temp_Integer_A) from 1 to SG_NS_MUI_Index_A, do (Actions)
      Loop - Actions
        -------- --------------- --------
        -------- Stay away, this is the counter. This counts down which is used to time everything. --------
        -------- --------------- --------
        Set VariableSet SG_NS_Counter[SG_NS_Temp_Integer_A] = (SG_NS_Counter[SG_NS_Temp_Integer_A] - 1)
        -------- --------------- --------
        -------- This here is the floating text, it shows both the dot and the timer. --------
        -------- --------------- --------
        -------- This part changes the floating text's texts. This shows the time before impact, up to 1 decimal. --------
        Floating Text - Change text of SG_NS_Floating_Text[SG_NS_Temp_Integer_A] to (|cffff0000Nuclear Strike:|n|cffffffff + (String(((Real(SG_NS_Counter[SG_NS_Temp_Integer_A])) x C_SG_NS_Loop_Interval), 1, 1))) using font size 12.00
        -------- This here makes it blink. The calculation uses MOD. If there is a remainder when the Counter is divided with the interval, --------
        -------- Then the dot hides, else if the remainder = 0, then the dot shows up. --------
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            Or - Any (Conditions) are true
              Conditions
                SG_NS_Counter[SG_NS_Temp_Integer_A] Less than or equal to C_SG_NS_Delay
                (SG_NS_Counter[SG_NS_Temp_Integer_A] mod C_SG_NS_Blink_Interval) Less than or equal to 0
          Then - Actions
            Floating Text - Change text of SG_NS_Floating_Text_Dot[SG_NS_Temp_Integer_A] to using font size 12.00
          Else - Actions
            Floating Text - Change text of SG_NS_Floating_Text_Dot[SG_NS_Temp_Integer_A] to . using font size 12.00
        -------- This part ensures that the floating texts are moved where they are supposed to be. --------
        Floating Text - Change the position of SG_NS_Floating_Text[SG_NS_Temp_Integer_A] to SG_NS_Point[SG_NS_Temp_Integer_A] with Z offset 128.00
        Floating Text - Change the position of SG_NS_Floating_Text_Dot[SG_NS_Temp_Integer_A] to SG_NS_Point[SG_NS_Temp_Integer_A] with Z offset 0
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            And - All (Conditions) are true
              Conditions
                Or - Any (Conditions) are true
                  Conditions
                    (SG_NS_Caster[SG_NS_Temp_Integer_A] is dead) Equal to True
                    (Current order of SG_NS_Caster[SG_NS_Temp_Integer_A]) Not equal to SG_NS_Order[SG_NS_Temp_Integer_A]
                    (SG_NS_Caster[SG_NS_Temp_Integer_A] is Polymorphed) Equal to True
                    (SG_NS_Caster[SG_NS_Temp_Integer_A] is Stunned) Equal to True
                    (SG_NS_Caster[SG_NS_Temp_Integer_A] is Snared) Equal to True
                SG_NS_Counter[SG_NS_Temp_Integer_A] Greater than C_SG_NS_Delay
          Then - Actions
            Set VariableSet SG_NS_Completed[SG_NS_Temp_Integer_A] = False
          Else - Actions
            Set VariableSet SG_NS_Completed[SG_NS_Temp_Integer_A] = True
        -------- --------------- --------
        -------- Should it reaches the delay, this launches the missile. --------
        -------- --------------- --------
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            SG_NS_Counter[SG_NS_Temp_Integer_A] Equal to C_SG_NS_Delay
          Then - Actions
            Set VariableSet SG_NS_Completed[SG_NS_Temp_Integer_A] = True
            Special Effect - Create a special effect at SG_NS_Point[SG_NS_Temp_Integer_A] using C_SG_NS_SFX_Nuke
            Set VariableSet SG_NS_Nuke_SFX[SG_NS_Temp_Integer_A] = (Last created special effect)
          Else - Actions
        -------- --------------- --------
        -------- DAMAGE CHANGING? --------
        -------- --------------- --------
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            Or - Any (Conditions) are true
              Conditions
                SG_NS_Completed[SG_NS_Temp_Integer_A] Equal to False
                And - All (Conditions) are true
                  Conditions
                    SG_NS_Counter[SG_NS_Temp_Integer_A] Less than or equal to 0
                    SG_NS_Completed[SG_NS_Temp_Integer_A] Equal to True
          Then - Actions
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                SG_NS_Completed[SG_NS_Temp_Integer_A] Equal to True
              Then - Actions
                Set VariableSet Temp_Group = (Units within SG_NS_AOE[SG_NS_Temp_Integer_A] of SG_NS_Point[SG_NS_Temp_Integer_A] matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) is A flying unit) Equal to False)).)
                -------- --------------- --------
                -------- Change damage here. --------
                -------- --------------- --------
                Unit Group - Pick every unit in Temp_Group and do (Actions)
                  Loop - Actions
                    Set VariableSet Temp_PickedUnit = (Picked unit)
                    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      If - Conditions
                        (Temp_PickedUnit is A structure) Equal to True
                      Then - Actions
                        Unit - Cause SG_NS_Caster[SG_NS_Temp_Integer_A] to damage Temp_PickedUnit, dealing SG_NS_DMG_Structure[SG_NS_Temp_Integer_A] damage of attack type Magic and damage type Magic
                      Else - Actions
                        Unit - Make Temp_PickedUnit Explode on death
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                          If - Conditions
                            ((Max life of Temp_PickedUnit) x SG_NS_DMG_Percent[SG_NS_Temp_Integer_A]) Greater than SG_NS_DMG_Flat[SG_NS_Temp_Integer_A]
                          Then - Actions
                            Unit - Cause SG_NS_Caster[SG_NS_Temp_Integer_A] to damage Temp_PickedUnit, dealing ((Max life of (Picked unit)) x SG_NS_DMG_Percent[SG_NS_Temp_Integer_A]) damage of attack type Magic and damage type Magic
                          Else - Actions
                            Unit - Cause SG_NS_Caster[SG_NS_Temp_Integer_A] to damage Temp_PickedUnit, dealing SG_NS_DMG_Flat[SG_NS_Temp_Integer_A] damage of attack type Magic and damage type Magic
                        Unit - Make Temp_PickedUnit Die normally on death
                    Special Effect - Create a special effect attached to the chest (attachpoint) of Temp_PickedUnit using C_SG_NS_SFX_Hit
                    Special Effect - Destroy (Last created special effect)
                -------- --------------- --------
                Custom script: call DestroyGroup (udg_Temp_Group)
              Else - Actions
            Floating Text - Destroy SG_NS_Floating_Text[SG_NS_Temp_Integer_A]
            Floating Text - Destroy SG_NS_Floating_Text_Dot[SG_NS_Temp_Integer_A]
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                SG_NS_Completed[SG_NS_Temp_Integer_A] Equal to True
              Then - Actions
                Unit - Create 1.Atomic Land 1 for Neutral Hostile at SG_NS_Point[SG_NS_Temp_Integer_A] facing Default building facing degrees
                Unit - Add a 180.00 second Generic expiration timer to (Last created unit)
              Else - Actions
            Custom script: call RemoveLocation (udg_SG_NS_Point[udg_SG_NS_Temp_Integer_A])
            Visibility - Disable SG_NS_Vision[SG_NS_Temp_Integer_A]
            Visibility - Destroy SG_NS_Vision[SG_NS_Temp_Integer_A]
            Set VariableSet SG_NS_Order[SG_NS_Temp_Integer_A] = SG_NS_Order[SG_NS_MUI_Index_A]
            Set VariableSet SG_NS_Caster[SG_NS_Temp_Integer_A] = SG_NS_Caster[SG_NS_MUI_Index_A]
            Set VariableSet SG_NS_Counter[SG_NS_Temp_Integer_A] = SG_NS_Counter[SG_NS_MUI_Index_A]
            Set VariableSet SG_NS_Point[SG_NS_Temp_Integer_A] = SG_NS_Point[SG_NS_MUI_Index_A]
            Set VariableSet SG_NS_DMG_Flat[SG_NS_Temp_Integer_A] = SG_NS_DMG_Flat[SG_NS_MUI_Index_A]
            Set VariableSet SG_NS_DMG_Percent[SG_NS_Temp_Integer_A] = SG_NS_DMG_Percent[SG_NS_MUI_Index_A]
            Set VariableSet SG_NS_DMG_Structure[SG_NS_Temp_Integer_A] = SG_NS_DMG_Structure[SG_NS_MUI_Index_A]
            Set VariableSet SG_NS_AOE[SG_NS_Temp_Integer_A] = SG_NS_AOE[SG_NS_MUI_Index_A]
            Set VariableSet SG_NS_Nuke_SFX[SG_NS_Temp_Integer_A] = SG_NS_Nuke_SFX[SG_NS_MUI_Index_A]
            Set VariableSet SG_NS_Floating_Text[SG_NS_Temp_Integer_A] = SG_NS_Floating_Text[SG_NS_MUI_Index_A]
            Set VariableSet SG_NS_Floating_Text_Dot[SG_NS_Temp_Integer_A] = SG_NS_Floating_Text_Dot[SG_NS_MUI_Index_A]
            Set VariableSet SG_NS_Completed[SG_NS_Temp_Integer_A] = SG_NS_Completed[SG_NS_MUI_Index_A]
            Set VariableSet SG_NS_Vision[SG_NS_Temp_Integer_B] = SG_NS_Vision[SG_NS_MUI_Index_A]
            Floating Text - Change the position of SG_NS_Floating_Text[SG_NS_Temp_Integer_A] to SG_NS_Point[SG_NS_Temp_Integer_A] with Z offset 128.00
            Floating Text - Change the position of SG_NS_Floating_Text_Dot[SG_NS_Temp_Integer_A] to SG_NS_Point[SG_NS_Temp_Integer_A] with Z offset 0.00
            Set VariableSet SG_NS_MUI_Index_A = (SG_NS_MUI_Index_A - 1)
            Set VariableSet SG_NS_Temp_Integer_A = (SG_NS_Temp_Integer_A - 1)
          Else - Actions
        -------- --------------- --------
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        SG_NS_MUI_Index_A Less than or equal to 0
      Then - Actions
        Trigger - Turn off (This trigger)
      Else - Actions
select
  Events
    Player - Player 1 (Red) Selects a unit
    Player - Player 2 (Blue) Selects a unit
    Player - Player 3 (Teal) Selects a unit
    Player - Player 4 (Purple) Selects a unit
    Player - Player 5 (Yellow) Selects a unit
    Player - Player 6 (Orange) Selects a unit
    Player - Player 7 (Green) Selects a unit
    Player - Player 8 (Pink) Selects a unit
    Player - Player 9 (Gray) Selects a unit
    Player - Player 10 (Light Blue) Selects a unit
    Player - Player 11 (Dark Green) Selects a unit
    Player - Player 12 (Brown) Selects a unit
    Player - Player 13 (Maroon) Selects a unit
    Player - Player 14 (Navy) Selects a unit
    Player - Player 15 (Turquoise) Selects a unit
    Player - Player 16 (Violet) Selects a unit
    Player - Player 17 (Wheat) Selects a unit
    Player - Player 18 (Peach) Selects a unit
    Player - Player 19 (Mint) Selects a unit
    Player - Player 20 (Lavender) Selects a unit
    Player - Player 21 (Coal) Selects a unit
    Player - Player 22 (Snow) Selects a unit
    Player - Player 23 (Emerald) Selects a unit
    Player - Player 24 (Peanut) Selects a unit
  Conditions
  Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        Uranium[(Player number of (Owner of (Triggering unit)))] Less than 20
      Then - Actions
        Player - Disable Cold Arrows yes for (Owner of (Triggering unit))
        Player - Enable Flèches de glace no for (Owner of (Attacking unit))
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        Uranium[(Player number of (Owner of (Triggering unit)))] Greater than or equal to 20
      Then - Actions
        Player - Enable Cold Arrows yes for (Owner of (Triggering unit))
        Player - Disable Flèches de glace no for (Owner of (Triggering unit))
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Point-value of (Triggering unit)) Equal to 210
      Then - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            Uranium[(Player number of (Owner of (Triggering unit)))] Less than 1000
          Then - Actions
            Player - Disable Nuclear Strike yes for (Owner of (Triggering unit))
            Player - Enable Nuclear Strike no for (Owner of (Triggering unit))
          Else - Actions
            Player - Enable Nuclear Strike yes for (Owner of (Triggering unit))
            Player - Disable Nuclear Strike no for (Owner of (Triggering unit))
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Unit-type of (Triggering unit)) Equal to Death Star
      Then - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            Uranium[(Player number of (Owner of (Triggering unit)))] Less than 20000
          Then - Actions
            Player - Disable Destroy Planet yes for (Owner of (Triggering unit))
            Player - Enable Destroy Planet no for (Owner of (Triggering unit))
          Else - Actions
            Player - Disable Destroy Planet no for (Owner of (Triggering unit))
            Player - Enable Destroy Planet yes for (Owner of (Triggering unit))
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Point-value of (Triggering unit)) Equal to 355
      Then - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            Uranium[(Player number of (Owner of (Triggering unit)))] Less than 1000
          Then - Actions
            Player - Enable Flame Strike no for (Owner of (Triggering unit))
            Player - Disable Flame Strike yes for (Owner of (Triggering unit))
          Else - Actions
            Player - Disable Flame Strike no for (Owner of (Triggering unit))
            Player - Enable Flame Strike yes for (Owner of (Triggering unit))
      Else - Actions
arrow nuke
  Events
    Unit - A unit Is attacked
  Conditions
    Or - Any (Conditions) are true
      Conditions
        ((Triggering unit) has buff Black Arrow) Equal to True
        ((Triggering unit) has buff Cold Arrows (Stacking)) Equal to True
        ((Triggering unit) has buff Cold Arrows (Non-stacking)) Equal to True
  Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        Or - Any (Conditions) are true
          Conditions
            (Point-value of (Attacking unit)) Equal to 201
            (Point-value of (Attacking unit)) Equal to 202
      Then - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            Uranium[(Player number of (Owner of (Attacking unit)))] Greater than 20
          Then - Actions
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                Pollution Less than 100.00
              Then - Actions
                Set VariableSet Pollution = (Pollution + 0.02)
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  If - Conditions
                    Pollution Greater than 100.00
                  Then - Actions
                    Set VariableSet Pollution = 100.00
                  Else - Actions
                For each (Integer A) from 1 to 24, do (Actions)
                  Loop - Actions
                    Set VariableSet MyResourceValue[((100 x (Player number of (Player((Integer A))))) + 14)] = ((String(Pollution)) + %)
              Else - Actions
            Floating Text - Create floating text that reads |cff008000-20 above (Attacking unit) with Z offset 0, using font size 10.00, color (100%, 100%, 100%), and 0% transparency
            Floating Text - Change (Last created floating text): Disable permanence
            Floating Text - Change the lifespan of (Last created floating text) to 1.80 seconds
            Floating Text - Set the velocity of (Last created floating text) to 32.00 towards 90 degrees
            Set VariableSet Uranium[(Player number of (Owner of (Attacking unit)))] = (Uranium[(Player number of (Owner of (Attacking unit)))] - 20)
            Set VariableSet MyResourceValue[((100 x (Player number of (Owner of (Attacking unit)))) + 13)] = (String(Uranium[(Player number of (Owner of (Attacking unit)))]))
            Set VariableSet Point_of_Path = ((Position of (Triggering unit)) offset by ((Random real number between -200.00 and 200.00), (Random real number between -200.00 and 200.00)))
            Unit - Create 1.Atomic Land 2 for (Owner of (Attacking unit)) at Point_of_Path facing Default building facing degrees
            Unit - Add a 20.00 second Generic expiration timer to (Last created unit)
            Custom script: call RemoveLocation (udg_Point_of_Path)
          Else - Actions
            Player - Disable Cold Arrows yes for (Owner of (Attacking unit))
            Player - Enable Flèches de glace no for (Owner of (Attacking unit))
      Else - Actions
destroy planet
  Events
    Unit - A unit Starts the effect of an ability
  Conditions
  Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Ability being cast) Equal to Flame Strike yes
      Then - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            (Terre <gen> contains (Target point of ability being cast)) Equal to True
          Then - Actions
            Set VariableSet Uranium[(Player number of (Owner of (Triggering unit)))] = (Uranium[(Player number of (Owner of (Triggering unit)))] - 1000)
            Set VariableSet MyResourceValue[((100 x (Player number of (Owner of (Triggering unit)))) + 13)] = (String(Uranium[(Player number of (Owner of (Triggering unit)))]))
            Set VariableSet Point_of_Path = (Position of (Target unit of ability being cast))
            Cinematic - Ping minimap for (All players) at Point_of_Path for 1 seconds
            Custom script: call RemoveLocation (udg_Point_of_Path)
            Sound - Play MapPing <gen>
            Game - Display to (All players) for 5.00 seconds the text: ((|cff800000 + titre[(Player number of (Owner of (Triggering unit)))]) + |r has launched an Orbital Strike.)
          Else - Actions
            Game - Display to (Player group((Owner of (Triggering unit)))) for 10.00 seconds the text: |cffffcc00You can only do orbital attack on Earth.
            Unit - Order (Triggering unit) to Stop.
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Ability being cast) Equal to Mine Asteroid
      Then - Actions
        Set VariableSet Gold[(Player number of (Owner of (Triggering unit)))] = (Gold[(Player number of (Owner of (Triggering unit)))] - 50)
        Set VariableSet MyResourceValue[((100 x (Player number of (Owner of (Triggering unit)))) + 11)] = (String(Gold[(Player number of (Owner of (Triggering unit)))]))
        Set VariableSet Uranium[(Player number of (Owner of (Triggering unit)))] = (Uranium[(Player number of (Owner of (Triggering unit)))] + 10)
        Set VariableSet MyResourceValue[((100 x (Player number of (Owner of (Triggering unit)))) + 13)] = (String(Uranium[(Player number of (Owner of (Triggering unit)))]))
        Floating Text - Create floating text that reads |cffd45e19 +20 above (Triggering unit) with Z offset 0, using font size 10.00, color (100%, 100%, 100%), and 0% transparency
        Floating Text - Change (Last created floating text): Disable permanence
        Floating Text - Change the lifespan of (Last created floating text) to 1.80 seconds
        Floating Text - Set the velocity of (Last created floating text) to 32.00 towards 90 degrees
        Unit - Order (Triggering unit) to Night Elf Mountain Giant - War Club.(Random destructible in (Region centered at (Position of (Triggering unit)) with size (1000.00, 1000.00)) matching ((Destructible-type of (Matching destructible)) Equal to B002 (destructablecode)))
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Ability being cast) Equal to Destroy Planet yes
      Then - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            (Point-value of (Target unit of ability being cast)) Equal to 99
          Then - Actions
            Set VariableSet Uranium[(Player number of (Owner of (Triggering unit)))] = (Uranium[(Player number of (Owner of (Triggering unit)))] - 20000)
            Set VariableSet MyResourceValue[((100 x (Player number of (Owner of (Triggering unit)))) + 13)] = (String(Uranium[(Player number of (Owner of (Triggering unit)))]))
            Floating Text - Create floating text that reads |cff008000-20 000 above (Triggering unit) with Z offset 0, using font size 10.00, color (100%, 100%, 100%), and 0% transparency
            Floating Text - Change (Last created floating text): Disable permanence
            Floating Text - Change the lifespan of (Last created floating text) to 1.80 seconds
            Floating Text - Set the velocity of (Last created floating text) to 32.00 towards 90 degrees
            Game - Display to (All players) for 10.00 seconds the text: ((|cff800000 + titre[(Player number of (Owner of (Triggering unit)))]) + (|r has destroyed the planet |cff800000 + ((Name of (Target unit of ability being cast)) + .)))
            Sound - Play Warning <gen>
            Special Effect - Create a special effect at (Position of (Target unit of ability being cast)) using war3mapImported\NewMassiveEX.mdx
            Set VariableSet Lieu[12] = ((Position of (Target unit of ability being cast)) offset by ((Random real number between -500.00 and 500.00), (Random real number between -500.00 and 500.00)))
            Destructible - Create a B002 (destructablecode) at Lieu[12] facing (Random angle) with scale (Random real number between 0.40 and 0.80) and variation 0
            Custom script: call RemoveLocation (udg_Lieu[12])
            Set VariableSet Lieu[12] = ((Position of (Target unit of ability being cast)) offset by ((Random real number between -500.00 and 500.00), (Random real number between -500.00 and 500.00)))
            Destructible - Create a B002 (destructablecode) at Lieu[12] facing (Random angle) with scale (Random real number between 0.40 and 0.80) and variation 0
            Custom script: call RemoveLocation (udg_Lieu[12])
            Set VariableSet Lieu[12] = ((Position of (Target unit of ability being cast)) offset by ((Random real number between -500.00 and 500.00), (Random real number between -500.00 and 500.00)))
            Destructible - Create a B002 (destructablecode) at Lieu[12] facing (Random angle) with scale (Random real number between 0.40 and 0.80) and variation 0
            Custom script: call RemoveLocation (udg_Lieu[12])
            Set VariableSet Lieu[12] = ((Position of (Target unit of ability being cast)) offset by ((Random real number between -500.00 and 500.00), (Random real number between -500.00 and 500.00)))
            Destructible - Create a B002 (destructablecode) at Lieu[12] facing (Random angle) with scale (Random real number between 0.40 and 0.80) and variation 0
            Custom script: call RemoveLocation (udg_Lieu[12])
            Set VariableSet Lieu[12] = ((Position of (Target unit of ability being cast)) offset by ((Random real number between -500.00 and 500.00), (Random real number between -500.00 and 500.00)))
            Destructible - Create a B002 (destructablecode) at Lieu[12] facing (Random angle) with scale (Random real number between 0.40 and 0.80) and variation 0
            Custom script: call RemoveLocation (udg_Lieu[12])
            Set VariableSet Lieu[12] = ((Position of (Target unit of ability being cast)) offset by ((Random real number between -500.00 and 500.00), (Random real number between -500.00 and 500.00)))
            Destructible - Create a B002 (destructablecode) at Lieu[12] facing (Random angle) with scale (Random real number between 0.40 and 0.80) and variation 0
            Custom script: call RemoveLocation (udg_Lieu[12])
            Set VariableSet Lieu[12] = ((Position of (Target unit of ability being cast)) offset by ((Random real number between -500.00 and 500.00), (Random real number between -500.00 and 500.00)))
            Destructible - Create a B002 (destructablecode) at Lieu[12] facing (Random angle) with scale (Random real number between 0.40 and 0.80) and variation 0
            Custom script: call RemoveLocation (udg_Lieu[12])
            Set VariableSet Lieu[12] = ((Position of (Target unit of ability being cast)) offset by ((Random real number between -500.00 and 500.00), (Random real number between -500.00 and 500.00)))
            Destructible - Create a B002 (destructablecode) at Lieu[12] facing (Random angle) with scale (Random real number between 0.40 and 0.80) and variation 0
            Custom script: call RemoveLocation (udg_Lieu[12])
            Unit - Remove (Target unit of ability being cast) from the game
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                (Unit-type of (Target unit of ability being cast)) Equal to Earth
              Then - Actions
                Unit Group - Pick every unit in (Units in Terre <gen>) and do (Actions)
                  Loop - Actions
                    Unit - Explode (Picked unit).
                Unit Group - Pick every unit in (Units of type Fishing Ship 6) and do (Actions)
                  Loop - Actions
                    Unit - Explode (Picked unit).
                Unit Group - Pick every unit in (Units of type Fishing Ship 5) and do (Actions)
                  Loop - Actions
                    Unit - Explode (Picked unit).
                Wait 0.50 seconds
                Unit Group - Pick every unit in (Units in Terre <gen>) and do (Actions)
                  Loop - Actions
                    Unit - Explode (Picked unit).
              Else - Actions
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                (Unit-type of (Target unit of ability being cast)) Equal to Jupiter
              Then - Actions
                Unit Group - Pick every unit in (Units in Jupiter <gen>) and do (Actions)
                  Loop - Actions
                    Unit - Explode (Picked unit).
              Else - Actions
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                (Unit-type of (Target unit of ability being cast)) Equal to Mars
              Then - Actions
                Unit Group - Pick every unit in (Units in Mars <gen>) and do (Actions)
                  Loop - Actions
                    Unit - Explode (Picked unit).
              Else - Actions
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                (Unit-type of (Target unit of ability being cast)) Equal to Mercury
              Then - Actions
                Unit Group - Pick every unit in (Units in Mercure <gen>) and do (Actions)
                  Loop - Actions
                    Unit - Explode (Picked unit).
              Else - Actions
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                (Unit-type of (Target unit of ability being cast)) Equal to Moon
              Then - Actions
                Unit Group - Pick every unit in (Units in Moon <gen>) and do (Actions)
                  Loop - Actions
                    Unit - Explode (Picked unit).
              Else - Actions
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                (Unit-type of (Target unit of ability being cast)) Equal to Neptune
              Then - Actions
                Unit Group - Pick every unit in (Units in Neptune <gen>) and do (Actions)
                  Loop - Actions
                    Unit - Explode (Picked unit).
              Else - Actions
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                (Unit-type of (Target unit of ability being cast)) Equal to Saturn
              Then - Actions
                Unit Group - Pick every unit in (Units in Saturne <gen>) and do (Actions)
                  Loop - Actions
                    Unit - Explode (Picked unit).
              Else - Actions
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                (Unit-type of (Target unit of ability being cast)) Equal to Uranus
              Then - Actions
                Unit Group - Pick every unit in (Units in Uranus <gen>) and do (Actions)
                  Loop - Actions
                    Unit - Explode (Picked unit).
              Else - Actions
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                (Unit-type of (Target unit of ability being cast)) Equal to Venus
              Then - Actions
                Unit Group - Pick every unit in (Units in Venus <gen>) and do (Actions)
                  Loop - Actions
                    Unit - Explode (Picked unit).
              Else - Actions
          Else - Actions
            Unit - Order (Triggering unit) to Stop.
            Game - Display to (All players) for 5.00 seconds the text: |cffffcc00You can only destroy a planet.
      Else - Actions
spell battleship
  Events
    Unit - A unit Starts the effect of an ability
  Conditions
  Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Ability being cast) Equal to Cluster Rockets
      Then - Actions
        Set VariableSet Gold[(Player number of (Owner of (Triggering unit)))] = (Gold[(Player number of (Owner of (Triggering unit)))] - 600)
        Set VariableSet MyResourceValue[((100 x (Player number of (Owner of (Triggering unit)))) + 11)] = (String(Gold[(Player number of (Owner of (Triggering unit)))]))
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Ability being cast) Equal to Invasive
      Then - Actions
        Set VariableSet Gold[(Player number of (Owner of (Triggering unit)))] = (Gold[(Player number of (Owner of (Triggering unit)))] - 800)
        Set VariableSet MyResourceValue[((100 x (Player number of (Owner of (Triggering unit)))) + 11)] = (String(Gold[(Player number of (Owner of (Triggering unit)))]))
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Ability being cast) Equal to Stampede
      Then - Actions
        Set VariableSet Gold[(Player number of (Owner of (Triggering unit)))] = (Gold[(Player number of (Owner of (Triggering unit)))] - 500)
        Set VariableSet MyResourceValue[((100 x (Player number of (Owner of (Triggering unit)))) + 11)] = (String(Gold[(Player number of (Owner of (Triggering unit)))]))
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Ability being cast) Equal to Acid Bomb
      Then - Actions
        Set VariableSet Gold[(Player number of (Owner of (Triggering unit)))] = (Gold[(Player number of (Owner of (Triggering unit)))] - 200)
        Set VariableSet MyResourceValue[((100 x (Player number of (Owner of (Triggering unit)))) + 11)] = (String(Gold[(Player number of (Owner of (Triggering unit)))]))
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Ability being cast) Equal to Dodge
      Then - Actions
        Set VariableSet Gold[(Player number of (Owner of (Triggering unit)))] = (Gold[(Player number of (Owner of (Triggering unit)))] - 100)
        Set VariableSet MyResourceValue[((100 x (Player number of (Owner of (Triggering unit)))) + 11)] = (String(Gold[(Player number of (Owner of (Triggering unit)))]))
        Unit - Remove Dodge from (Triggering unit)
        Unit - Add Evasion 30 to (Triggering unit)
        Animation - Add the alternate (animationname) animation tag to (Triggering unit)
        Wait 30.00 seconds
        Animation - Remove the alternate (animationname) animation tag to (Triggering unit)
        Unit - Remove Evasion 30 from (Triggering unit)
        Unit - Add Dodge to (Triggering unit)
      Else - Actions
CreateSpace
  Events
    Time - Elapsed game time is 0.02 seconds
  Conditions
  Actions
    Custom script: local real x
    Custom script: local real y
    Custom script: local real roll1
    Custom script: local integer roll2
    Custom script: local boolean b=false
    Custom script: local effect SFX
    Custom script: loop
    Custom script: set x=GetRandomReal(udg_SpaceMinX,udg_SpaceMaxX)
    Custom script: set y=GetRandomReal(udg_SpaceMinY,udg_SpaceMaxY)
    Custom script: set roll1=GetRandomReal(0,100)
    Custom script: set roll2=GetRandomInt(1,15)
    Custom script: set b=false
    Custom script: exitwhen udg_SpaceObjectsMax<=0 and udg_SpaceObjectsMax2<=0
    Custom script: set udg_SpaceObjectsMax=udg_SpaceObjectsMax-1
    Custom script: loop
    Custom script: if roll1<=udg_SpaceObjectSpawnChance[roll2] then
    Custom script: set b=true
    Custom script: set SFX=AddSpecialEffect(udg_SpaceObject[roll2],x,y)
    Custom script: if roll2>=12 then
    Custom script: call BlzSetSpecialEffectColor(SFX, GetRandomInt(0, 255), GetRandomInt(0, 255), GetRandomInt(0, 255) )
    Custom script: endif
    Custom script: call BlzSetSpecialEffectAlpha(SFX, GetRandomInt(100, 255) )
    Custom script: call BlzSetSpecialEffectZ(SFX, GetRandomReal(-2048,0) )
    Custom script: call BlzSetSpecialEffectScale(SFX,GetRandomReal(udg_SpaceObjectMinSize[roll2],udg_SpaceObjectMaxSize[roll2] ))
    Custom script: else
    Custom script: set roll1=GetRandomReal(0,100)
    Custom script: set roll2=GetRandomInt(1,15)
    Custom script: endif
    Custom script: exitwhen b
    Custom script: endloop
    Custom script: set SFX=null
    Custom script: if udg_SpaceObjectsMax==0 then
    Custom script: if udg_SpaceObjectsMax2>0 then
    Custom script: set udg_SpaceObjectsMax=udg_SpaceObjectsMax2
    Custom script: set udg_SpaceObjectsMax2=0
    Set VariableSet SpaceMaxX = (Max X of Space <gen>)
    Set VariableSet SpaceMaxY = (Max Y of Space <gen>)
    Set VariableSet SpaceMinX = (Min X of Space <gen>)
    Set VariableSet SpaceMinY = (Min Y of Space <gen>)
    Custom script: endif
    Custom script: endif
    Custom script: endloop
    Set VariableSet SpaceMaxX = (Max X of Space <gen>)
    Set VariableSet SpaceMaxY = (Max Y of Space <gen>)
    Set VariableSet SpaceMinX = (Min X of Space <gen>)
    Set VariableSet SpaceMinY = (Min Y of Space <gen>)
space
  Events
    Time - Elapsed game time is 0.00 seconds
  Conditions
  Actions
    Set VariableSet SpaceObject[1] = star0.mdx
    Set VariableSet SpaceObjectMaxSize[1] = 1.00
    Set VariableSet SpaceObjectMinSize[1] = 0.10
    Set VariableSet SpaceObjectSpawnChance[1] = 100.00
    Set VariableSet SpaceObject[2] = star1.mdx
    Set VariableSet SpaceObjectMaxSize[2] = 0.50
    Set VariableSet SpaceObjectMinSize[2] = 0.10
    Set VariableSet SpaceObjectSpawnChance[2] = 100.00
    Set VariableSet SpaceObject[3] = star2.mdx
    Set VariableSet SpaceObjectMaxSize[3] = 0.50
    Set VariableSet SpaceObjectMinSize[3] = 0.10
    Set VariableSet SpaceObjectSpawnChance[3] = 100.00
    Set VariableSet SpaceObject[4] = star3.mdx
    Set VariableSet SpaceObjectMaxSize[4] = 0.50
    Set VariableSet SpaceObjectMinSize[4] = 0.10
    Set VariableSet SpaceObjectSpawnChance[4] = 100.00
    Set VariableSet SpaceObject[5] = star4.mdx
    Set VariableSet SpaceObjectMaxSize[5] = 0.50
    Set VariableSet SpaceObjectMinSize[5] = 0.10
    Set VariableSet SpaceObjectSpawnChance[5] = 100.00
    Set VariableSet SpaceObject[6] = galaxy0.mdx
    Set VariableSet SpaceObjectMaxSize[6] = 5.00
    Set VariableSet SpaceObjectMinSize[6] = 0.40
    Set VariableSet SpaceObjectSpawnChance[6] = 0.50
    Set VariableSet SpaceObject[7] = galaxy1.mdx
    Set VariableSet SpaceObjectMaxSize[7] = 5.00
    Set VariableSet SpaceObjectMinSize[7] = 0.40
    Set VariableSet SpaceObjectSpawnChance[7] = 0.50
    Set VariableSet SpaceObject[8] = galaxy2.mdx
    Set VariableSet SpaceObjectMaxSize[8] = 5.00
    Set VariableSet SpaceObjectMinSize[8] = 0.40
    Set VariableSet SpaceObjectSpawnChance[8] = 0.50
    Set VariableSet SpaceObject[9] = galaxy3.mdx
    Set VariableSet SpaceObjectMaxSize[9] = 5.00
    Set VariableSet SpaceObjectMinSize[9] = 0.40
    Set VariableSet SpaceObjectSpawnChance[9] = 0.50
    Set VariableSet SpaceObject[10] = galaxy4.mdx
    Set VariableSet SpaceObjectMaxSize[10] = 5.00
    Set VariableSet SpaceObjectMinSize[10] = 0.40
    Set VariableSet SpaceObjectSpawnChance[10] = 0.50
    Set VariableSet SpaceObject[11] = galaxy5.mdx
    Set VariableSet SpaceObjectMaxSize[11] = 5.00
    Set VariableSet SpaceObjectMinSize[11] = 0.40
    Set VariableSet SpaceObjectSpawnChance[11] = 0.50
    Set VariableSet SpaceObject[12] = NebulaA0.mdx
    Set VariableSet SpaceObjectMaxSize[12] = 8.00
    Set VariableSet SpaceObjectMinSize[12] = 3.00
    Set VariableSet SpaceObjectSpawnChance[12] = 1.00
    Set VariableSet SpaceObject[13] = NebulaA1.mdx
    Set VariableSet SpaceObjectMaxSize[13] = 8.00
    Set VariableSet SpaceObjectMinSize[13] = 3.00
    Set VariableSet SpaceObjectSpawnChance[13] = 1.00
    Set VariableSet SpaceObject[14] = NebulaA2.mdx
    Set VariableSet SpaceObjectMaxSize[14] = 8.00
    Set VariableSet SpaceObjectMinSize[14] = 3.00
    Set VariableSet SpaceObjectSpawnChance[14] = 1.00
    Set VariableSet SpaceObject[15] = NebulaA3.mdx
    Set VariableSet SpaceObjectMaxSize[15] = 8.00
    Set VariableSet SpaceObjectMinSize[15] = 3.00
    Set VariableSet SpaceObjectSpawnChance[15] = 1.00
    Set VariableSet SpaceObjectsMax = 5000
    Set VariableSet SpaceObjectsMax2 = 300
    Set VariableSet SpaceMaxX = (Max X of Space <gen>)
    Set VariableSet SpaceMaxY = (Max Y of Space <gen>)
    Set VariableSet SpaceMinX = (Min X of Space <gen>)
    Set VariableSet SpaceMinY = (Min Y of Space <gen>)
space Copier
  Events
    Time - Elapsed game time is 2.10 seconds
  Conditions
  Actions
    Set VariableSet SpaceObject[1] = star0.mdx
    Set VariableSet SpaceObjectMaxSize[1] = 1.00
    Set VariableSet SpaceObjectMinSize[1] = 0.10
    Set VariableSet SpaceObjectSpawnChance[1] = 100.00
    Set VariableSet SpaceObject[2] = star1.mdx
    Set VariableSet SpaceObjectMaxSize[2] = 0.50
    Set VariableSet SpaceObjectMinSize[2] = 0.10
    Set VariableSet SpaceObjectSpawnChance[2] = 100.00
    Set VariableSet SpaceObject[3] = star2.mdx
    Set VariableSet SpaceObjectMaxSize[3] = 0.50
    Set VariableSet SpaceObjectMinSize[3] = 0.10
    Set VariableSet SpaceObjectSpawnChance[3] = 100.00
    Set VariableSet SpaceObject[4] = star3.mdx
    Set VariableSet SpaceObjectMaxSize[4] = 0.50
    Set VariableSet SpaceObjectMinSize[4] = 0.10
    Set VariableSet SpaceObjectSpawnChance[4] = 100.00
    Set VariableSet SpaceObject[5] = star4.mdx
    Set VariableSet SpaceObjectMaxSize[5] = 0.50
    Set VariableSet SpaceObjectMinSize[5] = 0.10
    Set VariableSet SpaceObjectSpawnChance[5] = 100.00
    Set VariableSet SpaceObjectsMax = 2500
    Set VariableSet SpaceObjectsMax2 = 150
    Set VariableSet SpaceMaxX = (Max X of Uranus <gen>)
    Set VariableSet SpaceMaxY = (Max Y of Uranus <gen>)
    Set VariableSet SpaceMinX = (Min X of Uranus <gen>)
    Set VariableSet SpaceMinY = (Min Y of Uranus <gen>)
CreateSpace Copier
  Events
    Time - Elapsed game time is 2.50 seconds
  Conditions
  Actions
    Custom script: local real x
    Custom script: local real y
    Custom script: local real roll1
    Custom script: local integer roll2
    Custom script: local boolean b=false
    Custom script: local effect SFX
    Custom script: loop
    Custom script: set x=GetRandomReal(udg_SpaceMinX,udg_SpaceMaxX)
    Custom script: set y=GetRandomReal(udg_SpaceMinY,udg_SpaceMaxY)
    Custom script: set roll1=GetRandomReal(0,100)
    Custom script: set roll2=GetRandomInt(1,5)
    Custom script: set b=false
    Custom script: exitwhen udg_SpaceObjectsMax<=0 and udg_SpaceObjectsMax2<=0
    Custom script: set udg_SpaceObjectsMax=udg_SpaceObjectsMax-1
    Custom script: loop
    Custom script: if roll1<=udg_SpaceObjectSpawnChance[roll2] then
    Custom script: set b=true
    Custom script: set SFX=AddSpecialEffect(udg_SpaceObject[roll2],x,y)
    Custom script: if roll2>=12 then
    Custom script: call BlzSetSpecialEffectColor(SFX, GetRandomInt(0, 255), GetRandomInt(0, 255), GetRandomInt(0, 255) )
    Custom script: endif
    Custom script: call BlzSetSpecialEffectAlpha(SFX, GetRandomInt(100, 255) )
    Custom script: call BlzSetSpecialEffectZ(SFX, GetRandomReal(1048,0) )
    Custom script: call BlzSetSpecialEffectScale(SFX,GetRandomReal(udg_SpaceObjectMinSize[roll2],udg_SpaceObjectMaxSize[roll2] ))
    Custom script: else
    Custom script: set roll1=GetRandomReal(0,100)
    Custom script: set roll2=GetRandomInt(1,5)
    Custom script: endif
    Custom script: exitwhen b
    Custom script: endloop
    Custom script: set SFX=null
    Custom script: if udg_SpaceObjectsMax==0 then
    Custom script: if udg_SpaceObjectsMax2>0 then
    Custom script: set udg_SpaceObjectsMax=udg_SpaceObjectsMax2
    Custom script: set udg_SpaceObjectsMax2=0
    Set VariableSet SpaceMaxX = (Max X of Space <gen>)
    Set VariableSet SpaceMaxY = (Max Y of Space <gen>)
    Set VariableSet SpaceMinX = (Min X of Space <gen>)
    Set VariableSet SpaceMinY = (Min Y of Space <gen>)
    Custom script: endif
    Custom script: endif
    Custom script: endloop
    Set VariableSet SpaceMaxX = (Max X of Space <gen>)
    Set VariableSet SpaceMaxY = (Max Y of Space <gen>)
    Set VariableSet SpaceMinX = (Min X of Space <gen>)
    Set VariableSet SpaceMinY = (Min Y of Space <gen>)
Warning
  Events
    Unit - A unit Is issued an order targeting an object
  Conditions
  Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Point-value of (Target unit of issued order)) Equal to 99
      Then - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            (Unit-type of (Triggering unit)) Equal to Death Star
          Then - Actions
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                (Issued order) Not equal to (Order(attack))
                (Issued order) Not equal to (Order(move))
                (Issued order) Not equal to (Order(smart))
                (Issued order) Not equal to (Order(patrol))
              Then - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  If - Conditions
                    (Point-value of (Target unit of issued order)) Equal to 99
                  Then - Actions
                    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      If - Conditions
                        (Distance between (Position of (Triggering unit)) and (Position of (Target unit of issued order))) Less than or equal to 500.00
                      Then - Actions
                        Animation - Play (Triggering unit)'s attack (animationname) animation
                        Game - Display to (All players) for 10.00 seconds the text: ((|cff800000 + titre[(Player number of (Owner of (Triggering unit)))]) + (|r is about to destroy the planet |cff800000 + ((Name of (Target unit of issued order)) + |r. In |cffffff0060|r seconds, the planet will explode.)))
                        Sound - Play Warning <gen>
                        Countdown Timer - Destroy Boom2
                        Countdown Timer - Create a timer window for Boom with title (Doom of + (Name of (Target unit of issued order)))
                        Set VariableSet Boom2 = (Last created timer window)
                        Countdown Timer - Start Boom as a One-shot timer that will expire in 60.00 seconds
                        Wait 60.00 seconds
                        Countdown Timer - Destroy Boom2
                      Else - Actions
                        Unit - Order (Triggering unit) to Stop.
                        Game - Display to (Player group((Owner of (Triggering unit)))) for 5.00 seconds the text: |cffffcc00You need to be closer to the planet to destroy it.
                        Set VariableSet pla = (Owner of (Triggering unit))
                        Custom script: if GetLocalPlayer() == udg_pla then
                        Sound - Play Error <gen>
                        Custom script: endif
                  Else - Actions
                    Unit - Order (Triggering unit) to Stop.
                    Game - Display to (Player group((Owner of (Triggering unit)))) for 5.00 seconds the text: |cffffcc00You need to be closer to the planet to destroy it.
                    Set VariableSet pla = (Owner of (Triggering unit))
                    Custom script: if GetLocalPlayer() == udg_pla then
                    Sound - Play Error <gen>
                    Custom script: endif
              Else - Actions
          Else - Actions
      Else - Actions
dyson income
  Events
    Time - Every 60.00 seconds of game time
  Conditions
  Actions
    Floating Text - Create floating text that reads Dyson Sphere:|n|cff00ff00+1000|n|cff800000+1000|n|cff008000+1000 above Dyson with Z offset 0, using font size 12.00, color (100%, 100%, 100%), and 0% transparency
    Floating Text - Change (Last created floating text): Disable permanence
    Floating Text - Change the lifespan of (Last created floating text) to 3.10 seconds
    Floating Text - Set the velocity of (Last created floating text) to 32.00 towards 90 degrees
    Player - Add 1000 to (Owner of Dyson).Current gold
    Player - Add 1000 to (Owner of Dyson).Current lumber
    Set VariableSet Uranium[(Player number of (Owner of Dyson))] = (Uranium[(Player number of (Owner of Dyson))] + 1000)
    Set VariableSet MyResourceValue[((100 x (Player number of (Owner of Dyson))) + 13)] = (String(Uranium[(Player number of (Owner of Dyson))]))
dyson
  Events
    Unit - A unit Finishes construction
  Conditions
  Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Unit-type of (Constructed structure)) Equal to Dyson Sphere
      Then - Actions
        Set VariableSet Dyson = (Constructed structure)
        Animation - Play the death (animationname) animation for all doodads of type D00R (doodadcode) within Space <gen>.
        Game - Display to (All players) for 10.00 seconds the text: ((|cff0000ff + titre[(Player number of (Owner of (Triggering unit)))]) + |r has build a Dyson sphere around the Sun.)
        Sound - Play QuestLog <gen>
        Trigger - Turn on dyson_income <gen>
        Trigger - Turn off pollute <gen>
        Set VariableSet Pollution = 0.00
        For each (Integer A) from 1 to 24, do (Actions)
          Loop - Actions
            Set VariableSet MyResourceValue[((100 x (Player number of (Player((Integer A))))) + 14)] = ((String(Pollution)) + %)
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Unit-type of (Constructed structure)) Equal to Death Star
      Then - Actions
        Game - Display to (All players) for 10.00 seconds the text: ((|cff0000ff + titre[(Player number of (Owner of (Triggering unit)))]) + |r has build a Death Star.)
        Sound - Play Warning <gen>
        Set VariableSet pla = (Owner of (Triggering unit))
        Custom script: if GetLocalPlayer() == udg_pla then
        Sound - Play Stage11 <gen>
        Custom script: endif
      Else - Actions
dyson mort
  Events
    Unit - A unit Dies
  Conditions
    (Triggering unit) Equal to Dyson
  Actions
    Animation - Play the stand (animationname) animation for all doodads of type D00R (doodadcode) within Space <gen>.
    Unit - Remove (Triggering unit) from the game
    Trigger - Turn off dyson_income <gen>
    Trigger - Turn on pollute <gen>
build
  Events
    Unit - A unit Finishes construction
  Conditions
  Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Unit-type of (Constructed structure)) Equal to Stellar Shield
      Then - Actions
        Custom script: call UnitAddAbilityBJ( 'Aloc', GetConstructedStructure() )
        Unit - Add Chaos Stuff to (Constructed structure)
      Else - Actions
no sat
  Events
    Unit - A unit Dies
  Conditions
  Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Unit-type of (Triggering unit)) Equal to Observation Satellite
      Then - Actions
        Unit Group - Pick every unit in (Units in Terre <gen> matching ((Owner of (Matching unit)) Not equal to (Owner of (Triggering unit)))) and do (Deny shared vision of (Picked unit) to (Owner of (Triggering unit)))
        Game - Display to (Player group((Owner of (Triggering unit)))) for 10.00 seconds the text: Your observation sattelite has been destroyed. You no longer have vision of Earth.
      Else - Actions
satellite
  Events
    Unit - A unit Finishes training a unit
  Conditions
  Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Unit-type of (Trained unit)) Equal to Observation Satellite
      Then - Actions
        Set VariableSet satellite = (satellite + 1)
        Set VariableSet satelliteN[satellite] = (Trained unit)
        Unit Group - Pick every unit in (Units in Terre <gen>) and do (Grant shared vision of (Picked unit) to (Owner of (Triggering unit)))
        Game - Display to (All players) for 10.00 seconds the text: ((|cff0000ff + titre[(Player number of (Owner of (Triggering unit)))]) + |r has launched an observation satellite into orbit.)
        Sound - Play QuestLog <gen>
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Unit-type of (Trained unit)) Equal to Orbital AttackSatellite
      Then - Actions
        Set VariableSet satellite = (satellite + 1)
        Set VariableSet satelliteN[satellite] = (Trained unit)
      Else - Actions
finit build
  Events
    Unit - A unit Finishes construction
  Conditions
  Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        Or - Any (Conditions) are true
          Conditions
            (Unit-type of (Constructed structure)) Equal to Planetary Administration 1
            (Unit-type of (Constructed structure)) Equal to Planetary Capital 2
      Then - Actions
        Set VariableSet spawn_mob = (Position of (Constructed structure))
        Region - Center Spawn_Capital <gen> on spawn_mob
        Environment - Change terrain type at spawn_mob to Barrens - Rough Dirt using variation -1 in an area of size 6 and shape Square
        Environment - Change terrain type at spawn_mob to Barrens - Rough Dirt using variation -1 in an area of size 6 and shape Square
        Unit - Create 1.Dome for (Owner of (Triggering unit)) at spawn_mob facing Default building facing degrees
        Animation - Change (Last created unit)'s vertex coloring to (100%, 100%, 100%) with 30.00% transparency
        Custom script: call RemoveLocation(udg_spawn_mob)
        For each (Integer A) from 1 to 12000, do (Actions)
          Loop - Actions
            Set VariableSet build[(Integer A)] = (Random point in Spawn_Capital <gen>)
            Environment - Set terrain pathing at build[(Integer A)] of type Buildability to On
            Custom script: call RemoveLocation(udg_build[GetForLoopIndexA()])
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Point-value of (Constructed structure)) Equal to 83
        (Terre <gen> contains (Constructed structure)) Equal to False
      Then - Actions
        Unit - Remove Cut Trees from (Constructed structure)
        Unit - Remove Grew Trees from (Constructed structure)
      Else - Actions
//TESH.scrollpos=251
//TESH.alwaysfold=0
library AutoIndex
//===========================================================================
// Information:
//==============
//
//     AutoIndex is a very simple script to utilize. Just call GetUnitId(unit)
// to get get the unique value assigned to a particular unit. The GetUnitId
// function is extremely fast because it inlines directly to a GetUnitUserData
// call. AutoIndex automatically assigns an ID to each unit as it enters the
// map, and instantly frees that ID as the unit leaves the map. Detection of
// leaving units is accomplished in constant time without a periodic scan.
//
//     AutoIndex uses UnitUserData by default. If something else in your map
// would conflict with that, you can set the UseUnitUserData configuration
// constant to false, and a hashtable will be used instead. Note that hash-
// tables are about 60% slower.
//
//     If you turn on debug mode, AutoIndex will be able to display several
// helpful error messages. The following issues will be detected:
//   -Passing a removed or decayed unit to GetUnitId
//   -Code outside of AutoIndex has overwritten a unit's UserData value.
//   -GetUnitId was used on a filtered unit (a unit you don't want indexed).
//
//     AutoIndex provides events upon indexing or deindexing units. This
// effectively allows you to notice when units enter or leave the game. Also
// included are the AutoData, AutoCreate, and AutoDestroy modules, which allow
// you to fully utilize AutoIndex's enter/leave detection capabilities in
// conjunction with your structs.
//
//===========================================================================
// How to install AutoIndex:
//===========================
//
// 1.) Copy and paste this script into your map.
// 2.) Save it to allow the ObjectMerger macro to generate the "Leave Detect"
//     ability for you. Close and re-open the map. After that, disable the macro
//     to prevent the delay while saving.
//
//===========================================================================
// How to use AutoIndex:
//=======================
//
//     So you can get a unique integer for each unit, but how do you use that to
// attach data to a unit? GetUnitId will always return a number in the range of
// 1-8190. This means it can be used as an array index, as demonstrated below:
/*
    globals
        integer array IntegerData
        real array RealData
        SomeStruct array SomeStructData
    englobals

    function Example takes nothing returns nothing
        local unit u = CreateUnit(Player(0), 'hpea', 0., 0., 0.)
        local integer id = GetUnitId(u)
            //You now have a unique index for the unit, so you can
            //attach or retrieve data about the unit using arrays.
            set IntegerData[id] = 5
            set RealData[id] = 25.0
            set SomeStructData[id] = SomeStruct.create()
            //If you have access to the same unit in another function, you can
            //retrieve the data by using GetUnitId() and reading the arrays.
    endfunction
*/

//     The UnitFilter function in the configuration section is provided so that
// you can make AutoIndex completely ignore certain unit-types. Ignored units
// won't be indexed or fire indexed/deindexed events. You may want to filter out
// dummy casters or system-private units, especially ones that use UnitUserData
// internally. xe dummy units are automatically filtered.
//
//===========================================================================
// How to use OnUnitIndexed / OnUnitDeindexed:
//=============================================
//
//     AutoIndex will fire the OnUnitIndexed event when a unit enters the map,
// and the OnUnitDeindexed event when a unit leaves the map. Functions used
// as events must take a unit and return nothing. An example is given below:
/*
    function UnitEntersMap takes unit u returns nothing
        call BJDebugMsg(GetUnitName(u)+" with ID "+I2S(GetUnitId(u))+" entered the map.")
    endfunction //Using GetUnitId() during Indexed events works fine...

    function UnitLeavesMap takes unit u returns nothing
        call BJDebugMsg(GetUnitName(u)+" with ID "+I2S(GetUnitId(u))+" left the map.")
    endfunction  //So does using GetUnitId() during Deindexed events.

    function Init takes nothing returns nothing
        call OnUnitIndexed(UnitEntersMap)
        call OnUnitDeindexed(UnitLeavesMap)
    endfunction
*/

//     If you call OnUnitIndexed during map initialization, every existing
// unit will be considered as entering the map. This saves you from the need
// to manually enumerate preplaced units (or units created by initialization
// code that ran before OnUnitIndexed was called).
//
//     OnUnitDeindexed runs while a unit still exists, which means you can
// still do things such as destroy special effects attached to the unit.
// The unit will cease to exist immediately after the event is over.
//
//===========================================================================
// AutoIndex API:
//================
//
// GetUnitId(unit) -> integer
//   This function returns a unique ID in the range of 1-8190 for the
//   specified unit. Returns 0 if a null unit was passed. This function
//   inlines directly to GetUnitUserData or LoadInteger if debug mode
//   is disabled. If debug mode is enabled, this function will print
//   an error message when passed a decayed or filtered unit.
//
// IsUnitIndexed(unit) -> boolean
//   This function returns a boolean indicating whether the specified
//   unit has been indexed. The only time this will return false is
//   for units you have filtered using the UnitFilter function, or
//   for xe dummy units. You can use this function to easily detect
//   dummy units and avoid performing certain actions on them.
//
// OnUnitIndexed(IndexFunc)
//   This function accepts an IndexFunc, which must take a unit and
//   return nothing. The IndexFunc will be fired instantly whenever
//   a unit enters the map. You may use GetUnitId on the unit. When
//   you call this function during map initialization, every existing
//   unit will be considered as entering the map.
//
// OnUnitDeindexed(IndexFunc)
//   Same as above, but runs whenever a unit is leaving the map. When
//   this event runs, the unit still exists, but it will cease to exist
//   as soon as the event ends. You may use GetUnitId on the unit.
//
//===========================================================================
// How to use AutoData:
//======================
//
//     The AutoData module allows you to associate one or more instances
// of the implementing struct with units, as well as iterate through all
// of the instances associated with each unit.
//
//     This association is accomplished through the "me" instance member,
// which the module will place in the implementing struct. Whichever unit
// you assign to "me" becomes the owner of that instance. You may change
// ownership by reassigning "me" to another unit at any time, or you may
// make the instance unowned by assigning "me" to null.
//
//     AutoData implements the static method operator [] in your struct
// to allow you to access instances from their owning units. For example,
// you may type: local StructName s = StructName[u]. If u has been set
// to own an instance of StructName, s will be set to that instance.
//
//     So, what happens if you assign the same owning unit to multiple
// instances? You may use 2D array syntax to access instances assigned to
// the same unit: local StructName s = StructName[u][n], where u is the
// owning unit, and n is the index beginning with 0 for each unit. You
// can access the size of a unit's instance list (i.e. the number of
// instances belonging to the unit) by using the .size instance member.
/*
    struct Example
        implement AutoData
        static method create takes unit u returns Example
            local Example this = allocate()
                set me = u //Assigning the "me" member from AutoData.
            return this
        endmethod
    endstruct
    function Test takes nothing returns nothing
        local unit u = CreateUnit(Player(0), 'hpea', 0., 0., 0.)
        local Example e1 = Example.create(u)
        local Example e2 = Example.create(u)
        local Example e3 = Example.create(u)
        local Example e
            call BJDebugMsg(I2S(Example[u].size)) //Prints 3 because u owns e1, e2, and e3.
            set e = Example[u][GetRandomInt(0, Example[u].size - 1)] //Random instance belonging to u.
            set e = Example[u]  //This is the fastest way to iterate the instances belonging
            loop                //to a specific unit, starting with the first instance.
                exitwhen e == 0 //e will be assigned to 0 when no instances remain.
                call BJDebugMsg(I2S(e)) //Prints the values of e1, e2, e3.
                set e = e[e.index + 1] //"e.index" refers to the e's position in u's instance list.
            endloop                    //Thus, index + 1 is next, and index - 1 is previous.
    endfunction                        //This trick allows you to avoid a local counter.
*/

//   AutoData restrictions:
//   -You may not implement AutoData in any struct which has already
//    declared static or non-static method operator [].
//   -AutoData will conflict with anything named "me", "size", or
//    "index" in the implementing struct.
//   -AutoData may not be implemented in structs that extend array.
//   -You may not declare your own destroy method. (This restriction
//    can be dropped as soon as JassHelper supports module onDestroy).
//
//   AutoData information:
//   -You do not need to null the "me" member when destroying an
//    instance. That is done for you automatically during destroy().
//    (But if you use deallocate(), you must null "me" manually.)
//   -StructName[u] and StructName[u][0] refer to the same instance,
//    which is the first instance that was associated with unit u.
//   -StructName[u][StructName[u].size - 1] refers to the instance that
//    was most recently associated with unit u.
//   -Instances keep their relative order in the list when one is removed.
//
//===========================================================================
// How to use AutoCreate:
//=======================
//
//     The AutoCreate module allows you to automatically create instances
// of the implementing struct for units as they enter the game. AutoCreate
// automatically implements AutoData into your struct. Any time an instance
// is automatically created for a unit, that instance's "me" member will be
// assigned to the entering unit.
//
//   AutoCreate restrictions:
//   -All of the same restrictions as AutoData.
//   -If your struct's allocate() method takes parameters (i.e. the parent
//    type's create method takes parameters), you must declare a create
//    method and pass those extra parameters to allocate yourself.
//
//   AutoCreate information:
//   -You may optionally declare the createFilter method, which specifies
//    which units should recieve an instance as they enter the game. If
//    you do not declare it, all entering units will recieve an instance.
//   -You may optionally declare the onCreate method, which will run when
//    AutoCreate automatically creates an instance. (This is just a stand-
//    in until JassHelper supports the onCreate method.)
//   -You may declare your own create method, but it must take a single
//    unit parameter (the entering unit) if you do so.
/*
    struct Example
        private static method createFilter takes unit u returns boolean
            return GetUnitTypeId(u) == 'hfoo' //Created only for Footmen.
        endmethod
        private method onCreate takes nothing returns nothing
            call BJDebugMsg(GetUnitName(me)+" entered the game!")
        endmethod
        implement AutoCreate
    endstruct
*/

//===========================================================================
// How to use AutoDestroy:
//=========================
//
//     The AutoDestroy module allows you to automatically destroy instances
// of the implementing struct when their "me" unit leaves the game. AutoDestroy
// automatically implements AutoData into your struct. You must assign a unit
// to the "me" member of an instance for this module to have any effect.
//
//   AutoDestroy restrictions:
//   -All of the same restrictions as AutoData.
//
//   AutoDestroy information:
//   -If you also implement AutoCreate in the same struct, remember that it
//    assigns the "me" unit automatically. That means you can have fully
//    automatic creation and destruction.
/*
    struct Example
        static method create takes unit u returns Example
            local Example this = allocate()
                set me = u //You should assign a unit to "me",
            return this    //otherwise AutoDestroy does nothing.
        endmethod          //Not necessary if using AutoCreate.
        private method onDestroy takes nothing returns nothing
            call BJDebugMsg(GetUnitName(me)+" left the game!")
        endmethod
        implement AutoDestroy
    endstruct
*/

//===========================================================================
// Configuration:
//================

//! external ObjectMerger w3a Adef lvdt anam "Leave Detect" aart "" arac 0
//Save your map with this Object Merger call enabled, then close and reopen your
//map. Disable it by removing the exclamation to remove the delay while saving.

globals
    private constant integer LeaveDetectAbilityID = 'lvdt'
    //This rawcode must match the parameter after "Adef" in the
    //ObjectMerger macro above. You may change both if you want.
   
    private constant boolean UseUnitUserData = true
    //If this is set to true, UnitUserData will be used. You should only set
    //this to false if something else in your map already uses UnitUserData.
    //A hashtable will be used instead, but it is about 60% slower.
   
    private constant boolean SafeMode = true
    //This is set to true by default so that GetUnitId() will ALWAYS work.
    //If if this is set to false, GetUnitId() may fail to work in a very
    //rare circumstance: creating a unit that has a default-on autocast
    //ability, and using GetUnitId() on that unit as it enters the game,
    //within a trigger that detects any order. Set this to false for a
    //performance boost only if you think you can avoid this issue.
   
    private constant boolean AutoDataFastMode = true
    //If this is set to true, AutoData will utilize one hashtable per time
    //it is implemented. If this is set to false, all AutoDatas will share
    //a single hashtable, but iterating through the instances belonging to
    //a unit will become about 12.5% slower. Your map will break if you
    //use more than 255 hashtables simultaneously. Only set this to false
    //if you suspect you will run out of hashtable instances.
endglobals

private function UnitFilter takes unit u returns boolean
    local integer id = GetUnitTypeId(u)
   
    if id == 'smis' or id == 'lmis' or id == 'roct' or id == 'dumm' or id == 'dumt' then
        return false
    endif
   
    return true
endfunction
//Make this function return false for any unit-types you want to ignore.
//Ignored units won't be indexed or fire OnUnitIndexed/OnUnitDeindexed
//events. The unit parameter "u" to refers to the unit being filtered.
//Do not filter out xe dummy units; they are automatically filtered.

//===========================================================================
// AutoData / AutoCreate / AutoDestroy modules:
//==============================================

function interface AutoCreator takes unit u returns nothing
function interface AutoDestroyer takes unit u returns nothing

globals                
    hashtable AutoData = null //If AutoDataFastMode is disabled, this hashtable will be
endglobals                    //initialized and shared between all AutoData implementations.

module AutoData
    private static hashtable ht
    private static thistype array data
    private static integer array listsize
    private static key typeid //Good thing keys exist to identify each implementing struct.
    private unit meunit
    private integer id
   
    readonly integer index //The user can avoid using a local counter because this is accessable.
   
    static method operator [] takes unit u returns thistype
        return data[GetUnitId(u)]
    endmethod //This is as fast as retrieving an instance from a unit gets.
   
    method operator [] takes integer index returns thistype
        static if AutoDataFastMode then //If fast mode is enabled...
            return LoadInteger(ht, id, index)
        else //Each instance has its own hashtable to associate unit and index.
            return LoadInteger(AutoData, id, index*8190+typeid)
        endif //Otherwise, simulate a 3D array associating unit, struct-type ID, and index.
    endmethod //Somehow, this version is 12.5% slower just because of the math.
   
    private method setIndex takes integer index, thistype data returns nothing
        static if AutoDataFastMode then //Too bad you can't have a module-private operator []=.
            call SaveInteger(ht, id, index, data)
        else
            call SaveInteger(AutoData, id, index*8190+typeid, data)
        endif
    endmethod
   
    private method remove takes nothing returns nothing
        if meunit == null then //If the struct doesn't have an owner...
            return             //Nothing needs to be done.
        endif
        loop
            exitwhen index == listsize[id]        //The last value gets overwritten by 0.
            call setIndex(index, this[index + 1]) //Shift each element down by one.
            set this[index].index = index         //Update the shifted instance's index.
            set index = index + 1
        endloop
        set listsize[id] = listsize[id] - 1
        set data[id] = this[0] //Ensure thistype[u] returns the same value as thistype[u][0].
        set meunit = null
    endmethod
   
    private method add takes unit u returns nothing
        if meunit != null then     //If the struct has an owner...
            call remove()          //remove it first.
        endif
        set meunit = u
        set id = GetUnitId(u)      //Cache GetUnitId for slight performance boost.
        if data[id] == 0 then      //If this is the first instance for this unit...
            set data[id] = this    //Update the value that thistype[u] returns.
        endif
        set index = listsize[id]   //Remember the index for removal.
        call setIndex(index, this) //Add to the array.
        set listsize[id] = index + 1
    endmethod
   
    method operator me takes nothing returns unit
        return meunit
    endmethod
   
    method operator me= takes unit u returns nothing
        if u != null then //If assigning "me" a non-null value...
            call add(u)   //Add this instance to that unit's array.
        else              //If assigning "me" a null value...
            call remove() //Remove this instance from that unit's array.
        endif
    endmethod
   
    method operator size takes nothing returns integer
        return listsize[id]
    endmethod
   
    method destroy takes nothing returns nothing
        call deallocate()
        call remove() //This makes removal automatic when an instance is destroyed.
    endmethod
   
    private static method onInit takes nothing returns nothing
        static if AutoDataFastMode then        //If fast mode is enabled...
            set ht = InitHashtable()           //Initialize one hashtable per instance.
        else                                   //If fast mode is disabled...
            if AutoData == null then           //If the hashtable hasn't been initialized yet...
                set AutoData = InitHashtable() //Initialize the shared hashtable.
            endif
        endif
    endmethod
endmodule

module AutoCreate
    implement AutoData //AutoData is necessary for AutoCreate.

    private static method creator takes unit u returns nothing
        local thistype this
        local boolean b = true                          //Assume that the instance will be created.
            static if thistype.createFilter.exists then //If createFilter exists...
                set b = createFilter(u)                 //evaluate it and update b.
            endif
            if b then                                   //If the instance should be created...
                static if thistype.create.exists then   //If the create method exists...
                    set this = create(u)                //Create the instance, passing the entering unit.
                else                                    //If the create method doesn't exist...
                    set this = allocate()               //Just allocate the instance.
                endif
                set me = u                              //Assign the instance's owner as the entering unit.
                static if thistype.onCreate.exists then //If onCreate exists...
                    call onCreate()                     //Call it, because JassHelper should do this anyway.
                endif
            endif
    endmethod

    private static method onInit takes nothing returns nothing
        call AutoIndex.addAutoCreate(thistype.creator)
    endmethod //During module initialization, pass the creator function to AutoIndex.
endmodule

module AutoDestroy
    implement AutoData //AutoData is necessary for AutoDestroy.
   
    static method destroyer takes unit u returns nothing
        loop
            exitwhen thistype[u] == 0
            call thistype[u].destroy()
        endloop
    endmethod //Destroy each instance owned by the unit until none are left.

    private static method onInit takes nothing returns nothing
        call AutoIndex.addAutoDestroy(thistype.destroyer)
    endmethod //During module initialization, pass the destroyer function to AutoIndex.
endmodule

//===========================================================================
// AutoIndex struct:
//===================

function interface IndexFunc takes unit u returns nothing

hook RemoveUnit AutoIndex.hook_RemoveUnit
hook ReplaceUnitBJ AutoIndex.hook_ReplaceUnitBJ
debug hook SetUnitUserData AutoIndex.hook_SetUnitUserData

private keyword getIndex
private keyword getIndexDebug
private keyword isUnitIndexed
private keyword onUnitIndexed
private keyword onUnitDeindexed

struct AutoIndex
    private static trigger   enter      = CreateTrigger()
    private static trigger   order      = CreateTrigger()
    private static trigger   creepdeath = CreateTrigger()
    private static group     preplaced  = CreateGroup()
    private static timer     allowdecay = CreateTimer()
    private static hashtable ht

    private static boolean array dead
    private static boolean array summoned
    private static boolean array animated
    private static boolean array nodecay
    private static boolean array removing
   
    private static IndexFunc array indexfuncs
    private static integer indexfuncs_n = -1
    private static IndexFunc array deindexfuncs
    private static integer deindexfuncs_n = -1
    private static IndexFunc indexfunc
   
    private static AutoCreator array creators
    private static integer creators_n = -1
    private static AutoDestroyer array destroyers
    private static integer destroyers_n = -1
   
    private static unit array allowdecayunit
    private static integer allowdecay_n = -1
   
    private static boolean duringinit = true
    private static boolean array altered
    static unit array idunit
   
    //===========================================================================

    static method getIndex takes unit u returns integer
        static if UseUnitUserData then
            return GetUnitUserData(u)
        else
            return LoadInteger(ht, 0, GetHandleId(u))
        endif
    endmethod //Resolves to an inlinable one-liner after the static if.
   
    static method operator initialized takes nothing returns boolean
        return not thistype.duringinit
    endmethod
   
    static method getIndexDebug takes unit u returns integer
            if u == null then
                return 0
            elseif GetUnitTypeId(u) == 0 then
                call BJDebugMsg("AutoIndex error: Removed or decayed unit passed to GetUnitId.")
            elseif idunit[getIndex(u)] != u and GetIssuedOrderId() != 852056 then
                call BJDebugMsg("AutoIndex error: "+GetUnitName(u)+" is a filtered unit.")
            endif
        return getIndex(u)
    endmethod //If debug mode is enabled, use the getIndex method that shows errors.
   
    private static method setIndex takes unit u, integer index returns nothing
        static if UseUnitUserData then
            call SetUnitUserData(u, index)
        else
            call SaveInteger(ht, 0, GetHandleId(u), index)
        endif
    endmethod //Resolves to an inlinable one-liner after the static if.
   
    static method isUnitIndexed takes unit u returns boolean
        return u != null and idunit[getIndex(u)] == u
    endmethod
   
    static method isUnitAnimateDead takes unit u returns boolean
        return animated[getIndex(u)]
    endmethod //Don't use this; use IsUnitAnimateDead from AutoEvents instead.
   
    //===========================================================================
   
    private static method onUnitIndexed_sub takes nothing returns nothing
        call indexfunc.evaluate(GetEnumUnit())
    endmethod
    static method onUnitIndexed takes IndexFunc func returns nothing
        set indexfuncs_n = indexfuncs_n + 1
        set indexfuncs[indexfuncs_n] = func
        if duringinit then //During initialization, evaluate the indexfunc for every preplaced unit.
            set indexfunc = func
            call ForGroup(preplaced, function AutoIndex.onUnitIndexed_sub)
        endif
    endmethod
   
    static method onUnitDeindexed takes IndexFunc func returns nothing
        set deindexfuncs_n = deindexfuncs_n + 1
        set deindexfuncs[deindexfuncs_n] = func
    endmethod
   
    static method addAutoCreate takes AutoCreator func returns nothing
        set creators_n = creators_n + 1
        set creators[creators_n] = func
    endmethod
   
    static method addAutoDestroy takes AutoDestroyer func returns nothing
        set destroyers_n = destroyers_n + 1
        set destroyers[destroyers_n] = func
    endmethod
   
    //===========================================================================
   
    private static method hook_RemoveUnit takes unit whichUnit returns nothing
        set removing[getIndex(whichUnit)] = true
    endmethod //Intercepts whenever RemoveUnit is called and sets a flag.
    private static method hook_ReplaceUnitBJ takes unit whichUnit, integer newUnitId, integer unitStateMethod returns nothing
        set removing[getIndex(whichUnit)] = true
    endmethod //Intercepts whenever ReplaceUnitBJ is called and sets a flag.
   
    private static method hook_SetUnitUserData takes unit whichUnit, integer data returns nothing
        static if UseUnitUserData then
            if idunit[getIndex(whichUnit)] == whichUnit then
                if getIndex(whichUnit) == data then
                    call BJDebugMsg("AutoIndex error: Code outside AutoIndex attempted to alter "+GetUnitName(whichUnit)+"'s index.")
                else
                    call BJDebugMsg("AutoIndex error: Code outside AutoIndex altered "+GetUnitName(whichUnit)+"'s index.")
                    if idunit[data] != null then
                        call BJDebugMsg("AutoIndex error: "+GetUnitName(whichUnit)+" and "+GetUnitName(idunit[data])+" now have the same index.")
                    endif
                    set altered[data] = true
                endif
            endif
        endif //In debug mode, intercepts whenever SetUnitUserData is used on an indexed unit.
    endmethod //Displays an error message if outside code tries to alter a unit's index.
   
    //===========================================================================
   
    private static method allowDecay takes nothing returns nothing
        local integer n = allowdecay_n
            loop
                exitwhen n < 0
                set nodecay[getIndex(allowdecayunit[n])] = false
                set allowdecayunit[n] = null
                set n = n - 1
            endloop
            set allowdecay_n = -1
    endmethod //Iterate through all the units in the stack and allow them to decay again.
   
    private static method detectStatus takes nothing returns boolean
        local unit u = GetTriggerUnit()
        local integer index = getIndex(u)
        local integer n
           
            if idunit[index] == u then //Ignore non-indexed units.
                if not IsUnitType(u, UNIT_TYPE_DEAD) then
               
                    if dead[index] then         //The unit was dead, but now it's alive.
                        set dead[index] = false //The unit has been resurrected.
                        //! runtextmacro optional RunAutoEvent("Resurrect")
                        //If AutoEvents is in the map, run the resurrection events.
                       
                        if IsUnitType(u, UNIT_TYPE_SUMMONED) and not summoned[index] then
                            set summoned[index] = true //If the unit gained the summoned flag,
                            set animated[index] = true //it's been raised with Animate Dead.
                            //! runtextmacro optional RunAutoEvent("AnimateDead")
                            //If AutoEvents is in the map, run the Animate Dead events.
                        endif
                    endif
                else
               
                    if not removing[index] and not dead[index] and not animated[index] then
                        set dead[index] = true               //The unit was alive, but now it's dead.
                        set nodecay[index] = true            //A dead unit can't decay for at least 0. seconds.
                        set allowdecay_n = allowdecay_n + 1  //Add the unit to a stack. After the timer
                        set allowdecayunit[allowdecay_n] = u //expires, allow the unit to decay again.
                        call TimerStart(allowdecay, 0., false, function AutoIndex.allowDecay)
                        //! runtextmacro optional RunAutoEvent("Death")
                        //If AutoEvents is in the map, run the Death events.
                       
                    elseif removing[index] or (dead[index] and not nodecay[index]) or (not dead[index] and animated[index]) then
                        //If .nodecay was false and the unit is dead and was previously dead, the unit decayed.
                        //If .animated was true and the unit is dead, the unit died and exploded.
                        //If .removing was true, the unit is being removed or replaced.
                        set n = deindexfuncs_n
                        loop //Run the OnUnitDeindexed events.
                            exitwhen n < 0
                            call deindexfuncs[n].evaluate(u)
                            set n = n - 1
                        endloop
                        set n = destroyers_n
                        loop //Destroy AutoDestroy structs for the leaving unit.
                            exitwhen n < 0
                            call destroyers[n].evaluate(u)
                            set n = n - 1
                        endloop
                        call AutoIndex(index).destroy() //Free the index by destroying the AutoIndex struct.
                        set idunit[index] = null        //Null this unit reference to prevent a leak.
                    endif
                endif
            endif
        set u = null
        return false
    endmethod

    //===========================================================================
   
    private static method unitEntersMap takes unit u returns nothing
        local integer index
        local integer n = 0
            if getIndex(u) != 0 then
                return //Don't index a unit that already has an ID.
            endif
            static if LIBRARY_xebasic then
                if GetUnitTypeId(u) == XE_DUMMY_UNITID then
                    return //Don't index xe dummy units.
                endif
            endif
            if not UnitFilter(u) then
                return //Don't index units that fail the unit filter.
            endif
            set index = create()
            call setIndex(u, index) //Assign an index to the entering unit.
           
            call UnitAddAbility(u, LeaveDetectAbilityID)                 //Add the leave detect ability to the entering unit.
            call UnitMakeAbilityPermanent(u, true, LeaveDetectAbilityID) //Prevent it from disappearing on morph.
            set dead[index] = IsUnitType(u, UNIT_TYPE_DEAD)              //Reset all of the flags for the entering unit.
            set summoned[index] = IsUnitType(u, UNIT_TYPE_SUMMONED)      //Each of these flags are necessary to detect
            set animated[index] = false                                  //when a unit leaves the map.
            set nodecay[index] = false
            set removing[index] = false
            debug set altered[index] = false    //In debug mode, this flag tracks wheter a unit's index was altered.
            set idunit[index] = u               //Attach the unit that is supposed to have this index to the index.
           
            if duringinit then                  //If a unit enters the map during initialization...
                call GroupAddUnit(preplaced, u) //Add the unit to the preplaced units group. This ensures that
            endif                               //all units are noticed by OnUnitIndexed during initialization.
            loop //Create AutoCreate structs for the entering unit.
                exitwhen n > creators_n
                call creators[n].evaluate(u)
                set n = n + 1
            endloop
            set n = 0
            loop //Run the OnUnitIndexed events.
                exitwhen n > indexfuncs_n
                call indexfuncs[n].evaluate(u)
                set n = n + 1
            endloop
    endmethod
   
    private static method onIssuedOrder takes nothing returns boolean
            static if SafeMode then     //If SafeMode is enabled, perform this extra check.
                if getIndex(GetTriggerUnit()) == 0 then  //If the unit doesn't already have
                    call unitEntersMap(GetTriggerUnit()) //an index, then assign it one.
                endif
            endif
        return GetIssuedOrderId() == 852056 //If the order is Undefend, allow detectStatus to run.
    endmethod
   
    private static method initEnteringUnit takes nothing returns boolean
            call unitEntersMap(GetFilterUnit())
        return false
    endmethod
   
    //===========================================================================
   
    private static method afterInit takes nothing returns nothing
        set duringinit = false               //Initialization is over; set a flag.
        call DestroyTimer(GetExpiredTimer()) //Destroy the timer.
        call GroupClear(preplaced)           //The preplaced units group is
        call DestroyGroup(preplaced)         //no longer needed, so clean it.
        set preplaced = null
    endmethod
   
    private static method onInit takes nothing returns nothing
        local region maparea = CreateRegion()
        local rect bounds = GetWorldBounds()
        local group g = CreateGroup()
        local integer i = 15
            static if not UseUnitUserData then
                set ht = InitHashtable() //Only create a hashtable if it will be used.
            endif
            loop
                exitwhen i < 0
                call SetPlayerAbilityAvailable(Player(i), LeaveDetectAbilityID, false)
                //Make the LeaveDetect ability unavailable so that it doesn't show up on the command card of every unit.
                call TriggerRegisterPlayerUnitEvent(order, Player(i), EVENT_PLAYER_UNIT_ISSUED_ORDER, null)
                //Register the "EVENT_PLAYER_UNIT_ISSUED_ORDER" event for each player.
                call GroupEnumUnitsOfPlayer(g, Player(i), function AutoIndex.initEnteringUnit)
                //Enum every non-filtered unit on the map during initialization and assign it a unique
                //index. By using GroupEnumUnitsOfPlayer, even units with Locust can be detected.
                set i = i - 1
            endloop
            call TriggerAddCondition(order, And(function AutoIndex.onIssuedOrder, function AutoIndex.detectStatus))
            //The detectStatus method will fire every time a non-filtered unit recieves an undefend order.
            //And() is used here to avoid using a trigger action, which starts a new thread and is slower.
            call TriggerRegisterPlayerUnitEvent(creepdeath, Player(12), EVENT_PLAYER_UNIT_DEATH, null)
            call TriggerAddCondition(creepdeath, function AutoIndex.detectStatus)
            //The detectStatus method must also fire when a neutral hostile creep dies, in case it was
            //sleeping. Sleeping creeps don't fire undefend orders on non-damaging deaths.
            call RegionAddRect(maparea, bounds) //GetWorldBounds() includes the shaded boundry areas.
            call TriggerRegisterEnterRegion(enter, maparea, function AutoIndex.initEnteringUnit)
            //The filter function of an EnterRegion trigger runs instantly when a unit is created.
            call TimerStart(CreateTimer(), 0., false, function AutoIndex.afterInit)
            //After any time elapses, perform after-initialization actions.
        call GroupClear(g)
        call DestroyGroup(g)
        call RemoveRect(bounds)
        set g = null
        set bounds = null
    endmethod
   
endstruct

//===========================================================================
// User functions:
//=================

function GetUnitId takes unit u returns integer
    static if DEBUG_MODE then             //If debug mode is enabled...
        return AutoIndex.getIndexDebug(u) //call the debug version of GetUnitId.
    else                                  //If debug mode is disabled...
        return AutoIndex.getIndex(u)      //call the normal, inlinable version.
    endif
endfunction

function GetUnitById takes integer id returns unit
    return AutoIndex.idunit[id]
endfunction

function IsUnitIndexed takes unit u returns boolean
    return AutoIndex.isUnitIndexed(u)
endfunction

function OnUnitIndexed takes IndexFunc func returns nothing
    call AutoIndex.onUnitIndexed(func)
endfunction

function OnUnitDeindexed takes IndexFunc func returns nothing
    call AutoIndex.onUnitDeindexed(func)
endfunction

endlibrary
 
//TESH.scrollpos=0
//TESH.alwaysfold=0
library ListModule
//===========================================================================
// Information:
//==============
//
//     This library provides the List module, which allows you to easily create
// a linked list of all of the allocated instances of a struct-type. Iterating
// through a linked list is about 12% faster than iteratating through an array
// in JASS. There is no faster method to iterate through a list of structs than
// the method used by this module. Aside from the marginal speed gain, the best
// use of this library is to hide some ugly low-level code from your structs.
// Rather than manually building and maintaining a list of struct instances,
// just implement the List module, and your code will become much prettier.
//
//===========================================================================
// How to use the List module:
//=============================
//
//     Using the List module is pretty simple. First, implement it in your
// struct (preferably at the top to avoid unnecessary TriggerEvaluate calls).
// In the struct's create method, you must call listAdd(). In the onDestroy
// method, you must also call listRemove(). An example is shown below:
/*
    struct Example
        implement List
       
        static method create takes nothing returns Example
            local Example this = allocate()
                call listAdd() //This method adds the instance to the list.
            return this
        endmethod
       
        method onDestroy takes nothing returns nothing
            call listRemove() //This method removes the instance from the list.
        endmethod
    endstruct
*/

//     The requirement to call listAdd() and listRemove() will be done away
// with once JassHelper supports module onDestroy and module onCreate, but
// for now, it is not too much of a burden.
//
//     Once this is done, your struct will gain all of the methods detailed
// in the API section. Below is an example of how to iterate through the list
// of allocated structs of the implementing struct-type:
/*
    function IterationExample takes nothing returns nothing
        local Example e = Example.first
            loop
                exitwhen e == 0
                //Do something with e here.
                set e = e.next
            endloop
        //Use .last and .prev instead to iterate backwards.
    endmethod
*/

//
//===========================================================================
// List module API:
//==================
//
// (readonly)(static) first -> thistype
//   This member contains the first instance of thistype in the list.
//
// (readonly)(static) last -> thistype
//   This member contains the last instance of thistype in the list.
//
// (readonly)(static) count -> integer
//   This member contains the number of allocated structs of thistype.
//
// (readonly) next -> thistype
//   This member contains the next instance of thistype in the list.
//
// (readonly) prev -> thistype
//   This member contains the previous instance of thistype in the list.
//
// listAdd()
//   This method adds this instance to the list of structs of thistype.
//   This should be called on each instance after it is allocated (within
//   the create method).
//
// listRemove()
//   This method removes this instance from the list of structs of thistype.
//   This should be called on each instance before it is destroyed (within
//   the onDestroy method).
//
// (static) listDestroy()
//   This method destroys all the structs of thistype within the list.
//
//===========================================================================

module List
    private static boolean destroying = false
    private boolean inlist = false
   
    readonly static integer count = 0
   
    readonly thistype next = 0
    readonly thistype prev = 0
   
    static method operator first takes nothing returns thistype
        return thistype(0).next
    endmethod
   
    static method operator last takes nothing returns thistype
        return thistype(0).prev
    endmethod
   
    method listRemove takes nothing returns nothing
        if not inlist then
            return
        endif
        set inlist = false
        set prev.next = next
        set next.prev = prev
        set count = count - 1
    endmethod

    method listAdd takes nothing returns nothing
        if inlist or destroying then
            return
        endif
        set inlist = true
        set last.next = this
        set prev = last
        set thistype(0).prev = this
        set count = count + 1
    endmethod
   
    static method listDestroy takes nothing returns nothing
        local thistype this = last
            set destroying = true
            loop
                exitwhen this == 0
                call destroy()
                set this = prev
            endloop
            set destroying = false
    endmethod
   
endmodule

endlibrary
//TESH.scrollpos=39
//TESH.alwaysfold=0
library mAirplanes requires ListModule, AutoIndex

    /*
       .~@ FINGOLFINS AIRPLANE MOVEMENT SYSTEM @~.
   
        INSTRUCTIONS:
            - Implement AutoIndex as specified in its description
            - Create your airplane units as you would with any normal unit
            - Set the turn speed of your airplanes to something below 0.1 (use shift-click)
            - Register plane types by adding this line to the initPlaneTypes function:
           
              call registerPlaneType('xxxx')
             
              where 'xxxx' is the id of your airplane.
    */

   
    //=======================//
    //======= GLOBALS =======//
    //=======================//

    globals
        private constant real INTERVAL          = 0.03125 //I SUBMIT TO THIS FOLLY
        private constant real DEFAULT_FACING    = 270
       
        //LOWER NUMBERS = LESS INERTIA. SET TO ZERO TO REMOVE INERTIA COMPLETELY. THIS VALUE MUST BE LOWER THAN 1!
        private constant real AIR_FRICTION      = 0.93
       
        //A CONSTANT MULTIPILER TO THE UNIT SPEED, TO CIRCUMVENT THE HARDCODED SPEED LIMIT OF WC3.
        private constant real SPEED_FACTOR      = 1.6
       
        //MAP BOUNDS
        private real MAP_MAX_X
        private real MAP_MAX_Y
        private real MAP_MIN_X
        private real MAP_MIN_Y
       
        //HAVING A UNIQUE ID MIGHT BE USEFUL IF YOU WANT TO USE YOUR OWN, EXISTING HASHTABLE.
        private constant integer SYSTEM_ID      = StringHash("Airplanes")
       
        private hashtable Hash                  = InitHashtable()
    endglobals
   
    native UnitAlive takes unit id returns boolean
   
    //=======================//
    //===== SYSTEM CODE =====//
    //=======================//
   
    private function RegisterPlaneType takes integer unitid returns nothing
        call SaveInteger(Hash, SYSTEM_ID, unitid, 1)
    endfunction
   
    private function IsUnitPlane takes unit whichunit returns boolean
        return HaveSavedInteger(Hash, SYSTEM_ID, GetUnitTypeId(whichunit))
    endfunction
   
    private function InitPlaneTypes takes nothing returns nothing
        //REGISTER YOUR PLANE TYPES LIKE THIS
        call RegisterPlaneType('h01F')
        call RegisterPlaneType('h01J')
        call RegisterPlaneType('h01H')
        call RegisterPlaneType('h02B')
        call RegisterPlaneType('h01N')
        call RegisterPlaneType('h01E')
        call RegisterPlaneType('h02F')
        call RegisterPlaneType('h02D')
        call RegisterPlaneType('h02C')
    endfunction
   
    struct Plane
   
        implement List
   
        unit plane      = null
        unit target     = null
       
        real vx         = 0
        real vy         = 0
       
        real tx         = 0
        real ty         = 0
       
        real speed      = 0
       
        integer order   = 0
        integer index   = 0
       
        private static timer t1
        private static timer t2
       
        private static thistype array planes
       
        static method get takes unit whichunit returns thistype
            return .planes[GetUnitId(whichunit)]
        endmethod
       
        method onDestroy takes nothing returns nothing
            //DON'T GIVE ME CRAP ABOUT USING onDestroy(), IT POSES NO PERFORMANCE ISSUE IN THIS CASE.
            call .listRemove()
            //SAVING THE INDEX IS UGLY, BUT THE UNIT HAS ALREADY BEEN DEINDEXED AT THIS POINT.
            set .planes[.index] = 0
           
            if .count == 0 then
                call PauseTimer(.t1)
                call PauseTimer(.t2)
            endif
        endmethod
       
        private static method updateOrder takes nothing returns nothing
            local thistype this = .first
            local thistype temp
            local real x
            local real y
           
            if .count == 0 then
                call PauseTimer(.t1)
                call PauseTimer(.t2)
            endif
           
            loop
                exitwhen this == 0
                set temp = .next
               
                if GetUnitTypeId(.plane) == 0 then
                    //DESTROY THE STRUCT WHEN THE PLANE NO LONGER EXISTS
                    call .destroy()
                else
                    if .target != null then
                        if UnitAlive(.target) == false or GetUnitTypeId(.target) == 0 then
                            set .target = null
                            set .tx = GetUnitX(.plane)
                            set .ty = GetUnitY(.plane)
                            set .order = OrderId("attack")
                        else
                            call IssueTargetOrderById(.plane, .order, .target)
                        endif
                    else
                        if .order == OrderId("move") or .order == OrderId("smart") then
                            set x = GetUnitX(.plane)
                            set y = GetUnitY(.plane)
                            if (x - .tx)*(x - .tx) + (y - .ty)*(y - .ty) < 10000 then
                                //ALLOW THE UNIT TO ATTACK ONCE IT HAS REACHED ITS DESTINATION
                                set .order = OrderId("attack")
                            endif
                        endif
                       
                       
                        call IssuePointOrderById(.plane, .order, .tx, .ty)
                    endif
                endif
               
                set this = temp
            endloop
        endmethod
       
        private static method updatePosition takes nothing returns nothing
            local thistype this = .first
            local real x         = 0
            local real y         = 0
            local real f         = 0
           
            loop
                exitwhen this == 0  
               
                set f = GetUnitFacing(.plane)*bj_DEGTORAD
               
                //ADD FRICTION FIRST INCASE IT IS ZEROED
                set .vx = (.vx * AIR_FRICTION) + .speed * Cos(f)
                set .vy = (.vy * AIR_FRICTION) + .speed * Sin(f)
               
                set x = GetUnitX(.plane)+.vx
                set y = GetUnitY(.plane)+.vy
               
                //ENFORCE BOUNDS
               
                if x > MAP_MAX_X then
                    set x = MAP_MAX_X
                elseif x < MAP_MIN_X then
                    set x = MAP_MIN_X
                endif
               
                if y > MAP_MAX_Y then
                    set y = MAP_MAX_Y
                elseif y < MAP_MIN_Y then
                    set y = MAP_MIN_Y
                endif
               
                call SetUnitX(.plane, x)
                call SetUnitY(.plane, y)
               
                set this = .next
            endloop
        endmethod
       
        private static method onOrderTarget takes nothing returns boolean
            local thistype this = thistype.get(GetTriggerUnit())
           
            if this == 0 then
                return false
            endif
           
            set .target = GetOrderTargetUnit()
            set .tx = GetUnitX(.target)
            set .ty = GetUnitY(.target)
            set .order = GetIssuedOrderId()
           
            return false
        endmethod
       
        private static method onOrderPoint takes nothing returns boolean
            local real x = GetOrderPointX()
            local real y = GetOrderPointY()
            local thistype this = thistype.get(GetTriggerUnit())
           
            if this == 0 then
                return false
            endif
           
            set .tx = x
            set .ty = y
            set .target = null
            set .order = GetIssuedOrderId()
           
            return false
        endmethod
       
        static method create takes unit whichunit returns thistype
            local thistype this = thistype.allocate()
           
            call .listAdd()
           
           
            set .planes[GetUnitId(whichunit)] = this
           
           
            //=========SOME MATH TRIVIA!=========//
            //The acceleration is given by the following differential equation:
            // v(t)' = a = v(t) - v(t)*(1-R), where R = AIR_FRICTION
            //And it's solution:
            //v(t) = (a/(1-R)*(1 + e^-(1-R)t)
            //Calculating the limit when (t -> infinity) gives:
            //vmax = a/(1-R)
            //vmax*(1-R) = a (in this case 'vmax' is known and 'a' is unknown)
            //===========END OF TRIVIA===========//
           
            set .plane = whichunit
            set .speed = GetUnitDefaultMoveSpeed(.plane)*(1-AIR_FRICTION)*INTERVAL*SPEED_FACTOR
           
           
            set .tx = GetUnitX(.plane) + 500 * Cos(DEFAULT_FACING*bj_DEGTORAD)
            set .ty = GetUnitY(.plane) + 500 * Sin(DEFAULT_FACING*bj_DEGTORAD)
            set .order = OrderId("move")
            set .index = GetUnitId(whichunit)
           
            call SetUnitMoveSpeed(.plane, 0.01)
            call SetUnitFacing(.plane, DEFAULT_FACING)
            call SetUnitFlyHeight(.plane, 0, 0)
            call SetUnitFlyHeight(.plane, GetUnitDefaultFlyHeight(.plane), GetUnitDefaultFlyHeight(.plane)/3)
           
            if .count == 1 then
                call TimerStart(.t1, INTERVAL, true, function thistype.updatePosition)
                call TimerStart(.t2, 1, true, function thistype.updateOrder)
            endif
            return this
        endmethod
       
        private static method onIndex takes unit u returns nothing
            if IsUnitPlane(u) then
                call .create(u)
            endif
        endmethod
       
        private static method onInit takes nothing returns nothing
            local trigger t = CreateTrigger()
            local integer i = 0
            local rect r = GetWorldBounds()
           
            set MAP_MAX_X = GetRectMaxX(r)-200
            set MAP_MAX_Y = GetRectMaxY(r)-200
            set MAP_MIN_X = GetRectMinX(r)+200
            set MAP_MIN_Y = GetRectMinY(r)+200
           
            set Plane.t1 = CreateTimer()
            set Plane.t2 = CreateTimer()
           
            call InitPlaneTypes()
           
            loop
                exitwhen i > 11
                call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER, null)
                set i = i+1
            endloop
            call TriggerAddCondition(t, Condition(function Plane.onOrderTarget))
           
            set t = CreateTrigger()
            set i = 0
           
            loop
                exitwhen i > 11
                call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, null)
                set i = i+1
            endloop
            call TriggerAddCondition(t, Condition(function Plane.onOrderPoint))
           
            call OnUnitIndexed(thistype.onIndex)
            call RemoveRect(r)
            set r = null
            set t = null
        endmethod
   
    endstruct

endlibrary
avion2
  Events
    Unit - A unit Starts the effect of an ability
  Conditions
  Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Ability being cast) Equal to Avion 1
      Then - Actions
        Set VariableSet spawn_mob = (Position of (Triggering unit))
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            (Terrain pathing at spawn_mob of type Floatability is off) Equal to True
          Then - Actions
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                (Unit-type of (Triggering unit)) Equal to Bristol F2 2 1
              Then - Actions
                Unit - Replace (Triggering unit) with a Bristol F2 2 1bis using The old unit's relative life and mana
                Animation - Change (Last replaced unit) flying height to 0.00 at 50.00
                Selection - Select (Last replaced unit) for (Owner of (Triggering unit))
              Else - Actions
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                (Unit-type of (Triggering unit)) Equal to B-2 Spirit 1 3
              Then - Actions
                Unit - Replace (Triggering unit) with a B-2 Spirit 1 3bis using The old unit's relative life and mana
                Animation - Change (Last replaced unit) flying height to 450.00 at 200.00
                Selection - Select (Last replaced unit) for (Owner of (Triggering unit))
              Else - Actions
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                (Unit-type of (Triggering unit)) Equal to B17 Flying Fortress 1 2
              Then - Actions
                Unit - Replace (Triggering unit) with a B17 Flying Fortress 1 2bis using The old unit's relative life and mana
                Animation - Change (Last replaced unit) flying height to 450.00 at 200.00
                Selection - Select (Last replaced unit) for (Owner of (Triggering unit))
              Else - Actions
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                (Unit-type of (Triggering unit)) Equal to Convair YB-100 1 5
              Then - Actions
                Unit - Replace (Triggering unit) with a Convair YB-100 1 5bis using The old unit's relative life and mana
                Animation - Change (Last replaced unit) flying height to 450.00 at 200.00
                Selection - Select (Last replaced unit) for (Owner of (Triggering unit))
              Else - Actions
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                (Unit-type of (Triggering unit)) Equal to F-65 Lightning III 2 4
              Then - Actions
                Unit - Replace (Triggering unit) with a F-65 Lightning III 2 4bis using The old unit's relative life and mana
                Animation - Change (Last replaced unit) flying height to 450.00 at 200.00
                Selection - Select (Last replaced unit) for (Owner of (Triggering unit))
              Else - Actions
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                (Unit-type of (Triggering unit)) Equal to F/A-22 Raptor 2 3
              Then - Actions
                Unit - Replace (Triggering unit) with a F/A-22 Raptor 2 3bis using The old unit's relative life and mana
                Animation - Change (Last replaced unit) flying height to 450.00 at 200.00
                Selection - Select (Last replaced unit) for (Owner of (Triggering unit))
              Else - Actions
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                (Unit-type of (Triggering unit)) Equal to Lockheed SR-101 Obama 1 4
              Then - Actions
                Unit - Replace (Triggering unit) with a Lockheed SR-101 Obama 1 4bis using The old unit's relative life and mana
                Animation - Change (Last replaced unit) flying height to 450.00 at 200.00
                Selection - Select (Last replaced unit) for (Owner of (Triggering unit))
              Else - Actions
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                (Unit-type of (Triggering unit)) Equal to P51 Mustang 2 2
              Then - Actions
                Unit - Replace (Triggering unit) with a P51 Mustang 2 2bis using The old unit's relative life and mana
                Animation - Change (Last replaced unit) flying height to 450.00 at 200.00
                Selection - Select (Last replaced unit) for (Owner of (Triggering unit))
              Else - Actions
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                (Unit-type of (Triggering unit)) Equal to XV-105 Stingray 2 5
              Then - Actions
                Unit - Replace (Triggering unit) with a XV-105 Stingray 2 5bis using The old unit's relative life and mana
                Animation - Change (Last replaced unit) flying height to 450.00 at 200.00
                Selection - Select (Last replaced unit) for (Owner of (Triggering unit))
              Else - Actions
          Else - Actions
            Game - Display to (Player group((Owner of (Triggering unit)))) for 4.00 seconds the text: |cffffcc00You can't land on water.
        Custom script: call RemoveLocation(udg_spawn_mob)
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Ability being cast) Equal to Avion 2
      Then - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            (Unit-type of (Triggering unit)) Equal to Bristol F2 2 1bis
          Then - Actions
            Unit - Replace (Triggering unit) with a Bristol F2 2 1 using The old unit's relative life and mana
            Selection - Select (Last replaced unit) for (Owner of (Triggering unit))
            Animation - Change (Last replaced unit) flying height to 450.00 at 100.00
          Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            (Unit-type of (Triggering unit)) Equal to B-2 Spirit 1 3bis
          Then - Actions
            Unit - Replace (Triggering unit) with a B-2 Spirit 1 3 using The old unit's relative life and mana
            Selection - Select (Last replaced unit) for (Owner of (Triggering unit))
            Animation - Change (Last replaced unit) flying height to 450.00 at 100.00
          Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            (Unit-type of (Triggering unit)) Equal to B17 Flying Fortress 1 2bis