#encoding:utf-8 #============================================================================== # ■ 技能物品说明增强 蓝本:wyongcan # 修改 :VIPArcher # # 改动说明: # 改用新的帮助窗口和新定义draw_text_vip方法来增强兼容性 # 更改初始化数据时机以支持跳过标题 # 追加对普通物品和技能的说明内容 # 修改了对帮助窗口行数的计算以支持控制符 # 加上了各种颜色的设置,具体更高级的玩法自己领悟吧 # 改成光标不动一段时间后才会出现帮助窗口 # # -- 本脚本来自 [url]https://rpg.blue[/url] 使用或转载请保留以上信息。 #============================================================================== $VIPArcherScript ||= {};$VIPArcherScript[:help_ex] = 20141007 $VIPArcherScript[:equip_limit] = false #是否使用了后知后觉的装备能力限制 class << DataManager alias_method :vip_load_database, :load_database #-------------------------------------------------------------------------- # ● 读取数据库 #-------------------------------------------------------------------------- def load_database vip_load_database VIPArcher::Equipplus.equiphelpready end end module VIPArcher;end module VIPArcher::Equipplus TIME = 90 #帮助窗口自动出现的时间(单位帧 Font_Name = Font.default_name # 推荐"微软雅黑" Font_Size = 14 # "微软雅黑"的话就20号字体 UP = 24 #能力值提升颜色编号 DOWN = 25 #能力值下降颜色编号 VIP = 14 #特殊能力颜色编号 MP = 23 TP = 29 CODE ={ 11 => "属性抗性", 12 => "弱化抗性", 13 => "状态抗性", 14 => "状态免疫", 21 => "普通能力", 22 => "添加能力", 23 => "特殊能力", 31 => "附带属性", 32 => "附带状态", 33 => "攻击速度", 34 => "添加攻击次数", 41 => "添加技能类型", 42 => "禁用技能类型", 43 => "添加技能", 44 => "禁用技能", 51 => "可装备武器类型", 52 => "可装备护甲类型", 53 => "固定装备", 54 => "禁用装备", 55 => "装备风格", 61 => "添加行动次数", 62 => "特殊标志", 63 => "消失效果", 64 => "队伍能力"} #特殊标志 FLAG ={ 0 => "自动战斗", 1 => "擅长防御", 2 => "保护弱者", 3 => "特技专注"} #技能效果范围 SCOPE ={ 0 => "无", 1 => "单个敌人", 2 => "全体敌人", 3 => "一个随机敌人", 4 => "两个随机敌人", 5 => "三个随机敌人", 6 => "四个随机敌人", 7 => "单个队友", 8 => "全体队友", 9 => "单个队友(濒死)", 10 => "全体队友(濒死)", 11 => "使用者" } #技能命中类型 HIT ={ 0 => "必定命中", 1 => "物理攻击", 2 => "魔法攻击"} #使用限制 OCCASION ={ 0 => "随时可用", 1 => "仅战斗中", 2 => "仅菜单中", 3 => "不能使用"} #添加能力 XPARAM ={ 0 => "物理命中几率:", 1 => "物理闪避几率:", 2 => "必杀几率:", 3 => "必杀闪避几率:", 4 => "魔法闪避几率:", 5 => "魔法反射几率:", 6 => "物理反击几率:", 7 => "体力值再生速度:", 8 => "魔力值再生速度:", 9 => "特技值再生速度:"} #特殊能力 SPARAM ={ 0 => "受到攻击的几率", 1 => "防御效果比率", 2 => "恢复效果比率", 3 => "药理知识", 4 => "MP消费率", 5 => "TP消耗率", 6 => "物理伤害加成", 7 => "魔法伤害加成", 8 => "地形伤害加成", 9 => "经验获得加成"} #装备风格 require 装备风格扩展脚本 SLOT_TYPE ={ 0 => "普通", 1 => "双持武器", 2 => "索爷三刀流", 3 => "NPC", 4 => "233", 5 => "论坛@的BUG好烦啊"} #队伍能力 PARTY_ABILITY ={ 0 => "遇敌几率减半", 1 => "随机遇敌无效", 2 => "敌人偷袭无效", 3 => "先制攻击几率上升", 4 => "获得金钱数量双倍", 5 => "物品掉落几率双倍"} #伤害类型 DAMAGE_TYPE = { 0 => "无", 1 => "体力值伤害", 2 => "魔力值伤害", 3 => "体力值恢复", 4 => "魔力值恢复", 5 => "体力值吸收", 6 => "魔力值吸收"} #普通能力 #这只是个示范,你也可以依照个人喜好对这些用语添加颜色控制符 @params ={ 0 => "\\c[17]最大HP", 1 => "\\c[16]最大MP", 2 => "\\c[20]物攻", 3 => "\\c[21]物防", 4 => "\\c[30]魔攻", 5 => "\\c[31]魔防", 6 => "\\c[14]敏捷", 7 => "\\c[17]幸运"} #我举例技能类型的原因就是因为它 短 @skill_types = { # 这个和下面equiphelpready里注释掉的做的是一样的事 # 只是下面是读取数据库添加用语,这里是手动枚举 1 => "\\c[1]特技", 2 => "\\c[2]魔法", 3 => "\\c[3]绝技", 4 => "\\c[5]卖萌"} #初始化数据,当然如果你要用上面那样的控制符改变颜色的话 #欢迎枚举格式就是上面这样用Hash,用ID做键把用语对应起来 def self.equiphelpready params = $data_system.terms.params elements = $data_system.elements weapon_types = $data_system.weapon_types armor_types = $data_system.armor_types etypes = $data_system.terms.etypes skill_types = $data_system.skill_types @states ||= {} @params ||= {} @weapon_types ||= {} @armor_types ||= {} @etypes ||= {} @skill_types ||= {} @elements ||= {} skill_types.each_with_index{|x,y| @skill_types[y] = x if !x.nil?} if @skill_types == {} $data_states.each{|x| @states[x.id] = x.name if !x.nil?} if @states == {} elements.each_with_index{|x,y| @elements[y] = x if !x.nil?} if @elements == {} weapon_types.each_with_index{|x,y| @weapon_types[y] = x if !x.nil?} if @weapon_types == {} armor_types.each_with_index{|x,y| @armor_types[y] = x if !x.nil?} if @armor_types == {} etypes.each_with_index{|x,y| @etypes[y] = x} if @etypes == {} params.each_with_index{|x,y| @params[y] = x} if @params == {} end #获取装备帮助内容 def self.getequiphelp(equip) help = "" param = [] help += "\\c[16]装备位置:#{Vocab::etype(equip.etype_id)}\\c[0]\n" if $VIPArcherScript[:equip_limit] #装备能力限制 help += "\\c[16]等级需求:#{equip.level_limit}\n" if equip.level_limit > 0 param_limit = [] for i in 0..7 if equip.params_limit(i) != 0 help += "\\c[16]#{@params[i]}需求:#{equip.params_limit(i)}\\c[0]\n" end end end equip.params.each_with_index{|x,y| param.push([@params[y],x])} param = param.select{|x| x[1] != 0} param.each{|x| help += "\\c[#{x[1]>0? UP : DOWN}]#{x[0]}:\\c[#{x[1]>0? UP : DOWN}]#{"﹢"if x[1]>0}#{x[1].to_int.to_s}\\c[0]\n"} features = equip.features featuresparam = [] featuresparam.push features.select{|x| x.code == 21} featuresparam.push features.select{|x| x.code == 22} featuresparam.push features.select{|x| x.code == 23} featuresparam[0].each{|x| help += "\\c[#{x.value<0?DOWN: UP}]#{@params[x.data_id]}#{x.value<0?"﹣":"﹢"}#{(x.value.abs*100).to_i}%\n"} featuresparam[1].each{|x| help += "\\c[#{x.value<0?DOWN: UP}]#{XPARAM[x.data_id]}#{x.value<0?"﹣":"﹢"}#{(x.value.abs*100).to_i}%\n"} featuresparam[2].each{|x| help += "\\c[#{x.value<0?DOWN: UP}]#{SPARAM[x.data_id]}#{x.value<0?"﹣":"﹢"}#{(x.value.abs*100).to_i}%\n"} if $VIPArcherScript[:slot_type] help += "\\c[#{VIP}]#{CODE[55]}:#{SLOT_TYPE[$1.to_i]}\\c[0]\n" if equip.note =~ /<slot_type\s*[:](.*)>/i else features.select{|x| x.code == 55}.each{|x| help += "\\c[#{VIP}]#{CODE[x.code]}:双持武器\\c[0]\n"} end features.select{|x| x.code == 11}.each{|x| help += "\\c[#{UP}]#{CODE[x.code]}:#{@elements[x.data_id]}×#{(x.value*100).to_i}%\\c[0]\n"} features.select{|x| x.code == 12}.each{|x| help += "\\c[#{UP}]#{CODE[x.code]}:#{@params[x.data_id]}×#{(x.value*100).to_i}%\\c[0]\n"} features.select{|x| x.code == 13}.each{|x| help += "\\c[#{UP}]#{CODE[x.code]}:#{@states[x.data_id]}×#{(x.value*100).to_i}%\\c[0]\n"} features.select{|x| x.code == 14}.each{|x| help += "\\c[#{VIP}]#{CODE[x.code]}:#{@states[x.data_id]}\\c[0]\n"} features.select{|x| x.code == 31}.each{|x| help += "\\c[#{UP}]#{CODE[x.code]}:#{@elements[x.data_id]}\\c[0]\n"} features.select{|x| x.code == 32}.each{|x| help += "\\c[#{UP}]#{CODE[x.code]}:#{@states[x.data_id]}#{(x.value*100).to_i}%\\c[0]\n"} features.select{|x| x.code == 33}.each{|x| help += "\\c[#{x.value>0? UP : DOWN}]#{CODE[x.code]}:#{x.value}\\c[0]\n"} features.select{|x| x.code == 34}.each{|x| help += "\\c[#{UP}]#{CODE[x.code]}:#{x.value}\\c[0]\n"} features.select{|x| x.code == 41}.each{|x| help += "\\c[#{UP}]#{CODE[x.code]}:#{@skill_types[x.data_id]}\\c[0]\n"} features.select{|x| x.code == 42}.each{|x| help += "\\c[#{DOWN}]#{CODE[x.code]}:#{@skill_types[x.data_id]}\\c[0]\n"} features.select{|x| x.code == 43}.each{|x| help += "\\c[#{UP}]#{CODE[x.code]}:#{$data_skills[x.data_id].name}\\c[0]\n"} features.select{|x| x.code == 44}.each{|x| help += "\\c[#{DOWN}]#{CODE[x.code]}:#{$data_skills[x.data_id].name}\\c[0]\n"} features.select{|x| x.code == 51}.each{|x| help += "\\c[#{UP}]#{CODE[x.code]}:#{@weapon_types[x.data_id]}\\c[0]\n"} features.select{|x| x.code == 52}.each{|x| help += "\\c[#{UP}]#{CODE[x.code]}:#{@armor_types[x.data_id]}\\c[0]\n"} features.select{|x| x.code == 53}.each{|x| help += "\\c[#{DOWN}]#{CODE[x.code]}:#{@etypes[x.data_id]}\\c[0]\n"} features.select{|x| x.code == 54}.each{|x| help += "\\c[#{DOWN}]#{CODE[x.code]}:#{@etypes[x.data_id]}\\c[0]\n"} features.select{|x| x.code == 61}.each{|x| help += "\\c[#{VIP}]#{CODE[x.code]}:#{x.value}\\c[0]\n"} features.select{|x| x.code == 62}.each{|x| help += "\\c[#{VIP}]#{CODE[x.code]}:#{FLAG[x.data_id]}\\c[0]\n"} features.select{|x| x.code == 64}.each{|x| help += "\\c[#{VIP}]#{CODE[x.code]}:#{PARTY_ABILITY[x.data_id]}\\c[0]\n"} help end #获取技能帮助内容 def self.getskillhelp(skill) help = "" effects = skill.effects damage = skill.damage r = [skill.required_wtype_id1,skill.required_wtype_id2] help += "\\c[16]消耗:\\c[#{MP}]MP:#{skill.mp_cost.to_s} \\c[#{TP}]TP:#{skill.tp_cost.to_s}\\c[0]\n" if skill.mp_cost > 0 && skill.tp_cost > 0 help += "\\c[16]消耗:\\c[#{MP}]MP:#{skill.mp_cost.to_s}\\c[0]\n" if skill.mp_cost > 0 && skill.tp_cost <= 0 help += "\\c[16]消耗:\\c[#{TP}]TP:#{skill.tp_cost.to_s}\\c[0]\n" if skill.tp_cost > 0 && skill.mp_cost <= 0 help += "\\c[#{skill.speed<0?DOWN: UP}]速度修正:#{skill.speed}\\c[0]\n" if skill.speed != 0 help += "\\c[#{DOWN}]成功率:#{skill.success_rate}%\\c[0]\n" if skill.success_rate != 100 help += "\\c[16]类型:#{HIT[skill.hit_type]}\\c[0]\n" help += "\\c[16]范围:#{SCOPE[skill.scope]}\\c[0]\n" if skill.scope != 0 help += "\\c[16]效果:#{@elements[damage.element_id]}#{DAMAGE_TYPE[damage.type]}\\c[0]\n" if damage.type != 0 effects.select{|x| x.code == 31}.each{|x| help += "\\c[#{UP}]强化:#{@params[x.data_id]} #{x.value1.to_i}回合\\c[0]\n"} effects.select{|x| x.code == 32}.each{|x| help += "\\c[#{UP}]弱化:#{@params[x.data_id]} #{x.value1.to_i}回合\\c[0]\n"} effects.select{|x| x.code == 33}.each{|x| help += "\\c[#{UP}]解除:强化#{@params[x.data_id]}\n"} effects.select{|x| x.code == 34}.each{|x| help += "\\c[#{UP}]解除:弱化#{@params[x.data_id]}\n"} effects.select{|x| x.code == 21}.each{|x| help += "\\c[#{UP}]附加:#{x.data_id == 0 ? "普通攻击" : @states[x.data_id]} #{(x.value1*100).to_i}%\\c[0]\n"} effects.select{|x| x.code == 22}.each{|x| help += "\\c[#{UP}]解除:#{@states[x.data_id]} #{(x.value1*100).to_i}%\\c[0]\n"} effects.select{|x| x.code == 41}.each{|x| help += "\\c[#{VIP}]特殊效果:撤退\n"} effects.select{|x| x.code == 42}.each{|x| help += "\\c[#{UP}]提升:#{@params[x.data_id]}#{x.value1.to_i}点\\c[0]\n"} effects.select{|x| x.code == 43}.each{|x| help += "\\c[#{VIP}]学会:#{$data_skills[x.data_id].name}\\c[0]\n"} help += "\\c[16]场合:#{OCCASION[skill.occasion]}\n" help += "\\c[#{DOWN}]限制:#{$data_system.weapon_types[r[0]] if r[0] != 0} #{$data_system.weapon_types[r[1]] if r[1] != 0}\\c[0]\n" if r != [0,0] help end #获取道具帮助内容 def self.getitemhelp(item) help = "" effects = item.effects damage = item.damage help += "\\c[16]类型:\\c[#{VIP}]#{"贵重物品 "if item.itype_id != 1}\\c[#{DOWN}]#{item.consumable ? "消耗品":"非消耗品"}\\c[0]\n" help += "\\c[16]范围:#{SCOPE[item.scope]}\\c[0]\n" if item.scope != 0 help += "\\c[16]效果:#{@elements[damage.element_id]}#{DAMAGE_TYPE[damage.type]}\\c[0]\n" if damage.type != 0 effects.select{|x| x.code == 31}.each{|x| help += "\\c[#{UP}]强化:#{@params[x.data_id]} #{x.value1.to_i}回合\\c[0]\n"} effects.select{|x| x.code == 32}.each{|x| help += "\\c[#{UP}]弱化:#{@params[x.data_id]} #{x.value1.to_i}回合\\c[0]\n"} effects.select{|x| x.code == 33}.each{|x| help += "\\c[#{UP}]解除:强化#{@params[x.data_id]}\\c[0]\n"} effects.select{|x| x.code == 34}.each{|x| help += "\\c[#{UP}]解除:弱化#{@params[x.data_id]}\\c[0]\n"} effects.select{|x| x.code == 21}.each{|x| help += "\\c[#{UP}]附加:#{x.data_id == 0 ? "普通攻击" : @states[x.data_id]} #{(x.value1*100).to_i}%\\c[0]\n"} effects.select{|x| x.code == 22}.each{|x| help += "\\c[#{UP}]解除:#{@states[x.data_id]} #{(x.value1*100).to_i}%\\c[0]\n"} effects.select{|x| x.code == 41}.each{|x| help += "\\c[#{VIP}]特殊效果:撤退\n"} effects.select{|x| x.code == 42}.each{|x| help += "\\c[#{VIP}]提升:#{@params[x.data_id]}#{x.value1.to_i}点\\c[0]\n"} effects.select{|x| x.code == 43}.each{|x| help += "\\c[#{VIP}]学会:#{$data_skills[x.data_id].name}\\c[0]\n"} help += "\\c[16]场合:#{OCCASION[item.occasion]}\\c[0]\n" help end #计算行数(有些字体的汉字和[字母,数字,符号]的宽度不同, #有可能会照成行数计算不对,尽量用宽度相同的字体吧) def self.getline(text,maxtext) text_new = "" xtext = [] line = 0 text.each_line{|x| text_new += x.gsub(/\\\S\[\d+\]/i){}} #去掉控制符 text_new.each_line{|x| xtext.push x.gsub(/\n/){}} #去掉换行符 xtext.each{|x| line += (x.size / (maxtext.to_f + 1).to_i) + 1} line end end #============================================================================== # ■ Window_Help_Ex #------------------------------------------------------------------------------ # 加强显示特技和物品等的说明 #============================================================================== class Window_Help_Ex < Window_Base include VIPArcher::Equipplus #-------------------------------------------------------------------------- # ● 初始化对象 #-------------------------------------------------------------------------- def initialize(line_number = 0) super(0, 0, 210, 0) self.z = 150 contents.font.size = Font_Size [url=home.php?mod=space&uid=134219]@Time[/url] = 0 end #-------------------------------------------------------------------------- # ● 设置内容 #-------------------------------------------------------------------------- def set_text(text) @text = text refresh end #-------------------------------------------------------------------------- # ● 清除 #-------------------------------------------------------------------------- def clear set_text("") end #-------------------------------------------------------------------------- # ● 更新帮助位置 #-------------------------------------------------------------------------- def uppos(index,rect,window) self.height = fitting_height_vip(VIPArcher::Equipplus.getline(@xtext,13)) create_contents contents.font.name = Font_Name contents.font.size = Font_Size rect.x -= window.ox rect.y -= window.oy ax = rect.x + rect.width + 10 ax = rect.x - self.width + 10 if ax + self.width > window.width + 10 ax += window.x ax = 0 if ax < 0 ay = rect.y + rect.height ay = rect.y - self.height if ay + self.height > window.height ay += window.y ay = 0 if ay < 0 self.x = ax self.y = ay set_text(@xtext) @time = TIME self.show self.openness = 0 end #-------------------------------------------------------------------------- # ● 设置物品 # item : 技能、物品等 #-------------------------------------------------------------------------- def set_item(item) if item == nil set_text("") return end @xtext = "" if $VIPArcherScript[:itemcolor] # require 物品描绘颜色脚本 @xtext = "\\c[16]名称:\\c[#{VIPArcher::ItemColor::Color_Lv[item.color]}]" + "#{item.name} #{item.color if item.color != 0}#{"★" if item.color != 0}\\c[0]\n" else @xtext = "\\c[16]名称:\\c[0]#{item.name}\n" end @xtext += "\\c[16]介绍:\\c[0]#{item.description}\n" if $VIPArcherScript[:load] # require 队伍负重脚本 @xtext += "\\c[16]售价:#{item.price} 重量:#{item.load}\\c[0]\n" else @xtext += item.price == 0 ? "\\c[16]售价:\\c[14]无法出售\\c[0]\n":"\\c[16]售价:#{item.price}\\c[0]\n" end if item.is_a?(RPG::EquipItem) || item.is_a?(RPG::Item) @xtext += VIPArcher::Equipplus.getequiphelp(item) if item.is_a?(RPG::EquipItem) @xtext += VIPArcher::Equipplus.getskillhelp(item) if item.is_a?(RPG::Skill) @xtext += VIPArcher::Equipplus.getitemhelp(item) if item.is_a?(RPG::Item) if $VIPArcherScript[:exdrop_rate] # require 队伍掉率扩展 @xtext += "\\c[#{$2.to_i > 0 ? UP : DOWN}]#{$1}掉率: #{$2}%\\c[0]\n" if item.note =~ /<(\W+)掉率:\s*([0-9+.-]+)%>/i end if item.is_a?(RPG::EquipItem) || item.is_a?(RPG::Skill) @xtext = @xtext[0,@text.size - 2] if @xtext[@xtext.size - 2,2] == "\n" end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh contents.clear self.hide if @text == "" draw_text_vip(4, 0, @text,width,40,false) end #-------------------------------------------------------------------------- # ● 更新画面 #-------------------------------------------------------------------------- def update super @time -= 1 if @time > 0 self.open if @time == 0 end end class Window_Base < Window #-------------------------------------------------------------------------- # ● 计算窗口显示指定行数时的应用高度2************************* #-------------------------------------------------------------------------- def fitting_height_vip(line_number) line_number * contents.font.size + standard_padding * 2 end # draw_text_ex的增强,使其可以自动换行 原作者:叶子 修改:wyongcan #-------------------------------------------------------------------------- # ● 绘制带有控制符的文本内容 # 如果传递了width参数的话,会自动换行 #-------------------------------------------------------------------------- def draw_text_vip(x, y, text, width = nil,textwidth = nil,normalfont = true) reset_font_settings if normalfont == true text = convert_escape_characters(text) pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)} if width != nil pos[:height] = contents.font.size pos[:width] = width pos[:textwidth] = textwidth end process_character(text.slice!(0, 1), text, pos) until text.empty? end #-------------------------------------------------------------------------- # ● 文字的处理 # c : 文字 # text : 绘制处理中的字符串缓存(字符串可能会被修改) # pos : 绘制位置 {:x, :y, :new_x, :height} #-------------------------------------------------------------------------- def process_character(c, text, pos) case c when "\r" # 回车 return when "\n" # 换行 process_new_line(text, pos) when "\f" # 翻页 process_new_page(text, pos) when "\e" # 控制符 process_escape_character(obtain_escape_code(text), text, pos) else # 普通文字 pos[:textwidth] == nil ? text_width = text_size(c).width : text_width = pos[:textwidth] if pos[:width] != nil && pos[:x] - pos[:new_x] + text_width > pos[:width] process_new_line(text, pos) end process_normal_character(c, pos) end end #-------------------------------------------------------------------------- # ● 处理换行文字 #-------------------------------------------------------------------------- alias vip_20141007_process_new_line process_new_line def process_new_line(text, pos) vip_20141007_process_new_line(text, pos) pos[:height] = contents.font.size if pos[:width] != nil end end #============================================================================== # ■ 设置帮助增强窗口 #============================================================================== class Window_Selectable < Window_Base attr_reader :help_ex_window #-------------------------------------------------------------------------- # ● 调用帮助窗口的更新方法 #-------------------------------------------------------------------------- alias help_ex_call_update_help call_update_help def call_update_help help_ex_call_update_help update_ex_help if active && @help_ex_window end #-------------------------------------------------------------------------- # ● 更新帮助内容 #-------------------------------------------------------------------------- def update_ex_help @help_ex_window.set_item(item) if @help_ex_window if index != -1 && item != nil @help_ex_window.uppos(index,item_rect(index),self) end end #-------------------------------------------------------------------------- # ● 设置帮助增强窗口 #-------------------------------------------------------------------------- def help_ex_window=(help_ex_window) @help_ex_window = help_ex_window end end #============================================================================== # ■ 在各场景处理帮助窗口 #============================================================================== class Scene_Base #-------------------------------------------------------------------------- # ● 生成帮助增强窗口 #-------------------------------------------------------------------------- def create_help_ex @help_ex_window = Window_Help_Ex.new @help_ex_window .viewport = @viewport @item_window.help_ex_window = @help_ex_window if @item_window @slot_window.help_ex_window = @help_ex_window if @slot_window @skill_window.help_ex_window = @help_ex_window if @skill_window @buy_window.help_ex_window = @help_ex_window if @buy_window @sell_window.help_ex_window = @help_ex_window if @sell_window end end #道具栏 class Scene_Item < Scene_ItemBase #-------------------------------------------------------------------------- # ● 开始处理 #-------------------------------------------------------------------------- alias help_ex_start start def start help_ex_start create_help_ex end #-------------------------------------------------------------------------- # ● 物品“取消” #-------------------------------------------------------------------------- alias help_ex_on_item_cancel on_item_cancel def on_item_cancel help_ex_on_item_cancel @help_ex_window.hide end end #装备栏 class Scene_Equip < Scene_MenuBase #-------------------------------------------------------------------------- # ● 开始处理 #-------------------------------------------------------------------------- alias help_ex_start start def start help_ex_start create_help_ex end #-------------------------------------------------------------------------- # ● 装备栏“取消” #-------------------------------------------------------------------------- alias help_ex_on_slot_cancel on_slot_cancel def on_slot_cancel help_ex_on_slot_cancel @help_ex_window.hide end end #技能栏 class Scene_Skill < Scene_ItemBase #-------------------------------------------------------------------------- # ● 开始处理 #-------------------------------------------------------------------------- alias help_ex_start start def start help_ex_start create_help_ex end #-------------------------------------------------------------------------- # ● 物品“确定” #-------------------------------------------------------------------------- alias help_ex_on_item_ok on_item_ok def on_item_ok help_ex_on_item_ok @help_ex_window.hide end #-------------------------------------------------------------------------- # ● 物品“取消” #-------------------------------------------------------------------------- alias help_ex_on_item_cancel on_item_cancel def on_item_cancel help_ex_on_item_cancel @help_ex_window.hide end end #战斗界面 class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # ● 开始处理 #-------------------------------------------------------------------------- alias help_ex_start start def start help_ex_start create_help_ex end #-------------------------------------------------------------------------- # ● 技能“确定” #-------------------------------------------------------------------------- alias help_ex_on_skill_ok on_skill_ok def on_skill_ok help_ex_on_skill_ok @help_ex_window.hide end #-------------------------------------------------------------------------- # ● 技能“取消” #-------------------------------------------------------------------------- alias help_ex_on_skill_cancel on_skill_cancel def on_skill_cancel help_ex_on_skill_cancel @help_ex_window.hide end #-------------------------------------------------------------------------- # ● 物品“确定” #-------------------------------------------------------------------------- alias help_ex_on_item_ok on_item_ok def on_item_ok help_ex_on_item_ok @help_ex_window.hide end #-------------------------------------------------------------------------- # ● 物品“取消” #-------------------------------------------------------------------------- alias help_ex_on_item_cancel on_item_cancel def on_item_cancel help_ex_on_item_cancel @help_ex_window.hide end end #商店界面 class Scene_Shop < Scene_MenuBase #-------------------------------------------------------------------------- # ● 开始处理 #-------------------------------------------------------------------------- alias help_ex_start start def start help_ex_start create_help_ex end #-------------------------------------------------------------------------- # ● 买入“确定” #-------------------------------------------------------------------------- alias help_ex_on_buy_ok on_buy_ok def on_buy_ok help_ex_on_buy_ok @help_ex_window.hide end #-------------------------------------------------------------------------- # ● 买入“取消” #-------------------------------------------------------------------------- alias help_ex_on_buy_cancel on_buy_cancel def on_buy_cancel help_ex_on_buy_cancel @help_ex_window.hide end #-------------------------------------------------------------------------- # ● 卖出“确定” #-------------------------------------------------------------------------- alias help_ex_on_sell_ok on_sell_ok def on_sell_ok help_ex_on_sell_ok @help_ex_window.hide end #-------------------------------------------------------------------------- # ● 卖出“取消” #-------------------------------------------------------------------------- alias help_ex_on_sell_cancel on_sell_cancel def on_sell_cancel help_ex_on_sell_cancel @help_ex_window.hide end end
#============================================================================== # ■ 此脚本来自 [url]www.66rpg.com[/url] #------------------------------------------------------------------------------ # 名称:横版战斗模板 # 作者:后知后觉([email][email protected][/email]) # 版本:v1.7 2012-02-09 # 使用协议:在保留此脚本相关信息的情况下 # 可任意使用、修改及修改后发布. # 如是修改后发布.请在作者标注那里加上 某某某改 等信息 # 感谢你来这里谈谈你对这个工程的看法或报告BUG. # [url]http://rpg.blue/thread-216673-1-1.html[/url] # 使用说明: # 请来发布帖查看: # [url]http://rpg.blue/thread-216673-1-1.html[/url] #============================================================================== module Hzhj module HorizontalBattleSystem # 取得参战角色的最大数.如果要改大.需要在下面的坐标设置里增加对应的条目 MaxBattleMembers = 4 ActorsBattlePosition = {} # 设置角色战斗图形的坐标 # 等号左边的[]号里面的1 2 3 4 表示角色在队伍里的位置 # 等号右边的[]号里面的两个数字分别表示 X坐标 Y坐标 # 每次进入战斗的时候都会以这里设置的信息作为初始化位置. # 如果你把上面的 MaxBattleMembers 改大了.比如改成了 5. # 那么你需要在下面新增一行代码设置队伍中第5位置的坐标. # 就像这样 ActorsBattlePosition[5] = [X坐标, Y坐标] ActorsBattlePosition[1] = [378, 228] ActorsBattlePosition[2] = [422, 272] ActorsBattlePosition[3] = [466, 228] ActorsBattlePosition[4] = [510, 272] # 设置伤害值图形的色相 取值范围 0~360 DamageBitmapHue = 0 # 伤害值分段显示的标志SE文件名 DamageSectionDisplaySEName = "DamageSection" # 动画 Z 坐标值默认变化量 DefaultAniAddZ = 768 # 状态动画 Z 坐标值默认变化量 DefaultLoopAniAddZ = 20 # 战斗中角色的面向 ActorDirection = 4 # 真位移的帧数 RealMoveDuration = 20 # 真位移移动前会计算目标点.会获取攻防双方战斗图大小来进行计算. # 下面2个是对战斗图 width height 进行修正. # 为正则扩大 为负则缩小.单位 像素. # 一般来说不必修改.只有像梦幻群侠传那种战斗图四边有很多透明区域时才修正. RealMoveBmpAddW = 0 RealMoveBmpAddH = 0 # 使用技能、物品的过程默认使用RMVA模式 # 在该模式下.本脚本提供的很多功能受限无法使用. DefaultUseRmvaMode = false # 默认显示敌人的HP条、MP条、TP条 DefaultDisplayEnemyBar = true # 一张战斗图中有几个样式(帧、格) DynamicPatternMax = 1 # 一张战斗图中的一个样式持续多少帧 OnePatternDuration = 15 # 角色使用战斗死亡图形 UseActorDeadGraphic = false # 敌人使用战斗死亡图形 UseEnemyDeadGraphic = false # 使用挨打图形 UseBeatenGraphic = false # 挨打图形维持帧数 BeatenGraphicDuration = 30 # 是否使用角色防御图 只有同时使用了挨打图.此项才有效. UseActorGuardGraphic = false # 是否使用敌人防御图 只有同时使用了挨打图.此项才有效. UseEnemyGuardGraphic = false # 角色是否使用挨打SE UseActorWBSE = false # 敌人是否使用挨打SE UseEnemyWBSE = false # 角色是否使用防御SE UseActorGDSE = false # 敌人是否使用防御SE UseEnemyGDSE = false end end class RPG::Actor < RPG::BaseItem def battler_name return @battler_name unless @battler_name.nil? if /@btname\[(.+?)\]/ =~ @note return (@battler_name = $1.clone) else return (@battler_name = "#{@name}_#{@nickname}") end end def battler_hue return @battler_hue unless @battler_hue.nil? if /@bthue\[([0-9]+?)\]/ =~ @note return (@battler_hue = $1.to_i.abs) else return (@battler_hue = 0) end end attr_writer :battler_name attr_writer :battler_hue end #============================================================================== # ■ Game_Actor #============================================================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # ● 属性(新增定义) #-------------------------------------------------------------------------- attr_writer :battler_name # 战斗图形文件名 attr_writer :battler_hue # 战斗图形色相 #-------------------------------------------------------------------------- # ● 设置(追加定义) #-------------------------------------------------------------------------- alias hzhj_old_setup_for_add_actor_battle_graphic setup def setup(actor_id) hzhj_old_setup_for_add_actor_battle_graphic(actor_id) @battler_name = actor.battler_name @battler_hue = actor.battler_hue end #-------------------------------------------------------------------------- # ● 是否使用活动块(重定义) #-------------------------------------------------------------------------- def use_sprite? return true end #-------------------------------------------------------------------------- # ● 取得战斗画面 X 坐标(新增定义) #-------------------------------------------------------------------------- def screen_x return ActorsBattlePosition[index + 1][0] end #-------------------------------------------------------------------------- # ● 取得战斗画面 Y 坐标(新增定义) #-------------------------------------------------------------------------- def screen_y return ActorsBattlePosition[index + 1][1] end #-------------------------------------------------------------------------- # ● 取得战斗画面 Z 坐标(新增定义) #-------------------------------------------------------------------------- def screen_z return real_screen_y + 100 end end #============================================================================== # ■ Game_Enemy #============================================================================== class Game_Enemy < Game_Battler #-------------------------------------------------------------------------- # ● 属性(新增定义) #-------------------------------------------------------------------------- attr_writer :battler_name # 战斗图形文件名 attr_writer :battler_hue # 战斗图形色相 #-------------------------------------------------------------------------- # ● 取得战斗画面 Z 坐标(重定义) #-------------------------------------------------------------------------- def screen_z return real_screen_y + 100 end end #============================================================================== # ■ Game_Party #============================================================================== class Game_Party < Game_Unit include Hzhj::HorizontalBattleSystem #-------------------------------------------------------------------------- # ● 取得参战角色的最大数(重定义) #-------------------------------------------------------------------------- def max_battle_members return MaxBattleMembers end end class RPG::Animation def wait_subject_duration return @wait_subject_duration unless @wait_subject_duration.nil? if /@w\[(\-??\d+?)\]/ =~ @name @wait_subject_duration = $1.to_i else @wait_subject_duration = 0 end return @wait_subject_duration end attr_writer :wait_subject_duration end class RPG::UsableItem < RPG::BaseItem include Hzhj::HorizontalBattleSystem def animation1_id return @animation1_id unless @animation1_id.nil? if /@a1id\[(\d+?)\]/i =~ @note return (@animation1_id = $1.to_i) else return (@animation1_id = 0) end end def wljn return @wljn unless @wljn.nil? if /@wljn/i =~ @note return (@wljn = true) else return (@wljn = false) end end def rmva_mode return @rmva_mode unless @rmva_mode.nil? if /@rmva/i =~ @note return (@rmva_mode = !DefaultUseRmvaMode) else return (@rmva_mode = DefaultUseRmvaMode) end end attr_writer :animation1_id attr_writer :wljn attr_writer :rmva_mode end class RPG::Weapon < RPG::EquipItem def animation1_id return @animation1_id unless @animation1_id.nil? if /@a1id\[(\d+?)\]/ =~ @note return (@animation1_id = $1.to_i) else return (@animation1_id = 0) end end attr_writer :animation1_id end class RPG::Enemy < RPG::BaseItem def animation1_id return @animation1_id unless @animation1_id.nil? if /@a1id\[(\d+?)\]/ =~ @note return (@animation1_id = $1.to_i) else return (@animation1_id = 0) end end def animation2_id return @animation2_id unless @animation2_id.nil? if /@a2id\[(\d+?)\]/ =~ @note return (@animation2_id = $1.to_i) else return (@animation2_id = 0) end end def animation3_id return @animation3_id unless @animation3_id.nil? if /@a3id\[(\d+?)\]/ =~ @note return (@animation3_id = $1.to_i) else return (@animation3_id = 0) end end attr_writer :animation1_id attr_writer :animation2_id attr_writer :animation3_id end #============================================================================== # ■ Game_Actor #============================================================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # ● 取得普通攻击的行动方动画 ID (新增定义) #-------------------------------------------------------------------------- def animation1_id if dual_wield? return weapons[0].animation1_id if weapons[0] return weapons[1] ? weapons[1].animation1_id : 0 else return weapons[0] ? weapons[0].animation1_id : 0 end end end #============================================================================== # ■ Game_Enemy #============================================================================== class Game_Enemy < Game_Battler #-------------------------------------------------------------------------- # ● 取得普通攻击的行动方动画 ID (新增定义) #-------------------------------------------------------------------------- def animation1_id return enemy.animation1_id end #-------------------------------------------------------------------------- # ● 取得普通攻击的动画 ID (新增定义) #-------------------------------------------------------------------------- def atk_animation_id1 return enemy.animation2_id end #-------------------------------------------------------------------------- # ● 取得普通攻击的动画 ID (二刀流:武器2)(新增定义) #-------------------------------------------------------------------------- def atk_animation_id2 return enemy.animation3_id end end #============================================================================== # ■ Scene_Battle #============================================================================== class Scene_Battle < Scene_Base include Hzhj::HorizontalBattleSystem #-------------------------------------------------------------------------- # ● 使用技能/物品(重定义) #-------------------------------------------------------------------------- def use_item item = @subject.current_action.item @log_window.display_use_item(@subject, item) @subject.use_item(item) refresh_status targets = @subject.current_action.make_targets.compact show_animation(targets, item.animation_id) end #-------------------------------------------------------------------------- # ● 显示动画(重定义) #-------------------------------------------------------------------------- def show_animation(targets, animation_id) item = @subject.current_action.item if item.rmva_mode show_rmva_animation(targets, animation_id, item) else show_hzhj_animation(targets, animation_id, item) end end #-------------------------------------------------------------------------- # ● RMVA模式显示动画(新增定义) #-------------------------------------------------------------------------- def show_rmva_animation(targets, animation_id, item) @subject.damage_section_displayed = false @subject.not_damage_section = true targets.each do |target| target.damage_section_displayed = false target.not_damage_section = true end if animation_id < 0 show_attack_animation(targets) else show_rmva_usable_animation(targets, animation_id, item) end end #-------------------------------------------------------------------------- # ● HZHJ模式显示动画(新增定义) #-------------------------------------------------------------------------- def show_hzhj_animation(targets, animation_id, item) if animation_id < 0 show_hzhj_attack_animation(targets, item) else if item.wljn show_wljn_skill_animation(targets, animation_id, item) else show_magic_skill_animation(targets, animation_id, item) end end end #-------------------------------------------------------------------------- # ● HZHJ模式显示攻击动画(重定义) #-------------------------------------------------------------------------- def show_hzhj_attack_animation(targets, item) ary = [] need_move = false animation1 = $data_animations[@subject.animation1_id] need_move = animation1.need_move if animation1 come_back = true targets.each_with_index do |target, i| ary[0] = target item.repeats.times do next if target.dead? && item.damage.type == 1 next if @subject.dead? next if !@subject.current_action if need_move && come_back come_back = false @subject.setup_move_info(target, RealMoveDuration, animation1.move_se) wait_for_move end damage_target = hzhj_apply_item_effects(target, item) show_subject_animation(@subject.animation1_id) show_normal_animation(ary, @subject.atk_animation_id1, false) show_normal_animation(ary, @subject.atk_animation_id2, true) @log_window.wait wait_for_animation hzhj_invoke_item(target, item, damage_target) end if need_move if target != targets[i+1] or target.dead? come_back = true @subject.come_back_self_position(RealMoveDuration) wait_for_move else come_back = false end end end end #-------------------------------------------------------------------------- # ● HZHJ模式显示物理技能类动画(新增定义) #-------------------------------------------------------------------------- def show_wljn_skill_animation(targets, animation_id, item) ary = [] need_move = false animation1 = $data_animations[item.animation1_id] need_move = animation1.need_move if animation1 come_back = true targets.each_with_index do |target, i| ary[0] = target item.repeats.times do next if target.dead? && item.damage.type == 1 next if @subject.dead? next if !@subject.current_action if need_move && come_back come_back = false @subject.setup_move_info(target, RealMoveDuration, animation1.move_se) wait_for_move end damage_target = hzhj_apply_item_effects(target, item) show_subject_animation(item.animation1_id) show_normal_animation(ary, animation_id, false) @log_window.wait wait_for_animation hzhj_invoke_item(target, item, damage_target) end if need_move if target != targets[i+1] or target.dead? come_back = true @subject.come_back_self_position(RealMoveDuration) wait_for_move else come_back = false end end end end #-------------------------------------------------------------------------- # ● HZHJ模式显示魔法技能类动画(新增定义) #-------------------------------------------------------------------------- def show_magic_skill_animation(targets, animation_id, item) ary = [] damage_targets = {} item.repeats.times do next if @subject.dead? next if !@subject.current_action ary.clear damage_targets.clear targets.each do |target| next if target.dead? && item.damage.type == 1 ary << target damage_targets[target] = hzhj_apply_item_effects(target, item) end next if ary.empty? show_subject_animation(item.animation1_id) show_normal_animation(ary, animation_id) @log_window.wait wait_for_animation ary.each do |target| hzhj_invoke_item(target, item, damage_targets[target]) end if [9, 10].include?(item.scope) ary.each do |target| if target.alive? target.come_back_self_position(RealMoveDuration) end end wait_for_move end end end #-------------------------------------------------------------------------- # ● RMVA模式显示攻击动画(重定义) #-------------------------------------------------------------------------- def show_attack_animation(targets) item = @subject.current_action.item show_subject_animation(@subject.animation1_id) show_normal_animation(targets, @subject.atk_animation_id1, false) show_normal_animation(targets, @subject.atk_animation_id2, true) @log_window.wait wait_for_animation targets.each {|target| item.repeats.times { invoke_item(target, item) } } end #-------------------------------------------------------------------------- # ● RMVA模式显示技能、物品动画 (新增定义) #-------------------------------------------------------------------------- def show_rmva_usable_animation(targets, animation_id, item) show_subject_animation(item.animation1_id) show_normal_animation(targets, animation_id) @log_window.wait wait_for_animation targets.each {|target| item.repeats.times { invoke_item(target, item) } } if [9, 10].include?(item.scope) targets.each do |target| if target.alive? target.come_back_self_position(RealMoveDuration) end end wait_for_move end end #-------------------------------------------------------------------------- # ● 显示行动方动画(新增定义) #-------------------------------------------------------------------------- def show_subject_animation(animation_id, subject = @subject, mirror = false) animation = $data_animations[animation_id] if animation subject.animation_id = animation_id subject.animation_mirror = mirror if animation.wait_subject_duration < 0 wait_for_animation elsif animation.wait_subject_duration > 0 animation.wait_subject_duration.times{update_for_wait} end end end end class RPG::Animation include Hzhj::HorizontalBattleSystem def ani_z_correction return @ani_z_correction unless @ani_z_correction.nil? if /@az\[(\-??\d+?)\]/ =~ @name return (@ani_z_correction = $1.to_i) else return (@ani_z_correction = DefaultAniAddZ) end end def loop_z_correction return @loop_z_correction unless @loop_z_correction.nil? if /@lz\[(\-??\d+?)\]/ =~ @name return (@loop_z_correction = $1.to_i) else return (@loop_z_correction = DefaultLoopAniAddZ) end end attr_writer :ani_z_correction attr_writer :loop_z_correction end class RPG::State < RPG::BaseItem def animation_id return @animation_id unless @animation_id.nil? if /@aid\[(\d+?)\]/ =~ @note return (@animation_id = $1.to_i) else return (@animation_id = 0) end end attr_writer :animation_id end #============================================================================== # ■ Game_BattlerBase #============================================================================== class Game_BattlerBase #-------------------------------------------------------------------------- # ● 实例变量(新增定义) #-------------------------------------------------------------------------- attr_reader :hzhj_add_state_id attr_reader :hzhj_remove_state_id attr_accessor :need_update_state_animation #-------------------------------------------------------------------------- # ● 初始化(追加定义) #-------------------------------------------------------------------------- alias hzhj_old_init_for_state_ani_game_battler_base initialize def initialize @hzhj_add_state_id = [] @hzhj_remove_state_id = [] @need_update_state_animation = false @states = [] @state_turns = {} @state_steps = {} hzhj_old_init_for_state_ani_game_battler_base end #-------------------------------------------------------------------------- # ● 清除状态信息(追加定义) #-------------------------------------------------------------------------- alias hzhj_old_clear_states_for_state_ani_game_battler_base clear_states def clear_states old_states = @states.clone hzhj_old_clear_states_for_state_ani_game_battler_base bingji = old_states | @states return if bingji.empty? set_add_state_id(bingji & @states) set_remove_state_id(bingji & old_states) end #-------------------------------------------------------------------------- # ● 消除状态(追加定义) #-------------------------------------------------------------------------- alias hzhj_old_erase_state_for_state_ani_game_battler_base erase_state def erase_state(state_id) old_states = @states.clone hzhj_old_erase_state_for_state_ani_game_battler_base(state_id) bingji = old_states | @states return if bingji.empty? set_add_state_id(bingji & @states) set_remove_state_id(bingji & old_states) end #-------------------------------------------------------------------------- # ● 设置增加的状态(新增定义) #-------------------------------------------------------------------------- def set_add_state_id(zjdzt) for i in zjdzt if $data_states[i].animation_id > 0 if not @hzhj_add_state_id.include?(i) @hzhj_add_state_id.push(i) end end end end #-------------------------------------------------------------------------- # ● 设置解除的状态(新增定义) #-------------------------------------------------------------------------- def set_remove_state_id(jsdzt) for i in jsdzt if $data_states[i].animation_id > 0 if not @hzhj_remove_state_id.include?(i) ani_id = $data_states[i].animation_id not_end_loop_animation = false for state in self.states if state.animation_id == ani_id not_end_loop_animation = true break end end unless not_end_loop_animation @hzhj_remove_state_id.push(i) end end end end end end #============================================================================== # ■ Game_Battler #============================================================================== class Game_Battler < Game_BattlerBase #-------------------------------------------------------------------------- # ● 附加新的状态(追加定义) #-------------------------------------------------------------------------- alias hzhj_old_add_new_state_for_state_ani_game_battler add_new_state def add_new_state(state_id) old_states = @states.clone hzhj_old_add_new_state_for_state_ani_game_battler(state_id) bingji = old_states | @states return if bingji.empty? set_add_state_id(bingji & @states) set_remove_state_id(bingji & old_states) end end #============================================================================== # ■ Sprite_Base #============================================================================== class Sprite_Base < Sprite #-------------------------------------------------------------------------- # ● 初始化(追加定义) #-------------------------------------------------------------------------- alias hzhj_old_init_for_state_ani_spr_base initialize def initialize(*args) hzhj_old_init_for_state_ani_spr_base(*args) @hzhj_loop_animations = [] @hzhj_loop_durations = {} @hzhj_loop_sprites = {} @hzhj_loop_bitmap1s = {} @hzhj_loop_bitmap2s = {} @hzhj_loop_ani_oxs = {} @hzhj_loop_ani_oys = {} @flash_nil_duration = 0 end #-------------------------------------------------------------------------- # ● 释放(追加定义) #-------------------------------------------------------------------------- alias hzhj_old_dispose_for_state_ani_spr_base dispose def dispose dispose_loop_animation hzhj_old_dispose_for_state_ani_spr_base end #-------------------------------------------------------------------------- # ● 设定动画的活动块(追加定义) #-------------------------------------------------------------------------- alias hzhj_old_ani_set_spr_for_state_ani_spr_base animation_set_sprites def animation_set_sprites(*args) hzhj_old_ani_set_spr_for_state_ani_spr_base(*args) @ani_sprites.each{|sprite|sprite.z += @animation.ani_z_correction} end #-------------------------------------------------------------------------- # ● 判断是否有循环动画(新增定义) #-------------------------------------------------------------------------- def loop_animation? return (not @hzhj_loop_animations.empty?) end #-------------------------------------------------------------------------- # ● 开始播放循环动画(新增定义) #-------------------------------------------------------------------------- def start_loop_animation(animation) return if @hzhj_loop_animations.include?(animation) if animation.nil? dispose_loop_animation return end set_animation_rate @hzhj_loop_animations.push(animation) init_loop_animation_duration(animation) load_loop_animation_bitmap(animation) make_loop_animation_sprites(animation) set_loop_animation_origin(animation) end #-------------------------------------------------------------------------- # ● 初始化循环动画播放位置(新增定义) #-------------------------------------------------------------------------- def init_loop_animation_duration(animation) @hzhj_loop_durations[animation] = animation.frame_max * @ani_rate + 1 end #-------------------------------------------------------------------------- # ● 读取循环动画图像(新增定义) #-------------------------------------------------------------------------- def load_loop_animation_bitmap(animation) animation1_name = animation.animation1_name animation1_hue = animation.animation1_hue animation2_name = animation.animation2_name animation2_hue = animation.animation2_hue bitmap1 = Cache.animation(animation1_name, animation1_hue) bitmap2 = Cache.animation(animation2_name, animation2_hue) if @@_reference_count.include?(bitmap1) @@_reference_count[bitmap1] += 1 else @@_reference_count[bitmap1] = 1 end if @@_reference_count.include?(bitmap2) @@_reference_count[bitmap2] += 1 else @@_reference_count[bitmap2] = 1 end @hzhj_loop_bitmap1s[animation] = bitmap1 @hzhj_loop_bitmap2s[animation] = bitmap2 Graphics.frame_reset end #-------------------------------------------------------------------------- # ● 生成循环动画活动块(新增定义) #-------------------------------------------------------------------------- def make_loop_animation_sprites(animation) sprites = [] if @use_sprite 16.times do sprite = ::Sprite.new(viewport) sprite.visible = false sprites.push(sprite) end end @hzhj_loop_sprites[animation] = sprites end #-------------------------------------------------------------------------- # ● 设定循环动画的原点(新增定义) #-------------------------------------------------------------------------- def set_loop_animation_origin(animation) if animation.position == 3 if viewport == nil ani_ox = Graphics.width / 2 ani_oy = Graphics.height / 2 else ani_ox = viewport.rect.width / 2 ani_oy = viewport.rect.height / 2 end else ani_ox = x - ox + width / 2 ani_oy = y - oy + height / 2 if animation.position == 0 ani_oy -= height / 2 elsif animation.position == 2 ani_oy += height / 2 end end @hzhj_loop_ani_oxs[animation] = ani_ox @hzhj_loop_ani_oys[animation] = ani_oy end #-------------------------------------------------------------------------- # ● 释放所有循环动画(新增定义) #-------------------------------------------------------------------------- def dispose_loop_animation return unless loop_animation? for animation in @hzhj_loop_animations.clone end_loop_animation(animation) end @hzhj_loop_durations.clear @hzhj_loop_sprites.clear @hzhj_loop_bitmap1s.clear @hzhj_loop_bitmap2s.clear @hzhj_loop_ani_oxs.clear @hzhj_loop_ani_oys.clear @hzhj_loop_animations.clear end #-------------------------------------------------------------------------- # ● 结束某个循环动画(新增定义) #-------------------------------------------------------------------------- def end_loop_animation(animation) return if not @hzhj_loop_animations.include?(animation) bitmap1 = @hzhj_loop_bitmap1s[animation] @@_reference_count[bitmap1] -= 1 if @@_reference_count[bitmap1] == 0 @@_reference_count.delete(bitmap1) bitmap1.dispose end bitmap2 = @hzhj_loop_bitmap2s[animation] @@_reference_count[bitmap2] -= 1 if @@_reference_count[bitmap2] == 0 @@_reference_count.delete(bitmap2) bitmap2.dispose end sprites = @hzhj_loop_sprites[animation] for sprite in sprites sprite.dispose end @hzhj_loop_durations.delete(animation) @hzhj_loop_sprites.delete(animation) @hzhj_loop_bitmap1s.delete(animation) @hzhj_loop_bitmap2s.delete(animation) @hzhj_loop_ani_oxs.delete(animation) @hzhj_loop_ani_oys.delete(animation) @hzhj_loop_animations.delete(animation) end #-------------------------------------------------------------------------- # ● 刷新(追加定义) #-------------------------------------------------------------------------- alias hzhj_old_update_for_state_ani_spr_base update def update hzhj_old_update_for_state_ani_spr_base update_loop_animation end #-------------------------------------------------------------------------- # ● 刷新循环动画(新增定义) #-------------------------------------------------------------------------- def update_loop_animation @flash_nil_duration -= 1 if @flash_nil_duration > 0 return unless loop_animation? for animation in @hzhj_loop_animations @hzhj_loop_durations[animation] -= 1 duration = @hzhj_loop_durations[animation] if duration % @ani_rate == 0 if duration > 0 set_loop_animation_origin(animation) frame_index = animation.frame_max frame_index -= (duration + @ani_rate - 1) / @ani_rate args = [] args[0] = @hzhj_loop_sprites[animation] args[1] = @hzhj_loop_bitmap1s[animation] args[2] = @hzhj_loop_bitmap2s[animation] args[3] = @hzhj_loop_ani_oxs[animation] args[4] = @hzhj_loop_ani_oys[animation] args[5] = animation.loop_z_correction args[6] = ((not flash_nil? or animation.to_screen?) and visible) loop_animation_set_sprites(animation.frames[frame_index], args) animation.timings.each do |timing| loop_animation_process_timing(timing) if timing.frame == frame_index end else init_loop_animation_duration(animation) redo end end end end #-------------------------------------------------------------------------- # ● 设定循环动画的活动块(新增定义) #-------------------------------------------------------------------------- def loop_animation_set_sprites(frame, args) sprites = args[0] bitmap1 = args[1] bitmap2 = args[2] ani_ox = args[3] ani_oy = args[4] loop_z_correction = args[5] state_visible = args[6] cell_data = frame.cell_data sprites.each_with_index do |sprite, i| next unless sprite pattern = cell_data[i, 0] if !pattern || pattern < 0 sprite.visible = false next end sprite.bitmap = pattern < 100 ? bitmap1 : bitmap2 sprite.visible = state_visible sprite.src_rect.set(pattern % 5 * 192, pattern % 100 / 5 * 192, 192, 192) sprite.x = ani_ox + cell_data[i, 1] sprite.y = ani_oy + cell_data[i, 2] sprite.angle = cell_data[i, 4] sprite.mirror = (cell_data[i, 5] == 1) if loop_z_correction > 9999 sprite.z = loop_z_correction % 10000 + i elsif loop_z_correction < -9999 sprite.z = loop_z_correction % -10000 + i else sprite.z = self.z + loop_z_correction + i end sprite.ox = 96 sprite.oy = 96 sprite.zoom_x = cell_data[i, 3] / 100.0 sprite.zoom_y = cell_data[i, 3] / 100.0 sprite.opacity = cell_data[i, 6] * self.opacity / 255.0 sprite.blend_type = cell_data[i, 7] end end #-------------------------------------------------------------------------- # ● 循环动画SE 和闪烁时机的处理(新增定义) #-------------------------------------------------------------------------- def loop_animation_process_timing(timing) timing.se.play case timing.flash_scope when 1 self.flash(timing.flash_color, timing.flash_duration * @ani_rate) when 2 if viewport viewport.flash(timing.flash_color, timing.flash_duration * @ani_rate) end when 3 self.flash(nil, timing.flash_duration * @ani_rate) end end #-------------------------------------------------------------------------- # ● 设置闪烁(追加定义) #-------------------------------------------------------------------------- alias hzhj_old_flash_for_state_ani_spr_base flash def flash(*args) if args[0].nil? @flash_nil_duration = args[1] else @flash_nil_duration = 0 end hzhj_old_flash_for_state_ani_spr_base(*args) end #-------------------------------------------------------------------------- # ● 判断是否正处于【隐藏目标】(新增定义) #-------------------------------------------------------------------------- def flash_nil? return (@flash_nil_duration > 0) end end #============================================================================== # ■ Sprite_Battler #============================================================================== class Sprite_Battler < Sprite_Base #-------------------------------------------------------------------------- # ● 初始化(追加定义) #-------------------------------------------------------------------------- alias hzhj_old_init_for_state_ani_spr_battler initialize def initialize(*args) hzhj_old_init_for_state_ani_spr_battler(*args) init_battler_add_state_id end #-------------------------------------------------------------------------- # ● 初始化战斗者要播放状态动画的状态(新增定义) #-------------------------------------------------------------------------- def init_battler_add_state_id if @battler.nil? dispose_loop_animation else @battler.hzhj_add_state_id.clear @battler.hzhj_remove_state_id.clear @battler.need_update_state_animation = true for state in @battler.states next if state.nil? next if $data_animations[state.animation_id].nil? @battler.hzhj_add_state_id.push(state.id) end end end #-------------------------------------------------------------------------- # ● 设置战斗者(追加定义) #-------------------------------------------------------------------------- alias hzhj_old_battlerdy_for_state_ani_spr_battler battler= def battler=(value) old_battler = @battler hzhj_old_battlerdy_for_state_ani_spr_battler(value) if old_battler != @battler init_battler_add_state_id end end #-------------------------------------------------------------------------- # ● 刷新(追加定义) #-------------------------------------------------------------------------- alias hzhj_old_update_for_state_ani_spr_battler update def update hzhj_old_update_for_state_ani_spr_battler if @battler if @battler.need_update_state_animation @battler.need_update_state_animation = false if not @battler.hzhj_add_state_id.empty? for i in @battler.hzhj_add_state_id if @battler.state?(i) ani_id = $data_states[i].animation_id animation = $data_animations[ani_id] start_loop_animation(animation) if not animation.nil? end end @battler.hzhj_add_state_id.clear end if not @battler.hzhj_remove_state_id.empty? for i in @battler.hzhj_remove_state_id if not @battler.state?(i) ani_id = $data_states[i].animation_id animation = $data_animations[ani_id] end_loop_animation(animation) if not animation.nil? end end @battler.hzhj_remove_state_id.clear end end end end end #============================================================================== # ■ Window_BattleLog #============================================================================== class Window_BattleLog < Window_Selectable #-------------------------------------------------------------------------- # ● 显示状态附加/解除(追加定义) #-------------------------------------------------------------------------- alias hzhj_old_display_status_for_state_ani_wnd_btlog display_changed_states def display_changed_states(target) target.need_update_state_animation = true hzhj_old_display_status_for_state_ani_wnd_btlog(target) end end #============================================================================== # ■ Sprite_Damage (新增类) #============================================================================== class Sprite_Damage < Sprite include Hzhj::HorizontalBattleSystem #-------------------------------------------------------------------------- # ● 获取/生成伤害值源图 #-------------------------------------------------------------------------- @@obmp = nil def self.obmp if @@obmp.nil? or @@obmp.disposed? @@obmp = Bitmap.new(180, 256) @@obmp.font.bold = true @@obmp.font.shadow = false @@obmp.font.outline = true @@obmp.font.out_color = Color.new(255, 255, 255, 255) @@obmp.font.size = 32 colors = [] colors.push(Color.new(255, 0, 0, 255)) colors.push(Color.new(255, 128, 128, 255)) colors.push(Color.new( 0, 0, 255, 255)) colors.push(Color.new(128, 128, 255, 255)) colors.push(Color.new( 0, 255, 0, 255)) colors.push(Color.new(128, 255, 128, 255)) colors.each_with_index do |color, hi| @@obmp.font.color = color for wi in 0..9 @@obmp.draw_text(wi * 18, hi * 32, 18, 32, "#{wi}", 1) end end @@obmp.font.size = 20 @@obmp.font.italic = true @@obmp.font.out_color = Color.new(0, 0, 0, 255) @@obmp.font.color = Color.new(255, 255, 255, 255) @@obmp.draw_text( 0, 192, 90, 32, "Critical", 1) @@obmp.draw_text(90, 192, 90, 32, "Miss", 1) @@obmp.draw_text( 0, 224, 90, 32, "Evasion", 1) @@obmp.hue_change(DamageBitmapHue) end return @@obmp end #-------------------------------------------------------------------------- # ● 初始化 #-------------------------------------------------------------------------- def initialize(viewport, args) super(viewport) @type = args[0] @value = args[1] @critical = args[2] self.x = args[4] self.y = args[5] self.z = args[6] + Graphics.height * 5 make_move(args[3]) refresh end #-------------------------------------------------------------------------- # ● 生成移动数据 #-------------------------------------------------------------------------- def make_move(battler_obj_class) @move = [] case battler_obj_class when :actor make_move_actor when :enemy make_move_enemy else make_move_default end end #-------------------------------------------------------------------------- # ● 生成移动数据 默认 #-------------------------------------------------------------------------- def make_move_default 45.times do |n| if n % 3 == 0 ady = n < 21 ? -6 : -1 opa = n < 21 ? 255 : 255-(n-21)*6 @move.push([0, ady, opa]) else @move.push([0, 0, -1]) end end end #-------------------------------------------------------------------------- # ● 生成移动数据 角色 #-------------------------------------------------------------------------- def make_move_actor make_move_default end #-------------------------------------------------------------------------- # ● 生成移动数据 敌人 #-------------------------------------------------------------------------- def make_move_enemy make_move_default end #-------------------------------------------------------------------------- # ● 描绘 #-------------------------------------------------------------------------- def refresh if not self.bitmap.nil? self.bitmap.dispose self.bitmap = nil end begin @obmp = Cache.animation("damage", DamageBitmapHue) rescue Errno::ENOENT @obmp = Sprite_Damage.obmp end @numw = @obmp.width / 10 @numh = @obmp.height / 8 @strw = @obmp.width / 2 case @value when Numeric blt_obmp_numeric when Symbol blt_obmp_text end end #-------------------------------------------------------------------------- # ● 通过源图描绘数字 #-------------------------------------------------------------------------- def blt_obmp_numeric nums = @value.to_i.abs.to_s.split("") nbmpw = nums.size * @numw bmph = @numh cbmpw = 0 crect = nil dy = 0 if @critical cbmpw = @strw bmph *= 2 crect = Rect.new(0, @numh * 6, @strw, @numh) dy = @numh end self.bitmap = Bitmap.new([nbmpw, cbmpw, 32].max, [bmph, 32].max) self.ox = bitmap.width / 2 self.oy = bmph /2 bitmap.blt((bitmap.width - cbmpw) / 2, 0, @obmp, crect) if crect dx = (bitmap.width - nbmpw) / 2 ry = 0 case @type when :hp ry = @value >= 0 ? 0 : @numh when :mp ry = @value >= 0 ? @numh * 2 : @numh * 3 when :tp ry = @value >= 0 ? @numh * 4 : @numh * 5 else return end rect = Rect.new(0, ry, @numw, @numh) nums.each_with_index do |str, i| rect.x = str.to_i * @numw bitmap.blt(dx, dy, @obmp, rect) dx += @numw end end #-------------------------------------------------------------------------- # ● 通过源图描绘文字 #-------------------------------------------------------------------------- def blt_obmp_text self.bitmap = Bitmap.new([@strw, 32].max, [@numh, 32].max) self.ox = @strw / 2 self.oy = @numh / 2 rx = ry = 0 case @type when :miss rx = @strw ry = @numh * 6 when :eva ry = @numh * 7 else return end rect = Rect.new(rx, ry, @strw, @numh) bitmap.blt(0, 0, @obmp, rect) end #-------------------------------------------------------------------------- # ● 释放 #-------------------------------------------------------------------------- def dispose bitmap.dispose if bitmap super end #-------------------------------------------------------------------------- # ● 移动中判定 #-------------------------------------------------------------------------- def moving? return (not @move.empty?) end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def update super if moving? ary = @move.shift self.x += ary[0] self.y += ary[1] self.opacity = ary[2] if ary[2] >= 0 end end end #============================================================================== # ■ Game_BattlerBase #============================================================================== class Game_BattlerBase #-------------------------------------------------------------------------- # ● 实例变量(新增定义) #-------------------------------------------------------------------------- attr_accessor :hzhj_damage #-------------------------------------------------------------------------- # ● 初始化(追加定义) #-------------------------------------------------------------------------- alias hzhj_old_init_for_display_damage_game_battler_base initialize def initialize @hzhj_damage = [] hzhj_old_init_for_display_damage_game_battler_base end end #============================================================================== # ■ Sprite_Base #============================================================================== class Sprite_Base < Sprite #-------------------------------------------------------------------------- # ● 初始化(追加定义) #-------------------------------------------------------------------------- alias hzhj_old_init_for_display_damage_spr_base initialize def initialize(*args) hzhj_old_init_for_display_damage_spr_base(*args) @hzhj_damage_sprites = [] end #-------------------------------------------------------------------------- # ● 释放(追加定义) #-------------------------------------------------------------------------- alias hzhj_old_dispose_for_display_damage_spr_base dispose def dispose hzhj_old_dispose_for_display_damage_spr_base dispose_damage end #-------------------------------------------------------------------------- # ● 判断是否有伤害在显示(新增定义) #-------------------------------------------------------------------------- def damage? return (not @hzhj_damage_sprites.empty?) end #-------------------------------------------------------------------------- # ● 开始显示伤害(新增定义) #-------------------------------------------------------------------------- def start_damage(args) args[4] = x - ox + width / 2 args[5] = y - oy + height / 2 args[6] = z @hzhj_damage_sprites.push(Sprite_Damage.new(viewport, args)) end #-------------------------------------------------------------------------- # ● 释放所有伤害显示(新增定义) #-------------------------------------------------------------------------- def dispose_damage return unless damage? @hzhj_damage_sprites.each{|sprite|sprite.dispose} @hzhj_damage_sprites.clear end #-------------------------------------------------------------------------- # ● 刷新(追加定义) #-------------------------------------------------------------------------- alias hzhj_old_update_for_display_damage_spr_base update def update hzhj_old_update_for_display_damage_spr_base update_damage end #-------------------------------------------------------------------------- # ● 刷新显示伤害(新增定义) #-------------------------------------------------------------------------- def update_damage return unless damage? @hzhj_damage_sprites.each_with_index do |sprite, i| if sprite.moving? sprite.update else sprite.dispose @hzhj_damage_sprites[i] = nil end end @hzhj_damage_sprites.delete(nil) end end #============================================================================== # ■ Sprite_Battler #============================================================================== class Sprite_Battler < Sprite_Base #-------------------------------------------------------------------------- # ● 刷新(追加定义) #-------------------------------------------------------------------------- alias hzhj_old_update_for_display_damage_spr_battler update def update hzhj_old_update_for_display_damage_spr_battler if @battler if not @battler.hzhj_damage.empty? unless @battler.damage_section_displayed args = @battler.hzhj_damage.clone args[3] = @battler.actor? ? :actor : (@battler.enemy? ? :enemy : nil) start_damage(args) end @battler.hzhj_damage.clear end end end end #============================================================================== # ■ Window_BattleLog #============================================================================== class Window_BattleLog < Window_Selectable #-------------------------------------------------------------------------- # ● 显示 MISS (追加定义) #-------------------------------------------------------------------------- alias hzhj_old_display_miss_for_display_damage_wnd_btlog display_miss def display_miss(target, item) target.hzhj_damage = [:miss, :miss, false] hzhj_old_display_miss_for_display_damage_wnd_btlog(target, item) end #-------------------------------------------------------------------------- # ● 显示回避 (追加定义) #-------------------------------------------------------------------------- alias hzhj_old_display_evasion_for_display_damage_wnd_btlog display_evasion def display_evasion(target, item) target.hzhj_damage = [:eva, :evasion, false] hzhj_old_display_evasion_for_display_damage_wnd_btlog(target, item) end #-------------------------------------------------------------------------- # ● 显示 HP 伤害 (追加定义) #-------------------------------------------------------------------------- alias hzhj_old_display_hp_damage_for_display_damage_wnd_btlog display_hp_damage def display_hp_damage(target, item) return if target.result.hp_damage == 0 && item && !item.damage.to_hp? value = target.result.hp_damage critical = target.result.critical target.hzhj_damage = [:hp, value, critical] hzhj_old_display_hp_damage_for_display_damage_wnd_btlog(target, item) end #-------------------------------------------------------------------------- # ● 显示 MP 伤害 (追加定义) #-------------------------------------------------------------------------- alias hzhj_old_display_mp_damage_for_display_damage_wnd_btlog display_mp_damage def display_mp_damage(target, item) return if target.dead? || target.result.mp_damage == 0 value = target.result.mp_damage critical = target.result.critical target.hzhj_damage = [:mp, value, critical] hzhj_old_display_mp_damage_for_display_damage_wnd_btlog(target, item) end #-------------------------------------------------------------------------- # ● 显示 TP 伤害 (追加定义) #-------------------------------------------------------------------------- alias hzhj_old_display_tp_damage_for_display_damage_wnd_btlog display_tp_damage def display_tp_damage(target, item) return if target.dead? || target.result.tp_damage == 0 value = target.result.tp_damage critical = target.result.critical target.hzhj_damage = [:tp, value, critical] hzhj_old_display_tp_damage_for_display_damage_wnd_btlog(target, item) end end class RPG::Animation def need_move return @need_move unless @need_move.nil? if /@[Rr][Mm]/ =~ @name return (@need_move = true) else return (@need_move = false) end end def move_se return @move_se unless @move_se.nil? @move_se = RPG::SE.new if /@[Ss][Ee]\[(.+?)\]/ =~ @name @move_se.name = $1.clone end return @move_se end attr_writer :need_move attr_writer :move_se end #============================================================================== # ■ Game_Battler #============================================================================== class Game_Battler < Game_BattlerBase include Hzhj::HorizontalBattleSystem #-------------------------------------------------------------------------- # ● 属性 #-------------------------------------------------------------------------- attr_accessor :add_x # X 坐标变化量 attr_accessor :add_y # Y 坐标变化量 attr_accessor :move_speed_x # 战斗图 X 移动速度 attr_accessor :move_speed_y # 战斗图 Y 移动速度 #-------------------------------------------------------------------------- # ● 初始化(追加定义) #-------------------------------------------------------------------------- alias hzhj_old_init_for_real_move_game_battler initialize def initialize @add_x = 0 @add_y = 0 @move_speed_x = 0 @move_speed_y = 0 hzhj_old_init_for_real_move_game_battler end #-------------------------------------------------------------------------- # ● 真实 X 坐标(新增定义) #-------------------------------------------------------------------------- def real_screen_x return screen_x + add_x end #-------------------------------------------------------------------------- # ● 真实 Y 坐标(新增定义) #-------------------------------------------------------------------------- def real_screen_y return screen_y + add_y end #-------------------------------------------------------------------------- # ● 返回自己的战斗位置(新增定义) #-------------------------------------------------------------------------- def come_back_self_position(duration) return if dead? tx = screen_x ty = screen_y addx = tx - real_screen_x addy = ty - real_screen_y return if addx == 0 && addy == 0 @add_x = 0 @add_y = 0 @move_speed_x = [(addx.abs / duration.to_f).ceil, 1].max @move_speed_y = [(addy.abs / duration.to_f).ceil, 1].max end #-------------------------------------------------------------------------- # ● 设置移动信息(新增定义) #-------------------------------------------------------------------------- def setup_move_info(target_battler, duration, move_se) return if dead? tbmp = Cache.battler(target_battler.battler_name, target_battler.battler_hue) sbmp = Cache.battler(@battler_name, @battler_hue) tbw = tbmp.width / DynamicPatternMax + RealMoveBmpAddW sbw = sbmp.width / DynamicPatternMax + RealMoveBmpAddW tbh = tbmp.height + RealMoveBmpAddH sbh = sbmp.height + RealMoveBmpAddH d = actor? ? ActorDirection : 10 - ActorDirection tx = target_battler.real_screen_x ty = target_battler.real_screen_y case d when 1 tx = tx + tbw / 2 + sbw / 2 ty = ty - sbh / 2 when 2 ty = ty - sbh / 2 when 3 tx = tx - tbw / 2 - sbw / 2 ty = ty - sbh / 2 when 4 tx = tx + tbw / 2 + sbw / 2 when 6 tx = tx - tbw / 2 - sbw / 2 when 7 tx = tx + tbw / 2 + sbw / 2 ty = ty + sbh / 2 when 8 ty = ty + sbh / 2 when 9 tx = tx - tbw / 2 - sbw / 2 ty = ty + sbh / 2 end addx = tx - real_screen_x addy = ty - real_screen_y return if addx == 0 && addy == 0 @add_x = tx - screen_x if addx != 0 @add_y = ty - screen_y if addy != 0 @move_speed_x = [(addx.abs / duration.to_f).ceil, 1].max @move_speed_y = [(addy.abs / duration.to_f).ceil, 1].max move_se.play end end #============================================================================== # ■ Sprite_Battler #============================================================================== class Sprite_Battler < Sprite_Base #-------------------------------------------------------------------------- # ● 初始化(追加定义) #-------------------------------------------------------------------------- alias hzhj_old_init_for_real_move_spr_battler initialize def initialize(viewport, battler = nil) hzhj_old_init_for_real_move_spr_battler(viewport, battler) init_position(@battler) if @battler end #-------------------------------------------------------------------------- # ● 设置战斗者(追加定义) #-------------------------------------------------------------------------- alias hzhj_old_set_battler_for_real_move_spr_battler battler= def battler=(value) if @battler != value && value init_position(value) end hzhj_old_set_battler_for_real_move_spr_battler(value) end #-------------------------------------------------------------------------- # ● 初始化位置(新增定义) #-------------------------------------------------------------------------- def init_position(battler) battler.add_x = 0 battler.add_y = 0 self.x = battler.real_screen_x self.y = battler.real_screen_y self.z = battler.screen_z end #-------------------------------------------------------------------------- # ● 移动中判定(新增定义) #-------------------------------------------------------------------------- def moving? return false unless @battler (x != @battler.real_screen_x or y != @battler.real_screen_y) && @battler end #-------------------------------------------------------------------------- # ● 位置的更新(重定义) #-------------------------------------------------------------------------- def update_position if !@battler.dead? if x < @battler.real_screen_x self.x = [x + @battler.move_speed_x, @battler.real_screen_x].min elsif x > @battler.real_screen_x self.x = [x - @battler.move_speed_x, @battler.real_screen_x].max end if y < @battler.real_screen_y self.y = [y + @battler.move_speed_y, @battler.real_screen_y].min elsif y > @battler.real_screen_y self.y = [y - @battler.move_speed_y, @battler.real_screen_y].max end self.z = y + 100 end end end #============================================================================== # ■ Spriteset_Battle #============================================================================== class Spriteset_Battle #-------------------------------------------------------------------------- # ● 判定是否移动中(新增定义) #-------------------------------------------------------------------------- def moving? battler_sprites.any? {|sprite| sprite.moving? } end end #============================================================================== # ■ Scene_Battle #============================================================================== class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # ● 等待战斗图移动的结束(新增定义) #-------------------------------------------------------------------------- def wait_for_move update_for_wait update_for_wait while @spriteset.moving? end end class RPG::Troop include Hzhj::HorizontalBattleSystem def display_enemy_bar return @display_enemy_bar unless @display_enemy_bar.nil? if /@ebar/i =~ @name return (@display_enemy_bar = !DefaultDisplayEnemyBar) else return (@display_enemy_bar = DefaultDisplayEnemyBar) end end attr_writer :display_enemy_bar end #============================================================================== # ■ Game_Troop #============================================================================== class Game_Troop < Game_Unit attr_accessor :display_enemy_bar # 是否显示敌人HP条、MP条、TP条 #-------------------------------------------------------------------------- # ● 设置 #-------------------------------------------------------------------------- alias hzhj_old_setup_for_display_enemy_bar_game_troop setup def setup(troop_id) hzhj_old_setup_for_display_enemy_bar_game_troop(troop_id) @display_enemy_bar = troop.display_enemy_bar end end #============================================================================== # ■ Window_BattleEnemy #============================================================================== class Window_BattleEnemy < Window_Selectable #-------------------------------------------------------------------------- # ● 取得列数 #-------------------------------------------------------------------------- def col_max if $game_troop.display_enemy_bar return 1 else return 2 end end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh create_contents super end #-------------------------------------------------------------------------- # ● 描画项目 #-------------------------------------------------------------------------- def draw_item(index) if $game_troop.display_enemy_bar enemy = $game_troop.alive_members[index] draw_basic_area(basic_area_rect(index), enemy) draw_gauge_area(gauge_area_rect(index), enemy) else change_color(normal_color) name = $game_troop.alive_members[index].name draw_text(item_rect_for_text(index), name) end end #-------------------------------------------------------------------------- # ● 取得基本区域的矩形 #-------------------------------------------------------------------------- def basic_area_rect(index) rect = item_rect_for_text(index) rect.width -= gauge_area_width + 10 rect end #-------------------------------------------------------------------------- # ● 取得值槽区域的矩形 #-------------------------------------------------------------------------- def gauge_area_rect(index) rect = item_rect_for_text(index) rect.x += rect.width - gauge_area_width rect.width = gauge_area_width rect end #-------------------------------------------------------------------------- # ● 取得值槽区域的宽度 #-------------------------------------------------------------------------- def gauge_area_width return 220 end #-------------------------------------------------------------------------- # ● 描画基本区域 #-------------------------------------------------------------------------- def draw_basic_area(rect, actor) draw_actor_name(actor, rect.x + 0, rect.y, 100) draw_actor_icons(actor, rect.x + 104, rect.y, rect.width - 104) end #-------------------------------------------------------------------------- # ● 描画值槽区域 #-------------------------------------------------------------------------- def draw_gauge_area(rect, actor) if $data_system.opt_display_tp draw_gauge_area_with_tp(rect, actor) else draw_gauge_area_without_tp(rect, actor) end end #-------------------------------------------------------------------------- # ● 描画值槽区域(包括 TP 值) #-------------------------------------------------------------------------- def draw_gauge_area_with_tp(rect, actor) draw_actor_hp(actor, rect.x + 0, rect.y, 72) draw_actor_mp(actor, rect.x + 82, rect.y, 64) draw_actor_tp(actor, rect.x + 156, rect.y, 64) end #-------------------------------------------------------------------------- # ● 描画值槽区域(不包括 TP 值) #-------------------------------------------------------------------------- def draw_gauge_area_without_tp(rect, actor) draw_actor_hp(actor, rect.x + 0, rect.y, 134) draw_actor_mp(actor, rect.x + 144, rect.y, 76) end end #============================================================================== # ■ Sprite_Battler #============================================================================== class Sprite_Battler < Sprite_Base include Hzhj::HorizontalBattleSystem #-------------------------------------------------------------------------- # ● 初始化(追加定义) #-------------------------------------------------------------------------- alias hzhj_old_init_for_dynamic_spr_battler initialize def initialize(viewport, battler = nil) hzhj_old_init_for_dynamic_spr_battler(viewport, battler) @dynamic_duration = 0 @dynamic_duration_max = DynamicPatternMax * OnePatternDuration end #-------------------------------------------------------------------------- # ● 源位图(Source Bitmap)的更新(重定义) #-------------------------------------------------------------------------- def update_bitmap new_bitmap = Cache.battler(@battler.battler_name, @battler.battler_hue) if bitmap != new_bitmap self.bitmap = new_bitmap init_visibility @dynamic_duration = 0 @sx = 0 @sw = bitmap.width / DynamicPatternMax @sh = bitmap.height self.ox = @sw / 2 self.oy = @sh src_rect.set(@sx, 0, @sw, @sh) end end #-------------------------------------------------------------------------- # ● 原点的更新(重定义) #-------------------------------------------------------------------------- def update_origin if bitmap @dynamic_duration += 1 @dynamic_duration %= @dynamic_duration_max @sx = @dynamic_duration / OnePatternDuration * @sw src_rect.set(@sx, 0, @sw, @sh) end end #-------------------------------------------------------------------------- # ● 返回普通设定(追加定义) #-------------------------------------------------------------------------- alias hzhj_old_revert_to_normal_for_dynamic_spr_battler revert_to_normal def revert_to_normal hzhj_old_revert_to_normal_for_dynamic_spr_battler self.ox = @sw / 2 if bitmap end #-------------------------------------------------------------------------- # ● BOSS 战败(崩坏)效果的更新(追加定义) #-------------------------------------------------------------------------- alias hzhj_old_update_boss_col_for_dynamic_spr_battler update_boss_collapse def update_boss_collapse hzhj_old_update_boss_col_for_dynamic_spr_battler self.ox = @sw / 2 + @effect_duration % 2 * 4 - 2 end end #============================================================================== # ■ Game_Battler #============================================================================== class Game_Battler < Game_BattlerBase def set_normal_battler_name @battler_name = @battler_name.split(/★/)[0] end def set_beaten_battler_name if guard? if (UseActorGuardGraphic && actor?) or (UseEnemyGuardGraphic && enemy?) set_guard_battler_name return end end @battler_name = @battler_name.split(/★/)[0] + "★1" if UseActorWBSE && actor? Audio.se_play("Audio/SE/AWBSE_#{id}", 100, 100) elsif UseEnemyWBSE && enemy? Audio.se_play("Audio/SE/EWBSE_#{enemy_id}", 100, 100) end end def set_dead_battler_name @battler_name = @battler_name.split(/★/)[0] + "★2" end def set_guard_battler_name @battler_name = @battler_name.split(/★/)[0] + "★3" if UseActorGDSE && actor? Audio.se_play("Audio/SE/AGDSE_#{id}", 100, 100) elsif UseEnemyGDSE && enemy? Audio.se_play("Audio/SE/EGDSE_#{enemy_id}", 100, 100) end end end #============================================================================== # ■ Sprite_Battler #============================================================================== class Sprite_Battler < Sprite_Base #-------------------------------------------------------------------------- # ● 初始化(追加定义) #-------------------------------------------------------------------------- alias hzhj_old_init_for_dead_spr_battler initialize def initialize(viewport, battler = nil) hzhj_old_init_for_dead_spr_battler(viewport, battler) @dead_graphic_used = false if @battler @battler.set_normal_battler_name if @battler.dead? if (UseActorDeadGraphic && @battler.actor?) or (UseEnemyDeadGraphic && @battler.enemy?) @battler.set_dead_battler_name @dead_graphic_used = true end end end @beaten_duration = -1 end #-------------------------------------------------------------------------- # ● 设置战斗者(追加定义) #-------------------------------------------------------------------------- alias hzhj_old_set_battler_for_dead_spr_battler battler= def battler=(value) if @battler != value @dead_graphic_used = false if value value.set_normal_battler_name if value.dead? if (UseActorDeadGraphic && value.actor?) or (UseEnemyDeadGraphic && value.enemy?) value.set_dead_battler_name @dead_graphic_used = true end end end @beaten_duration = -1 end hzhj_old_set_battler_for_dead_spr_battler(value) end #-------------------------------------------------------------------------- # ● 源位图(Source Bitmap)的更新(重定义) #-------------------------------------------------------------------------- alias hzhj_old_update_bitmap_for_was_beaten_spr_battler update_bitmap def update_bitmap if @beaten_duration > 0 @beaten_duration -= 1 elsif @beaten_duration == 0 @beaten_duration = -1 set_bitmap(:normal) end hzhj_old_update_bitmap_for_was_beaten_spr_battler end #-------------------------------------------------------------------------- # ● 初始化可视状态(追加定义) #-------------------------------------------------------------------------- alias hzhj_old_visibility_for_dead_spr_battler init_visibility def init_visibility hzhj_old_visibility_for_dead_spr_battler if @battler.dead? if (UseActorDeadGraphic && @battler.actor?) or (UseEnemyDeadGraphic && @battler.enemy?) self.opacity = 255 end end end #-------------------------------------------------------------------------- # ● 效果开始(追加定义) #-------------------------------------------------------------------------- alias hzhj_old_start_effect_for_dead_spr_battler start_effect def start_effect(effect_type) if effect_type == :appear if @dead_graphic_used set_bitmap(:normal) @effect_type = nil @effect_duration = 0 @dead_graphic_used = false @battler_visible = true return end elsif effect_type == :collapse or effect_type == :boss_collapse or effect_type == :instant_collapse if @beaten_duration >= 0 @beaten_duration = -1 set_bitmap(:normal) end if (UseActorDeadGraphic && @battler.actor?) or (UseEnemyDeadGraphic && @battler.enemy?) set_bitmap(:dead) @effect_type = nil @effect_duration = 0 @dead_graphic_used = true @battler_visible = false return end end hzhj_old_start_effect_for_dead_spr_battler(effect_type) end #-------------------------------------------------------------------------- # ● 设置新的位图(新增定义) #-------------------------------------------------------------------------- def set_bitmap(sym) case sym when :normal @battler.set_normal_battler_name when :was_beaten @battler.set_beaten_battler_name when :dead @battler.set_dead_battler_name else return end new_bitmap = Cache.battler(@battler.battler_name, @battler.battler_hue) if bitmap != new_bitmap self.bitmap = new_bitmap @dynamic_duration = 0 @sx = 0 @sw = bitmap.width / DynamicPatternMax @sh = bitmap.height self.ox = @sw / 2 self.oy = @sh src_rect.set(@sx, 0, @sw, @sh) end update_origin update_position end end #============================================================================== # ■ Scene_Battle #============================================================================== class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # ● 发动技能/物品(新增定义) #-------------------------------------------------------------------------- def hzhj_invoke_item(target, item, damage_target) refresh_status @log_window.display_action_results(damage_target, item) @subject.damage_section_displayed = false @subject.last_target_index = target.index return if target.dead? if rand < target.item_cnt(@subject, item) hzhj_invoke_counter_attack(target, item) elsif rand < target.item_mrf(@subject, item) hzhj_invoke_magic_reflection(target, item) end end #-------------------------------------------------------------------------- # ● 发动物理反击(新增定义) #-------------------------------------------------------------------------- def hzhj_invoke_counter_attack(target, item) @log_window.display_counter(target, item) attack_skill = $data_skills[target.attack_skill_id] @subject.item_apply(target, attack_skill) need_move = false animation1 = $data_animations[target.animation1_id] need_move = animation1.need_move if animation1 ary = [@subject] if need_move target.setup_move_info(@subject, RealMoveDuration, animation1.move_se) wait_for_move end @subject.damage_section_displayed = false @subject.not_damage_section = false show_subject_animation(target.animation1_id, target) show_normal_animation(ary, target.atk_animation_id1, false) show_normal_animation(ary, target.atk_animation_id2, true) @log_window.wait wait_for_animation if need_move && target.alive? target.come_back_self_position(RealMoveDuration) wait_for_move end refresh_status @log_window.display_action_results(@subject, attack_skill) end #-------------------------------------------------------------------------- # ● 发动魔法反射(新增定义) #-------------------------------------------------------------------------- def hzhj_invoke_magic_reflection(target, item) @subject.damage_section_displayed = false @subject.not_damage_section = false @log_window.display_reflection(target, item) @subject.item_apply(@subject, item) refresh_status @log_window.display_action_results(@subject, item) end end #============================================================================== # ■ Game_Battler #============================================================================== class Game_Battler < Game_BattlerBase attr_accessor :damage_section_displayed attr_accessor :not_damage_section end #============================================================================== # ■ Game_Actor #============================================================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # ● 执行伤害效果 #-------------------------------------------------------------------------- alias hzhj_old_per_damage_for_damage_section_game_actor perform_damage_effect def perform_damage_effect unless damage_section_displayed hzhj_old_per_damage_for_damage_section_game_actor end end end #============================================================================== # ■ Game_Enemy #============================================================================== class Game_Enemy < Game_Battler #-------------------------------------------------------------------------- # ● 执行伤害效果 #-------------------------------------------------------------------------- alias hzhj_old_per_damage_for_damage_section_game_enemy perform_damage_effect def perform_damage_effect unless damage_section_displayed hzhj_old_per_damage_for_damage_section_game_enemy end end end #============================================================================== # ■ Sprite_Battler #============================================================================== class Sprite_Battler < Sprite_Base #-------------------------------------------------------------------------- # ● SE 和闪烁时机的处理 #-------------------------------------------------------------------------- def animation_process_timing(timing) if timing.se.name == DamageSectionDisplaySEName hp_value = @battler.result.hp_damage mp_value = @battler.result.mp_damage tp_value = @battler.result.tp_damage value = args = nil was_beaten = false if hp_value != 0 && !@battler.not_damage_section was_beaten = true if hp_value > 0 value = hp_value * timing.flash_color.red.to_i / 100 critical = @battler.result.critical args = [:hp, value, critical] elsif mp_value != 0 && !@battler.not_damage_section was_beaten = true if mp_value > 0 value = mp_value * timing.flash_color.red.to_i / 100 critical = @battler.result.critical args = [:mp, value, critical] elsif tp_value != 0 && !@battler.not_damage_section was_beaten = true if tp_value > 0 value = tp_value * timing.flash_color.red.to_i / 100 critical = @battler.result.critical args = [:tp, value, critical] end if value && args args[3] = @battler.actor? ? :actor : (@battler.enemy? ? :enemy : nil) @battler.damage_section_displayed = true start_damage(args) if UseBeatenGraphic && was_beaten set_bitmap(:was_beaten) @beaten_duration = BeatenGraphicDuration end end return end super(timing) end end #============================================================================== # ■ Scene_Battle #============================================================================== class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # ● 应用技能/物品效果(新增定义) #-------------------------------------------------------------------------- def hzhj_apply_item_effects(target, item) target.damage_section_displayed = false target.not_damage_section = false target = apply_substitute(target, item) target.damage_section_displayed = false target.not_damage_section = false target.item_apply(@subject, item) return target end end #============================================================================== # ■ 此脚本来自 [url]www.66rpg.com[/url] #==============================================================================
QQ截图20160825161343.png (160.45 KB, 下载次数: 13)
如何去掉A1ID之类
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |