#============================================================================== # 功能:战斗中显示敌人血和蓝于敌人脚下 # 适用:RMVX Ace # 作者:殇殃 2012.3.10 # 使用方法:复制整个脚本插入到Main之前 # 注意:由于血条是显示在敌人脚下,所以敌群的位置不能太靠底部,不然会被挡住。 # 可以自行更改坐标修改显示位置、血条的颜色等。 #============================================================================== # ■ Window_Base #------------------------------------------------------------------------------ # 游戏中全部窗口的超级类。 #============================================================================== class Window_Base < Window #-------------------------------------------------------------------------- # ● 描绘敌人HP #-------------------------------------------------------------------------- def draw_enemy_hp(enemy, x, y, width = 80) draw_gauge(x, y, width, enemy.hp_rate, hp_gauge_color1, hp_gauge_color2) self.contents.font.color = system_color self.contents.draw_text(x, y, 30, line_height, Vocab::hp_a) self.contents.font.color = hp_color(enemy) self.contents.draw_text(x + width - 64, y, 64, line_height, enemy.hp, 2) #一个数字占16像素 end #-------------------------------------------------------------------------- # ● 绘制敌人MP #-------------------------------------------------------------------------- def draw_enemy_mp(enemy, x, y, width = 80) draw_gauge(x, y, width, enemy.mp_rate, mp_gauge_color1, mp_gauge_color2) self.contents.font.color = system_color self.contents.draw_text(x, y, 30, line_height, Vocab::mp_a) self.contents.font.color = mp_color(enemy) self.contents.draw_text(x + width - 64, y, 64, line_height, enemy.mp, 2) end end #============================================================================== # ■ Sprite_Battler #------------------------------------------------------------------------------ # 战斗显示用活动块。Game_Battler 类的实例监视、 # 活动块的状态的监视、活动块状态自动变化。 #============================================================================== class Sprite_Battler < Sprite_Base #-------------------------------------------------------------------------- # ● 初始化对象 # viewport : 视区 # battler : 战斗者 (Game_Battler) #-------------------------------------------------------------------------- def initialize(viewport, battler = nil) super(viewport) @battler = battler @battler_visible = false @effect_type = nil @effect_duration = 0 if @battler.is_a?(Game_Enemy) width = 24 + 80 #边距12*2+血条的长度(在draw_enemy_hp中定义) height = 24 + 24*2 #边距12*2+line_height*2 x = @battler.screen_x - width/2 #screen_x是怪物图片水平方向上的中点位置 y = @battler.screen_y - 12 #边距12,显示HP/MP的窗口无边框 @enemy_hpmp_window = Window_Base.new(x, y, width, height) @enemy_hpmp_window.opacity = 0 @enemy_hpmp_window.contents = Bitmap.new(width - 24, height - 24)#位图比窗口小24像素取消边框 @enemy_hpmp_window.draw_enemy_hp(@battler, 0, 0) @old_hp = -1 @enemy_hpmp_window.draw_enemy_mp(@battler, 0, 24) @old_mp = -1 end end #-------------------------------------------------------------------------- # ● 释放 #-------------------------------------------------------------------------- def dispose if self.bitmap != nil self.bitmap.dispose @enemy_hpmp_window.dispose end super end #-------------------------------------------------------------------------- # ● 更新画面 #-------------------------------------------------------------------------- def update super if @battler == nil self.bitmap = nil else @use_sprite = @battler.use_sprite? if @use_sprite update_bitmap update_origin update_position end setup_new_effect setup_new_animation update_effect if @enemy_hpmp_window != nil and (@old_hp != @battler.hp or @old_mp != @battler.mp) if @battler.hp == 0 @enemy_hpmp_window.hide else @enemy_hpmp_window.contents.clear @enemy_hpmp_window.draw_enemy_hp(@battler, 0, 0) @old_hp = @battler.hp @enemy_hpmp_window.draw_enemy_mp(@battler, 0, 24) @old_mp = @battler.mp @enemy_hpmp_window.show #怪物死后再被复活 end #if battler.hp == 0 end end #if @battler == nil end end
#============================================================================== # +++ MOG - Combo Count (v1.2) +++ #============================================================================== # By Moghunter # [url]http://www.atelier-rgss.com/[/url] #============================================================================== # Apresenta a quantidade de acertos no alvo e o dano maximo. #============================================================================== # É necessário ter os arquivos imagens na pasta Graphics/Systems. # Combo_Damage.png # Combo_Hud.png # Combo_Number.png #============================================================================== #============================================================================== # ● Histórico (Version History) #============================================================================== # v 1.2 - Corrigido o erro de crash randômico. (relativo a dispose de imagem.) # v 1.1 - Opção de definir a prioridade da Hud. #============================================================================== module MOG_COMBO_COUNT #Ativar tempo para fazer combo. TIME_COUNT = true # Tempo para fazer um combo. (60 = 1s) COMBO_TIME = 120 # Cancelar a contagem de Combo caso o inimigo acertar o herói. ENEMY_CANCEL_COMBO = true # Posição geral das imagens. X Y COMBO_POSITION = [10,90] # Posição do número de HITS. X Y HIT_POSITION = [55,20] # Posição do número de dano. X Y TOTAL_POSITION = [100,-20] # Prioridade da HUD HUD_Z = 1 end #=============================================================================== # ■ Game_Temp #=============================================================================== class Game_Temp attr_accessor :combo_hit attr_accessor :max_damage attr_accessor :combo_time #-------------------------------------------------------------------------- # ● initialize #-------------------------------------------------------------------------- alias mog_combo_display_initialize initialize def initialize @combo_hit = 0 @max_damage = 0 @combo_time = 0 mog_combo_display_initialize end end #=============================================================================== # ■ Game_Battler #=============================================================================== class Game_Battler #-------------------------------------------------------------------------- # ● Item Apply #-------------------------------------------------------------------------- alias mog_combo_display_item_apply item_apply def item_apply(user, item) mog_combo_display_item_apply(user, item) unless @result.hit? $game_temp.combo_time = 0 end end #-------------------------------------------------------------------------- # ● execute_damage #-------------------------------------------------------------------------- alias mog_combo_display_execute_damage execute_damage def execute_damage(user) mog_combo_display_execute_damage(user) if @result.hp_damage > 0 if user.is_a?(Game_Actor) $game_temp.combo_hit += 1 $game_temp.max_damage += @result.hp_damage $game_temp.combo_time = MOG_COMBO_COUNT::COMBO_TIME else $game_temp.combo_time = 0 if MOG_COMBO_COUNT::ENEMY_CANCEL_COMBO == true end end end end #=============================================================================== # Scene_Battle #=============================================================================== class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # ● start #-------------------------------------------------------------------------- alias mog_combo_start start def start create_cb_sprite mog_combo_start end #-------------------------------------------------------------------------- # ● create_cb_sprite #-------------------------------------------------------------------------- def create_cb_sprite @combo_sprite = Combo_Sprite_Hud.new end #-------------------------------------------------------------------------- # ● Terminate #-------------------------------------------------------------------------- alias mog_combo_terminate terminate def terminate mog_combo_terminate @combo_sprite.dispose end #-------------------------------------------------------------------------- # ● update_basic #-------------------------------------------------------------------------- alias mog_combo_update_basic update_basic def update_basic mog_combo_update_basic update_combo_hit end #-------------------------------------------------------------------------- # ● Update Combo Hit #-------------------------------------------------------------------------- def update_combo_hit @combo_sprite.update if (@spriteset.animation? or @spriteset.effect?) @combo_sprite.combo_wait = true else @combo_sprite.combo_wait = false end end end #=============================================================================== # ■ Combo_Sprite_Hud #=============================================================================== class Combo_Sprite_Hud attr_accessor :combo_wait include MOG_COMBO_COUNT #-------------------------------------------------------------------------- # ● Initialize #-------------------------------------------------------------------------- def initialize dispose @combo_wait = false $game_temp.combo_time = 0 $game_temp.combo_hit = 0 $game_temp.max_damage = 0 @combo_hit_old = 0 @animation_speed = 0 @pos_x = COMBO_POSITION[0] @pos_x_fix = 0 @pos_y = COMBO_POSITION[1] create_combo_sprite create_total_damage_sprite create_hud_sprite end #-------------------------------------------------------------------------- # ● create_hud_sprite #-------------------------------------------------------------------------- def create_hud_sprite @hud = Sprite.new @hud.bitmap = Cache.system("Combo_HUD") @hud.z = HUD_Z @hud.x = COMBO_POSITION[0] @hud.y = COMBO_POSITION[1] @hud.opacity = 250 @hud.visible = false end #-------------------------------------------------------------------------- # ● create_total_damage_sprite #-------------------------------------------------------------------------- def create_total_damage_sprite @total_image = Cache.system("Combo_damage") @total = Sprite.new @total.bitmap = Bitmap.new(@combo_image.width,@combo_image.height) @total_im_cw = @total_image.width / 10 @total_im_ch = @total_image.height @total.z = HUD_Z + 1 @total_orig_x = COMBO_POSITION[0] + TOTAL_POSITION[0] @total_orig_y = COMBO_POSITION[1] + TOTAL_POSITION[1] @total.x = @total_orig_x @total.y = @total_orig_y @total.zoom_x = 1.00 @total.zoom_y = 1.00 @total.opacity = 250 @total.visible = false end #-------------------------------------------------------------------------- # ● create_combo_number #-------------------------------------------------------------------------- def create_combo_sprite @combo_image = Cache.system("Combo_Number") @combo = Sprite.new @combo.bitmap = Bitmap.new(@combo_image.width,@combo_image.height) @combo_im_cw = @combo_image.width / 10 @combo_im_ch = @combo_image.height @combo.z = HUD_Z + 2 @combo_orig_x = COMBO_POSITION[0] + HIT_POSITION[0] @combo_orig_y = COMBO_POSITION[1] + HIT_POSITION[1] @combo.zoom_x = 1.00 @combo.zoom_y = 1.00 @combo.opacity = 250 @combo.visible = false end #-------------------------------------------------------------------------- # ● Dispose #-------------------------------------------------------------------------- def dispose return if @hud == nil @hud.bitmap.dispose @hud.dispose @hud = nil @combo_image.dispose @combo.bitmap.dispose @combo.dispose @total_image.dispose @total.bitmap.dispose @total.dispose end #-------------------------------------------------------------------------- # ● Refresh #-------------------------------------------------------------------------- def refresh @combo_hit_old = $game_temp.combo_hit @combo.bitmap.clear @total.bitmap.clear @combo_number_text = $game_temp.combo_hit.abs.to_s.split(//) for r in [email]0..@combo_number_text.size[/email] - 1 @combo_number_abs = @combo_number_text[r].to_i @combo_src_rect = Rect.new(@combo_im_cw * @combo_number_abs, 0, @combo_im_cw, @combo_im_ch) @combo.bitmap.blt(@combo_im_cw * r, 0, @combo_image, @combo_src_rect) end @total_number_text = $game_temp.max_damage.abs.to_s.split(//) for r in [email]0..@total_number_text.size[/email] - 1 @total_number_abs = @total_number_text[r].to_i @total_src_rect = Rect.new(@total_im_cw * @total_number_abs, 0, @total_im_cw, @total_im_ch) @total.bitmap.blt(@total_im_cw * r, 20, @total_image, @total_src_rect) end #Combo Position @pos_x_fix = (@combo_im_cw / 2 * @combo_number_text.size) @combo.x = @combo_orig_x - @pos_x_fix @combo.y = @combo_orig_y @combo.zoom_x = 2 @combo.zoom_y = 2 @combo.opacity = 70 @combo.visible = true #Total Position @total.x = @total_orig_x + 20 @total.y = @total_orig_y @total.opacity = 100 @total.visible = true #Hud Position @hud.x = COMBO_POSITION[0] @hud.y = COMBO_POSITION[1] @hud.opacity = 255 @hud.visible = true end #-------------------------------------------------------------------------- # ● Slide Update #-------------------------------------------------------------------------- def slide_update return if !@combo.visible if $game_temp.combo_time > 0 and @combo_wait == false $game_temp.combo_time -= 1 if TIME_COUNT == true end if $game_temp.combo_time > 0 and $game_temp.combo_hit > 0 #Total Damage if @total.x > @total_orig_x @total.x -= 1 @total.opacity += 8 else @total.x = @total_orig_x @total.opacity = 255 end #Combo if @combo.zoom_x > 1.00 @combo.zoom_x -= 0.05 @combo.zoom_y -= 0.05 @combo.opacity += 8 else @combo.zoom_x = 1 @combo.zoom_y = 1 @combo.opacity = 255 @combo.x = @combo_orig_x - @pos_x_fix @combo.y = @combo_orig_y end elsif $game_temp.combo_time == 0 and @combo.visible @combo.x -= 5 @combo.opacity -= 10 @total.x -= 3 @total.opacity -= 10 @hud.x += 5 @hud.opacity -= 10 $game_temp.combo_hit = 0 @combo_hit_old = $game_temp.combo_hit $game_temp.max_damage = 0 if @combo.opacity <= 0 @combo.visible = false @total.visible = false @hud.visible = false end end end #-------------------------------------------------------------------------- # ● Cancel #-------------------------------------------------------------------------- def cancel $game_temp.combo_hit = 0 $game_temp.max_damage = 0 $game_temp.combo_time = 0 @combo_hit_old = $game_temp.combo_hit end #-------------------------------------------------------------------------- # ● Clear #-------------------------------------------------------------------------- def clear $game_temp.combo_time = 0 end #-------------------------------------------------------------------------- # ● Update #-------------------------------------------------------------------------- def update return if @hud == nil refresh if $game_temp.combo_hit != @combo_hit_old slide_update end end $mog_rgss3_combo_count = true
#============================================================================== # +++ MOG - Enemy HP Meter (v1.1) +++ #============================================================================== # By Moghunter # [url]http://www.atelier-rgss.com/[/url] #============================================================================== # Apresenta um medidor animado com o HP do inimigo. #============================================================================== # Para ocultar o HP do inimigo use a TAG abaixo na caixa de notas. # # <Hide HP> # #============================================================================== # Serão necessários as imagens. # # Battle_Enemy_HP_Layout.png # Battle_Enemy_HP_Meter.png # # #============================================================================== #============================================================================== # ● Histórico (Version History) #============================================================================== # v 1.1 - Corrigido o erro de crash randômico. (relativo a dispose de imagem.) #============================================================================== module MOG_ENEMY_HP #Posição geral do medidor em relação ao battler. POSITION_CORRECTION = [0,0] #Posição do medidor de HP. HP_METER_POSITION = [2,4] #Prioridade do medidor na tela. PRIORITY_Z = 101 end #============================================================================== # ■ Game Enemy #============================================================================== class Game_Enemy < Game_Battler attr_accessor :hp_meter_active #-------------------------------------------------------------------------- # ● Initialize #-------------------------------------------------------------------------- alias mog_enemy_hp_initialize initialize def initialize(index, enemy_id) mog_enemy_hp_initialize(index, enemy_id) hide = enemy.note =~ /<Hide HP>/i ? true : false @hp_meter_active = [false,hide] end end #============================================================================== # ■ Game_Battler #============================================================================== class Game_Battler < Game_BattlerBase #-------------------------------------------------------------------------- # ● Item Apply #-------------------------------------------------------------------------- alias mog_enemy_hp_item_apply item_apply def item_apply(user, item) mog_enemy_hp_item_apply(user, item) if self.is_a?(Game_Enemy) self.hp_meter_active[0] = true if @result.hp_damage != 0 end end #-------------------------------------------------------------------------- # ● Regenerate HP #-------------------------------------------------------------------------- alias mog_enemy_hp_regenerate_hp regenerate_hp def regenerate_hp mog_enemy_hp_regenerate_hp if self.is_a?(Game_Enemy) self.hp_meter_active[0] = true if @result.hp_damage != 0 end end end #============================================================================== # ■ Battle_Hud #============================================================================== class Enemy_HP include MOG_ENEMY_HP #-------------------------------------------------------------------------- # ● Initialize #-------------------------------------------------------------------------- def initialize(viewport = nil,enemy) dispose @enemy = enemy @fade_time = -1 create_layout create_hp_meter b_pos = [enemy.screen_x - (@layout.width / 2) + POSITION_CORRECTION[0], enemy.screen_y + POSITION_CORRECTION[1] - (@layout.height / 2)] @layout.opacity = 0 @org_pos1 = [b_pos[0],b_pos[1]] @layout.x = @org_pos1[0] @layout.y = @org_pos1[1] @layout.visible = false @hp_meter.opacity = 0 @hp_meter.visible = false @org_pos2 = [b_pos[0] + HP_METER_POSITION[0], b_pos[1] + HP_METER_POSITION[1]] @hp_meter.x = @org_pos2[0] @hp_meter.y = @org_pos2[1] @hp_meter.viewport = viewport @hp_meter.z = PRIORITY_Z @layout.viewport = viewport @layout.z = PRIORITY_Z @enemy.hp_meter_active[0] = false @hide = @enemy.hp_meter_active[1] end #-------------------------------------------------------------------------- # ● Create HP Meter #-------------------------------------------------------------------------- def create_layout @layout = Sprite.new @layout.bitmap = Cache.system("Battle_Enemy_HP_Layout") end #-------------------------------------------------------------------------- # ● Create HP Meter #-------------------------------------------------------------------------- def create_hp_meter @meter_image = Cache.system("Battle_Enemy_HP_Meter") @meter_cw = @meter_image.width @meter_ch = @meter_image.height / 2 @hp_meter = Sprite.new @hp_meter.bitmap = Bitmap.new(@meter_cw,@meter_ch) @hp_width_old = @meter_cw * @enemy.hp / @enemy.mhp end #-------------------------------------------------------------------------- # ● Hp Flow Update #-------------------------------------------------------------------------- def update_hp_flow return if !@layout.visible hp_width = @meter_cw * @enemy.hp / @enemy.mhp @hp_meter.bitmap.clear execute_damage_flow(hp_width) hp_src_rect = Rect.new(0, 0,hp_width, @meter_ch) @hp_meter.bitmap.blt(0,0, @meter_image, hp_src_rect) end #-------------------------------------------------------------------------- # ● Execute Damage Flow #-------------------------------------------------------------------------- def execute_damage_flow(hp_width) n = (@hp_width_old - hp_width).abs * 3 / 100 damage_flow = [[n, 2].min,0.5].max @hp_width_old -= damage_flow if @hp_width_old <= hp_width @hp_width_old = hp_width end src_rect_old = Rect.new(0,@meter_ch,@hp_width_old, @meter_ch) @hp_meter.bitmap.blt(0,0, @meter_image, src_rect_old) end #-------------------------------------------------------------------------- # ● Dispose #-------------------------------------------------------------------------- def dispose return if @meter_image == nil @layout.bitmap.dispose @layout.dispose @hp_meter.bitmap.dispose @hp_meter.dispose @meter_image.dispose @meter_image = nil end #-------------------------------------------------------------------------- # ● Update #-------------------------------------------------------------------------- def update return if @meter_image == nil return if @hide update_fade update_visible update_hp_flow refresh if @enemy.hp_meter_active[0] end #-------------------------------------------------------------------------- # ● Update Fade #-------------------------------------------------------------------------- def update_fade @fade_time -= 1 if @fade_time > 0 return if @fade_time != 0 @layout.opacity -= 10 @hp_meter.opacity -= 10 @layout.x += 1 @hp_meter.x += 1 @fade_time = -1 if @layout.opacity == 0 end #-------------------------------------------------------------------------- # ● Update Visible #-------------------------------------------------------------------------- def update_visible return if !@layout.visible vis = can_visible? @layout.visible = vis @hp_meter.visible = vis end #-------------------------------------------------------------------------- # ● Refresh #-------------------------------------------------------------------------- def refresh @enemy.hp_meter_active[0] = false @layout.opacity = 255 @hp_meter.opacity = 255 @layout.visible = true @hp_meter.visible = true @fade_time = 60 @layout.x = @org_pos1[0] @layout.y = @org_pos1[1] @hp_meter.x = @org_pos2[0] @hp_meter.y = @org_pos2[1] hp_width = @meter_cw * @enemy.hp / @enemy.mhp @hp_width_old = hp_width if @hp_width_old < hp_width update_hp_flow end #-------------------------------------------------------------------------- # ● Can Visible? #-------------------------------------------------------------------------- def can_visible? return false if @layout.opacity == 0 return true end end #============================================================================== # ■ Spriteset Battle #============================================================================== class Spriteset_Battle #-------------------------------------------------------------------------- # ● Initialize #-------------------------------------------------------------------------- alias mog_enemy_hp_initialize initialize def initialize mog_enemy_hp_initialize create_enemy_hp end #-------------------------------------------------------------------------- # ● Create Battle Hud #-------------------------------------------------------------------------- def create_enemy_hp dispose_enemy_hp @enemy_hp = [] for i in $game_troop.members @enemy_hp.push(Enemy_HP.new(@viewport1,i)) end end #-------------------------------------------------------------------------- # ● Dispose #-------------------------------------------------------------------------- alias mog_enemy_hp_dispose dispose def dispose mog_enemy_hp_dispose dispose_enemy_hp end #-------------------------------------------------------------------------- # ● Dispose Enemy HP #-------------------------------------------------------------------------- def dispose_enemy_hp return if @enemy_hp == nil @enemy_hp.each {|sprite| sprite.dispose } @enemy_hp.clear @enemy_hp = nil end #-------------------------------------------------------------------------- # ● Update #-------------------------------------------------------------------------- alias mog_enemy_hp_update update def update mog_enemy_hp_update update_enemy_hp end #-------------------------------------------------------------------------- # ● Update Enemy HP #-------------------------------------------------------------------------- def update_enemy_hp return if @enemy_hp == nil @enemy_hp.each {|sprite| sprite.update } end end $mog_rgss3_enemy_hp_meter = true
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |