Name | Type | is_array | initial_value |
BE_angle | real | Yes | |
BE_array | integer | No | |
BE_array2 | integer | No | |
BE_caster | unit | Yes | |
BE_distance | real | Yes | |
BE_dummy | unit | Yes | |
BE_group | group | Yes | |
BE_height | real | Yes | |
BE_integer | integer | No | |
BE_MAX | integer | Yes | |
BE_move | location | Yes | |
BE_point1 | location | Yes | |
BE_speed | integer | Yes | |
BE_target | location | Yes | |
BladestormGroup | group | No | |
BladestormPoint | location | No | |
BladestormSfx | effect | No | |
bounces | integer | Yes | |
bounces_ran | integer | Yes | |
Builder_timer | timer | No | |
cast_angle | real | Yes | |
Caster | unit | No | |
ColorString | string | Yes | EmptyString |
Creep_Item_Point | location | No | |
CreepSpawn | rect | Yes | RectNull |
damage | integer | Yes | |
damage1 | integer | Yes | |
DamageEvent | real | No | |
DamageEventAmount | real | No | |
DamageEventSource | unit | No | |
DamageEventTarget | unit | No | |
DamageTestGroup | force | No | |
Difficulty | integer | No | |
DifficultyButtons | button | Yes | |
DifficultyDialog | dialog | No | |
DPS_CurrentDPS | real | Yes | |
DPS_CurrentDPSStr | string | Yes | |
DPS_FormatSuffix | string | Yes | |
DPS_IsOn | boolean | No | |
DPS_TotalDamage | real | Yes | |
DPS_TotalDamageStr | string | Yes | |
Empyrean_Nova_Caster | unit | No | |
Empyrean_Nova_DMG | real | No | |
Empyrean_Nova_Group | group | No | |
Empyrean_Nova_Targetpoint | location | No | |
first_integer | integer | No | |
firstlevel | timer | No | |
Formula | integer | Yes | |
Gold | integer | Yes | |
GST_ChildKey | integer | No | -1 |
GST_Integer1 | integer | No | |
GST_Integer2 | integer | No | |
GST_Integer3 | integer | No | |
GST_ParentKey | integer | No | -1 |
GST_Real1 | real | No | |
GST_Real2 | real | No | |
GST_Trigger | trigger | No | |
GST_Unit1 | unit | No | |
GST_Unit2 | unit | No | |
Integer | integer | No | |
Integer2 | integer | No | 25 |
IsUnitPreplaced | boolean | Yes | |
ItemDropChance | integer | No | |
ItemDropChance_boss | integer | No | |
ItemType | itemcode | Yes | |
ItemType_boss | itemcode | Yes | |
Kill_Count | integer | Yes | |
Kill_Counter | integer | Yes | |
Kill_CV | integer | No | |
Kill_Player | player | No | |
Kill_String | string | No | |
Kill_Unit | unit | No | |
Kills | integer | Yes | |
List | integer | No | |
Lives | integer | Yes | 32 |
Loc | location | No | |
loc | location | Yes | |
loop_off | boolean | Yes | |
Lumber | integer | Yes | |
Moneytowerincome | integer | Yes | 1 |
Multiboard | multiboard | No | |
Multiboard_Copy | multiboard | No | |
Multiboard_Difficulty_Row | integer | No | |
Multiboard_Health_Row | integer | No | |
Multiboard_List | integer | No | |
Multiboard_PG | force | No | |
Multiboard_Player | player | No | |
Multiboard_Player_Count | integer | No | |
Multiboard_Player_Row | integer | Yes | |
Multiboard_PN | integer | No | |
Multiboard_Spots | integer | Yes | |
NextSpawnTimer | timer | No | |
Nextwave | integer | No | |
P | player | No | |
Player_Color | string | Yes | |
Player_Colors | string | Yes | |
Player_Group_Self | force | Yes | |
Player_Name_New | string | Yes | |
Player_Name_Old | string | Yes | |
Player_Total_Kills | integer | Yes | |
Player_Won_Game | boolean | Yes | |
PlayerCreepSpawn | rect | Yes | |
PlayerPointzone | location | No | |
Players | force | No | |
PlayersActive | force | No | |
PlayerZone | rect | Yes | RectNull |
PlayerZoneVisibility | fogmodifier | Yes | |
PN | integer | No | |
point | location | No | |
PointCurrent | location | No | |
PR | integer | No | |
PR_Angle | real | Yes | |
PR_CastNumber | integer | No | |
PR_Damage | real | Yes | |
PR_Distance | real | Yes | |
PR_Dummie | unit | Yes | |
PR_Effect1 | unit | Yes | |
PR_Effect2 | unit | Yes | |
PR_Effect3 | unit | Yes | |
PR_Group | group | Yes | |
PR_Height | real | Yes | |
PR_Off | boolean | Yes | |
PR_Point | location | Yes | |
PR_Switch | integer | No | |
Random | integer | No | 23 |
Row_Count | integer | No | |
Selected_Unit | unit | Yes | |
Sell_Value | integer | No | |
set_temp_index | integer | No | |
SoF_Ability | abilcode | No | |
SoF_Animation | string | No | |
SoF_Animation2 | string | No | |
SoF_Caster | unit | Yes | |
SoF_DummyAbility | abilcode | No | |
SoF_DummyCaster | unit | Yes | |
SoF_DummyTypeA | unitcode | No | |
SoF_DummyTypeB | unitcode | No | |
SoF_Duration | real | Yes | |
SoF_Duration_Real | real | Yes | |
SoF_Level | integer | Yes | |
SoF_Loop | real | No | |
SoF_Player | player | Yes | |
SoF_SFXCreated | effect | Yes | |
SoF_SpecialEffect | string | No | |
SoF_SpecialEffect2 | string | No | |
SoF_SpinSpeed | real | No | |
SoF_Spirit | unit | Yes | |
SoF_SpiritAngle | real | Yes | |
SoF_SpiritDuration | real | No | |
SoF_TempInt | integer | No | |
SoF_TempLoc | location | No | |
SoF_TempLoc2 | location | No | |
SoF_TempLoc3 | location | No | |
SoF_X | integer | No | |
SoF_Y | integer | No | |
SoF_Y_Index | integer | Yes | |
SoF_Y_maxSize | integer | No | |
Special_Effect_1 | effect | No | |
Temp_Real | real | No | |
TempForce | force | No | |
TempGroup | group | No | |
TempPoint | location | No | |
Timer | integer | No | |
UDex | integer | No | |
UDexGen | integer | No | |
UDexNext | integer | Yes | |
UDexPrev | integer | Yes | |
UDexRecycle | integer | No | |
UDexUnits | unit | Yes | |
UDexWasted | integer | No | |
UnitIndexerEnabled | boolean | No | |
UnitIndexEvent | real | No | |
UntitledVariable001 | location | No | |
UntitledVariable002 | location | No | |
UntitledVariable003 | location | No | |
Wave | integer | Yes | 0 |
WaveAmount | integer | Yes | 20 |
WaveSound | sound | Yes | |
WaveText | string | Yes | |
WaveUnit | unitcode | Yes | |
WaveUnitsToSpawn | integer | Yes | |
Waypoints | group | Yes | |
Zone | rect | Yes | RectNull |
ZoneEnd | unit | Yes |
function GetPlayerDamageStrings takes player p returns nothing
local integer scoreIndex = 0
local real currentValue = 0.0
local integer pn = GetConvertedPlayerId(p)
// Current DPS:
set currentValue = udg_DPS_CurrentDPS[pn]
set scoreIndex = 0
loop
exitwhen currentValue < 1000 or scoreIndex == 4
set scoreIndex = scoreIndex + 1
set currentValue = currentValue / 1000
endloop
set udg_DPS_CurrentDPSStr[pn] = R2SW(currentValue,3,2) + udg_DPS_FormatSuffix[scoreIndex]
// Total Damage (Individual):
set currentValue = udg_DPS_TotalDamage[pn]
set scoreIndex = 0
loop
exitwhen currentValue < 1000 or scoreIndex == 4
set scoreIndex = scoreIndex + 1
set currentValue = currentValue / 1000
endloop
set udg_DPS_TotalDamageStr[pn] = R2SW(currentValue,3,2) + udg_DPS_FormatSuffix[scoreIndex]
endfunction
globals
hashtable GST_Hash = InitHashtable()
timer GST_LoadedTimer
integer GST_NewParentKey = 0
integer GST_Index = 0
endglobals
// Used to destroy and clean up an expired repeating timer.
// The user must manually call this function:
function GST_DestroyTimer takes nothing returns nothing
local timer t = GetExpiredTimer()
call FlushChildHashtable(GST_Hash, GetHandleId(t))
call PauseTimer(t)
call DestroyTimer(t)
set t = null
endfunction
// Used with the Key system to "restart" a timer.
// It destroys the previously created timer (if one is found).
// Then the new timer that was just created replaces it.
function GST_RestartTimer takes nothing returns nothing
set GST_NewParentKey = (-1000000000 + (100000 * LoadInteger(GST_Hash, -1, GetHandleId(udg_GST_Trigger))))
if (GST_NewParentKey != -1000000000) then
// key already exists
set GST_NewParentKey = GST_NewParentKey + udg_GST_ParentKey
else
// key doesn't exist, initialize it
set GST_Index = GST_Index + 1
set GST_NewParentKey = (-1000000000 + (100000 * GST_Index)) + udg_GST_ParentKey
call SaveInteger(GST_Hash, -1, GetHandleId(udg_GST_Trigger), GST_Index)
endif
set GST_LoadedTimer = LoadTimerHandle(GST_Hash, GST_NewParentKey, udg_GST_ChildKey)
// remove the old timer stored at these keys
if (GST_LoadedTimer != null) then
call PauseTimer(GST_LoadedTimer)
call DestroyTimer(GST_LoadedTimer)
call RemoveSavedInteger(GST_Hash, GST_NewParentKey, udg_GST_ChildKey)
endif
endfunction
// Callback functions which run when a timer expires:
function GST_Int_Expire takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetHandleId(t)
local trigger trig = LoadTriggerHandle(GST_Hash, id, 2)
local boolean repeating = LoadBoolean(GST_Hash, id, 1)
set udg_GST_Integer1 = LoadInteger(GST_Hash, id, 0)
// run the GUI trigger
call TriggerExecute(trig)
// the timer is not repeating so destroy it
if (repeating == false) then
call FlushChildHashtable(GST_Hash, id)
call PauseTimer(t)
call DestroyTimer(t)
endif
// clean up memory leaks
set t = null
set trig = null
endfunction
function GST_IntInt_Expire takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetHandleId(t)
local trigger trig = LoadTriggerHandle(GST_Hash, id, 3)
local boolean repeating = LoadBoolean(GST_Hash, id, 2)
set udg_GST_Integer1 = LoadInteger(GST_Hash, id, 0)
set udg_GST_Integer2 = LoadInteger(GST_Hash, id, 1)
// run the GUI trigger
call TriggerExecute(trig)
// the timer is not repeating so destroy it
if (repeating == false) then
call FlushChildHashtable(GST_Hash, id)
call PauseTimer(t)
call DestroyTimer(t)
endif
// clean up memory leaks
set t = null
set trig = null
endfunction
function GST_IntIntInt_Expire takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetHandleId(t)
local trigger trig = LoadTriggerHandle(GST_Hash, id, 4)
local boolean repeating = LoadBoolean(GST_Hash, id, 3)
set udg_GST_Integer1 = LoadInteger(GST_Hash, id, 0)
set udg_GST_Integer2 = LoadInteger(GST_Hash, id, 1)
set udg_GST_Integer3 = LoadInteger(GST_Hash, id, 2)
// run the GUI trigger
call TriggerExecute(trig)
// the timer is not repeating so destroy it
if (repeating == false) then
call FlushChildHashtable(GST_Hash, id)
call PauseTimer(t)
call DestroyTimer(t)
endif
// clean up memory leaks
set t = null
set trig = null
endfunction
function GST_Real_Expire takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetHandleId(t)
local trigger trig = LoadTriggerHandle(GST_Hash, id, 2)
local boolean repeating = LoadBoolean(GST_Hash, id, 1)
set udg_GST_Real1 = LoadReal(GST_Hash, id, 0)
// run the GUI trigger
call TriggerExecute(trig)
// the timer is not repeating so destroy it
if (repeating == false) then
call FlushChildHashtable(GST_Hash, id)
call PauseTimer(t)
call DestroyTimer(t)
endif
// clean up memory leaks
set t = null
set trig = null
endfunction
function GST_RealReal_Expire takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetHandleId(t)
local trigger trig = LoadTriggerHandle(GST_Hash, id, 3)
local boolean repeating = LoadBoolean(GST_Hash, id, 2)
set udg_GST_Real1 = LoadReal(GST_Hash, id, 0)
set udg_GST_Real2 = LoadReal(GST_Hash, id, 1)
// run the GUI trigger
call TriggerExecute(trig)
// the timer is not repeating so destroy it
if (repeating == false) then
call FlushChildHashtable(GST_Hash, id)
call PauseTimer(t)
call DestroyTimer(t)
endif
// clean up memory leaks
set t = null
set trig = null
endfunction
function GST_IntReal_Expire takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetHandleId(t)
local trigger trig = LoadTriggerHandle(GST_Hash, id, 3)
local boolean repeating = LoadBoolean(GST_Hash, id, 2)
set udg_GST_Integer1 = LoadInteger(GST_Hash, id, 0)
set udg_GST_Real1 = LoadReal(GST_Hash, id, 1)
// run the GUI trigger
call TriggerExecute(trig)
// the timer is not repeating so destroy it
if (repeating == false) then
call FlushChildHashtable(GST_Hash, id)
call PauseTimer(t)
call DestroyTimer(t)
endif
// clean up memory leaks
set t = null
set trig = null
endfunction
function GST_Unit_Expire takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetHandleId(t)
local trigger trig = LoadTriggerHandle(GST_Hash, id, 2)
local boolean repeating = LoadBoolean(GST_Hash, id, 1)
set udg_GST_Unit1 = LoadUnitHandle(GST_Hash, id, 0)
// run the GUI trigger
call TriggerExecute(trig)
// the timer is not repeating so destroy it
if (repeating == false) then
call FlushChildHashtable(GST_Hash, id)
call PauseTimer(t)
call DestroyTimer(t)
endif
// clean up memory leaks
set t = null
set trig = null
endfunction
function GST_UnitUnit_Expire takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetHandleId(t)
local trigger trig = LoadTriggerHandle(GST_Hash, id, 3)
local boolean repeating = LoadBoolean(GST_Hash, id, 2)
set udg_GST_Unit1 = LoadUnitHandle(GST_Hash, id, 0)
set udg_GST_Unit2 = LoadUnitHandle(GST_Hash, id, 1)
// run the GUI trigger
call TriggerExecute(trig)
// the timer is not repeating so destroy it
if (repeating == false) then
call FlushChildHashtable(GST_Hash, id)
call PauseTimer(t)
call DestroyTimer(t)
endif
// clean up memory leaks
set t = null
set trig = null
endfunction
function GST_UnitReal_Expire takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetHandleId(t)
local trigger trig = LoadTriggerHandle(GST_Hash, id, 3)
local boolean repeating = LoadBoolean(GST_Hash, id, 2)
set udg_GST_Unit1 = LoadUnitHandle(GST_Hash, id, 0)
set udg_GST_Real1 = LoadReal(GST_Hash, id, 1)
// run the GUI trigger
call TriggerExecute(trig)
// the timer is not repeating so destroy it
if (repeating == false) then
call FlushChildHashtable(GST_Hash, id)
call PauseTimer(t)
call DestroyTimer(t)
endif
// clean up memory leaks
set t = null
set trig = null
endfunction
function GST_UnitInt_Expire takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetHandleId(t)
local trigger trig = LoadTriggerHandle(GST_Hash, id, 3)
local boolean repeating = LoadBoolean(GST_Hash, id, 2)
set udg_GST_Unit1 = LoadUnitHandle(GST_Hash, id, 0)
set udg_GST_Integer1 = LoadInteger(GST_Hash, id, 1)
// run the GUI trigger
call TriggerExecute(trig)
// the timer is not repeating so destroy it
if (repeating == false) then
call FlushChildHashtable(GST_Hash, id)
call PauseTimer(t)
call DestroyTimer(t)
endif
// clean up memory leaks
set t = null
set trig = null
endfunction
function GST_Simple_Expire takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetHandleId(t)
local trigger trig = LoadTriggerHandle(GST_Hash, id, 0)
local boolean repeating = LoadBoolean(GST_Hash, id, 1)
// run the GUI trigger
call TriggerExecute(trig)
// the timer is not repeating so destroy it
if (repeating == false) then
call FlushChildHashtable(GST_Hash, id)
call PauseTimer(t)
call DestroyTimer(t)
endif
// clean up memory leaks
set t = null
set trig = null
endfunction
// Functions to start timers:
function GST_Real takes real r1, boolean repeating, real interval returns nothing
local timer t = CreateTimer()
local integer id = GetHandleId(t)
// save to hashtable
call SaveReal(GST_Hash, id, 0, r1)
call SaveBoolean(GST_Hash, id, 1, repeating)
call SaveTriggerHandle(GST_Hash, id, 2, udg_GST_Trigger)
// start timer
call TimerStart(t, interval, repeating, function GST_Real_Expire)
// check for keys which are used to restart existing timers
if udg_GST_ParentKey >= 0 then
call GST_RestartTimer()
// keep track of the new timer stored at these keys
call SaveTimerHandle(GST_Hash, GST_NewParentKey, udg_GST_ChildKey, t)
set udg_GST_ParentKey = -1
set udg_GST_ChildKey = -1
endif
// clean up memory leaks
set t = null
endfunction
function GST_RealReal takes real r1, real r2, boolean repeating, real interval returns nothing
local timer t = CreateTimer()
local integer id = GetHandleId(t)
// save to hashtable
call SaveReal(GST_Hash, id, 0, r1)
call SaveReal(GST_Hash, id, 1, r2)
call SaveBoolean(GST_Hash, id, 2, repeating)
call SaveTriggerHandle(GST_Hash, id, 3, udg_GST_Trigger)
// start timer
call TimerStart(t, interval, repeating, function GST_RealReal_Expire)
// check for keys which are used to restart existing timers
if udg_GST_ParentKey >= 0 then
call GST_RestartTimer()
// keep track of the new timer stored at these keys
call SaveTimerHandle(GST_Hash, GST_NewParentKey, udg_GST_ChildKey, t)
set udg_GST_ParentKey = -1
set udg_GST_ChildKey = -1
endif
// clean up memory leaks
set t = null
endfunction
function GST_IntReal takes integer i1, real r1, boolean repeating, real interval returns nothing
local timer t = CreateTimer()
local integer id = GetHandleId(t)
// save to hashtable
call SaveInteger(GST_Hash, id, 0, i1)
call SaveReal(GST_Hash, id, 1, r1)
call SaveBoolean(GST_Hash, id, 2, repeating)
call SaveTriggerHandle(GST_Hash, id, 3, udg_GST_Trigger)
// start timer
call TimerStart(t, interval, repeating, function GST_IntReal_Expire)
// check for keys which are used to restart existing timers
if udg_GST_ParentKey >= 0 then
call GST_RestartTimer()
// keep track of the new timer stored at these keys
call SaveTimerHandle(GST_Hash, GST_NewParentKey, udg_GST_ChildKey, t)
set udg_GST_ParentKey = -1
set udg_GST_ChildKey = -1
endif
// clean up memory leaks
set t = null
endfunction
function GST_Int takes integer i1, boolean repeating, real interval returns nothing
local timer t = CreateTimer()
local integer id = GetHandleId(t)
// save to hashtable
call SaveInteger(GST_Hash, id, 0, i1)
call SaveBoolean(GST_Hash, id, 1, repeating)
call SaveTriggerHandle(GST_Hash, id, 2, udg_GST_Trigger)
// start timer
call TimerStart(t, interval, repeating, function GST_Int_Expire)
// check for keys which are used to restart existing timers
if udg_GST_ParentKey >= 0 then
call GST_RestartTimer()
// keep track of the new timer stored at these keys
call SaveTimerHandle(GST_Hash, GST_NewParentKey, udg_GST_ChildKey, t)
set udg_GST_ParentKey = -1
set udg_GST_ChildKey = -1
endif
// clean up memory leaks
set t = null
endfunction
function GST_IntInt takes integer i1, integer i2, boolean repeating, real interval returns nothing
local timer t = CreateTimer()
local integer id = GetHandleId(t)
// save to hashtable
call SaveInteger(GST_Hash, id, 0, i1)
call SaveInteger(GST_Hash, id, 1, i2)
call SaveBoolean(GST_Hash, id, 2, repeating)
call SaveTriggerHandle(GST_Hash, id, 3, udg_GST_Trigger)
// start timer
call TimerStart(t, interval, repeating, function GST_IntInt_Expire)
// check for keys which are used to restart existing timers
if udg_GST_ParentKey >= 0 then
call GST_RestartTimer()
// keep track of the new timer stored at these keys
call SaveTimerHandle(GST_Hash, GST_NewParentKey, udg_GST_ChildKey, t)
set udg_GST_ParentKey = -1
set udg_GST_ChildKey = -1
endif
// clean up memory leaks
set t = null
endfunction
function GST_IntIntInt takes integer i1, integer i2, integer i3, boolean repeating, real interval returns nothing
local timer t = CreateTimer()
local integer id = GetHandleId(t)
// save to hashtable
call SaveInteger(GST_Hash, id, 0, i1)
call SaveInteger(GST_Hash, id, 1, i2)
call SaveInteger(GST_Hash, id, 2, i3)
call SaveBoolean(GST_Hash, id, 3, repeating)
call SaveTriggerHandle(GST_Hash, id, 4, udg_GST_Trigger)
// start timer
call TimerStart(t, interval, repeating, function GST_IntIntInt_Expire)
// check for keys which are used to restart existing timers
if udg_GST_ParentKey >= 0 then
call GST_RestartTimer()
// keep track of the new timer stored at these keys
call SaveTimerHandle(GST_Hash, GST_NewParentKey, udg_GST_ChildKey, t)
set udg_GST_ParentKey = -1
set udg_GST_ChildKey = -1
endif
// clean up memory leaks
set t = null
endfunction
function GST_UnitInt takes unit u1, integer i1, boolean repeating, real interval returns nothing
local timer t = CreateTimer()
local integer id = GetHandleId(t)
// save to hashtable
call SaveUnitHandle(GST_Hash, id, 0, u1)
call SaveInteger(GST_Hash, id, 1, i1)
call SaveBoolean(GST_Hash, id, 2, repeating)
call SaveTriggerHandle(GST_Hash, id, 3, udg_GST_Trigger)
// start timer
call TimerStart(t, interval, repeating, function GST_UnitInt_Expire)
// check for keys which are used to restart existing timers
if udg_GST_ParentKey >= 0 then
call GST_RestartTimer()
// keep track of the new timer stored at these keys
call SaveTimerHandle(GST_Hash, GST_NewParentKey, udg_GST_ChildKey, t)
set udg_GST_ParentKey = -1
set udg_GST_ChildKey = -1
endif
// clean up memory leaks
set t = null
endfunction
function GST_UnitReal takes unit u1, real r1, boolean repeating, real interval returns nothing
local timer t = CreateTimer()
local integer id = GetHandleId(t)
// save to hashtable
call SaveUnitHandle(GST_Hash, id, 0, u1)
call SaveReal(GST_Hash, id, 1, r1)
call SaveBoolean(GST_Hash, id, 2, repeating)
call SaveTriggerHandle(GST_Hash, id, 3, udg_GST_Trigger)
// start timer
call TimerStart(t, interval, repeating, function GST_UnitReal_Expire)
// check for keys which are used to restart existing timers
if udg_GST_ParentKey >= 0 then
call GST_RestartTimer()
// keep track of the new timer stored at these keys
call SaveTimerHandle(GST_Hash, GST_NewParentKey, udg_GST_ChildKey, t)
set udg_GST_ParentKey = -1
set udg_GST_ChildKey = -1
endif
// clean up memory leaks
set t = null
endfunction
function GST_UnitUnit takes unit u1, unit u2, boolean repeating, real interval returns nothing
local timer t = CreateTimer()
local integer id = GetHandleId(t)
// save to hashtable
call SaveUnitHandle(GST_Hash, id, 0, u1)
call SaveUnitHandle(GST_Hash, id, 1, u2)
call SaveBoolean(GST_Hash, id, 2, repeating)
call SaveTriggerHandle(GST_Hash, id, 3, udg_GST_Trigger)
// start timer
call TimerStart(t, interval, repeating, function GST_UnitUnit_Expire)
// check for keys which are used to restart existing timers
if udg_GST_ParentKey >= 0 then
call GST_RestartTimer()
// keep track of the new timer stored at these keys
call SaveTimerHandle(GST_Hash, GST_NewParentKey, udg_GST_ChildKey, t)
set udg_GST_ParentKey = -1
set udg_GST_ChildKey = -1
endif
// clean up memory leaks
set t = null
endfunction
function GST_Unit takes unit u1, boolean repeating, real interval returns nothing
local timer t = CreateTimer()
local integer id = GetHandleId(t)
// save to hashtable
call SaveUnitHandle(GST_Hash, id, 0, u1)
call SaveBoolean(GST_Hash, id, 1, repeating)
call SaveTriggerHandle(GST_Hash, id, 2, udg_GST_Trigger)
// start timer
call TimerStart(t, interval, repeating, function GST_Unit_Expire)
// check for keys which are used to restart existing timers
if udg_GST_ParentKey >= 0 then
call GST_RestartTimer()
// keep track of the new timer stored at these keys
call SaveTimerHandle(GST_Hash, GST_NewParentKey, udg_GST_ChildKey, t)
set udg_GST_ParentKey = -1
set udg_GST_ChildKey = -1
endif
// clean up memory leaks
set t = null
endfunction
function GST_Simple takes boolean repeating, real interval returns nothing
local timer t = CreateTimer()
local integer id = GetHandleId(t)
// save to hashtable
call SaveTriggerHandle(GST_Hash, id, 0, udg_GST_Trigger)
call SaveBoolean(GST_Hash, id, 1, repeating)
// start timer
call TimerStart(t, interval, repeating, function GST_Simple_Expire)
// check for keys which are used to restart existing timers
if udg_GST_ParentKey >= 0 then
call GST_RestartTimer()
// keep track of the new timer stored at these keys
call SaveTimerHandle(GST_Hash, GST_NewParentKey, udg_GST_ChildKey, t)
set udg_GST_ParentKey = -1
set udg_GST_ChildKey = -1
endif
// clean up memory leaks
set t = null
endfunction
globals
trigger DamageDetectionTrigger = CreateTrigger()
endglobals
function DamageWasDealt takes nothing returns nothing
set udg_DamageEventSource = GetEventDamageSource()
set udg_DamageEventTarget = BlzGetEventDamageTarget()
set udg_DamageEventAmount = GetEventDamage()
set udg_DamageEvent = 1.00
set udg_DamageEvent = 0.00
endfunction
function EnableDamageDetection takes nothing returns nothing
set DamageDetectionTrigger = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(DamageDetectionTrigger, EVENT_PLAYER_UNIT_DAMAGING)
call TriggerAddAction(DamageDetectionTrigger, function DamageWasDealt)
endfunction
function DisableDamageDetection takes nothing returns nothing
call DisableTrigger(DamageDetectionTrigger)
endfunction
scope RangeDemo initializer Init
globals
private constant real DEATH_TIME = 3.0
private constant integer SPELL_ID = 'A00M'
endglobals
globals
private hashtable hash = InitHashtable()
endglobals
private function RemoveEffect takes nothing returns nothing
local integer id = GetHandleId(GetExpiredTimer())
local effect sfx = LoadEffectHandle(hash, id, 0)
// Move effect to edge of map, so it is not seen by players
call BlzSetSpecialEffectPosition(sfx, GetRectMaxX(GetWorldBounds()), GetRectMaxY(GetWorldBounds()), 0)
// Clean up
call FlushChildHashtable(hash, id)
call BlzSetSpecialEffectAlpha(sfx, 0)
call DestroyEffect(sfx)
call DestroyTimer(GetExpiredTimer())
set sfx = null
endfunction
private function Display takes nothing returns nothing
local timer t
local effect sfx
if GetSpellAbilityId() == SPELL_ID then
set sfx = ShowRange(GetTriggerUnit(), 0)
if DEATH_TIME ==2 then
// Effect disappears after 2 seconds after this function call since model has a 2 seconds death animation
call BlzSetSpecialEffectAlpha(sfx, 0)
call DestroyEffect(sfx)
else
set t = CreateTimer()
call SaveEffectHandle(hash, GetHandleId(t), 0, sfx)
call TimerStart(t, DEATH_TIME, false, function RemoveEffect)
set t = null
endif
set sfx = null
endif
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddAction(t, function Display)
endfunction
endscope
library RangeShower
globals
// ---------------- CONFIGURATION
// Default values for sfx coloring in decimal format
private constant integer RED = 255
private constant integer GREEN = 255
private constant integer BLUE = 255
// Model displayed to show range
private constant string FX_MODEL = "RangeIndicator.mdx"
// Value to adjust size of sfx with
private constant real FX_SCALE_ADJUSTMENT = 50.
// ---------------- END OF CONFIGURATION
endglobals
globals
private effect sfx
endglobals
// Use 0 for weaponIndex to get the range of Attack 1
// Use 1 for Attack 2
function ShowRangeEx takes unit u, integer weaponIndex, integer red, integer green, integer blue returns effect
local string path = ""
local real scale = BlzGetUnitWeaponRealField(u, UNIT_WEAPON_RF_ATTACK_RANGE, weaponIndex) / FX_SCALE_ADJUSTMENT
if GetLocalPlayer() == GetOwningPlayer(u) then
set path = FX_MODEL
endif
set sfx = null
set sfx = AddSpecialEffect(path, GetUnitX(u), GetUnitY(u))
call BlzSetSpecialEffectMatrixScale(sfx, scale, scale, 1)
call BlzSetSpecialEffectX(sfx, GetUnitX(u))
call BlzSetSpecialEffectY(sfx, GetUnitY(u))
call BlzSetSpecialEffectColor(sfx, red, green, blue) // SET TEXTURE COLOR
return sfx
endfunction
function ShowRange takes unit u, integer weaponIndex returns effect
return ShowRangeEx(u, weaponIndex, RED, GREEN, BLUE)
endfunction
endlibrary