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.

Bit of a bug in the individual commands/skill kinds set

I've noticed I get NoMethod errors in line 303 of the individual command script (with ccoa's skill kind stuff added in) when I load a game. If I start a new game, it works fine. But after I shut it down, restart it and load from the file, The command shows up in my character's command list, but when I select it, it gives me the error.

Code:
      when $SKILL_KINDS[0] #this is line 303
        $game_system.se_play($data_system.decision_se)
        @active_battler.current_action.kind = 1
        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
        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
        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
        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
        start_skill_select(4 + $SKILL_OFFSET)
        return
 
perhaps the full script would work here.

Code:
class Game_Actor < Game_Battler
  attr_accessor :battle_commands
  
  alias ibc_initialize initialize
  def initialize(actor_id)
    ibc_initialize(actor_id)
    @battle_commands = ["Attack", "Defend", "Item"]
    $SKILL_KINDS = ["Magic", "E-Sword", "Clawtech", "Theeder", "Recall"]
    $SKILL_OFFSET = 9
  end
end
  
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 actor command window
    @actor_command_windows = []
    setup_actor_command_windows
    # 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 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 i in 0..$game_party.actors.size - 1
      @actor_command_windows[i].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
      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
    @phase = 2
    @actor_index = -1
    @active_battler = nil
    @party_command_window.active = true
    @party_command_window.visible = true
    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
    $game_temp.battle_main_phase = false
    $game_party.clear_actions
    unless $game_party.inputable?
      start_phase4
    end
  end
  
  #--------------------------------------------------------------------------
  # * Actor Command Window Setup
  #--------------------------------------------------------------------------
  def phase3_setup_command_window
    @party_command_window.active = false
    @party_command_window.visible = false
    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
    @actor_command_windows[@actor_index].active = true
    @actor_command_windows[@actor_index].visible = true
    @actor_command_windows[@actor_index].index = 0
  end
  
  #--------------------------------------------------------------------------
  # * Frame Update (actor command phase)
  #--------------------------------------------------------------------------
  def update_phase3
    if @enemy_arrow != nil
      update_phase3_enemy_select
      return
    elsif @actor_arrow != nil
      update_phase3_actor_select
      return
    elsif @skill_window != nil
      update_phase3_skill_select
      return
    elsif @item_window != nil
      update_phase3_item_select
      return
    end
    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 Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      phase3_prior_actor
      return
    end
    if Input.trigger?(Input::C)
      y = @active_battler.battle_commands
      x = y[@actor_command_windows[@actor_index].index]
      case x
      when "Attack"
        $game_system.se_play($data_system.decision_se)
        @active_battler.current_action.kind = 0
        @active_battler.current_action.basic = 0
        start_enemy_select
      when "Defend"
        $game_system.se_play($data_system.decision_se)
        @active_battler.current_action.kind = 0
        @active_battler.current_action.basic = 1
        phase3_next_actor
      when $SKILL_KINDS[0]
        $game_system.se_play($data_system.decision_se)
        @active_battler.current_action.kind = 1
        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
        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
        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
        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
        start_skill_select(4 + $SKILL_OFFSET)
        return
      when "Item"
        $game_system.se_play($data_system.decision_se)
        @active_battler.current_action.kind = 2
        start_item_select
      # when "Your Command Here"
      # Place code for additional battle commands here.
      end
      return
    end
  end
  
  #--------------------------------------------------------------------------
  # * Start Enemy Selection
  #--------------------------------------------------------------------------
  def start_enemy_select
    @enemy_arrow = Arrow_Enemy.new(@spriteset.viewport1)
    @enemy_arrow.help_window = @help_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
    @actor_arrow = Arrow_Actor.new(@spriteset.viewport2)
    @actor_arrow.index = @actor_index
    @actor_arrow.help_window = @help_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
    @skill_window.dispose
    @skill_window = nil
    @help_window.visible = false
    @actor_command_windows[@actor_index].active = true
    @actor_command_windows[@actor_index].visible = true
  end
  
  #--------------------------------------------------------------------------
  # * Start Item Selection
  #--------------------------------------------------------------------------
  def start_item_select
    @item_window = Window_Item.new
    @item_window.help_window = @help_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
    @item_window.dispose
    @item_window = nil
    @help_window.visible = false
    @actor_command_windows[@actor_index].active = true
    @actor_command_windows[@actor_index].visible = true
  end
  
  #--------------------------------------------------------------------------
  # * Start Main Phase
  #--------------------------------------------------------------------------
  def start_phase4
    @phase = 4
    $game_temp.battle_turn += 1
    for index in 0...$data_troops[@troop_id].pages.size
      page = $data_troops[@troop_id].pages[index]
      if page.span == 1
        $game_temp.battle_event_flags[index] = false
      end
    end
    @actor_index = -1
    @active_battler = nil
    @party_command_window.active = false
    @party_command_window.visible = false
    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
    $game_temp.battle_main_phase = true
    for enemy in $game_troop.enemies
      enemy.make_action
    end
    make_action_orders
    @phase4_step = 1
  end
  
  def setup_actor_command_windows
    if @actor_command_windows != []
      for window in @actor_command_windows
        window.dispose
      end
    end
    @actor_command_windows = []
    for i in 0...$game_party.actors.size
      member = $game_party.actors[i]
      if member != nil
        @actor_command_windows[i] = Window_BattleCommand.new(member, 160)
        @actor_command_windows[i].x = i * 160
        @actor_command_windows[i].y = 160
        @actor_command_windows[i].back_opacity = 160
        @actor_command_windows[i].active = false
        @actor_command_windows[i].visible = false
      end
    end
  end
end

class Interpreter
  def command_129
    actor = $game_actors[@parameters[0]]
    if actor != nil
      if @parameters[1] == 0
        if @parameters[2] == 1
          $game_actors[@parameters[0]].setup(@parameters[0])
        end
        $game_party.add_actor(@parameters[0])
        if $game_temp.in_battle
          $scene.setup_actor_command_windows
        end
      else
        $game_party.remove_actor(@parameters[0])
        if $game_temp.in_battle
          $scene.setup_actor_command_windows
        end
      end
    end
    return true
  end
end

class Window_BattleCommand < Window_Selectable
  attr_reader :commands
  
  def initialize(actor, width)
    @actor = actor
    super(0, 0, width, 160)
    self.x = -9999
    @column_max = 1
    @item_max = @actor.battle_commands.size
    @commands = @actor.battle_commands
    if @commands == []
      name = actor.name
      print("Error: " + name + " must have at least one battle command.")
      exit
    end
    self.contents = Bitmap.new(width - 32, @item_max * 32)
    refresh
    self.index = 0
  end
  
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i, normal_color)
    end
  end
  
  def draw_item(index, color)
    self.contents.font.color = color
    rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[index])
  end
  
  def disable_item(index)
    draw_item(index, disabled_color)
  end
end
 
Hmm, lemme try this. You asked the value of skill_kinds [0], yes? well, the skill offset's supposed to be 9, so skill_kinds [0] would be 9. As for the variable used in the case, it's simply 'x'.

Code:
y = @active_battler.battle_commands
x = y[@actor_command_windows[@actor_index].index]
case x
 

Anonymous

Guest

$SKILL_KINDS is not an array or a hash, apparently. Make sure you have a line that says $SKILL_KINDS = [], where the array contains your values separated by commas. Also, press Ctrl+Shift+F and find any lines with $SKILL_KINDS on it and make sure that it's not being set to any boolean(true/false) or numeric(1,2,3,4,5) values. If a line has a single = sign (instead of ==), it's being given a new value. Hope that helps!
 

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