library OtherFunctions initializer InitGroupSystem
globals
gamecache DotACache = InitGameCache("DotACache.x")
unit TempUnit
unit TempFilterUnit
real TempReal
integer TempGroupInteger
integer TempGroupInteger2
boolean array GroupUsedOrNot
group array GroupArray
integer TriggerCount
trigger array Triggers
real array Reals
timer Timer
endglobals
function H2I takes handle h returns integer
return h
return 0
endfunction
function H2S takes handle h returns string
return I2S(H2I(h))
endfunction
function SetStringInteger takes string hs, string s, integer i returns nothing
call StoreInteger(DotACache, hs, s, i)
endfunction
function SetStringUnit takes string hs, string s, handle h returns nothing
call StoreInteger(DotACache, hs, s, H2I(h))
endfunction
function GetStringInteger takes string hs, string s returns integer
return GetStoredInteger(DotACache, hs, s)
endfunction
function GetStringUnit takes string hs, string s returns unit
return GetStoredInteger(DotACache, hs, s)
return null
endfunction
function FlushStringLocals takes string s returns nothing
call FlushStoredMission(DotACache, s)
endfunction
function FilterLearned takes unit u returns boolean
return GetUnitAbilityLevel(u, 1113815395) > 0
endfunction
function FilterDead takes unit u returns boolean
return GetUnitTypeId(u) < 1 or IsUnitType(u, UNIT_TYPE_DEAD) == true
endfunction
function UnitIDComparison takes unit u returns boolean
local integer i = GetUnitTypeId(u)
return i == 1848651828 or i == 1848652103 or i == 1848652099 or i == 1848652088 or i == 1697656907 or i == 1697656905 or i == 1697656908 or i == 1697657162
endfunction
function AnotherFilter takes nothing returns boolean
return GetUnitAbilityLevel(GetFilterUnit(), 1093678162) == 0 and IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false and FilterDead(GetFilterUnit()) == false and FilterLearned(GetFilterUnit())==false
endfunction
function FilterTargets takes nothing returns boolean
return IsUnitEnemy(TempFilterUnit, GetOwningPlayer(GetFilterUnit())) and AnotherFilter() and (IsUnitType(GetFilterUnit(), UNIT_TYPE_ANCIENT) == false or UnitIDComparison(GetFilterUnit()))
endfunction
function RealComparison takes real a, real b returns real
if a < b then
return a
else
return b
endif
endfunction
function RealComparison2 takes real a, real b returns real
if a < b then
return b
else
return a
endif
endfunction
function Whatever takes trigger t, string s returns boolean
return GetStringInteger(H2S(t), "state" + s) == 1
endfunction
function Whateverr takes unit u returns boolean
return Whatever(u, "s")
endfunction
function AbilityLevelComparison takes unit u returns boolean
return GetUnitAbilityLevel(u, 1093686070) > 0 or GetUnitAbilityLevel(u, 1094937961) > 0 or GetUnitAbilityLevel(u, 1093686101) > 0 or GetUnitAbilityLevel(u, 1110454580) > 0 or Whateverr(u)
endfunction
function GroupRecycle takes group g returns nothing
local integer i = H2I(g) - TempGroupInteger2
if i < 0 or i > 120 then
//
else
call GroupClear(g)
set GroupUsedOrNot[i] = false
set TempGroupInteger = i
endif
endfunction
function GroupUsage takes nothing returns group
local integer i = TempGroupInteger
loop
exitwhen i == TempGroupInteger - 1
if GroupUsedOrNot[i] == false then
set TempGroupInteger = i + 1
if TempGroupInteger == 120 then
set TempGroupInteger = 0
endif
set GroupUsedOrNot[i] = true
return GroupArray[i]
endif
set i = i + 1
if i == 120 then
set i = 0
endif
endloop
call BJDebugMsg("|c00ff0303CRITICAL ERROR: FOUND NO AVAILABLE GROUPS|r")
return CreateGroup()
endfunction
function InitGroupSystem takes nothing returns nothing
local integer i = 0
set TempGroupInteger = 0
set GroupArray[i] = CreateGroup()
set GroupUsedOrNot[i] = false
set i = i + 1
set TempGroupInteger2 = H2I(GroupArray[0])
loop
exitwhen i == 120
set GroupArray[i] = CreateGroup()
set GroupUsedOrNot[i] = false
set i = i + 1
endloop
endfunction
function Error takes nothing returns nothing
local integer i = 0
loop
call DisplayTimedTextToPlayer(Player(i), 0, 0, 120, "|c00ff0303An internal checksum has failed|r")
set i = i + 1
exitwhen i == 12
endloop
endfunction
function TimeElasped takes nothing returns real
return TimerGetElapsed(Timer)
endfunction
function TriggerRecycle2 takes trigger t returns nothing
call DisableTrigger(t)
set TriggerCount = TriggerCount + 1
set Triggers[TriggerCount] = t
set Reals[TriggerCount] = TimeElasped() + 60
if TriggerCount > 8000 then
call Error()
endif
endfunction
function TriggerRecycle1 takes integer i returns nothing
if i != TriggerCount then
set Triggers[i] = Triggers[TriggerCount]
set Reals[i] = Reals[TriggerCount]
endif
set Triggers[TriggerCount] = null
set Reals[TriggerCount] = 0
set TriggerCount = TriggerCount - 1
endfunction
function TriggerRecycle takes nothing returns boolean
local real r = TimeElasped()
local integer i
set i = 1
loop
exitwhen i > TriggerCount
if Reals[i] < r then
if Triggers[i] == null or IsTriggerEnabled(Triggers[i]) == true then
call Error()
else
call DestroyTrigger(Triggers[i])
endif
call TriggerRecycle1(i)
else
set i = i + 1
endif
endloop
return false
endfunction
function InitTriggerSystem takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterTimerEvent(t, 15, true)
call TriggerAddCondition(t, Condition(function TriggerRecycle))
call TimerStart(Timer, 99999.0, false, null)
set t = null
endfunction
function Damage takes unit n, unit u, integer i, real r returns nothing
if i == 0 then
return
endif
if i == 1 then
call UnitDamageTarget(n, u, r, true, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_FIRE, WEAPON_TYPE_WHOKNOWS)
elseif i == 2 then
call UnitDamageTarget(n, u, r, true, true, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
elseif i == 3 then
call UnitDamageTarget(n, u, r, true, true, ATTACK_TYPE_HERO, DAMAGE_TYPE_FIRE, WEAPON_TYPE_WHOKNOWS)
endif
endfunction
function True takes nothing returns boolean
return true
endfunction
function TriggerRegisterAllPlayersUnitEvent takes trigger t, playerunitevent pue returns nothing
local integer i = 0
loop
call TriggerRegisterPlayerUnitEvent(t, Player(i), pue, Condition(function True))
set i = i + 1
exitwhen i == 16
endloop
endfunction
endlibrary