$imported = {} if $imported.nil? $imported["YES-BattlePopup"] = true #============================================================================== # ■ BattleLuna #============================================================================== module BattleLuna module Addon BATTLE_POPUP = { # 基础设定 :basic_setting => { :enable => true, # 伤害弹出的开关. :state_popup => true, # 状态弹出的开关. :buff_popup => true, # 能力变化的开关. :delay => 6, # 伤害弹出的间隔时间. :no_delay => [:critical, :drained, :weakpoint, :resistant, :absorbed], }, #无间隔 # 文本设定. :word_setting => { :default => "%s ", # 默认. :hp_dmg => "%s ", # HP 伤害. :hp_heal => "%s ", # HP 回复. :mp_dmg => "%s", # MP 伤害. :mp_heal => "%s", # MP 回复. :tp_dmg => "%s", # TP 伤害. :tp_heal => "%s", # TP 伤害. :drained => "%s", # 吸收 HP/MP. :critical => "", # 暴击. :missed => "失误", # 未命中. :evaded => "MISS", # 闪避. :nulled => "无伤害", # 无效攻击. :failed => "无效", # 攻击失败. :add_state => "%s", # 附加状态. :rem_state => "%s", # 移除状态. :dur_state => "%s", # 状态持续. :weakpoint => "", # 属性弱点. :resistant => "", # 属性抵抗. :immune => "", # 属性无效. :absorbed => "", # 吸收属性伤害. :add_buff => "%s", # 强化能力. :add_debuff => "%s", # 弱化能力. }, # 设定文字效果. :style_setting => { # 类型 => [红, 绿, 蓝, 大小, 加粗, 斜体, 字体], :default => [255, 255, 255, 30, false, false, Font.default_name],# 默认. :hp_dmg => [255, 255, 255, 30, false, false, Font.default_name],# HP 伤害. :hp_heal => [50, 255, 50, 30, false, false, Font.default_name], # HP 回复. :mp_dmg => [175, 125, 250, 30, false, false, Font.default_name],# MP 伤害. :mp_heal => [110, 110, 255, 30, true, false, Font.default_name], # MP 回复. :tp_dmg => [255, 255, 255, 30, false, false, Font.default_name],# TP 伤害. :tp_heal => [255, 255, 255, 30, false, false, Font.default_name],# TP 回复. :drained => [255, 255, 255, 30, false, false, Font.default_name],# 吸收 HP/MP. :critical => [255, 0, 50, 30, false, false, Font.default_name], # 暴击. :missed => [125, 125, 125, 22, false, false, Font.default_name],# 未命中. :evaded => [255, 255, 255, 25, false, false, Font.default_name],# 闪避. :nulled => [125, 125, 255, 22, false, false, Font.default_name],# 无效攻击. :failed => [255, 255, 255, 25, false, false, Font.default_name],# 攻击失败. :add_state => [255, 255, 255, 25, false, false, Font.default_name],# 附加状态. :rem_state => [255, 255, 255, 25, false, false, Font.default_name],# 移除状态. :dur_state => [255, 255, 255, 25, false, false, Font.default_name],# 状态持续. :weakpoint => [255, 255, 255, 25, false, false, Font.default_name],# 属性弱点. :resistant => [255, 255, 255, 25, false, false, Font.default_name],# 属性抵抗. :immune => [255, 255, 255, 25, false, false, Font.default_name],# 属性无效. :absorbed => [255, 255, 255, 25, false, false, Font.default_name],# 吸收属性伤害. :add_debuff => [255, 255, 255, 25, false, false, Font.default_name],# 强化能力. :lvup => [255, 255, 255, 25, false, false, Font.default_name], # 弱化能力. }, # 设定弹出效果. :effect_setting => { # 类型 => [效果顺序], :default => [:up, :wait], :hp_dmg => [:up, :wait], :hp_heal => [:jump_1, :wait], :mp_dmg => [:jump_1, :wait], :mp_heal => [:jump_1, :wait], :tp_dmg => [:jump_1, :wait], :tp_heal => [:jump_1, :wait], :drained => [:affect, :up , :wait], :critical => [:up , :wait], :missed => [:up , :wait], :evaded => [:up , :wait], :nulled => [:up , :wait], :failed => [:up , :wait], :add_state => [:affect, :up , :wait], :rem_state => [:affect, :up , :wait], :dur_state => [:affect, :up , :wait], :weakpoint => [:affect, :up , :wait], :resistant => [:affect, :up , :wait], :immune => [:up , :wait], :absorbed => [:affect, :up , :wait], :add_buff => [:affect, :up , :wait], :add_debuff => [:affect, :up , :wait], :lvup => [:up, :wait], }, :effect_setup => { #:效果 => [缩放X, 缩放Y, 起始X, 起始Y, 移动X, 移动Y, 重力, 不透明度, 时间, 随机], :up => [1.0 , 1.0 , 0.0 , 0.0 , 0.0 , -0.5 , 0.0 , 220 , 28 , false ], :jump_1 => [1.0 , 1.0 , 0.0 , 0.0 , 0.0 , -0.5 , 0.0 , 255 , 33 , false ], :jump_2 => [1.0 , 1.0 , 0.0 , 0.0 , 0.0 , -0.5 , 0.0 , 255 , 33 , false ], :wait => [1.0 , 1.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0 , 20 , false ], :affect => [1.0 , 1.0 , 0.0 , -32.0 , 0.0 , 0.0 , 0.0 , 255 , 1 , false ], :affect2 => [1.0 , 1.0 , 0.0 , -32.0 , 0.0 , 0.0 , 0.0 , 180 , 1 , false ], }, } # End BATTLE_POPUP. end # Addon end # BattleLuna #============================================================================== # ■ Game_BattlerBase #============================================================================== class Game_BattlerBase #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :popups #-------------------------------------------------------------------------- # new method: create_popup #-------------------------------------------------------------------------- def create_popup(data, rule = :default) return unless SceneManager.scene_is?(Scene_Battle) return unless BattleLuna::Addon::BATTLE_POPUP[:basic_setting][:enable] @popups ||= [] @popups.push([data, rule]) end #-------------------------------------------------------------------------- # new method: make_damage_popups #-------------------------------------------------------------------------- def make_damage_popups(user) if @result.hp_drain != 0 rule = :drained user.create_popup(["", nil], rule) rule = :hp_dmg if @result.hp_drain < 0 rule = :hp_heal if @result.hp_drain > 0 value = @result.hp_drain.abs user.create_popup(["#{value}", nil], rule) end if @result.mp_drain != 0 rule = :drained user.create_popup(["", nil], rule) rule = :mp_dmg if @result.mp_drain < 0 rule = :mp_heal if @result.mp_drain > 0 value = @result.mp_drain.abs user.create_popup(["#{value}", nil], rule) end #--- rule = :critical create_popup(["", nil], rule) if @result.critical if @result.hp_damage != 0 rule = :hp_dmg if @result.hp_damage > 0 rule = :hp_heal if @result.hp_damage < 0 value = @result.hp_damage.abs create_popup(["#{value}", nil], rule) end if @result.mp_damage != 0 rule = :mp_dmg if @result.mp_damage > 0 rule = :mp_heal if @result.mp_damage < 0 value = @result.mp_damage.abs create_popup(["#{value}", nil], rule) end if @result.tp_damage != 0 rule = :tp_dmg if @result.tp_damage > 0 rule = :tp_heal if @result.tp_damage < 0 value = @result.tp_damage.abs create_popup(["#{value}", nil], rule) end end alias battle_luna_dp_erase_state erase_state unless $imported["YEA-BattleEngine"] def erase_state(state_id) make_state_popup(state_id, :rem_state) if @states.include?(state_id) if $imported["YEA-BattleEngine"] game_battlerbase_erase_state_abe(state_id) else battle_luna_dp_erase_state(state_id) end end #-------------------------------------------------------------------------- # new method: make_during_state_popup #-------------------------------------------------------------------------- def make_during_state_popup state_id = most_important_state_id return if state_id == 0 make_state_popup(state_id, :dur_state) end #-------------------------------------------------------------------------- # new method: most_important_state_id #-------------------------------------------------------------------------- def most_important_state_id states.each {|state| return state.id unless state.message3.empty? } return 0 end #-------------------------------------------------------------------------- # new method: make_state_popup #-------------------------------------------------------------------------- def make_state_popup(state_id, type) return unless BattleLuna::Addon::BATTLE_POPUP[:basic_setting][:state_popup] state = $data_states[state_id] return if state.icon_index == 0 create_popup(["#{state.name}", state.icon_index], type) end #-------------------------------------------------------------------------- # new method: make_miss_popups #-------------------------------------------------------------------------- def make_miss_popups(user, item) return if dead? if @result.missed rule = :missed create_popup(["", nil], rule) end if @result.evaded rule = :evaded create_popup(["", nil], rule) end if @result.hit? && !@result.success rule = :failed create_popup(["", nil], rule) end if @result.hit? && item.damage.to_hp? if @result.hp_damage == 0 && @result.mp_damage == 0 rule = :nulled create_popup(["", nil], rule) end end end #-------------------------------------------------------------------------- # new method: make_rate_popup #-------------------------------------------------------------------------- def make_rate_popup(rate) return if rate == 1.0 if rate > 1.0 rule = :weakpoint elsif rate == 0.0 rule = :immune elsif rate < 0.0 rule = :absorbed else rule = :resistant end create_popup(["", nil], rule) end #-------------------------------------------------------------------------- # new method: make_buff_popup #-------------------------------------------------------------------------- def make_buff_popup(param_id, positive = true) return unless BattleLuna::Addon::BATTLE_POPUP[:basic_setting][:buff_popup] return unless SceneManager.scene_is?(Scene_Battle) return unless alive? name = Vocab::param(param_id) if positive rule = :add_buff buff_level = 1 else rule = :add_debuff buff_level = -1 end icon = buff_icon_index(buff_level, param_id) create_popup(["#{name}", icon], rule) end end # Game_BattlerBase #============================================================================== # ■ Game_Battler #============================================================================== class Game_Battler < Game_BattlerBase #-------------------------------------------------------------------------- # alias method: on_battle_end #-------------------------------------------------------------------------- alias battle_luna_dp_on_battle_end on_battle_end def on_battle_end battle_luna_dp_on_battle_end @popups ||= [] @popups.clear end #-------------------------------------------------------------------------- # alias method: item_apply #-------------------------------------------------------------------------- alias battle_luna_dp_item_apply item_apply unless $imported["YEA-BattleEngine"] def item_apply(user, item) if $imported["YEA-BattleEngine"] game_battler_item_apply_abe(user, item) else battle_luna_dp_item_apply(user, item) end @result.restore_damage make_miss_popups(user, item) make_damage_popups(user) end #-------------------------------------------------------------------------- # alias method: make_damage_value #-------------------------------------------------------------------------- alias battle_luna_dp_make_damage_value make_damage_value unless $imported["YEA-BattleEngine"] def make_damage_value(user, item) if $imported["YEA-BattleEngine"] game_battler_make_damage_value_abe(user, item) else battle_luna_dp_make_damage_value(user, item) end rate = item_element_rate(user, item) make_rate_popup(rate) end #-------------------------------------------------------------------------- # alias method: execute_damage #-------------------------------------------------------------------------- alias battle_luna_dp_execute_damage execute_damage unless $imported["YEA-BattleEngine"] def execute_damage(user) if $imported["YEA-BattleEngine"] game_battler_execute_damage_abe(user) else battle_luna_dp_execute_damage(user) end #make_damage_popups(user) end #-------------------------------------------------------------------------- # alias method: item_effect_recover_hp #-------------------------------------------------------------------------- alias battle_luna_dp_item_effect_recover_hp item_effect_recover_hp unless $imported["YEA-BattleEngine"] def item_effect_recover_hp(user, item, effect) if $imported["YEA-BattleEngine"] game_battler_item_effect_recover_hp_abe(user, item, effect) else battle_luna_dp_item_effect_recover_hp(user, item, effect) end #make_damage_popups(user) end #-------------------------------------------------------------------------- # alias method: item_effect_recover_mp #-------------------------------------------------------------------------- alias battle_luna_item_effect_recover_mp item_effect_recover_mp unless $imported["YEA-BattleEngine"] def item_effect_recover_mp(user, item, effect) if $imported["YEA-BattleEngine"] game_battler_item_effect_recover_mp_abe(user, item, effect) else battle_luna_item_effect_recover_mp(user, item, effect) end #make_damage_popups(user) end #-------------------------------------------------------------------------- # alias method: item_effect_gain_tp #-------------------------------------------------------------------------- alias battle_luna_item_effect_gain_tp item_effect_gain_tp unless $imported["YEA-BattleEngine"] def item_effect_gain_tp(user, item, effect) if $imported["YEA-BattleEngine"] game_battler_item_effect_gain_tp_abe(user, item, effect) else battle_luna_item_effect_gain_tp(user, item, effect) end #make_damage_popups(user) end #-------------------------------------------------------------------------- # alias method: add_new_state #-------------------------------------------------------------------------- alias battle_luna_dp_add_new_state add_new_state unless $imported["YEA-BattleEngine"] def add_new_state(state_id) if $imported["YEA-BattleEngine"] game_battler_add_new_state_abe(state_id) else battle_luna_dp_add_new_state(state_id) end make_state_popup(state_id, :add_state) if @states.include?(state_id) end #-------------------------------------------------------------------------- # alias method: add_buff #-------------------------------------------------------------------------- alias battle_luna_dp_add_buff add_buff unless $imported["YEA-BattleEngine"] def add_buff(param_id, turns) make_buff_popup(param_id, true) if $imported["YEA-BattleEngine"] game_battler_add_buff_abe(param_id, turns) else battle_luna_dp_add_buff(param_id, turns) end end #-------------------------------------------------------------------------- # alias method: add_debuff #-------------------------------------------------------------------------- alias battle_luna_dp_add_debuff add_debuff unless $imported["YEA-BattleEngine"] def add_debuff(param_id, turns) make_buff_popup(param_id, false) if $imported["YEA-BattleEngine"] game_battler_add_debuff_abe(param_id, turns) else battle_luna_dp_add_debuff(param_id, turns) end end #-------------------------------------------------------------------------- # alias method: regenerate_all #-------------------------------------------------------------------------- alias battle_luna_dp_regenerate_all regenerate_all unless $imported["YEA-BattleEngine"] def regenerate_all if $imported["YEA-BattleEngine"] game_battler_regenerate_all_abe else battle_luna_dp_regenerate_all end return unless alive? make_damage_popups(self) end end # Game_Battler #============================================================================== # ■ Sprite_Battler #============================================================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # new method: screen_x #-------------------------------------------------------------------------- unless Game_Actor.instance_methods.include?(:screen_x) def screen_x 0 end end #-------------------------------------------------------------------------- # new method: screen_y #-------------------------------------------------------------------------- unless Game_Actor.instance_methods.include?(:screen_y) def screen_y 0 end end #-------------------------------------------------------------------------- # new method: screen_z #-------------------------------------------------------------------------- unless Game_Actor.instance_methods.include?(:screen_z) def screen_y 0 end end end # Game_Actor #============================================================================== # ■ Sprite_Battler #============================================================================== class Sprite_Battler < Sprite_Base #-------------------------------------------------------------------------- # alias method: initialize #-------------------------------------------------------------------------- alias battle_luna_dp_initialize initialize def initialize(viewport, battler = nil) battle_luna_dp_initialize(viewport, battler) @popups = [] @popup_delay = 0 end #-------------------------------------------------------------------------- # alias method: setup_new_effect #-------------------------------------------------------------------------- alias battle_luna_dp_setup_new_effect setup_new_effect def setup_new_effect battle_luna_dp_setup_new_effect setup_popups end #-------------------------------------------------------------------------- # new method: setup_popups #-------------------------------------------------------------------------- def setup_popups setting = BattleLuna::Addon::BATTLE_POPUP return unless @battler.use_sprite? @battler.popups ||= [] @popup_delay -= 1 return if @popup_delay > 0 array = @battler.popups.shift return if array.nil? create_new_popup(array[0], array[1]) return if @battler.popups.size == 0 return if setting[:basic_setting][:no_delay].include?(array[1]) @popup_delay = setting[:basic_setting][:delay] end #-------------------------------------------------------------------------- # new method: create_new_popup #-------------------------------------------------------------------------- def create_new_popup(data, rule) return unless @battler return unless SceneManager.scene.is_a?(Scene_Battle) viewport = self.viewport popup = Sprite_PopupLuna.new(viewport, @battler, data, rule) @popups.push(popup) end #-------------------------------------------------------------------------- # alias method: update #-------------------------------------------------------------------------- alias battle_luna_dp_update update def update battle_luna_dp_update update_popups end #-------------------------------------------------------------------------- # new method: update_popups #-------------------------------------------------------------------------- def update_popups @popups.each { |popup| popup.update } @popups.each_with_index { |sprite, index| next unless sprite.disposed? @popups[index] = nil } @popups.compact! end #-------------------------------------------------------------------------- # alias method: dispose #-------------------------------------------------------------------------- alias battle_luna_dp_dispose dispose def dispose @popups.each { |popup| popup.dispose } @popups.clear battle_luna_dp_dispose end end # Sprite_Battler #============================================================================== # ■ Sprite_PopupLuna #============================================================================== class Sprite_PopupLuna < Sprite #-------------------------------------------------------------------------- # initialize #-------------------------------------------------------------------------- def initialize(viewport, battler, data, rule) super(viewport) @data = data @rule = rule #--- @style = rule @style = :default unless setting[:style_setting].has_key?(@style) @style = setting[:style_setting][@style] #--- @effects = rule @effects = :default unless setting[:effect_setting].has_key?(@effects) @effects = setting[:effect_setting][@effects].dup #--- @current_effect = nil @duration = 0 @battler = battler #--- start_popup start_effect update end #-------------------------------------------------------------------------- # setting #-------------------------------------------------------------------------- def setting BattleLuna::Addon::BATTLE_POPUP end #-------------------------------------------------------------------------- # start_popup #-------------------------------------------------------------------------- def start_popup self.bitmap = create_bitmap self.x = @battler.screen_x self.y = @battler.screen_y self.ox = self.bitmap.width / 2 self.oy = self.bitmap.height self.z = @battler.screen_z + 350 end #-------------------------------------------------------------------------- # create_bitmap #-------------------------------------------------------------------------- def create_bitmap bw = Graphics.width bw = bw + 48 if @data[1] bh = @style[3] * 2 bitmap = Bitmap.new(bw, bh) #--- bitmap.font.color.set(@style[0], @style[1], @style[2]) bitmap.font.size = @style[3] bitmap.font.bold = @style[4] bitmap.font.italic = @style[5] bitmap.font.name = @style[6] #--- dx = @data[1] ? 24 : 0; dy = 0 text = setting[:word_setting][@rule] text = setting[:word_setting][:default] unless text text = sprintf(text, @data[0]) bitmap.draw_text(dx, dy, bw - dx, bh, text, 1) #--- text_width = bitmap.text_size(text).width if @data[1] icon_bitmap = Cache.system("Iconset") icon_index = @data[1].to_i rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24) bitmap.blt((bw-text_width)/2-32, (bh - 24)/2, icon_bitmap, rect) end bitmap end #-------------------------------------------------------------------------- # start_effect #-------------------------------------------------------------------------- def start_effect @current_effect = @effects.shift return dispose if @current_effect.nil? effect = setting[:effect_setup][@current_effect] @duration = effect[8] #--- @zoom_x_rate = (effect[0] - self.zoom_x) / @duration @zoom_y_rate = (effect[1] - self.zoom_y) / @duration #--- @move_x = effect[4] @move_y = effect[5] #from 5 if effect[9] @move_x = @move_x * rand(0) @move_x = rand(10) % 2 == 0 ? -@move_x : @move_x end #--- @gravity = effect[6] #--- @opacity_rate = (effect[7] - self.opacity) / @duration.to_f #--- self.x += effect[2] self.y += effect[3] end #-------------------------------------------------------------------------- # update #-------------------------------------------------------------------------- def update super update_zoom update_move update_opacity update_effect end #-------------------------------------------------------------------------- # update_effect #-------------------------------------------------------------------------- def update_effect @duration -= 1 return if @duration > 0 start_effect end #-------------------------------------------------------------------------- # update_zoom #-------------------------------------------------------------------------- def update_zoom self.zoom_x += @zoom_x_rate self.zoom_y += @zoom_y_rate end #-------------------------------------------------------------------------- # update_move #-------------------------------------------------------------------------- def update_move self.x += @move_x self.y += @move_y @move_y += @gravity end #-------------------------------------------------------------------------- # update_opacity #-------------------------------------------------------------------------- def update_opacity self.opacity += @opacity_rate end #-------------------------------------------------------------------------- # dispose #-------------------------------------------------------------------------- def dispose self.bitmap.dispose if self.bitmap super end end # Sprite_PopupLuna #============================================================================== # ■ Window_BattleHelp #============================================================================== if $imported["YEA-BattleEngine"] class Window_BattleHelp < Window_Help #-------------------------------------------------------------------------- # alias method: update #-------------------------------------------------------------------------- alias battle_luna_yea_be_update update def update battle_luna_yea_be_update return unless $imported["YEA-BattleEngine"] return unless @actor_window && @enemy_window if !self.visible and @text != "" @text = "" return refresh end update_battler_name end end # Window_BattleHelp end #============================================================================== # ■ Sprite_Battler #============================================================================== class Sprite_Battler < Sprite_Base #-------------------------------------------------------------------------- # alias method: create_new_popup # Compatible with YEA - Battle Engine. #-------------------------------------------------------------------------- if $imported["YEA-BattleEngine"] && !$imported["YES-BattlePopup"] alias battle_luna_yea_create_new_popup create_new_popup def create_new_popup(value, rules, flags) battle_luna_yea_create_new_popup(value, rules, flags) @popups.each { |popup| popup.viewport = nil popup.z = @battler.screen_z + 1000 } end end end # Sprite_Battler #============================================================================== # ■ Game_ActionResult #============================================================================== class Game_ActionResult #-------------------------------------------------------------------------- # alias method: clear_stored_damage #-------------------------------------------------------------------------- alias battle_luna_yea_clear_stored_damage clear_stored_damage if $imported["YEA-BattleEngine"] def clear_stored_damage battle_luna_yea_clear_stored_damage unless $imported["YES-BattlePopup"] end #-------------------------------------------------------------------------- # alias method: store_damage #-------------------------------------------------------------------------- alias battle_luna_yea_store_damage store_damage if $imported["YEA-BattleEngine"] def store_damage battle_luna_yea_store_damage unless $imported["YES-BattlePopup"] end #-------------------------------------------------------------------------- # alias method: restore_damage #-------------------------------------------------------------------------- alias battle_luna_yea_restore_damage restore_damage if $imported["YEA-BattleEngine"] def restore_damage battle_luna_yea_restore_damage unless $imported["YES-BattlePopup"] end end # Game_ActionResult
=begin 护盾系统 by 炽天之咸鱼裁决 本插件基于yanfly引擎编写,没有yanfly也可运行,但是视觉效果会大打折扣 使用方法:此页面手动创建护盾类型,在技能或物品的备注栏调用 <addshield: x(,y,z...)> 为目标添加以下id的护盾 <shielddamage: "(技能公式)"> 用self替换b,用user替换a.技能仅对目标护盾造成此数值的伤害 <realdamage: "(技能公式)"> 用self替换b,用user替换a,技能对目标造成无视护盾的此数值的伤害 <shield_cancel: x&y-z(,a&b-c)> x表示消除的护盾编号,使用&隔开,可以输入all无视类型消除 z表示单次消除护盾数量的上限,用inf表示无限次 (新)现在可以使用技能驱散护盾 (新)增加了画面的刷新 护盾参数,除数值外,不需要则无需填写 value:护盾数值,不能为空 status:数组,附加状态,代码来自Ninjamida fade:护盾每回合增长数值(负数为减少数值) max:护盾自然增长的最大值 cansave:若为false,脱战后不可保留 protect:若为true,则在破碎后防止额外的伤害 no:编号,拥有编号的护盾生成时会顶替掉同编号的 life:护盾持续最大回合数 death参数已被移除 disappear:字符串,护盾由于击破以外的原因消失后执行以下代码 broken:字符串,护盾被击破后执行以下代码 battlecry:字符串,护盾生成后执行以下代码 element:数组,护盾只对以下属性的伤害有作用 color1/2:color 盾条颜色 heal:布尔,若值为true则治疗量会被转化为盾量 add:布尔,若值为true则新护盾会继承原有同编号护盾的所有属性 hp_heal:(支持使用技能公式)每回合为持有者恢复此数值的hp,负数则为减少 mp_heal:(支持使用技能公式)每回合为持有者恢复此数值的mp,负数则为减少 tp_heal:(支持使用技能公式)每回合为持有者恢复此数值的tp,负数则为减少 onlyattack:若值为true,则无法防御状态造成的伤害 icon:护盾图像的编号 (新)uncancel:开启时不能被驱散 =end module SHIELD TAKE_DAM= "吸收" HP_HEAL = "护盾恢复" HP_DAM = "护盾反噬" MP_HEAL = "护盾恢复" MP_DAM = "护盾反噬" TP_HEAL = "护盾恢复" TP_DAM = "护盾反噬" FADE = "护盾衰减" BREAK = "护盾破碎" DISAPPEAR = "护盾消失" REFRESH = "护盾刷新" NEW = "护盾" ADD = "护盾补充" PROTECT = "保护" GET_DAM= "吸收" S_DAM = "碎盾" R_DAM = "真实伤害" CANCEL = "驱散" end class Battler_shield attr_accessor :value attr_accessor :status attr_accessor :fade attr_accessor :cansave attr_accessor :protect attr_accessor :no attr_accessor :max attr_accessor :life attr_accessor :disappear attr_accessor :broken attr_accessor :color1 attr_accessor :color2 attr_accessor :battlecry attr_accessor :element attr_accessor :heal attr_accessor :add attr_accessor :hp_heal attr_accessor :mp_heal attr_accessor :tp_heal attr_accessor :onlyattack attr_accessor :icon attr_accessor :uncancel def initialize(type,user,target) @user = user @target = target case type #以如下格式创建自定义的护盾 when 1 @value = user.mhp - user.hp + 30 @max = 0 @cansave = false @protect = false @no = 1 @life = 5 @add = true @onlyattack = true when 2 @value = user.mhp * 0.25 - user.hp * 0.25 + 200 .to_i @max = 0 @cansave = false @protect = false @no = 1 @life = 5 @add = true @onlyattack = true when 3 @value = 10 @max = 0 @cansave = false @protect = false @no = 1 @life = 999 @add = true @onlyattack = true when 4 @value = 1000 @max = 0 @cansave = false @protect = true @no = 1 @life = 7 @add = true @onlyattack = true when 5 @value = 30 @max = 0 @cansave = false @protect = true @no = 1 @life = 3 @add = true @onlyattack = true when 6 @value = 1 @max = 0 @cansave = false @protect = true @no = 1 @life = 2 @add = true @onlyattack = true when 7 @value = @user.hp/4 @cansave = false when 8 @value = 1 @protect = true @cansave = false end ################################## msgbox("护盾值不能为空") if @value == nil @value = @value.to_i end end class Sprite_Seed#伴生精灵参数 attr_accessor :icon#图像与色调 attr_accessor :dx#相对战斗者的x值 attr_accessor :dy#相对战斗者的y值 attr_accessor :dz#相对战斗者的z值 attr_accessor :opacity#透明度 attr_accessor :begin#入场动画id attr_accessor :exist#持续时播放的动画id attr_accessor :end#退场动画id def initialize(n) case n when 1 @icon = ["terry.png",0] @dx = 0 @dy = 0 @dz = 0 @opacity = 100 end end end ############################################################################# class RPG::BaseItem attr_accessor :shield attr_accessor :s_damage attr_accessor :r_damage def shield if @shield.nil? @shield = [] if @note =~ /<addshield:[ ](.*)>/i for x in $1.split(",") @shield += [x.to_i] end end end @shield end def shield_damage if @s_damage.nil? @s_damage = 0 if @note =~ /<shielddamage:[ ](.*)>/i @s_damage = $1.to_s end end @s_damage end def real_damage if @r_damage.nil? @r_damage = 0 if @note =~ /<realdamage:[ ](.*)>/i @r_damage = $1.to_s end end @r_damage end def shield_cancel if @shield_cancel.nil? @shield_cancel = {} if @note =~ /<shield_cancel:[ ](.*)>/i lines = $1.to_s.split(",") lines.each{|s| list = s.split("-") if list.size == 2 k = list[0].delete(" ").split("&") v = list[1].delete(" ") @shield_cancel[k] = v end } end end @shield_cancel end end ###############来自Ninjamida####################### class RPG::BaseItem def auto_states if @auto_states.nil? @auto_states = [] if @note =~ /<auto state:[ ](.*)>/i for x in $1.split(",") @auto_states += [x.to_i] end end end @auto_states end end class Game_Actor < Game_Battler def auto_states autostates = self.class.auto_states + actor.auto_states equips.each do |eq| autostates += eq.auto_states unless eq.nil? end states.each do |st| autostates += st.auto_states end @shield.each{|i| autostates += i.status if i.status != nil } autostates = autostates.uniq return autostates end def shield_init return if @shield @shield = [] @ex_sprite = {} @s = 0 end end class Game_Enemy < Game_Battler def auto_states autostates = enemy.auto_states states.each do |st| autostates += st.auto_states end @shield.each{|i| autostates += i.status if i.status != nil } autostates = autostates.uniq return autostates end end class Scene_Battle alias s_auto_state_battle_start battle_start def battle_start s_auto_state_battle_start $game_party.members.each{|mem| mem.add_auto_states status_redraw_target(mem) if $imported["YEA-BattleEngine"] } end end class Game_Battler alias s_auto_states_initialize initialize def initialize s_auto_states_initialize @old_auto_states = [] end def add_auto_states return if state?(death_state_id) auto_states.each do |st| if not state?(st) add_state(st) @state_turns[st] = -1 end end end def remove_old_auto_states auto_states.each do |as| @old_auto_states.delete(as) end @old_auto_states.each do |oas| remove_state(oas) end @old_auto_states = auto_states end alias s_auto_state_item_effect_remove_state item_effect_remove_state def item_effect_remove_state(user, item, effect) s_auto_state_item_effect_remove_state(user, item, effect) unless auto_states.include?(effect.data_id) end alias s_auto_state_refresh refresh def refresh s_auto_state_refresh add_auto_states remove_old_auto_states end end ############################################################### class Game_ActionResult attr_accessor :s_damage attr_accessor :r_damage attr_accessor :shield_cancel alias s_clear_damage_values clear_damage_values def clear_damage_values s_clear_damage_values @s_damage = 0 @r_damage = 0 @shield_cancel = {} end alias s_make_damage make_damage def make_damage(value, item) s_make_damage(value, item) @s_damage = item.shield_damage @r_damage = item.r_damage @shield_cancel = item.shield_cancel end end class Game_BattlerBase attr_accessor :shield attr_accessor :ex_sprite $imported = {} if $imported.nil? if $imported["YEA-BattleEngine"] alias shieldmake_damage_popups make_damage_popups def make_damage_popups(user) if @useshield != nil if @t_damage > 0 if @protect != nil text = SHIELD::PROTECT rules = "HP_HEL" @protect = nil else text = SHIELD::GET_DAM rules = "HP_DMG" end create_popup(text, rules) value = @t_damage.abs rules = "MP_DMG" text = sprintf("%s", value.group) create_popup(text, rules) elsif @t_damage < 0 text = SHIELD::ADD rules = "HP_HEL" @protect = nil create_popup(text, rules) value = @t_damage.abs rules = "MP_DMG" text = sprintf(+"%s", value.group) create_popup(text, rules) end end if @result.s_damage != 0 text = SHIELD::S_DAM rules = "HP_DMG" create_popup(text, rules) value = @result.s_damage text = sprintf("%s", value) create_popup(text, rules) @result.s_damage = 0 end if @result.r_damage != 0 text = SHIELD::R_DAM rules = "HP_DMG" create_popup(text, rules) value = @result.r_damage text = sprintf("%s", value) create_popup(text, rules) @result.r_damage = 0 end shieldmake_damage_popups(user) @t_damage = 0 end def make_miss_popups(user, item) return if dead? if @result.missed && item.shield == [] text = YEA::BATTLE::POPUP_SETTINGS[:missed] rules = "DEFAULT" create_popup(text, rules) end if @result.evaded && item.shield == [] text = YEA::BATTLE::POPUP_SETTINGS[:evaded] rules = "DEFAULT" create_popup(text, rules) end if @result.hit? && !@result.success && item.shield == [] text = YEA::BATTLE::POPUP_SETTINGS[:failed] rules = "DEFAULT" create_popup(text, rules) end if @result.hit? && item.damage.to_hp? && @useshield == nil && item.shield == [] if @result.hp_damage == 0 && @result.hp_damage == 0 text = YEA::BATTLE::POPUP_SETTINGS[:nulled] rules = "DEFAULT" create_popup(text, rules) end end @useshield = nil end end def shield_add(a,b) b.value += a.value b.status += a.status if b.status != nil and a.status != nil b.status = a.status if b.status == nil b.element += a.element if b.element != nil and a.element != nil b.element = a.element if b.element == nil b.fade += a.fade if b.fade != nil and a.fade != nil b.fade = a.fade if b.fade == nil b.cansave = false if a.cansave == false b.protect = true if a.protect == true b.max = a.max if b.max == nil b.life += a.life if b.life != nil and a.life != nil b.life = a.life if b.life == nil b.disappear = "#{a.disappear};#{b.disappear}" if b.disappear != nil and a.disappear != nil b.disappear = a.disappear if b.disappear == nil b.broken = "#{a.broken};#{b.broken}" if b.broken != nil and a.broken != nil b.broken = a.broken if b.broken == nil b.color1 = a.color1 if a.color1 b.color2 = a.color2 if a.color2 b.heal = true if a.heal == true b.hp_heal += a.hp_heal if b.hp_heal != nil and a.hp_heal != nil b.hp_heal = a.hp_heal if b.hp_heal == nil b.mp_heal += a.mp_heal if b.mp_heal != nil and a.mp_heal != nil b.mp_heal = a.mp_heal if b.mp_heal == nil b.tp_heal += a.tp_heal if b.tp_heal != nil and a.tp_heal != nil b.tp_heal = a.tp_heal if b.tp_heal == nil end def s sv = 0 @shield.each{|i| sv += i.value } return sv end def shield_init return if @shield @shield = [] @ex_sprite = {} @s = 0 end alias initializewithshield initialize def initialize initializewithshield shield_init end def nocheck(no) @shield.each_index{|i| if @shield[i].no == no @shield.delete_at(i) break end } end def shieldtotal n = 0 @shield.each{|i| n += i.value} return n end def draw_bar_rate a = [] b = draw_hp_rate a << b s = 1 - b t = shieldtotal @shield.each{|i| r = s * i.value.to_f / t a << r } return a end def shield_bar_rate a = [] b = draw_hp_rate s = 1 - b t = shieldtotal @shield.each{|i| r = s * i.value.to_f / t a << r } return a end def shield_rate s = shieldtotal if @hp + s <= mhp return s.to_f / mhp else return s.to_f / (s + @hp).to_f end end def draw_hp_rate s = shieldtotal if @hp + s <= mhp return @hp.to_f / mhp else return @hp.to_f / (s + @hp).to_f end end def draw_shield_rate s = shieldtotal if @hp + s <= mhp return s.to_f / (mhp - @hp) else return 1 end end end class Game_Battler < Game_BattlerBase def shield_heal shield_hp_heal shield_mp_heal shield_tp_heal end def shield_hp_heal @shield.each_index{|i| if @shield[i].hp_heal != nil value = @shield[i].hp_heal value = self.mhp - @hp if (@hp + value) > self.mhp value = @hp if (@hp + value) < 0 if $imported["YEA-BattleEngine"] if value > 0 rules = "HP_HEL" text = SHIELD::HP_HEAL create_popup(text, rules) text = "+#{value}" create_popup(text, rules) elsif value < 0 rules = "HP_DMG" text = SHIELD::HP_DAM create_popup(text, rules) text = "-#{-value}" create_popup(text, rules) end end @hp += value end } end def shield_mp_heal @shield.each_index{|i| if @shield[i].mp_heal != nil value = @shield[i].mp_heal value = @self.mmp - @mp if (@mp + value) > self.mmp value = @mp if (@mp + value) < 0 if $imported["YEA-BattleEngine"] if value > 0 rules = "MP_HEL" text = SHIELD::MP_HEAL create_popup(text, rules) text = "+#{value}" create_popup(text, rules) elsif value < 0 rules = "MP_DMG" text = SHIELD::MP_DAM create_popup(text, rules) text = "-#{-value}" create_popup(text, rules) end end @mp += value end } end def shield_tp_heal @shield.each_index{|i| if @shield[i].tp_heal != nil value = @shield[i].tp_heal value = 100 - @tp if (@tp + value) > 100 value = @tp if (@tp + value) < 0 if $imported["YEA-BattleEngine"] if value > 0 rules = "MP_HEL" text = SHIELD::TP_HEAL create_popup(text, rules) text = "+#{value}" create_popup(text, rules) elsif value < 0 rules = "MP_DMG" text = SHIELD::TP_DAM create_popup(text, rules) text = "-#{-value}" create_popup(text, rules) end end @tp += value end } end alias shieldon_turn_end on_turn_end def on_turn_end shield_heal s = @shield.size - 1 i = 0 while i <= s fade = @shield[i].fade if fade != nil and fade != 0 if @shield[i].max != nil ts = @shield[i].value + fade if @shield[i].max > @shield[i].value fade = @shield[i].max - @shield[i].value if ts > @shield[i].max else fade = 0 end end rules = "MP_DMG" text = SHIELD::FADE create_popup(text, rules) if $imported["YEA-BattleEngine"] text = sprintf(+"%s", fade) if fade > 0 text = sprintf("%s", fade) if fade < 0 create_popup(text, rules) if $imported["YEA-BattleEngine"] @shield[i].value += fade end life = @shield[i].life if life != nil @shield[i].life -= 1 end if @shield[i].value <= 0 or @shield[i].life == 0 shielddisappear(i) i -= 1 s = @shield.size - 1 end i += 1 end shieldon_turn_end end def addshield(item,user,target) return if item.shield == nil item.shield.each{|i| s = Battler_shield.new(i,user,target) if s.no != nil @shield.each_index{|i| if @shield[i].no == s.no shield_add(@shield[i],s) if @shield[i].add == true or s.add == true @ex_sprite[@shield[i]].kill unless @shield[i].icon.nil? @shield.delete_at(i) @s_fresh = true break end } end if self.class == Game_Enemy scene = SceneManager.scene.spriteset.viewport1 else scene = nil end @ex_sprite[s]=Sprite_Battler_Ex.new(scene,Sprite_Seed.new(s.icon),self) unless s.icon.nil? @s_value << s.value @shield << s eval s.battlecry if s.battlecry != nil } if $imported["YEA-BattleEngine"] if @s_value != [] and @s_value != nil if @s_fresh != nil text = SHIELD::REFRESH rules = "HP_HEL" create_popup(text, rules) @s_fresh = nil else text = SHIELD::NEW rules = "HP_DMG" create_popup(text, rules) end @s_value.each{|i| value = i.abs text = sprintf("%s", value.group) create_popup(text, rules) } @s_value = [] end end shield_refresh end def shield_refresh SceneManager.scene.update_basic refresh end def shielddisappear(i) $imported = {} if $imported.nil? if $imported["YEA-BattleEngine"] if @shield[i].value == 0 rules = "HP_DMG" text = SHIELD::BREAK create_popup(text, rules) if $imported["YEA-BattleEngine"] else rules = "HP_DMG" text = SHIELD::DISAPPEAR create_popup(text, rules) if $imported["YEA-BattleEngine"] end end if @shield[i].value == 0 eval @shield[i].broken if @shield[i].broken != nil else eval @shield[i].disappear if @shield[i].disappear != nil end @ex_sprite[@shield[i]].kill unless @shield[i].icon.nil? @shield.delete_at(i) end def regenerate_hp #状态伤害 damage = -(mhp * hrg).to_i perform_map_damage_effect if $game_party.in_battle && damage > 0 @result.hp_damage = [damage, max_slip_damage].min state_shielduse self.hp -= @result.hp_damage end def state_shielduse return if @result.hp_damage == 0 if @result.hp_damage < 0 healshield return end unless @shield.empty? size = @shield.size n = size - 1 while n >= 0 if @s_invalid.include?(n) n -= 1 next end if @shield[n].onlyattack == true n -= 1 next end @result.hp_damage -= @shield[n].value if @result.hp_damage >= 0 #碎盾 if @shield[n].protect == true @result.hp_damage = 0 @protect = true end #碎盾保护 @t_damage += @shield[n].value shielddisappear(n) else #未碎盾 @t_damage += @shield[n].value @t_damage += @result.hp_damage @shield[n].value = -@result.hp_damage @result.hp_damage = 0 end break if @result.hp_damage == 0 n -= 1 end @useshield = true if @t_damage != 0 end end def shielddamage return if @result.s_damage == 0 @result.s_damage = 0 if @shield.empty? unless @shield.empty? dam = @result.s_damage size = @shield.size n = size - 1 while n >= 0 @result.s_damage -= @shield[n].value if @result.s_damage >= 0 #碎盾 @s_damage += @shield[n].value @shield.delete_at(n) else #未碎盾 @s_damage += @shield[n].value @s_damage += @result.s_damage @shield[n].value = -@result.s_damage @result.s_damage = 0 end break if @result.s_damage == 0 n -= 1 end @result.s_damage = 0 if @result.s_damage < 0 @result.s_damage = dam - @result.s_damage end end def healshield unless @shield.empty? size = @shield.size n = size - 1 while n >= 0 if @shield[n].heal == true @shield[n].value -= @result.hp_damage @t_damage = -@result.hp_damage @result.hp_damage = 0 return end n -= 1 end end end def useshield shielddamage return if @result.hp_damage == 0 if @result.hp_damage < 0 healshield return end unless @shield.empty? size = @shield.size n = size - 1 while n >= 0 if @s_invalid.include?(n) n -= 1 next end @result.hp_damage -= @shield[n].value if @result.hp_damage >= 0 #碎盾 if @shield[n].protect == true @result.hp_damage = 0 @protect = true end #碎盾保护 @t_damage += @shield[n].value shielddisappear(n) else #未碎盾 @t_damage += @shield[n].value @t_damage += @result.hp_damage @shield[n].value = -@result.hp_damage @result.hp_damage = 0 end break if @result.hp_damage == 0 n -= 1 end @useshield = true if @t_damage != 0 end end def s_invalid(user, item) @s_invalid = [] return if item.damage == nil @shield.each_index{|n| if @shield[n].element != nil @shield[n].element.each{|i| @s_invalid << n unless user.atk_elements.include?(i) or item.damage.element_id == i } end } end def item_element(i) if item.damage.element_id < 0 user.atk_elements else item.damage.element_id end end alias item_applyshield item_apply def item_apply(user, item) @s_value = [] cancel_shield(user, item) s_invalid(user, item) addshield(item,user,self) #make_damage_popups(user) item_applyshield(user, item) end def cancel_shield(user, item) list = item.shield_cancel return if list.empty? list.each{|k,v| counter = 0 ok = false while !ok shield = find_shield_to_cancel(k) if shield @shield.delete(shield) popup_cancel_shield counter += 1 if v != "inf" ok = true if counter >= v.to_i end else ok = true end end } end def popup_cancel_shield return unless $imported["YEA-BattleEngine"] text = SHIELD::CANCEL rules = "CRITICAL" create_popup(text,rules) end def find_shield_to_cancel(list) @shield.each{|s| return s if check_shield_cancel(s,list) } return false end def check_shield_cancel(shield,list) return false if shield.uncancel list.each{|l| return true if l == "all" next unless shield.no return true if l.to_i == shield.no } end alias s_make_damage_value make_damage_value def make_damage_value(user, item) s_make_damage_value(user, item) r = eval(item.real_damage.to_s) @result.r_damage = r.to_i s = eval(item.s_damage.to_s) @result.s_damage = s.to_i end alias execute_damagewithshield execute_damage def execute_damage(user) @t_damage = 0 @s_damage = 0 useshield self.hp -= [@result.r_damage,self.hp].min execute_damagewithshield(user) end alias shieldon_battle_end on_battle_end def on_battle_end shieldon_battle_end s = @shield.size - 1 i = 0 while i <= s if @shield[i].cansave == false shielddisappear(i) i -= 1 s = @shield.size - 1 end i += 1 end end end class Window_BattleStatus def shield_gauge_color1; text_color(0); end; def shield_gauge_color2; text_color(8); end; def draw_actor_hp(actor, dx, dy, width = 124) s = actor.shieldtotal draw_gauge(dx, dy, width, actor.draw_hp_rate, hp_gauge_color1, hp_gauge_color2) draw_actor_shield(actor, dx + width * actor.draw_hp_rate , dy, width) cy = (Font.default_size - contents.font.size) / 2 + 1 draw_text(dx+2, dy+cy, 30, line_height, Vocab::hp_a) draw_current_and_max_values(dx, dy+cy, width, actor.hp, actor.mhp, hp_color(actor), normal_color) end def draw_actor_shield(actor, dx, dy, width = 124) actor.shield.each{|i| w = width.to_f * (1- actor.draw_hp_rate) * actor.draw_shield_rate * i.value / actor.shieldtotal c1 = i.color1 ? i.color1 : shield_gauge_color1 c2 = i.color2 ? i.color2 : shield_gauge_color2 draw_gauge(dx, dy, w , 1, c1, c2) dx += w } change_color(system_color) end end class Window_Base def shield_gauge_color1; text_color(0); end; def shield_gauge_color2; text_color(8); end; def draw_actor_hp(actor, dx, dy, width = 124) s = actor.shieldtotal draw_gauge(dx, dy, width, actor.draw_hp_rate, hp_gauge_color1, hp_gauge_color2) draw_actor_shield(actor, dx + width * actor.draw_hp_rate , dy, width) cy = (Font.default_size - contents.font.size) / 2 + 1 draw_text(dx+2, dy+cy, 30, line_height, Vocab::hp_a) draw_current_and_max_values(dx, dy+cy, width, actor.hp, actor.mhp, hp_color(actor), normal_color) end def draw_actor_shield(actor, dx, dy, width = 124) actor.shield.each{|i| w = width.to_f * (1- actor.draw_hp_rate) * actor.draw_shield_rate * i.value / actor.shieldtotal c1 = i.color1 ? i.color1 : shield_gauge_color1 c2 = i.color2 ? i.color2 : shield_gauge_color2 draw_gauge(dx, dy, w , 1, c1, c2) dx += w } change_color(system_color) end end #######来自yanfly与DoubleX############# $imported = {} if $imported.nil? if $imported["YEA-EnemyHPBars"] and $imported["DoubleX RMVXA Percentage Addon to YEA-EnemyHPBars"] class Enemy_HP_Gauge_Viewport < Viewport def initialize(battler, sprite, type) @battler = battler @base_sprite = sprite @type = type dw = YEA::BATTLE::ENEMY_GAUGE_WIDTH if @type == :percent && FIX_LARGE_TEXT dh = [TEXT_SIZE, YEA::BATTLE::ENEMY_GAUGE_HEIGHT].max else dh = YEA::BATTLE::ENEMY_GAUGE_HEIGHT end if @type != :hp and @type != :shield dw += 2 dh += 2 end @start_width = dw rect = Rect.new(0, 0, dw, dh) @current_hp = @battler.hp @current_mhp = @battler.mhp @current_hr = @battler.draw_hp_rate @current_sr = @battler.shield_bar_rate @target_gauge_width = target_gauge_width @gauge_rate = @current_hr setup_original_hide_gauge super(rect) self.z = 125 create_gauge_sprites self.visible = false update_position self.rect.width = @gauge_width if @type == :hp end def target_gauge_rate return @current_hr end def target_gauge_width return [@current_hr * @start_width, @start_width].min end def update_gauge unless @gauge_width == @target_gauge_width rate = 3 @target_gauge_width = target_gauge_width if @gauge_width > @target_gauge_width @gauge_width = [@gauge_width - rate, @target_gauge_width].max elsif @gauge_width < @target_gauge_width @gauge_width = [@gauge_width + rate, @target_gauge_width].min end @visible_counter = @gauge_width == 0 ? 10 : 60 rect.width = @gauge_width if @type == :hp end shield_update end def new_hp_updates return if @current_hr == @battler.draw_hp_rate and @current_sr == @battler.shield_bar_rate @current_hp = @battler.hp @current_mhp = @battler.mhp @current_hr = @battler.draw_hp_rate return if @gauge_rate == target_gauge_rate @gauge_rate = target_gauge_rate @target_gauge_width = target_gauge_width @visible_counter = 60 end def update_percentage return if @last_hp == @current_hp @last_hp = @current_hp set_percentage_font if ACTUAL_NUMBER percent = @current_hp.to_i.to_s else percent = "#{(@current_hp.to_f / @current_mhp.to_f * 100).to_i.to_s}%" end dw = @sprite.bitmap.text_size(percent).width @sprite.bitmap.clear @sprite.bitmap.draw_text(YEA::BATTLE::ENEMY_GAUGE_WIDTH + 2 - dw, 1, dw, @sprite.bitmap.text_size(percent).height, percent) end def create_gauge_sprites @sprite = Plane.new(self) @sprite.bitmap = Bitmap.new(rect.width * 4, rect.height) enemy = @battler.enemy if @type == :back colour = Colour.text_colour(enemy.back_gauge_colour) colour1 = colour2 = colour elsif @type == :hp colour1 = Colour.text_colour(enemy.hp_gauge_colour1) colour2 = Colour.text_colour(enemy.hp_gauge_colour2) elsif @type == :percent colour1 = colour2 = Color.new(0, 0, 0, 0) end dw = rect.width dw *= @battler.draw_hp_rate dh = rect.height @gauge_width = target_gauge_width if @type == :shield new_shield else @sprite.bitmap.gradient_fill_rect(0, 0, dw, dh, colour1, colour2) @sprite.bitmap.gradient_fill_rect(dw, 0, dw, dh, colour2, colour1) end @visible_counter = 0 end def new_shield return if @battler.shield == [] dh = rect.height dx = @gauge_width shield = @battler.shield shield.each_index{|i| dw = @start_width * @current_sr[i] dw = @start_width - dx + 3 if i == shield.size - 1 c1 = shield[i].color1 ? shield[i].color1 : Colour.text_colour(0) c2 = shield[i].color2 ? shield[i].color2 : Colour.text_colour(8) @sprite.bitmap.gradient_fill_rect(dx, 0, dw, dh, c1, c2) dx += dw } end def shield_update if @type == :shield and @battler.shield_bar_rate == [] @sprite.bitmap.clear end return if @current_sr == @battler.shield_bar_rate and @gauge_width == @target_gauge_width @current_sr = @battler.shield_bar_rate if @type == :shield dx = @gauge_width dh = rect.height shield = @battler.shield shield.each_index{|i| dw = @start_width * @current_sr[i] dw = @start_width - dx + 3 if i == shield.size - 1 c1 = shield[i].color1 ? shield[i].color1 : Colour.text_colour(0) c2 = shield[i].color2 ? shield[i].color2 : Colour.text_colour(8) @sprite.bitmap.gradient_fill_rect(dx, 0, dw, dh, c1, c2) dx += dw } end @visible_counter = 60 end def update_position dx = @battler.screen_x dy = @battler.screen_y @update_position = false return if @last_x == dx && @last_y == dy @last_x = dx @last_y = dy @update_position = true dx -= @start_width / 2 if @type == :percent dx += TEXT_X_OFFSET dy += TEXT_Y_OFFSET end rect.x = dx rect.y = dy dh = rect.height + 1 dh += 2 if @type == :hp or @type == :shield dy = [dy, Graphics.height - dh - 120].min dy += 1 if @type == :hp or @type == :shield # rect.y = dy end end class Sprite_Battler < Sprite_Base def create_enemy_gauges return if @battler.nil? return if @battler.actor? return unless @battler.enemy.show_gauge @back_gauge_viewport = Enemy_HP_Gauge_Viewport.new(@battler, self, :back) @hp_gauge_viewport = Enemy_HP_Gauge_Viewport.new(@battler, self, :hp) @shield_gauge_viewport = Enemy_HP_Gauge_Viewport.new(@battler, self, :shield) return unless @battler && !@battler.actor? && @battler.enemy.show_gauge @percent_gauge_viewport = Enemy_HP_Gauge_Viewport.new(@battler, self, :percent) end def dispose_enemy_gauges @back_gauge_viewport.dispose unless @back_gauge_viewport.nil? @hp_gauge_viewport.dispose unless @hp_gauge_viewport.nil? @shield_gauge_viewport.dispose unless @shield_gauge_viewport.nil? @percent_gauge_viewport.dispose if @percent_gauge_viewport end def update_enemy_gauges @back_gauge_viewport.update unless @back_gauge_viewport.nil? @hp_gauge_viewport.update unless @hp_gauge_viewport.nil? @shield_gauge_viewport.update unless @shield_gauge_viewport.nil? @percent_gauge_viewport.update if @percent_gauge_viewport end def update_enemy_gauge_value @back_gauge_viewport.new_hp_updates unless @back_gauge_viewport.nil? @hp_gauge_viewport.new_hp_updates unless @hp_gauge_viewport.nil? @shield_gauge_viewport.new_hp_updates unless @shield_gauge_viewport.nil? @percent_gauge_viewport.new_hp_updates if @percent_gauge_viewport end end end class Sprite_Battler alias ex_initialize initialize def initialize(viewport, battler = nil) ex_initialize(viewport, battler) end alias ex_update update def update ex_update return if self.class == Sprite_Battler_Ex return if @battler == nil return if @battler.ex_sprite == {} @battler.ex_sprite.each_value {|sprite| sprite.update} end alias s_start_effect start_effect def start_effect(effect_type) s_start_effect(effect_type) return if self.class == Sprite_Battler_Ex return if @battler == nil @battler.ex_sprite.each_value {|sprite| sprite.start_effect(effect_type) } unless @battler.ex_sprite == [] end alias s_dispose dispose def dispose s_dispose return if self.class == Sprite_Battler_Ex return if @battler == nil @battler.ex_sprite.each_value {|sprite| sprite.dispose } unless @battler.ex_sprite == [] end end class Sprite_Battler_Ex < Sprite_Battler def initialize(viewport,sprite,battler) super(viewport) @battler = battler @sprite = sprite @icon = @sprite.icon @opacity = @sprite.opacity @dx = @sprite.dx @dy = @sprite.dy @dz = @sprite.dz @begin = @sprite.begin @exist = @sprite.exist @end = @sprite.end @visible = false @live = true @path = "Graphics/Battlers/" appear end def appear if @sprite.begin != nil start_animation(@sprite.begin[0], @sprite.begin[1]) else start_effect(:appear) end end def dispose bitmap.dispose if bitmap super end def update super update_exist update_bitmap update_origin update_position update_effect update_kill end def update_exist if @sprite.exist != nil start_animation(@sprite.exist[0], @sprite.exist[1]) unless animation? end end def update_kill return if @live == true @live -= 1 dispose if @live == 0 end def kill @life = 60 if @end != nil start_animation(@end[0], @end[1]) end start_effect(:disappear) end def update_bitmap new_bitmap = Cache.load_bitmap(@path,@icon[0],@icon[1]) if bitmap != new_bitmap self.bitmap = new_bitmap init_visibility end end def init_visibility @battler_visible = @battler.alive? self.opacity = 0 unless @battler_visible end def update_position self.x = @battler.screen_x + @sprite.dx self.y = @battler.screen_y + @sprite.dy self.z = @battler.screen_z + @sprite.dz end def revert_to_normal self.blend_type = 0 self.color.set(0, 0, 0, 0) self.opacity = @sprite.opacity self.ox = bitmap.width / 2 if bitmap self.src_rect.y = 0 end end class Game_Enemy def shield_refresh sprite.update_enemy_gauge_value super end end class Game_Actor def shield_refresh SceneManager.scene.refresh_status if $game_party.in_battle super end end
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |