找回密码
 点一下
查看: 1107|回复: 5

怎么判断是在看录像还是在进行游戏

[复制链接]
发表于 2008-6-26 12:52:12 | 显示全部楼层 |阅读模式

有的脚本,比如反MH的,MS在看录像的时候,也会起作用,导致看录像的人也会掉,不知道有什么好的解决方法呢??请各位指点一下,谢谢了
发表于 2008-6-26 12:55:17 | 显示全部楼层
转KOOK大人的帖子
[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]


流程大约如下:
1.找到一个存在的玩家。
2.在暂停游戏的情况下轻微调整一下这个玩家的镜头(当然,过程中玩家的操作ui是要锁住的)
3.如果镜头变化和预设的一致,则认为在游戏中,否则在录像中。原理应该是暂停游戏对录像是空白的瞬间,比如暂停游戏后聊天,在录像里表现出来的是那些聊天记录是瞬间一起出来的。
4.以上的数据用的是本地玩家,故需要同步,使用syn函数。不是说syn是将主机数据同步么。。何解?如果选择的是所有存在的玩家,不用同步也是可以的吧。
回复

使用道具 举报

 楼主| 发表于 2008-6-26 12:58:56 | 显示全部楼层
多谢楼上的
回复

使用道具 举报

发表于 2008-6-26 13:26:32 | 显示全部楼层
syn同步在某些时候显然不只是同步主机数据,话说这个是在看某人的存档系统同步本地存档数据时注意到的,具体的没研究,主要现在也不想干这些了
回复

使用道具 举报

发表于 2008-6-26 15:28:45 | 显示全部楼层
这个我联机试过,有很多问题
回复

使用道具 举报

发表于 2008-6-26 15:32:39 | 显示全部楼层
如果直接调用AMHS_IsInGame函数,似乎没有作用,如果另外开线程调用,有可能不同步
刚才仔细看了下,我写的那个和2楼贴的还是有些不同,先测试了再发言
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 点一下

本版积分规则

Archiver|移动端|小黑屋|地精研究院

GMT+8, 2024-7-20 20:17 , Processed in 0.047012 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表