- Reaction score
- 91
I just implemented PandaMine's replay detection script in my map, however I ran into some trouble - it seems like when the function is ran it permanently freezes the game (only camera can be moved around) and I can't unpause to do anything. Here's my code and the script:
JASS:
scope IsItReplay initializer Init
private function Conditions takes nothing returns boolean
// isReplay is a global boolean that has to acquire the value returned by IsInGame().
set isReplay = IsInGame()
return true
endfunction
private function Init takes nothing returns nothing
local trigger trig = CreateTrigger()
call TriggerRegisterTimerEventSingle(trig, 5.)
call TriggerAddCondition(trig, Condition(function Conditions))
endfunction
endscope
JASS:
library ReplayDetectLib
function IsInGame takes nothing returns boolean
local integer counter = 0
local real camerax
local real cameray
local real x
local real y
local boolean output
loop
exitwhen counter > 11
if GetLocalPlayer() == Player(counter) then
set camerax = GetCameraTargetPositionX()
set cameray = GetCameraTargetPositionY()
endif
set counter = counter + 1
endloop
set counter = 0
call PauseGame(true)
call TriggerSleepAction(0)
loop
exitwhen counter > 11
if GetLocalPlayer() == Player(counter) then
call SetCameraPosition(camerax + 1,cameray + 1)
endif
set counter = counter + 1
endloop
call TriggerSleepAction(0)
call PauseGame(false)
set counter = 0
loop
exitwhen counter > 11
if GetLocalPlayer() == Player(counter) then
set x = GetCameraTargetPositionX()
if x == camerax + 1 then
set output = true
else
set output = false
endif
call SetCameraPosition(camerax,cameray)
endif
set counter = counter + 1
endloop
return output
endfunction
endlibrary