Advertisement
FlipelyFlip

Battle Result Manual Scroll

Sep 8th, 2024
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 38.32 KB | None | 0 0
  1. #==============================================================================
  2. # +++ MOG - Battle Result (2.0) +++
  3. #==============================================================================
  4. # By Moghunter
  5. # https://atelierrgss.wordpress.com/
  6. #==============================================================================
  7. # Apresentação animada do resultado da batalha.
  8. #==============================================================================
  9. # Arquivos necessários. (Graphics/System)
  10. #
  11. # Result.png
  12. # Result_Layout.png
  13. # Result_Levelup.png
  14. # Result_Levelword.png
  15. # Result_Number_1.png
  16. # Result_Number_2.png
  17. #
  18. #==============================================================================
  19. # ● Histórico (Version History)
  20. #==============================================================================
  21. # v2.0 - Correção do bug de não ativar o resultado em inimigos ocultos.
  22. #==============================================================================
  23. module MOG_BATLE_RESULT
  24.   #Posição do EXP.
  25.   RESULT_EXP_POSITION = [551,109]
  26.   #Posição do GOLD.
  27.   RESULT_GOLD_POSITION = [586,155]
  28.   #Posição da palavra LeveL UP.
  29.   RESULT_LEVELWORD_POSITION = [-16,-28]
  30.   #Posição do Level.
  31.   RESULT_LEVEL_POSITION = [250,-9]
  32.   #Posição dos parâmetros
  33.   RESULT_PARAMETER_POSITION = [70,70]
  34.   #Posição da janela de skill.
  35.   RESULT_NEW_SKILL_POSITION = [240,230]
  36.   #Definição da animação de Level UP.
  37.   RESULT_LEVELUP_ANIMATION_ID = 5
  38. end
  39.  
  40. $imported = {} if $imported.nil?
  41. $imported[:mog_battler_result] = true
  42.  
  43. #==============================================================================
  44. # ■ Game Temp
  45. #==============================================================================
  46. class Game_Temp
  47.   attr_accessor :level_parameter
  48.   attr_accessor :level_parameter_old
  49.   attr_accessor :result
  50.   attr_accessor :battle_end
  51.   attr_accessor :battle_result
  52.    
  53.   #--------------------------------------------------------------------------
  54.   # ● Initialize
  55.   #--------------------------------------------------------------------------
  56.   alias mog_result_initialize initialize
  57.   def initialize
  58.       @level_parameter = [] ; @level_parameter_old = []
  59.       @result = false ; @battle_end = false ; @battle_result = false
  60.       mog_result_initialize
  61.   end
  62.  
  63.   #--------------------------------------------------------------------------
  64.   # ● Sprite Visible
  65.   #--------------------------------------------------------------------------    
  66.   def sprite_visible
  67.       return false if $game_message.visible
  68.       return false if $game_temp.battle_end
  69.       return true
  70.   end  
  71.  
  72. end
  73.  
  74. #==============================================================================
  75. # ■ Game Actor
  76. #==============================================================================
  77. class Game_Actor < Game_Battler
  78.  
  79.   #--------------------------------------------------------------------------
  80.   # ● Display_level_up
  81.   #--------------------------------------------------------------------------
  82.   alias mog_result_display_level_up display_level_up
  83.   def display_level_up(new_skills)
  84.       if $game_temp.result
  85.          $game_temp.level_parameter = [@level,new_skills]
  86.          return
  87.       end    
  88.       mog_result_display_level_up(new_skills)
  89.   end
  90.  
  91. end
  92.  
  93. #==============================================================================
  94. # ■ BattleManager
  95. #==============================================================================
  96. module BattleManager
  97.  
  98.   #--------------------------------------------------------------------------
  99.   # ● Process Victory
  100.   #--------------------------------------------------------------------------
  101.   def self.process_victory
  102.       @phase = nil
  103.       @event_proc.call(0) if @event_proc
  104.       $game_temp.battle_result = true ;play_battle_end_me ; replay_bgm_and_bgs
  105.       SceneManager.return
  106.       return true
  107.   end
  108.  
  109. end
  110.  
  111. #==============================================================================
  112. # ■ Spriteset Battle
  113. #==============================================================================
  114. class Scene_Battle < Scene_Base
  115.  
  116.   #--------------------------------------------------------------------------
  117.   # ● Dispose
  118.   #--------------------------------------------------------------------------                
  119.   alias mog_battle_result_pre_terminate pre_terminate
  120.   def pre_terminate
  121.       execute_result if can_enable_battle_result?
  122.       mog_battle_result_pre_terminate
  123.   end  
  124.  
  125.   #--------------------------------------------------------------------------
  126.   # ● Can Enable Battle Result?
  127.   #--------------------------------------------------------------------------  
  128.   def can_enable_battle_result?
  129.       return false if !$game_temp.battle_result
  130.       return true
  131.   end
  132.    
  133.   #--------------------------------------------------------------------------
  134.   # ● Execute Result
  135.   #--------------------------------------------------------------------------                  
  136.   def execute_result
  137.       $game_variables[YEA::MESSAGE::VARIABLE_ROWS] = 0 #FlipEdit
  138.       $game_variables[YEA::MESSAGE::VARIABLE_WIDTH] = 0 #FlipEdit
  139.       $game_temp.battle_result = false
  140.       result = Battle_Result.new
  141.       $game_temp.combo_hit[2] = 0 rescue nil if $imported[:mog_combo_count]
  142.       @status_window.visible = false
  143.       if $imported[:mog_battle_command_ex]
  144.          @window_actor_face.visible = false if @window_actor_face != nil
  145.       end
  146.       loop do
  147.            result.update ; @spriteset.update
  148.            Graphics.update ; Input.update
  149.            break if result.victory_phase == 10
  150.       end
  151.       result.dispose
  152.       $game_party.on_battle_end
  153.       $game_troop.on_battle_end
  154.       SceneManager.exit if $BTEST
  155.   end  
  156.  
  157. end
  158.  
  159. #==============================================================================
  160. # ■ Battle Result
  161. #==============================================================================
  162. class Battle_Result
  163.   include MOG_BATLE_RESULT
  164.  
  165.   attr_accessor :victory_phase
  166.    
  167.   #--------------------------------------------------------------------------
  168.   # ● Initialize
  169.   #--------------------------------------------------------------------------      
  170.   def initialize
  171.       $game_temp.battle_end = true ; $game_temp.result = true
  172.       @victory_phase = 0 ; @victory_wait_duration = 0
  173.       @fade_result_window = false ; create_victory_sprites
  174.   end
  175.  
  176.   #--------------------------------------------------------------------------
  177.   # ● Create Victory Sprites
  178.   #--------------------------------------------------------------------------    
  179.   def create_victory_sprites
  180.       @result_number = Cache.system("Result_Number_1")
  181.       @result_number2 = Cache.system("Result_Number_2")
  182.       @result_cw = @result_number.width / 10
  183.       @result_ch = @result_number.height / 2          
  184.       @result2_cw = @result_number2.width / 10
  185.       @result2_ch = @result_number2.height / 2  
  186.       create_victory_text ; create_victory_layout ; create_victory_exp
  187.       create_victory_gold ; create_window_treasure
  188.   end  
  189.  
  190.   #--------------------------------------------------------------------------
  191.   # ● Victory Wait ?
  192.   #--------------------------------------------------------------------------        
  193.   def victory_wait?
  194.       return false if @victory_wait_duration <= 0
  195.       @victory_wait_duration -= 1
  196.       return true
  197.   end    
  198.  
  199.   #--------------------------------------------------------------------------
  200.   # ● End Victory
  201.   #--------------------------------------------------------------------------    
  202.   def end_victory
  203.       @victory_wait_duration = 30 ; dispose
  204.   end
  205.  
  206.   #--------------------------------------------------------------------------
  207.   # ● Create Victory Layout
  208.   #--------------------------------------------------------------------------      
  209.   def create_victory_layout
  210.       return if @victory_layout_sprite != nil
  211.       @victory_layout_sprite = Sprite.new
  212.       @victory_layout_sprite.z = 1001
  213.       @victory_layout_sprite.bitmap = Cache.system("Result_Layout")
  214.       @victory_layout_sprite.zoom_x = 2.0
  215.       @victory_layout_sprite.opacity = 0
  216.   end  
  217.  
  218.   #--------------------------------------------------------------------------
  219.   # ● Create Victory Text
  220.   #--------------------------------------------------------------------------      
  221.   def create_victory_text
  222.       return if @victory_sprite != nil
  223.       @victory_sprite = Sprite.new
  224.       @victory_sprite.z = 1000
  225.       @victory_sprite.bitmap = Cache.system("Result")
  226.       @victory_sprite.ox = @victory_sprite.width / 2
  227.       @victory_sprite.oy = @victory_sprite.height / 2
  228.       @victory_sprite.x = @victory_sprite.ox
  229.       @victory_sprite.y = @victory_sprite.oy
  230.       @victory_sprite.zoom_x = 1.5
  231.       @victory_sprite.zoom_y = 1.5
  232.       @victory_sprite.opacity = 0    
  233.   end  
  234.  
  235. end
  236.  
  237. #==============================================================================
  238. # ■ Battle Result
  239. #==============================================================================
  240. class Battle_Result
  241.  
  242.   #--------------------------------------------------------------------------
  243.   # ● Dispose
  244.   #--------------------------------------------------------------------------      
  245.   def dispose
  246.       $game_temp.result = false
  247.       @victory_sprite.bitmap.dispose ; @victory_sprite.dispose
  248.       @victory_layout_sprite.bitmap.dispose ; @victory_layout_sprite.dispose
  249.       @exp_number.bitmap.dispose ; @exp_number.dispose
  250.       @gold_number.bitmap.dispose ; @gold_number.dispose
  251.       @result_number.dispose ; @window_treasure.dispose
  252.       dispose_level_up ; @result_number.dispose ; @result_number2.dispose
  253.       @tr_viewport.dispose
  254.   end  
  255.    
  256.   #--------------------------------------------------------------------------
  257.   # ● Dispose Result Actor Bitmap
  258.   #--------------------------------------------------------------------------              
  259.   def dispose_result_actor_bitmap
  260.       return if @result_actor_sprite == nil
  261.       return if @result_actor_sprite.bitmap == nil
  262.       @result_actor_sprite.bitmap.dispose
  263.   end
  264.  
  265.   #--------------------------------------------------------------------------
  266.   # ● Dispose Level UP
  267.   #--------------------------------------------------------------------------        
  268.   def dispose_level_up
  269.       return if @levelup_layout == nil
  270.       @levelup_layout.bitmap.dispose ; @levelup_layout.dispose
  271.       @levelup_word.bitmap.dispose ; @levelup_word.dispose
  272.       @result_actor_sprite.bitmap.dispose ; @result_actor_sprite.dispose
  273.       @parameter_sprite.bitmap.dispose ; @parameter_sprite.dispose
  274.       @level_sprite.bitmap.dispose ; @level_sprite.dispose
  275.       @new_skill_window.dispose if @new_skill_window
  276.   end
  277.  
  278. end
  279.  
  280. #==============================================================================
  281. # ■ Battle Result
  282. #==============================================================================
  283. class Battle_Result
  284.  
  285.   #--------------------------------------------------------------------------
  286.   # ● Update
  287.   #--------------------------------------------------------------------------  
  288.   def update
  289.       $game_temp.battle_end = true
  290.       if $mog_rgss3_pause != nil
  291.          update_pause if MOG_PAUSE::PAUSE_SCENE_BATTLE
  292.       end    
  293.       return if @victory_phase == nil
  294.       update_victory_fade if @fade_result_window
  295.       return if victory_wait?
  296.       case @victory_phase
  297.          when 0;  update_victory_initial
  298.          when 1;  update_victory_initial2
  299.          when 2;  update_victory_initial3
  300.          when 3;  update_victory_exp
  301.          when 4;  update_victory_gold
  302.          when 5;  update_victory_item
  303.          when 6;  update_victory_levelup
  304.          when 9;  update_skip_result
  305.       end
  306.       if Input.trigger?(:C)
  307.          if @victory_phase == 10
  308.             end_victory
  309.          elsif @victory_phase.between?(1,5)
  310.             Sound.play_cursor ; @victory_phase = 9
  311.          end          
  312.       end  
  313.   end
  314.  
  315.   #--------------------------------------------------------------------------
  316.   # ● Skip Result
  317.   #--------------------------------------------------------------------------        
  318.   def update_skip_result
  319.       @victory_sprite.opacity -= 10
  320.       @victory_sprite.visible = false
  321.       @victory_layout_sprite.opacity += 10
  322.       @victory_layout_sprite.zoom_x = 1.00
  323.       @gold_number.opacity += 10
  324.       @gold_number.zoom_x = 1.00
  325.       @gold_number.zoom_y = 1.00
  326.       @exp_number.opacity += 10
  327.       @exp_number.zoom_x = 1.00
  328.       @exp_number.zoom_y = 1.00      
  329.       @window_treasure.contents_opacity += 10
  330.       if @exp_old != @exp_total
  331.          @exp_old = @exp_total
  332.          refresh_exp_number
  333.       end
  334.       if @gold_old = @gold_total  
  335.          @gold_old = @gold_total
  336.          refresh_gold_number
  337.       end  
  338.       @window_treasure.x = 0
  339.       update_victory_item if @window_treasure.contents_opacity == 255
  340.   end  
  341.  
  342.   #--------------------------------------------------------------------------
  343.   # ● Update Victory Fade
  344.   #--------------------------------------------------------------------------      
  345.   def update_victory_fade
  346.       fade_speed = 10
  347.       @victory_sprite.opacity -= fade_speed
  348.       @victory_layout_sprite.opacity -= fade_speed
  349.       @gold_number.opacity -= fade_speed
  350.       @exp_number.opacity -= fade_speed
  351.       @window_treasure.contents_opacity -= fade_speed
  352.   end
  353.  
  354.   #--------------------------------------------------------------------------
  355.   # ● Update Victory Initial
  356.   #--------------------------------------------------------------------------      
  357.   def update_victory_initial
  358.       @victory_sprite.zoom_x -= 0.01
  359.       @victory_sprite.zoom_y -= 0.01
  360.       @victory_sprite.opacity += 10
  361.       if @victory_sprite.zoom_x <= 1.00
  362.          @victory_sprite.zoom_x = 1
  363.          @victory_sprite.zoom_y = 1
  364.          @victory_sprite.opacity = 255
  365.          @victory_phase = 1
  366.          @victory_wait_duration = 20
  367.       end
  368.   end
  369.  
  370.   #--------------------------------------------------------------------------
  371.   # ● Update Victory Initial 2
  372.   #--------------------------------------------------------------------------      
  373.   def update_victory_initial2
  374.       @victory_sprite.zoom_x += 0.01
  375.       @victory_sprite.zoom_y += 0.01
  376.       @victory_sprite.opacity -= 10
  377.       if @victory_sprite.opacity <= 0
  378.          @victory_sprite.zoom_x = 1
  379.          @victory_sprite.zoom_y = 1
  380.          @victory_sprite.opacity = 0
  381.          @victory_phase = 2
  382.       end
  383.   end
  384.  
  385.   #--------------------------------------------------------------------------
  386.   # ● Update Victory Initial 3
  387.   #--------------------------------------------------------------------------        
  388.   def update_victory_initial3    
  389.       @victory_layout_sprite.zoom_x -= 0.02
  390.       @victory_layout_sprite.opacity += 10
  391.       if @victory_layout_sprite.zoom_x <= 1.00
  392.          @victory_layout_sprite.zoom_x = 1
  393.          @victory_layout_sprite.opacity = 255
  394.          @victory_phase = 3
  395.       end              
  396.   end    
  397.      
  398. end
  399.  
  400. #==============================================================================
  401. # ■ Battle Result
  402. #==============================================================================
  403. class Battle_Result
  404.  
  405.   #--------------------------------------------------------------------------
  406.   # ● Create Victory Exp
  407.   #--------------------------------------------------------------------------      
  408.   def create_victory_exp
  409.       @exp_number = Sprite.new
  410.       @exp_number.bitmap = Bitmap.new(@result_number.width,@result_ch)
  411.       @exp_number.z = 1002 ; @exp_number.y = RESULT_EXP_POSITION[1]
  412.       @exp_number.zoom_x = 2 ; @exp_number.zoom_y = 2
  413.       @exp_total = $game_troop.exp_total ; @exp_number.opacity = 0
  414.       @exp_old = 0
  415.       @exp_ref = ((1 * @exp_total) / 111).truncate rescue nil
  416.       @exp_ref = 1 if @exp_ref < 1 or @exp_ref == nil      
  417.       @exp_ref = 0 if @exp_total == 0
  418.       refresh_exp_number
  419.   end
  420.  
  421.   #--------------------------------------------------------------------------
  422.   # ● Update Victory Exp
  423.   #--------------------------------------------------------------------------        
  424.   def update_victory_exp
  425.       update_exp_sprite ; update_exp_number
  426.   end
  427.  
  428.   #--------------------------------------------------------------------------
  429.   # ● Update EXP Sprite
  430.   #--------------------------------------------------------------------------          
  431.   def update_exp_sprite
  432.       @exp_number.opacity += 15
  433.       if @exp_number.zoom_x > 1.00
  434.          @exp_number.zoom_x -= 0.03
  435.          @exp_number.zoom_x = 1.00 if @exp_number.zoom_x <= 1.00
  436.       end
  437.       @exp_number.zoom_y = @exp_number.zoom_x
  438.       if (@exp_old >= @exp_total) and @exp_number.zoom_x == 1.00
  439.          @victory_phase = 4
  440.          Sound.play_cursor
  441.       end  
  442.   end
  443.  
  444.   #--------------------------------------------------------------------------
  445.   # ● Refresh Exp Number
  446.   #--------------------------------------------------------------------------        
  447.   def refresh_exp_number
  448.       @exp_number.bitmap.clear
  449.       draw_result_exp(@exp_old, 0,0)      
  450.   end
  451.  
  452.   #--------------------------------------------------------------------------
  453.   # ● Update Exp_number
  454.   #--------------------------------------------------------------------------
  455.   def update_exp_number
  456.       return if @exp_old == @exp_total
  457.       @exp_old += @exp_ref
  458.       @exp_old = @exp_total if @exp_old > @exp_total
  459.       refresh_exp_number
  460.   end
  461.  
  462.   #--------------------------------------------------------------------------
  463.   # ● Draw Result EXP
  464.   #--------------------------------------------------------------------------        
  465.   def draw_result_exp(value,x,y)
  466.       ncw = @result_cw ; nch = @result_ch ; number = value.abs.to_s.split(//)
  467.       x2 = x - (number.size * ncw)
  468.       @exp_number.ox = (number.size * ncw) / 2
  469.       @exp_number.oy = @result_ch / 2
  470.       @exp_number.x = (RESULT_EXP_POSITION[0] + @result_cw + @exp_number.ox) - (number.size * ncw)
  471.       for r in 0..number.size - 1
  472.           number_abs = number[r].to_i
  473.           nsrc_rect = Rect.new(ncw * number_abs, 0, ncw, nch)
  474.           @exp_number.bitmap.blt(x + (ncw *  r), y, @result_number, nsrc_rect)        
  475.       end
  476.   end
  477.  
  478. end
  479.  
  480. #==============================================================================
  481. # ■ Battle Result
  482. #==============================================================================
  483. class Battle_Result
  484.  
  485.   #--------------------------------------------------------------------------
  486.   # ● Create Victory Gold
  487.   #--------------------------------------------------------------------------      
  488.   def create_victory_gold
  489.       @gold_number = Sprite.new
  490.       @gold_number.bitmap = Bitmap.new(@result_number.width,@result_ch)
  491.       @gold_number.z = 1002
  492.       @gold_number.y = RESULT_GOLD_POSITION[1]
  493.       @gold_number.opacity = 0
  494.       @gold_number.zoom_x = 2
  495.       @gold_number.zoom_y = 2      
  496.       @gold_total = $game_troop.gold_total
  497.       @gold_old = 0
  498.       @gold_ref = ((1 * @gold_total) / 111).truncate rescue nil
  499.       @gold_ref = 1 if @gold_ref < 1 or @gold_ref == nil      
  500.       @gold_ref = 0 if @gold_total == 0
  501.       $game_party.gain_gold($game_troop.gold_total)
  502.       refresh_gold_number
  503.   end  
  504.  
  505.   #--------------------------------------------------------------------------
  506.   # ● Update Victory Gold
  507.   #--------------------------------------------------------------------------        
  508.   def update_victory_gold
  509.       update_gold_sprite ; update_gold_number
  510.   end
  511.  
  512.   #--------------------------------------------------------------------------
  513.   # ● Update GOLD Sprite
  514.   #--------------------------------------------------------------------------          
  515.   def update_gold_sprite
  516.       @gold_number.opacity += 15
  517.       if @gold_number.zoom_x > 1.00
  518.          @gold_number.zoom_x -= 0.03
  519.          @gold_number.zoom_x = 1.00 if @gold_number.zoom_x <= 1.00
  520.       end
  521.       @gold_number.zoom_y = @gold_number.zoom_x
  522.       if @gold_old >= @gold_total and @gold_number.zoom_x == 1.00
  523.          @victory_phase = 5 ; Sound.play_cursor
  524.       end  
  525.   end  
  526.  
  527.   #--------------------------------------------------------------------------
  528.   # ● Refresh gold Number
  529.   #--------------------------------------------------------------------------        
  530.   def refresh_gold_number
  531.       @gold_number.bitmap.clear
  532.       draw_result_gold(@gold_old, 0,0)      
  533.   end
  534.  
  535.   #--------------------------------------------------------------------------
  536.   # ● Update Gold Number
  537.   #--------------------------------------------------------------------------
  538.   def update_gold_number
  539.       return if @gold_old == @gold_total
  540.       @gold_old += @gold_ref
  541.       @gold_old = @gold_total if @gold_old > @gold_total
  542.       refresh_gold_number
  543.   end      
  544.  
  545.   #--------------------------------------------------------------------------
  546.   # ● Draw Result Gold
  547.   #--------------------------------------------------------------------------        
  548.   def draw_result_gold(value,x,y)
  549.       ncw = @result_cw ; nch = @result_ch
  550.       number = value.abs.to_s.split(//)
  551.       x2 = x - (number.size * ncw)
  552.       @gold_number.ox = (number.size * ncw) / 2
  553.       @gold_number.oy = @result_ch / 2
  554.       @gold_number.x = (RESULT_GOLD_POSITION[0] + @result_cw + @gold_number.ox) - (number.size * ncw)
  555.       for r in 0..number.size - 1
  556.           number_abs = number[r].to_i
  557.           nsrc_rect = Rect.new(ncw * number_abs, @result_ch, ncw, nch)
  558.           @gold_number.bitmap.blt(x + (ncw *  r), y, @result_number, nsrc_rect)        
  559.       end
  560.   end
  561.  
  562. end
  563.  
  564. #==============================================================================
  565. # ■ Battle Result
  566. #==============================================================================
  567. class Battle_Result
  568.  
  569.   #--------------------------------------------------------------------------
  570.   # ● Create Window Treasure
  571.   #--------------------------------------------------------------------------            
  572.   def create_window_treasure
  573.       @tr_viewport = Viewport.new(20, 198, Graphics.width + 32, 118)
  574.       @tr_viewport.z = 1003
  575.       @window_treasure = Window_Treasure.new
  576.       @window_treasure.viewport = @tr_viewport
  577.   end  
  578.  
  579.   #--------------------------------------------------------------------------
  580.   # ● Update Victory Item
  581.   #--------------------------------------------------------------------------          
  582.   def update_victory_item
  583.       @window_treasure.update
  584.       @actor_level = []
  585.       return if @window_treasure.x != 0 and @victory_phase >= 6
  586.       @victory_phase = 6
  587.       if $data_system.opt_extra_exp
  588.          @result_member_max = $game_party.members.size
  589.       else
  590.          @result_member_max = $game_party.battle_members.size
  591.       end
  592.       @result_member_id = 0
  593.   end
  594.  
  595. end
  596.  
  597. #==============================================================================
  598. # ■ Window Treasure
  599. #==============================================================================
  600. class Window_Treasure < Window_Base
  601.  
  602.   #--------------------------------------------------------------------------
  603.   # ● Initialize
  604.   #--------------------------------------------------------------------------
  605.   def initialize
  606.       super(-Graphics.width,-10, Graphics.width + 32, 288)
  607.       self.opacity = 0 ; self.contents_opacity = 0
  608.       self.contents.font.size = 24 ; self.contents.font.bold = true
  609.       self.z = 1003 ; @range_max = 256 ; @wait_time = 30 ; @scroll = false
  610.       @scroll_speed = 1
  611.       draw_treasure
  612.   end
  613.  
  614.   #--------------------------------------------------------------------------
  615.   # ● Draw_Treasure
  616.   #--------------------------------------------------------------------------  
  617.   def draw_treasure
  618.       contents.clear
  619.       space_x = Graphics.width / 3
  620.       $game_troop.make_drop_items.each_with_index do |item, index|
  621.          xi = (index * space_x) - ((index / 3) * (space_x * 3))        
  622.          yi = (index / 3) * 32
  623.          $game_party.gain_item(item, 1)
  624.          draw_item_name(item,xi, yi, true, 140)
  625.      end
  626.      @range_max = ($game_troop.make_drop_items.size / 3) * 32 - 32*2
  627.      @scroll = true if $game_troop.make_drop_items.size > 12
  628.   end  
  629.  
  630.   #--------------------------------------------------------------------------
  631.   # ● Update
  632.   #--------------------------------------------------------------------------  
  633.   def update
  634.       super
  635.       self.contents_opacity += 10
  636.       if self.x < 0
  637.          self.x += 15
  638.         (self.x = 0 ; Sound.play_cursor) if self.x >= 0
  639.       end
  640.       if Input.press?(Input::DOWN)
  641.         self.y -= @scroll_speed unless self.y < -@range_max
  642.       elsif Input.press?(Input::UP)
  643.         self.y += @scroll_speed unless self.y == -10
  644.       end
  645. #~       if @scroll and self.contents_opacity == 255 and self.x == 0
  646. #~          @wait_time -= 1 if  @wait_time > 0
  647. #~          return if @wait_time > 0
  648. #~          self.y -= @scroll_speed
  649. #~          @scroll_speed = -1 if self.y < -@range_max
  650. #~          @scroll_speed = 1 if self.y == -10
  651. #~          @wait_time = 30 if self.y == -10
  652. #~       end
  653.   end
  654.  
  655. end
  656.  
  657. #==============================================================================
  658. # ■ Battle Result
  659. #==============================================================================
  660. class Battle_Result
  661.  
  662.   #--------------------------------------------------------------------------
  663.   # ● Create Levelup
  664.   #--------------------------------------------------------------------------            
  665.   def create_levelup
  666.       if @levelup_layout == nil
  667.          @levelup_layout = Sprite.new ; @levelup_layout.z = 1000
  668.          @levelup_layout.bitmap = Cache.system("Result_Levelup")
  669.       end
  670.       if @levelup_word == nil
  671.          @levelup_word = Sprite.new ; @levelup_word.z = 1001
  672.          @levelup_word.bitmap = Cache.system("Result_Levelword")
  673.          @levelup_word.ox = @levelup_word.bitmap.width / 2
  674.          @levelup_word.oy = @levelup_word.bitmap.height / 2
  675.          @levelup_word.x = @levelup_word.ox + RESULT_LEVELWORD_POSITION[0]
  676.          @levelup_word.y = @levelup_word.oy + RESULT_LEVELWORD_POSITION[1]
  677.       end
  678.       @levelup_word.blend_type = 1
  679.       @levelup_word.zoom_x = 2 ; @levelup_word.zoom_y = 2      
  680.   end  
  681.  
  682.   #--------------------------------------------------------------------------
  683.   # ● Create Parameter Number
  684.   #--------------------------------------------------------------------------              
  685.   def create_parameter_number
  686.       if @parameter_sprite == nil
  687.          @parameter_sprite = Sprite.new
  688.          @parameter_sprite.bitmap = Bitmap.new(250,220)
  689.          @parameter_sprite.z = 1001
  690.          @parameter_sprite.x = RESULT_PARAMETER_POSITION[0]
  691.          @parameter_sprite.y = RESULT_PARAMETER_POSITION[1]
  692.          @parameter_sprite.bitmap.font.size = 16
  693.          @parameter_sprite.bitmap.font.bold = true        
  694.       end
  695.       refresh_parameter
  696.   end
  697.  
  698.   #--------------------------------------------------------------------------
  699.   # ● Refresh Parameter
  700.   #--------------------------------------------------------------------------                
  701.   def refresh_parameter
  702.        @parameter_animation = 0
  703.        @parameter_sprite.bitmap.clear
  704.        @parameter_sprite.opacity = 0
  705.        @parameter_sprite.x = RESULT_PARAMETER_POSITION[0] - 200
  706.        actor_old = $game_temp.level_parameter_old
  707.        draw_result_parameter(@actor_result.mhp,actor_old[1],0,28 * 0)
  708.        draw_result_parameter(@actor_result.mmp,actor_old[2],0,28 * 1)
  709.        draw_result_parameter(@actor_result.atk,actor_old[3],0,28 * 2)
  710.        draw_result_parameter(@actor_result.def,actor_old[4],0,28 * 3)
  711.        draw_result_parameter(@actor_result.mat,actor_old[5],0,28 * 4)
  712.        draw_result_parameter(@actor_result.mdf,actor_old[6],0,28 * 5)
  713.        draw_result_parameter(@actor_result.agi,actor_old[7],0,28 * 6)
  714.        draw_result_parameter(@actor_result.luk,actor_old[8],0,28 * 7)
  715.   end  
  716.  
  717.   #--------------------------------------------------------------------------
  718.   # ● Draw Result EXP
  719.   #--------------------------------------------------------------------------        
  720.   def draw_result_parameter(value,value2,x,y)
  721.       ncw = @result2_cw ; nch = @result2_ch ; number = value.abs.to_s.split(//)
  722.       x2 = x + (number.size * ncw) + 16
  723.       for r in 0..number.size - 1
  724.           number_abs = number[r].to_i
  725.           nsrc_rect = Rect.new(ncw * number_abs, 0, ncw, nch)
  726.           @parameter_sprite.bitmap.blt(x + (ncw *  r), y, @result_number2, nsrc_rect)        
  727.       end
  728.       value3 = value - value2
  729.       par = ""
  730.       if value > value2
  731.          par = "+"
  732.          @parameter_sprite.bitmap.font.color = Color.new(50,255,255)
  733.       elsif value < value2
  734.          par = ""
  735.          @parameter_sprite.bitmap.font.color = Color.new(255,155,100)
  736.       end
  737.       return if value == value2
  738.       @parameter_sprite.bitmap.draw_text(x2,y - 8,100,32,par.to_s + value3.to_s,0)  
  739.   end  
  740.  
  741.   #--------------------------------------------------------------------------
  742.   # ● Create Result Actor
  743.   #--------------------------------------------------------------------------            
  744.   def create_result_actor
  745.       if @result_actor_sprite == nil
  746.          @result_actor_sprite = Sprite.new ; @result_actor_sprite.z = 1005
  747.       end
  748.       dispose_result_actor_bitmap
  749.       @result_actor_sprite.bitmap = Cache.picture("Actor" + @actor_result.id.to_s)
  750.       @result_actor_org = [380 - (@result_actor_sprite.bitmap.width / 2), Graphics.height - @result_actor_sprite.bitmap.height]
  751.       @result_actor_sprite.x = @result_actor_org[0] + 200
  752.       @result_actor_sprite.y = @result_actor_org[1]
  753.       @result_actor_sprite.opacity = 0
  754.   end  
  755.  
  756.   #--------------------------------------------------------------------------
  757.   # ● Check New Skill
  758.   #--------------------------------------------------------------------------              
  759.   def check_new_skill
  760.       @new_skills = $game_temp.level_parameter[1] ; @new_skills_index = 0
  761.   end
  762.      
  763.   #--------------------------------------------------------------------------
  764.   # ● Show New Skill
  765.   #--------------------------------------------------------------------------                
  766.   def show_new_skill(start = false)
  767.       Sound.play_recovery unless start
  768.       @new_skill_window.draw_new_skill(@new_skills[@new_skills_index])
  769.       @new_skills_index += 1
  770.       if @new_skills_index == @new_skills.size or
  771.          @new_skills[@new_skills_index] == nil
  772.          @new_skills = nil
  773.       end  
  774.   end
  775.  
  776.   #--------------------------------------------------------------------------
  777.   # ● Check Level UP
  778.   #--------------------------------------------------------------------------            
  779.   def check_level_up    
  780.       if @new_skills != nil and !@new_skills.empty?
  781.          show_new_skill
  782.          return
  783.        end  
  784.       for battler_id in @result_member_id..@result_member_max
  785.           actor_result = $game_party.members[@result_member_id]  
  786.           $game_temp.level_parameter = []
  787.           $game_temp.level_parameter_old = []
  788.           $game_temp.level_parameter_old = [actor_result.level,actor_result.mhp,actor_result.mmp,
  789.           actor_result.atk, actor_result.def, actor_result.mat, actor_result.mdf, actor_result.agi, actor_result.luk] rescue nil
  790.           actor_result.gain_exp($game_troop.exp_total) rescue nil
  791.           @result_member_id += 1 ; @new_skills = nil ; @new_skills_index = 0
  792.           if @result_member_id > $game_party.battle_members.size
  793.              $game_temp.level_parameter = []
  794.              $game_temp.level_parameter_old = []
  795.              next
  796.           end
  797.           if $game_temp.level_parameter != nil and !$game_temp.level_parameter.empty?
  798.              show_level_result
  799.              break
  800.           end  
  801.       end
  802.       return if !$game_temp.level_parameter.empty?
  803.       @victory_phase = 10 if @result_member_id >= @result_member_max
  804.   end  
  805.  
  806.   #--------------------------------------------------------------------------
  807.   # ● Create Level
  808.   #--------------------------------------------------------------------------                
  809.   def create_level
  810.       if @level_sprite == nil
  811.          @level_sprite = Sprite.new ; @level_sprite.bitmap = Bitmap.new(200,64)
  812.          @level_sprite.z = 1002
  813.       end      
  814.       @level_sprite.bitmap.font.size = 48
  815.       @level_sprite.bitmap.font.bold = true
  816.       @level_sprite.x = RESULT_LEVEL_POSITION[0]
  817.       @level_sprite.y = RESULT_LEVEL_POSITION[1]
  818.       @level_sprite.bitmap.clear
  819.       @level_sprite.bitmap.font.color = Color.new(255,255,255)
  820.       @level_sprite.bitmap.draw_text(0,0,100,64,@actor_result.level,1)
  821.       levelup = @actor_result.level - $game_temp.level_parameter_old[0]
  822.       @level_sprite.bitmap.font.color = Color.new(50,255,255)
  823.       @level_sprite.bitmap.font.size = 18
  824.       @level_sprite.bitmap.draw_text(80,0,100,64,"+" + levelup.to_s ,0)
  825.   end
  826.  
  827.   #--------------------------------------------------------------------------
  828.   # ● Create New Skill Windos
  829.   #--------------------------------------------------------------------------                  
  830.   def create_new_skill_window
  831.       @new_skill_window = Window_Result_Skill.new if @new_skill_window == nil
  832.       @new_skill_window.x = RESULT_NEW_SKILL_POSITION[0]
  833.       @new_skill_window.y = RESULT_NEW_SKILL_POSITION[1]
  834.       check_new_skill
  835.       if @new_skills != nil and !@new_skills.empty?
  836.          show_new_skill
  837.       else  
  838.          @new_skill_window.x = -Graphics.width
  839.       end
  840.   end  
  841.  
  842.   #--------------------------------------------------------------------------
  843.   # ● Show Level Result
  844.   #--------------------------------------------------------------------------              
  845.   def show_level_result
  846.       Sound.play_cursor
  847.       @actor_result = $game_party.members[@result_member_id - 1] rescue nil
  848.       return if @actor_result == nil
  849.       @actor_result.animation_id = RESULT_LEVELUP_ANIMATION_ID
  850.       @fade_result_window = true
  851.       create_levelup ; create_level ; create_parameter_number
  852.       create_result_actor ; create_new_skill_window
  853.   end  
  854.  
  855. end
  856.  
  857. #==============================================================================
  858. # ■ Battle Result
  859. #==============================================================================
  860. class Battle_Result
  861.  
  862.   #--------------------------------------------------------------------------
  863.   # ● Update Victory Item
  864.   #--------------------------------------------------------------------------          
  865.   def update_victory_levelup      
  866.        check_level_up if Input.trigger?(:C)
  867.        update_show_levelup
  868.        if @levelup_layout == nil
  869.           @window_treasure.update
  870.        else
  871.           @window_treasure.contents_opacity -= 15
  872.        end
  873.   end
  874.  
  875.   #--------------------------------------------------------------------------
  876.   # ● Update Show Level UP
  877.   #--------------------------------------------------------------------------            
  878.   def update_show_levelup
  879.       return if @levelup_layout == nil
  880.       return if @result_actor_sprite == nil
  881.       @new_skill_window.update
  882.       if @result_actor_sprite.x > @result_actor_org[0]
  883.          @result_actor_sprite.x -= 5
  884.          @result_actor_sprite.opacity += 7
  885.          if @result_actor_sprite.x <= @result_actor_org[0]
  886.             @result_actor_sprite.x = @result_actor_org[0]
  887.             @result_actor_sprite.opacity = 255
  888.          end
  889.       end
  890.       if @levelup_word.zoom_x > 1.00
  891.          @levelup_word.zoom_x -= 0.03
  892.          if @levelup_word.zoom_x < 1.00
  893.             @levelup_word.zoom_x = 1.00 ; @levelup_word.blend_type = 0
  894.          end
  895.       end
  896.       @levelup_word.zoom_y = @levelup_word.zoom_x
  897.       if @parameter_sprite.x < RESULT_PARAMETER_POSITION[0]
  898.          @parameter_sprite.opacity += 13
  899.          @parameter_sprite.x += 5
  900.          if @parameter_sprite.x >= RESULT_PARAMETER_POSITION[0]
  901.             @parameter_sprite.opacity = 255
  902.             @parameter_sprite.x = RESULT_PARAMETER_POSITION[0]
  903.          end  
  904.       end  
  905.   end    
  906.  
  907. end
  908.  
  909. #==============================================================================
  910. # ■ Window Result Skill
  911. #==============================================================================
  912. class Window_Result_Skill < Window_Base
  913.  
  914.   #--------------------------------------------------------------------------
  915.   # ● Initialize
  916.   #--------------------------------------------------------------------------
  917.   def initialize
  918.       super(0,0, 270, 58)
  919.       self.opacity = 160 ; self.contents_opacity = 255
  920.       self.contents.font.bold = true ; self.z = 1006 ; @animation_time = 999
  921.       @org = [MOG_BATLE_RESULT::RESULT_NEW_SKILL_POSITION[0],MOG_BATLE_RESULT::RESULT_NEW_SKILL_POSITION[1]]
  922.   end
  923.  
  924.   #--------------------------------------------------------------------------
  925.   # ● DrawNew Skill
  926.   #--------------------------------------------------------------------------  
  927.   def draw_new_skill(skill)
  928.       contents.clear
  929.       self.contents.font.size = 16
  930.       self.contents.font.color = Color.new(100,200,100)
  931.       contents.draw_text(0,0,100,32, "Neue Fähigkeit:",0)
  932.       self.contents.font.color = Color.new(255,255,255)
  933.       draw_item_name_skill(skill,70,0, true, 170)
  934.       self.x = @org[0] ; self.y = @org[1]
  935.       @animation_time = 0 ; self.opacity = 0 ; self.contents_opacity = 0      
  936.   end  
  937.  
  938.   #--------------------------------------------------------------------------
  939.   # ● Draw Item Name
  940.   #--------------------------------------------------------------------------
  941.   def draw_item_name_skill(item, x, y, enabled = true, width = 172)
  942.       return unless item
  943.       draw_icon(item.icon_index, x + 20, y, enabled)
  944.       change_color(normal_color, enabled)
  945.       draw_text(x + 44, y + 4, width, line_height, item.name)
  946.   end
  947.  
  948.   #--------------------------------------------------------------------------
  949.   # ● Update
  950.   #--------------------------------------------------------------------------  
  951.   def update
  952.       super
  953.       return if @animation_time == 999  
  954.       @animation_time += 1 if @animation_time != 999
  955.       case @animation_time
  956.           when 0..30
  957.             self.y -= 1 ; self.opacity += 5 ; self.contents_opacity += 5                  
  958.           when 31..60
  959.             self.y += 1 ; self.opacity += 5 ; self.contents_opacity += 5                    
  960.           else
  961.             self.y = @org[1] ; self.opacity = 255 ; self.contents_opacity = 255
  962.             @animation_time = 999      
  963.       end
  964.   end  
  965.    
  966. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement