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.

[Resolved] Always Have Something Equip

Okay right now if you have a bronze helm equip, you can take it off and wear nothing. I want to script it so that you CANNOT take it off for nothing, but you can take it off for other helmets.
In other words, your starting equipment cannot be unequipped unless it is replaced with new equipment. I have no idea where to begin, and any help would be really appreciated.

~Thanks.
 
Well, there are 2 ways:

1) Only do this if you do direct mods to the default classes. I strongly don't suggest this method, as any script which modifies the method could render this useless (such as the SDK).

In Scene_Equip, find
Code:
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Play equip SE
      $game_system.se_play($data_system.equip_se)
      # Get currently selected data on the item window
      item = @item_window.item
      # Change equipment
      @actor.equip(@right_window.index, item == nil ? 0 : item.id)
Change that with:
Code:
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Get currently selected data on the item window
      item = @item_window.item
      # return if nil item
      if item == nil
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Play equip SE
      $game_system.se_play($data_system.equip_se)
      # Change equipment
      @actor.equip(@right_window.index, item == nil ? 0 : item.id)

If you do this, I also suggest doing this method below, as a second chance percaution, incase some script uses the Game_Actor#equip method.

2) Just add this below all your other scripts.
Code:
class Game_Actor
  alias_method :seph_mustequipsomething_gmactr_equip, :equip
  def equip(equip_type, id)
    if id == 0
      $game_system.se_play($data_system.buzzer_se)
      return
    end
    seph_mustequipsomething_gmactr_equip(equip_type, id)
  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