偷窃脚本地图事件设置.PNG (103.73 KB, 下载次数: 21)
地图事件上的设置
191.09 KB, 下载次数: 16
第2张地图从左边进入
# encoding: utf-8 module Taeckle # 2 is the id of global variable which saves all npcs' stolen data Stolen_Data_VID = 2 class Stolen_Data def initialize @data = {} end def setup(index, force) if force || @data[index].nil? @data[index] = [] yield @data[index] end end def update(index) data = @data[index] if data.empty? return :empty_storage end # ----------------------------------------- # 定义处理 data 的方式 # 偷窃成功时操作 $game_party 以增加道具 # ----------------------------------------- # ----------------------------------------- return true end end end class Interpreter def steal_setup(vid = Taeckle::Stolen_Data_VID, &block) if $game_variables[vid] == 0 $game_variables[vid] = Taeckle::Stolen_Data.new end index = $game_map.map_id * 1000 + @event_id $game_variables[vid].setup(index, false, &block) end def steal_update(vid = Taeckle::Stolen_Data_VID) index = $game_map.map_id * 1000 + @event_id $game_variables[vid].update(index) end end =begin # 直接在事件脚本里调用 steal_setup 和 steal_update # usage : # 1. 向 data 里添加数据,数据类型任意 steal_setup { |data| data << [1, 2] data << [3, 4] } # 2. 必须在 steal_setup 后使用,执行动作 @steal_result = steal_update() # 3. 在条件分歧里判断结果以执行不同的分支 @steal_result == :empty_storage =end
guoxiaomi 发表于 2021-10-26 15:51
# encoding: utf-8
module Taeckle
# 2 is the id of global variable which saves all npcs' stolen dat ...
guoxiaomi 发表于 2021-10-26 15:51
# encoding: utf-8
module Taeckle
# 2 is the id of global variable which saves all npcs' stolen dat ...
#============================================================================== # ■ Game_System #------------------------------------------------------------------------------ # 处理系统附属数据的类。也可执行诸如 BGM 管理之类的功能。本类的实例请参考 # $game_system 。 #============================================================================== class Game_System #-------------------------------------------------------------------------- # ● 定义实例变量 #-------------------------------------------------------------------------- attr_reader :map_interpreter # 地图事件用解释程序 attr_reader :battle_interpreter # 战斗事件用解释程序 attr_accessor :timer # 计时器 attr_accessor :timer_working # 计时器执行中的标志 attr_accessor :save_disabled # 禁止存档 attr_accessor :menu_disabled # 禁止菜单 attr_accessor :encounter_disabled # 禁止遇敌 attr_accessor :message_position # 文章选项 显示位置 attr_accessor :message_frame # 文章选项 窗口外关 attr_accessor :save_count # 存档次数 attr_accessor :magic_number # 魔法编号 attr_accessor :npc_carry_items # NPC携带的物品集合 #-------------------------------------------------------------------------- # ● 初始化对像 #-------------------------------------------------------------------------- def initialize @map_interpreter = Interpreter.new(0, true) @battle_interpreter = Interpreter.new(0, false) @timer = 0 @timer_working = false @save_disabled = false @menu_disabled = false @encounter_disabled = false @message_position = 2 @message_frame = 0 @save_count = 0 @magic_number = 0 @npc_carry_items = Hash["偷窃对象1"=>[[1,11],[2,12],[3,13]], "偷窃对象2"=>[[5,15],[6,16],[7,17]], "guoxiaomi"=>[[2],[3],[5,5,5]], "待定"=>[[],[],[]]] end #-------------------------------------------------------------------------- # ● 演奏 BGM # bgm : 演奏的 BGM #-------------------------------------------------------------------------- def bgm_play(bgm) @playing_bgm = bgm if bgm != nil and bgm.name != "" Audio.bgm_play("Audio/BGM/" + bgm.name, bgm.volume, bgm.pitch) else Audio.bgm_stop end Graphics.frame_reset end #-------------------------------------------------------------------------- # ● 停止 BGM #-------------------------------------------------------------------------- def bgm_stop Audio.bgm_stop end #-------------------------------------------------------------------------- # ● BGM 的淡出 # time : 淡出时间 (秒) #-------------------------------------------------------------------------- def bgm_fade(time) @playing_bgm = nil Audio.bgm_fade(time * 1000) end #-------------------------------------------------------------------------- # ● 记忆 BGM #-------------------------------------------------------------------------- def bgm_memorize @memorized_bgm = @playing_bgm end #-------------------------------------------------------------------------- # ● 还原 BGM #-------------------------------------------------------------------------- def bgm_restore bgm_play(@memorized_bgm) end #-------------------------------------------------------------------------- # ● 演奏 BGS # bgs : 演奏的 BGS #-------------------------------------------------------------------------- def bgs_play(bgs) @playing_bgs = bgs if bgs != nil and bgs.name != "" Audio.bgs_play("Audio/BGS/" + bgs.name, bgs.volume, bgs.pitch) else Audio.bgs_stop end Graphics.frame_reset end #-------------------------------------------------------------------------- # ● BGS 的淡出 # time : 淡出时间 (秒) #-------------------------------------------------------------------------- def bgs_fade(time) @playing_bgs = nil Audio.bgs_fade(time * 1000) end #-------------------------------------------------------------------------- # ● 记忆 BGS #-------------------------------------------------------------------------- def bgs_memorize @memorized_bgs = @playing_bgs end #-------------------------------------------------------------------------- # ● 还原 BGS #-------------------------------------------------------------------------- def bgs_restore bgs_play(@memorized_bgs) end #-------------------------------------------------------------------------- # ● ME 的演奏 # me : 演奏的 ME #-------------------------------------------------------------------------- def me_play(me) if me != nil and me.name != "" Audio.me_play("Audio/ME/" + me.name, me.volume, me.pitch) else Audio.me_stop end Graphics.frame_reset end #-------------------------------------------------------------------------- # ● SE 的演奏 # se : 演奏的 SE #-------------------------------------------------------------------------- def se_play(se) if se != nil and se.name != "" Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch) end end #-------------------------------------------------------------------------- # ● 停止 SE #-------------------------------------------------------------------------- def se_stop Audio.se_stop end #-------------------------------------------------------------------------- # ● 获取演奏中 BGM #-------------------------------------------------------------------------- def playing_bgm return @playing_bgm end #-------------------------------------------------------------------------- # ● 获取演奏中 BGS #-------------------------------------------------------------------------- def playing_bgs return @playing_bgs end #-------------------------------------------------------------------------- # ● 获取窗口外观的文件名 #-------------------------------------------------------------------------- def windowskin_name if @windowskin_name == nil return $data_system.windowskin_name else return @windowskin_name end end #-------------------------------------------------------------------------- # ● 设置窗口外观的文件名 # windowskin_name : 新的窗口外观文件名 #-------------------------------------------------------------------------- def windowskin_name=(windowskin_name) @windowskin_name = windowskin_name end #-------------------------------------------------------------------------- # ● 获取战斗 BGM #-------------------------------------------------------------------------- def battle_bgm if @battle_bgm == nil return $data_system.battle_bgm else return @battle_bgm end end #-------------------------------------------------------------------------- # ● 设置战斗 BGM # battle_bgm : 新的战斗 BGM #-------------------------------------------------------------------------- def battle_bgm=(battle_bgm) @battle_bgm = battle_bgm end #-------------------------------------------------------------------------- # ● 获取战斗结束的 BGM #-------------------------------------------------------------------------- def battle_end_me if @battle_end_me == nil return $data_system.battle_end_me else return @battle_end_me end end #-------------------------------------------------------------------------- # ● 设置战斗结束的 BGM # battle_end_me : 新的战斗结束 BGM #-------------------------------------------------------------------------- def battle_end_me=(battle_end_me) @battle_end_me = battle_end_me end #-------------------------------------------------------------------------- # ● 刷新画面 #-------------------------------------------------------------------------- def update # 计时器减 1 if @timer_working and @timer > 0 @timer -= 1 end end end
#------------------------------------------------------------------------- # ★★★★★★ #------------------------------------------------------------------------- module Stolen STEAL_SKILL_ID = 1 # 偷盗特技id end #------------------------------------------------------------------------- # ★★★★★★ #------------------------------------------------------------------------- class Scene_Map attr_accessor :spriteset end #------------------------------------------------------------------------- # ★★★★★★ #------------------------------------------------------------------------- class Window_Npc_Item < Window_Selectable #-------------------------------------------------------------------------- # ● 初始化对像 #-------------------------------------------------------------------------- def initialize(item) super(224, 80, 188+100, 320) @column_max = 1 @item = item @item_max = @item.size self.height = @item.size*32+32 self.y = (480-self.height)/2 self.opacity = 160 refresh self.index = 0 end #-------------------------------------------------------------------------- def item return @item[self.index] end #-------------------------------------------------------------------------- def refresh if self.contents != nil self.contents.dispose self.contents = nil end if @item_max > 0 self.contents = Bitmap.new(width - 32, row_max * 32) for i in 0...@item_max draw_item(i) end end end #-------------------------------------------------------------------------- def draw_item(index) item = @item[index] x = 4 y = index * 32 bitmap = RPG::Cache.icon(item.icon_name) self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24)) self.contents.draw_text(x + 28, y, 212, 32, item.name, 0) end end #------------------------------------------------------------------------- # ★★★★★★ #------------------------------------------------------------------------- class Game_Party attr_reader :stealexp attr_accessor :stealnpc alias initialize_old initialize def initialize initialize_old @stealexp = 0 @stealnpc = {} end def add_sexp(n) @stealexp = [[@stealexp + n, 0].max, 100].min end end #------------------------------------------------------------------------- # ★★★★★★ #------------------------------------------------------------------------- class Interpreter def judge @npc_item = [] @npc_item.clear if @list[0].code == 108 if @list[0].parameters[0].split(/:/)[0] == "可偷盗对象" unless @list[0].parameters[0].split(/:/)[1] == nil @npc_item = eval(@list[0].parameters[0].split(/:/)[1]) end end end end #偷盗 def steal unless judge_skill @message_waiting = true $game_temp.message_proc = Proc.new { @message_waiting = false } $game_temp.message_text = "无人会偷盗技能!" return true end if @npc_item.size == 0 @message_waiting = true $game_temp.message_proc = Proc.new { @message_waiting = false } $game_temp.message_text = "对方已无任何道具." return true end win = Window_Npc_Item.new(@npc_item) loop do $game_map.update $scene.spriteset.update Graphics.update Input.update win.update if Input.trigger?(Input::B) win.dispose $game_system.se_play($data_system.cancel_se) return true end if Input.trigger?(Input::C) win.dispose $game_map.events[@event_id].animation_id = $data_skills[Stolen::STEAL_SKILL_ID].animation2_id for i in 1..$data_animations[$data_skills[Stolen::STEAL_SKILL_ID].animation2_id].frame_max*4 Graphics.update $game_map.update $game_player.update $scene.spriteset.update end if successful?(@list[2].parameters[0].split(/,/)[1].split(/:/)[1].to_i) $game_party.add_sexp(2) #偷盗经验值上升 item = win.item case item when RPG::Item $game_party.gain_item(item.id, 1) g_npc=$game_system.npc_carry_items[$game_map.events[@event_id].name.split(/,/)[0].to_s][0] g_npc.delete_at g_npc.index item.id #这里最好用指令arr.delete_at arr.index,用delete的话会把所有item.id号物品全删了 when RPG::Weapon $game_party.gain_weapon(item.id, 1) g_npc=$game_system.npc_carry_items[$game_map.events[@event_id].name.split(/,/)[0].to_s][1] g_npc.delete_at g_npc.index item.id when RPG::Armor $game_party.gain_armor(item.id, 1) g_npc=$game_system.npc_carry_items[$game_map.events[@event_id].name.split(/,/)[0].to_s][2] g_npc.delete_at g_npc.index item.id end @wait_count = 1 return true else #$game_party.add_sexp(1) #偷盗经验值上升 @message_waiting = true $game_temp.message_proc = Proc.new { @message_waiting = false } $game_temp.message_text = "盗取失败,被发现了!" Audio.se_play("Audio/SE/"+"Glass1",80,100) @wait_count = 1 if $data_troops[@list[3].parameters[0].split(/:/)[1].to_i] != nil $game_temp.battle_abort = true $game_temp.battle_calling = true $game_temp.battle_troop_id = @list[3].parameters[0].split(/:/)[1].to_i $game_temp.battle_can_escape = false $game_temp.battle_can_lose = false current_indent = @list[@index].indent $game_temp.battle_proc = Proc.new { |n| @branch[current_indent] = n } end end break end # end of C键 end #end of loop do end #end of def #是否有“盗窃”技能判断 def judge_skill actor = $game_party.actors for i in 0...actor.size if actor[i].skills.include?(Stolen::STEAL_SKILL_ID) return true end end return false end #取得物品 def get_item temp_item = [] #生成物品列表 for i in 0...$game_system.npc_carry_items[$game_map.events[@event_id].name.split(/,/)[0].to_s][0].size temp_item.push($data_items[$game_system.npc_carry_items[$game_map.events[@event_id].name.split(/,/)[0].to_s][0][i].to_i]) end #生成武器列表 for i in 0...$game_system.npc_carry_items[$game_map.events[@event_id].name.split(/,/)[0].to_s][1].size temp_item.push($data_weapons[$game_system.npc_carry_items[$game_map.events[@event_id].name.split(/,/)[0].to_s][1][i].to_i]) end #生成防具列表 for i in 0...$game_system.npc_carry_items[$game_map.events[@event_id].name.split(/,/)[0].to_s][2].size temp_item.push($data_armors[$game_system.npc_carry_items[$game_map.events[@event_id].name.split(/,/)[0].to_s][2][i].to_i]) end #返回物品数组 return temp_item end #偷盗成功判断 def successful?(n) # n - 对象npc的过失率, 这里暂时设定为100%成功 s_rate = 101 return rand(101) < s_rate end #------------------------------------------ end
taeckle简单的偷窃脚本_version_0.2.rar
194.66 KB, 下载次数: 8
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |