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.

Is it possible to change a class' equipment?

TSOVCL

Member

My game features a system similar to the sphere grid of FFX, and a key element of the system is the ability to learn how to equip more weapons/armour. However, I can see no way to change what equipment a class can use after the initial possibilities.

For example, one of my characters starts off with the ability to use swords, and so their class can initially equip only swords. But later on, they would gain the ability to also use axes, which would require the class' possible equippable weapons to be changed during gameplay. Is there a way to do this withing the game's standard programming, or would I have to find a script to do this for me?

If all else fails, I'll have to make a compeltely seperate class every time a character learns how to equip new weapons, which would be ridiculously cumbersome.
 

Atoa

Member

Code:
#==============================================================================

# ** Game_Actor

#==============================================================================

class Game_Actor < Game_Battler

  #--------------------------------------------------------------------------

  attr_accessor :eqp_weapons

  attr_accessor :eqp_armors

  #--------------------------------------------------------------------------

  alias add_equipable_setup setup

  def setup(actor_id)

    @eqp_weapons = []

    @eqp_armors = []

    add_equipable_setup(actor_id)

  end

  #--------------------------------------------------------------------------

  alias add_equipable_equippable? equippable?

  def equippable?(item)

    return true if item.is_a?(RPG::Weapon) and @eqp_weapons.include?(item.id)

    return true if item.is_a?(RPG::Armor) and @eqp_armors.include?(item.id)

    return add_equipable_equippable?(item)

  end

end

 

#==============================================================================

# ** Interpreter

#==============================================================================

class Interpreter

  #--------------------------------------------------------------------------

  def add_equippable_weapon(actor_id, equip_id)

    $game_actors[actor_id].eqp_weapons << equip_id

    $game_actors[actor_id].eqp_weapons.uniq!

  end

  #--------------------------------------------------------------------------

  def add_equippable_armor(actor_id, equip_id)

    $game_actors[actor_id].eqp_armors << equip_id

    $game_actors[actor_id].eqp_armors.uniq!

  end

end
I've made this small code so you can add new equippable items for actors. Just paste between Main and Scene Debug.
To add new equippable items make an script call and add
add_equippable_weapon(actor id, weapon id) # for weapons
add_equippable_armor(actor id, armor id) # for armors
 

TSOVCL

Member

Hrm, now the game runs perfectly, but whenever I try to initiate the script, nothing changes.

I've called a script which says, "add_equippable_weapon(1, 23) #". So, teoretically, I should be able to have character 1 equip weapon 23, but he can still only equip the weapons I've dictated his class can equip on the class menu. Samething happens with armour.

(Incidentally, thanks for the help, by the way, even if there are a few kerfuffles.)
 

TSOVCL

Member

I've also, by the way, tried every combination of spaces and extra 0s and whatnot imaginable, (add_equippable_weapon(1,23)#, add_equippable_weapon(01, 23) #, etc. etc.), so I doubt the issue's just my call script grammar.
 

Atoa

Member

RMXP and its IDIOT code...
It's creates an method to check wich equip is equippable, but it DON'T use it to make the available item list on the menu.

if you're not using any custom script that might change the refresh from Window_Equip_Item, just past it between Main and Scene_Debug.
Code:
#==============================================================================

# ** Game_Actor

#==============================================================================

class Game_Actor < Game_Battler

  #--------------------------------------------------------------------------

  attr_accessor :eqp_weapons

  attr_accessor :eqp_armors

  #--------------------------------------------------------------------------

  alias add_equipable_setup setup

  def setup(actor_id)

    @eqp_weapons = []

    @eqp_armors = []

    add_equipable_setup(actor_id)

  end

  #--------------------------------------------------------------------------

  alias add_equipable_equippable? equippable?

  def equippable?(item)

    return true if item.is_a?(RPG::Weapon) and @eqp_weapons.include?(item.id)

    return true if item.is_a?(RPG::Armor) and @eqp_armors.include?(item.id)

    return add_equipable_equippable?(item)

  end

end

 

#==============================================================================

# ** Interpreter

#==============================================================================

class Interpreter

  #--------------------------------------------------------------------------

  def add_equippable_weapon(actor_id, equip_id)

    $game_actors[actor_id].eqp_weapons << equip_id

    $game_actors[actor_id].eqp_weapons.uniq!

  end

  #--------------------------------------------------------------------------

  def add_equippable_armor(actor_id, equip_id)

    $game_actors[actor_id].eqp_armors << equip_id

    $game_actors[actor_id].eqp_armors.uniq!

  end

end

 

#==============================================================================

# ** Window_EquipItem

#==============================================================================

class Window_EquipItem < Window_Selectable

  #--------------------------------------------------------------------------

  def refresh

    if self.contents != nil

      self.contents.dispose

      self.contents = nil

    end

    @data = []

    if @equip_type == 0

      weapon_set = $data_classes[@actor.class_id].weapon_set + @actor.eqp_weapons

      for i in 1...$data_weapons.size

        if $game_party.weapon_number(i) > 0 and weapon_set.include?(i)

          @data.push($data_weapons[i])

        end

      end

    end

    if @equip_type != 0

      armor_set = $data_classes[@actor.class_id].armor_set + @actor.eqp_armors

      for i in 1...$data_armors.size

        if $game_party.armor_number(i) > 0 and armor_set.include?(i)

          if $data_armors[i].kind == @equip_type-1

            @data.push($data_armors[i])

          end

        end

      end

    end

    @data.push(nil)

    @item_max = @data.size

    self.contents = Bitmap.new(width - 32, row_max * 32)

    for i in 0...@item_max-1

      draw_item(i)

    end

  end

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