|
我为了判断游戏是在游戏,还是在录像回放的状态下,使用了如下的J
我节选前面一部分使用,但是地图掉线情况严重
后来我发现后面一段数据同步的代码,而且是用GC系统的函数实现的
故求问如何改造成hash系统适用的格式
感谢
原帖地址:
http://bbs.islga.org/read-htm-tid-15768.html
流程大约如下:
1.找到一个存在的玩家。
2.在暂停游戏的情况下轻微调整一下这个玩家的镜头(当然,过程中玩家的操作ui是要锁住的)
3.如果镜头变化和预设的一致,则认为在游戏中,否则在录像中。原理应该是暂停游戏对录像是空白的瞬间,比如暂停游戏后聊天,在录像里表现出来的是那些聊天记录是瞬间一起出来的。
4.以上的数据用的是本地玩家,故需要同步,使用syn函数。不是说syn是将主机数据同步么。。何解?如果选择的是所有存在的玩家,不用同步也是可以的吧。
[jass]//-> IsInGame created by PandaMine with help from Captain Griffein
//This function is what makes it possible for the system not to break replays,
//simply put if your actually playing the game, this function will return false.
//It will return true if the game is being viewed in a replay
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 integer counter = 1
local real currentx
local real currenty
local real x
local real y
local integer validplayer
set udg_AMHS_InGameOutPut = false
//Need to find the a valid player
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 = true
else
set udg_AMHS_InGameOutPut = false
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
local gamecache cache
call FlushGameCache(InitGameCache("cache"))
set cache = InitGameCache("cache")
call EnableUserControl(false)
call TriggerSleepAction(.0)
// sync the value for all players
call StoreBoolean(cache,"sync","1",AMHS_IsInGame())
call TriggerSyncStart()
call SyncStoredBoolean(cache,"sync","1")
call TriggerSyncReady()
set udg_AMHS_InGame = GetStoredBoolean(cache,"sync","1")
call EnableUserControl(true)
call FlushGameCache(cache)
set cache = null
endfunction[/jass] |
|