function InitGlobals takes nothing returns nothing
local integer i = 0
set udg_AMHS_FogPeriodicTimer = 0
set udg_AMHS_FogDisableSingle = false
set udg_AMHS_FogY = 0
set udg_AMHS_FogX = 0
set udg_AMHS_DummyId = 0
set udg_AMHS_InvisDetect = false
set udg_AMHS_InvisBuffer = 0
set udg_AMHS_SharedVision = false
set udg_AMHS_InvisX = 0
set udg_AMHS_InvisY = 0
set udg_AMHS_InvisPeriodicTimer = 0
set udg_AMHS_MaxPlayers = 0
set udg_AMHS_InGame = false
set udg_AMHS_InGameOutPut = false
set udg_AMHS_FogTimer = CreateTimer()
set udg_AMHS_InvisTimer = CreateTimer()
endfunction
function AMHS_SortPlayersEnemy takes nothing returns string
local integer counter = 1
local integer firstplayer
local string output
loop
exitwhen counter > 12
if (GetPlayerSlotState(Player(counter -1)) == PLAYER_SLOT_STATE_PLAYING) and (GetPlayerController(Player(counter - 1)) == MAP_CONTROL_USER) then
set firstplayer = counter - 1
set output = I2S(firstplayer)
set counter = 13
endif
set counter = counter + 1
endloop
set counter = 1
loop
exitwhen counter > (12 - firstplayer)
if IsPlayerEnemy(Player(firstplayer),Player(counter + firstplayer)) and IsPlayerAlly(Player(counter - 1 + firstplayer),Player(counter + firstplayer)) == false then
set output = output + ";" + I2S(counter + firstplayer)
endif
set counter = counter + 1
endloop
set counter = 0
set firstplayer = 0
return output
endfunction
function AMHS_TopRight takes nothing returns rect
local rect r = bj_mapInitialPlayableArea
local real MaxX = GetRectMaxX(r)
local real MaxY = GetRectMaxY(r)
local rect output = Rect(MaxX - 3,MaxY - 3,MaxX,MaxY)
set MaxX = 0
set MaxY = 0
set r = null
return output
endfunction
function AMHS_TopLeft takes nothing returns rect
local rect r = bj_mapInitialPlayableArea
local real MinX = GetRectMinX(r)
local real MaxY = GetRectMaxY(r)
local rect output = Rect(MinX,MaxY - 3,MinX + 3,MaxY)
set MinX = 0
set MaxY = 0
set r = null
return output
endfunction
function AMHS_BottomRight takes nothing returns rect
local rect r = bj_mapInitialPlayableArea
local real MaxX = GetRectMaxX(r)
local real MinY = GetRectMinY(r)
local rect output = Rect(MaxX - 3,MinY,MaxX,MinY + 3)
set MaxX = 0
set MinY = 0
set r = null
return output
endfunction
function AMHS_BottomLeft takes nothing returns rect
local rect r = bj_mapInitialPlayableArea
local real MinY = GetRectMinY(r)
local real MinX = GetRectMinX(r)
local rect output = Rect(MinX,MinY + 3,MinX + 3,MinY)
set MinX = 0
set MinY = 0
set r = null
return output
endfunction
function AMHS_GetSyncedCameraX takes player p returns real
local real output = 99999999
if GetLocalPlayer() == p then
set output = GetCameraTargetPositionX()
endif
return output
endfunction
function AMHS_GetSyncedCameraY takes player p returns real
local real output = 99999999
if GetLocalPlayer() == p then
set output = GetCameraTargetPositionY()
endif
return output
endfunction
function AMHS_IsInGame takes nothing returns boolean
local boolean output
local integer counter = 1
local real currentx
local real currenty
local real x
local real y
local integer validplayer
set udg_AMHS_InGameOutPut = false
loop
exitwhen counter > 12
if GetPlayerSlotState(Player(counter - 1)) == PLAYER_SLOT_STATE_PLAYING and (GetPlayerController(Player(counter - 1)) == MAP_CONTROL_USER) then
set validplayer = counter - 1
set counter = 13
endif
set counter = counter + 1
endloop
set currentx = AMHS_GetSyncedCameraX(Player(validplayer))
set currenty = AMHS_GetSyncedCameraY(Player(validplayer))
call PauseGame(true)
call TriggerSleepAction(0)
if currentx != 99999999 and currenty != 99999999 then
call SetCameraPositionForPlayer(Player(validplayer),currentx+1,currenty + 1)
endif
call TriggerSleepAction(0)
call PauseGame(false)
set x = AMHS_GetSyncedCameraX(Player(validplayer))
if GetLocalPlayer() == Player(validplayer) then
if x == currentx + 1 then
set udg_AMHS_InGameOutPut = false
else
set udg_AMHS_InGameOutPut = true
endif
endif
if x != 99999999 then
call SetCameraPositionForPlayer(Player(validplayer),currentx,currenty)
endif
set counter = 0
set x = 0
set y = 0
set currentx = 0
set currenty = 0
set validplayer = 0
return udg_AMHS_InGameOutPut
endfunction
function AMHS_ReplayEngine takes nothing returns nothing
set udg_AMHS_InGame = AMHS_IsInGame()
endfunction
function AMHS_DisableFogEngine takes nothing returns nothing
call PauseTimer(udg_AMHS_FogTimer)
endfunction
function AMHS_EnableFogEngine takes nothing returns nothing
call ResumeTimer(udg_AMHS_FogTimer)
endfunction
function AMHS_DisableInvisEngine takes nothing returns nothing
call PauseTimer(udg_AMHS_InvisTimer)
endfunction
function AMHS_EnableInvisEngine takes nothing returns nothing
call ResumeTimer(udg_AMHS_InvisTimer)
endfunction
function AMHS_FogSetValues takes nothing returns nothing
set udg_AMHS_FogPeriodicTimer = 3
set udg_AMHS_FogLightningRectangle = AMHS_TopRight()
set udg_AMHS_FogDisableSingle = true
endfunction
function AMHS_FogBoltDestroyer takes nothing returns nothing
local timer t = GetExpiredTimer()
call PauseTimer(t)
call DestroyTimer(t)
call DestroyLightning(udg_AMHS_FogCurrentBolt)
endfunction
function AMHS_FogBoldDestroyerTimer takes nothing returns nothing
local timer t = CreateTimer()
call TimerStart(t,udg_AMHS_FogPeriodicTimer - 0.01,true,function AMHS_FogBoltDestroyer)
endfunction
function AMHS_FOG_Check takes nothing returns nothing
local fogmodifier temp = null
local integer counter = 1
local integer counter2
local boolean check
local unit dummy
local real x
local real y
local string EnemyPlayers
local player array AnalysePlayers
local integer i=0
local integer st
local string c
local integer maxplayers
set lightning_area_rotator = lightning_area_rotator + 1
//rotate the lightning area
if lightning_area_rotator == 0 then
set udg_AMHS_FogLightningRectangle = AMHS_TopLeft()
elseif lightning_area_rotator == 1 then
set udg_AMHS_FogLightningRectangle = AMHS_TopRight()
elseif lightning_area_rotator == 2 then
set udg_AMHS_FogLightningRectangle = AMHS_BottomRight()
elseif lightning_area_rotator == 3 then
set udg_AMHS_FogLightningRectangle = AMHS_BottomLeft()
set lightning_area_rotator = 0
endif
loop
exitwhen counter > 12
if GetPlayerSlotState(Player(counter -1)) == PLAYER_SLOT_STATE_PLAYING then
if IsVisibleToPlayer(udg_AMHS_FogX,udg_AMHS_FogY,Player(counter-1)) then
set temp = CreateFogModifierRect(Player(counter -1),FOG_OF_WAR_MASKED,udg_AMHS_FogLightningRectangle,true,false)
endif
set udg_AMHS_FogCurrentBolt = AddLightning("AMHS", true,udg_AMHS_FogX,udg_AMHS_FogY,udg_AMHS_FogX,udg_AMHS_FogY)
if temp != null then
call DestroyFogModifier(temp)
endif
call ExecuteFunc("AMHS_FogBoldDestroyerTimer")
endif
set counter = counter + 1
endloop
set counter = 0
endfunction
function AMHS_FogClearVariables takes nothing returns nothing
set udg_AMHS_FogCurrentBolt = null
set udg_AMHS_FogPeriodicTimer = 0
call RemoveRect(udg_AMHS_FogLightningRectangle)
set udg_AMHS_FogDisableSingle = false
set udg_AMHS_FogX = 0
set udg_AMHS_FogY = 0
endfunction
function AMHS_FogEngineStarter takes nothing returns nothing
set udg_AMHS_FogTimer = CreateTimer()
if bj_isSinglePlayer and udg_AMHS_FogDisableSingle then
call ExecuteFunc("AMHS_FogClearVariables")
else
call ExecuteFunc("AMHS_FogSetValues")
set udg_AMHS_FogX = GetRectMinX(udg_AMHS_FogLightningRectangle) + 1.5
set udg_AMHS_FogY = GetRectMinY(udg_AMHS_FogLightningRectangle) + 1.5
call TimerStart(udg_AMHS_FogTimer,udg_AMHS_FogPeriodicTimer, true, function AMHS_FOG_Check)
endif
endfunction
function AMHS_FogDetectEngine takes nothing returns nothing
if udg_AMHS_InGame != true then
call ExecuteFunc("AMHS_FogEngineStarter")
else
call ExecuteFunc("AMHS_FogClearVariables")
endif
endfunction
function InitTrig_FogDetect_Engine takes nothing returns nothing
set gg_trg_FogDetect_Engine = CreateTrigger( )
endfunction
function Trig_FogDetect_Required_Variables_Actions takes nothing returns nothing
set udg_AMHS_InGame = false
set udg_AMHS_Cache = GetLastCreatedGameCacheBJ()
set udg_AMHS_FogPeriodicTimer = 0.00
set udg_AMHS_FogLightningRectangle = GetPlayableMapRect()
set udg_AMHS_FogDisableSingle = true
set udg_AMHS_FogCurrentBolt = GetLastCreatedLightningBJ()
set udg_AMHS_FogX = 0.00
set udg_AMHS_FogY = 0.00
set udg_AMHS_FogTimer = GetLastCreatedTimerBJ()
endfunction
function InitTrig_FogDetect_Required_Variables takes nothing returns nothing
set gg_trg_FogDetect_Required_Variables = CreateTrigger( )
call TriggerAddAction( gg_trg_FogDetect_Required_Variables, function Trig_FogDetect_Required_Variables_Actions )
endfunction
function AMHS_InvisSetValues takes nothing returns nothing
set udg_AMHS_InvisPeriodicTimer = 0.5
set udg_AMHS_InvisLightningRectangle = AMHS_TopLeft()
set udg_AMHS_InvisBuffer = 20
set udg_AMHS_SharedVision = true
set udg_AMHS_DummyId = 'h000'
endfunction
function AMHS_Invis_Check takes nothing returns nothing
local integer counter = 1
local integer counter2 = 1
local boolean check
local unit dummy
local real x
local real y
local fogmodifier temp
if udg_AMHS_SharedVision then
set check = false
loop
exitwhen counter > udg_AMHS_MaxPlayers
set temp = CreateFogModifierRect(udg_AMHS_AnalysePlayers[counter -1],FOG_OF_WAR_VISIBLE,udg_AMHS_InvisLightningRectangle,true,false)
set udg_AMHS_D1 = CreateUnit(Player(15),udg_AMHS_DummyId,udg_AMHS_InvisX,udg_AMHS_InvisY,0)
call UnitApplyTimedLife(udg_AMHS_D1,udg_AMHS_DummyId,0.02)
if IsUnitVisible(udg_AMHS_D1,udg_AMHS_AnalysePlayers[counter - 1]) == false then
set udg_AMHS_D2 = CreateUnit(Player(15),udg_AMHS_DummyId,udg_AMHS_InvisX,udg_AMHS_InvisY,0)
call UnitApplyTimedLife(udg_AMHS_D2,udg_AMHS_DummyId,0.02)
call IssueTargetOrderById(udg_AMHS_D1,851983,udg_AMHS_D2)
else
loop
exitwhen counter2 > udg_AMHS_InvisBuffer
set x = GetRandomReal(GetRectMinX(bj_mapInitialPlayableArea), GetRectMaxX(bj_mapInitialPlayableArea))
set y = GetRandomReal(GetRectMinY(bj_mapInitialPlayableArea), GetRectMaxY(bj_mapInitialPlayableArea))
set udg_AMHS_D1 = CreateUnit(Player(15),udg_AMHS_DummyId,x,y,0)
call UnitApplyTimedLife(udg_AMHS_D1,udg_AMHS_DummyId,0.02)
if IsUnitVisible(udg_AMHS_D1,udg_AMHS_AnalysePlayers[counter - 1]) == false then
set check = true
set counter2 = udg_AMHS_InvisBuffer + 1
set udg_AMHS_D2 = CreateUnit(Player(15),udg_AMHS_DummyId,x,y,0)
call UnitApplyTimedLife(udg_AMHS_D2,udg_AMHS_DummyId,0.02)
endif
set counter2 = counter2 + 1
endloop
if check then
call IssueTargetOrderById(udg_AMHS_D1,851983,udg_AMHS_D2)
endif
call DestroyFogModifier(temp)
endif
set counter = counter + 1
endloop
else
set counter = 1
set check = false
loop
exitwhen counter > 12
set temp = CreateFogModifierRect(Player(counter -1),FOG_OF_WAR_VISIBLE,udg_AMHS_InvisLightningRectangle,true,false)
set udg_AMHS_D1 = CreateUnit(Player(15),udg_AMHS_DummyId,udg_AMHS_InvisX,udg_AMHS_InvisY,0)
call UnitApplyTimedLife(udg_AMHS_D1,udg_AMHS_DummyId,0.02)
if IsUnitVisible(udg_AMHS_D1,Player(counter - 1)) == false then
set udg_AMHS_D2 = CreateUnit(Player(15),udg_AMHS_DummyId,udg_AMHS_InvisX,udg_AMHS_InvisY,0)
call IssueTargetOrderById(udg_AMHS_D1,851983,udg_AMHS_D2)
call UnitApplyTimedLife(udg_AMHS_D2,udg_AMHS_DummyId,0.02)
else
loop
exitwhen counter2 > udg_AMHS_InvisBuffer
set x = GetRandomReal(GetRectMinX(bj_mapInitialPlayableArea), GetRectMaxX(bj_mapInitialPlayableArea))
set y = GetRandomReal(GetRectMinY(bj_mapInitialPlayableArea), GetRectMaxY(bj_mapInitialPlayableArea))
set udg_AMHS_D1 = CreateUnit(Player(15),udg_AMHS_DummyId,x,y,0)
call UnitApplyTimedLife(udg_AMHS_D1,udg_AMHS_DummyId,0.02)
if IsUnitVisible(udg_AMHS_D1,Player(counter - 1)) == false then
set check = true
set counter2 = udg_AMHS_InvisBuffer + 1
set udg_AMHS_D2 = CreateUnit(Player(15),udg_AMHS_DummyId,x,y,0)
call UnitApplyTimedLife(udg_AMHS_D2,udg_AMHS_DummyId,0.02)
endif
set counter2 = counter2 + 1
endloop
if check then
call IssueTargetOrderById(udg_AMHS_D1,851983,udg_AMHS_D2)
endif
call DestroyFogModifier(temp)
endif
set counter = counter + 1
endloop
endif
endfunction
function AMHS_InvisClearVariables takes nothing returns nothing
set udg_AMHS_InvisX = 0
set udg_AMHS_InvisY = 0
set udg_AMHS_InvisPeriodicTimer = 0
call RemoveRect(udg_AMHS_FogLightningRectangle)
set udg_AMHS_SharedVision = false
endfunction
function AMHS_InvisEngineStarter takes nothing returns nothing
local string EnemyPlayers
local integer counter = 1
local integer i=0
local integer st
local string c
set udg_AMHS_InvisTimer = CreateTimer()
call ExecuteFunc("AMHS_InvisSetValues")
set udg_AMHS_InvisX = GetRectMinX(udg_AMHS_InvisLightningRectangle) + 1.5
set udg_AMHS_InvisY = GetRectMinY(udg_AMHS_InvisLightningRectangle) + 1.5
set EnemyPlayers = AMHS_SortPlayersEnemy()
if udg_AMHS_SharedVision then
set EnemyPlayers=EnemyPlayers+";"
set st=0
loop
set c=SubString(EnemyPlayers, i, i+1)
exitwhen (c == "") or (c == null)
if (c == ";") then
set udg_AMHS_AnalysePlayers[counter - 1] = Player(S2I(SubString(EnemyPlayers, st, i)))
set counter = counter + 1
set st=i+1
endif
set i=i+1
endloop
set udg_AMHS_MaxPlayers = counter
endif
call TimerStart(udg_AMHS_InvisTimer,udg_AMHS_InvisPeriodicTimer, true, function AMHS_Invis_Check)
endfunction
function AMHS_InvisDetectEngine takes nothing returns nothing
if udg_AMHS_InGame != true then
call ExecuteFunc("AMHS_InvisEngineStarter")
else
call ExecuteFunc("AMHS_InvisClearVariables")
endif
endfunction
function InitTrig_InvisDetect_Engine takes nothing returns nothing
set gg_trg_InvisDetect_Engine = CreateTrigger( )
endfunction
function Trig_InvisDetect_Required_Variables_Actions takes nothing returns nothing
set udg_AMHS_InvisTimer = GetLastCreatedTimerBJ()
set udg_AMHS_SharedVision = false
set udg_AMHS_D1 = GetLastCreatedUnit()
set udg_AMHS_D2 = GetLastCreatedUnit()
set udg_AMHS_DummyId = 0
set udg_AMHS_AnalysePlayers[0] = GetEnumPlayer()
set udg_AMHS_MaxPlayers = 0
set udg_AMHS_InGame = false
set udg_AMHS_Cache = GetLastCreatedGameCacheBJ()
set udg_AMHS_InvisPeriodicTimer = 0.00
set udg_AMHS_InvisLightningRectangle = GetPlayableMapRect()
set udg_AMHS_InvisX = 0.00
set udg_AMHS_InvisY = 0.00
set udg_AMHS_InvisBuffer = 0
endfunction
function InitTrig_InvisDetect_Required_Variables takes nothing returns nothing
set gg_trg_InvisDetect_Required_Variables = CreateTrigger( )
call TriggerAddAction( gg_trg_InvisDetect_Required_Variables, function Trig_InvisDetect_Required_Variables_Actions )
endfunction
function Trig_Initilize_Systems_Actions takes nothing returns nothing
call ExecuteFunc("AMHS_FogDetectEngine")
call ExecuteFunc("AMHS_InvisDetectEngine")
endfunction
function InitTrig_Initilize_Systems takes nothing returns nothing
set gg_trg_Initilize_Systems = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_Initilize_Systems, 90.0 )
call TriggerAddAction( gg_trg_Initilize_Systems, function Trig_Initilize_Systems_Actions )
endfunction
function Trig_Initilize_Replay_Detect_Actions takes nothing returns nothing
call CinematicModeBJ( true, GetPlayersAll() )
call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_024" )
call ExecuteFunc("AMHS_ReplayEngine")
call PolledWait(7)
call CinematicModeBJ( false, GetPlayersAll() )
endfunction
function InitTrig_Initilize_Replay_Detect takes nothing returns nothing
set gg_trg_Initilize_Replay_Detect = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_Initilize_Replay_Detect, 60.0 )
call TriggerAddAction( gg_trg_Initilize_Replay_Detect, function Trig_Initilize_Replay_Detect_Actions )
endfunction
function InitCustomTriggers takes nothing returns nothing
call InitTrig_FogDetect_Engine( )
call InitTrig_FogDetect_Required_Variables( )
call InitTrig_InvisDetect_Engine( )
call InitTrig_InvisDetect_Required_Variables( )
call InitTrig_Initilize_Systems( )
call InitTrig_Initilize_Replay_Detect( )
endfunction