Jragyn

[XP] Cogwheel's RTAB v1.16 (English)

May 29th, 2011
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 163.83 KB | None | 0 0
  1. # Real time active battle (RTAB)  Ver 1.16
  2. # Distribution original support URL
  3. # http://members.jcom.home.ne.jp/cogwheel/
  4. # For use with RMXP
  5.  
  6. class Scene_Battle
  7.   #--------------------------------------------------------------------------
  8.   # * Open instance variable
  9.   #--------------------------------------------------------------------------
  10.   attr_reader   :status_window            # Status Window
  11.   attr_reader   :spriteset                # Battle sprite
  12.   attr_reader   :scroll_time              # Screen portable basic time
  13.   attr_reader   :zoom_rate                # Enemy battler basic position
  14.   attr_reader   :drive                    # Camera drive
  15.   attr_accessor :force                    # Degree of action forcing
  16.   attr_accessor :camera                   # Present camera possession person
  17.   #--------------------------------------------------------------------------
  18.   # * ATB fundamental setup
  19.   #--------------------------------------------------------------------------
  20.   def atb_setup
  21.     # ATB initialization
  22.     #
  23.     # speed         : Battle system speed. Lower values speeds up the system.
  24.     #
  25.     # @active       : Degree of active setting (Command Window control)
  26.     #                 3 : Always active state
  27.     #                 2 : System pauses when selecting skill/item
  28.     #                 1 : Same as 2, but pauses during target selection
  29.     #                 0 : Same as 1, but pauses during command window selection
  30.     #
  31.     # @action       : Degree of action setting (Battler Action control)
  32.     #                 3 : Actions are performed unless incapacitated/dead
  33.     #                 2 : Actions are delayed when taking damage
  34.     #                 1 : Actions are delayed during the opponent/target's turn
  35.     #                 0 : Actions are delayed until his/her turn
  36.     #
  37.     # @anime_wait   : If true, the system pauses until Battle Animation is done.
  38.     #
  39.     # @damage_wait  : Sets how long (in frames) a delay will last after the
  40.     #                 damage pop shows.
  41.     #
  42.     # @after_wait   : The delay (in frames) after the battle is finished before
  43.     #                 moving to the 'game over' screen or showing the 'battle
  44.     #                 result' window.
  45.     #                 [a, b]  a) delay for party loss,  b) delay for enemy loss.
  46.     #
  47.     # @enemy_speed  : Reaction delay speed of enemy (in frames).  The Enemy
  48.     #                 reacts immediately if this is set to 1 (do not use '0').
  49.     #                 Action is caused with the chance of 1 / @enemy_speed
  50.     #
  51.     # @force        : With forced action forced condition at time of skill use
  52.     #                 2 : As for skill everything not to reside permanently, by all means immediately execution
  53.     #                 1 : As for independent skill to reside permanently, only cooperation skill immediately execution
  54.     #                 0 : All the skill permanent residence just are done
  55.     #
  56.     # ($scene.force = Usually by making x, from the script of the event modification possibility)
  57.     #
  58.     # CAMERA SYSTEM : This system moves the Camera POV to the current battler.
  59.     # @drive        : Camera drive system ON/OFF.  If true, the system is ON.
  60.     # @scroll_time  : Time it takes to scroll/move the camera POV during battle.
  61.     # @zoom_rate    : This controls the size/depth of the enemy battlers in the
  62.     #                 window.  If both set to 1.0, no scaling performed.
  63.     #                 [i, j]  i) Highest/furthest enemy, j) Lowest/closest enemy
  64.     #                 -Decimal values are permitted.-
  65.     #                 -System zooms in/out to target (scaled to 1) on decisions.
  66.    
  67.     #--Configurables--#
  68.     speed         = 50     # IN FRAMES / FOR ATB SYSTEM  
  69.     @active       = 3       # Active Setting (Range of 0 - 3) -Command Window-
  70.     @action       = 3       # Action Setting (Range of 0 - 3) -Battler Action-
  71.     @anime_wait   = false   # Pause system for battle animation
  72.     @damage_wait  = 10      # Delay after damage pop appears, in frames
  73.     @after_wait   = [80, 0] # Delay for party/troop after battle loss
  74.     @enemy_speed  = 140     # Speed delay setting for enemy action
  75.     @force        = 2       #
  76.     @drive        = true    # Turns camera system on/off
  77.     @scroll_time  = 15      # Speed of camera system
  78.     @zoom_rate = [0.2, 1.0] # Controls perspective of battlers on screen
  79.    
  80.     #--Reserved for the system, do not touch--#
  81.     @help_time = 40         # Reserved:  Length of window delay, in frames
  82.     @escape == false        # Reserved:  Determines if escape is possible
  83.     @camera = nil           # Reserved:  Determines camera
  84.     @max = 0                # Reserved:  To calculate max game speed
  85.     @turn_cnt = 0           # Reserved:  Counts turns
  86.     @help_wait = 0          # Reserved:  Help window delay
  87.     @action_battlers = []   # Reserved:  Holds battlers
  88.     @synthe = []            # Reserved:  For Cooperative Skills & such
  89.     @spell_p = {}           # Reserved:  Spell caster/battler array
  90.     @spell_e = {}           # Reserved:  Spell caster/battler array
  91.     @command_a  = false     # Reserved:  Determine if actor battler in use
  92.     @command = []           # Reserved:  Available commands
  93.     @party = false          # Reserved:  Party Command Window flag
  94.    
  95.     for battler in $game_party.actors + $game_troop.enemies
  96.       spell_reset(battler)
  97.       battler.at = battler.agi * rand(speed / 2)
  98.       battler.damage_pop = {}
  99.       battler.damage = {}
  100.       battler.damage_sp = {}
  101.       battler.critical = {}
  102.       battler.recover_hp = {}
  103.       battler.recover_sp = {}
  104.       battler.state_p = {}
  105.       battler.state_m = {}
  106.       battler.animation = []
  107.       if battler.is_a?(Game_Actor)
  108.         @max += battler.agi
  109.       end
  110.     end
  111.     @max *= speed
  112.     @max /= $game_party.actors.size
  113.  
  114.     for battler in $game_party.actors + $game_troop.enemies
  115.       battler.atp = 100 * battler.at / @max
  116.     end
  117.   end
  118.  
  119.   #--------------------------------------------------------------------------
  120.   # * Full AT Gauge SE
  121.   #--------------------------------------------------------------------------
  122.   def fullat_se
  123.     Audio.se_play("Audio/SE/033-switch02", 80, 100)
  124.   end
  125.  
  126.   #--------------------------------------------------------------------------
  127.   # * Leveling Up SE
  128.   #--------------------------------------------------------------------------
  129.   def levelup_se
  130.     Audio.se_play("Audio/SE/056-Right02", 80, 100)
  131.   end
  132.  
  133.   #--------------------------------------------------------------------------
  134.   # * Skill Acquisition SE
  135.   #--------------------------------------------------------------------------
  136.   def skill_se
  137.     Audio.se_play("Audio/SE/056-Right02", 80, 150)
  138.   end
  139. end
  140.  
  141. class Window_Base < Window
  142.   #--------------------------------------------------------------------------
  143.   # * Draw Actor ATG
  144.   #     actor : Actor
  145.   #     x     : draw spot x-coordinate
  146.   #     y     : draw spot y-coordinate
  147.   #     width : draw spot width
  148.   #--------------------------------------------------------------------------
  149.   def draw_actor_atg(actor, x, y, width = 144)
  150.     if @at_gauge == nil
  151.       # plus_x:     revised x-coordinate
  152.       # rate_x:     revised X-coordinate as (%)
  153.       # plus_y:     revised y-coordinate
  154.       # plus_width: revised width
  155.       # rate_width: revised width as (%)
  156.       # height:     Vertical width
  157.       # align1: Type 1 ( 0: left justify  1: center justify 2: right justify )
  158.       # align2: Type 2 ( 0: Upper stuffing 1: Central arranging  2:Lower stuffing )
  159.       # align3: Gauge type 0:Left justify 1: Right justify
  160.       @plus_x = 0
  161.       @rate_x = 0
  162.       @plus_y = 16
  163.       @plus_width = 0
  164.       @rate_width = 100
  165.       @width = @plus_width + width * @rate_width / 100
  166.       @height = 16
  167.       @align1 = 0
  168.       @align2 = 1
  169.       @align3 = 0
  170.       # Gradation settings:  grade1: Empty gauge   grade2:Actual gauge
  171.       # (0:On side gradation   1:Vertically gradation    2: Slantedly gradation)
  172.       grade1 = 1
  173.       grade2 = 0
  174.       # Color setting. color1: Outermost framework, color2: Medium framework
  175.       # color3: Empty framework dark color, color4: Empty framework light/write color
  176.       color1 = Color.new(0, 0, 0)
  177.       color2 = Color.new(255, 255, 192)
  178.       color3 = Color.new(0, 0, 0, 192)
  179.       color4 = Color.new(0, 0, 64, 192)
  180.       # Color setting of gauge
  181.       # Usually color setting of the time
  182.       color5 = Color.new(0, 64, 80)
  183.       color6 = Color.new(0, 128, 160)
  184.       # When gauge is MAX, color setting
  185.       color7 = Color.new(80, 0, 0)
  186.       color8 = Color.new(240, 0, 0)
  187.       # Color setting at time of cooperation skill use
  188.       color9 = Color.new(80, 64, 32)
  189.       color10 = Color.new(240, 192, 96)
  190.       # Color setting at time of skill permanent residence
  191.       color11 = Color.new(80, 0, 64)
  192.       color12 = Color.new(240, 0, 192)
  193.       # Drawing of gauge
  194.       gauge_rect_at(@width, @height, @align3, color1, color2,
  195.                   color3, color4, color5, color6, color7, color8,
  196.                   color9, color10, color11, color12, grade1, grade2)
  197.     end
  198.     # Variable at substituting the width of the gauge which is drawn
  199.     if actor.rtp == 0
  200.       at = (width + @plus_width) * actor.atp * @rate_width / 10000
  201.     else
  202.       at = (width + @plus_width) * actor.rt * @rate_width / actor.rtp / 100
  203.     end
  204.     if at > width
  205.       at = width
  206.     end
  207.     # Revision such as the left stuffing central posture of gauge
  208.     case @align1
  209.     when 1
  210.       x += (@rect_width - width) / 2
  211.     when 2
  212.       x += @rect_width - width
  213.     end
  214.     case @align2
  215.     when 1
  216.       y -= @height / 2
  217.     when 2
  218.       y -= @height
  219.     end
  220.     self.contents.blt(x + @plus_x + width * @rate_x / 100, y + @plus_y,
  221.                       @at_gauge, Rect.new(0, 0, @width, @height))
  222.     if @align3 == 0
  223.       rect_x = 0
  224.     else
  225.       x += @width - at - 1
  226.       rect_x = @width - at - 1
  227.     end
  228.     # Color setting of gauge
  229.     if at == width
  230.         # Gauge drawing at the time of MAX
  231.       self.contents.blt(x + @plus_x + @width * @rate_x / 100, y + @plus_y,
  232.                         @at_gauge, Rect.new(rect_x, @height * 2, at, @height))
  233.     else
  234.       if actor.rtp == 0
  235.         # Usually gauge drawing of the time
  236.         self.contents.blt(x + @plus_x + @width * @rate_x / 100, y + @plus_y,
  237.                           @at_gauge, Rect.new(rect_x, @height, at, @height))
  238.       else
  239.         if actor.spell == true
  240.           #Gauge drawing at time of cooperation skill use
  241.           self.contents.blt(x + @plus_x + @width * @rate_x / 100, y + @plus_y,
  242.                         @at_gauge, Rect.new(rect_x, @height * 3, at, @height))
  243.         else
  244.           # Gauge drawing at time of skill permanent residence
  245.           self.contents.blt(x + @plus_x + @width * @rate_x / 100, y + @plus_y,
  246.                         @at_gauge, Rect.new(rect_x, @height * 4, at, @height))
  247.         end
  248.       end
  249.     end
  250.   end
  251. end
  252.  
  253. #==============================================================================
  254. # ** Scene_Battle (part 1)
  255. #------------------------------------------------------------------------------
  256. #  This class performs battle screen processing.
  257. #==============================================================================
  258.  
  259. class Scene_Battle
  260.   #--------------------------------------------------------------------------
  261.   # * Main Processing
  262.   #--------------------------------------------------------------------------
  263.   def main
  264.     # Initialize each kind of temporary battle data
  265.     $game_temp.in_battle = true
  266.     $game_temp.battle_turn = 0
  267.     $game_temp.battle_event_flags.clear
  268.     $game_temp.battle_abort = false
  269.     $game_temp.battle_main_phase = false
  270.     $game_temp.battleback_name = $game_map.battleback_name
  271.     $game_temp.forcing_battler = nil
  272.     # Initialize battle event interpreter
  273.     $game_system.battle_interpreter.setup(nil, 0)
  274.     # Prepare troop
  275.     @troop_id = $game_temp.battle_troop_id
  276.     $game_troop.setup(@troop_id)
  277.     atb_setup
  278.     # Make actor command window
  279.     s1 = $data_system.words.attack
  280.     s2 = $data_system.words.skill
  281.     s3 = $data_system.words.guard
  282.     s4 = $data_system.words.item
  283.     @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
  284.     @actor_command_window.y = 160
  285.     @actor_command_window.back_opacity = 160
  286.     @actor_command_window.active = false
  287.     @actor_command_window.visible = false
  288.     # Make other windows
  289.     @party_command_window = Window_PartyCommand.new
  290.     @help_window = Window_Help.new
  291.     @help_window.back_opacity = 160
  292.     @help_window.visible = false
  293.     @status_window = Window_BattleStatus.new
  294.     @message_window = Window_Message.new
  295.     # Make sprite set
  296.     @spriteset = Spriteset_Battle.new
  297.     # Initialize wait count
  298.     @wait_count = 0
  299.     # Execute transition
  300.     if $data_system.battle_transition == ""
  301.       Graphics.transition(20)
  302.     else
  303.       Graphics.transition(40, "Graphics/Transitions/" +
  304.         $data_system.battle_transition)
  305.     end
  306.     # Start pre-battle phase
  307.     start_phase1
  308.     # Main loop
  309.     loop do
  310.       # Update game screen
  311.       Graphics.update
  312.       # Update input information
  313.       Input.update
  314.       # Frame update
  315.       update
  316.       # Abort loop if screen is changed
  317.       if $scene != self
  318.         break
  319.       end
  320.     end
  321.     # Refresh map
  322.     $game_map.refresh
  323.     # Prepare for transition
  324.     Graphics.freeze
  325.     # Dispose of windows
  326.     @actor_command_window.dispose
  327.     @party_command_window.dispose
  328.     @help_window.dispose
  329.     @status_window.dispose
  330.     @message_window.dispose
  331.     if @skill_window != nil
  332.       @skill_window.dispose
  333.     end
  334.     if @item_window != nil
  335.       @item_window.dispose
  336.     end
  337.     if @result_window != nil
  338.       @result_window.dispose
  339.     end
  340.     # Dispose of spriteset
  341.     @spriteset.dispose
  342.     # If switching to title screen
  343.     if $scene.is_a?(Scene_Title)
  344.       # Fade out screen
  345.       Graphics.transition
  346.       Graphics.freeze
  347.     end
  348.     # If switching from battle test to any screen other than game over screen
  349.     if $BTEST and not $scene.is_a?(Scene_Gameover)
  350.       $scene = nil
  351.     end
  352.   end
  353.   #--------------------------------------------------------------------------
  354.   # * Determine Battle Win/Loss Results
  355.   #--------------------------------------------------------------------------
  356.   def judge
  357.     # If all dead determinant is true, or number of members in party is 0
  358.     if $game_party.all_dead? or $game_party.actors.size == 0
  359.       # If possible to lose
  360.       if $game_temp.battle_can_lose
  361.         # Return to BGM before battle starts
  362.         $game_system.bgm_play($game_temp.map_bgm)
  363.         # Battle end
  364.         battle_end(2)
  365.         # Return true
  366.         return true
  367.       end
  368.       # Setting the game over flag
  369.       $game_temp.gameover = true
  370.       # Return true
  371.       return true
  372.     end
  373.     # Return false if even 1 enemy exists
  374.     for enemy in $game_troop.enemies
  375.       if enemy.exist?
  376.         return false
  377.       end
  378.     end
  379.     # Start after battle phase (win)
  380.     start_phase5
  381.     # Return true
  382.     return true
  383.   end
  384.   #--------------------------------------------------------------------------
  385.   # * Frame renewal
  386.   #--------------------------------------------------------------------------
  387.   def update
  388.     # If battle event is running
  389.     if $game_system.battle_interpreter.running?
  390.       if @command.size > 0
  391.         @command_a = false
  392.         @command = []
  393.         command_delete
  394.       end
  395.       @status_window.at_refresh
  396.       # Update interpreter
  397.       $game_system.battle_interpreter.update
  398.       # If a battler which is forcing actions doesn't exist
  399.       if $game_temp.forcing_battler == nil
  400.         # If battle event has finished running
  401.         unless $game_system.battle_interpreter.running?
  402.           # Refresh status window
  403.           @status_window.refresh
  404.           setup_battle_event
  405.         end
  406.       end
  407.     end
  408.     # Update system (timer) and screen
  409.     $game_system.update
  410.     $game_screen.update
  411.     # If timer has reached 0
  412.     if $game_system.timer_working and $game_system.timer == 0
  413.       # Abort battle
  414.       $game_temp.battle_abort = true
  415.     end
  416.     # Update windows
  417.     @help_window.update
  418.     @party_command_window.update
  419.     @actor_command_window.update
  420.     @status_window.update
  421.     @message_window.update
  422.     # Update sprite set
  423.     @spriteset.update
  424.     # If transition is processing
  425.     if $game_temp.transition_processing
  426.       # Clear transition processing flag
  427.       $game_temp.transition_processing = false
  428.       # Execute transition
  429.       if $game_temp.transition_name == ""
  430.         Graphics.transition(20)
  431.       else
  432.         Graphics.transition(40, "Graphics/Transitions/" +
  433.           $game_temp.transition_name)
  434.       end
  435.     end
  436.     # If message window is showing
  437.     if $game_temp.message_window_showing
  438.       return
  439.     end
  440.     # If game over
  441.     if $game_temp.gameover
  442.       # Switch to game over screen
  443.       $scene = Scene_Gameover.new
  444.       return
  445.     end
  446.     # If returning to title screen
  447.     if $game_temp.to_title
  448.       # Switch to title screen
  449.       $scene = Scene_Title.new
  450.       return
  451.     end
  452.     # If battle is aborted
  453.     if $game_temp.battle_abort
  454.       # Return to BGM used before battle started
  455.       $game_system.bgm_play($game_temp.map_bgm)
  456.       # Battle ends
  457.       battle_end(1)
  458.       return
  459.     end
  460.     # If help window is waiting
  461.     if @help_wait > 0
  462.       @help_wait -= 1
  463.       if @help_wait == 0
  464.         # Hide help window
  465.         @help_window.visible = false
  466.       end
  467.     end
  468.     # When the battler forced into action doesn't exist
  469.     # while the battle event is in the midst of executing
  470.     if $game_temp.forcing_battler == nil and
  471.        $game_system.battle_interpreter.running?
  472.       return
  473.     end
  474.     # Branch according to phase
  475.     case @phase
  476.     when 0  # AT gauge renewal phase
  477.       if anime_wait_return
  478.         update_phase0
  479.       end
  480.     when 1  # pre-battle phase
  481.       update_phase1
  482.       return
  483.     when 2  # party command phase
  484.       update_phase2
  485.       return
  486.     when 5  # after battle phase
  487.       update_phase5
  488.       return
  489.     end
  490.     if $scene != self
  491.       return
  492.     end
  493.     if @phase == 0
  494.       if @command.size != 0  # Actor command phase
  495.         if @command_a == false
  496.           start_phase3
  497.         end
  498.         update_phase3
  499.       end
  500.       # If waiting
  501.       if @wait_count > 0
  502.         # Decrease wait count
  503.         @wait_count -= 1
  504.         return
  505.       end
  506.       update_phase4
  507.     end
  508.   end
  509.  
  510. #==============================================================================
  511. # ** Scene_Battle (part 2)
  512. #------------------------------------------------------------------------------
  513. #  This class performs battle screen processing.
  514. #==============================================================================
  515.  
  516.   #--------------------------------------------------------------------------
  517.   # * Frame renewal (AT gauge renewal phase)
  518.   #--------------------------------------------------------------------------
  519.   def update_phase0
  520.     if $game_temp.battle_turn == 0
  521.       $game_temp.battle_turn = 1
  522.     end
  523.     # If B button was pressed
  524.     if @command_a == false and @party == false
  525.       if Input.trigger?(Input::B)
  526.         # Play cancel SE
  527.         $game_system.se_play($data_system.cancel_se)
  528.         @party = true
  529.       end
  530.     end
  531.     if @party == true and
  532.         ((@action > 0 and @action_battlers.empty?) or (@action == 0 and
  533.         (@action_battlers.empty? or @action_battlers[0].phase == 1)))
  534.       # Start party command phase
  535.       start_phase2
  536.       return
  537.     end
  538.     # AT gauge increase processing
  539.     cnt = 0
  540.     for battler in $game_party.actors + $game_troop.enemies
  541.       active?(battler)
  542.       if battler.rtp == 0
  543.         if battler.at >= @max
  544.           if battler.is_a?(Game_Actor)
  545.             if battler.inputable?
  546.               unless @action_battlers.include?(battler) or
  547.                   @command.include?(battler) or @escape == true
  548.                 if battler.current_action.forcing
  549.                   fullat_se
  550.                   force_action(battler)
  551.                   action_start(battler)
  552.                 else
  553.                   fullat_se
  554.                   @command.push(battler)
  555.                 end
  556.               end
  557.             else
  558.               unless @action_battlers.include?(battler) or
  559.                       battler == @command[0]
  560.                 battler.current_action.clear
  561.                 if @command.include?(battler)
  562.                   @command.delete(battler)
  563.                 else
  564.                   if battler.movable?
  565.                     fullat_se
  566.                   end
  567.                 end
  568.                 action_start(battler)
  569.               end
  570.             end
  571.           else
  572.             unless @action_battlers.include?(battler)
  573.               if battler.current_action.forcing
  574.                 force_action(battler)
  575.                 action_start(battler)
  576.               else
  577.                 if @enemy_speed != 0
  578.                   if rand(@enemy_speed) == 0
  579.                     number = cnt - $game_party.actors.size
  580.                     enemy_action(number)
  581.                   end
  582.                 else
  583.                   number = cnt - $game_party.actors.size
  584.                   enemy_action(number)
  585.                 end
  586.               end
  587.             end
  588.           end
  589.         else
  590.           battler.at += battler.agi
  591.           if battler.guarding?
  592.             battler.at += battler.agi
  593.           end
  594.           if battler.movable?
  595.             battler.atp = 100 * battler.at / @max
  596.           end
  597.         end
  598.       else
  599.         if battler.rt >= battler.rtp
  600.           speller = synthe?(battler)
  601.           if speller != nil
  602.             battler = speller[0]
  603.           end
  604.           unless @action_battlers.include?(battler)
  605.             if battler.is_a?(Game_Actor)
  606.               fullat_se
  607.             end
  608.             battler.rt = battler.rtp
  609.             action_start(battler)
  610.           end
  611.         else
  612.           battler.rt += battler.agi
  613.           speller = synthe?(battler)
  614.           if speller != nil
  615.             for spell in speller
  616.               if spell != battler
  617.                 spell.rt += battler.agi
  618.               end
  619.             end
  620.           end
  621.         end
  622.       end
  623.       cnt += 1
  624.     end
  625.     # Refresh AT gauge
  626.     @status_window.at_refresh
  627.     # Escape processing
  628.     if @escape == true and
  629.         ((@action > 0 and @action_battlers.empty?) or (@action == 0 and
  630.         (@action_battlers.empty? or @action_battlers[0].phase == 1)))
  631.       temp = false
  632.       for battler in $game_party.actors
  633.         if battler.inputable?
  634.           temp = true
  635.         end
  636.       end
  637.       if temp == true
  638.         for battler in $game_party.actors
  639.           if battler.at < @max and battler.inputable?
  640.             temp = false
  641.             break
  642.           end
  643.         end
  644.         if temp == true
  645.           @escape = false
  646.           for battler in $game_party.actors
  647.             battler.at %= @max
  648.           end
  649.           $game_temp.battle_main_phase = false
  650.           update_phase2_escape
  651.         end
  652.       end
  653.     end
  654.   end
  655.   #--------------------------------------------------------------------------
  656.   # * Start Party Command Phase
  657.   #--------------------------------------------------------------------------
  658.   def start_phase2
  659.     # Shift to phase 2
  660.     @phase = 2
  661.     @party = false
  662.     # Enable party command window
  663.     @party_command_window.active = true
  664.     @party_command_window.visible = true
  665.     # Set actor to non-selecting
  666.     @actor_index = -1
  667.     # Disable actor command window
  668.     @actor_command_window.active = false
  669.     @actor_command_window.visible = false
  670.     if @command.size != 0
  671.       # Actor blink effect OFF
  672.       if @active_actor != nil
  673.         @active_actor.blink = false
  674.       end
  675.     end
  676.     # Camera set
  677.     @camera == "party"
  678.     @spriteset.screen_target(0, 0, 1)
  679.     # Clear main phase flag
  680.     $game_temp.battle_main_phase = false
  681.   end
  682.   #--------------------------------------------------------------------------
  683.   # * Frame renewal (party command phase)
  684.   #--------------------------------------------------------------------------
  685.   def update_phase2
  686.     # When C button is pushed
  687.     if Input.trigger?(Input::C)
  688.       # It diverges at cursor position of the party command window
  689.       case @party_command_window.index
  690.       when 0  # It fights
  691.         # Nullifying the party command window
  692.         @party_command_window.active = false
  693.         @party_command_window.visible = false
  694.         # Performing decision SE
  695.         $game_system.se_play($data_system.decision_se)
  696.         @escape = false
  697.         @phase = 0
  698.         if $game_temp.battle_turn == 0
  699.           $game_temp.battle_turn = 1
  700.         end
  701.         if @command_a == true
  702.           # Actor command phase start
  703.           start_phase3
  704.         else
  705.           $game_temp.battle_main_phase = true
  706.         end
  707.       when 1  # It escapes
  708.         # When it is not flight possible,
  709.         if $game_temp.battle_can_escape == false
  710.           # Performing buzzer SE
  711.           $game_system.se_play($data_system.buzzer_se)
  712.           return
  713.         end
  714.         # Performing decision SE
  715.         $game_system.se_play($data_system.decision_se)
  716.         @phase = 0
  717.         # Nullifying the party command window
  718.         @party_command_window.active = false
  719.         @party_command_window.visible = false
  720.         $game_temp.battle_main_phase = true
  721.         if $game_temp.battle_turn == 0
  722.           update_phase2_escape
  723.           $game_temp.battle_turn = 1
  724.           for battler in $game_party.actors
  725.             battler.at -= @max / 2
  726.           end
  727.           return
  728.         end
  729.         # Performing decision SE
  730.         $game_system.se_play($data_system.decision_se)
  731.         @escape = true
  732.         for battler in $game_party.actors
  733.           @command_a = false
  734.           @command.delete(battler)
  735.           @action_battlers.delete(battler)
  736.           skill_reset(battler)
  737.         end
  738.       end
  739.       return
  740.     end
  741.   end
  742.   #--------------------------------------------------------------------------
  743.   # * Frame renewal (party command phase: It escapes)
  744.   #--------------------------------------------------------------------------
  745.   def update_phase2_escape
  746.     # The enemy it is fast, calculating mean value
  747.     enemies_agi = 0
  748.     enemies_number = 0
  749.     for enemy in $game_troop.enemies
  750.       if enemy.exist?
  751.         enemies_agi += enemy.agi
  752.         enemies_number += 1
  753.       end
  754.     end
  755.     if enemies_number > 0
  756.       enemies_agi /= enemies_number
  757.     end
  758.     # The actor it is fast, calculating mean value
  759.     actors_agi = 0
  760.     actors_number = 0
  761.     for actor in $game_party.actors
  762.       if actor.exist?
  763.         actors_agi += actor.agi
  764.         actors_number += 1
  765.       end
  766.     end
  767.     if actors_number > 0
  768.       actors_agi /= actors_number
  769.     end
  770.     # Flight success decision
  771.     success = rand(100) < 50 * actors_agi / enemies_agi
  772.     # In case of flight success
  773.     if success
  774.       # Performing flight SE
  775.       $game_system.se_play($data_system.escape_se)
  776.       # You reset to BGM before the battle starting
  777.       $game_system.bgm_play($game_temp.map_bgm)
  778.       # Battle end
  779.       battle_end(1)
  780.     # In case of failure of flight
  781.     else
  782.       @help_window.set_text("Cannot escape", 1)
  783.       @help_wait = @help_time
  784.       # Clearing the action of party everyone
  785.       $game_party.clear_actions
  786.       # Main phase start
  787.       start_phase4
  788.     end
  789.   end
  790.   #--------------------------------------------------------------------------
  791.   # * After battle phase start
  792.   #--------------------------------------------------------------------------
  793.   def start_phase5
  794.     # It moves to phase 5
  795.     @phase = 5
  796.     # Performing battle end ME
  797.     $game_system.me_play($game_system.battle_end_me)
  798.     # You reset to BGM before the battle starting
  799.     $game_system.bgm_play($game_temp.map_bgm)
  800.     # Initializing EXP, the gold and the treasure
  801.     exp = 0
  802.     gold = 0
  803.     treasures = []
  804.     if @active_actor != nil
  805.       @active_actor.blink = false
  806.     end
  807.     # Setting the main phase flag
  808.     $game_temp.battle_main_phase = true
  809.     # Nullifying the party command window
  810.     @party_command_window.active = false
  811.     @party_command_window.visible = false
  812.     # Nullifying the actor command window
  813.     @actor_command_window.active = false
  814.     @actor_command_window.visible = false
  815.     if @skill_window != nil
  816.       # Releasing the skill window
  817.       @skill_window.dispose
  818.       @skill_window = nil
  819.     end
  820.     if @item_window != nil
  821.       # Releasing the item window
  822.       @item_window.dispose
  823.       @item_window = nil
  824.     end
  825.     # The help window is hidden
  826.     @help_window.visible = false if @help_wait == 0
  827.     # Loop
  828.     for enemy in $game_troop.enemies
  829.       # When the enemy hides and it is not state,
  830.       unless enemy.hidden
  831.         # Adding acquisition EXP and the gold
  832.         exp += enemy.exp
  833.         gold += enemy.gold
  834.         # Treasure appearance decision
  835.         if rand(100) < enemy.treasure_prob
  836.           if enemy.item_id > 0
  837.             treasures.push($data_items[enemy.item_id])
  838.           end
  839.           if enemy.weapon_id > 0
  840.             treasures.push($data_weapons[enemy.weapon_id])
  841.           end
  842.           if enemy.armor_id > 0
  843.             treasures.push($data_armors[enemy.armor_id])
  844.           end
  845.         end
  846.       end
  847.     end
  848.     # It limits the number of treasures up to 6
  849.     treasures = treasures[0..5]
  850.     # EXP acquisition
  851.     for i in 0...$game_party.actors.size
  852.       actor = $game_party.actors[i]
  853.       if actor.cant_get_exp? == false
  854.         last_level = actor.level
  855.         actor.exp += exp
  856.         if actor.level > last_level
  857.           @status_window.level_up(i)
  858.           actor.damage[[actor, -1]] = "Level up!"
  859.           actor.up_level = actor.level - last_level
  860.         end
  861.       end
  862.     end
  863.     # Gold acquisition
  864.     $game_party.gain_gold(gold)
  865.     # Treasure acquisition
  866.     for item in treasures
  867.       case item
  868.       when RPG::Item
  869.         $game_party.gain_item(item.id, 1)
  870.       when RPG::Weapon
  871.         $game_party.gain_weapon(item.id, 1)
  872.       when RPG::Armor
  873.         $game_party.gain_armor(item.id, 1)
  874.       end
  875.     end
  876.     # Drawing up the battle result window
  877.     @result_window = Window_BattleResult.new(exp, gold, treasures)
  878.     # Setting wait count
  879.     @phase5_wait_count = 100
  880.   end
  881.   #--------------------------------------------------------------------------
  882.   # * Frame renewal (after battle phase)
  883.   #--------------------------------------------------------------------------
  884.   def update_phase5
  885.     # When wait count is larger than 0,
  886.     if @phase5_wait_count > 0
  887.       # Wait count is decreased
  888.       @phase5_wait_count -= 1
  889.       # When wait count becomes 0,
  890.       if @phase5_wait_count == 0
  891.         # Indicating the result window
  892.         @result_window.visible = true
  893.         # Clearing the main phase flag
  894.         $game_temp.battle_main_phase = false
  895.         # Refreshing the status window
  896.         @status_window.refresh
  897.         for actor in $game_party.actors
  898.           if actor.damage.include?([actor, 0])
  899.             @phase5_wait_count = 20
  900.             actor.damage_pop[[actor, 0]] = true
  901.           end
  902.           if actor.damage.include?([actor, -1])
  903.             @phase5_wait_count = 20
  904.             actor.damage_pop[[actor, -1]] = true
  905.             for level in actor.level - actor.up_level + 1..actor.level
  906.               for skill in $data_classes[actor.class_id].learnings
  907.                 if level == skill.level and not actor.skill_learn?(skill.id)
  908.                   actor.damage[[actor, 0]] = "New Skill!"
  909.                   break
  910.                 end
  911.               end
  912.             end
  913.           end
  914.         end
  915.       end
  916.       return
  917.     end
  918.     # When C button is pushed,
  919.     if Input.trigger?(Input::C)
  920.       # Battle end
  921.       battle_end(0)
  922.     end
  923.   end
  924.  
  925. #==============================================================================
  926. # ** Scene_Battle (Part 3)
  927. #------------------------------------------------------------------------------
  928. #  This class performs battle screen processing.
  929. #==============================================================================
  930.  
  931.   #--------------------------------------------------------------------------
  932.   # * Actor command phase start
  933.   #--------------------------------------------------------------------------
  934.   def start_phase3
  935.     if victory?
  936.       return
  937.     end
  938.     # Clearing the main phase flag
  939.     $game_temp.battle_main_phase = false
  940.     @command_a = true
  941.     @active_actor = @command[0]
  942.     cnt = 0
  943.     for actor in $game_party.actors
  944.       if actor == @active_actor
  945.         @actor_index = cnt
  946.       end
  947.       cnt += 1
  948.     end
  949.     @active_actor.blink = true
  950.     unless @active_actor.inputable?
  951.       @active_actor.current_action.clear
  952.       phase3_next_actor
  953.       return
  954.     end
  955.     phase3_setup_command_window
  956.     # Setting of camera
  957.     @camera = "command"
  958.     plus = ($game_party.actors.size - 1) / 2.0 - @actor_index
  959.     y = [(plus.abs - 1.5) * 10 , 0].min
  960.     @spriteset.screen_target(plus * 50, y, 1.0 + y * 0.002)
  961.   end
  962.   #--------------------------------------------------------------------------
  963.   # * Command input end of actor
  964.   #--------------------------------------------------------------------------
  965.   def phase3_next_actor
  966.     @command.shift
  967.     @command_a = false
  968.     # Setting the main phase flag
  969.     $game_temp.battle_main_phase = true
  970.     # Nullifying the actor command window
  971.     @actor_command_window.active = false
  972.     @actor_command_window.visible = false
  973.     # Blinking effect OFF of actor
  974.     if @active_actor != nil
  975.       @active_actor.blink = false
  976.     end
  977.     action_start(@active_actor)
  978.     # You reset on the basis of the camera
  979.     if @camera == "command"
  980.       @spriteset.screen_target(0, 0, 1)
  981.     end
  982.     return
  983.   end
  984.   #--------------------------------------------------------------------------
  985.   # * Setup of actor command window
  986.   #--------------------------------------------------------------------------
  987.   def phase3_setup_command_window
  988.     # Nullifying the party command window
  989.     @party_command_window.active = false
  990.     @party_command_window.visible = false
  991.     # Enabling the actor command window
  992.     @actor_command_window.active = true
  993.     @actor_command_window.visible = true
  994.     # Setting the position of the actor command window
  995.     @actor_command_window.x = @actor_index * 160 +
  996.                               (4 - $game_party.actors.size) * 80
  997.     # Setting the index to 0
  998.     @actor_command_window.index = 0
  999.   end
  1000.   #--------------------------------------------------------------------------
  1001.   # * Enemy action compilation
  1002.   #--------------------------------------------------------------------------
  1003.   def enemy_action(number)
  1004.     enemy = $game_troop.enemies[number]
  1005.     unless enemy.current_action.forcing
  1006.       enemy.make_action
  1007.     end
  1008.     action_start(enemy)
  1009.   end
  1010.   #--------------------------------------------------------------------------
  1011.   # * Frame renewal (actor command phase)
  1012.   #--------------------------------------------------------------------------
  1013.   def update_phase3
  1014.     if victory? and @command_a
  1015.       command_delete
  1016.       @command.push(@active_actor)
  1017.       return
  1018.     end
  1019.     # When the enemy arrow is effective,
  1020.     if @enemy_arrow != nil
  1021.       update_phase3_enemy_select
  1022.     # When the actor arrow is effective,
  1023.     elsif @actor_arrow != nil
  1024.       update_phase3_actor_select
  1025.     # When the skill window is effective,
  1026.     elsif @skill_window != nil
  1027.       update_phase3_skill_select
  1028.     # When the item window is effective
  1029.     elsif @item_window != nil
  1030.       update_phase3_item_select
  1031.     # When the actor command window is effective,
  1032.     elsif @actor_command_window.active
  1033.       update_phase3_basic_command
  1034.     end
  1035.   end
  1036.   #--------------------------------------------------------------------------
  1037.   # * Frame renewal (actor command phase: Basic command)
  1038.   #--------------------------------------------------------------------------
  1039.   def update_phase3_basic_command
  1040.     unless @active_actor.inputable?
  1041.       @active_actor.current_action.clear
  1042.       phase3_next_actor
  1043.       return
  1044.     end
  1045.     # The B when button is pushed,
  1046.     if Input.trigger?(Input::B) and @party == false
  1047.       # Performing cancellation SE
  1048.       $game_system.se_play($data_system.cancel_se)
  1049.       @party = true
  1050.     end
  1051.     if @party == true and
  1052.         ((@action > 0 and @action_battlers.empty?) or (@action == 0 and
  1053.         (@action_battlers.empty? or @action_battlers[0].phase == 1)))
  1054.       # To party command phase
  1055.       start_phase2
  1056.       return
  1057.     end
  1058.     # When C button is pushed,
  1059.     if Input.trigger?(Input::C)
  1060.       @party = false
  1061.       # It diverges at cursor position of the actor command window
  1062.       case @actor_command_window.index
  1063.       when 0  # Attack
  1064.         # Performing decision SE
  1065.         $game_system.se_play($data_system.decision_se)
  1066.         # Starting the selection of the enemy
  1067.         start_enemy_select
  1068.       when 1  # Skill
  1069.         # Performing decision SE
  1070.         $game_system.se_play($data_system.decision_se)
  1071.         # Starting the selection of skill
  1072.         start_skill_select
  1073.       when 2  # Defense
  1074.         # Performing decision SE
  1075.         $game_system.se_play($data_system.decision_se)
  1076.         # Setting action
  1077.         @active_actor.current_action.kind = 0
  1078.         @active_actor.current_action.basic = 1
  1079.         # To command input of the following actor
  1080.         phase3_next_actor
  1081.       when 3  # Item
  1082.         # Performing decision SE
  1083.         $game_system.se_play($data_system.decision_se)
  1084.         # Starting the selection of the item
  1085.         start_item_select
  1086.       end
  1087.       return
  1088.     end
  1089.     # Change Character
  1090.     if @command.size > 1
  1091.       # When the R when button is pushed,
  1092.       if Input.trigger?(Input::R)
  1093.         $game_system.se_play($data_system.cursor_se)
  1094.         @party = false
  1095.         # Blinking effect OFF of actor
  1096.         if @active_actor != nil
  1097.           @active_actor.blink = false
  1098.         end
  1099.         @command.push(@command[0])
  1100.         @command.shift
  1101.         @command_a = false
  1102.         # Start-up of new command window
  1103.         start_phase3
  1104.       end
  1105.       # When the L when button is pushed,
  1106.       if Input.trigger?(Input::L)
  1107.         $game_system.se_play($data_system.cursor_se)
  1108.         @party = false
  1109.         # Blinking effect OFF of actor
  1110.         if @active_actor != nil
  1111.           @active_actor.blink = false
  1112.         end
  1113.         @command.unshift(@command[@command.size - 1])
  1114.         @command.delete_at(@command.size - 1)
  1115.         @command_a = false
  1116.         # Start-up of new command window
  1117.         start_phase3
  1118.       end
  1119.      # When the right button is pushed,
  1120.       if Input.trigger?(Input::RIGHT)
  1121.         $game_system.se_play($data_system.cursor_se)
  1122.         @party = false
  1123.         # Blinking effect OFF of actor
  1124.         if @active_actor != nil
  1125.           @active_actor.blink = false
  1126.         end
  1127.         actor = $game_party.actors[@actor_index]
  1128.         while actor == @command[0] or (not @command.include?(actor))
  1129.           @actor_index += 1
  1130.           @actor_index %= $game_party.actors.size
  1131.           actor = $game_party.actors[@actor_index]
  1132.           if actor == @command[0]
  1133.             break
  1134.           end
  1135.         end
  1136.         while actor != @command[0]
  1137.           @command.push(@command.shift)
  1138.         end
  1139.         @command_a = false
  1140.         # Start-up of new command window
  1141.         start_phase3
  1142.       end
  1143.      # When the left button is pushed,
  1144.       if Input.trigger?(Input::LEFT)
  1145.         $game_system.se_play($data_system.cursor_se)
  1146.         @party = false
  1147.         # Blinking effect OFF of actor
  1148.         if @active_actor != nil
  1149.           @active_actor.blink = false
  1150.         end
  1151.         actor = $game_party.actors[@actor_index]
  1152.         while actor == @command[0] or (not @command.include?(actor))
  1153.           @actor_index -= 1
  1154.           @actor_index %= $game_party.actors.size
  1155.           actor = $game_party.actors[@actor_index]
  1156.           if actor == @command[0]
  1157.             break
  1158.           end
  1159.         end
  1160.         while actor != @command[0]
  1161.           @command.push(@command.shift)
  1162.         end
  1163.         @command_a = false
  1164.         # Start-up of new command window
  1165.         start_phase3
  1166.       end
  1167.     end
  1168.   end
  1169.   #--------------------------------------------------------------------------
  1170.   # * Frame renewal (actor command phase: Skill selection)
  1171.   #--------------------------------------------------------------------------
  1172.   def update_phase3_skill_select
  1173.     # During command selecting when it becomes incapacitation,
  1174.     unless @active_actor.inputable?
  1175.       @active_actor.current_action.clear
  1176.       command_delete
  1177.       # To command input of the following actor
  1178.       phase3_next_actor
  1179.       return
  1180.     end
  1181.     # The skill window is put in visible state
  1182.     @skill_window.visible = true
  1183.     # Renewing the skill window
  1184.     @skill_window.update
  1185.     # The B when button is pushed,
  1186.     if Input.trigger?(Input::B)
  1187.       # Performing cancellation SE
  1188.       $game_system.se_play($data_system.cancel_se)
  1189.       # End selection of skill
  1190.       end_skill_select
  1191.       return
  1192.     end
  1193.     # When C button is pushed,
  1194.     if Input.trigger?(Input::C)
  1195.       # Acquiring the data which presently is selected in the skill window
  1196.       @skill = @skill_window.skill
  1197.       # When you cannot use,
  1198.       if @skill == nil or not @active_actor.skill_can_use?(@skill.id)
  1199.         # Performing buzzer SE
  1200.         $game_system.se_play($data_system.buzzer_se)
  1201.         return
  1202.       end
  1203.       # Performing decision SE
  1204.       $game_system.se_play($data_system.decision_se)
  1205.       # Setting action
  1206.       @active_actor.current_action.skill_id = @skill.id
  1207.       # The skill window is put in invisibility state
  1208.       @skill_window.visible = false
  1209.       # When the effective range is the enemy single unit,
  1210.       if @skill.scope == 1
  1211.         # Starting the selection of the enemy
  1212.         start_enemy_select
  1213.       # When the effective range is the friend single unit,
  1214.       elsif @skill.scope == 3 or @skill.scope == 5
  1215.         # Starting the selection of the actor
  1216.         start_actor_select
  1217.       # When the effective range is not the single unit,
  1218.       else
  1219.         # Setting action
  1220.         @active_actor.current_action.kind = 1
  1221.         # End selection of skill
  1222.         end_skill_select
  1223.         # To command input of the following actor
  1224.         phase3_next_actor
  1225.       end
  1226.       return
  1227.     end
  1228.   end
  1229.   #--------------------------------------------------------------------------
  1230.   # * Frame renewal (actor command phase: Item selection)
  1231.   #--------------------------------------------------------------------------
  1232.   def update_phase3_item_select
  1233.     # During command selecting when it becomes incapacitation,
  1234.     unless @active_actor.inputable?
  1235.       @active_actor.current_action.clear
  1236.       command_delete
  1237.       # To command input of the following actor
  1238.       phase3_next_actor
  1239.       return
  1240.     end
  1241.     # The item window is put in visible state
  1242.     @item_window.visible = true
  1243.     # Renewing the item window
  1244.     @item_window.update
  1245.     # The B when button is pushed,
  1246.     if Input.trigger?(Input::B)
  1247.       # Performing cancellation SE
  1248.       $game_system.se_play($data_system.cancel_se)
  1249.       # End selection of item
  1250.       end_item_select
  1251.       return
  1252.     end
  1253.     #When C button is pushed,
  1254.     if Input.trigger?(Input::C)
  1255.       # Acquiring the data which presently is selected in the item window
  1256.       @item = @item_window.item
  1257.       # When you cannot use,
  1258.       unless $game_party.item_can_use?(@item.id)
  1259.         # Performing buzzer SE
  1260.         $game_system.se_play($data_system.buzzer_se)
  1261.         return
  1262.       end
  1263.       # Performing decision SE
  1264.       $game_system.se_play($data_system.decision_se)
  1265.       # Setting action
  1266.       @active_actor.current_action.item_id = @item.id
  1267.       # The item window is put in invisibility state
  1268.       @item_window.visible = false
  1269.       # When the effective range is the enemy single unit,
  1270.       if @item.scope == 1
  1271.         # Starting the selection of the enemy
  1272.         start_enemy_select
  1273.       # When the effective range is the friend single unit,
  1274.       elsif @item.scope == 3 or @item.scope == 5
  1275.         # Starting the selection of the actor
  1276.         start_actor_select
  1277.       # When the effective range is not the single unit,
  1278.       else
  1279.         # Setting action
  1280.         @active_actor.current_action.kind = 2
  1281.         # End selection of item
  1282.         end_item_select
  1283.         # To command input of the following actor
  1284.         phase3_next_actor
  1285.       end
  1286.       return
  1287.     end
  1288.   end
  1289.   #--------------------------------------------------------------------------
  1290.   # * Frame renewal (actor command phase: Enemy selection)
  1291.   #--------------------------------------------------------------------------
  1292.   def update_phase3_enemy_select
  1293.     # During command selecting when it becomes incapacitation,
  1294.     unless @active_actor.inputable?
  1295.       # You reset on the basis of the camera
  1296.       if @camera == "select"
  1297.         @spriteset.screen_target(0, 0, 1)
  1298.       end
  1299.       @active_actor.current_action.clear
  1300.       command_delete
  1301.       # To command input of the following actor
  1302.       phase3_next_actor
  1303.       return
  1304.     end
  1305.     # Renewing the enemy arrow
  1306.     @enemy_arrow.update
  1307.     # The B when button is pushed,
  1308.     if Input.trigger?(Input::B)
  1309.       # Performing cancellation SE
  1310.       $game_system.se_play($data_system.cancel_se)
  1311.       # You reset on the basis of the camera
  1312.       if @camera == "select"
  1313.         # Setting of camera
  1314.         @camera = "command"
  1315.         plus = ($game_party.actors.size - 1) / 2.0 - @actor_index
  1316.         y = [(plus.abs - 1.5) * 10 , 0].min
  1317.         @spriteset.screen_target(plus * 50, y, 1.0 + y * 0.002)
  1318.       end
  1319.       # End selection of enemy
  1320.       end_enemy_select
  1321.       return
  1322.     end
  1323.     # When C button is pushed,
  1324.     if Input.trigger?(Input::C)
  1325.       # Performing decision SE
  1326.       $game_system.se_play($data_system.decision_se)
  1327.       # Performing decision SE
  1328.       @active_actor.current_action.kind = 0
  1329.       @active_actor.current_action.basic = 0
  1330.       @active_actor.current_action.target_index = @enemy_arrow.index
  1331.       # When it is in the midst of skill window indicating,
  1332.       if @skill_window != nil
  1333.         # Resetting action
  1334.         @active_actor.current_action.kind = 1
  1335.         # End selection of skill
  1336.         end_skill_select
  1337.       end
  1338.       # When it is in the midst of item window indicating,
  1339.       if @item_window != nil
  1340.         # Resetting action
  1341.         @active_actor.current_action.kind = 2
  1342.         # End selection of item
  1343.         end_item_select
  1344.       end
  1345.       # End selection of enemy
  1346.       end_enemy_select
  1347.       # To command input of the following actor
  1348.       phase3_next_actor
  1349.     end
  1350.   end
  1351.   #--------------------------------------------------------------------------
  1352.   # * Frame renewal (actor command phase: Actor selection)
  1353.   #--------------------------------------------------------------------------
  1354.   def update_phase3_actor_select
  1355.     # During command selecting when it becomes incapacitation,
  1356.     unless @active_actor.inputable?
  1357.       @active_actor.current_action.clear
  1358.       command_delete
  1359.       # To command input of the following actor
  1360.       phase3_next_actor
  1361.       return
  1362.     end
  1363.     # Renewing the actor arrow
  1364.     @actor_arrow.update
  1365.     # The B when button is pushed,
  1366.     if Input.trigger?(Input::B)
  1367.       # Performing cancellation SE
  1368.       $game_system.se_play($data_system.cancel_se)
  1369.       # End selection of actor
  1370.       end_actor_select
  1371.       return
  1372.     end
  1373.     # When C button is pushed,
  1374.     if Input.trigger?(Input::C)
  1375.       # Performing decision SE
  1376.       $game_system.se_play($data_system.decision_se)
  1377.       # Setting action
  1378.       @active_actor.current_action.kind = 0
  1379.       @active_actor.current_action.basic = 0
  1380.       @active_actor.current_action.target_index = @actor_arrow.index
  1381.       # End selection of actor
  1382.       end_actor_select
  1383.       # When it is in the midst of skill window indicating,
  1384.       if @skill_window != nil
  1385.         # Resetting action
  1386.         @active_actor.current_action.kind = 1
  1387.         # End selection of skill
  1388.         end_skill_select
  1389.       end
  1390.       # When it is in the midst of item window indicating
  1391.       if @item_window != nil
  1392.         # Resetting action
  1393.         @active_actor.current_action.kind = 2
  1394.         # End selection of item
  1395.         end_item_select
  1396.       end
  1397.       # To command input of the following actor
  1398.       phase3_next_actor
  1399.     end
  1400.   end
  1401.   #--------------------------------------------------------------------------
  1402.   # * Start of enemy selection
  1403.   #--------------------------------------------------------------------------
  1404.   alias :start_enemy_select_rtab :start_enemy_select
  1405.   def start_enemy_select
  1406.     @camera = "select"
  1407.     for enemy in $game_troop.enemies
  1408.       if enemy.exist?
  1409.         zoom = 1 / enemy.zoom
  1410.         @spriteset.screen_target(enemy.attack_x(zoom) * 0.75,
  1411.                                   enemy.attack_y(zoom) * 0.75, zoom)
  1412.         break
  1413.       end
  1414.     end
  1415.     # Original processing
  1416.     start_enemy_select_rtab
  1417.   end
  1418.   #--------------------------------------------------------------------------
  1419.   # * Enemy selection end
  1420.   #--------------------------------------------------------------------------
  1421.   alias :end_enemy_select_rtab :end_enemy_select
  1422.   def end_enemy_select
  1423.     # Original processing
  1424.     end_enemy_select_rtab
  1425.     if (@action == 0 and not @action_battlers.empty?) or
  1426.           (@camera == "select" and (@active_actor.current_action.kind != 0 or
  1427.                                             @active_actor.animation1_id != 0))
  1428.       @spriteset.screen_target(0, 0, 1)
  1429.     end
  1430.   end
  1431.   #--------------------------------------------------------------------------
  1432.   # * Start of skill selection
  1433.   #--------------------------------------------------------------------------
  1434.   def start_skill_select
  1435.     # Drawing up the skill window
  1436.     @skill_window = Window_Skill.new(@active_actor)
  1437.     # Help window association
  1438.     @skill_window.help_window = @help_window
  1439.     # Nullifying the actor command window
  1440.     @actor_command_window.active = false
  1441.     @actor_command_window.visible = false
  1442.   end
  1443.  
  1444. #==============================================================================
  1445. # ** Scene_Battle (Part 4)
  1446. #------------------------------------------------------------------------------
  1447. #  It is the class which processes the battle picture.
  1448. #==============================================================================
  1449.  
  1450.   #--------------------------------------------------------------------------
  1451.   # * Main phase start
  1452.   #--------------------------------------------------------------------------
  1453.   def start_phase4
  1454.     $game_temp.battle_main_phase = true
  1455.   end
  1456.   #--------------------------------------------------------------------------
  1457.   # * Frame renewal (main phase)
  1458.   #--------------------------------------------------------------------------
  1459.   def update_phase4
  1460.     # When the battler who is forced action exists
  1461.     if $game_temp.forcing_battler != nil
  1462.       battler = $game_temp.forcing_battler
  1463.       if battler.current_action.forcing == false
  1464.         if @action_battlers.include?(battler)
  1465.           if @action > 0 or @action_battlers[0].phase == 1
  1466.             @action_battlers.delete(battler)
  1467.             @action_battlers.push(battler)
  1468.           end
  1469.           if battler.phase == 1
  1470.             battler.current_action.forcing = true
  1471.             force_action(battler)
  1472.           end
  1473.         else
  1474.           battler.current_action.forcing = true
  1475.           force_action(battler)
  1476.           action_start(battler)
  1477.           @action_battlers.delete(battler)
  1478.           @action_battlers.push(battler)
  1479.         end
  1480.         battler.at = @max
  1481.         battler.atp = 100 * battler.at / @max
  1482.       end
  1483.     end
  1484.     # When action is 1 or more, conduct is caused simultaneously
  1485.     for battler in @action_battlers.reverse
  1486.       # When it is in wait,
  1487.       if battler.wait > 0
  1488.         # Wait count is decreased
  1489.         battler.wait -= 1
  1490.         break if @action == 0
  1491.         next
  1492.       end
  1493.       unless fin? and battler.phase < 3 and
  1494.           not $game_system.battle_interpreter.running?
  1495.         action_phase(battler)
  1496.       end
  1497.       break if @action == 0
  1498.     end
  1499.     # When the battler who is forced action does not exist
  1500.     if $game_temp.forcing_battler == nil
  1501.       # Setting up the battle event
  1502.       setup_battle_event
  1503.       # When it is in the midst of battle event executing,
  1504.       if $game_system.battle_interpreter.running?
  1505.         return
  1506.       end
  1507.     end
  1508.     # The case where victory or defeat is decided processing
  1509.     if fin?
  1510.       # When being defeated, designated time wait
  1511.       if $game_party.all_dead? and @after_wait[0] > 0
  1512.         @after_wait[0] -= 1
  1513.         return
  1514.       end
  1515.       # At the time of victory, designated time wait
  1516.       if victory? and @after_wait[1] > 0
  1517.         @after_wait[1] -= 1
  1518.         return
  1519.       end
  1520.       # When battle ends, at the same time the actor is immediately before the acting, eliminating the conduct of the actor
  1521.       for battler in @action_battlers.reverse
  1522.         if battler.phase < 3 and not $game_system.battle_interpreter.running?
  1523.           @action_battlers.delete(battler)
  1524.         end
  1525.       end
  1526.       # Victory or defeat decision
  1527.       if @action_battlers.empty? and
  1528.           not $game_system.battle_interpreter.running?
  1529.         judge
  1530.       end
  1531.     end
  1532.   end
  1533.   #--------------------------------------------------------------------------
  1534.   # * Action renewal (main phase)
  1535.   #--------------------------------------------------------------------------
  1536.   def action_phase(battler)
  1537.     # When action 1 is, verification whether or not the battler while acting
  1538.     if @action == 1 and battler.phase <= 3
  1539.       for target in battler.target
  1540.         speller = synthe?(target)
  1541.         if speller == nil
  1542.           # When the target is in the midst of usual acting,
  1543.           if @action_battlers.include?(target)
  1544.             if target.phase > 2
  1545.               return
  1546.             end
  1547.           end
  1548.         else
  1549.           # When the target is in the midst of cooperation skill moving
  1550.           for spell in speller
  1551.             if @action_battlers.include?(spell)
  1552.               if spell.phase > 2
  1553.                 return
  1554.               end
  1555.             end
  1556.           end
  1557.         end
  1558.       end
  1559.     end
  1560.     case battler.phase
  1561.     when 1
  1562.       update_phase4_step1(battler)
  1563.     when 2
  1564.       update_phase4_step2(battler)
  1565.     when 3
  1566.       update_phase4_step3(battler)
  1567.     when 4
  1568.       update_phase4_step4(battler)
  1569.     when 5
  1570.       update_phase4_step5(battler)
  1571.     when 6
  1572.       update_phase4_step6(battler)
  1573.     end
  1574.   end
  1575.   #--------------------------------------------------------------------------
  1576.   # * Frame Update (main phase step 1 : action preparation)
  1577.   #--------------------------------------------------------------------------
  1578.   def update_phase4_step1(battler)
  1579.     # Already, when it is removed from battle
  1580.     if battler.index == nil
  1581.       @action_battlers.delete(battler)
  1582.       anime_wait_return
  1583.       return
  1584.     end
  1585.     speller = synthe?(battler)
  1586.     if speller == nil
  1587.       # When it is while the damage receiving
  1588.       unless battler.damage.empty? or @action > 2
  1589.         return
  1590.       end
  1591.       # Whether or not conduct possibility decision
  1592.       unless battler.movable?
  1593.         battler.phase = 6
  1594.         return
  1595.       end
  1596.     else
  1597.       # When it is while the damage receiving,
  1598.       for spell in speller
  1599.         unless spell.damage.empty? or @action > 2
  1600.           return
  1601.         end
  1602.         # Whether or not conduct possibility decision
  1603.         unless spell.movable?
  1604.           battler.phase = 6
  1605.           return
  1606.         end
  1607.       end
  1608.     end
  1609.     # At the time of skill use, permanent residence time setting
  1610.     # When forced action and @force 2 being, skill immediately motion
  1611.     if battler.current_action.kind == 1 and
  1612.       (not battler.current_action.forcing or @force != 2)
  1613.       if battler.rtp == 0
  1614.         # If it is in the midst of skill residing permanently, cancellation
  1615.         skill_reset(battler)
  1616.         # Skill permanent residence time setting
  1617.         recite_time(battler)
  1618.         # Cooperation skill setting
  1619.         synthe_spell(battler)
  1620.         # When skill you reside permanently,
  1621.         if battler.rtp > 0
  1622.           # When forced action and @force 1 being, only cooperation skill immediately motion
  1623.           speller = synthe?(battler)
  1624.           if battler.current_action.forcing and @force > 0 and speller != nil
  1625.             for spell in speller
  1626.               spell.rt = spell.rtp
  1627.             end
  1628.           else
  1629.             battler.blink = true
  1630.             if battler.current_action.forcing
  1631.               $game_temp.forcing_battler = nil
  1632.               battler.current_action.forcing = false
  1633.             end
  1634.             @action_battlers.delete(battler)
  1635.             return
  1636.           end
  1637.         end
  1638.       end
  1639.     end
  1640.     # Blinking effect OFF of actor
  1641.     if battler != nil
  1642.       battler.blink = false
  1643.     end
  1644.     speller = synthe?(battler)
  1645.     if speller == nil
  1646.       @spell_p.delete(battler)
  1647.       @spell_e.delete(battler)
  1648.     else
  1649.       for spell in speller
  1650.         spell.blink = false
  1651.         @spell_p.delete(spell)
  1652.         @spell_e.delete(spell)
  1653.       end
  1654.     end
  1655.     # It moves to step 2
  1656.     battler.phase = 2
  1657.   end
  1658.   #--------------------------------------------------------------------------
  1659.   # * Frame renewal (main phase step 2: Action start)
  1660.   #--------------------------------------------------------------------------
  1661.   def update_phase4_step2(battler)
  1662.     # If it is not forced action
  1663.     unless battler.current_action.forcing
  1664.       # When restriction [ the enemy is attacked ] [ friend attacks ] usually usually
  1665.       if battler.restriction == 2 or battler.restriction == 3
  1666.         # Setting attack to action
  1667.         battler.current_action.kind = 0
  1668.         battler.current_action.basic = 0
  1669.       end
  1670.     end
  1671.     # It diverges with classification of action
  1672.     case battler.current_action.kind
  1673.     when 0  # Basis
  1674.       if fin?
  1675.         battler.phase = 6
  1676.         return
  1677.       end
  1678.       make_basic_action_result(battler)
  1679.     when 1  # Skill
  1680.       if fin? and $data_skills[battler.current_action.skill_id].scope == 1..2
  1681.         battler.phase = 6
  1682.         return
  1683.       end
  1684.       make_skill_action_result(battler)
  1685.     when 2  # Item
  1686.       if fin? and $data_items[battler.current_action.item_id].scope == 1..2
  1687.         battler.phase = 6
  1688.         return
  1689.       end
  1690.       make_item_action_result(battler)
  1691.     end
  1692.     if battler.phase == 2
  1693.       # It moves to step 3
  1694.       battler.phase = 3
  1695.     end
  1696.   end
  1697.   #--------------------------------------------------------------------------
  1698.   # * Basic action result compilation
  1699.   #--------------------------------------------------------------------------
  1700.   def make_basic_action_result(battler)
  1701.     # In case of attack
  1702.     if battler.current_action.basic == 0
  1703.       # Setting animation ID
  1704.       battler.anime1 = battler.animation1_id
  1705.       battler.anime2 = battler.animation2_id
  1706.       # When the conduct side battler is the enemy
  1707.       if battler.is_a?(Game_Enemy)
  1708.         if battler.restriction == 3
  1709.           target = $game_troop.random_target_enemy
  1710.         elsif battler.restriction == 2
  1711.           target = $game_party.random_target_actor
  1712.         else
  1713.           index = battler.current_action.target_index
  1714.           target = $game_party.smooth_target_actor(index)
  1715.         end
  1716.       end
  1717.       # When the conduct side battler is the actor
  1718.       if battler.is_a?(Game_Actor)
  1719.         if battler.restriction == 3
  1720.           target = $game_party.random_target_actor
  1721.         elsif battler.restriction == 2
  1722.           target = $game_troop.random_target_enemy
  1723.         else
  1724.           index = battler.current_action.target_index
  1725.           target = $game_troop.smooth_target_enemy(index)
  1726.         end
  1727.       end
  1728.       # Setting the arrangement of the object side battler
  1729.       battler.target = [target]
  1730.       # Applying the effect of normality attack
  1731.       for target in battler.target
  1732.         target.attack_effect(battler)
  1733.       end
  1734.       return
  1735.     end
  1736.     # In case of defense
  1737.     if battler.current_action.basic == 1
  1738.       return
  1739.     end
  1740.     # When escapes and is
  1741.     if battler.is_a?(Game_Enemy) and battler.current_action.basic == 2
  1742.       return
  1743.     end
  1744.     # When what is not and is
  1745.     if battler.current_action.basic == 3
  1746.       # It moves to step 6
  1747.       battler.phase = 6
  1748.       return
  1749.     end
  1750.   end
  1751.   #--------------------------------------------------------------------------
  1752.   # * Object side battler setting of skill or item
  1753.   #     scope : Effective range of skill or item
  1754.   #--------------------------------------------------------------------------
  1755.   def set_target_battlers(scope, battler)
  1756.     # When the conduct side battler is the enemy,
  1757.     if battler.is_a?(Game_Enemy)
  1758.       # It diverges in the effective range
  1759.       case scope
  1760.       when 1  # Enemy single unit
  1761.         index =battler.current_action.target_index
  1762.         battler.target.push($game_party.smooth_target_actor(index))
  1763.       when 2  # Whole enemy
  1764.         for actor in $game_party.actors
  1765.           if actor.exist?
  1766.             battler.target.push(actor)
  1767.           end
  1768.         end
  1769.       when 3  # Friend single unit
  1770.         index = battler.current_action.target_index
  1771.         battler.target.push($game_troop.smooth_target_enemy(index))
  1772.       when 4  # Whole friend
  1773.         for enemy in $game_troop.enemies
  1774.           if enemy.exist?
  1775.             battler.target.push(enemy)
  1776.           end
  1777.         end
  1778.       when 5  # Friend single unit (HP 0)
  1779.         index = battler.current_action.target_index
  1780.         enemy = $game_troop.enemies[index]
  1781.         if enemy != nil and enemy.hp0?
  1782.           battler.target.push(enemy)
  1783.         end
  1784.       when 6  # Whole friend (HP 0)
  1785.         for enemy in $game_troop.enemies
  1786.           if enemy != nil and enemy.hp0?
  1787.             battler.target.push(enemy)
  1788.           end
  1789.         end
  1790.       when 7  # User
  1791.         battler.target.push(battler)
  1792.       end
  1793.     end
  1794.     # When the conduct side battler is the actor,
  1795.     if battler.is_a?(Game_Actor)
  1796.       # It diverges in the effective range
  1797.       case scope
  1798.       when 1  # Enemy single unit
  1799.         index = battler.current_action.target_index
  1800.         battler.target.push($game_troop.smooth_target_enemy(index))
  1801.       when 2  # Whole enemy
  1802.         for enemy in $game_troop.enemies
  1803.           if enemy.exist?
  1804.             battler.target.push(enemy)
  1805.           end
  1806.         end
  1807.       when 3  # Friend single unit
  1808.         index = battler.current_action.target_index
  1809.         battler.target.push($game_party.smooth_target_actor(index))
  1810.       when 4  # Whole friend
  1811.         for actor in $game_party.actors
  1812.           if actor.exist?
  1813.             battler.target.push(actor)
  1814.           end
  1815.         end
  1816.       when 5  # Friend single unit (HP 0)
  1817.         index = battler.current_action.target_index
  1818.         actor = $game_party.actors[index]
  1819.         if actor != nil and actor.hp0?
  1820.           battler.target.push(actor)
  1821.         end
  1822.       when 6  # Whole friend (HP 0)
  1823.         for actor in $game_party.actors
  1824.           if actor != nil and actor.hp0?
  1825.             battler.target.push(actor)
  1826.           end
  1827.         end
  1828.       when 7  # User
  1829.         battler.target.push(battler)
  1830.       end
  1831.     end
  1832.   end
  1833.   #--------------------------------------------------------------------------
  1834.   # * Skill action result compilation
  1835.   #--------------------------------------------------------------------------
  1836.   def make_skill_action_result(battler)
  1837.     # Acquiring skill
  1838.     @skill = $data_skills[battler.current_action.skill_id]
  1839.     # Verification whether or not it is cooperation skill,
  1840.     speller = synthe?(battler)
  1841.     # If it is not forced action
  1842.     unless battler.current_action.forcing
  1843.       # When with SP and so on is cut off and it becomes not be able to use
  1844.       if speller == nil
  1845.         unless battler.skill_can_use?(@skill.id)
  1846.           # It moves to step 6
  1847.           battler.phase = 6
  1848.          return
  1849.         end
  1850.       end
  1851.     end
  1852.     # SP consumption
  1853.     temp = false
  1854.     if speller != nil
  1855.       for spell in speller
  1856.         if spell.current_action.spell_id == 0
  1857.           spell.sp -= @skill.sp_cost
  1858.         else
  1859.           spell.sp -= $data_skills[spell.current_action.spell_id].sp_cost
  1860.         end
  1861.         # Refreshing the status window
  1862.         status_refresh(spell)
  1863.       end
  1864.     else
  1865.       battler.sp -= @skill.sp_cost
  1866.       # Refreshing the status window
  1867.       status_refresh(battler)
  1868.     end
  1869.     # Setting animation ID
  1870.     battler.anime1 = @skill.animation1_id
  1871.     battler.anime2 = @skill.animation2_id
  1872.     # Setting common event ID
  1873.     battler.event = @skill.common_event_id
  1874.     # Setting the object side battler
  1875.     set_target_battlers(@skill.scope, battler)
  1876.     # Applying the effect of skill
  1877.     for target in battler.target
  1878.       if speller != nil
  1879.         damage = 0
  1880.         d_result = false
  1881.         effective = false
  1882.         state_p = []
  1883.         state_m = []
  1884.         for spell in speller
  1885.           if spell.current_action.spell_id != 0
  1886.             @skill = $data_skills[spell.current_action.spell_id]
  1887.           end
  1888.           effective |= target.skill_effect(spell, @skill)
  1889.           if target.damage[spell].class != String
  1890.             d_result = true
  1891.             damage += target.damage[spell]
  1892.           elsif effective
  1893.             effect = target.damage[spell]
  1894.           end
  1895.           state_p += target.state_p[spell]
  1896.           state_m += target.state_m[spell]
  1897.           target.damage.delete(spell)
  1898.           target.state_p.delete(spell)
  1899.           target.state_m.delete(spell)
  1900.         end
  1901.         if d_result
  1902.           target.damage[battler] = damage
  1903.         elsif effective
  1904.           target.damage[battler] = effect
  1905.         else
  1906.           target.damage[battler] = 0
  1907.         end
  1908.         target.state_p[battler] = state_p
  1909.         target.state_m[battler] = state_m
  1910.       else
  1911.         target.skill_effect(battler, @skill)
  1912.       end
  1913.     end
  1914.   end
  1915.   #--------------------------------------------------------------------------
  1916.   # * Item action result compilation
  1917.   #--------------------------------------------------------------------------
  1918.   def make_item_action_result(battler)
  1919.     # Acquiring the item
  1920.     @item = $data_items[battler.current_action.item_id]
  1921.     # When with the item and so on is cut off and it becomes not be able to use
  1922.     unless $game_party.item_can_use?(@item.id)
  1923.       # It moves to step 6
  1924.       battler.phase = 6
  1925.       return
  1926.     end
  1927.     # In case of consumable
  1928.     if @item.consumable
  1929.       # The item which you use is decreased 1
  1930.       $game_party.lose_item(@item.id, 1)
  1931.     end
  1932.     # Setting animation ID
  1933.     battler.anime1 = @item.animation1_id
  1934.     battler.anime2 = @item.animation2_id
  1935.     # Setting common event ID
  1936.     battler.event = @item.common_event_id
  1937.     # Deciding the object
  1938.     index = battler.current_action.target_index
  1939.     target = $game_party.smooth_target_actor(index)
  1940.     # Setting the object side battler
  1941.     set_target_battlers(@item.scope, battler)
  1942.     # Applying the effect of the item
  1943.     for target in battler.target
  1944.       target.item_effect(@item, battler)
  1945.     end
  1946.   end
  1947.   #--------------------------------------------------------------------------
  1948.   # * Frame renewal (main phase step 3: Conduct side animation)
  1949.   #--------------------------------------------------------------------------
  1950.   def update_phase4_step3(battler)
  1951.     # Renewal of help window. It diverges with classification of action
  1952.     case battler.current_action.kind
  1953.     when 0  # Basis
  1954.       if battler.current_action.basic == 1
  1955.         @help_window.set_text($data_system.words.guard, 1)
  1956.         @help_wait = @help_time
  1957.       end
  1958.       if battler.current_action.basic == 2
  1959.         # Escape
  1960.         @help_window.set_text("Escape", 1)
  1961.         @help_wait = @help_time
  1962.         battler.escape
  1963.         battler.phase = 4
  1964.         return
  1965.       end
  1966.     when 1  # Skill
  1967.       skill =  $data_skills[battler.current_action.skill_id]
  1968.       @help_window.set_text(skill.name, 1)
  1969.       @help_wait = @help_time
  1970.     when 2  # Item
  1971.       item = $data_items[battler.current_action.item_id]
  1972.       @help_window.set_text(item.name, 1)
  1973.       @help_wait = @help_time
  1974.     end
  1975.     # When conduct side animation (ID 0 is, the white flash)
  1976.     if battler.anime1 == 0
  1977.       battler.white_flash = true
  1978.       battler.wait = 5
  1979.       # Camera setting
  1980.       if battler.target[0].is_a?(Game_Enemy)
  1981.         camera_set(battler)
  1982.       end
  1983.     else
  1984.       battler.animation.push([battler.anime1, true])
  1985.       speller = synthe?(battler)
  1986.       if speller != nil
  1987.         for spell in speller
  1988.           if spell != battler
  1989.             if spell.current_action.spell_id == 0
  1990.               spell.animation.push([battler.anime1, true])
  1991.             else
  1992.               skill = spell.current_action.spell_id
  1993.               spell.animation.push([$data_skills[skill].animation1_id, true])
  1994.               spell.current_action.spell_id = 0
  1995.             end
  1996.           end
  1997.         end
  1998.       end
  1999.       battler.wait = 2 * $data_animations[battler.anime1].frame_max - 10
  2000.     end
  2001.     # It moves to step 4
  2002.     battler.phase = 4
  2003.   end
  2004.   #--------------------------------------------------------------------------
  2005.   # * Frame renewal (main phase step 4: Object side animation)
  2006.   #--------------------------------------------------------------------------
  2007.   def update_phase4_step4(battler)
  2008.     # Camera setting
  2009.     if battler.target[0].is_a?(Game_Enemy) and battler.anime1 != 0
  2010.        camera_set(battler)
  2011.     end
  2012.     # Object side animation
  2013.     for target in battler.target
  2014.       target.animation.push([battler.anime2,
  2015.                                           (target.damage[battler] != "Miss")])
  2016.       unless battler.anime2 == 0
  2017.         battler.wait = 2 * $data_animations[battler.anime2].frame_max - 10
  2018.       end
  2019.     end
  2020.     # It moves to step 5
  2021.     battler.phase = 5
  2022.   end
  2023.   #--------------------------------------------------------------------------
  2024.   # * Frame renewal (main phase step 5: Damage indication)
  2025.   #--------------------------------------------------------------------------
  2026.   def update_phase4_step5(battler)
  2027.     # Damage indication
  2028.     for target in battler.target
  2029.       if target.damage[battler] != nil
  2030.         target.damage_pop[battler] = true
  2031.         target.damage_effect(battler, battler.current_action.kind)
  2032.         battler.wait = @damage_wait
  2033.         # Refreshing the status window
  2034.         status_refresh(target)
  2035.       end
  2036.     end
  2037.     # It moves to step 6
  2038.     battler.phase = 6
  2039.   end
  2040.   #--------------------------------------------------------------------------
  2041.   # * Frame renewal (main phase step 6: Refreshment)
  2042.   #--------------------------------------------------------------------------
  2043.   def update_phase4_step6(battler)
  2044.     # The camera is reset
  2045.     if battler.target[0].is_a?(Game_Enemy) and @camera == battler
  2046.       @spriteset.screen_target(0, 0, 1)
  2047.     end
  2048.     # Skill learning
  2049.     if battler.target[0].is_a?(Game_Actor) and battler.current_action.kind == 1
  2050.       for target in battler.target
  2051.         skill_learning(target, target.class_id,
  2052.                         battler.current_action.skill_id)
  2053.       end
  2054.     end
  2055.     # Clearing the battler of the action forced object
  2056.     if battler.current_action.forcing == true and
  2057.         battler.current_action.force_kind == 0 and
  2058.         battler.current_action.force_basic == 0 and
  2059.         battler.current_action.force_skill_id == 0
  2060.       $game_temp.forcing_battler = nil
  2061.       battler.current_action.forcing = false
  2062.     end
  2063.     refresh_phase(battler)
  2064.     speller = synthe?(battler)
  2065.     if speller != nil
  2066.       for spell in speller
  2067.         if spell != battler
  2068.           refresh_phase(spell)
  2069.         end
  2070.       end
  2071.       synthe_delete(speller)
  2072.     end
  2073.     # When common event ID is valid
  2074.     if battler.event > 0
  2075.       # Setting up the event
  2076.       common_event = $data_common_events[battler.event]
  2077.       $game_system.battle_interpreter.setup(common_event.list, 0)
  2078.     end
  2079.     act = 0
  2080.     for actor in $game_party.actors + $game_troop.enemies
  2081.       if actor.movable?
  2082.         act += 1
  2083.       end
  2084.     end
  2085.     if @turn_cnt >= act and act > 0
  2086.       @turn_cnt %= act
  2087.       $game_temp.battle_turn += 1
  2088.       # Searching the full page of the battle event
  2089.       for index in 0...$data_troops[@troop_id].pages.size
  2090.         # Acquiring the event page
  2091.         page = $data_troops[@troop_id].pages[index]
  2092.         # When the span of this page [ turn ] is
  2093.         if page.span == 1
  2094.           # Clearing the execution being completed flag
  2095.           $game_temp.battle_event_flags[index] = false
  2096.         end
  2097.       end
  2098.     end
  2099.     battler.phase = 1
  2100.     @action_battlers.delete(battler)
  2101.   end
  2102.   #--------------------------------------------------------------------------
  2103.   # * Refresh
  2104.   #--------------------------------------------------------------------------
  2105.   def refresh_phase(battler)
  2106.     battler.at -= @max
  2107.     if battler.movable?
  2108.       battler.atp = 100 * battler.at / @max
  2109.     end
  2110.     spell_reset(battler)
  2111.     # Slip damage
  2112.     if battler.hp > 0 and battler.slip_damage?
  2113.       battler.slip_damage_effect
  2114.       battler.damage_pop["slip"] = true
  2115.     end
  2116.     # State natural cancellation
  2117.     battler.remove_states_auto
  2118.     # Refreshing the status window
  2119.     status_refresh(battler, true)
  2120.     unless battler.movable?
  2121.       return
  2122.     end
  2123.     # Turn several counts
  2124.     @turn_cnt += 1
  2125.   end
  2126.   #--------------------------------------------------------------------------
  2127.   # * Battler action start
  2128.   #--------------------------------------------------------------------------
  2129.   def action_start(battler)
  2130.     battler.phase = 1
  2131.     battler.anime1 = 0
  2132.     battler.anime2 = 0
  2133.     battler.target = []
  2134.     battler.event = 0
  2135.     @action_battlers.unshift(battler)
  2136.   end
  2137.   #--------------------------------------------------------------------------
  2138.   # * Refreshing the status window
  2139.   #--------------------------------------------------------------------------
  2140.   def status_refresh(battler, at = false)
  2141.     if battler.is_a?(Game_Actor)
  2142.       for i in 0...$game_party.actors.size
  2143.         if battler == $game_party.actors[i]
  2144.           number = i + 1
  2145.         end
  2146.       end
  2147.       @status_window.refresh(number)
  2148.       if at == true
  2149.         @status_window.at_refresh(number)
  2150.       end
  2151.     end
  2152.   end
  2153.   #--------------------------------------------------------------------------
  2154.   # * Animation wait judgement processing
  2155.   #--------------------------------------------------------------------------
  2156.   def anime_wait_return
  2157.     if (@action_battlers.empty? or @anime_wait == false) and
  2158.         not $game_system.battle_interpreter.running?
  2159.       # When the enemy arrow is valid
  2160.       if @enemy_arrow != nil
  2161.         return [@active - 2, 0].min == 0
  2162.       # When the actor arrow is valid
  2163.       elsif @actor_arrow != nil
  2164.         return [@active - 2, 0].min == 0
  2165.       # When the skill window is valid
  2166.       elsif @skill_window != nil
  2167.         return [@active - 3, 0].min == 0
  2168.       # When the item window is valid
  2169.       elsif @item_window != nil
  2170.         return [@active - 3, 0].min == 0
  2171.       # When the actor command window is valid
  2172.       elsif @actor_command_window.active
  2173.         return [@active - 1, 0].min == 0
  2174.       else
  2175.         return true
  2176.       end
  2177.     else
  2178.       return false
  2179.     end
  2180.   end
  2181.   #--------------------------------------------------------------------------
  2182.   # * Actor command elimination judgement
  2183.   #--------------------------------------------------------------------------
  2184.   def command_delete
  2185.     # When the enemy arrow is valid
  2186.     if @enemy_arrow != nil
  2187.       end_enemy_select
  2188.     # When the actor is valid
  2189.     elsif @actor_arrow != nil
  2190.       end_actor_select
  2191.     end
  2192.     # When the skill window is valid
  2193.     if @skill_window != nil
  2194.       end_skill_select
  2195.     # When the item window is valid
  2196.     elsif @item_window != nil
  2197.       end_item_select
  2198.     end
  2199.     # When the actor command window is valid
  2200.     if @actor_command_window.active
  2201.       @command.shift
  2202.       @command_a = false
  2203.       # Setting the main phase flag
  2204.       $game_temp.battle_main_phase = true
  2205.       # Hides the actor command window when it is invalid
  2206.       @actor_command_window.active = false
  2207.       @actor_command_window.visible = false
  2208.       # Blinking effect OFF of actor
  2209.       if @active_actor != nil
  2210.         @active_actor.blink = false
  2211.       end
  2212.     end
  2213.   end
  2214.   #--------------------------------------------------------------------------
  2215.   # * Forcing action setting
  2216.   #--------------------------------------------------------------------------
  2217.   def force_action(battler)
  2218.     battler.current_action.kind = battler.current_action.force_kind
  2219.     battler.current_action.basic = battler.current_action.force_basic
  2220.     battler.current_action.skill_id = battler.current_action.force_skill_id
  2221.     battler.current_action.force_kind = 0
  2222.     battler.current_action.force_basic = 0
  2223.     battler.current_action.force_skill_id = 0
  2224.   end
  2225.   #--------------------------------------------------------------------------
  2226.   # * Camera set
  2227.   #--------------------------------------------------------------------------
  2228.   def camera_set(battler)
  2229.     @camera = battler
  2230.     if battler.target.size == 1
  2231.       if battler.current_action.kind == 0
  2232.         zoom = 1.2 / battler.target[0].zoom
  2233.       elsif synthe?(battler) == nil
  2234.         zoom = 1.5 / battler.target[0].zoom
  2235.       else
  2236.         zoom = 2.0 / battler.target[0].zoom
  2237.       end
  2238.       @spriteset.screen_target(battler.target[0].attack_x(zoom),
  2239.                                 battler.target[0].attack_y(zoom), zoom)
  2240.     else
  2241.       @spriteset.screen_target(0, 0, 0.75)
  2242.     end
  2243.   end
  2244.   #--------------------------------------------------------------------------
  2245.   # * Skill permanent residence time compilation
  2246.   #--------------------------------------------------------------------------
  2247.   def recite_time(battler)
  2248.   end
  2249.   #--------------------------------------------------------------------------
  2250.   # * Cooperation skill distinction
  2251.   #--------------------------------------------------------------------------
  2252.   def synthe_spell(battler)
  2253.   end
  2254.   #--------------------------------------------------------------------------
  2255.   # * Skill learning system
  2256.   #--------------------------------------------------------------------------
  2257.   def skill_learning(actor, class_id, skill_id)
  2258.   end
  2259.   #--------------------------------------------------------------------------
  2260.   # * Conduct possible decision
  2261.   #--------------------------------------------------------------------------
  2262.   def active?(battler)
  2263.     speller = synthe?(battler)
  2264.     if speller != nil
  2265.       if synthe_delete?(speller)
  2266.         return false
  2267.       end
  2268.     else
  2269.       unless battler.inputable?
  2270.         spell_reset(battler)
  2271.         unless battler.movable?
  2272.           battler.atp = 0
  2273.           return false
  2274.         end
  2275.       end
  2276.       if battler.current_action.forcing
  2277.         spell_reset(battler)
  2278.       end
  2279.     end
  2280.     return true
  2281.   end
  2282.   #--------------------------------------------------------------------------
  2283.   # * During synthesis skill residing permanently?
  2284.   #--------------------------------------------------------------------------
  2285.   def synthe?(battler)
  2286.     for speller in @synthe
  2287.       if speller.include?(battler)
  2288.         return speller
  2289.       end
  2290.     end
  2291.     return nil
  2292.   end
  2293.   #--------------------------------------------------------------------------
  2294.   # * Synthesis skill elimination judgement
  2295.   #--------------------------------------------------------------------------
  2296.   def synthe_delete?(speller)
  2297.     for battler in speller
  2298.       if not battler.inputable? and dead_ok?(battler)
  2299.         synthe_delete(speller)
  2300.         return true
  2301.       end
  2302.     end
  2303.     return false
  2304.   end
  2305.   #--------------------------------------------------------------------------
  2306.   # * Synthesis skill elimination
  2307.   #--------------------------------------------------------------------------
  2308.   def synthe_delete(speller)
  2309.     for battler in speller
  2310.       spell_reset(battler)
  2311.       if dead_ok?(battler)
  2312.         @action_battlers.delete(battler)
  2313.       end
  2314.     end
  2315.     @synthe.delete(speller)
  2316.   end
  2317.   #--------------------------------------------------------------------------
  2318.   # * Cooperation the skill permanent residence cancellation which is included
  2319.   #--------------------------------------------------------------------------
  2320.   def skill_reset(battler)
  2321.     speller = synthe?(battler)
  2322.     if speller != nil
  2323.       synthe_delete(speller)
  2324.     else
  2325.       spell_reset(battler)
  2326.     end
  2327.   end
  2328.   #--------------------------------------------------------------------------
  2329.   # * Skill permanent residence cancellation
  2330.   #--------------------------------------------------------------------------
  2331.   def spell_reset(battler)
  2332.     battler.rt = 0
  2333.     battler.rtp = 0
  2334.     battler.blink = false
  2335.     battler.spell = false
  2336.     battler.current_action.spell_id = 0
  2337.     @spell_p.delete(battler)
  2338.     @spell_e.delete(battler)
  2339.   end
  2340.   #--------------------------------------------------------------------------
  2341.   # * Battle end decision
  2342.   #--------------------------------------------------------------------------
  2343.   def fin?
  2344.    return (victory? or $game_party.all_dead? or $game_party.actors.size == 0)
  2345.   end
  2346.   #--------------------------------------------------------------------------
  2347.   # * Enemy total destruction decision
  2348.   #--------------------------------------------------------------------------
  2349.   def victory?
  2350.     for battler in $game_troop.enemies
  2351.       if not battler.hidden and (battler.rest_hp > 0 or
  2352.           battler.immortal or battler.damage_pop.size > 0)
  2353.         return false
  2354.       end
  2355.     end
  2356.     return true
  2357.   end
  2358.   #--------------------------------------------------------------------------
  2359.   # * Death permission decision
  2360.   #--------------------------------------------------------------------------
  2361.   def dead_ok?(battler)
  2362.     speller = synthe?(battler)
  2363.     if speller == nil
  2364.       if @action_battlers.include?(battler)
  2365.         if battler.phase > 2
  2366.           return false
  2367.         end
  2368.       end
  2369.     else
  2370.       for battler in speller
  2371.         if @action_battlers.include?(battler)
  2372.           if battler.phase > 2
  2373.             return false
  2374.           end
  2375.         end
  2376.       end
  2377.     end
  2378.     return true
  2379.   end
  2380. end
  2381.  
  2382. #==============================================================================
  2383. # ** Game_Actor
  2384. #------------------------------------------------------------------------------
  2385. #  It is the class which handles the actor. This class Game_Actors class
  2386. #  ($game_actors) is used in inside, Game_Party class ($game_party) from is
  2387. #  referred to.
  2388. #==============================================================================
  2389.  
  2390. class Game_Actor < Game_Battler
  2391.   #--------------------------------------------------------------------------
  2392.   # * Acquisition in battle picture X coordinate
  2393.   #--------------------------------------------------------------------------
  2394.   def screen_x
  2395.     # Calculating X coordinate from line order inside the party, it returns
  2396.     if self.index != nil
  2397.       return self.index * 160 + (4 - $game_party.actors.size) * 80 + 80
  2398.     else
  2399.       return 0
  2400.     end
  2401.   end
  2402. end
  2403.  
  2404. #==============================================================================
  2405. # ** Spriteset_Battle
  2406. #------------------------------------------------------------------------------
  2407. #  It is the class which collected the sprite of the battle picture. This class
  2408. #  is used inside Scene_Battle クラ ス.
  2409. #==============================================================================
  2410.  
  2411. class Spriteset_Battle
  2412.   #--------------------------------------------------------------------------
  2413.   # * Public Instance Variables
  2414.   #--------------------------------------------------------------------------
  2415.   attr_reader   :real_x                   # X coordinate revision (presently value)
  2416.   attr_reader   :real_y                   # Y coordinate revision (presently value)
  2417.   attr_reader   :real_zoom                # Enlargement ratio (presently value)
  2418.   #--------------------------------------------------------------------------
  2419.   # * Object initialization
  2420.   #--------------------------------------------------------------------------
  2421.   def initialize
  2422.     # Drawing up the viewport
  2423.     @viewport1 = Viewport.new(0, 0, 640, 480)
  2424.     @viewport2 = Viewport.new(0, 0, 640, 480)
  2425.     @viewport3 = Viewport.new(0, 0, 640, 480)
  2426.     @viewport4 = Viewport.new(0, 0, 640, 480)
  2427.     @viewport2.z = 101
  2428.     @viewport3.z = 200
  2429.     @viewport4.z = 5000
  2430.     @wait = 0
  2431.     @real_x = 0
  2432.     @real_y = 0
  2433.     @real_zoom = 1.0
  2434.     @target_x = 0
  2435.     @target_y = 0
  2436.     @target_zoom = 1.0
  2437.     @gap_x = 0
  2438.     @gap_y = 0
  2439.     @gap_zoom = 0.0
  2440.     # Make battleback sprite
  2441.     @battleback_sprite = Sprite.new(@viewport1)
  2442.     # Drawing up enemy sprite
  2443.     @enemy_sprites = []
  2444.     for enemy in $game_troop.enemies.reverse
  2445.       @enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
  2446.     end
  2447.     # Drawing up actor sprite
  2448.     @actor_sprites = []
  2449.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
  2450.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
  2451.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
  2452.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
  2453.     # Drawing up the weather
  2454.     @weather = RPG::Weather.new(@viewport1)
  2455.     # Drawing up picture sprite
  2456.     @picture_sprites = []
  2457.     for i in 51..100
  2458.       @picture_sprites.push(Sprite_Picture.new(@viewport3,
  2459.         $game_screen.pictures[i]))
  2460.     end
  2461.     # Drawing up timer sprite
  2462.     @timer_sprite = Sprite_Timer.new
  2463.     # Frame renewal
  2464.     update
  2465.   end
  2466.   #--------------------------------------------------------------------------
  2467.   # * Frame renewal
  2468.   #--------------------------------------------------------------------------
  2469.   def update
  2470.     # Contents of actor sprite renewal (in replacement of actor correspondence)
  2471.     @actor_sprites[0].battler = $game_party.actors[0]
  2472.     @actor_sprites[1].battler = $game_party.actors[1]
  2473.     @actor_sprites[2].battler = $game_party.actors[2]
  2474.     @actor_sprites[3].battler = $game_party.actors[3]
  2475.     # When file name of the battle back is different from present ones,
  2476.     if @battleback_name != $game_temp.battleback_name
  2477.       make_battleback
  2478.     end
  2479.     # Scroll of picture
  2480.     screen_scroll
  2481.     # Position revision of monster
  2482.     for enemy in $game_troop.enemies
  2483.       enemy.real_x = @real_x
  2484.       enemy.real_y = @real_y
  2485.       enemy.real_zoom = @real_zoom
  2486.     end
  2487.     # Renewing battler sprite
  2488.     for sprite in @enemy_sprites + @actor_sprites
  2489.       sprite.update
  2490.     end
  2491.     # Renewing weather graphics
  2492.     @weather.type = $game_screen.weather_type
  2493.     @weather.max = $game_screen.weather_max
  2494.     @weather.update
  2495.     # Renewing picture sprite
  2496.     for sprite in @picture_sprites
  2497.       sprite.update
  2498.     end
  2499.     # Renewing timer sprite
  2500.     @timer_sprite.update
  2501.     # Setting the color tone and shake position of the picture
  2502.     @viewport1.tone = $game_screen.tone
  2503.     @viewport1.ox = $game_screen.shake
  2504.     # Setting the flash color of the picture
  2505.     @viewport4.color = $game_screen.flash_color
  2506.     # Renewing the viewport
  2507.     @viewport1.update
  2508.     @viewport2.update
  2509.     @viewport4.update
  2510.   end
  2511.   #--------------------------------------------------------------------------
  2512.   # * Setting of battle background
  2513.   #--------------------------------------------------------------------------
  2514.   def make_battleback
  2515.     @battleback_name = $game_temp.battleback_name
  2516.     if @battleback_sprite.bitmap != nil
  2517.       @battleback_sprite.bitmap.dispose
  2518.     end
  2519.     @battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
  2520.     if @battleback_sprite.bitmap.width == 640 and
  2521.        @battleback_sprite.bitmap.height == 320
  2522.       @battleback_sprite.src_rect.set(0, 0, 1280, 640)
  2523.       @base_zoom = 2.0
  2524.       @battleback_sprite.zoom_x = @base_zoom
  2525.       @battleback_sprite.zoom_y = @base_zoom
  2526.       @real_y = 4
  2527.       @battleback_sprite.x = 320
  2528.       @battleback_sprite.y = @real_y
  2529.       @battleback_sprite.ox = @battleback_sprite.bitmap.width / 2
  2530.       @battleback_sprite.oy = @battleback_sprite.bitmap.height / 4
  2531.     elsif @battleback_sprite.bitmap.width == 640 and
  2532.           @battleback_sprite.bitmap.height == 480
  2533.       @battleback_sprite.src_rect.set(0, 0, 960, 720)
  2534.       @base_zoom = 1.5
  2535.       @battleback_sprite.zoom_x = @base_zoom
  2536.       @battleback_sprite.zoom_y = @base_zoom
  2537.       @battleback_sprite.x = 320
  2538.       @battleback_sprite.y = 0
  2539.       @battleback_sprite.ox = @battleback_sprite.bitmap.width / 2
  2540.       @battleback_sprite.oy = @battleback_sprite.bitmap.height / 4
  2541.     else
  2542.       @battleback_sprite.src_rect.set(0, 0, @battleback_sprite.bitmap.width,
  2543.                                       @battleback_sprite.bitmap.height)
  2544.       @base_zoom = 1.0
  2545.       @battleback_sprite.zoom_x = @base_zoom
  2546.       @battleback_sprite.zoom_y = @base_zoom
  2547.       @battleback_sprite.x = 320
  2548.       @battleback_sprite.y = 0
  2549.       @battleback_sprite.ox = @battleback_sprite.bitmap.width / 2
  2550.       @battleback_sprite.oy = @battleback_sprite.bitmap.height / 4
  2551.     end
  2552.   end
  2553.   #--------------------------------------------------------------------------
  2554.   # * Position enlargement ratio setting of scroll goal of picture
  2555.   #--------------------------------------------------------------------------
  2556.   def screen_target(x, y, zoom)
  2557.     return unless $scene.drive
  2558.     @wait = $scene.scroll_time
  2559.     @target_x = x
  2560.     @target_y = y
  2561.     @target_zoom = zoom
  2562.     screen_over
  2563.     @gap_x = @target_x - @real_x
  2564.     @gap_y = @target_y - @real_y
  2565.     @gap_zoom = @target_zoom - @real_zoom
  2566.   end
  2567.   #--------------------------------------------------------------------------
  2568.   # * Scroll of picture
  2569.   #--------------------------------------------------------------------------
  2570.   def screen_scroll
  2571.     if @wait > 0
  2572.       @real_x = @target_x - @gap_x * (@wait ** 2) / ($scene.scroll_time ** 2)
  2573.       @real_y = @target_y - @gap_y * (@wait ** 2) / ($scene.scroll_time ** 2)
  2574.       @real_zoom = @target_zoom -
  2575.                     @gap_zoom * (@wait ** 2) / ($scene.scroll_time ** 2)
  2576.       @battleback_sprite.x = 320 + @real_x
  2577.       @battleback_sprite.y = @real_y
  2578.       @battleback_sprite.zoom_x = @base_zoom * @real_zoom
  2579.       @battleback_sprite.zoom_y = @base_zoom * @real_zoom
  2580.       @battleback_sprite.ox = @battleback_sprite.bitmap.width / 2
  2581.       @battleback_sprite.oy = @battleback_sprite.bitmap.height / 4
  2582.       @wait -= 1
  2583.     end
  2584.   end
  2585.   #--------------------------------------------------------------------------
  2586.   # * When the screen goes outside the picture, revision processing
  2587.   #--------------------------------------------------------------------------
  2588.   def screen_over
  2589.     width = @battleback_sprite.bitmap.width * @base_zoom * @target_zoom / 2
  2590.     unless 324 + @target_x > width and 324 - @target_x > width
  2591.       if 324 + @target_x > width
  2592.         @target_x = width - 324
  2593.       elsif 324 - @target_x > width
  2594.         @target_x = 324 - width
  2595.       end
  2596.     end
  2597.     height = @battleback_sprite.bitmap.height * @base_zoom * @target_zoom / 4
  2598.     unless @target_y > height - 4 and 484 - @target_y > 3 * height
  2599.       if @target_y > height - 4
  2600.         @target_y = height - 4
  2601.       elsif 484 - @target_y > 3 * height
  2602.         @target_y = 484 - 3 * height
  2603.       end
  2604.     end
  2605.   end
  2606. end
  2607.  
  2608. #==============================================================================
  2609. # ** Game_Battler (Part 1)
  2610. #------------------------------------------------------------------------------
  2611. #  It is the class which handles the battler. This class is used as superclass
  2612. #  of Game_Actor class and Game_Enemy クラ ス.
  2613. #==============================================================================
  2614.  
  2615. class Game_Battler
  2616.   #--------------------------------------------------------------------------
  2617.   # * Release instance variable addition
  2618.   #--------------------------------------------------------------------------
  2619.   attr_accessor :up_level                  # The frequency of levelling up
  2620.   attr_accessor :at                        # AT (time gauge)
  2621.   attr_accessor :atp                       # AT (for indication)
  2622.   attr_accessor :rt                        # RP (permanent residence gauge)
  2623.   attr_accessor :rtp                       # RP (permanent residence necessary quantity)
  2624.   attr_accessor :spell                     # In the midst of synthesis skill motion
  2625.   attr_accessor :recover_hp                # HP recovery quantity
  2626.   attr_accessor :recover_sp                # SP recovery quantity
  2627.   attr_accessor :state_p                   # Status abnormal arrangement
  2628.   attr_accessor :state_m                   # Status abnormal arrangement
  2629.   attr_accessor :damage_sp                 # SP damage indicatory flag
  2630.   attr_accessor :animation                 # Arrangement of animation ID and Hit
  2631.   attr_accessor :phase
  2632.   attr_accessor :wait
  2633.   attr_accessor :target
  2634.   attr_accessor :anime1
  2635.   attr_accessor :anime2
  2636.   attr_accessor :event
  2637.   #--------------------------------------------------------------------------
  2638.   # * Object initialization
  2639.   #--------------------------------------------------------------------------
  2640.   alias :initialize_rtab :initialize
  2641.   def initialize
  2642.     initialize_rtab
  2643.     @damage_pop = {}
  2644.     @damage = {}
  2645.     @damage_sp = {}
  2646.     @critical = {}
  2647.     @recover_hp = {}
  2648.     @recover_sp = {}
  2649.     @state_p = {}
  2650.     @state_m = {}
  2651.     @animation = []
  2652.     @phase = 1
  2653.     @wait = 0
  2654.     @target = []
  2655.     @anime1 = 0
  2656.     @anime2 = 0
  2657.     @event = 0
  2658.   end
  2659.   #--------------------------------------------------------------------------
  2660.   # * Existence decision
  2661.   #--------------------------------------------------------------------------
  2662.   def exist?
  2663.     return (not @hidden and (@hp > 0 or @immortal or @damage.size > 0))
  2664.   end
  2665.   #--------------------------------------------------------------------------
  2666.   # * Remaining HP estimate
  2667.   #--------------------------------------------------------------------------
  2668.   def rest_hp
  2669.     # Substituting reality HP to rest_hp
  2670.     rest_hp = @hp
  2671.     # All damage which the battler receives is made to reflect on rest_hp
  2672.     for pre_damage in @damage
  2673.       if pre_damage[1].is_a?(Numeric)
  2674.         rest_hp -= pre_damage[1]
  2675.       end
  2676.     end
  2677.     return rest_hp
  2678.   end
  2679.   #--------------------------------------------------------------------------
  2680.   # * Cancellation of state
  2681.   #     state_id : State ID
  2682.   #     force    : Forced cancellation flag (with processing of automatic state use)
  2683.   #--------------------------------------------------------------------------
  2684.   def remove_state(state_id, force = false)
  2685.     # When this state is added,
  2686.     if state?(state_id)
  2687.       # When with the state which it is forced is added, at the same time cancellation is not forcing
  2688.       if @states_turn[state_id] == -1 and not force
  2689.         # Method end
  2690.         return
  2691.       end
  2692.       # When present HP 0 and option [ the state of HP 0 you regard ] it is valid
  2693.       if @hp == 0 and $data_states[state_id].zero_hp
  2694.         # Whether or not [ you regard the state of HP 0 ] there is a state in other things, decision
  2695.         zero_hp = false
  2696.         for i in @states
  2697.           if i != state_id and $data_states[i].zero_hp
  2698.             zero_hp = true
  2699.           end
  2700.         end
  2701.         # If you are possible to cancel aggressive failure, HP in 1 modification
  2702.         if zero_hp == false
  2703.           @hp = 1
  2704.         end
  2705.       end
  2706.       unless self.movable?
  2707.         # Deleting state ID from @states arrangement and @states_turn hash
  2708.         @states.delete(state_id)
  2709.         @states_turn.delete(state_id)
  2710.         if self.movable?
  2711.           self.at = 0
  2712.         end
  2713.       else
  2714.         # Deleting state ID from @states arrangement and @states_turn hash
  2715.         @states.delete(state_id)
  2716.         @states_turn.delete(state_id)
  2717.       end
  2718.     end
  2719.     # The maximum check of HP and SP
  2720.     @hp = [@hp, self.maxhp].min
  2721.     @sp = [@sp, self.maxsp].min
  2722.   end
  2723.   #--------------------------------------------------------------------------
  2724.   # * Effective application of normality attack
  2725.   #     attacker : Attack person (battler)
  2726.   #--------------------------------------------------------------------------
  2727.   def attack_effect(attacker)
  2728.     # Clearing the critical flag
  2729.     self.critical[attacker] = false
  2730.     state_p[attacker] = []
  2731.     state_m[attacker] = []
  2732.     # First on-target hit decision
  2733.     hit_result = (rand(100) < attacker.hit)
  2734.     # In case of on-target hit
  2735.     hit_result = true
  2736.     if hit_result == true
  2737.       # Calculating the basic damage
  2738.       atk = [attacker.atk - self.pdef / 2, 0].max
  2739.       self.damage[attacker] = atk * (attacker.str / 5)
  2740.       # Attribute correction
  2741.       self.damage[attacker] *= elements_correct(attacker.element_set)
  2742.       self.damage[attacker] /= 100
  2743.       self.damage[attacker] = (self.damage[attacker]).ceil
  2744.       # When the mark of the damage is correct,
  2745.       if self.damage[attacker] > 0
  2746.         # Critical correction
  2747.         if rand(100) < 4 * attacker.dex / self.agi
  2748.           self.damage[attacker] *= 3
  2749.           self.critical[attacker] = true
  2750.         end
  2751.         # Defense correction
  2752.         if self.guarding?
  2753.           self.damage[attacker] /= 4
  2754.         end
  2755.       end
  2756.       # Dispersion
  2757.       if self.damage[attacker].abs > 0
  2758.         amp = [self.damage[attacker].abs * 10 / 100, 1].max
  2759.         self.damage[attacker] += rand(amp+1) + rand(amp+1) - amp
  2760.       end
  2761.       # Second on-target hit decision
  2762.       eva = 8 * self.agi / attacker.dex + self.eva
  2763.       hit = self.damage[attacker] < 0 ? 100 : 100 - eva
  2764.       hit = self.cant_evade? ? 100 : hit
  2765.       hit_result = (rand(100) < hit)
  2766.     end
  2767.     # In case of on-target hit
  2768.     if hit_result == true
  2769.       # State shocking cancellation
  2770.       remove_states_shock
  2771.       # From HP damage subtraction
  2772.       # State change
  2773.       @state_changed = false
  2774.       states_plus(attacker, attacker.plus_state_set)
  2775.       states_minus(attacker, attacker.minus_state_set)
  2776.     # In case of miss
  2777.     else
  2778.       # Setting "Miss" to the damage
  2779.       self.damage[attacker] = "Miss"
  2780.       # Clearing the critical flag
  2781.       self.critical[attacker] = false
  2782.     end
  2783.     # Method end
  2784.     return true
  2785.   end
  2786.   #--------------------------------------------------------------------------
  2787.   # * Effective application of skill
  2788.   #     user  : User of skill (battler)
  2789.   #     skill : Skill
  2790.   #--------------------------------------------------------------------------
  2791.   def skill_effect(user, skill)
  2792.     # Clearing the critical flag
  2793.     self.critical[user] = false
  2794.     state_p[user] = []
  2795.     state_m[user] = []
  2796.     # Effective range of skill with friend of HP 1 or more, your own HP 0,
  2797.     # Or when the effective range of skill with the friend of HP 0, your own HP are 1 or more
  2798.     if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
  2799.        ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
  2800.       # Method end
  2801.       return false
  2802.     end
  2803.     # Clearing the effective flag
  2804.     effective = false
  2805.     # When common event ID is valid setting the effective flag
  2806.     effective |= skill.common_event_id > 0
  2807.     # First on-target hit decision
  2808.     hit = skill.hit
  2809.     if skill.atk_f > 0
  2810.       hit *= user.hit / 100
  2811.     end
  2812.     hit_result = (rand(100) < hit)
  2813.     # In case of uncertain skill setting the effective flag
  2814.     effective |= hit < 100
  2815.     # In case of on-target hit
  2816.     if hit_result == true
  2817.       # Calculating power
  2818.       power = skill.power + user.atk * skill.atk_f / 100
  2819.       if power > 0
  2820.         power -= self.pdef * skill.pdef_f / 200
  2821.         power -= self.mdef * skill.mdef_f / 200
  2822.         power = [power, 0].max
  2823.       end
  2824.       # Calculating magnification ratio
  2825.       rate = 20
  2826.       rate += (user.str * skill.str_f / 100)
  2827.       rate += (user.dex * skill.dex_f / 100)
  2828.       rate += (user.agi * skill.agi_f / 100)
  2829.       rate += (user.int * skill.int_f / 100)
  2830.       # Calculating the basic damage
  2831.       self.damage[user] = power * rate / 20
  2832.       # Attribute correction
  2833.       self.damage[user] *= elements_correct(skill.element_set)
  2834.       self.damage[user] /= 100
  2835.       # When the mark of the damage is correct
  2836.       if self.damage[user] > 0
  2837.         # Defense correction
  2838.         if self.guarding?
  2839.           self.damage[user] /= 2
  2840.         end
  2841.       end
  2842.       # Dispersion
  2843.       if skill.variance > 0 and self.damage[user].abs > 0
  2844.         amp = [self.damage[user].abs * skill.variance / 100, 1].max
  2845.         self.damage[user] += rand(amp+1) + rand(amp+1) - amp
  2846.       end
  2847.       # Second on-target hit decision
  2848.       eva = 8 * self.agi / user.dex + self.eva
  2849.       hit = self.damage[user] < 0 ? 100 : 100 - eva * skill.eva_f / 100
  2850.       hit = self.cant_evade? ? 100 : hit
  2851.       hit_result = (rand(100) < hit)
  2852.       # In case of uncertain skill setting the effective flag
  2853.       effective |= hit < 100
  2854.     end
  2855.     # In case of on-target hit
  2856.     if hit_result == true
  2857.       # In case of physical attack other than power 0
  2858.       if skill.power != 0 and skill.atk_f > 0
  2859.         # State shocking cancellation
  2860.         remove_states_shock
  2861.         # Setting the effective flag
  2862.         effective = true
  2863.       end
  2864.       # The fluctuation decision of HP
  2865.       last_hp = [[self.hp - self.damage[user], self.maxhp].min, 0].max      # Effective decision
  2866.       effective |= self.hp != last_hp
  2867.       # State change
  2868.       @state_changed = false
  2869.       effective |= states_plus(user, skill.plus_state_set)
  2870.       effective |= states_minus(user, skill.minus_state_set)
  2871.       unless $game_temp.in_battle
  2872.         self.damage_effect(user, 1)
  2873.       end
  2874.       # When power 0 is,
  2875.       if skill.power == 0
  2876.         # Setting the null line to the damage
  2877.         self.damage[user] = ""
  2878.         # When there is no change in the state,
  2879.         unless @state_changed
  2880.           # Setting "Miss" to the damage
  2881.           self.damage[user] = "Miss"
  2882.         end
  2883.       end
  2884.     # In case of miss
  2885.     else
  2886.       # Setting "Miss" to the damage
  2887.       self.damage[user] = "Miss"
  2888.     end
  2889.     # When it is not in the midst of fighting,
  2890.     unless $game_temp.in_battle
  2891.       # Setting nil to the damage
  2892.       self.damage[user] = nil
  2893.     end
  2894.     # Method end
  2895.     return effective
  2896.   end
  2897.   #--------------------------------------------------------------------------
  2898.   # * Effective application of item
  2899.   #     item : Item
  2900.   #--------------------------------------------------------------------------
  2901.   def item_effect(item, user = $game_party.actors[0])
  2902.     # Clearing the critical flag
  2903.     self.critical[user] = false
  2904.     state_p[user] = []
  2905.     state_m[user] = []
  2906.     self.recover_hp[user] = 0
  2907.     self.recover_sp[user] = 0
  2908.     # Effective range of item with friend of HP 1 or more, your own HP 0,
  2909.     # Or when the effective range of the item with the friend of HP 0, your own HP are 1 or more,
  2910.     if ((item.scope == 3 or item.scope == 4) and self.hp == 0) or
  2911.        ((item.scope == 5 or item.scope == 6) and self.hp >= 1)
  2912.       # Method end
  2913.       return false
  2914.     end
  2915.     # Clearing the effective flag
  2916.     effective = false
  2917.     # When common event ID is valid setting the effective flag
  2918.     effective |= item.common_event_id > 0
  2919.     # On-target hit decision
  2920.     hit_result = (rand(100) < item.hit)
  2921.     # In case of uncertain skill setting the effective flag
  2922.     effective |= item.hit < 100
  2923.     # In case of on-target hit
  2924.     if hit_result == true
  2925.       # Calculating the recovery quantity
  2926.       self.recover_hp[user] = maxhp * item.recover_hp_rate / 100 +
  2927.                               item.recover_hp
  2928.       self.recover_sp[user] = maxsp * item.recover_sp_rate / 100 +
  2929.                               item.recover_sp
  2930.       if self.recover_hp[user] < 0
  2931.         self.recover_hp[user] += self.pdef * item.pdef_f / 20
  2932.         self.recover_hp[user] += self.mdef * item.mdef_f / 20
  2933.         self.recover_hp[user] = [self.recover_hp[user], 0].min
  2934.       end
  2935.       # Attribute correction
  2936.       self.recover_hp[user] *= elements_correct(item.element_set)
  2937.       self.recover_hp[user] /= 100
  2938.       self.recover_sp[user] *= elements_correct(item.element_set)
  2939.       self.recover_sp[user] /= 100
  2940.       # Dispersion
  2941.       if item.variance > 0 and self.recover_hp[user].abs > 0
  2942.         amp = [self.recover_hp[user].abs * item.variance / 100, 1].max
  2943.         self.recover_hp[user] += rand(amp+1) + rand(amp+1) - amp
  2944.       end
  2945.       if item.variance > 0 and self.recover_sp[user].abs > 0
  2946.         amp = [self.recover_sp[user].abs * item.variance / 100, 1].max
  2947.         self.recover_sp[user] += rand(amp+1) + rand(amp+1) - amp
  2948.       end
  2949.       # When the mark of the recovery quantity is negative number
  2950.       if self.recover_hp[user] < 0
  2951.         # Defense correction
  2952.         if self.guarding?
  2953.           self.recover_hp[user] /= 2
  2954.         end
  2955.       end
  2956.       # The mark of the HP recovery quantity it reverses, sets to the value of the damage
  2957.       self.damage[user] = -self.recover_hp[user]
  2958.       # The fluctuation decision of HP and SP
  2959.       last_hp = [[self.hp + self.recover_hp[user], self.maxhp].min, 0].max
  2960.       last_sp = [[self.sp + self.recover_sp[user], self.maxsp].min, 0].max
  2961.       effective |= self.hp != last_hp
  2962.       effective |= self.sp != last_sp
  2963.       # State change
  2964.       @state_changed = false
  2965.       effective |= states_plus(user, item.plus_state_set)
  2966.       effective |= states_minus(user, item.minus_state_set)
  2967.       unless $game_temp.in_battle
  2968.         self.damage_effect(user, 2)
  2969.       end
  2970.       # When parameter rise value is valid
  2971.       if item.parameter_type > 0 and item.parameter_points != 0
  2972.         # It diverges with parameter
  2973.         case item.parameter_type
  2974.         when 1  # MaxHP
  2975.           @maxhp_plus += item.parameter_points
  2976.         when 2  # MaxSP
  2977.           @maxsp_plus += item.parameter_points
  2978.         when 3  #Strength
  2979.           @str_plus += item.parameter_points
  2980.         when 4  # Dexterity
  2981.           @dex_plus += item.parameter_points
  2982.         when 5  # Agility
  2983.           @agi_plus += item.parameter_points
  2984.         when 6  # Intelligence
  2985.           @int_plus += item.parameter_points
  2986.         end
  2987.         # Setting the effective flag
  2988.         effective = true
  2989.       end
  2990.       # When HP recovery factor and the recovery quantity 0 is
  2991.       if item.recover_hp_rate == 0 and item.recover_hp == 0
  2992.         # Setting the null line to the damage
  2993.         self.damage[user] = ""
  2994.         # When SP recovery factor and the recovery quantity 0, parameter rise value is invalid,
  2995.         if item.recover_sp_rate == 0 and item.recover_sp == 0 and
  2996.            (item.parameter_type == 0 or item.parameter_points == 0)
  2997.           # When there is no change in the state,
  2998.           unless @state_changed
  2999.             # Setting "Miss" to the damage
  3000.             self.damage[user] = "Miss"
  3001.           end
  3002.         end
  3003.       end
  3004.     # In case of miss
  3005.     else
  3006.       # Setting "Miss" to the damage
  3007.       self.damage[user] = "Miss"
  3008.     end
  3009.     # When it is not in the midst of fighting,
  3010.     unless $game_temp.in_battle
  3011.       # Setting nil to the damage
  3012.       self.damage[user] = nil
  3013.     end
  3014.     # Method end
  3015.     return effective
  3016.   end
  3017.   #--------------------------------------------------------------------------
  3018.   # * State change (+) application
  3019.   #     plus_state_set  : State change (+)
  3020.   #--------------------------------------------------------------------------
  3021.   def states_plus(battler, plus_state_set)
  3022.     # Clearing the effective flag
  3023.     effective = false
  3024.     # The loop (the state which is added)
  3025.     for i in plus_state_set
  3026.       # When this state is not defended,
  3027.       unless self.state_guard?(i)
  3028.         # If this state is not full, setting the effective flag
  3029.         effective |= self.state_full?(i) == false
  3030.         # When the state [ it does not resist ] is,
  3031.         if $data_states[i].nonresistance
  3032.           # Setting the state change flag
  3033.           @state_changed = true
  3034.           # Adding the state
  3035.           self.state_p[battler].push(i)
  3036.         # When this state is not full,
  3037.         elsif self.state_full?(i) == false
  3038.           # It converts degree of state validity to probability, compares with random number
  3039.           if rand(100) < [0,100,80,60,40,20,0][self.state_ranks[i]]
  3040.             # Setting the state change flag
  3041.             @state_changed = true
  3042.             # Adding the state
  3043.             self.state_p[battler].push(i)
  3044.           end
  3045.         end
  3046.       end
  3047.     end
  3048.     # Method end
  3049.     return effective
  3050.   end
  3051.   #--------------------------------------------------------------------------
  3052.   # * State change (-) application
  3053.   #     minus_state_set : State change (-)
  3054.   #--------------------------------------------------------------------------
  3055.   def states_minus(battler, minus_state_set)
  3056.     # Clearing the effective flag
  3057.     effective = false
  3058.     # The loop (the state which is cancelled)
  3059.     for i in minus_state_set
  3060.       # If this state is added, setting the effective flag
  3061.       effective |= self.state?(i)
  3062.       # Setting the state change flag
  3063.       @state_changed = true
  3064.       # Cancelling the state
  3065.       self.state_m[battler].push(i)
  3066.     end
  3067.     # Method end
  3068.     return effective
  3069.   end
  3070.   #--------------------------------------------------------------------------
  3071.   # * Damage operation
  3072.   #--------------------------------------------------------------------------
  3073.   def damage_effect(battler, item)
  3074.     if item == 2
  3075.       self.hp += self.recover_hp[battler]
  3076.       self.sp += self.recover_sp[battler]
  3077.       if self.recover_sp[battler] != 0
  3078.         self.damage_sp[battler] = -self.recover_sp[battler]
  3079.       end
  3080.       self.recover_hp.delete(battler)
  3081.       self.recover_sp.delete(battler)
  3082.     else
  3083.       if self.damage[battler].class != String
  3084.         self.hp -= self.damage[battler]
  3085.       end
  3086.     end
  3087.     for i in self.state_p[battler]
  3088.       add_state(i)
  3089.     end
  3090.     for i in self.state_m[battler]
  3091.       remove_state(i)
  3092.     end
  3093.   end
  3094.   #--------------------------------------------------------------------------
  3095.   # * Effective application of slip damage
  3096.   #--------------------------------------------------------------------------
  3097.   def slip_damage_effect
  3098.     # Setting the damage
  3099.     self.damage["slip"] = self.maxhp / 10
  3100.     # Dispersion
  3101.     if self.damage["slip"].abs > 0
  3102.       amp = [self.damage["slip"].abs * 15 / 100, 1].max
  3103.       self.damage["slip"] += rand(amp+1) + rand(amp+1) - amp
  3104.     end
  3105.     # From HP damage subtraction
  3106.     self.hp -= self.damage["slip"]
  3107.     # Method end
  3108.     return true
  3109.   end
  3110. end
  3111.  
  3112. #==============================================================================
  3113. # ** Game_BattleAction
  3114. #------------------------------------------------------------------------------
  3115. #  Action (the conduct which is in the midst of fighting) it is the class which
  3116. #  is handled. This class is used inside Game_Battler クラ ス.
  3117. #==============================================================================
  3118.  
  3119. class Game_BattleAction
  3120.   #--------------------------------------------------------------------------
  3121.   # * Public Instance Variables
  3122.   #--------------------------------------------------------------------------
  3123.   attr_accessor :spell_id                 # Skill ID for union magic
  3124.   attr_accessor :force_kind               # Classification (basis/skill/item)
  3125.   attr_accessor :force_basic              # basis (attack/defend/escape)
  3126.   attr_accessor :force_skill_id           # Skill ID
  3127.   #--------------------------------------------------------------------------
  3128.   # * Validity decision
  3129.   #--------------------------------------------------------------------------
  3130.   def valid?
  3131.     return (not (@force_kind == 0 and @force_basic == 3))
  3132.   end
  3133. end
  3134.  
  3135. #==============================================================================
  3136. # ** Game_Actor
  3137. #------------------------------------------------------------------------------
  3138. #  It is the class which handles the actor. This class Game_Actors class
  3139. #  ($game_actors) is used in inside, Game_Party class ($game_party) from is
  3140. #  referred to.
  3141. #==============================================================================
  3142.  
  3143. class Game_Actor < Game_Battler
  3144.   def skill_can_use?(skill_id)
  3145.     return super
  3146.   end
  3147. end
  3148.  
  3149. #==============================================================================
  3150. # ** Game_Enemy
  3151. #------------------------------------------------------------------------------
  3152. #  It is the class which handles the enemy. This class Game_Troop class
  3153. #  ($game_troop) is used in inside.
  3154. #==============================================================================
  3155.  
  3156. class Game_Enemy < Game_Battler
  3157.   #--------------------------------------------------------------------------
  3158.   # * Public Instance Variables
  3159.   #--------------------------------------------------------------------------
  3160.   attr_accessor :height                  # Height of picture
  3161.   attr_accessor :real_x                  # X-coordinate revision
  3162.   attr_accessor :real_y                  # Y-coordinate revision
  3163.   attr_accessor :real_zoom               # Enlargement ratio
  3164.   #--------------------------------------------------------------------------
  3165.   # * Object initialization
  3166.   #     troop_id     :Troop ID
  3167.   #     member_index : Index of troop member
  3168.   #--------------------------------------------------------------------------
  3169.   def initialize(troop_id, member_index)
  3170.     super()
  3171.     @troop_id = troop_id
  3172.     @member_index = member_index
  3173.     troop = $data_troops[@troop_id]
  3174.     @enemy_id = troop.members[@member_index].enemy_id
  3175.     enemy = $data_enemies[@enemy_id]
  3176.     @battler_name = enemy.battler_name
  3177.     @battler_hue = enemy.battler_hue
  3178.     @hp = maxhp
  3179.     @sp = maxsp
  3180.     @real_x = 0
  3181.     @real_y = 0
  3182.     @real_zoom = 1.0
  3183.     @fly = 0
  3184.     enemy.name.sub(/\\[Ff]\[([0-9]+)\]/) {@fly = $1.to_i}
  3185.     @hidden = troop.members[@member_index].hidden
  3186.     @immortal = troop.members[@member_index].immortal
  3187.   end
  3188.   alias :true_x :screen_x
  3189.   alias :true_y :screen_y
  3190.   #--------------------------------------------------------------------------
  3191.   # * Acquisition in battle picture X coordinate
  3192.   #--------------------------------------------------------------------------
  3193.   def screen_x
  3194.     return 320 + (true_x - 320) * @real_zoom + @real_x
  3195.   end
  3196.   #--------------------------------------------------------------------------
  3197.   # * Acquisition in battle picture Y coordinate
  3198.   #--------------------------------------------------------------------------
  3199.   def screen_y
  3200.     return true_y * @real_zoom + @real_y
  3201.   end
  3202.   #--------------------------------------------------------------------------
  3203.   # * Acquisition in battle picture Z coordinate
  3204.   #--------------------------------------------------------------------------
  3205.   def screen_z
  3206.     return true_y + @fly
  3207.   end
  3208.   #--------------------------------------------------------------------------
  3209.   # * Acquisition of battle picture enlargement ratio
  3210.   #--------------------------------------------------------------------------
  3211.   def zoom
  3212.     return ($scene.zoom_rate[1] - $scene.zoom_rate[0]) *
  3213.                           (true_y + @fly) / 320 + $scene.zoom_rate[0]
  3214.   end
  3215.   #--------------------------------------------------------------------------
  3216.   # * For attack and acquisition in battle picture X coordinate
  3217.   #--------------------------------------------------------------------------
  3218.   def attack_x(z)
  3219.     return (320 - true_x) * z * 0.75
  3220.   end
  3221.   #--------------------------------------------------------------------------
  3222.   # * For attack and acquisition of battle picture Y-coordinate
  3223.   #--------------------------------------------------------------------------
  3224.   def attack_y(z)
  3225.     return (160 - (true_y + @fly / 4) * z + @height * zoom * z / 2) * 0.75
  3226.   end
  3227.   #--------------------------------------------------------------------------
  3228.   # * Action compilation
  3229.   #--------------------------------------------------------------------------
  3230.   def make_action
  3231.     # Clearing current action
  3232.     self.current_action.clear
  3233.     # When it cannot move,
  3234.     unless self.inputable?
  3235.       # Method end
  3236.       return
  3237.     end
  3238.     # Presently extracting effective action
  3239.     available_actions = []
  3240.     rating_max = 0
  3241.     for action in self.actions
  3242.       # Turn conditional verification
  3243.       n = $game_temp.battle_turn
  3244.       a = action.condition_turn_a
  3245.       b = action.condition_turn_b
  3246.       if (b == 0 and n != a) or
  3247.          (b > 0 and (n < 1 or n < a or n % b != a % b))
  3248.         next
  3249.       end
  3250.       # HP conditional verification
  3251.       if self.hp * 100.0 / self.maxhp > action.condition_hp
  3252.         next
  3253.       end
  3254.       # Level conditional verification
  3255.       if $game_party.max_level < action.condition_level
  3256.         next
  3257.       end
  3258.       # Switch conditional verification
  3259.       switch_id = action.condition_switch_id
  3260.       if switch_id > 0 and $game_switches[switch_id] == false
  3261.         next
  3262.       end
  3263.       # Skill active conditional verification
  3264.       if action.kind == 1
  3265.         unless self.skill_can_use?(action.skill_id)
  3266.           next
  3267.         end
  3268.       end
  3269.       # It corresponds to condition : Adding this action
  3270.       available_actions.push(action)
  3271.       if action.rating > rating_max
  3272.         rating_max = action.rating
  3273.       end
  3274.     end
  3275.     # Maximum rating value as 3 total calculation (as for 0 or less exclusion)
  3276.     ratings_total = 0
  3277.     for action in available_actions
  3278.       if action.rating > rating_max - 3
  3279.         ratings_total += action.rating - (rating_max - 3)
  3280.       end
  3281.     end
  3282.     # When total of rating 0 is not,
  3283.     if ratings_total > 0
  3284.       # Drawing up random number
  3285.       value = rand(ratings_total)
  3286.       # Setting those which correspond to the random number which it drew up to current action
  3287.       for action in available_actions
  3288.         if action.rating > rating_max - 3
  3289.           if value < action.rating - (rating_max - 3)
  3290.             self.current_action.kind = action.kind
  3291.             self.current_action.basic = action.basic
  3292.             self.current_action.skill_id = action.skill_id
  3293.             self.current_action.decide_random_target_for_enemy
  3294.             return
  3295.           else
  3296.             value -= action.rating - (rating_max - 3)
  3297.           end
  3298.         end
  3299.       end
  3300.     end
  3301.   end
  3302. end
  3303.  
  3304. #==============================================================================
  3305. # ** Game_Party
  3306. #------------------------------------------------------------------------------
  3307. #  It is the class which handles the party. Information of the gold and the
  3308. #  item etc. is included. Instance of this ク lath is referred to being
  3309. #  $game_party.
  3310. #==============================================================================
  3311.  
  3312. class Game_Party
  3313.   #--------------------------------------------------------------------------
  3314.   # * Total destruction decision
  3315.   #--------------------------------------------------------------------------
  3316.   def all_dead?
  3317.     # When party number of people 0 is
  3318.     if $game_party.actors.size == 0
  3319.       return false
  3320.     end
  3321.     # When the actor of HP 0 or more is in the party,
  3322.     for actor in @actors
  3323.       if actor.rest_hp > 0
  3324.         return false
  3325.       end
  3326.     end
  3327.     # Total destruction
  3328.     return true
  3329.   end
  3330.   #--------------------------------------------------------------------------
  3331.   # * Random of object actor decision
  3332.   #     hp0 : Limits to the actor of HP 0
  3333.   #--------------------------------------------------------------------------
  3334.   # Original target decisive routine smooth_target_actor_rtab and name modification
  3335.   alias :random_target_actor_rtab :random_target_actor
  3336.   def random_target_actor(hp0 = false)
  3337.     # Initializing the roulette
  3338.     roulette = []
  3339.     # Loop
  3340.     for actor in @actors
  3341.       # When it corresponds to condition
  3342.       if (not hp0 and actor.exist? and actor.rest_hp > 0) or
  3343.           (hp0 and actor.hp0?)
  3344.         # Acquiring the [ position ] of class of actor
  3345.         position = $data_classes[actor.class_id].position
  3346.         # At the time of avant-garde n = 4、At the time of medium defense n = 3、At the time rear guard n = 2
  3347.         n = 4 - position
  3348.         # In roulette actor n time addition
  3349.         n.times do
  3350.           roulette.push(actor)
  3351.         end
  3352.       end
  3353.     end
  3354.     # When size of the roulette 0 is
  3355.     if roulette.size == 0
  3356.       return random_target_actor_rtab(hp0)
  3357.     end
  3358.     # It turns the roulette, deciding the actor
  3359.     return roulette[rand(roulette.size)]
  3360.   end
  3361.   #--------------------------------------------------------------------------
  3362.   # * Smooth decision of object actor
  3363.   #     actor_index : actor index
  3364.   #--------------------------------------------------------------------------
  3365.   # Original target decisive routine smooth_target_actor_rtab and name modification
  3366.   alias :smooth_target_actor_rtab :smooth_target_actor
  3367.   def smooth_target_actor(actor_index)
  3368.     # Acquiring the actor
  3369.     actor = @actors[actor_index]
  3370.     # When the actor exists
  3371.     if actor != nil and actor.exist? and actor.rest_hp > 0
  3372.       return actor
  3373.     end
  3374.     # Loop
  3375.     for actor in @actors
  3376.       # When the actor exists
  3377.       if actor.exist? and actor.rest_hp > 0
  3378.         return actor
  3379.       end
  3380.     end
  3381.     # When friend has destroyed, original target decisive routine is executed
  3382.     return smooth_target_actor_rtab(actor_index)
  3383.   end
  3384. end
  3385.  
  3386. #==============================================================================
  3387. # ** Game_Troop
  3388. #------------------------------------------------------------------------------
  3389. #  It is the class which handles the troop. As for instance of this class with
  3390. #  $game_troop reference the れ it increases.
  3391. #==============================================================================
  3392.  
  3393. class Game_Troop
  3394.   #--------------------------------------------------------------------------
  3395.   # * Random of object enemy decision
  3396.   #     hp0 : It limits to the enemy of HP 0
  3397.   #--------------------------------------------------------------------------
  3398.   # Original target decisive routine random_target_enemy_rtab and name modification
  3399.   alias :random_target_enemy_rtab :random_target_enemy
  3400.   def random_target_enemy(hp0 = false)
  3401.     # Initializing the roulette
  3402.     roulette = []
  3403.     # Loop
  3404.     for enemy in @enemies
  3405.       # When it corresponds to condition,
  3406.       if (not hp0 and enemy.exist? and enemy.rest_hp > 0) or
  3407.           (hp0 and enemy.hp0?)
  3408.         # Adding the enemy to the roulette
  3409.         roulette.push(enemy)
  3410.       end
  3411.     end
  3412.     # When size of the roulette 0 is,
  3413.     if roulette.size == 0
  3414.       return random_target_enemy_rtab(hp0)
  3415.     end
  3416.     # It turns the roulette, deciding the enemy
  3417.     return roulette[rand(roulette.size)]
  3418.   end
  3419.   #--------------------------------------------------------------------------
  3420.   # * Smooth decision of object enemy
  3421.   #     enemy_index : enemy index
  3422.   #--------------------------------------------------------------------------
  3423.   # Original target decisive routine smooth_target_enemy_rtab and name modification
  3424.   alias :smooth_target_enemy_rtab :smooth_target_enemy
  3425.   def smooth_target_enemy(enemy_index)
  3426.     # Acquiring the enemy
  3427.     enemy = @enemies[enemy_index]
  3428.     # When the enemy exists,
  3429.     if enemy != nil and enemy.exist? and enemy.rest_hp > 0
  3430.       return enemy
  3431.     end
  3432.     # Loop
  3433.     for enemy in @enemies
  3434.       # When the enemy exists,
  3435.       if enemy.exist? and enemy.rest_hp > 0
  3436.         return enemy
  3437.       end
  3438.     end
  3439.     # When the enemy has destroyed, it searches the enemy for the second time
  3440.     return smooth_target_enemy_rtab(enemy_index)
  3441.   end
  3442. end
  3443.  
  3444. #==============================================================================
  3445. # ** Sprite_Battler
  3446. #------------------------------------------------------------------------------
  3447. #  It is sprite for battler indication. Instance of Game_Battler class is watched,
  3448. #  state of sprite changes automatically.
  3449. #==============================================================================
  3450.  
  3451. class Sprite_Battler < RPG::Sprite
  3452.   #--------------------------------------------------------------------------
  3453.   # * Frame Renewal
  3454.   #--------------------------------------------------------------------------
  3455.   def update
  3456.     super
  3457.     # When the battler is nil
  3458.     if @battler == nil
  3459.       self.bitmap = nil
  3460.       loop_animation(nil)
  3461.       return
  3462.     end
  3463.     # When file name or hue differs from present ones
  3464.     if @battler.battler_name != @battler_name or
  3465.        @battler.battler_hue != @battler_hue
  3466.       # To acquire bitmap, setting
  3467.       @battler_name = @battler.battler_name
  3468.       @battler_hue = @battler.battler_hue
  3469.       self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
  3470.       @width = bitmap.width
  3471.       @height = bitmap.height
  3472.       self.ox = @width / 2
  3473.       self.oy = @height
  3474.       if @battler.is_a?(Game_Enemy)
  3475.         @battler.height = @height
  3476.       end
  3477.       # Aggressive failure or it hides and if state it designates opacity as 0
  3478.       if @battler.dead? or @battler.hidden
  3479.         self.opacity = 0
  3480.       end
  3481.     end
  3482.     # When animation ID differs from present ones
  3483.     if @battler.state_animation_id != @state_animation_id
  3484.       @state_animation_id = @battler.state_animation_id
  3485.       loop_animation($data_animations[@state_animation_id])
  3486.     end
  3487.     # In case of the actor whom it should indicate
  3488.     if @battler.is_a?(Game_Actor) and @battler_visible
  3489.       # When being main phase, opacity is lowered a little
  3490.       if $game_temp.battle_main_phase
  3491.         self.opacity += 3 if self.opacity < 255
  3492.       else
  3493.         self.opacity -= 3 if self.opacity > 207
  3494.       end
  3495.     end
  3496.     # Blinking
  3497.     if @battler.blink
  3498.       blink_on
  3499.     else
  3500.       blink_off
  3501.     end
  3502.     # In case of invisibility
  3503.     unless @battler_visible
  3504.       # Appearance
  3505.       if not @battler.hidden and not @battler.dead? and
  3506.          (@battler.damage.size < 2 or @battler.damage_pop.size < 2)
  3507.         appear
  3508.         @battler_visible = true
  3509.       end
  3510.     end
  3511.     # Damage
  3512.     for battler in @battler.damage_pop
  3513.       if battler[0].class == Array
  3514.         if battler[0][1] >= 0
  3515.           $scene.skill_se
  3516.         else
  3517.           $scene.levelup_se
  3518.         end
  3519.         damage(@battler.damage[battler[0]], false, 2)
  3520.       else
  3521.         damage(@battler.damage[battler[0]], @battler.critical[battler[0]])
  3522.       end
  3523.       if @battler.damage_sp.include?(battler[0])
  3524.         damage(@battler.damage_sp[battler[0]],
  3525.                 @battler.critical[battler[0]], 1)
  3526.         @battler.damage_sp.delete(battler[0])
  3527.       end
  3528.       @battler.damage_pop.delete(battler[0])
  3529.       @battler.damage.delete(battler[0])
  3530.       @battler.critical.delete(battler[0])
  3531.     end
  3532.     # When it is visible
  3533.     if @battler_visible
  3534.       # Flight
  3535.       if @battler.hidden
  3536.         $game_system.se_play($data_system.escape_se)
  3537.         escape
  3538.         @battler_visible = false
  3539.       end
  3540.       # White Flash
  3541.       if @battler.white_flash
  3542.         whiten
  3543.         @battler.white_flash = false
  3544.       end
  3545.       # Animation
  3546.       unless @battler.animation.empty?
  3547.         for animation in @battler.animation.reverse
  3548.           animation($data_animations[animation[0]], animation[1])
  3549.           @battler.animation.delete(animation)
  3550.         end
  3551.       end
  3552.       # Collapse
  3553.       if @battler.damage.empty? and @battler.dead?
  3554.         if $scene.dead_ok?(@battler)
  3555.           if @battler.is_a?(Game_Enemy)
  3556.             $game_system.se_play($data_system.enemy_collapse_se)
  3557.           else
  3558.             $game_system.se_play($data_system.actor_collapse_se)
  3559.           end
  3560.           collapse
  3561.           @battler_visible = false
  3562.         end
  3563.       end
  3564.     end
  3565.     # Setting the coordinate of sprite
  3566.     self.x = @battler.screen_x
  3567.     self.y = @battler.screen_y
  3568.     self.z = @battler.screen_z
  3569.     if @battler.is_a?(Game_Enemy)
  3570.       self.zoom_x = @battler.real_zoom * @battler.zoom
  3571.       self.zoom_y = @battler.real_zoom * @battler.zoom
  3572.     end
  3573.   end
  3574. end
  3575.  
  3576. #==============================================================================
  3577. # ** Window_Base
  3578. #------------------------------------------------------------------------------
  3579. #  It is superclass of all windows in the game.
  3580. #==============================================================================
  3581.  
  3582. class Window_Base < Window
  3583.   #--------------------------------------------------------------------------
  3584.   # * Drawing of gauge
  3585.   #--------------------------------------------------------------------------
  3586.   def gauge_rect_at(width, height, align3,
  3587.                     color1, color2, color3, color4, color5, color6, color7,
  3588.                     color8, color9, color10, color11, color12, grade1, grade2)
  3589.     # Framework drawing
  3590.     @at_gauge = Bitmap.new(width, height * 5)
  3591.     @at_gauge.fill_rect(0, 0, width, height, color1)
  3592.     @at_gauge.fill_rect(1, 1, width - 2, height - 2, color2)
  3593.     if (align3 == 1 and grade1 == 0) or grade1 > 0
  3594.       color = color3
  3595.       color3 = color4
  3596.       color4 = color
  3597.     end
  3598.     if (align3 == 1 and grade2 == 0) or grade2 > 0
  3599.       color = color5
  3600.       color5 = color6
  3601.       color6 = color
  3602.       color = color7
  3603.       color7 = color8
  3604.       color8 = color
  3605.       color = color9
  3606.       color9 = color10
  3607.       color10 = color
  3608.       color = color11
  3609.       color11 = color12
  3610.       color12 = color
  3611.     end
  3612.     if align3 == 0
  3613.       if grade1 == 2
  3614.         grade1 = 3
  3615.       end
  3616.       if grade2 == 2
  3617.         grade2 = 3
  3618.       end
  3619.     end
  3620.     # Drawing vertically of empty gauge gradation indication
  3621.     @at_gauge.gradation_rect(2, 2, width - 4, height - 4,
  3622.                                   color3, color4, grade1)
  3623.     # Drawing of actual gauge
  3624.     @at_gauge.gradation_rect(2, height + 2, width- 4, height - 4,
  3625.                                   color5, color6, grade2)
  3626.     @at_gauge.gradation_rect(2, height * 2 + 2, width- 4, height - 4,
  3627.                                   color7, color8, grade2)
  3628.     @at_gauge.gradation_rect(2, height * 3 + 2, width- 4, height - 4,
  3629.                                   color9, color10, grade2)
  3630.     @at_gauge.gradation_rect(2, height * 4 + 2, width- 4, height - 4,
  3631.                                   color11, color12, grade2)
  3632.   end
  3633. end
  3634.  
  3635. #==============================================================================
  3636. # ** Window_Help
  3637. #------------------------------------------------------------------------------
  3638. #  It is the window which indicates the item description the skill and the
  3639. #  status etc. of the actor.
  3640. #==============================================================================
  3641.  
  3642. class Window_Help < Window_Base
  3643.   #--------------------------------------------------------------------------
  3644.   # * Enemy Setting
  3645.   #     enemy : The enemy which indicates name and the state
  3646.   #--------------------------------------------------------------------------
  3647.   def set_enemy(enemy)
  3648.     text = enemy.name.sub(/\\[Ff]\[([0-9]+)\]/) {""}
  3649.     state_text = make_battler_state_text(enemy, 112, false)
  3650.     if state_text != ""
  3651.       text += "  " + state_text
  3652.     end
  3653.     set_text(text, 1)
  3654.   end
  3655. end
  3656.  
  3657. #==============================================================================
  3658. # ** Window_BattleStatus
  3659. #------------------------------------------------------------------------------
  3660. #  It is the window which indicates the status of the party member in the
  3661. #  battle picture.
  3662. #==============================================================================
  3663.  
  3664. class Window_BattleStatus < Window_Base
  3665.   #--------------------------------------------------------------------------
  3666.   # * Object Initialization
  3667.   #--------------------------------------------------------------------------
  3668.   def initialize
  3669.     x = (4 - $game_party.actors.size) * 80
  3670.     width = $game_party.actors.size * 160
  3671.     super(x, 320, width, 160)
  3672.     self.back_opacity = 160
  3673.     @actor_window = []
  3674.     for i in 0...$game_party.actors.size
  3675.       @actor_window.push(Window_ActorStatus.new(i, x + i * 160))
  3676.     end
  3677.     @level_up_flags = [false, false, false, false]
  3678.     refresh
  3679.   end
  3680.   #--------------------------------------------------------------------------
  3681.   # * Dispose
  3682.   #--------------------------------------------------------------------------
  3683.   def dispose
  3684.     for window in @actor_window
  3685.       window.dispose
  3686.     end
  3687.     super
  3688.   end
  3689.   #--------------------------------------------------------------------------
  3690.   # * Refresh
  3691.   #--------------------------------------------------------------------------
  3692.   def refresh(number = 0)    if number == 0
  3693.       cnt = 0
  3694.       for window in @actor_window
  3695.         window.refresh(@level_up_flags[cnt])
  3696.         cnt += 1
  3697.       end
  3698.     else
  3699.       @actor_window[number - 1].refresh(@level_up_flags[number - 1])
  3700.     end
  3701.   end
  3702.   #--------------------------------------------------------------------------
  3703.   # * AT gauge refreshment
  3704.   #--------------------------------------------------------------------------
  3705.   def at_refresh(number = 0)
  3706.     if number == 0
  3707.       for window in @actor_window
  3708.         window.at_refresh
  3709.       end
  3710.     else
  3711.       @actor_window[number - 1].at_refresh
  3712.     end
  3713.   end
  3714.   #--------------------------------------------------------------------------
  3715.   # * Frame Renewal
  3716.   #--------------------------------------------------------------------------
  3717.   def update
  3718.     super
  3719.     if self.x != (4 - $game_party.actors.size) * 80
  3720.       self.x = (4 - $game_party.actors.size) * 80
  3721.       self.width = $game_party.actors.size * 160
  3722.       for window in @actor_window
  3723.         window.dispose
  3724.       end
  3725.       @actor_window = []
  3726.       for i in 0...$game_party.actors.size
  3727.         @actor_window.push(Window_ActorStatus.new(i, x + i * 160))
  3728.       end
  3729.       refresh
  3730.     end
  3731.     for window in @actor_window
  3732.       window.update
  3733.     end
  3734.   end
  3735. end
  3736.  
  3737. #==============================================================================
  3738. # ** Window_ActorStatus
  3739. #------------------------------------------------------------------------------
  3740. #  It is the window which indicates the status of the party member respectively
  3741. #  in the battle picture.
  3742. #==============================================================================
  3743.  
  3744. class Window_ActorStatus < Window_Base
  3745.   #--------------------------------------------------------------------------
  3746.   # * Object Initialization
  3747.   #--------------------------------------------------------------------------
  3748.   def initialize(id, x)
  3749.     @actor_num = id
  3750.     super(x, 320, 160, 160)
  3751.     self.contents = Bitmap.new(width - 32, height - 32)
  3752.     self.opacity = 0
  3753.     self.back_opacity = 0
  3754.     actor = $game_party.actors[@actor_num]
  3755.     @actor_nm = actor.name
  3756.     @actor_mhp = actor.maxhp
  3757.     @actor_msp = actor.maxsp
  3758.     @actor_hp = actor.hp
  3759.     @actor_sp = actor.sp
  3760.     @actor_st = make_battler_state_text(actor, 120, true)
  3761.     @status_window = []
  3762.     for i in 0...5
  3763.       @status_window.push(Window_DetailsStatus.new(actor, i, x))
  3764.     end
  3765.     refresh(false)
  3766.   end
  3767.   #--------------------------------------------------------------------------
  3768.   # * Dispose
  3769.   #--------------------------------------------------------------------------
  3770.   def dispose
  3771.     for i in 0...5
  3772.       @status_window[i].dispose
  3773.     end
  3774.     super
  3775.   end
  3776.   #--------------------------------------------------------------------------
  3777.   # * Refresh
  3778.   #--------------------------------------------------------------------------
  3779.   def refresh(level_up_flags)
  3780.     self.contents.clear
  3781.     actor = $game_party.actors[@actor_num]
  3782.     @status_window[0].refresh(actor) if @actor_nm != actor.name
  3783.     @status_window[1].refresh(actor) if
  3784.       @actor_mhp != actor.maxhp or @actor_hp != actor.hp
  3785.     @status_window[2].refresh(actor) if
  3786.       @actor_msp != actor.maxsp or @actor_sp != actor.sp
  3787.     @status_window[3].refresh(actor, level_up_flags) if
  3788.       @actor_st != make_battler_state_text(actor, 120, true) or level_up_flags
  3789.     @actor_nm = actor.name
  3790.     @actor_mhp = actor.maxhp
  3791.     @actor_msp = actor.maxsp
  3792.     @actor_hp = actor.hp
  3793.     @actor_sp = actor.sp
  3794.     @actor_st = make_battler_state_text(actor, 120, true)
  3795.   end
  3796.   #--------------------------------------------------------------------------
  3797.   # * AT gauge refreshment
  3798.   #--------------------------------------------------------------------------
  3799.   def at_refresh
  3800.     @status_window[4].refresh($game_party.actors[@actor_num])
  3801.   end
  3802.   #--------------------------------------------------------------------------
  3803.   # * Frame Renewal
  3804.   #--------------------------------------------------------------------------
  3805.   def update
  3806.     for window in @status_window
  3807.       window.update
  3808.     end
  3809.   end
  3810. end
  3811.  
  3812. #==============================================================================
  3813. # ** Window_DetailsStatus
  3814. #------------------------------------------------------------------------------
  3815. #  It is the window which indicates the status of the actor in individually in the battle picture.
  3816. #==============================================================================
  3817.  
  3818. class Window_DetailsStatus < Window_Base
  3819.   #--------------------------------------------------------------------------
  3820.   # * Object Initialization
  3821.   #--------------------------------------------------------------------------
  3822.   def initialize(actor, id, x)
  3823.     @status_id = id
  3824.     super(x, 320 + id * 26, 160, 64)
  3825.     self.contents = Bitmap.new(width - 32, height - 32)
  3826.     self.opacity = 0
  3827.     self.back_opacity = 0
  3828.     refresh(actor, false)
  3829.   end
  3830.   #--------------------------------------------------------------------------
  3831.   # * Dispose
  3832.   #--------------------------------------------------------------------------
  3833.   def dispose
  3834.     super
  3835.   end
  3836.   #--------------------------------------------------------------------------
  3837.   # * Refresh
  3838.   #--------------------------------------------------------------------------
  3839.   def refresh(actor, level_up_flags = false)
  3840.     self.contents.clear
  3841.     case @status_id
  3842.     when 0
  3843.       draw_actor_name(actor, 4, 0)
  3844.     when 1
  3845.       draw_actor_hp(actor, 4, 0, 120)
  3846.     when 2
  3847.       draw_actor_sp(actor, 4, 0, 120)
  3848.     when 3
  3849.       if level_up_flags
  3850.         self.contents.font.color = normal_color
  3851.         self.contents.draw_text(4, 0, 120, 32, "LEVEL UP!")
  3852.       else
  3853.         draw_actor_state(actor, 4, 0)
  3854.       end
  3855.     when 4
  3856.       draw_actor_atg(actor, 4, 0, 120)
  3857.     end
  3858.   end
  3859.   #--------------------------------------------------------------------------
  3860.   # * Frame renewal
  3861.   #--------------------------------------------------------------------------
  3862.   def update
  3863.     #At the time of main phase opacity is lowered a little
  3864.     if $game_temp.battle_main_phase
  3865.       self.contents_opacity -= 4 if self.contents_opacity > 191
  3866.     else
  3867.       self.contents_opacity += 4 if self.contents_opacity < 255
  3868.     end
  3869.   end
  3870. end
  3871.  
  3872. #==============================================================================
  3873. # ** Arrow_Base
  3874. #------------------------------------------------------------------------------
  3875. #  It is sprite for the arrow cursor indication which is used in the battle picture.
  3876. #  This class is used as superclass of Arrow_Enemy class and Arrow_Actor class.
  3877. #==============================================================================
  3878.  
  3879. class Arrow_Base < Sprite
  3880.   #--------------------------------------------------------------------------
  3881.   # * Object Initialization
  3882.   #     viewport :viewport
  3883.   #--------------------------------------------------------------------------
  3884.   def initialize(viewport)
  3885.     super(viewport)
  3886.     self.bitmap = RPG::Cache.windowskin($game_system.windowskin_name)
  3887.     self.ox = 16
  3888.     self.oy = 32
  3889.     self.z = 2500
  3890.     @blink_count = 0
  3891.     @index = 0
  3892.     @help_window = nil
  3893.     update
  3894.   end
  3895. end
  3896.  
  3897. #==============================================================================
  3898. # ** Arrow_Enemy
  3899. #------------------------------------------------------------------------------
  3900. #  It is arrow cursor in order to make the enemy select.
  3901. #  This class succeeds Arrow_Base.
  3902. #==============================================================================
  3903.  
  3904. class Arrow_Enemy < Arrow_Base
  3905.   #--------------------------------------------------------------------------
  3906.   # * Frame renewal
  3907.   #--------------------------------------------------------------------------
  3908.   def update
  3909.     super
  3910.     # When it points to the enemy which does not exist, it throws
  3911.     $game_troop.enemies.size.times do
  3912.       break if self.enemy.exist?
  3913.       @index += 1
  3914.       @index %= $game_troop.enemies.size
  3915.     end
  3916.     # The cursor right
  3917.     if Input.repeat?(Input::RIGHT)
  3918.       $game_system.se_play($data_system.cursor_se)
  3919.       $game_troop.enemies.size.times do
  3920.         @index += 1
  3921.         @index %= $game_troop.enemies.size
  3922.         break if self.enemy.exist?
  3923.       end
  3924.       $scene.camera = "select"
  3925.       zoom = 1 / self.enemy.zoom
  3926.       $scene.spriteset.screen_target(self.enemy.attack_x(zoom) * 0.75,
  3927.                                       self.enemy.attack_y(zoom) * 0.75, zoom)
  3928.     end
  3929.     # The cursor left
  3930.     if Input.repeat?(Input::LEFT)
  3931.       $game_system.se_play($data_system.cursor_se)
  3932.       $game_troop.enemies.size.times do
  3933.         @index += $game_troop.enemies.size - 1
  3934.         @index %= $game_troop.enemies.size
  3935.         break if self.enemy.exist?
  3936.       end
  3937.       $scene.camera = "select"
  3938.       zoom = 1 / self.enemy.zoom
  3939.       $scene.spriteset.screen_target(self.enemy.attack_x(zoom) * 0.75,
  3940.                                       self.enemy.attack_y(zoom) * 0.75, zoom)
  3941.     end
  3942.     # Setting the coordinate of sprite
  3943.     if self.enemy != nil
  3944.       self.x = self.enemy.screen_x
  3945.       self.y = self.enemy.screen_y
  3946.     end
  3947.   end
  3948. end
  3949.  
  3950. #==============================================================================
  3951. # ** Interpreter
  3952. #------------------------------------------------------------------------------
  3953. #  It is the interpreter which executes event command. This class is used inside
  3954. #  the Game_System class and Game_Event class.
  3955. #==============================================================================
  3956.  
  3957. class Interpreter
  3958.   #--------------------------------------------------------------------------
  3959.   # ● アクターの入れ替え
  3960.   #--------------------------------------------------------------------------
  3961.   def command_129
  3962.     # Acquiring the actor
  3963.     actor = $game_actors[@parameters[0]]
  3964.     # When the actor is valid
  3965.     if actor != nil
  3966.       # It diverges with operation
  3967.       if @parameters[1] == 0
  3968.         if @parameters[2] == 1
  3969.           $game_actors[@parameters[0]].setup(@parameters[0])
  3970.         end
  3971.         $game_party.add_actor(@parameters[0])
  3972.         if $game_temp.in_battle
  3973.           $game_actors[@parameters[0]].at = 0
  3974.           $game_actors[@parameters[0]].atp = 0
  3975.           $scene.spell_reset($game_actors[@parameters[0]])
  3976.           $game_actors[@parameters[0]].damage_pop = {}
  3977.           $game_actors[@parameters[0]].damage = {}
  3978.           $game_actors[@parameters[0]].damage_sp = {}
  3979.           $game_actors[@parameters[0]].critical = {}
  3980.           $game_actors[@parameters[0]].recover_hp = {}
  3981.           $game_actors[@parameters[0]].recover_sp = {}
  3982.           $game_actors[@parameters[0]].state_p = {}
  3983.           $game_actors[@parameters[0]].state_m = {}
  3984.           $game_actors[@parameters[0]].animation = []
  3985.         end
  3986.       else
  3987.         $game_party.remove_actor(@parameters[0])
  3988.       end
  3989.     end
  3990.     if $game_temp.in_battle
  3991.       $scene.status_window.update
  3992.     end
  3993.     # Continuation
  3994.     return true
  3995.   end
  3996.   #--------------------------------------------------------------------------
  3997.   # * The increase and decrease of HP
  3998.   #--------------------------------------------------------------------------
  3999.   alias :command_311_rtab :command_311
  4000.   def command_311
  4001.     command_311_rtab
  4002.     if $game_temp.in_battle
  4003.       $scene.status_window.refresh
  4004.     end
  4005.   end
  4006.   #--------------------------------------------------------------------------
  4007.   # *The increase and decrease of SP
  4008.   #--------------------------------------------------------------------------
  4009.   alias :command_312_rtab :command_312
  4010.   def command_312
  4011.     command_312_rtab
  4012.     if $game_temp.in_battle
  4013.       $scene.status_window.refresh
  4014.     end
  4015.   end
  4016.   #--------------------------------------------------------------------------
  4017.   # * Modification of state
  4018.   #--------------------------------------------------------------------------
  4019.   alias :command_313_rtab :command_313
  4020.   def command_313
  4021.     command_313_rtab
  4022.     if $game_temp.in_battle
  4023.       $scene.status_window.refresh
  4024.     end
  4025.   end
  4026.   #--------------------------------------------------------------------------
  4027.   # * All recovery
  4028.   #--------------------------------------------------------------------------
  4029.   alias :command_314_rtab :command_314
  4030.   def command_314
  4031.     command_314_rtab
  4032.     if $game_temp.in_battle
  4033.       $scene.status_window.refresh
  4034.     end
  4035.   end
  4036.   #--------------------------------------------------------------------------
  4037.   # * The increase and decrease of EXP
  4038.   #--------------------------------------------------------------------------
  4039.   alias :command_315_rtab :command_315
  4040.   def command_315
  4041.     command_315_rtab
  4042.     if $game_temp.in_battle
  4043.       $scene.status_window.refresh
  4044.     end
  4045.   end
  4046.   #--------------------------------------------------------------------------
  4047.   # * Increase and decrease of level
  4048.   #--------------------------------------------------------------------------
  4049.   alias :command_316_rtab :command_316
  4050.   def command_316
  4051.     command_316_rtab
  4052.     if $game_temp.in_battle
  4053.       $scene.status_window.refresh
  4054.     end
  4055.   end
  4056.   #--------------------------------------------------------------------------
  4057.   # * Increase and decrease of parameter
  4058.   #--------------------------------------------------------------------------
  4059.   alias :command_317_rtab :command_317
  4060.   def command_317
  4061.     command_317_rtab
  4062.     if $game_temp.in_battle
  4063.       $scene.status_window.refresh
  4064.     end
  4065.   end
  4066.   #--------------------------------------------------------------------------
  4067.   # * Modification of equipment
  4068.   #--------------------------------------------------------------------------
  4069.   alias :command_319_rtab :command_319
  4070.   def command_319
  4071.     command_319_rtab
  4072.     if $game_temp.in_battle
  4073.       $scene.status_window.refresh
  4074.     end
  4075.   end
  4076.   #--------------------------------------------------------------------------
  4077.   # * Name modification of actor
  4078.   #--------------------------------------------------------------------------
  4079.   alias :command_320_rtab :command_320
  4080.   def command_320
  4081.     command_320_rtab
  4082.     if $game_temp.in_battle
  4083.       $scene.status_window.refresh
  4084.     end
  4085.   end
  4086.   #--------------------------------------------------------------------------
  4087.   # * Class modification of actor
  4088.   #--------------------------------------------------------------------------
  4089.   alias :command_321_rtab :command_321
  4090.   def command_321
  4091.     command_321_rtab
  4092.     if $game_temp.in_battle
  4093.       $scene.status_window.refresh
  4094.     end
  4095.   end
  4096.   #--------------------------------------------------------------------------
  4097.   # * Indication of animation
  4098.   #--------------------------------------------------------------------------
  4099.   def command_337
  4100.     # Process iteration
  4101.     iterate_battler(@parameters[0], @parameters[1]) do |battler|
  4102.       # When the battler exists
  4103.       if battler.exist?
  4104.       #  Setting animation ID
  4105.         battler.animation.push([@parameters[2], true])
  4106.       end
  4107.     end
  4108.     # continuous
  4109.     return true
  4110.   end
  4111.   #--------------------------------------------------------------------------
  4112.   # * Deal Damage
  4113.   #--------------------------------------------------------------------------
  4114.   def command_338
  4115.   # of the damage the value which is operated acquisition
  4116.   value = operate_value(0, @parameters[2], @parameters[3])
  4117.   # Process iteration
  4118.   iterate_battler(@parameters[0], @parameters[1]) do |battler|
  4119.   # battler exists with
  4120.     if battler.exist?
  4121.       # HP modification
  4122.       battler.hp -= value
  4123.       # fighting
  4124.         if $game_temp.in_battle
  4125.           # damage setting
  4126.           battler.damage["event"] = value
  4127.           battler.damage_pop["event"] = true
  4128.         end
  4129.       end
  4130.     end
  4131.     if $game_temp.in_battle
  4132.       $scene.status_window.refresh
  4133.     end
  4134.     # continuation
  4135.   return true
  4136.   end
  4137.   #--------------------------------------------------------------------------
  4138.   # * Forcing the action
  4139.   #--------------------------------------------------------------------------
  4140.   def command_339
  4141.     # If it is not in the midst of fighting, disregard
  4142.     unless $game_temp.in_battle
  4143.       return true
  4144.     end
  4145.     # If the number of turns 0 disregard
  4146.     if $game_temp.battle_turn == 0
  4147.       return true
  4148.     end
  4149.     # Processing (With convenient ones, there are no times when it becomes plural)
  4150.     iterate_battler(@parameters[0], @parameters[1]) do |battler|
  4151.       # When the battler exists,
  4152.       if battler.exist?
  4153.       # Setting action
  4154.         battler.current_action.force_kind = @parameters[2]
  4155.         if battler.current_action.force_kind == 0
  4156.           battler.current_action.force_basic = @parameters[3]
  4157.         else
  4158.           battler.current_action.force_skill_id = @parameters[3]
  4159.         end
  4160.         #  Setting the conduct object
  4161.         if @parameters[4] == -2
  4162.           if battler.is_a?(Game_Enemy)
  4163.             battler.current_action.decide_last_target_for_enemy
  4164.           else
  4165.             battler.current_action.decide_last_target_for_actor
  4166.           end
  4167.         elsif @parameters[4] == -1
  4168.           if battler.is_a?(Game_Enemy)
  4169.             battler.current_action.decide_random_target_for_enemy
  4170.           else
  4171.             battler.current_action.decide_random_target_for_actor
  4172.           end
  4173.         elsif @parameters[4] >= 0
  4174.           battler.current_action.target_index = @parameters[4]
  4175.         end
  4176.         # When action validity and [ directly execution ] is,
  4177.         if battler.current_action.valid? and @parameters[5] == 1
  4178.           # Setting the battler of the forced object
  4179.           $game_temp.forcing_battler = battler
  4180.           # The index is advanced
  4181.           @index += 1
  4182.           # end
  4183.           return false
  4184.         elsif battler.current_action.valid? and @parameters[5] == 0
  4185.           battler.current_action.forcing = true
  4186.         end
  4187.       end
  4188.     end
  4189.   # continuation
  4190.     return true
  4191.   end
  4192. end
  4193.  
  4194. #==============================================================================
  4195. # * Sprite module
  4196. #------------------------------------------------------------------------------
  4197. # This module manages and controls animation.
  4198. #==============================================================================
  4199.  
  4200. module RPG
  4201.  
  4202.   class Sprite < ::Sprite
  4203.     def initialize(viewport = nil)
  4204.       super(viewport)
  4205.       @_whiten_duration = 0
  4206.       @_appear_duration = 0
  4207.       @_escape_duration = 0
  4208.       @_collapse_duration = 0
  4209.       @_damage = []
  4210.       @_animation = []
  4211.       @_animation_duration = 0
  4212.       @_blink = false
  4213.     end
  4214.     def damage(value, critical, type = 0)
  4215.       if value.is_a?(Numeric)
  4216.         damage_string = value.abs.to_s
  4217.       else
  4218.         damage_string = value.to_s
  4219.       end
  4220.       bitmap = Bitmap.new(160, 48)
  4221.       bitmap.font.name = "monofur"
  4222.       bitmap.font.size = 32
  4223.       bitmap.font.italic = false
  4224.       bitmap.font.color.set(0, 0, 0)
  4225.       bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
  4226.       bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
  4227.       bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
  4228.       bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
  4229.       if value.is_a?(Numeric) and value < 0
  4230.         if type == 0
  4231.           bitmap.font.color.set(176, 255, 144)
  4232.         else
  4233.           bitmap.font.color.set(176, 144, 255)
  4234.         end
  4235.       else
  4236.         if type == 0
  4237.           bitmap.font.color.set(255, 255, 255)
  4238.         else
  4239.           bitmap.font.color.set(255, 176, 144)
  4240.         end
  4241.       end
  4242.       if type == 2
  4243.         bitmap.font.color.set(255, 224, 128)
  4244.       end
  4245.       bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
  4246.       if critical
  4247.         string = "CRITICAL"
  4248.         bitmap.font.size = 20
  4249.         bitmap.font.color.set(0, 0, 0)
  4250.         bitmap.draw_text(-1, -1, 160, 20, string, 1)
  4251.         bitmap.draw_text(+1, -1, 160, 20, string, 1)
  4252.         bitmap.draw_text(-1, +1, 160, 20, string, 1)
  4253.         bitmap.draw_text(+1, +1, 160, 20, string, 1)
  4254.         bitmap.font.color.set(255, 255, 255)
  4255.         bitmap.draw_text(0, 0, 160, 20, string, 1)
  4256.       end
  4257.       num = @_damage.size
  4258.       if type != 2
  4259.         @_damage.push([::Sprite.new, 40, 0, rand(40) - 20, rand(30) + 50])
  4260.       else
  4261.         @_damage.push([::Sprite.new, 40, 0, rand(20) - 10, rand(20) + 60])
  4262.       end
  4263.       @_damage[num][0].bitmap = bitmap
  4264.       @_damage[num][0].ox = 80 + self.viewport.ox
  4265.       @_damage[num][0].oy = 20 + self.viewport.oy
  4266.       if self.battler.is_a?(Game_Actor)
  4267.         @_damage[num][0].x = self.x
  4268.         @_damage[num][0].y = self.y - self.oy / 2
  4269.       else
  4270.         @_damage[num][0].x = self.x + self.viewport.rect.x -
  4271.                             self.ox + self.src_rect.width / 2
  4272.         @_damage[num][0].y = self.y - self.oy * self.zoom_y / 2 +
  4273.                             self.viewport.rect.y
  4274.         @_damage[num][0].zoom_x = self.zoom_x
  4275.         @_damage[num][0].zoom_y = self.zoom_y
  4276.         @_damage[num][0].z = 3000
  4277.       end
  4278.     end
  4279.     def animation(animation, hit)
  4280.       return if animation == nil
  4281.       num = @_animation.size
  4282.       @_animation.push([animation, hit, animation.frame_max, []])
  4283.       bitmap = RPG::Cache.animation(animation.animation_name,
  4284.                                     animation.animation_hue)
  4285.       if @@_reference_count.include?(bitmap)
  4286.         @@_reference_count[bitmap] += 1
  4287.       else
  4288.         @@_reference_count[bitmap] = 1
  4289.       end
  4290.       if @_animation[num][0].position != 3 or
  4291.           not @@_animations.include?(animation)
  4292.         for i in 0..15
  4293.           sprite = ::Sprite.new
  4294.           sprite.bitmap = bitmap
  4295.           sprite.visible = false
  4296.           @_animation[num][3].push(sprite)
  4297.         end
  4298.         unless @@_animations.include?(animation)
  4299.           @@_animations.push(animation)
  4300.         end
  4301.       end
  4302.       update_animation(@_animation[num])
  4303.     end
  4304.     def loop_animation(animation)
  4305.       return if animation == @_loop_animation
  4306.       dispose_loop_animation
  4307.       @_loop_animation = animation
  4308.       return if @_loop_animation == nil
  4309.       @_loop_animation_index = 0
  4310.       animation_name = @_loop_animation.animation_name
  4311.       animation_hue = @_loop_animation.animation_hue
  4312.       bitmap = RPG::Cache.animation(animation_name, animation_hue)
  4313.       if @@_reference_count.include?(bitmap)
  4314.         @@_reference_count[bitmap] += 1
  4315.       else
  4316.         @@_reference_count[bitmap] = 1
  4317.       end
  4318.       @_loop_animation_sprites = []
  4319.       for i in 0..15
  4320.         sprite = ::Sprite.new
  4321.         sprite.bitmap = bitmap
  4322.         sprite.visible = false
  4323.         @_loop_animation_sprites.push(sprite)
  4324.       end
  4325.       # update_loop_animation
  4326.     end
  4327.     def dispose_damage
  4328.       for damage in @_damage.reverse
  4329.         damage[0].bitmap.dispose
  4330.         damage[0].dispose
  4331.         @_damage.delete(damage)
  4332.       end
  4333.     end
  4334.     def dispose_animation
  4335.       for anime in @_animation.reverse
  4336.         sprite = anime[3][0]
  4337.         if sprite != nil
  4338.           @@_reference_count[sprite.bitmap] -= 1
  4339.           if @@_reference_count[sprite.bitmap] == 0
  4340.             sprite.bitmap.dispose
  4341.           end
  4342.         end
  4343.         for sprite in anime[3]
  4344.           sprite.dispose
  4345.         end
  4346.         @_animation.delete(anime)
  4347.       end
  4348.     end
  4349.     def effect?
  4350.       @_whiten_duration > 0 or
  4351.       @_appear_duration > 0 or
  4352.       @_escape_duration > 0 or
  4353.       @_collapse_duration > 0 or
  4354.       @_damage.size == 0 or
  4355.       @_animation.size == 0
  4356.     end
  4357.     def update
  4358.       super
  4359.       if @_whiten_duration > 0
  4360.         @_whiten_duration -= 1
  4361.         self.color.alpha = 128 - (16 - @_whiten_duration) * 10
  4362.       end
  4363.       if @_appear_duration > 0
  4364.         @_appear_duration -= 1
  4365.         self.opacity = (16 - @_appear_duration) * 16
  4366.       end
  4367.       if @_escape_duration > 0
  4368.         @_escape_duration -= 1
  4369.         self.opacity = 256 - (32 - @_escape_duration) * 10
  4370.       end
  4371.       if @_collapse_duration > 0
  4372.         @_collapse_duration -= 1
  4373.         self.opacity = 256 - (48 - @_collapse_duration) * 6
  4374.       end
  4375.       for damage in @_damage
  4376.         if damage[1] > 0
  4377.           damage[1] -= 1
  4378.           damage[4] -= 3
  4379.           damage[2] -= damage[4]
  4380.           if self.battler.is_a?(Game_Actor)
  4381.             damage[0].x = self.x + (40 - damage[1]) * damage[3] / 10
  4382.             damage[0].y = self.y - self.oy / 2 + damage[2] / 10
  4383.           else
  4384.             damage[0].x = self.x + self.viewport.rect.x -
  4385.                           self.ox + self.src_rect.width / 2 +
  4386.                           (40 - damage[1]) * damage[3] / 10
  4387.             damage[0].y = self.y - self.oy * self.zoom_y / 2 +
  4388.                           self.viewport.rect.y + damage[2] / 10
  4389.             damage[0].zoom_x = self.zoom_x
  4390.             damage[0].zoom_y = self.zoom_y
  4391.           end
  4392.           damage[0].z = 2960 + damage[1]
  4393.           damage[0].opacity = 256 - (12 - damage[1]) * 32
  4394.           if damage[1] == 0
  4395.             damage[0].bitmap.dispose
  4396.             damage[0].dispose
  4397.             @_damage.delete(damage)
  4398.           end
  4399.         end
  4400.       end
  4401.       for anime in @_animation
  4402.         if (Graphics.frame_count % 2 == 0)
  4403.           anime[2] -= 1
  4404.           update_animation(anime)
  4405.         end
  4406.       end
  4407.       if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
  4408.         update_loop_animation
  4409.         @_loop_animation_index += 1
  4410.         @_loop_animation_index %= @_loop_animation.frame_max
  4411.       end
  4412.       if @_blink
  4413.         @_blink_count = (@_blink_count + 1) % 32
  4414.         if @_blink_count < 16
  4415.           alpha = (16 - @_blink_count) * 6
  4416.         else
  4417.           alpha = (@_blink_count - 16) * 6
  4418.         end
  4419.         self.color.set(255, 255, 255, alpha)
  4420.       end
  4421.       @@_animations.clear
  4422.     end
  4423.     def update_animation(anime)
  4424.       if anime[2] > 0
  4425.         frame_index = anime[0].frame_max - anime[2]
  4426.         cell_data = anime[0].frames[frame_index].cell_data
  4427.         position = anime[0].position
  4428.         animation_set_sprites(anime[3], cell_data, position)
  4429.         for timing in anime[0].timings
  4430.           if timing.frame == frame_index
  4431.             animation_process_timing(timing, anime[1])
  4432.           end
  4433.         end
  4434.       else
  4435.         @@_reference_count[anime[3][0].bitmap] -= 1
  4436.         if @@_reference_count[anime[3][0].bitmap] == 0
  4437.             anime[3][0].bitmap.dispose
  4438.         end
  4439.         for sprite in anime[3]
  4440.           sprite.dispose
  4441.         end
  4442.         @_animation.delete(anime)
  4443.       end
  4444.     end
  4445.     def animation_set_sprites(sprites, cell_data, position)
  4446.       for i in 0..15
  4447.         sprite = sprites[i]
  4448.         pattern = cell_data[i, 0]
  4449.         if sprite == nil or pattern == nil or pattern == -1
  4450.           sprite.visible = false if sprite != nil
  4451.           next
  4452.         end
  4453.         sprite.visible = true
  4454.         sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
  4455.         if position == 3
  4456.           if self.viewport != nil
  4457.             sprite.x = self.viewport.rect.width / 2
  4458.             if $game_temp.in_battle and self.battler.is_a?(Game_Enemy)
  4459.               sprite.y = self.viewport.rect.height - 320
  4460.             else
  4461.               sprite.y = self.viewport.rect.height - 160
  4462.             end
  4463.           else
  4464.             sprite.x = 320
  4465.             sprite.y = 240
  4466.           end
  4467.         else
  4468.           sprite.x = self.x + self.viewport.rect.x -
  4469.                       self.ox + self.src_rect.width / 2
  4470.           if $game_temp.in_battle and self.battler.is_a?(Game_Enemy)
  4471.             sprite.y = self.y - self.oy * self.zoom_y / 2 +
  4472.                         self.viewport.rect.y
  4473.             if position == 0
  4474.               sprite.y -= self.src_rect.height * self.zoom_y / 4
  4475.             elsif position == 2
  4476.               sprite.y += self.src_rect.height * self.zoom_y / 4
  4477.             end
  4478.           else
  4479.             sprite.y = self.y + self.viewport.rect.y -
  4480.                         self.oy + self.src_rect.height / 2
  4481.             sprite.y -= self.src_rect.height / 4 if position == 0
  4482.             sprite.y += self.src_rect.height / 4 if position == 2
  4483.           end
  4484.         end
  4485.         sprite.x += cell_data[i, 1]
  4486.         sprite.y += cell_data[i, 2]
  4487.         sprite.z = 2000
  4488.         sprite.ox = 96
  4489.         sprite.oy = 96
  4490.         sprite.zoom_x = cell_data[i, 3] / 100.0
  4491.         sprite.zoom_y = cell_data[i, 3] / 100.0
  4492.         if position != 3
  4493.           sprite.zoom_x *= self.zoom_x
  4494.           sprite.zoom_y *= self.zoom_y
  4495.         end
  4496.         sprite.angle = cell_data[i, 4]
  4497.         sprite.mirror = (cell_data[i, 5] == 1)
  4498.         sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  4499.         sprite.blend_type = cell_data[i, 7]
  4500.       end
  4501.     end
  4502.     def x=(x)
  4503.       sx = x - self.x
  4504.       if sx != 0
  4505.         for anime in @_animation
  4506.           if anime[3] != nil
  4507.             for i in 0..15
  4508.               anime[3][i].x += sx
  4509.             end
  4510.           end
  4511.         end
  4512.         if @_loop_animation_sprites != nil
  4513.           for i in 0..15
  4514.             @_loop_animation_sprites[i].x += sx
  4515.           end
  4516.         end
  4517.       end
  4518.       super
  4519.     end
  4520.     def y=(y)
  4521.       sy = y - self.y
  4522.       if sy != 0
  4523.         for anime in @_animation
  4524.           if anime[3] != nil
  4525.             for i in 0..15
  4526.               anime[3][i].y += sy
  4527.             end
  4528.           end
  4529.         end
  4530.         if @_loop_animation_sprites != nil
  4531.           for i in 0..15
  4532.             @_loop_animation_sprites[i].y += sy
  4533.           end
  4534.         end
  4535.       end
  4536.       super
  4537.     end
  4538.   end
  4539. end
  4540.  
  4541. #------------------------------------------------------------------------------
  4542. # New routine added to the Bitmap class.
  4543. #==============================================================================
  4544.  
  4545. class Bitmap
  4546. #--------------------------------------------------------------------------
  4547. # * Rectangle Gradation Indicator
  4548. #   color1: Start color
  4549. #   color2: Ending color
  4550. #   align: 0: On side gradation
  4551. #          1: Vertically gradation
  4552. #          2: The gradation (intense concerning slantedly heavily note)
  4553. #--------------------------------------------------------------------------
  4554.   def gradation_rect(x, y, width, height, color1, color2, align = 0)
  4555.     if align == 0
  4556.       for i in x...x + width
  4557.         red   = color1.red + (color2.red - color1.red) * (i - x) / (width - 1)
  4558.         green = color1.green +
  4559.                 (color2.green - color1.green) * (i - x) / (width - 1)
  4560.         blue  = color1.blue +
  4561.                 (color2.blue - color1.blue) * (i - x) / (width - 1)
  4562.         alpha = color1.alpha +
  4563.                 (color2.alpha - color1.alpha) * (i - x) / (width - 1)
  4564.         color = Color.new(red, green, blue, alpha)
  4565.         fill_rect(i, y, 1, height, color)
  4566.       end
  4567.     elsif align == 1
  4568.       for i in y...y + height
  4569.         red   = color1.red +
  4570.                 (color2.red - color1.red) * (i - y) / (height - 1)
  4571.         green = color1.green +
  4572.                 (color2.green - color1.green) * (i - y) / (height - 1)
  4573.         blue  = color1.blue +
  4574.                 (color2.blue - color1.blue) * (i - y) / (height - 1)
  4575.         alpha = color1.alpha +
  4576.                 (color2.alpha - color1.alpha) * (i - y) / (height - 1)
  4577.         color = Color.new(red, green, blue, alpha)
  4578.         fill_rect(x, i, width, 1, color)
  4579.       end
  4580.     elsif align == 2
  4581.       for i in x...x + width
  4582.         for j in y...y + height
  4583.           red   = color1.red + (color2.red - color1.red) *
  4584.                   ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  4585.           green = color1.green + (color2.green - color1.green) *
  4586.                   ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  4587.           blue  = color1.blue + (color2.blue - color1.blue) *
  4588.                   ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  4589.           alpha = color1.alpha + (color2.alpha - color1.alpha) *
  4590.                   ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  4591.           color = Color.new(red, green, blue, alpha)
  4592.           set_pixel(i, j, color)
  4593.         end
  4594.       end
  4595.     elsif align == 3
  4596.       for i in x...x + width
  4597.         for j in y...y + height
  4598.           red   = color1.red + (color2.red - color1.red) *
  4599.               ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  4600.           green = color1.green + (color2.green - color1.green) *
  4601.               ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  4602.           blue  = color1.blue + (color2.blue - color1.blue) *
  4603.               ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  4604.           alpha = color1.alpha + (color2.alpha - color1.alpha) *
  4605.               ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  4606.           color = Color.new(red, green, blue, alpha)
  4607.           set_pixel(i, j, color)
  4608.         end
  4609.       end
  4610.     end
  4611.   end
  4612. end
Add Comment
Please, Sign In to add comment