#============================================================================== # ■ Game_Interpreter(分割定義) #------------------------------------------------------------------------------ # 是执行事件命令的解释器。这个类是game_map类, # game_troop类,在game_event类内部使用。 #============================================================================== class Game_Interpreter #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ # ゲーム進行 = #□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□ #============================================================================ # ◆ 脚本:用于脚本 ◆ #============================================================================ #-------------------------------------------------------------------------- # ● 変数の操作(定制) #-------------------------------------------------------------------------- #-------------------------------------------------------------------------- # ● 获取玩家的X坐标 #-------------------------------------------------------------------------- def get_player_x(variable_id = 0) character = get_character(-1) #-1是玩家的意思。 if variable_id > 0 $game_variables[variable_id] = character.x end return character.x end #-------------------------------------------------------------------------- # ● 获取玩家的Y坐标 #-------------------------------------------------------------------------- def get_player_y(variable_id = 0) character = get_character(-1) #-1是玩家的意思。 if variable_id > 0 $game_variables[variable_id] = character.y end return character.y end #-------------------------------------------------------------------------- # ● 获取这个事件的X坐标 #-------------------------------------------------------------------------- def get_this_event_x(variable_id = 0) character = get_character(0) #0表示这个事件。 if variable_id > 0 $game_variables[variable_id] = character.x end return character.x end #-------------------------------------------------------------------------- # ● 获取这个事件的Y坐标 #-------------------------------------------------------------------------- def get_this_event_y(variable_id = 0) character = get_character(0) #0表示这个事件。 if variable_id > 0 $game_variables[variable_id] = character.y end return character.y end #-------------------------------------------------------------------------- # ● 获取包含特定名称的事件的X坐标 #-------------------------------------------------------------------------- def get_name_event_x(name = "",variable_id = 0) event_id = 0 # 搜索相应的事件 events = $game_map.events.values.find_all { |e| e.x == x && e.y == y } event_id = (events.max { |a, b| a.id <=> b.id }).id unless events.empty? character = get_character(event_id) # 変数に代入 if variable_id > 0 $game_variables[variable_id] = character.x $game_map.need_refresh = true end return character.x end #-------------------------------------------------------------------------- # ● 获取包含特定名称的事件的Y坐标 #-------------------------------------------------------------------------- def get_name_event_y(name = "",variable_id = 0) event_id = 0 # 該当するイベントを検索 events = $game_map.events.values.find_all { |e| e.x == x && e.y == y } event_id = (events.max { |a, b| a.id <=> b.id }).id unless events.empty? character = get_character(event_id) # 変数に代入 if variable_id > 0 $game_variables[variable_id] = character.y end return character.y end #-------------------------------------------------------------------------- # ● 开关的操作(自定义) #-------------------------------------------------------------------------- def operate_switches(operate,value,value2=0) if value >= value2 #开关单体操作 case operate when 0 #operate = 0 #开关OFF $game_switches[value] = false when 1 #operate = 1 #开关ON $game_switches[value] = true when 2 #operate = 2 #ON/OFF逆转 $game_switches[value] ^= true #逆转 end else #スイッチ一括操作 case operate when 0 #operate = 0 #尽出OFF for i in value .. value2 # 批量操作循环 $game_switches[i] = false end when 1 #operate = 1 #スイッチをON for i in value .. value2 # 批量操作循环 $game_switches[i] = true end when 2 #operate = 2 #ON/OFFを逆転 for i in value .. value2 # 批量操作循环 $game_switches[i] ^= true #逆転 end end end $game_map.need_refresh = true end #-------------------------------------------------------------------------- # ● 开关的操作 #打开指定ID的开关 #-------------------------------------------------------------------------- def on_switche(switche_id) if switche_id != nil $game_switches[switche_id] = true end $game_map.need_refresh = true end #-------------------------------------------------------------------------- # ● 开关的操作 #关闭指定ID的开关 #-------------------------------------------------------------------------- def off_switche(switche_id) if switche_id != nil $game_switches[switche_id] = false end $game_map.need_refresh = true end #-------------------------------------------------------------------------- # ● 开关的操作 #指定ID的开关的ON/OFF逆转 #-------------------------------------------------------------------------- def change_switche(switche_id) if switche_id != nil $game_switches[switche_id] ^= true #スイッチの逆転 end $game_map.need_refresh = true end #-------------------------------------------------------------------------- # ● 开关的操作 #打开指定ID的开关 #-------------------------------------------------------------------------- def on_multi_switches(value,value2) if value > value2 sw_id = value2 sw_id2 = value else sw_id = value sw_id2 = value2 end for i in sw_id .. sw_id2 $game_switches[i] = true end $game_map.need_refresh = true end #-------------------------------------------------------------------------- # ● スイッチの一括操作 #关闭指定ID的开关 #-------------------------------------------------------------------------- def off_multi_switches(value,value2) if value > value2 sw_id = value2 sw_id2 = value else sw_id = value sw_id2 = value2 end for i in sw_id .. sw_id2 $game_switches[i] = false end $game_map.need_refresh = true end #-------------------------------------------------------------------------- # ● スイッチの一括操作 #指定IDのスイッチのON/OFF逆転 #-------------------------------------------------------------------------- def change_multi_switches(value,value2) if value > value2 sw_id = value2 sw_id2 = value else sw_id = value sw_id2 = value2 end for i in sw_id .. sw_id2 $game_switches[i] ^= true end $game_map.need_refresh = true return true end #-------------------------------------------------------------------------- # ● 获取第一位参与者的ID #-------------------------------------------------------------------------- def get_top_actor_id(variable_id = 0) actor = $game_party.members[0] # 変数に代入 if variable_id > 0 $game_variables[variable_id] = actor.id end return actor.id end #-------------------------------------------------------------------------- # ● 取得最前面的演员的武器ID #-------------------------------------------------------------------------- def get_top_actor_weapon_id(variable_id = 0) actor = $game_party.members[0] # 変数に代入 if variable_id > 0 $game_variables[variable_id] = actor.weapon_id end return actor.weapon_id end #-------------------------------------------------------------------------- # ● 取得第一位演员的名字 #演员的名字一般是字符串。变量的操作,除了代入以外的数量的增减 #进行操作的话会出错,请注意。 #-------------------------------------------------------------------------- def get_top_actor_name(variable_id = 0) actor = $game_party.members[0] # 変数に代入 if variable_id > 0 $game_variables[variable_id] = actor.name end return actor.name end #-------------------------------------------------------------------------- # ● 取得第一位演员的HP #-------------------------------------------------------------------------- def get_top_actor_hp(variable_id = 0) actor = $game_party.members[0] # 変数に代入 if variable_id > 0 $game_variables[variable_id] = actor.hp end return actor.hp end #-------------------------------------------------------------------------- # ● 取得第一位演员的最大HP #-------------------------------------------------------------------------- def get_top_actor_maxhp(variable_id = 0) actor = $game_party.members[0] # 変数に代入 if variable_id > 0 $game_variables[variable_id] = actor.maxhp end return actor.maxhp end #-------------------------------------------------------------------------- # ● 取得第一位参与者的生命值比率(百分比) #-------------------------------------------------------------------------- def get_top_actor_hp_ratio(variable_id = 0) actor = $game_party.members[0] if actor.maxhp != 0 hp_ratio = 100 * actor.hp / actor.maxhp else hp_ratio = 0 end # 変数に代入 if variable_id > 0 $game_variables[variable_id] = hp_ratio end return hp_ratio end #-------------------------------------------------------------------------- # ● 获取首位参与者的MP #-------------------------------------------------------------------------- def get_top_actor_mp(variable_id = 0) actor = $game_party.members[0] # 変数に代入 if variable_id > 0 $game_variables[variable_id] = actor.mp end return actor.mp end #-------------------------------------------------------------------------- # ● 先頭のアクターの最大MPを取得 #-------------------------------------------------------------------------- def get_top_actor_maxmp(variable_id = 0) actor = $game_party.members[0] # 変数に代入 if variable_id > 0 $game_variables[variable_id] = actor.maxmp end return actor.maxmp end #-------------------------------------------------------------------------- # ● 先頭のアクターの攻撃力を取得 #-------------------------------------------------------------------------- def get_top_actor_atk(variable_id = 0) actor = $game_party.members[0] # 変数に代入 if variable_id > 0 $game_variables[variable_id] = actor.atk end return actor.atk end #-------------------------------------------------------------------------- # ● 先頭のアクターの防御力を取得 #-------------------------------------------------------------------------- def get_top_actor_def(variable_id = 0) actor = $game_party.members[0] # 変数に代入 if variable_id > 0 $game_variables[variable_id] = actor.def end return actor.def end #-------------------------------------------------------------------------- # ● アイテムの所持数取得 #-------------------------------------------------------------------------- def get_item_number(item_id,variable_id = 0) if item_id == nil print("アイテムIDを指定してください!IDは直接または変数で指定出来ます!") exit end if item_id > $data_items.size print("アイテムIDがデータベースで指定した範囲を超えました!") exit end if variable_id > 0 #変数に代入 $game_variables[variable_id] = $game_party.item_number($data_items[item_id]) end return $game_party.item_number($data_items[item_id]) end #-------------------------------------------------------------------------- # ● 武器の所持数取得 #-------------------------------------------------------------------------- def get_weapon_number(weapon_id,variable_id = 0) if weapon_id == nil print("武器IDを指定してください!IDは直接または変数で指定出来ます!") exit end if weapon_id > $data_weapons.size print("武器IDがデータベースで指定した範囲を超えました!") exit end if variable_id > 0 #変数に代入 $game_variables[variable_id] = $game_party.item_number($data_weapons[weapon_id]) end return $game_party.item_number($data_weapons[weapon_id]) end #-------------------------------------------------------------------------- # ● 防具の所持数取得 #-------------------------------------------------------------------------- def get_armor_number(armor_id,variable_id = 0) if armor_id == nil print("防具IDを指定してください!IDは直接または変数で指定出来ます!") exit end if armor_id > $data_armors.size print("防具IDがデータベースで指定した範囲を超えました!") exit end if variable_id > 0 #変数に代入 $game_variables[variable_id] = $game_party.item_number($data_armors[armor_id]) end return $game_party.item_number($data_armors[armor_id]) end #-------------------------------------------------------------------------- # ● アイテムボックス内のアイテムの所持数取得 #-------------------------------------------------------------------------- def get_item_number_in_box(item_id,variable_id = 0) if item_id == nil print("アイテムIDを指定してください!IDは直接または変数で指定出来ます!") exit end if item_id > $data_items.size print("アイテムIDがデータベースで指定した範囲を超えました!") exit end if variable_id > 0 #変数に代入 $game_variables[variable_id] = $game_party.keeping_item_number($data_items[item_id]) end return $game_party.keeping_item_number($data_items[item_id]) end #-------------------------------------------------------------------------- # ● アイテムボックス内の武器の所持数取得 #-------------------------------------------------------------------------- def get_weapon_number_in_box(weapon_id,variable_id = 0) if weapon_id == nil print("武器IDを指定してください!IDは直接または変数で指定出来ます!") exit end if weapon_id > $data_weapons.size print("武器IDがデータベースで指定した範囲を超えました!") exit end if variable_id > 0 #変数に代入 $game_variables[variable_id] = $game_party.keeping_item_number($data_weapons[weapon_id]) end return $game_party.keeping_item_number($data_weapons[weapon_id]) end #-------------------------------------------------------------------------- # ● アイテムボックス内の防具の所持数取得 #-------------------------------------------------------------------------- def get_armor_number_in_box(armor_id,variable_id = 0) if armor_id == nil print("防具IDを指定してください!IDは直接または変数で指定出来ます!") exit end if armor_id > $data_armors.size print("防具IDがデータベースで指定した範囲を超えました!") exit end if variable_id > 0 #変数に代入 $game_variables[variable_id] = $game_party.keeping_item_number($data_armors[armor_id]) end return $game_party.keeping_item_number($data_armors[armor_id]) end #-------------------------------------------------------------------------- # ● プレイ時間の取得 #-------------------------------------------------------------------------- def get_playtime(variable_id1=0,variable_id2=0 ,variable_id3=0) total_sec = Graphics.frame_count / Graphics.frame_rate # 変数に代入 if variable_id1 > 0 #時間 $game_variables[variable_id1] = total_sec / 60 / 60 end if variable_id2 > 0 #分 $game_variables[variable_id2] = total_sec / 60 % 60 end if variable_id3 > 0 #秒 $game_variables[variable_id3] = total_sec % 60 end return total_sec end #-------------------------------------------------------------------------- # ● タイマーの操作 #変数指定可能 #-------------------------------------------------------------------------- def set_timer(sec = 0) if min > 0 # 始動 $game_system.timer = sec * Graphics.frame_rate $game_system.timer_working = true end if min == 0 # 停止 $game_system.timer_working = false end return true end #-------------------------------------------------------------------------- # ● タイマー表示 #-------------------------------------------------------------------------- def timer_appear#タイマーの表示 $game_system.timer_hide = false #表示 end #-------------------------------------------------------------------------- # ● タイマー非表示 #-------------------------------------------------------------------------- def timer_hide#タイマーの非表示 $game_system.timer_hide = true #非表示 end #-------------------------------------------------------------------------- # ● タイマーの一時停止 #-------------------------------------------------------------------------- def stop_timer#タイマー一時停止 $game_system.timer_stop end #-------------------------------------------------------------------------- # ● タイマーの再スタート #-------------------------------------------------------------------------- def restart_timer#タイマー再始動 $game_system.timer_start end #-------------------------------------------------------------------------- #■マップ画面でプレイヤーの操作強制無効 RGSS2 DAIpage■と連動 #-------------------------------------------------------------------------- # ● プレイヤーロックのON/OFF #-------------------------------------------------------------------------- def player_lock_on_off $game_player.player_lock end #-------------------------------------------------------------------------- # ● プレイヤーロックのON #-------------------------------------------------------------------------- def player_lock_on#プレイヤーロック開始 $game_player.player_lock_on#プレイヤーロック開始 end #-------------------------------------------------------------------------- # ● プレイヤーロックのOFF #-------------------------------------------------------------------------- def player_lock_off#プレイヤーロック終了 $game_player.player_lock_off#プレイヤーロック終了 end end
QQ截图20230116165412.png (25.2 KB, 下载次数: 11)
QQ截图20230116165534.png (5.59 KB, 下载次数: 9)
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |