Archeia

Damage Popup

Apr 3rd, 2017
154
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #==============================================================================
  2. # ■ BattleLuna: Damage Popup
  3. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  4. # This script allows you to have damage popups in battle.
  5. # This disables Yanfly Battle Engine's Built-In Popup. Remove this to use
  6. # that pop-up instead.
  7. #==============================================================================
  8. $imported = {} if $imported.nil?
  9. $imported["YES-BattlePopup"] = true
  10. module BattleLuna
  11.   module Addon
  12.    
  13.     BATTLE_POPUP = {
  14.       # Basic Configuration.
  15.       :basic_setting  =>  {
  16.         :enable      =>  true,       # Set to false to disable popup.
  17.         :state_popup =>  true,       # Set to false to disable state popup.
  18.         :buff_popup  =>  true,       # Set to false to disable buff popup.
  19.         :delay       =>  0,          # Delay between each popup.
  20.         :no_delay    =>  [:critical, :drained, :weakpoint, :resistant, :absorbed],
  21.       },
  22.      
  23.       # Configuration for words.
  24.       :word_setting   =>  {
  25.         :default    => "%s",        # SprintF for Default.
  26.         :hp_dmg     => "-%s ",      # SprintF for HP damage.
  27.         :hp_heal    => "+%s ",      # SprintF for HP healing.
  28.         :mp_dmg     => "-%s MP",    # SprintF for MP damage.
  29.         :mp_heal    => "+%s MP",    # SprintF for MP healing.
  30.         :tp_dmg     => "-%s TP",    # SprintF for MP damage.
  31.         :tp_heal    => "+%s TP",    # SprintF for MP healing.
  32.         :drained    => "DRAIN",     # Text display for draining HP/MP.
  33.         :critical   => "CRITICAL", # Text display for critical hit.
  34.         :missed     => "MISS",      # Text display for missed attack.
  35.         :evaded     => "EVADE!",    # Text display for evaded attack.
  36.         :nulled     => "NULL",      # Text display for nulled attack.
  37.         :failed     => "FAILED",    # Text display for a failed attack.
  38.         :add_state  => "%s",       # SprintF for added states.
  39.         :rem_state  => "%s",       # SprintF for removed states.
  40.         :dur_state  => "%s",        # SprintF for during states.
  41.         :weakpoint  => "weakpoint", # Appears if foe is weak to element.
  42.         :resistant  => "RESIST",    # Appears if foe is resistant to element.
  43.         :immune     => "IMMUNE",    # Appears if foe is immune to element.
  44.         :absorbed   => "ABSORB",    # Appears if foe can absorb the element.
  45.         :add_buff   => "%s",        # Appears when a positive buff is applied.
  46.         :add_debuff => "%s",        # Appears when a negative buff is applied.
  47.       },
  48.      
  49.       # Configuration for popup visual.
  50.       :style_setting  =>  {
  51.         # Type      => [Red, Green, Blue, Size, Bold, Italic, Font],
  52.         :default    => [255,   255,  255,   32, true,  false, Font.default_name],
  53.         :hp_dmg     => [255,   255,  255,   32, true,  false, Font.default_name],
  54.         :hp_heal    => [255,   255,  255,   32, true,  false, Font.default_name],
  55.         :mp_dmg     => [255,   255,  255,   32, true,  false, Font.default_name],
  56.         :mp_heal    => [255,   255,  255,   32, true,  false, Font.default_name],
  57.         :tp_dmg     => [255,   255,  255,   32, true,  false, Font.default_name],
  58.         :tp_heal    => [255,   255,  255,   32, true,  false, Font.default_name],
  59.         :drained    => [255,   255,  255,   32, true,  false, Font.default_name],
  60.         :critical   => [255,   255,  255,   32, true,  false, Font.default_name],
  61.         :missed     => [255,   255,  255,   32, true,  false, Font.default_name],
  62.         :evaded     => [255,   255,  255,   32, true,  false, Font.default_name],
  63.         :nulled     => [255,   255,  255,   32, true,  false, Font.default_name],
  64.         :failed     => [255,   255,  255,   32, true,  false, Font.default_name],
  65.         :add_state  => [255,   255,  255,   32, true,  false, Font.default_name],
  66.         :rem_state  => [255,   255,  255,   32, true,  false, Font.default_name],
  67.         :dur_state  => [255,   255,  255,   32, true,  false, Font.default_name],
  68.         :weakpoint  => [255,   255,  255,   32, true,  false, Font.default_name],
  69.         :resistant  => [255,   255,  255,   32, true,  false, Font.default_name],
  70.         :immune     => [255,   255,  255,   32, true,  false, Font.default_name],
  71.         :absorbed   => [255,   255,  255,   32, true,  false, Font.default_name],
  72.         :add_buff   => [255,   255,  255,   32, true,  false, Font.default_name],
  73.         :add_debuff => [255,   255,  255,   32, true,  false, Font.default_name],
  74.         :lvup       => [255,   255,  255,   20, false, false, Font.default_name],
  75.       },
  76.      
  77.       # Configuration for popup effect.
  78.       :effect_setting =>  {
  79.         # Type      => [Effect sequence],
  80.         :default    => [:up, :wait],
  81.         :hp_dmg     => [:affect, :fadein2, :normal1, :normal2, :fadeout],
  82.         :hp_heal    => [:fadein1, :fadein2, :normal1, :normal2, :fadeout],
  83.         :mp_dmg     => [:fadein1, :fadein2, :normal1, :normal2, :fadeout],
  84.         :mp_heal    => [:fadein1, :fadein2, :normal1, :normal2, :fadeout],
  85.         :tp_dmg     => [:fadein1, :fadein2, :normal1, :normal2, :fadeout],
  86.         :tp_heal    => [:fadein1, :fadein2, :normal1, :normal2, :fadeout],
  87.         :drained    => [:affect, :up    , :wait],
  88.         :critical   => [:affect, :up    , :wait],
  89.         :missed     => [:up    , :wait],
  90.         :evaded     => [:up    , :wait],
  91.         :nulled     => [:up    , :wait],
  92.         :failed     => [:up    , :wait],
  93.         :add_state  => [:affect, :up    , :wait, :wait],
  94.         :rem_state  => [:affect, :up    , :wait, :wait],
  95.         :dur_state  => [:affect, :up    , :wait],
  96.         :weakpoint  => [:affect, :up    , :wait],
  97.         :resistant  => [:affect, :up    , :wait],
  98.         :immune     => [:up    , :wait],
  99.         :absorbed   => [:affect, :up    , :wait],
  100.         :add_buff   => [:affect, :up    , :wait],
  101.         :add_debuff => [:affect, :up    , :wait],
  102.         :lvup       => [:up, :wait],
  103.       },
  104.      
  105.       :effect_setup   =>  {
  106.         #:type   => [ZoomX, ZoomY, StartX, StartY, MoveX, MoveY, Gravt, Opacity, Dur, Random],
  107.         :up      => [1.0  , 1.0  , 0.0   , 0.0   , 0.0  , -1.0 , 0.0  , 255    , 32 , false ],
  108.         :jump_1  => [1.0  , 1.0  , 0.0   , 0.0   , 0.0  , -6.4 , 0.4  , 255    , 33 , false ],
  109.         :jump_2  => [1.0  , 1.0  , 0.0   , 0.0   , 0.0  , -3.2 , 0.2  , 255    , 33 , false ],
  110.         :wait    => [1.0  , 1.0  , 0.0   , 0.0   , 0.0  , 0.0  , 0.0  , 0      , 20 , false ],
  111.         :affect  => [1.0  , 1.0  , 0.0   , -32.0 , 0.0  , 0.0  , 0.0  , 255    , 1  , false ],
  112.         :normal1 => [1.0  , 1.0  , 0.0   , 0.0   , 0.0  , 0 , 0.0  , 255    , 2 , false ],
  113.         :normal2 => [1.0  , 1.0  , 0.0   , 0.0   , 0.0  , 0 , 0.0  , 255    , 36 , false ],
  114.         :fadein1 => [1.1  , 1.1  , 0.0   , 0.0   , 0.0  , 0 , 0.0  , 0      , 5 , false ],
  115.         :fadein2 => [0.95 , 0.95 , 0.0   , 0.0   , 0.0  , 0 , 0.0  , 255    , 3 , false ],
  116.         :fadeout => [0.9  , 0.9  , 0.0   , 0.0   , 0.0  , 0 , 0.0  , 0    , 12 , false ],
  117.        
  118.       },
  119.      
  120.     } # End BATTLE_POPUP.
  121.    
  122.   end # Addon
  123. end # BattleLuna
  124.  
  125. #==============================================================================
  126. # ■ Game_BattlerBase
  127. #==============================================================================
  128.  
  129. class Game_BattlerBase
  130.  
  131.   #--------------------------------------------------------------------------
  132.   # * Public Instance Variables
  133.   #--------------------------------------------------------------------------
  134.   attr_accessor :popups
  135.  
  136.   #--------------------------------------------------------------------------
  137.   # new method: create_popup
  138.   #--------------------------------------------------------------------------
  139.   def create_popup(data, rule = :default)
  140.     return unless SceneManager.scene_is?(Scene_Battle)
  141.     return unless BattleLuna::Addon::BATTLE_POPUP[:basic_setting][:enable]
  142.     @popups ||= []
  143.     @popups.push([data, rule])
  144.   end
  145.  
  146.   #--------------------------------------------------------------------------
  147.   # new method: make_damage_popups
  148.   #--------------------------------------------------------------------------
  149.   def make_damage_popups(user)
  150.     if @result.hp_drain != 0
  151.       rule = :drained
  152.       user.create_popup(["", nil], rule)
  153.       rule = :hp_dmg  if @result.hp_drain < 0
  154.       rule = :hp_heal if @result.hp_drain > 0
  155.       value = @result.hp_drain.abs
  156.       user.create_popup(["#{value}", nil], rule)
  157.     end
  158.     if @result.mp_drain != 0
  159.       rule = :drained
  160.       user.create_popup(["", nil], rule)
  161.       rule = :mp_dmg  if @result.mp_drain < 0
  162.       rule = :mp_heal if @result.mp_drain > 0
  163.       value = @result.mp_drain.abs
  164.       user.create_popup(["#{value}", nil], rule)
  165.     end
  166.     #---
  167.     rule = :critical
  168.     create_popup(["", nil], rule) if @result.critical
  169.     if @result.hp_damage != 0
  170.       rule = :hp_dmg  if @result.hp_damage > 0
  171.       rule = :hp_heal if @result.hp_damage < 0
  172.       value = @result.hp_damage.abs
  173.       create_popup(["#{value}", nil], rule)
  174.     end
  175.     if @result.mp_damage != 0
  176.       rule = :mp_dmg  if @result.mp_damage > 0
  177.       rule = :mp_heal if @result.mp_damage < 0
  178.       value = @result.mp_damage.abs
  179.       create_popup(["#{value}", nil], rule)
  180.     end
  181.     if @result.tp_damage != 0
  182.       rule = :tp_dmg  if @result.tp_damage > 0
  183.       rule = :tp_heal if @result.tp_damage < 0
  184.       value = @result.tp_damage.abs
  185.       create_popup(["#{value}", nil], rule)
  186.     end
  187.   end
  188.  
  189.   #--------------------------------------------------------------------------
  190.   # alias method: erase_state
  191.   #--------------------------------------------------------------------------
  192.   alias battle_luna_dp_erase_state erase_state unless $imported["YEA-BattleEngine"]
  193.   def erase_state(state_id)
  194.     make_state_popup(state_id, :rem_state) if @states.include?(state_id)
  195.     if $imported["YEA-BattleEngine"]
  196.       game_battlerbase_erase_state_abe(state_id)
  197.     else
  198.       battle_luna_dp_erase_state(state_id)
  199.     end
  200.   end
  201.  
  202.   #--------------------------------------------------------------------------
  203.   # new method: make_during_state_popup
  204.   #--------------------------------------------------------------------------
  205.   def make_during_state_popup
  206.     state_id = most_important_state_id
  207.     return if state_id == 0
  208.     make_state_popup(state_id, :dur_state)
  209.   end
  210.  
  211.   #--------------------------------------------------------------------------
  212.   # new method: most_important_state_id
  213.   #--------------------------------------------------------------------------
  214.   def most_important_state_id
  215.     states.each {|state| return state.id unless state.message3.empty? }
  216.     return 0
  217.   end
  218.  
  219.   #--------------------------------------------------------------------------
  220.   # new method: make_state_popup
  221.   #--------------------------------------------------------------------------
  222.   def make_state_popup(state_id, type)
  223.     return unless BattleLuna::Addon::BATTLE_POPUP[:basic_setting][:state_popup]
  224.     state = $data_states[state_id]
  225.     return if state.icon_index == 0
  226.     create_popup(["#{state.name}", state.icon_index], type)
  227.   end
  228.  
  229.   #--------------------------------------------------------------------------
  230.   # new method: make_miss_popups
  231.   #--------------------------------------------------------------------------
  232.   def make_miss_popups(user, item)
  233.     return if dead?
  234.     if @result.missed
  235.       rule = :missed
  236.       create_popup(["", nil], rule)
  237.     end
  238.     if @result.evaded
  239.       rule = :evaded
  240.       create_popup(["", nil], rule)
  241.     end
  242.     if @result.hit? && !@result.success
  243.       rule = :failed
  244.       create_popup(["", nil], rule)
  245.     end
  246.     if @result.hit? && item.damage.to_hp?
  247.       if @result.hp_damage == 0 && @result.mp_damage == 0
  248.         rule = :nulled
  249.         create_popup(["", nil], rule)
  250.       end
  251.     end
  252.   end
  253.  
  254.   #--------------------------------------------------------------------------
  255.   # new method: make_rate_popup
  256.   #--------------------------------------------------------------------------
  257.   def make_rate_popup(rate)
  258.     return if rate == 1.0
  259.     if rate > 1.0
  260.       rule = :weakpoint
  261.     elsif rate == 0.0
  262.       rule = :immune
  263.     elsif rate < 0.0
  264.       rule = :absorbed
  265.     else
  266.       rule = :resistant
  267.     end
  268.     create_popup(["", nil], rule)
  269.   end
  270.  
  271.   #--------------------------------------------------------------------------
  272.   # new method: make_buff_popup
  273.   #--------------------------------------------------------------------------
  274.   def make_buff_popup(param_id, positive = true)
  275.     return unless BattleLuna::Addon::BATTLE_POPUP[:basic_setting][:buff_popup]
  276.     return unless SceneManager.scene_is?(Scene_Battle)
  277.     return unless alive?
  278.     name = Vocab::param(param_id)
  279.     if positive
  280.       rule = :add_buff
  281.       buff_level = 1
  282.     else
  283.       rule = :add_debuff
  284.       buff_level = -1
  285.     end
  286.     icon = buff_icon_index(buff_level, param_id)
  287.     create_popup(["#{name}", icon], rule)
  288.   end
  289.  
  290. end # Game_BattlerBase
  291.  
  292. #==============================================================================
  293. # ■ Game_Battler
  294. #==============================================================================
  295.  
  296. class Game_Battler < Game_BattlerBase
  297.  
  298.   #--------------------------------------------------------------------------
  299.   # alias method: on_battle_end
  300.   #--------------------------------------------------------------------------
  301.   alias battle_luna_dp_on_battle_end on_battle_end
  302.   def on_battle_end
  303.     battle_luna_dp_on_battle_end
  304.     @popups ||= []
  305.     @popups.clear
  306.   end
  307.  
  308.   #--------------------------------------------------------------------------
  309.   # alias method: item_apply
  310.   #--------------------------------------------------------------------------
  311.   alias battle_luna_dp_item_apply item_apply unless $imported["YEA-BattleEngine"]
  312.   def item_apply(user, item)
  313.     if $imported["YEA-BattleEngine"]
  314.       game_battler_item_apply_abe(user, item)
  315.     else
  316.       battle_luna_dp_item_apply(user, item)
  317.     end    
  318.     make_miss_popups(user, item)
  319.     make_damage_popups(user)
  320.   end
  321.  
  322.   #--------------------------------------------------------------------------
  323.   # alias method: make_damage_value
  324.   #--------------------------------------------------------------------------
  325.   alias battle_luna_dp_make_damage_value make_damage_value unless $imported["YEA-BattleEngine"]
  326.   def make_damage_value(user, item)
  327.     if $imported["YEA-BattleEngine"]
  328.       game_battler_make_damage_value_abe(user, item)
  329.     else
  330.       battle_luna_dp_make_damage_value(user, item)
  331.     end    
  332.     rate = item_element_rate(user, item)
  333.     make_rate_popup(rate)
  334.   end
  335.  
  336.   #--------------------------------------------------------------------------
  337.   # alias method: execute_damage
  338.   #--------------------------------------------------------------------------
  339.   alias battle_luna_dp_execute_damage execute_damage unless $imported["YEA-BattleEngine"]
  340.   def execute_damage(user)
  341.     if $imported["YEA-BattleEngine"]
  342.       game_battler_execute_damage_abe(user)
  343.     else
  344.       battle_luna_dp_execute_damage(user)
  345.     end    
  346.     #make_damage_popups(user)
  347.   end
  348.  
  349.   #--------------------------------------------------------------------------
  350.   # alias method: item_effect_recover_hp
  351.   #--------------------------------------------------------------------------
  352.   alias battle_luna_dp_item_effect_recover_hp item_effect_recover_hp unless $imported["YEA-BattleEngine"]
  353.   def item_effect_recover_hp(user, item, effect)
  354.     if $imported["YEA-BattleEngine"]
  355.       game_battler_item_effect_recover_hp_abe(user, item, effect)
  356.     else
  357.       battle_luna_dp_item_effect_recover_hp(user, item, effect)
  358.     end    
  359.     #make_damage_popups(user)
  360.   end
  361.  
  362.   #--------------------------------------------------------------------------
  363.   # alias method: item_effect_recover_mp
  364.   #--------------------------------------------------------------------------
  365.   alias battle_luna_item_effect_recover_mp item_effect_recover_mp unless $imported["YEA-BattleEngine"]
  366.   def item_effect_recover_mp(user, item, effect)
  367.     if $imported["YEA-BattleEngine"]
  368.       game_battler_item_effect_recover_mp_abe(user, item, effect)
  369.     else
  370.       battle_luna_item_effect_recover_mp(user, item, effect)
  371.     end  
  372.     #make_damage_popups(user)
  373.   end
  374.  
  375.   #--------------------------------------------------------------------------
  376.   # alias method: item_effect_gain_tp
  377.   #--------------------------------------------------------------------------
  378.   alias battle_luna_item_effect_gain_tp item_effect_gain_tp unless $imported["YEA-BattleEngine"]
  379.   def item_effect_gain_tp(user, item, effect)
  380.     if $imported["YEA-BattleEngine"]
  381.       game_battler_item_effect_gain_tp_abe(user, item, effect)
  382.     else
  383.       battle_luna_item_effect_gain_tp(user, item, effect)
  384.     end  
  385.     #make_damage_popups(user)
  386.   end
  387.  
  388.   #--------------------------------------------------------------------------
  389.   # alias method: add_new_state
  390.   #--------------------------------------------------------------------------
  391.   alias battle_luna_dp_add_new_state add_new_state unless $imported["YEA-BattleEngine"]
  392.   def add_new_state(state_id)
  393.     if $imported["YEA-BattleEngine"]
  394.       game_battler_add_new_state_abe(state_id)
  395.     else
  396.       battle_luna_dp_add_new_state(state_id)
  397.     end  
  398.     make_state_popup(state_id, :add_state) if @states.include?(state_id)
  399.   end
  400.  
  401.   #--------------------------------------------------------------------------
  402.   # alias method: add_buff
  403.   #--------------------------------------------------------------------------
  404.   alias battle_luna_dp_add_buff add_buff unless $imported["YEA-BattleEngine"]
  405.   def add_buff(param_id, turns)
  406.     make_buff_popup(param_id, true)
  407.     if $imported["YEA-BattleEngine"]
  408.       game_battler_add_buff_abe(param_id, turns)
  409.     else
  410.       battle_luna_dp_add_buff(param_id, turns)
  411.     end  
  412.   end
  413.  
  414.   #--------------------------------------------------------------------------
  415.   # alias method: add_debuff
  416.   #--------------------------------------------------------------------------
  417.   alias battle_luna_dp_add_debuff add_debuff unless $imported["YEA-BattleEngine"]
  418.   def add_debuff(param_id, turns)
  419.     make_buff_popup(param_id, false)
  420.     if $imported["YEA-BattleEngine"]
  421.       game_battler_add_debuff_abe(param_id, turns)
  422.     else
  423.       battle_luna_dp_add_debuff(param_id, turns)
  424.     end  
  425.   end
  426.  
  427.   #--------------------------------------------------------------------------
  428.   # alias method: regenerate_all
  429.   #--------------------------------------------------------------------------
  430.   alias battle_luna_dp_regenerate_all regenerate_all unless $imported["YEA-BattleEngine"]
  431.   def regenerate_all
  432.     if $imported["YEA-BattleEngine"]
  433.       game_battler_regenerate_all_abe
  434.     else
  435.       battle_luna_dp_regenerate_all
  436.     end  
  437.     return unless alive?
  438.     make_damage_popups(self)
  439.   end
  440.    
  441. end # Game_Battler
  442.  
  443. #==============================================================================
  444. # ■ Sprite_Battler
  445. #==============================================================================
  446.  
  447. class Game_Actor < Game_Battler
  448.  
  449.   #--------------------------------------------------------------------------
  450.   # new method: screen_x
  451.   #--------------------------------------------------------------------------
  452.   unless Game_Actor.instance_methods.include?(:screen_x)
  453.   def screen_x
  454.     0
  455.   end
  456.   end
  457.  
  458.   #--------------------------------------------------------------------------
  459.   # new method: screen_y
  460.   #--------------------------------------------------------------------------
  461.   unless Game_Actor.instance_methods.include?(:screen_y)
  462.   def screen_y
  463.     0
  464.   end
  465.   end
  466.  
  467.   #--------------------------------------------------------------------------
  468.   # new method: screen_z
  469.   #--------------------------------------------------------------------------
  470.   unless Game_Actor.instance_methods.include?(:screen_z)
  471.   def screen_y
  472.     0
  473.   end
  474.   end
  475.  
  476. end # Game_Actor
  477.  
  478. #==============================================================================
  479. # ■ Sprite_Battler
  480. #==============================================================================
  481.  
  482. class Sprite_Battler < Sprite_Base
  483.   attr_reader   :info_viewport
  484.   #--------------------------------------------------------------------------
  485.   # alias method: initialize
  486.   #--------------------------------------------------------------------------
  487.   alias battle_luna_dp_initialize initialize
  488.   def initialize(viewport, battler = nil)
  489.     battle_luna_dp_initialize(viewport, battler)
  490.     @popups = []
  491.     @popup_delay = 0
  492.   end
  493.  
  494.   #--------------------------------------------------------------------------
  495.   # alias method: setup_new_effect
  496.   #--------------------------------------------------------------------------
  497.   alias battle_luna_dp_setup_new_effect setup_new_effect
  498.   def setup_new_effect
  499.     battle_luna_dp_setup_new_effect
  500.     setup_popups
  501.   end
  502.  
  503.   #--------------------------------------------------------------------------
  504.   # new method: setup_popups
  505.   #--------------------------------------------------------------------------
  506.   def setup_popups
  507.     setting = BattleLuna::Addon::BATTLE_POPUP
  508.     return unless @battler.use_sprite?
  509.     @battler.popups ||= []
  510.     @popup_delay -= 1
  511.     return if @popup_delay > 0
  512.     array = @battler.popups.shift
  513.     return if array.nil?
  514.     create_new_popup(array[0], array[1])
  515.     return if @battler.popups.size == 0
  516.     return if setting[:basic_setting][:no_delay].include?(array[1])
  517.     @popup_delay = setting[:basic_setting][:delay]
  518.   end
  519.  
  520.   #--------------------------------------------------------------------------
  521.   # new method: create_new_popup
  522.   #--------------------------------------------------------------------------
  523.   def create_new_popup(data, rule)
  524.     return unless @battler
  525.     return unless SceneManager.scene.is_a?(Scene_Battle)
  526.     viewport = info_viewport
  527.     popup = Sprite_PopupLuna.new(viewport, @battler, data, rule)
  528.     @popups.push(popup)
  529.   end
  530.  
  531.   #--------------------------------------------------------------------------
  532.   # alias method: update
  533.   #--------------------------------------------------------------------------
  534.   alias battle_luna_dp_update update
  535.   def update
  536.     battle_luna_dp_update
  537.     update_popups
  538.   end
  539.  
  540.   #--------------------------------------------------------------------------
  541.   # new method: update_popups
  542.   #--------------------------------------------------------------------------
  543.   def update_popups
  544.     @popups.each { |popup| popup.update }
  545.     @popups.each_with_index { |sprite, index|
  546.       next unless sprite.disposed?
  547.       @popups[index] = nil
  548.     }
  549.     @popups.compact!
  550.   end
  551.  
  552.   #--------------------------------------------------------------------------
  553.   # alias method: dispose
  554.   #--------------------------------------------------------------------------
  555.   alias battle_luna_dp_dispose dispose
  556.   def dispose
  557.     @popups.each { |popup| popup.dispose }
  558.     @popups.clear
  559.     battle_luna_dp_dispose
  560.   end
  561.  
  562. end # Sprite_Battler
  563.  
  564. #==============================================================================
  565. # ■ Sprite_PopupLuna
  566. #==============================================================================
  567.  
  568. class Sprite_PopupLuna < Sprite
  569.  
  570.   #--------------------------------------------------------------------------
  571.   # initialize
  572.   #--------------------------------------------------------------------------
  573.   def initialize(viewport, battler, data, rule)
  574.     super(viewport)
  575.     @data = data
  576.     @rule = rule
  577.     #---
  578.     @style = rule
  579.     @style = :default unless setting[:style_setting].has_key?(@style)
  580.     @style = setting[:style_setting][@style]
  581.     #---
  582.     @effects = rule
  583.     @effects = :default unless setting[:effect_setting].has_key?(@effects)
  584.     @effects = setting[:effect_setting][@effects].dup
  585.     #---
  586.     @current_effect = nil
  587.     @duration = 0
  588.     @battler = battler
  589.     #---
  590.     start_popup
  591.     start_effect
  592.     update
  593.   end
  594.  
  595.   #--------------------------------------------------------------------------
  596.   # setting
  597.   #--------------------------------------------------------------------------
  598.   def setting
  599.     BattleLuna::Addon::BATTLE_POPUP
  600.   end
  601.  
  602.   #--------------------------------------------------------------------------
  603.   # start_popup
  604.   #--------------------------------------------------------------------------
  605.   def start_popup
  606.     self.bitmap = create_bitmap
  607.     self.x = @battler.screen_x
  608.     self.y = @battler.screen_y
  609.     self.ox = self.bitmap.width / 2
  610.     self.oy = self.bitmap.height
  611.     self.z = @battler.screen_z + 350
  612.   end
  613.  
  614.   #--------------------------------------------------------------------------
  615.   # create_bitmap
  616.   #--------------------------------------------------------------------------
  617.   def create_bitmap
  618.     bw = Graphics.width
  619.     bw = bw + 48 if @data[1]
  620.     bh = @style[3] * 2
  621.     bitmap = Bitmap.new(bw, bh)
  622.     #---
  623.     bitmap.font.color.set(@style[0], @style[1], @style[2])
  624.     bitmap.font.size   = @style[3]
  625.     bitmap.font.bold   = @style[4]
  626.     bitmap.font.italic = @style[5]
  627.     bitmap.font.name   = @style[6]
  628.     #---
  629.     dx = @data[1] ? 24 : 0; dy = 0
  630.     text = setting[:word_setting][@rule]
  631.     text = setting[:word_setting][:default] unless text
  632.     text = sprintf(text, @data[0])
  633.     bitmap.draw_text(dx, dy, bw - dx, bh, text, 1)
  634.     #---
  635.     text_width = bitmap.text_size(text).width
  636.     if @data[1]
  637.       icon_bitmap = Cache.system("Iconset")
  638.       icon_index = @data[1].to_i
  639.       rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  640.       bitmap.blt((bw-text_width)/2-32, (bh - 24)/2, icon_bitmap, rect)
  641.     end
  642.     bitmap
  643.   end
  644.  
  645.   #--------------------------------------------------------------------------
  646.   # start_effect
  647.   #--------------------------------------------------------------------------
  648.   def start_effect
  649.     @current_effect = @effects.shift
  650.     return dispose if @current_effect.nil?
  651.     effect = setting[:effect_setup][@current_effect]
  652.     @duration = effect[8]
  653.     #---
  654.     @zoom_x_rate = (effect[0] - self.zoom_x) / @duration
  655.     @zoom_y_rate = (effect[1] - self.zoom_y) / @duration
  656.     #---
  657.     @move_x = effect[4]
  658.     @move_y = effect[5]
  659.     if effect[9]
  660.       @move_x = @move_x * rand(0)
  661.       @move_x = rand(10) % 2 == 0 ? -@move_x : @move_x
  662.     end
  663.     #---
  664.     @gravity = effect[6]
  665.     #---
  666.     @opacity_rate = (effect[7] - self.opacity) / @duration.to_f
  667.     #---
  668.     self.x += effect[2]
  669.     self.y += effect[3]
  670.   end
  671.  
  672.   #--------------------------------------------------------------------------
  673.   # update
  674.   #--------------------------------------------------------------------------
  675.   def update
  676.     super
  677.     update_zoom
  678.     update_move
  679.     update_opacity
  680.     update_effect
  681.   end
  682.  
  683.   #--------------------------------------------------------------------------
  684.   # update_effect
  685.   #--------------------------------------------------------------------------
  686.   def update_effect
  687.     @duration -= 1
  688.     return if @duration > 0
  689.     start_effect
  690.   end
  691.  
  692.   #--------------------------------------------------------------------------
  693.   # update_zoom
  694.   #--------------------------------------------------------------------------
  695.   def update_zoom
  696.     self.zoom_x += @zoom_x_rate
  697.     self.zoom_y += @zoom_y_rate
  698.   end
  699.  
  700.   #--------------------------------------------------------------------------
  701.   # update_move
  702.   #--------------------------------------------------------------------------
  703.   def update_move
  704.     self.x += @move_x
  705.     self.y += @move_y
  706.     @move_y += @gravity
  707.   end
  708.  
  709.   #--------------------------------------------------------------------------
  710.   # update_opacity
  711.   #--------------------------------------------------------------------------
  712.   def update_opacity
  713.     self.opacity += @opacity_rate
  714.   end
  715.  
  716.   #--------------------------------------------------------------------------
  717.   # dispose
  718.   #--------------------------------------------------------------------------
  719.   def dispose
  720.     self.bitmap.dispose if self.bitmap
  721.     super
  722.   end
  723.  
  724. end # Sprite_PopupLuna
  725.  
  726. #==============================================================================
  727. # ■ Window_BattleHelp
  728. #==============================================================================
  729. if $imported["YEA-BattleEngine"]
  730. class Window_BattleHelp < Window_Help
  731.  
  732.   #--------------------------------------------------------------------------
  733.   # alias method: update
  734.   #--------------------------------------------------------------------------
  735.   alias battle_luna_yea_be_update update
  736.   def update
  737.     battle_luna_yea_be_update
  738.     return unless $imported["YEA-BattleEngine"]
  739.     return unless @actor_window && @enemy_window
  740.     if !self.visible and @text != ""
  741.       @text = ""
  742.       return refresh
  743.     end
  744.     update_battler_name
  745.   end
  746.  
  747. end # Window_BattleHelp
  748. end
RAW Paste Data