$game_player.damage_popup(-9999)
#============================================================================== # +++ MOG - DAMAGEPOPUP (v2.0) +++ #============================================================================== # By Moghunter # [url]http://www.atelier-rgss.com/[/url] #============================================================================== # Apresenta danos dos alvos em imagens. #============================================================================== # Será necessário ter a imagem Damage_Number.png na pasta /GRAPHICS/SYSTEM/ #============================================================================== #============================================================================== # DAMAGE POPUP ON CHARACTERS (Events) #============================================================================== # Basta usar o código abaixo para apresentar o dano nos eventos. # # damage_popup(STRING) # # STRING = valor do dano (Texto). # # # Para ativar o dano no jogador use o código abaixo # # $game_player.damage_popup(STRING) # #============================================================================== #============================================================================== # ● Histórico (Version History) #============================================================================== # v 2.0 - Apresentar o texto de recuperar nos efeitos de regenerar. # v 1.9 - Corrigido o erro de apresentar as condições sendo removidas quando a # batalha termina. # - Corrigido a centralização da string em danos do tipo texto. # - Corrigido o "erro" de apresentar a condição de Death. # v 1.8 - Corrigido o erro de apresentar os textos das condições (Status) quando # o battler estiver morto. # v 1.7 - Melhor codificação e compatibilidade. # v 1.6 - Corrigido o erro da opacidade do dano em EXP e GOLD. # v 1.5 - Possibilidade de ativar o dano nos eventos no mapa. # v 1.4 - Corrigido o erro do efeito drain. # v 1.3 - Corrigido o erro de crash randômico. (relativo a dispose de imagem.) # v 1.2 - Corrigido o limite do tamanho da string em palavras longas. # v 1.1 - Opção de definir a prioridade do dano. # v 1.0 - Primeiro lançamento. #============================================================================== module MOG_DAMAGEPOP #Definição do espaço entre a palavra MP/TP e o numero de dano. MP_TP_STRING_SPACE = 32 #Correção da posição do dano. DAMAGE_POSITION_CORRECTION = [0 ,0] #Apresentar a exp e ouro do inimigo. EXP_POPUP = true #Definição da prioridade do dano na tela. DAMAGE_Z = 60 end #============================================================================== # ■ Game_Battler #============================================================================== class Game_Battler < Game_BattlerBase attr_accessor :damage #-------------------------------------------------------------------------- # ● Initialize #-------------------------------------------------------------------------- alias mog_damage_sprite_initialize initialize def initialize @damage = [] mog_damage_sprite_initialize end #-------------------------------------------------------------------------- # ● Item Apply #-------------------------------------------------------------------------- alias mog_damage_pop_item_apply item_apply def item_apply(user, item) mog_damage_pop_item_apply(user, item) if @result.missed self.damage.push(["Missed","Missed"]) if self.hp > 0 elsif @result.evaded self.damage.push(["Evaded","Evaded"]) if self.hp > 0 end end #-------------------------------------------------------------------------- # ● Regenerate HP #-------------------------------------------------------------------------- alias mog_damage_pop_regenerate_hp regenerate_hp def regenerate_hp mog_damage_pop_regenerate_hp self.damage.push(["Regenerate",""]) if @result.hp_damage < 0 self.damage.push([@result.hp_damage,"HP"]) if @result.hp_damage != 0 end #-------------------------------------------------------------------------- # ● Regenerate MP #-------------------------------------------------------------------------- alias mog_damage_pop_regenerate_mp regenerate_mp def regenerate_mp mog_damage_pop_regenerate_mp # self.damage.push(["Regenerate",""]) if @result.mp_damage < 0 self.damage.push([@result.mp_damage,"MP"]) if @result.mp_damage != 0 end #-------------------------------------------------------------------------- # ● Regenerate TP #-------------------------------------------------------------------------- alias mog_damage_pop_regenerate_tp regenerate_tp def regenerate_tp mog_damage_pop_regenerate_tp tp_damage = 100 * trg self.damage.push([tp_damage,"TP"]) if tp_damage != 0 end #-------------------------------------------------------------------------- # ● Added New State #-------------------------------------------------------------------------- alias mog_damage_pop_add_new_state add_new_state def add_new_state(state_id) mog_damage_pop_add_new_state(state_id) # unless guard_feature?(state_id) st = $data_states[state_id] self.damage.push([st.name.to_s,"States Plus",false,st.icon_index]) if self.hp > 0 # end end #-------------------------------------------------------------------------- # ● Guard Feature? #-------------------------------------------------------------------------- def guard_feature?(state_id) st = $data_states[state_id] for i in st.features return true if i.code == 62 and i.data_id == 1 end return false end #-------------------------------------------------------------------------- # ● Remove State #-------------------------------------------------------------------------- alias mog_damage_pop_remove_state remove_state def remove_state(state_id) if state?(state_id) unless BattleManager.escape? st = $data_states[state_id] self.damage.push([st.name.to_s,"States Minus",false,st.icon_index]) if self.hp > 0 end end mog_damage_pop_remove_state(state_id) end #-------------------------------------------------------------------------- # ● Update State Turns #-------------------------------------------------------------------------- alias mog_damage_popup_update_state_turns update_state_turns def update_state_turns mog_damage_popup_update_state_turns states.each do |state| for features in state.features if features.data_id == 7 or features.data_id == 8 or features.data_id == 9 # self.damage.push([state.name.to_s + " Effect","States Effect"]) if self.hp > 0 end end end end #-------------------------------------------------------------------------- # ● Execute Damage #-------------------------------------------------------------------------- alias mog_damage_pop_execute_damage execute_damage def execute_damage(user) mog_damage_pop_execute_damage(user) user.damage.push([[email]-@result.hp_drain[/email],"HP",@result.critical]) if @result.hp_drain != 0 user.damage.push([[email]-@result.mp_drain[/email],"MP",@result.critical]) if @result.mp_drain != 0 end end #============================================================================== # ■ BattleManager #============================================================================== module BattleManager #-------------------------------------------------------------------------- # ● Escape? #-------------------------------------------------------------------------- def self.escape? @phase == nil end end #============================================================================== # ■ Game_ActionResult #============================================================================== class Game_ActionResult #-------------------------------------------------------------------------- # ● HP Damage Text #-------------------------------------------------------------------------- alias mog_damage_pop_hp_damage_text hp_damage_text def hp_damage_text if @hp_drain > 0 @battler.damage.push([@hp_drain,"HP",@critical]) elsif @hp_damage >= 0 @battler.damage.push([@hp_damage,"HP",@critical]) elsif @hp_damage < 0 @battler.damage.push([@hp_damage,"HP",@critical]) end mog_damage_pop_hp_damage_text end #-------------------------------------------------------------------------- # ● MP Damage Text #-------------------------------------------------------------------------- alias mog_damage_pop_mp_damage_text mp_damage_text def mp_damage_text if @mp_drain > 0 @battler.damage.push([@mp_drain,"MP",@critical]) elsif @mp_damage > 0 @battler.damage.push([@mp_damage,"MP",@critical]) elsif @mp_damage < 0 @battler.damage.push([@mp_damage,"MP",@critical]) end mog_damage_pop_mp_damage_text end #-------------------------------------------------------------------------- # ● TP Damage Text #-------------------------------------------------------------------------- alias mog_damage_pop_tp_damage_text tp_damage_text def tp_damage_text if @tp_damage > 0 @battler.damage.push([@tp_damage,"TP",@critical]) elsif @tp_damage < 0 @battler.damage.push([@tp_damage,"TP",@critical]) end mog_damage_pop_tp_damage_text end end #============================================================================== # ■ Game Actor #============================================================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # ● Level UP #-------------------------------------------------------------------------- alias mog_damage_pop_level_up level_up def level_up mog_damage_pop_level_up @damage.push(["Level UP","Level_UP"]) end end #============================================================================== # ■ Scene_Battle #============================================================================== class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # ● Invoke Counter Attack #-------------------------------------------------------------------------- alias mog_damage_popup_invoke_counter_attack invoke_counter_attack def invoke_counter_attack(target, item) mog_damage_popup_invoke_counter_attack(target, item) target.damage.push(["Counter","Counter"]) end #-------------------------------------------------------------------------- # ● Invoke Counter Attack #-------------------------------------------------------------------------- alias mog_damage_popup_invoke_magic_reflection invoke_magic_reflection def invoke_magic_reflection(target, item) mog_damage_popup_invoke_magic_reflection(target, item) target.damage.push(["Reflection","Reflection"]) end end #============================================================================== # ■ Damage Sprite #============================================================================== class Damage_Sprite < Sprite include MOG_DAMAGEPOP attr_accessor :duration #-------------------------------------------------------------------------- # ● Initialize #-------------------------------------------------------------------------- def initialize(viewport = nil,x = 0,y = 0,value = 0,index) super(viewport) dispose @image = Cache.system("Damage_Number") @x = x @y = y @value = value[0] @type = value[1] @critical = (value[2] and @value.to_i >= 0) ? true : false @state_index = value[3] @duration = 80 + (10 * index) @cw = @image.width / 10 @ch = @image.height / 7 @center_x = 0 @mp_space = (@type == "MP" or @type == "TP") ? MP_TP_STRING_SPACE : 0 if @value.is_a?(Numeric) create_damage_number elsif @value == "Missed" or @value == "Evaded" create_damage_miss else create_damage_string end self.x = @x - (@center_x * (@cw / 2)) + DAMAGE_POSITION_CORRECTION[0] self.y = @y + DAMAGE_POSITION_CORRECTION[1] self.opacity = 1 zx = self.viewport != nil ? self.viewport.z : 0 self.z = DAMAGE_Z + zx self.visible = false damage_dir = rand(2) @speed_x = straight_pop? ? 0 : damage_dir == 1 ? -rand(2) : rand(2) @speed_y = 0 end #-------------------------------------------------------------------------- # ● Straight Pop #-------------------------------------------------------------------------- def straight_pop? case @type when "Gold"; return true when "Exp"; return true when "Level_UP"; return true end return false end #-------------------------------------------------------------------------- # ● Create Damage Number #-------------------------------------------------------------------------- def create_damage_miss dam = @value == "Missed" ? 5 : 6 self.bitmap = Bitmap.new(@cw * 5, @ch) src_rect = Rect.new(0, dam * @ch, @cw * 10, @ch) self.bitmap.blt(0, 0, @image, src_rect) @center_x += 5 end #-------------------------------------------------------------------------- # ● Create Damage Number #-------------------------------------------------------------------------- def create_damage_number dam = @critical ? @ch * 2 : @value >= 0 ? 0 : @ch f = @value >= 0 ? 0 : 1 number_value = @value.to_s.split(//) self.bitmap = Bitmap.new(@mp_space + (@cw * number_value.size),@ch * 4) for r in f...number_value.size number_value_abs = number_value[r].to_i src_rect = Rect.new(@cw * number_value_abs, dam, @cw, @ch) self.bitmap.blt(@mp_space + (@cw * r), 0, @image, src_rect) @center_x += 1 end if @type == "MP" or @type == "TP" ty = @type == "MP" ? 3 : 4 src_rect = Rect.new(0, @ch * ty, @cw * 10, @ch) self.bitmap.blt(0, 0, @image, src_rect) @center_x += 2 end @center_x += 1 if @value < 0 end #-------------------------------------------------------------------------- # ● Create Damage String #-------------------------------------------------------------------------- def create_damage_string string_size = @value.to_s.split(//) @stg_size = string_size.size > 0 ? ((1 + string_size.size) * 24) : 32 self.bitmap = Bitmap.new(@stg_size,32) self.bitmap.font.size = 28 self.bitmap.font.bold = true @center_x = 2 + (string_size.size / 2) if @state_index != nil draw_states else execute_font_color damage_string = @value.to_s self.bitmap.draw_text(0, 0, @stg_size, 32, damage_string,0) end end #-------------------------------------------------------------------------- # ● Execute Font Color #-------------------------------------------------------------------------- def execute_font_color case @type when "Gold" @duration = 160 self.bitmap.font.color = Color.new(255,255,100) when "Exp" @duration = 120 self.bitmap.font.color = Color.new(0,255,100) when "Level_UP" self.bitmap.font.color = Color.new(50,155,255) else self.bitmap.font.color = Color.new(255,255,255) end end #-------------------------------------------------------------------------- # ● Draw States #-------------------------------------------------------------------------- def draw_states icon_image = Cache.system("Iconset") if @type == "States Plus" self.bitmap.font.color = Color.new(200,150,50) damage_string = "+ " + @value.to_s elsif @type == "States Minus" self.bitmap.font.color = Color.new(100,100,100) damage_string = "- " + @value.to_s end rect = Rect.new(@state_index % 16 * 24, @state_index / 16 * 24, 24, 24) self.bitmap.blt(0, 0, icon_image, rect) self.bitmap.draw_text(26, 0, @stg_size - 24, 32, damage_string,0) @center_x += 5 icon_image.dispose icon_image = nil end #-------------------------------------------------------------------------- # ● Dispose #-------------------------------------------------------------------------- def dispose return if @image == nil @image.dispose @image = nil self.bitmap.dispose self.bitmap = nil @duration = -1 end #-------------------------------------------------------------------------- # ● Update #-------------------------------------------------------------------------- def update return if self.bitmap == nil @duration -= 1 if @duration > 0 self.visible = @duration > 80 ? false : true case @duration when 65..80 self.opacity += 5 self.x += @speed_x self.y -= 5 critical_effect(0.05) when 50..65 self.opacity = 255 self.y -= 3 self.x += @speed_x critical_effect(0.05) when 35..50 self.opacity = 255 self.y += 3 critical_effect(-0.05) when 0..35 self.opacity -= 7 self.y -= 1 critical_effect(-0.05) end dispose if self.opacity <= 0 end #-------------------------------------------------------------------------- # ● Critical Effect #-------------------------------------------------------------------------- def critical_effect(value) return if !@critical self.zoom_x += value self.zoom_y = self.zoom_x end end #============================================================================== # ■ Sprite Battle #============================================================================== class Sprite_Battler < Sprite_Base #-------------------------------------------------------------------------- # ● Initialize #-------------------------------------------------------------------------- alias mog_damagepop_initialize initialize def initialize(viewport, battler = nil) mog_damagepop_initialize(viewport, battler) create_damage_sprite end #-------------------------------------------------------------------------- # ● Create Damage Sprite #-------------------------------------------------------------------------- def create_damage_sprite dispose_damage_sprite @damage_sprites = [] end #-------------------------------------------------------------------------- # ● Dispose #-------------------------------------------------------------------------- alias mog_damge_sprite_dispose dispose def dispose mog_damge_sprite_dispose dispose_damage_sprite end #-------------------------------------------------------------------------- # ● Dispose Damage Sprite #-------------------------------------------------------------------------- def dispose_damage_sprite return if @damage_sprites == nil @damage_sprites.each {|sprite| sprite.dispose } @damage_sprites.clear @battler.damage.clear if @battler != nil end #-------------------------------------------------------------------------- # ● Update #-------------------------------------------------------------------------- alias mog_damage_sprite_update update def update mog_damage_sprite_update update_damage_sprite end #-------------------------------------------------------------------------- # ● Create Damage #-------------------------------------------------------------------------- def create_damage return if !@battler.use_sprite? index = 0 sx = @battler.screen_x != nil ? @battler.screen_x : self.x sy = @battler.screen_y != nil ? @battler.screen_y : self.y @damage_sprites = [] if @damage_sprites == nil for i in @battler.damage @damage_sprites.push(Damage_Sprite.new(nil,sx,sy,i,index)) index += 1 end @battler.damage.clear end #-------------------------------------------------------------------------- # ● Update Damage Sprite #-------------------------------------------------------------------------- def update_damage_sprite return if @damage_sprites == nil or @battler == nil if @initial_damage == nil @initial_damage = true @battler.damage.clear return end create_damage if !@battler.damage.empty? if !@damage_sprites.empty? clear = 0 for sprite in @damage_sprites sprite.update if sprite.duration == 0 sprite.dispose end clear += 1 if sprite.duration > 0 end clear_damage if clear == 0 end end #-------------------------------------------------------------------------- # ● Update Damage Sprite #-------------------------------------------------------------------------- def clear_damage @damage_sprites.each {|sprite| sprite.dispose } @damage_sprites.clear end #-------------------------------------------------------------------------- # ● Update Collapse #-------------------------------------------------------------------------- alias mog_damage_pop_update_collapse update_collapse def update_collapse mog_damage_pop_update_collapse execute_exp_pop end #-------------------------------------------------------------------------- # ● Update Instant Collapse #-------------------------------------------------------------------------- alias mog_damage_pop_update_instant_collapse update_instant_collapse def update_instant_collapse mog_damage_pop_update_instant_collapse execute_exp_pop end #-------------------------------------------------------------------------- # ● Update Boss Collapse #-------------------------------------------------------------------------- alias mog_damage_pop_update_boss_collapse update_boss_collapse def update_boss_collapse mog_damage_pop_update_boss_collapse execute_exp_pop end #-------------------------------------------------------------------------- # ● Execute Exp Pop #-------------------------------------------------------------------------- def execute_exp_pop return if @dam_exp != nil return if !MOG_DAMAGEPOP::EXP_POPUP return if @battler.is_a?(Game_Actor) @dam_exp = true @battler.damage.push(["EXP " + @battler.exp.to_s,"Exp"]) if @battler.exp > 0 @battler.damage.push([Vocab::currency_unit + " " + @battler.gold.to_s,"Gold"]) if @battler.gold > 0 end end #============================================================================== # ■ Game Interpreter #============================================================================== class Game_Interpreter #-------------------------------------------------------------------------- # ● damage Popup #-------------------------------------------------------------------------- def damage_popup(value,type = nil, critical = false) type = (type == nil and value.is_a?(Numeric)) ? "HP" : type $game_map.events[@event_id].damage.push([value,type,critical]) if same_map? && @event_id > 0 end end #============================================================================== # ■ Game Character #============================================================================== class Game_CharacterBase attr_accessor :damage #-------------------------------------------------------------------------- # ● Initialize #-------------------------------------------------------------------------- alias mog_damage_popup_initialize initialize def initialize @damage = [] mog_damage_popup_initialize end #-------------------------------------------------------------------------- # ● damage Popup #-------------------------------------------------------------------------- def damage_popup(value,type = nil, critical = false) type = (type == nil and value.is_a?(Numeric)) ? "HP" : type @damage.push([value,type,critical]) end end #============================================================================== # ■ Sprite Character #============================================================================== class Sprite_Character < Sprite_Base #-------------------------------------------------------------------------- # ● Initialize #-------------------------------------------------------------------------- alias mog_damage_popup_initialize initialize def initialize(viewport, character = nil) mog_damage_popup_initialize(viewport, character) create_damage_sprite end #-------------------------------------------------------------------------- # ● Create Damage Sprite #-------------------------------------------------------------------------- def create_damage_sprite dispose_damage_sprite @damage_sprites = [] end #-------------------------------------------------------------------------- # ● Dispose #-------------------------------------------------------------------------- alias mog_damage_popup_dispose dispose def dispose mog_damage_popup_dispose dispose_damage_sprite end #-------------------------------------------------------------------------- # ● Dispose Damage Sprite #-------------------------------------------------------------------------- def dispose_damage_sprite return if @damage_sprites == nil @damage_sprites.each {|sprite| sprite.dispose } @damage_sprites.clear @character.damage.clear $game_temp.dispose_damage_sprite = false end #-------------------------------------------------------------------------- # ● Update #-------------------------------------------------------------------------- alias mog_damage_popup_update update def update mog_damage_popup_update update_damage_sprite end #-------------------------------------------------------------------------- # ● Create Damage #-------------------------------------------------------------------------- def create_damage index = 0 sx = self.x sy = self.y + @ch @damage_sprites = [] if @damage_sprites == nil for i in @character.damage @damage_sprites.push(Damage_Sprite.new(nil,sx,sy,i,index)) index += 1 end @character.damage.clear end #-------------------------------------------------------------------------- # ● Update Damage Sprite #-------------------------------------------------------------------------- def update_damage_sprite return if @damage_sprites == nil if @initial_damage == nil @initial_damage = true @character.damage.clear return end create_damage if !@character.damage.empty? if !@damage_sprites.empty? clear = 0 for sprite in @damage_sprites sprite.update if sprite.duration == 0 sprite.dispose end clear += 1 if sprite.duration > 0 end clear_damage if clear == 0 end end #-------------------------------------------------------------------------- # ● Update Damage Sprite #-------------------------------------------------------------------------- def clear_damage @damage_sprites.each {|sprite| sprite.dispose } @damage_sprites.clear @character.damage.clear end end #============================================================================= # ■ Game_Temp #============================================================================= class Game_Temp attr_accessor :dispose_damage_sprite #-------------------------------------------------------------------------- # ● Initialize #-------------------------------------------------------------------------- alias mog_dispose_damage_initialize initialize def initialize @dispose_damage_sprite = true mog_dispose_damage_initialize end end #============================================================================= # ■ Scene Manager #============================================================================= class << SceneManager #-------------------------------------------------------------------------- # ● Call #-------------------------------------------------------------------------- alias mog_damage_pop_call call def call(scene_class) $game_temp.dispose_damage_sprite = true mog_damage_pop_call(scene_class) end end #============================================================================= # ■ Scene Map #============================================================================= class Scene_Map < Scene_Base #-------------------------------------------------------------------------- # ● Update Scene #-------------------------------------------------------------------------- alias mog_dispose_damage_sprites_update update_scene def update_scene @spriteset.dispose_damage_sprites mog_dispose_damage_sprites_update end end #============================================================================= # ■ Spriteset Map #============================================================================= class Spriteset_Map #-------------------------------------------------------------------------- # ● Dispose Damage Sprites #-------------------------------------------------------------------------- def dispose_damage_sprites return if !$game_temp.dispose_damage_sprite return if @character_sprites == nil @character_sprites.each {|sprite| sprite.dispose_damage_sprite } $game_temp.dispose_damage_sprite = false end end #============================================================================= # ■ Scene Battle #============================================================================= class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # ● Update #-------------------------------------------------------------------------- alias mog_damage_popup_dispose_sprite_update update def update @spriteset.dispose_damage_sprites mog_damage_popup_dispose_sprite_update end end #============================================================================= # ■ Spriteset Battle #============================================================================= class Spriteset_Battle #-------------------------------------------------------------------------- # ● Dispose Damage Sprites #-------------------------------------------------------------------------- def dispose_damage_sprites return if !$game_temp.dispose_damage_sprite battler_sprites.each {|sprite| sprite.dispose_damage_sprite } $game_temp.dispose_damage_sprite = false end end $mog_rgss3_damage_pop = true
QQ截图20120922170749.jpg (20.75 KB, 下载次数: 19)
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |