赞 | 9 |
VIP | 0 |
好人卡 | 0 |
积分 | 58 |
经验 | 5222 |
最后登录 | 2024-10-3 |
在线时间 | 186 小时 |
Lv4.逐梦者
- 梦石
- 3
- 星屑
- 2774
- 在线时间
- 186 小时
- 注册时间
- 2015-8-18
- 帖子
- 51
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 1262917464 于 2015-11-11 18:32 编辑
{:2_276:}拿到这个脚本后正在疑惑如何判定1P2PQAQ
用 $RMlinkSZK.np == * 注:*是指第几个玩家,如1P *=1- #==============================================================================
- # ■ RMlinkSZK v2.1
- #------------------------------------------------------------------------------
- # RPG MKAER聯機腳本。支持RMXP、RMVX、RMVA(注意:在VA裏不能用事件的按下按鈕,
- # VA中必須用腳本判斷按鈕。)
- # 將本腳本插入到Main之前,若為RMXP請在所有腳本之前插入Hangup 异常根除
- # 腳本,否則將可能導致“脚本已备份”的錯誤。
- # 獲取2P的按鍵輸入請传递np,例:檢測2P的C鍵位Input.press?(Input::C,2)
- # 獲取2P的方向輸入請傳遞np,例:檢測2P的C鍵位Input.dir4(2),同樣支持dir8
- # 獲取當前玩家是1P還是2P,例:$RMlinkSZK.np
- # 獲取當前遊戲人數,例:$RMlinkSZK.mnp
- # 在Game.ini中加入MaxNP=最多聯機人數,可以允許最多4P聯機。
- # 同時獲取任意一方的按鍵就传递0,例:Input.press?(num,0)
- # 交換身體請調用$RMlinkSZK.change_play
- # 判斷除方向鍵外任意鍵位是否被按下,例:Input.anykey?(np)或前一幀Input.anykey_?(np)
- #==============================================================================
- srand(368541734)#請不要在本脚本外調用srand否則將不同步!
- module Input
- def Input.update()
- $RMlinkSZK.update()
- end
- def Input.press?(num,np = 0)
- if np == 0
- for i in 1..$RMlinkSZK.mnp
- return true if $RMlinkSZK.press?(num,i) != 0
- end
- end
- return $RMlinkSZK.press?(num,np) != 0
- end
- def Input.trigger?(num,np = 0)
- if np == 0
- for i in 1..$RMlinkSZK.mnp
- return true if $RMlinkSZK.trigger?(num,i)
- end
- end
- return $RMlinkSZK.trigger?(num,np)
- end
- def Input.repeat?(num,np = 0)
- if np == 0
- for i in 1..$RMlinkSZK.mnp
- return true if $RMlinkSZK.repeat?(num,i)
- end
- end
- return $RMlinkSZK.repeat?(num,np)
- end
- def Input.dir4(np = 1)
- if np == 0
- for i in 1..$RMlinkSZK.mnp
- s = $RMlinkSZK.dir4(i)
- return $RMlinkSZK.dir4(i) if s != 0
- end
- end
- return $RMlinkSZK.dir4(np)
- end
- def Input.dir8(np = 1)
- if np == 0
- for i in 1..$RMlinkSZK.mnp
- s = $RMlinkSZK.dir8(i)
- return $RMlinkSZK.dir8(i) if s != 0
- end
- end
- return $RMlinkSZK.dir8(np)
- end
- def Input.anykey?(np = 0)
- return $RMlinkSZK.anykey?($RMlinkSZK.key,np)
- end
- def Input.anykey_?(np = 0)
- return $RMlinkSZK.anykey?($RMlinkSZK.key_,np)
- end
- end
- class RMlinkSZK
- UP = 0
- LEFT = 0
- DOWN = 65535
- RIGHT = 65535
-
- NODIR = 32511
- TONGSHI = 32767
-
- attr_accessor :np
- attr_accessor :mnp
- attr_accessor :exchange
- attr_accessor :key
- attr_accessor :key_
- attr_accessor :dk
- attr_accessor :dk_
- #--------------------------------------------------------------------------
- # ● 初始化
- #--------------------------------------------------------------------------
- def initialize
- linkdll = "\0" * 260 * 2
- @gpps = Win32API.new("kernel32.dll","GetPrivateProfileStringA","p p p p l p","l")
- @gpps.call("Core","MainPath","",linkdll,linkdll.size,".\\NO$GBAlinkSZK.ini")
- linkdll=linkdll[0,linkdll.index("\000")] + "NO$GBA_SZK.dll"
- @ud = Win32API.new(linkdll,"RM_Update",[],"v")
- @gk = Win32API.new(linkdll,"RM_GetKey",["l"],"l")
- @gx = Win32API.new(linkdll,"RM_GetX",["l"],"l")
- @gy = Win32API.new(linkdll,"RM_GetY",["l"],"l")
- @gnp = Win32API.new(linkdll,"GetNP",[],"l")
- @gmnp = Win32API.new(linkdll,"GetMaxNP",[],"l")
- @gpn = Win32API.new(linkdll,"GetPlayerName",["l","p"],"l")
- @gs = Win32API.new(linkdll,"GetSpeed",["l"],"l")
- @skip_c = 0
- @exchange = 0
- @np = @gnp.call()
- @mnp = @gmnp.call()
- @key = [0,0,0,0]
- @dir = [0,0,0,0]
- @dir8 = [0,0,0,0]
- @dk = [0,0,0,0]
-
- @key_ = [0,0,0,0]
- @dk_ = [0,0,0,0]
-
- @seed = 386212
- @set_seed = true
- end
- def change_play
- @exchange += 1
- @exchange = 0 if @exchange >= @mnp
- @np = @np += 1
- @np = 1 if @np > @mnp
- end
- def update
- for i in 1..@mnp
- @key_[i-1] = @key[i-1]
- @dk_[i-1] = @dk[i-1]
- end
-
- @ud.call()
- for i in 1..@mnp
- z = @exchange + i
- z = 1 if z > @mnp
- z -= 1
- @key[z] = @gk.call(i)
- #dir
- r = 0
- g = 0
- d = @gx.call(i)
- if d != NODIR
- if d == RIGHT
- g |= 1
- r = 6
- else
- if d == TONGSHI
- g |= 2 | 1
- else
- g |= 2
- end
- r = 4
- end
- end
-
- d = @gy.call(i)
- if d != NODIR
- if d == DOWN
- g |= 4
- r = 2
- else
- if d == TONGSHI
- g |= 4 | 8
- else
- g |= 8
- end
- r = 8
- end
- end
- @dir[z] = r
- @dk[z] = g
- end
- @dir8[0] = -1
- #第一次按C时重新设置一次种子从而解决每次启动随机函数都相同的问题
- if @set_seed
- @seed += 1
- if Input.trigger?(Input::C,0)
- @set_seed = false
- srand(Input.trigger?(Input::C,1) ? @seed : -@seed)
- end
- end
- end
- def press?(num,np)
- return case_key(num,@key,@dk,np)
- end
- def case_key(num,k,dk,np)
- np -= 1
- case num
- when Input::C
- return k[np] & 1
- when Input::B
- return k[np] & 2
- when Input::A
- return k[np] & 4
- when Input::Z
- return k[np] & 8
- when Input::L
- return k[np] & 16
- when Input::R
- return k[np] & 32
- when Input::X
- return k[np] & 64
- when Input::Y
- return k[np] & 128
- when Input::RIGHT
- return dk[np] & 1
- when Input::LEFT
- return dk[np] & 2
- when Input::DOWN
- return dk[np] & 4
- when Input::UP
- return dk[np] & 8
- end
- return 0
- end
- def trigger?(num,np)
- return case_key(num,@key,@dk,np) != 0 && case_key(num,@key_,@dk_,np) == 0
- end
- def repeat?(num,np)
- return case_key(num,@key,@dk,np) != 0 && case_key(num,@key_,@dk_,np) == 0
- end
- def anykey?(k,np)
- for i in 1..@mnp
- return true if k[i-1] != 0
- end
- return k[np-1] != 0
- end
-
- def dir4(np)
- return @dir[np-1]
- end
- def get_dir8(np)
- dk = @dk[np-1]
- if dk & 1 != 0
- if dk & 4 != 0
- return 3
- elsif dk & 8 != 0
- return 9
- end
- return 6
- end
-
- if dk & 2 != 0
- if dk & 4 != 0
- return 1
- elsif dk & 8 != 0
- return 7
- end
- return 4
- end
-
- return 8 if dk & 8 != 0
- return 2 if dk & 4 != 0
-
- return 0
- end
- def dir8(np)
- if @dir8[0] == -1
- for i in 1..@mnp
- @dir8[i-1] = get_dir8(i)
- end
- end
- return @dir8[np-1]
- end
- def get_player_name(np)
- text = "\0"*260
- @gpn.call(np|128,text)
- return text[0,text.index("\000")]
- end
- def skip?
- if @skip_c >= @gs.call(20)
- @skip_c = 0
- return false
- else
- @skip_c+=1
- return true
- end
- end
- end
- module DataManager
- #--------------------------------------------------------------------------
- # ● 存档文件的最大数
- #--------------------------------------------------------------------------
- def self.savefile_max
- return 4
- end
- end
- class << Graphics
- alias_method :original_szk_update, :update unless method_defined? :original_szk_update
- def update
- original_szk_update unless $RMlinkSZK.skip?
- end
- end
- $RMlinkSZK = RMlinkSZK.new
复制代码 |
|