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.

Help: Custom Commands For Party Members

Hi guys this is what I'm working on at the moment:

I'm trying to make it so each one of my characters has a differnat set of commands come up when they are selecting what to do in battle.

With in Scene_battle
Def main
...
    case $game_party.actor[index] #<<<<<<<<<<<<<<<<<<<can't figure out what to put here.
      when 1
        s1 = $data_system.words.attack
        s2 = "Arcuárius"                        #Archery Skills
        s3 = $data_system.words.guard
        s4 = $data_system.words.item
        s5 = "Familiars"                        #Nature Magic Skills
        @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4, s5])
        @actor_command_window.y = 290
      when 2

      Etc....

Cheers.
 

khmp

Sponsor

Code:
$game_party.actors[0].id

That will give you the party leader's id. And initialize the actor_command window to whatever skills are associated with his id. Later on in the Scene you can get a hold of @actor_index and use that in place of zero. However that doesn't change the fact that the window will stick with whatever commands it's first fed. Like if you create a command window with the following commands, "A", "B", "C". The commands aren't going to change ever. Until either a new window is created or you change the way something works. Below I gave you the method to change a command within a Window_Command object on the fly, while the game runs. Next. Institute an associative array tied to an actor's id. When fed an id it will give you back the skills associated with that actor. Using the constant below as an example I'll try to get actor 2 of the databases skills.
Code:
skills = Special_Skills[2]
"skills" will hold a 2 element array now. The first element, [Ó¨], will contain the skill associated with the actor. The second element, [1], will contain the magic associated with the actor. So anyway back to the most important thing and that's adjusting the actor command window with user changes. Like I said there's a method below for changing the commands that are displayed. And now at the time the method called before the window is displayed to the user @actor_index is valid and we can use it to get the skills associated with whatever actor is the current battler.
Code:
@actor_command_window[1] = Special_Skills[$game_party.actors[@actor_index].id][0]
@actor_command_window[4] = Special_Skills[$game_party.actors[@actor_index].id][1]

This next part is all on you. The magic skill, whatever it is, the fifth command, needs to do something when selected. That work is handled within update_phase3_basic_command inside Scene_Battle 3.

The code:
Code:
#==============================================================================
# ** Window_Command
#------------------------------------------------------------------------------
#  This window deals with general command choices.
#==============================================================================

class Window_Command < Window_Selectable
  #--------------------------------------------------------------------------
  # * Set Commands
  #     index : the index of the command you want to change.
  #     text  : the text you want the command to change to.
  #--------------------------------------------------------------------------
  def []=(index, text)
    @commands[index] = text
    self.draw_item(index, normal_color)
  end
end

#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle
  #--------------------------------------------------------------------------
  # * Constant Variables
  #--------------------------------------------------------------------------
  Special_Skills = {
    1 => ['Arcuárius', 'Familiars'],
    2 => ['Something', 'Magic Something'],
    3 => ['Different', 'Magic Different'],
  }
  Special_Skills.default = ['Skills', 'Magic']
  #--------------------------------------------------------------------------
  # * Main Processing                                              !OVERRIDE!
  #--------------------------------------------------------------------------
  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
    s1 = $data_system.words.attack
    s2 = Special_Skills.default[0]
    s3 = $data_system.words.guard
    s4 = $data_system.words.item
    s5 = Special_Skills.default[1]
    @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4, s5])
    @actor_command_window.height = 160
    @actor_command_window.y = 160
    @actor_command_window.back_opacity = 160
    @actor_command_window.active = false
    @actor_command_window.visible = false
    # 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
    @actor_command_window.dispose
    @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
  #--------------------------------------------------------------------------
  # * Actor Command Window Setup                                   !OVERRIDE!
  #--------------------------------------------------------------------------
  def phase3_setup_command_window
    # Disable party command window
    @party_command_window.active = false
    @party_command_window.visible = false
    # Enable actor command window
    @actor_command_window.active = true
    @actor_command_window.visible = true
    @actor_command_window[1] = 
      Special_Skills[$game_party.actors[@actor_index].id][0]
    @actor_command_window[4] = 
      Special_Skills[$game_party.actors[@actor_index].id][1]
    # Set actor command window position
    @actor_command_window.x = @actor_index * 160
    # Set index to 0
    @actor_command_window.index = 0
  end
end

Good luck with it dissonant1! :thumb:
 
Thanks khmp...

Got that to work in the default rmxp projects now I just need to implement it into my CBS, few errors coming up but I'll find out why...

Thanks a heap, life saver...
 

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