赞 | 7 |
VIP | 866 |
好人卡 | 185 |
积分 | 32 |
经验 | 130059 |
最后登录 | 2024-10-29 |
在线时间 | 3618 小时 |
Lv3.寻梦者 双子人
- 梦石
- 0
- 星屑
- 3185
- 在线时间
- 3618 小时
- 注册时间
- 2009-4-4
- 帖子
- 4154
|
- #==============================================================================
- # 本脚本来自www.66RPG.com,使用和转载请保留此信息
- #==============================================================================
- #
- # 全键盘
- # ★、Kboard.press?(键位) 返回是否按下这个键的判断。
- # 比如条件分歧:Kboard.keyboard($R_Key_H)
- # 则当按下键盘H键的时候条件分歧成立
- #
- # ★、Kboard.repeat?(键位) == 1 当连续按住某键返回真,否则为false
- # 比如条件分歧:Kboard.keyb($R_Key_U) == 1
- # 则当持续按下键盘U的时候条件分歧成立
- #
- # ★、Kboard.trigger?(键位,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
-
-
-
- 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
- #==============================================================================
- # ■ Scene_Save
- #------------------------------------------------------------------------------
- # 处理存档画面的类。
- #==============================================================================
- class Scene_Save2 < Scene_File
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize
- super("要保存到这个文件吗?")
- end
- #--------------------------------------------------------------------------
- # ● 确定时的处理
- #--------------------------------------------------------------------------
- def on_decision(filename)
- # 演奏存档 SE
- $game_system.se_play($data_system.save_se)
- # 写入存档数据
- file = File.open(filename, "wb")
- write_save_data(file)
- file.close
- # 如果被事件调用
- if $game_temp.save_calling
- # 清除存档调用标志
- $game_temp.save_calling = false
- # 切换到地图画面
- $scene = Scene_Map.new
- return
- end
- # 切换到菜单画面
- $scene = Scene_Menu.new(4)
- end
- #--------------------------------------------------------------------------
- # ● 取消时的处理
- #--------------------------------------------------------------------------
- def on_cancel
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- # 如果被事件调用
- if $game_temp.save_calling
- # 清除存档调用标志
- $game_temp.save_calling = false
- # 切换到地图画面
- $scene = Scene_Map.new
- return
- end
- # 切换到菜单画面
- $scene = Scene_Map.new
- end
- #--------------------------------------------------------------------------
- # ● 写入存档数据
- # file : 写入用文件对像 (已经打开)
- #--------------------------------------------------------------------------
- def write_save_data(file)
- # 生成描绘存档文件用的角色图形
- characters = []
- for i in 0...$game_party.actors.size
- actor = $game_party.actors[i]
- characters.push([actor.character_name, actor.character_hue])
- end
- # 写入描绘存档文件用的角色数据
- Marshal.dump(characters, file)
- # 写入测量游戏时间用画面计数
- Marshal.dump(Graphics.frame_count, file)
- # 增加 1 次存档次数
- $game_system.save_count += 1
- # 保存魔法编号
- # (将编辑器保存的值以随机值替换)
- $game_system.magic_number = $data_system.magic_number
- # 写入各种游戏对像
- Marshal.dump($game_system, file)
- Marshal.dump($game_switches, file)
- Marshal.dump($game_variables, file)
- Marshal.dump($game_self_switches, file)
- Marshal.dump($game_screen, file)
- Marshal.dump($game_actors, file)
- Marshal.dump($game_party, file)
- Marshal.dump($game_troop, file)
- Marshal.dump($game_map, file)
- Marshal.dump($game_player, file)
- end
- end
- #==============================================================================
- # ■ Scene_Item
- #------------------------------------------------------------------------------
- # 处理物品画面的类。
- #==============================================================================
- class Scene_Item2
- #--------------------------------------------------------------------------
- # ● 主处理
- #--------------------------------------------------------------------------
- def main
- # 生成帮助窗口、物品窗口
- @help_window = Window_Help.new
- @item_window = Window_Item.new
- # 关联帮助窗口
- @item_window.help_window = @help_window
- # 生成目标窗口 (设置为不可见・不活动)
- @target_window = Window_Target.new
- @target_window.visible = false
- @target_window.active = false
- # 执行过度
- Graphics.transition
- # 主循环
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入信息
- Input.update
- # 刷新画面
- update
- # 如果画面切换就中断循环
- if $scene != self
- break
- end
- end
- # 装备过渡
- Graphics.freeze
- # 释放窗口
- @help_window.dispose
- @item_window.dispose
- @target_window.dispose
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- # 刷新窗口
- @help_window.update
- @item_window.update
- @target_window.update
- # 物品窗口被激活的情况下: 调用 update_item
- if @item_window.active
- update_item
- return
- end
- # 目标窗口被激活的情况下: 调用 update_target
- if @target_window.active
- update_target
- return
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面 (物品窗口被激活的情况下)
- #--------------------------------------------------------------------------
- def update_item
- # 按下 B 键的情况下
- if Input.trigger?(Input::B)
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- # 切换到菜单画面
- $scene = Scene_Map.new
- return
- end
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- # 获取物品窗口当前选中的物品数据
- @item = @item_window.item
- # 不使用物品的情况下
- unless @item.is_a?(RPG::Item)
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # 不能使用的情况下
- unless $game_party.item_can_use?(@item.id)
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 效果范围是我方的情况下
- if @item.scope >= 3
- # 激活目标窗口
- @item_window.active = false
- @target_window.x = (@item_window.index + 1) % 2 * 304
- @target_window.visible = true
- @target_window.active = true
- # 设置效果范围 (单体/全体) 的对应光标位置
- if @item.scope == 4 || @item.scope == 6
- @target_window.index = -1
- else
- @target_window.index = 0
- end
- # 效果在我方以外的情况下
- else
- # 公共事件 ID 有效的情况下
- if @item.common_event_id > 0
- # 预约调用公共事件
- $game_temp.common_event_id = @item.common_event_id
- # 演奏物品使用时的 SE
- $game_system.se_play(@item.menu_se)
- # 消耗品的情况下
- if @item.consumable
- # 使用的物品数减 1
- $game_party.lose_item(@item.id, 1)
- # 再描绘物品窗口的项目
- @item_window.draw_item(@item_window.index)
- end
- # 切换到地图画面
- $scene = Scene_Map.new
- return
- end
- end
- return
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面 (目标窗口被激活的情况下)
- #--------------------------------------------------------------------------
- def update_target
- # 按下 B 键的情况下
- if Input.trigger?(Input::B)
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- # 由于物品用完而不能使用的场合
- unless $game_party.item_can_use?(@item.id)
- # 再次生成物品窗口的内容
- @item_window.refresh
- end
- # 删除目标窗口
- @item_window.active = true
- @target_window.visible = false
- @target_window.active = false
- return
- end
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- # 如果物品用完的情况下
- if $game_party.item_number(@item.id) == 0
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # 目标是全体的情况下
- if @target_window.index == -1
- # 对同伴全体应用物品使用效果
- used = false
- for i in $game_party.actors
- used |= i.item_effect(@item)
- end
- end
- # 目标是单体的情况下
- if @target_window.index >= 0
- # 对目标角色应用物品的使用效果
- target = $game_party.actors[@target_window.index]
- used = target.item_effect(@item)
- end
- # 使用物品的情况下
- if used
- # 演奏物品使用时的 SE
- $game_system.se_play(@item.menu_se)
- # 消耗品的情况下
- if @item.consumable
- # 使用的物品数减 1
- $game_party.lose_item(@item.id, 1)
- # 再描绘物品窗口的项目
- @item_window.draw_item(@item_window.index)
- end
- # 再生成目标窗口的内容
- @target_window.refresh
- # 全灭的情况下
- if $game_party.all_dead?
- # 切换到游戏结束画面
- $scene = Scene_Gameover.new
- return
- end
- # 公共事件 ID 有效的情况下
- if @item.common_event_id > 0
- # 预约调用公共事件
- $game_temp.common_event_id = @item.common_event_id
- # 切换到地图画面
- $scene = Scene_Map.new
- return
- end
- end
- # 无法使用物品的情况下
- unless used
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- end
- return
- end
- end
- end
- class Scene_Map
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- alias xy_Key_update update
- def update
- xy_Key_update
- if Kboard.press?($R_Key_K)
- $scene = Scene_Save2.new
- end
- if Kboard.press?($R_Key_Z)
- $scene = Scene_Item2.new
- end
- end
- end
复制代码 应LZ要求,完全整理了脚本……
K打开存档,Z打开物品 |
|