Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Undefined Local Variable when try to merge a scripts

I was try to merge a script again, this time is Skill learning Script and ccoa CBS, i was manage to find the line contain Skill Learning system but when i put it in ccoa CBS it gave me an error

Script 'CBS scene_Battle line 740': NameError Occured
Undefined Local Variable or method `battler' for # <scene_battle:0x139af40>

the line i want to insert and the one that make error
Code:
 if battler.target[0].is_a?(Game_Actor) and battler.current_action.kind == 1
      for target in battler.target
        skill_learning(target, target.class_id,
                        battler.current_action.skill_id)
      end
    end
  def skill_learning(actor, class_id, skill_id)
  end


ccoa scene_Battle
Code:
class Scene_Battle
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Initialize each kind of temporary battle data
    $game_temp.in_battle = true
    $game_temp.battle_turn = 0
    $game_temp.battle_event_flags.clear
    $game_temp.battle_abort = false
    $game_temp.battle_main_phase = false
    $game_temp.battleback_name = $game_map.battleback_name
    $game_temp.forcing_battler = nil
    # Initialize battle event interpreter
    $game_system.battle_interpreter.setup(nil, 0)
    # Prepare troop
    @troop_id = $game_temp.battle_troop_id
    $game_troop.setup(@troop_id)
    
    # Make other windows
    @party_command_window = Window_PartyCommand.new
    @help_window = Window_Help.new
    @help_window.back_opacity = 160
    @help_window.visible = false
    @status_window = Window_BattleStatus.new
    @message_window = Window_Message.new
    
    # Make actor command windows
    @actor_command_windows = []
    setup_actor_command_windows
    
    # Make sprite set
    @spriteset = Spriteset_Battle.new
    # Initialize wait count
    @wait_count = 0
    # Execute transition
    if $data_system.battle_transition == ""
      Graphics.transition(20)
    else
      Graphics.transition(40, "Graphics/Transitions/" +
        $data_system.battle_transition)
    end
    # Start pre-battle phase
    start_phase1
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Refresh map
    $game_map.refresh
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    for window in @actor_command_windows
      window.dispose
    end
    @party_command_window.dispose
    @help_window.dispose
    @status_window.dispose
    @message_window.dispose
    if @skill_window != nil
      @skill_window.dispose
    end
    if @item_window != nil
      @item_window.dispose
    end
    if @result_window != nil
      @result_window.dispose
    end
    # Dispose of sprite set
    @spriteset.dispose
    # If switching to title screen
    if $scene.is_a?(Scene_Title)
      # Fade out screen
      Graphics.transition
      Graphics.freeze
    end
    # If switching from battle test to any screen other than game over screen
    if $BTEST and not $scene.is_a?(Scene_Gameover)
      $scene = nil
    end
  end
  
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # If battle event is running
    if $game_system.battle_interpreter.running?
      # Update interpreter
      $game_system.battle_interpreter.update
      # If a battler which is forcing actions doesn't exist
      if $game_temp.forcing_battler == nil
        # If battle event has finished running
        unless $game_system.battle_interpreter.running?
          # Rerun battle event set up if battle continues
          unless judge
            setup_battle_event
          end
        end
        # If not after battle phase
        if @phase != 5
          # Refresh status window
          @status_window.refresh
        end
      end
    end
    # Update system (timer) and screen
    $game_system.update
    $game_screen.update
    # If timer has reached 0
    if $game_system.timer_working and $game_system.timer == 0
      # Abort battle
      $game_temp.battle_abort = true
    end
    # Update windows
    @help_window.update
    @party_command_window.update
    for i in 0..$game_party.actors.size - 1
      member = $game_party.actors[i]
      if member.battle_commands != @actor_command_windows[i].commands
        setup_actor_command_windows
      end
      if member != nil
        @actor_command_windows[i].update
      end
    end
    @status_window.update
    @message_window.update
    # Update sprite set
    @spriteset.update
    # If transition is processing
    if $game_temp.transition_processing
      # Clear transition processing flag
      $game_temp.transition_processing = false
      # Execute transition
      if $game_temp.transition_name == ""
        Graphics.transition(20)
      else
        Graphics.transition(40, "Graphics/Transitions/" +
          $game_temp.transition_name)
      end
    end
    # If message window is showing
    if $game_temp.message_window_showing
      return
    end
    # If effect is showing
    if @spriteset.effect?
      return
    end
    # If game over
    if $game_temp.gameover
      # Switch to game over screen
      $scene = Scene_Gameover.new
      return
    end
    # If returning to title screen
    if $game_temp.to_title
      # Switch to title screen
      $scene = Scene_Title.new
      return
    end
    # If battle is aborted
    if $game_temp.battle_abort
      # Return to BGM used before battle started
      $game_system.bgm_play($game_temp.map_bgm)
      # Battle ends
      battle_end(1)
      return
    end
    # If waiting
    if @wait_count > 0
      # Decrease wait count
      @wait_count -= 1
      return
    end
    # If battler forcing an action doesn't exist,
    # and battle event is running
    if $game_temp.forcing_battler == nil and
       $game_system.battle_interpreter.running?
      return
    end
    
    # Branch according to phase
    case @phase
    when 1  # pre-battle phase
      update_phase1
    when 2  # party command phase
      update_phase2
    when 3  # actor command phase
      update_phase3
    when 4  # main phase
      update_phase4
    when 5  # after battle phase
      update_phase5
    end
  end
  
  #--------------------------------------------------------------------------
  # * Start Party Command Phase
  #--------------------------------------------------------------------------
  def start_phase2
    
    # reset poses
    for actor in $game_party.actors
      reset_pose(actor)
    end
    
    # Shift to phase 2
    @phase = 2
    # Set actor to non-selecting
    @actor_index = -1
    @active_battler = nil
    # Enable party command window
    @party_command_window.active = true
    @party_command_window.visible = true
    # Disable actor command window
    for i in 0..3
      if $game_party.actors[i] != nil
        @actor_command_windows[i].active = false
        @actor_command_windows[i].visible = false
      end
    end
    # Clear main phase flag
    $game_temp.battle_main_phase = false
    # Clear all party member actions
    $game_party.clear_actions
    # If impossible to input command
    unless $game_party.inputable?
      # Start main phase
      start_phase4
    end
  end
  
  #--------------------------------------------------------------------------
  # * Actor Command Window Setup
  #--------------------------------------------------------------------------
  def phase3_setup_command_window
    # Disable party command window
    @party_command_window.active = false
    @party_command_window.visible = false
    # Enable actor command window
    for i in 0..$game_party.actors.size - 1
      if $game_party.actors[i] != nil
        @actor_command_windows[i].active = false
        @actor_command_windows[i].visible = false
        @actor_command_windows[i].index = 0
      end
    end
    @actor_command_windows[@actor_index].active = true
    @actor_command_windows[@actor_index].visible = true
  end
  
  #--------------------------------------------------------------------------
  # * Frame Update (actor command phase)
  #--------------------------------------------------------------------------
  def update_phase3
    # If enemy arrow is enabled
    if @enemy_arrow != nil
      update_phase3_enemy_select
      return
    # If actor arrow is enabled
    elsif @actor_arrow != nil
      update_phase3_actor_select
      return
    # If skill window is enabled
    elsif @skill_window != nil
      update_phase3_skill_select
      return
    # If item window is enabled
    elsif @item_window != nil
      update_phase3_item_select
      return
    end
    # If actor command window is enabled
    for i in 0..$game_party.actors.size - 1
      if @actor_command_windows[i].active
        update_phase3_basic_command
        return
      end
    end
  end
  
  #--------------------------------------------------------------------------
  # * Frame Update (actor command phase : basic command)
  #--------------------------------------------------------------------------
  def update_phase3_basic_command
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Go to command input for previous actor
      phase3_prior_actor
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Branch by actor command window cursor position
      case @active_battler.battle_commands[@actor_command_windows[@actor_index].index]
      when "Attack"  # attack
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Set action
        @active_battler.current_action.kind = 0
        @active_battler.current_action.basic = 0
        # Start enemy selection
        start_enemy_select
        return
      when "Skill"  # skill
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Set action
        @active_battler.current_action.kind = 1
        # Start skill selection
        start_skill_select
        return
      when "Defend"  # guard
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Set action
        @active_battler.current_action.kind = 0
        @active_battler.current_action.basic = 1
        # Go to command input for next actor
        phase3_next_actor
      when "Item"  # item
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Set action
        @active_battler.current_action.kind = 2
        # Start item selection
        start_item_select
        return
      when $SKILL_KINDS[0]
        $game_system.se_play($data_system.decision_se)
        @active_battler.current_action.kind = 1
        @active_battler.skill_kind = $SKILL_KINDS[0]
        start_skill_select(0 + $SKILL_OFFSET)
        return
      when $SKILL_KINDS[1]
        $game_system.se_play($data_system.decision_se)
        @active_battler.current_action.kind = 1
        @active_battler.skill_kind = $SKILL_KINDS[1]
        start_skill_select(1 + $SKILL_OFFSET)        
        return
      when $SKILL_KINDS[2]
        $game_system.se_play($data_system.decision_se)
        @active_battler.current_action.kind = 1
        @active_battler.skill_kind = $SKILL_KINDS[2]
        start_skill_select(2 + $SKILL_OFFSET)        
        return
      when $SKILL_KINDS[3]
        $game_system.se_play($data_system.decision_se)
        @active_battler.current_action.kind = 1
        @active_battler.skill_kind = $SKILL_KINDS[3]
        start_skill_select(3 + $SKILL_OFFSET)
        return
      when $SKILL_KINDS[4]
        $game_system.se_play($data_system.decision_se)
        @active_battler.current_action.kind = 1
        @active_battler.skill_kind = $SKILL_KINDS[4]
        start_skill_select(4 + $SKILL_OFFSET)
        return
      # copy and paste to add more skill kinds
      end
      return
    end
  end
  
  #--------------------------------------------------------------------------
  # * Start Enemy Selection
  #--------------------------------------------------------------------------
  def start_enemy_select
    # Make enemy arrow
    @enemy_arrow = Arrow_Enemy.new(@spriteset.viewport2)
    # Associate help window
    @enemy_arrow.help_window = @help_window
    # Disable actor command window
    for i in 0..$game_party.actors.size - 1
      if $game_party.actors[i] != nil
        @actor_command_windows[i].active = false
        @actor_command_windows[i].visible = false
      end
    end
  end
  
  #--------------------------------------------------------------------------
  # * End Enemy Selection
  #--------------------------------------------------------------------------
  def end_enemy_select
    @enemy_arrow.dispose
    @enemy_arrow = nil
    y = @active_battler.battle_commands
    x = y[@actor_command_windows[@actor_index].index]
    if x == "Attack"
      @actor_command_windows[@actor_index].active = true
      @actor_command_windows[@actor_index].visible = true
      @help_window.visible = false
    end
  end
  
  #--------------------------------------------------------------------------
  # * Start Actor Selection
  #--------------------------------------------------------------------------
  def start_actor_select
    # Make actor arrow
    @actor_arrow = Arrow_Actor.new(@spriteset.viewport2)
    @actor_arrow.index = @actor_index
    # Associate help window
    @actor_arrow.help_window = @help_window
    # Disable actor command window
    for i in 0..$game_party.actors.size - 1
      if $game_party.actors[i] != nil
        @actor_command_windows[i].active = false
        @actor_command_windows[i].visible = false
      end
    end
  end

  #--------------------------------------------------------------------------
  # * Start Skill Selection
  #--------------------------------------------------------------------------
  def start_skill_select(skill_kind = -1)
    # Make skill window
    @skill_window = Window_Skill.new(@active_battler, skill_kind)
    # Associate help window
    @skill_window.help_window = @help_window
    # Disable actor command window
    for i in 0..$game_party.actors.size - 1
      if $game_party.actors[i] != nil
        @actor_command_windows[i].active = false
        @actor_command_windows[i].visible = false
      end
    end
  end
  #--------------------------------------------------------------------------
  # * End Skill Selection
  #--------------------------------------------------------------------------
  def end_skill_select
    # Dispose of skill window
    @skill_window.dispose
    @skill_window = nil
    # Hide help window
    @help_window.visible = false
    # Enable actor command window
    @actor_command_windows[@actor_index].active = true
    @actor_command_windows[@actor_index].visible = true
  end
  
  #--------------------------------------------------------------------------
  # * Start Item Selection
  #--------------------------------------------------------------------------
  def start_item_select
    # Make item window
    @item_window = Window_Item.new
    # Associate help window
    @item_window.help_window = @help_window
    # Disable actor command window
    for i in 0..$game_party.actors.size - 1
      if $game_party.actors[i] != nil
        @actor_command_windows[i].active = false
        @actor_command_windows[i].visible = false
      end
    end
  end
  
  #--------------------------------------------------------------------------
  # * End Item Selection
  #--------------------------------------------------------------------------
  def end_item_select
    # Dispose of item window
    @item_window.dispose
    @item_window = nil
    # Hide help window
    @help_window.visible = false
    # Enable actor command window
    @actor_command_windows[@actor_index].active = true
    @actor_command_windows[@actor_index].visible = true
  end
  
  #--------------------------------------------------------------------------
  # * Start Main Phase
  #--------------------------------------------------------------------------
  def start_phase4
    # Shift to phase 4
    @phase = 4
    # Turn count
    $game_temp.battle_turn += 1
    # Search all battle event pages
    for index in 0...$data_troops[@troop_id].pages.size
      # Get event page
      page = $data_troops[@troop_id].pages[index]
      # If this page span is [turn]
      if page.span == 1
        # Clear action completed flags
        $game_temp.battle_event_flags[index] = false
      end
    end
    # Set actor as unselectable
    @actor_index = -1
    @active_battler = nil
    # Enable party command window
    @party_command_window.active = false
    @party_command_window.visible = false
    # Disable actor command window
    for i in 0..$game_party.actors.size - 1
      if $game_party.actors[i] != nil
        @actor_command_windows[i].active = false
        @actor_command_windows[i].visible = false
      end
    end
    # Set main phase flag
    $game_temp.battle_main_phase = true
    
    
    
    # Make enemy action
    for enemy in $game_troop.enemies
      reset_pose(enemy)
      enemy.make_action
    end
    # Make action orders
    make_action_orders
    # Shift to step 1
    @phase4_step = 1
  end
  
  #--------------------------------------------------------------------------
  # * Frame Update (main phase)
  #--------------------------------------------------------------------------
  def update_phase4
    case @phase4_step
    when 1
      update_phase4_step1
    when 2
      update_phase4_step2
    when 3
      update_phase4_step3
    when 4
      update_phase4_step4
    when 5
      update_phase4_step5
    when 6
      update_phase4_step6
    when 7
      update_phase4_step7
    when 8
      update_phase4_step8
    end
  end
  
  #--------------------------------------------------------------------------
  # * Frame Update (main phase step 1 : action preparation)
  #--------------------------------------------------------------------------
  def update_phase4_step1
    # Hide help window
    @help_window.visible = false
    # Determine win/loss
    if judge
      # If won, or if lost : end method
      return
    end
    
    # If an action forcing battler doesn't exist
    if $game_temp.forcing_battler == nil
      # Set up battle event
      setup_battle_event
      # If battle event is running
      if $game_system.battle_interpreter.running?
        return
      end
    end
    # If an action forcing battler exists
    if $game_temp.forcing_battler != nil
      # Add to head, or move
      @action_battlers.delete($game_temp.forcing_battler)
      @action_battlers.unshift($game_temp.forcing_battler)
    end
    # If no actionless battlers exist (all have performed an action)
    if @action_battlers.size == 0
      # Start party command phase
      start_phase2
      return
    end
    # Initialize animation ID and common event ID
    @animation1_id = 0
    @animation2_id = 0
    @common_event_id = 0
    # Shift from head of actionless battlers
    @active_battler = @action_battlers.shift
    # If already removed from battle
    if @active_battler.index == nil
      return
    end
    # Slip damage
    if @active_battler.hp > 0 and @active_battler.slip_damage?
      @active_battler.slip_damage_effect
      @active_battler.damage_pop = true
      @active_battler.set_pose($HIT, false)
    end
    # Natural removal of states
    @active_battler.remove_states_auto
    reset_pose(@active_battler)
    # Refresh status window
    @status_window.refresh
    # Shift to step 2
    @phase4_step = 2
  end
  
  #--------------------------------------------------------------------------
  # * Frame Update (main phase step 2 : start action)
  #--------------------------------------------------------------------------
  def update_phase4_step2
    # If not a forcing action
    unless @active_battler.current_action.forcing
      # If restriction is [normal attack enemy] or [normal attack ally]
      if @active_battler.restriction == 2 or @active_battler.restriction == 3
        # Set attack as an action
        @active_battler.current_action.kind = 0
        @active_battler.current_action.basic = 0
      end
      # If restriction is [cannot perform action]
      if @active_battler.restriction == 4
        # Clear battler being forced into action
        $game_temp.forcing_battler = nil
        # Shift to step 1
        @phase4_step = 1
        return
      end
    end
    # Clear target battlers
    @target_battlers = []
    # Branch according to each action
    case @active_battler.current_action.kind
    when 0  # basic
      if @active_battler.current_action.basic == 0
        if @active_battler.is_a?(Game_Actor)
          weapon = $data_weapons[@active_battler.weapon_id]
          # if we have a ranged weapon, just move forward a bit
          if (weapon != nil and weapon.element_set.include?($RANGED_ELEMENT)) or !@active_battler.moves
            make_basic_action_result
          else
            @active_battler.set_pose($MOVE_TO)
            # move to
            @phase4_step = 7
            return
          end
        else
          if @active_battler.moves
            @active_battler.set_pose($MOVE_TO)
            # move to
            @phase4_step = 7
            return
          else
            make_basic_action_result
          end
        end
      else
        make_basic_action_result
      end
    when 1  # skill
      make_skill_action_result
    when 2  # item
      make_item_action_result
    end
    # Shift to step 3
    if @phase4_step == 2
      @phase4_step = 3
    end
  end
  
  #--------------------------------------------------------------------------
  # * Frame Update (main phase step 3 : animation for action performer)
  #--------------------------------------------------------------------------
  def update_phase4_step3
    # Animation for action performer (if ID is 0, then white flash)
    if @animation1_id == 0
      @active_battler.white_flash = true
      @wait_count = [@active_battler.attack_frames * 10 - 10, 8].max
    else
      @active_battler.animation_id = @animation1_id
      @active_battler.animation_hit = true
    end
    
    if @active_battler.current_action.kind == 0 and @active_battler.current_action.basic == 0
      @active_battler.set_pose($ATTACK, false)
    end
        
    # Shift to step 4
    @phase4_step = 4
  end
  
  #--------------------------------------------------------------------------
  # * Frame Update (main phase step 4 : animation for target)
  #--------------------------------------------------------------------------
  def update_phase4_step4
    # Animation for target
    for target in @target_battlers
      target.animation_id = @animation2_id
      target.animation_hit = (target.damage != "Miss")
      if target.damage.is_a?(String)
        if target.damage == "Miss"
          target.set_pose($MISS, false)
        end
      elsif target.damage > 0
        target.set_pose($HIT, false)
      end
    end
    
    # Animation has at least 8 frames, regardless of its length
    @wait_count = 8
    # Shift to step 5
    @phase4_step = 5
  end
  
  #--------------------------------------------------------------------------
  # * Frame Update (main phase step 6 : refresh)
  #--------------------------------------------------------------------------
  def update_phase4_step6
    # Clear battler being forced into action
    $game_temp.forcing_battler = nil
    # If common event ID is valid
    if @common_event_id > 0
      # Set up event
      common_event = $data_common_events[@common_event_id]
      $game_system.battle_interpreter.setup(common_event.list, 0)
    end
    # if the battler moved to attack
    if @active_battler.current_action.kind == 0 and @active_battler.current_action.basic == 0
      # move the battler back to its base
      @phase4_step = 8
      @active_battler.set_pose($MOVE_FROM)
    else
      # Shift to step 1
      @phase4_step = 1
        def update_phase4_step6
    # Clear battler being forced into action
    $game_temp.forcing_battler = nil
    # If common event ID is valid
    if @common_event_id > 0
      # Set up event
      common_event = $data_common_events[@common_event_id]
      $game_system.battle_interpreter.setup(common_event.list, 0)
    end
    # Shift to step 1
    @phase4_step = 1
 if battler.target[0].is_a?(Game_Actor) and battler.current_action.kind == 1
      for target in battler.target
        skill_learning(target, target.class_id,
                        battler.current_action.skill_id)
      end
    end
def skill_learning(actor, class_id, skill_id)
end
end 
    end
  end
  
  #--------------------------------------------------------------------------
  # * Frame Update (main phase step 7 : move to)
  #--------------------------------------------------------------------------
  def update_phase4_step7
    if @active_battler.is_a?(Game_Actor)
        target = $game_troop.smooth_target_enemy(@active_battler.current_action.target_index)
        @active_battler.target_y = target.actual_y
        @active_battler.target_x = target.actual_x + target.width / 2
    else
      target = $game_party.smooth_target_actor(@active_battler.current_action.target_index)
      @active_battler.target_x = target.actual_x - target.width / 2
      @active_battler.target_y = target.actual_y
    end
    if @active_battler.actual_x == @active_battler.target_x and @active_battler.actual_y == @active_battler.target_y
      @active_battler.set_pose($READY)
      make_basic_action_result
      @phase4_step = 3
    end
  end
  
  #--------------------------------------------------------------------------
  # * Frame Update (main phase step 8 : move from)
  #--------------------------------------------------------------------------
  def update_phase4_step8
    @active_battler.target_x = @active_battler.base_x
    @active_battler.target_y = @active_battler.base_y
    
    if @active_battler.actual_x == @active_battler.target_x and @active_battler.actual_y == @active_battler.target_y
      # reset pose
      reset_pose(@active_battler)
      @phase4_step = 1
    end
  end

  #--------------------------------------------------------------------------
  # * Start After Battle Phase
  #--------------------------------------------------------------------------
  alias old_start_phase5 start_phase5
  def start_phase5
    for actor in $game_party.actors
      actor.set_pose($VICTORY)
    end
    old_start_phase5
  end
  
  #--------------------------------------------------------------------------
  # * Make Basic Action Results
  #--------------------------------------------------------------------------
  def make_basic_action_result
    # If attack
    if @active_battler.current_action.basic == 0
      # Set anaimation ID
      @animation1_id = @active_battler.animation1_id
      @animation2_id = @active_battler.animation2_id
      # If action battler is enemy
      if @active_battler.is_a?(Game_Enemy)
        if @active_battler.restriction == 3
          target = $game_troop.random_target_enemy
        elsif @active_battler.restriction == 2
          target = $game_party.random_target_actor
        else
          index = @active_battler.current_action.target_index
          target = $game_party.smooth_target_actor(index)
        end
      end
      # If action battler is actor
      if @active_battler.is_a?(Game_Actor)
        if @active_battler.restriction == 3
          target = $game_party.random_target_actor
        elsif @active_battler.restriction == 2
          target = $game_troop.random_target_enemy
        else
          index = @active_battler.current_action.target_index
          target = $game_troop.smooth_target_enemy(index)
        end
      end
      # Set array of targeted battlers
      @target_battlers = [target]
      # Apply normal attack results
      for target in @target_battlers
        target.attack_effect(@active_battler)
        reset_pose(target)
      end
      return
    end
    # If guard
    if @active_battler.current_action.basic == 1
      # Display "Guard" in help window
      @help_window.set_text($data_system.words.guard, 1)
      @active_battler.set_pose($GUARD)
      return
    end
    # If escape
    if @active_battler.is_a?(Game_Enemy) and
       @active_battler.current_action.basic == 2
      # Display "Escape" in help window
      @help_window.set_text("Escape", 1)
      # Escape
      @active_battler.escape
      return
    end
    # If doing nothing
    if @active_battler.current_action.basic == 3
      # Clear battler being forced into action
      $game_temp.forcing_battler = nil
      # Shift to step 1
      @phase4_step = 1
      return
    end
  end
  
  #--------------------------------------------------------------------------
  # * Make Skill Action Results
  #--------------------------------------------------------------------------
  def make_skill_action_result
    if @active_battler.is_a?(Game_Actor)
      if $USING_INDIV_SKILL_ANIM
        @active_battler.set_pose(@active_battler.skill_hash[$data_skills[@active_battler.current_action.skill_id].name], false)
      else # get animation by skill type
        @active_battler.set_pose(@active_battler.skill_type_hash[@active_battler.skill_kind], false)
      end
    else
      @active_battler.set_pose($SKILL, false)
    end
    # Get skill
    @skill = $data_skills[@active_battler.current_action.skill_id]
    # If not a forcing action
    unless @active_battler.current_action.forcing
      # If unable to use due to SP running out
      unless @active_battler.skill_can_use?(@skill.id)
        # Clear battler being forced into action
        $game_temp.forcing_battler = nil
        # Shift to step 1
        @phase4_step = 1
        return
      end
    end
    # Use up SP
    @active_battler.sp -= @skill.sp_cost
    # Refresh status window
    @status_window.refresh
    # Show skill name on help window
    @help_window.set_text(@skill.name, 1)
    # Set animation ID
    @animation1_id = @skill.animation1_id
    @animation2_id = @skill.animation2_id
    # Set command event ID
    @common_event_id = @skill.common_event_id
    # Set target battlers
    set_target_battlers(@skill.scope)
    # Apply skill effect
    for target in @target_battlers
      target.skill_effect(@active_battler, @skill)
      reset_pose(target)
    end
  end
  
  #--------------------------------------------------------------------------
  # * Make Item Action Results
  #--------------------------------------------------------------------------
  def make_item_action_result
    @active_battler.set_pose($ITEM, false)
    # Get item
    @item = $data_items[@active_battler.current_action.item_id]
    # If unable to use due to items running out
    unless $game_party.item_can_use?(@item.id)
      # Shift to step 1
      @phase4_step = 1
      return
    end
    # If consumable
    if @item.consumable
      # Decrease used item by 1
      $game_party.lose_item(@item.id, 1)
    end
    # Display item name on help window
    @help_window.set_text(@item.name, 1)
    # Set animation ID
    @animation1_id = @item.animation1_id
    @animation2_id = @item.animation2_id
    # Set common event ID
    @common_event_id = @item.common_event_id
    # Decide on target
    index = @active_battler.current_action.target_index
    target = $game_party.smooth_target_actor(index)
    # Set targeted battlers
    set_target_battlers(@item.scope)
    # Apply item effect
    for target in @target_battlers
      target.item_effect(@item)
      reset_pose(target)
    end
  end
  
  def setup_actor_command_windows
    if @actor_command_windows != []
      for i in 0..@actor_command_windows.size - 1
        @actor_command_windows[i].dispose
      end
    end
    @actor_command_windows = []
    for i in 0..$game_party.actors.size - 1
      member = $game_party.actors[i]
      if member != nil
      @actor_command_windows[i] = Window_BattleCommand.new(member, 160)
      @actor_command_windows[i].x = 0
      @actor_command_windows[i].y = 480 - @status_window.height - @actor_command_windows[i].height
      @actor_command_windows[i].back_opacity = 160
      @actor_command_windows[i].active = false
      @actor_command_windows[i].visible = false
      end
    end
  end
  
  # reset the current pose
  def reset_pose(actor)
    if actor == nil
      return
    end
    
    # highest priority is dead
    if actor.is_a?(Game_Actor) and actor.dead?
      actor.set_pose($DEAD)
      return
    end
    
    #guarding
    if actor.guarding?
      actor.set_pose($GUARD)
      return
    end
    
    # next is low hp
    if actor.is_a?(Game_Actor)
      if actor.low_hp?
        actor.set_pose($LOW_HP)
        return
      end
      # satus effects
      rating = 0
      pose = -1
      j = 0
      for i in $STATES_ANIMATED
        if actor.states.include?(i)
          if $data_states[i].rating >= rating
            pose = j
            rating = $data_states[i].rating
          end
        end
        j += 1
      end
      if pose != -1
        actor.set_pose($VICTORY + pose + 1)
        return
      end
    end
    actor.set_pose($READY)
  end
end

Can someone help me with this?
 
I try it the battler error was fixed but it gave another error

Undefined method `[]' for nil : Nilclass


From this line
if battler.target[0].is_a?(Game_Actor) and battler.current_action.kind == 1
 
I have no idea what the script does, and have not tested it, but try this:
Code:
 if @target_battlers[0].is_a?(Game_Actor) and battler.current_action.kind == 1
      for target in @target_battlers
        skill_learning(target, target.class_id,
                        battler.current_action.skill_id)
      end
    end
  def skill_learning(actor, class_id, skill_id)
  end
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top