赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 13512 |
最后登录 | 2022-5-16 |
在线时间 | 140 小时 |
Lv1.梦旅人 茄孓
- 梦石
- 0
- 星屑
- 72
- 在线时间
- 140 小时
- 注册时间
- 2007-5-29
- 帖子
- 956
|
给你贴上脚本!
把这脚本放到main前
即全键盘
- #==============================================================================
- # 本脚本来自www.66RPG.com,使用和转载请保留此信息
- #==============================================================================
- #============================================================================
- # ■ Keyboard Script
- #----------------------------------------------------------------------------
- # By: Cybersam
- # Date: 25/05/05
- # Version 4
- #============================================================================
- # 66对此脚本使用方法的说明(可能不是很准确,反正大体能用):
- #
- # ★、Kboard.keyboard(键位) 返回是否按下这个键的判断。
- # 比如条件分歧:Kboard.keyboard($R_Key_H)
- # 则当按下键盘H键的时候条件分歧成立
- #
- # ★、Kboard.keyb(键位) == 1 当连续按住某键返回真,否则为false
- # 比如条件分歧:Kboard.keyb($R_Key_U) == 1
- # 则当持续按下键盘U的时候条件分歧成立
- #
- # ★、Kboard.key(键位,1) 似乎可以做开关用。按下一次变为true,再按变false
- #============================================================================
- module Kboard
- #==========================================================================
- # 以下是全键盘按键列表
- #--------------------------------------------------------------------------
- $Rmouse_BUTTON_L = 0x01 # left mouse button
- $Rmouse_BUTTON_R = 0x02 # right mouse button
- $Rmouse_BUTTON_M = 0x04 # middle mouse button
- $Rmouse_BUTTON_4 = 0x05 # 4th mouse button
- $Rmouse_BUTTON_5 = 0x06 # 5th mouse button
- #--------------------------------------------------------------------------
- $R_Key_BACK = 0x08 # BACKSPACE key
- $R_Key_TAB = 0x09 # TAB key
- $R_Key_RETURN = 0x0D # ENTER key
- $R_Key_SHIFT = 0x10 # SHIFT key
- $R_Key_CTLR = 0x11 # CTLR key
- $R_Key_ALT = 0x12 # ALT key
- $R_Key_PAUSE = 0x13 # PAUSE key
- $R_Key_CAPITAL = 0x14 # CAPS LOCK key
- $R_Key_ESCAPE = 0x1B # ESC key
- $R_Key_SPACE = 0x20 # SPACEBAR
- $R_Key_PRIOR = 0x21 # PAGE UP key
- $R_Key_NEXT = 0x22 # PAGE DOWN key
- $R_Key_END = 0x23 # END key
- $R_Key_HOME = 0x24 # HOME key
- $R_Key_LEFT = 0x25 # LEFT ARROW key
- $R_Key_UP = 0x26 # UP ARROW key
- $R_Key_RIGHT = 0x27 # RIGHT ARROW key
- $R_Key_DOWN = 0x28 # DOWN ARROW key
- $R_Key_SELECT = 0x29 # SELECT key
- $R_Key_PRINT = 0x2A # PRINT key
- $R_Key_SNAPSHOT = 0x2C # PRINT SCREEN key
- $R_Key_INSERT = 0x2D # INS key
- $R_Key_DELETE = 0x2E # DEL key
- #--------------------------------------------------------------------------
- $R_Key_0 = 0x30 # 0 key
- $R_Key_1 = 0x31 # 1 key
- $R_Key_2 = 0x32 # 2 key
- $R_Key_3 = 0x33 # 3 key
- $R_Key_4 = 0x34 # 4 key
- $R_Key_5 = 0x35 # 5 key
- $R_Key_6 = 0x36 # 6 key
- $R_Key_7 = 0x37 # 7 key
- $R_Key_8 = 0x38 # 8 key
- $R_Key_9 = 0x39 # 9 key
- #--------------------------------------------------------------------------
- $R_Key_A = 0x41 # A key
- $R_Key_B = 0x42 # B key
- $R_Key_C = 0x43 # C key
- $R_Key_D = 0x44 # D key
- $R_Key_E = 0x45 # E key
- $R_Key_F = 0x46 # F key
- $R_Key_G = 0x47 # G key
- $R_Key_H = 0x48 # H key
- $R_Key_I = 0x49 # I key
- $R_Key_J = 0x4A # J key
- $R_Key_K = 0x4B # K key
- $R_Key_L = 0x4C # L key
- $R_Key_M = 0x4D # M key
- $R_Key_N = 0x4E # N key
- $R_Key_O = 0x4F # O key
- $R_Key_P = 0x50 # P key
- $R_Key_Q = 0x51 # Q key
- $R_Key_R = 0x52 # R key
- $R_Key_S = 0x53 # S key
- $R_Key_T = 0x54 # T key
- $R_Key_U = 0x55 # U key
- $R_Key_V = 0x56 # V key
- $R_Key_W = 0x57 # W key
- $R_Key_X = 0x58 # X key
- $R_Key_Y = 0x59 # Y key
- $R_Key_Z = 0x5A # Z key
- #--------------------------------------------------------------------------
- $R_Key_LWIN = 0x5B # Left Windows key (Microsoft Natural keyboard)
- $R_Key_RWIN = 0x5C # Right Windows key (Natural keyboard)
- $R_Key_APPS = 0x5D # Applications key (Natural keyboard)
- #--------------------------------------------------------------------------
- $R_Key_NUMPAD0 = 0x60 # Numeric keypad 0 key
- $R_Key_NUMPAD1 = 0x61 # Numeric keypad 1 key
- $R_Key_NUMPAD2 = 0x62 # Numeric keypad 2 key
- $R_Key_NUMPAD3 = 0x63 # Numeric keypad 3 key
- $R_Key_NUMPAD4 = 0x64 # Numeric keypad 4 key
- $R_Key_NUMPAD5 = 0x65 # Numeric keypad 5 key
- $R_Key_NUMPAD6 = 0x66 # Numeric keypad 6 key
- $R_Key_NUMPAD7 = 0x67 # Numeric keypad 7 key
- $R_Key_NUMPAD8 = 0x68 # Numeric keypad 8 key
- $R_Key_NUMPAD9 = 0x69 # Numeric keypad 9 key
- $R_Key_MULTIPLY = 0x6A # Multiply key (*)
- $R_Key_ADD = 0x6B # Add key (+)
- $R_Key_SEPARATOR = 0x6C # Separator key
- $R_Key_SUBTRACT = 0x6D # Subtract key (-)
- $R_Key_DECIMAL = 0x6E # Decimal key
- $R_Key_DIVIDE = 0x6F # Divide key (/)
- #--------------------------------------------------------------------------
- $R_Key_F1 = 0x70 # F1 key
- $R_Key_F2 = 0x71 # F2 key
- $R_Key_F3 = 0x72 # F3 key
- $R_Key_F4 = 0x73 # F4 key
- $R_Key_F5 = 0x74 # F5 key
- $R_Key_F6 = 0x75 # F6 key
- $R_Key_F7 = 0x76 # F7 key
- $R_Key_F8 = 0x77 # F8 key
- $R_Key_F9 = 0x78 # F9 key
- $R_Key_F10 = 0x79 # F10 key
- $R_Key_F11 = 0x7A # F11 key
- $R_Key_F12 = 0x7B # F12 key
- #--------------------------------------------------------------------------
- $R_Key_NUMLOCK = 0x90 # NUM LOCK key
- $R_Key_SCROLL = 0x91 # SCROLL LOCK key
- #--------------------------------------------------------------------------
- $R_Key_LSHIFT = 0xA0 # Left SHIFT key
- $R_Key_RSHIFT = 0xA1 # Right SHIFT key
- $R_Key_LCONTROL = 0xA2 # Left CONTROL key
- $R_Key_RCONTROL = 0xA3 # Right CONTROL key
- $R_Key_L_ALT = 0xA4 # Left ALT key
- $R_Key_R_ALT = 0xA5 # Right ALT key
- #--------------------------------------------------------------------------
- $R_Key_SEP = 0xBC # , key
- $R_Key_DASH = 0xBD # - key
- $R_Key_DOTT = 0xBE # . Key
- #--------------------------------------------------------------------------
- GetKeyState = Win32API.new("user32","GetAsyncKeyState",['I'],'I')
- GetKeyboardState = Win32API.new("user32","GetKeyState",['I'],'I')
- GetSetKeyState = Win32API.new("user32","SetKeyboardState",['I'],'I')
- #--------------------------------------------------------------------------
- module_function
- #--------------------------------------------------------------------------
- def keyb(rkey)
- if GetKeyState.call(rkey) != 0
- return 1
- end
- return 0
- end
- #--------------------------------------------------------------------------
- def keyboard(rkey)
- GetKeyState.call(rkey) & 0x01 == 1 #
- end
- #--------------------------------------------------------------------------
- def key(rkey, key = 0)
- GetKeyboardState.call(rkey) & 0x01 == key #
- end
- end
- #==============================================================================
- # 本脚本来自www.66RPG.com,使用和转载请保留此信息
- #==============================================================================
- #1、Kboard.press?(key) 同 Input.press?(key)
- #2、Kboard.repeat?(key) 同 Input.repeat?(key)
- #3、Kboard.trigger?(key) 同 Input.trigger?(key) #$R_Key
- module Kboard
- module_function
-
- @R_Key_Hash = {}
- @R_Key_Repeat = {}
-
- GetKeyState = Win32API.new("user32","GetAsyncKeyState",['I'],'I')
- def press?(rkey)
- return GetKeyState.call(rkey) != 0
- end
-
- def repeat?(rkey)
- result = GetKeyState.call(rkey)
- if result != 0
- if @R_Key_Repeat[rkey].nil?
- @R_Key_Repeat[rkey] = 0
- return true
- end
- @R_Key_Repeat[rkey] += 1
- else
- @R_Key_Repeat[rkey] = nil
- @R_Key_Hash[rkey] = 0
- end
- if !@R_Key_Repeat[rkey].nil? and @R_Key_Repeat[rkey] > 4 # 4乃准确数字
- @R_Key_Repeat[rkey] = 0
- return true
- else
- return false
- end
- end
-
- def trigger?(rkey)
- result = GetKeyState.call(rkey)
- if @R_Key_Hash[rkey] == 1 and result != 0
- return false
- end
- if result != 0
- @R_Key_Hash[rkey] = 1
- return true
- else
- @R_Key_Hash[rkey] = 0
- return false
- end
- end
-
- end
-
复制代码
然后 在Game_player里修改如下
- #==============================================================================
- # ■ Game_Player
- #------------------------------------------------------------------------------
- # 处理主角的类。事件启动的判定、以及地图的滚动等功能。
- # 本类的实例请参考 $game_player。
- #==============================================================================
- class Game_Player < Game_Character
- #--------------------------------------------------------------------------
- # ● 恒量
- #--------------------------------------------------------------------------
- CENTER_X = (320 - 16) * 4 # 画面中央的 X 坐标 * 4
- CENTER_Y = (240 - 16) * 4 # 画面中央的 Y 坐标 * 4
- #--------------------------------------------------------------------------
- # ● 可以通行判定
- # x : X 坐标
- # y : Y 坐标
- # d : 方向 (0,2,4,6,8) ※ 0 = 全方向不能通行的情况判定 (跳跃用)
- #--------------------------------------------------------------------------
- def passable?(x, y, d)
- # 求得新的坐标
- new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
- new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
- # 坐标在地图外的情况下
- unless $game_map.valid?(new_x, new_y)
- # 不能通行
- return false
- end
- # 调试模式为 ON 并且 按下 CTRL 键的情况下
- if $DEBUG and Input.press?(Input::CTRL)
- # 可以通行
- return true
- end
- super
- end
- #--------------------------------------------------------------------------
- # ● 像通到画面中央一样的设置地图的显示位置
- #--------------------------------------------------------------------------
- def center(x, y)
- max_x = ($game_map.width - 20) * 128
- max_y = ($game_map.height - 15) * 128
- $game_map.display_x = [0, [x * 128 - CENTER_X, max_x].min].max
- $game_map.display_y = [0, [y * 128 - CENTER_Y, max_y].min].max
- end
- #--------------------------------------------------------------------------
- # ● 向指定的位置移动
- # x : X 座標
- # y : Y 座標
- #--------------------------------------------------------------------------
- def moveto(x, y)
- super
- # 自连接
- center(x, y)
- # 生成遇敌计数
- make_encounter_count
- end
- #--------------------------------------------------------------------------
- # ● 增加步数
- #--------------------------------------------------------------------------
- def increase_steps
- super
- # 不是强制移动路线的场合
- unless @move_route_forcing
- # 增加步数
- $game_party.increase_steps
- # 步数是偶数的情况下
- if $game_party.steps % 2 == 0
- # 检查连续伤害
- $game_party.check_map_slip_damage
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 获取遇敌计数
- #--------------------------------------------------------------------------
- def encounter_count
- return @encounter_count
- end
- #--------------------------------------------------------------------------
- # ● 生成遇敌计数
- #--------------------------------------------------------------------------
- def make_encounter_count
- # 两种颜色震动的图像
- if $game_map.map_id != 0
- n = $game_map.encounter_step
- @encounter_count = rand(n) + rand(n) + 1
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- # 同伴人数为 0 的情况下
- if $game_party.actors.size == 0
- # 清除角色的文件名及对像
- @character_name = ""
- @character_hue = 0
- # 分支结束
- return
- end
- # 获取带头的角色
- actor = $game_party.actors[0]
- # 设置角色的文件名及对像
- @character_name = actor.character_name
- @character_hue = actor.character_hue
- # 初始化不透明度和合成方式子
- @opacity = 255
- @blend_type = 0
- end
- #--------------------------------------------------------------------------
- # ● 同位置的事件启动判定
- #--------------------------------------------------------------------------
- def check_event_trigger_here(triggers)
- result = false
- # 事件执行中的情况下
- if $game_system.map_interpreter.running?
- return result
- end
- # 全部事件的循环
- for event in $game_map.events.values
- # 事件坐标与目标一致的情况下
- if event.x == @x and event.y == @y and triggers.include?(event.trigger)
- # 跳跃中以外的情况下、启动判定是同位置的事件
- if not event.jumping? and event.over_trigger?
- event.start
- result = true
- end
- end
- end
- return result
- end
- #--------------------------------------------------------------------------
- # ● 正面事件的启动判定
- #--------------------------------------------------------------------------
- def check_event_trigger_there(triggers)
- result = false
- # 事件执行中的情况下
- if $game_system.map_interpreter.running?
- return result
- end
- # 计算正面坐标
- new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
- new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
- # 全部事件的循环
- for event in $game_map.events.values
- # 事件坐标与目标一致的情况下
- if event.x == new_x and event.y == new_y and
- triggers.include?(event.trigger)
- # 跳跃中以外的情况下、启动判定是正面的事件
- if not event.jumping? and not event.over_trigger?
- event.start
- result = true
- end
- end
- end
- # 找不到符合条件的事件的情况下
- if result == false
- # 正面的元件是计数器的情况下
- if $game_map.counter?(new_x, new_y)
- # 计算 1 元件里侧的坐标
- new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
- new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
- # 全事件的循环
- for event in $game_map.events.values
- # 事件坐标与目标一致的情况下
- if event.x == new_x and event.y == new_y and
- triggers.include?(event.trigger)
- # 跳跃中以外的情况下、启动判定是正面的事件
- if not event.jumping? and not event.over_trigger?
- event.start
- result = true
- end
- end
- end
- end
- end
- return result
- end
- #--------------------------------------------------------------------------
- # ● 接触事件启动判定
- #--------------------------------------------------------------------------
- def check_event_trigger_touch(x, y)
- result = false
- # 事件执行中的情况下
- if $game_system.map_interpreter.running?
- return result
- end
- # 全事件的循环
- for event in $game_map.events.values
- # 事件坐标与目标一致的情况下
- if event.x == x and event.y == y and [1,2].include?(event.trigger)
- # 跳跃中以外的情况下、启动判定是正面的事件
- if not event.jumping? and not event.over_trigger?
- event.start
- result = true
- end
- end
- end
- return result
- end
- #--------------------------------------------------------------------------
- # ● 画面更新
- #--------------------------------------------------------------------------
- def update
- # 本地变量记录移动信息
- last_moving = moving?
- # 移动中、事件执行中、强制移动路线中、
- # 信息窗口一个也不显示的时候
- unless moving? or $game_system.map_interpreter.running? or
- @move_route_forcing or $game_temp.message_window_showing
- # 如果方向键被按下、主角就朝那个方向移动
- # case Input.dir4
- ################################
- if Kboard.trigger?($R_Key_S) or Kboard.press?($R_Key_S)
- move_down
- end
- if Kboard.trigger?($R_Key_A) or Kboard.press?($R_Key_A)
- move_left
- end
- if Kboard.trigger?($R_Key_D) or Kboard.press?($R_Key_D)
- move_right
- end
- if Kboard.trigger?($R_Key_W) or Kboard.press?($R_Key_W)
- move_up
- end
- end
- ##############################3
- # end
- # 本地变量记忆坐标
- last_real_x = @real_x
- last_real_y = @real_y
- super
- # 角色向下移动、画面上的位置在中央下方的情况下
- if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
- # 画面向下卷动
- $game_map.scroll_down(@real_y - last_real_y)
- end
- # 角色向左移动、画面上的位置在中央左方的情况下
- if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
- # 画面向左卷动
- $game_map.scroll_left(last_real_x - @real_x)
- end
- # 角色向右移动、画面上的位置在中央右方的情况下
- if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
- # 画面向右卷动
- $game_map.scroll_right(@real_x - last_real_x)
- end
- # 角色向上移动、画面上的位置在中央上方的情况下
- if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
- # 画面向上卷动
- $game_map.scroll_up(last_real_y - @real_y)
- end
- # 不在移动中的情况下
- unless moving?
- # 上次主角移动中的情况
- if last_moving
- # 与同位置的事件接触就判定为事件启动
- result = check_event_trigger_here([1,2])
- # 没有可以启动的事件的情况下
- if result == false
- # 调试模式为 ON 并且按下 CTRL 键的情况下除外
- unless $DEBUG and Input.press?(Input::CTRL)
- # 遇敌计数下降
- if @encounter_count > 0
- @encounter_count -= 1
- end
- end
- end
- end
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- # 判定为同位置以及正面的事件启动
- check_event_trigger_here([0])
- check_event_trigger_there([0,1,2])
- end
- end
- end
- end
复制代码
这样以后好象就有8方向了
|
|