Archeia

Yami Damage PopUp ViewPort Fix

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