New account registration is temporarily disabled.

[RMVX] NEED HELP DISALLOWING THE PLAYER TO REMOVE WEAPON (BAREHANDED)

Posts

Pages: 1
Basically, I want to remove the ability to go Barehanded. However I still want to go naked for the armor.
I tried to look for myself in the script, if I could remove the option to select the empty space, but I couldn't find anything.

Is there perchance a tiny script for a problem like this? Or is it even possible?
Marrend
Guardian of the Description Thread
21806
I'm not 100% sure myself, but, I'd take a look at Scene_Equip first, then maybe Window_EquipItem?
SunflowerGames
The most beautiful user on RMN!
13323

A work around would involve checking if the character is equipped all the time using a parallel process. If not, then equip with default weapon (first one in the game that can't be sold.) The player could go bare hands, but at as soon as the player the exits the menu the character gets equipped with a basic weapon.
I couldn't find anything on Scene_Equip and apparently the Weapon and Armor slots are related to Game_Actor. I do see something in Window_EquipItem however and my guess is that that is what I'm looking for.


As far as I can tell, I need to either remove something here or add something new. But with what these lines indicate, I don't think there is a need to remove anything.
I'm bad at/barely know anything about scripting, so I wouldn't be able to do the latter unfortunately.

Edit: @kory_toombs sorry, your message didn't pop up.
Honestly, that gives a false impression to the player imo and I would rather have the Player just not select the empty space(removed)/ unable to select the empty space.
Give me a couple hours, I'll see if I can figure something out for you. I love working with RMVX's script database, and I like challenging myself to do new things. I'll see if I can make this work.
I tried a quick hack of Window_EquipItem to remove the barehand item, and Scene_Equip to prevent the user trying to equip something when there's no options. Hopefully this does the trick!

Not tested with any other scripts.

Demo project

Script:
class Window_EquipItem < Window_Item

  # Remove the barehand option from the window selection
  # Note that this doesn't matter if NO equipment selections are possible
  alias :barehanded_include? :include? unless $@
  def include?(item)
    # Don't include an nil item if our equip_type is 0 (weapons), this will
    # remove the empty slot when there are >0 other weapons available
    return @equip_type > 0 if item == nil
    # Otherwise call the original include? method
    return barehanded_include?(item)
  end
  
  def item_count
    return @data.length
  end
  
end


class Scene_Equip < Scene_Base
  
  alias :barehanded_update_equip_selection :update_equip_selection unless $@
  
  def update_equip_selection
    # If the user is selecting an equip slot that has zero items to equip,
    # play the buzzer and deny the selection. 
    # Note that no-armors won't trigger this because an empty item (naked) 
    # means there is ONE item theey can equip and won't trip this code
    if Input.trigger?(Input::C) and @item_window.item_count == 0
      Sound.play_buzzer
      return
    end
    # Otherwise call the original update method. This will let the player
    # select/exit/etc normally
    barehanded_update_equip_selection
  end
end

e: oh no, I started this before I saw Strak's message. Sorry!
@GreatRedSpirit Hey, if it works, then awesome! This is what I was able to put together. Looks like your code is a bit simpler and more plug-and-play, and possibly actually does what ShinNessTen is looking for more accurately.

What I've got is a slight re-write to the update_item_selection method in Scene_Equip. This doesn't prevent you from highlighting the barehanded option, but if you try to select it, a buzzer will play, basically indicating that you cannot unequip the player. It also works for two weapon fighting. All you'd need to do is replace everything from "def update_item_selection" to the end of the script in "Scene_Equip" with this code. Maybe not the most effective method, but in my own game development, this is basically the method I would use for rewriting the base scripts.

def update_item_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      @equip_window.active = true
      @item_window.active = false
      @item_window.index = -1
    elsif Input.trigger?(Input::C)
      if @equip_window.index == 0 and @item_window.item == nil
        Sound.play_buzzer
      elsif @equip_window.index == 1 and @actor.two_swords_style and @item_window.item == nil
        Sound.play_buzzer
      else
        Sound.play_equip
        @actor.change_equip(@equip_window.index, @item_window.item)
        @equip_window.active = true
        @item_window.active = false
        @item_window.index = -1
        @equip_window.refresh
        @element_window.refresh
        for item_window in @item_windows
          item_window.refresh
        end
      end
    end
  end

Well, whatever method you decide to use, hopefully this helps!

EDIT: Well, darn it, look at that. I did add an extra end statement. Fixed the snippet. Hopefully. I guess it doesn't matter now XD
Who would've thought I'd get two for the price of one? lol
I tried both so that no ones work would be gone to waste.

Unfortunately Straks script crashed whenever I entered the Equipment Menu in my Game. GreatRedSpirits worked just fine, however.
Regardless, thank you to the both of you!
Hmmm... I may have left out an end statement. Or added one. I'm great at reworking my own game, and this snippet worked when I tested it myself, but I'm not so good at creating user-friendly plug-and-play scripts. That's not something I've really had any practice with, so this was an interesting experiment. I wouldn't mind taking on new challenges though, so if you need any more help with scripting in RMVX, please don't hesitate to ask. I'll work on learning more about Ruby (still completely self-taught) so that I can make more efficient scripts.
Pages: 1