Block Actors / Classes from fighting bare-handed

Good Morning / Day / Afternoon / Evening everyone.


I have a request for a certain script.

Basically, my actors/classes will start with a weapon, but the thing is I don't want the ability to remove the weapon for them to fight barehanded, I only want to be able to switch to a different weapon they can equip when available.

Is this possible to code?

Any help would be appreciated.
Yeah, you can do this with a script that changes the item unequip method to only process if the new item isn't nil.
Could you please show me how to do it?
You don't ask me for much, do you? At this point I think I've made more of your game than you have. 😉
Code:
class Game_Actor < Game_Battler
  def change_equip(slot_id, item)
    return if slot_id == 0 && !item
    return unless trade_item_with_party(item, equips[slot_id])
    return if item && equip_slots[slot_id] != item.etype_id
    @equips[slot_id].object = item
    refresh
  end
end
You don't ask me for much, do you? At this point I think I've made more of your game than you have. 😉
Code:
class Game_Actor < Game_Battler
  def change_equip(slot_id, item)
    return if slot_id == 0 && !item
    return unless trade_item_with_party(item, equips[slot_id])
    return if item && equip_slots[slot_id] != item.etype_id
    @equips[slot_id].object = item
    refresh
  end
end
This statement is true much to my embarassment. I'm only really good at making things look and sound good. Though I really try to learn a bit everytime I recieve a piece of code so I don't have to ask for help as much as I usually do. Even going so far as doing tutorials on RGSS3 and do very basic things.

02.06.2021_01.17.08_REC.png


The script works as intended, it won't let me unequip the weapon at all, but it still sort of has the option as you see there... could we eliminate this entirely?

what would I need to add on the already made code?

Thank you so much for this.
That would be slightly more complex; it would require two main changes to Window_EquipItem:

1. overwrite cursor_up and cursor_down to include a check for the slot ID being 0 and the item at the new index being nil, and don't select the new index if so.
2 modify ok_enabled? to include a check for the slot ID being 0 and the number of equippable weapons being greater than 0.
I don't know if this makes difference but i'm using Tsukihime's Core Equip Slots


Can I modify this within that script?


02.06.2021_12.03.59_REC.png


at the risk of making a tool of myself... I am obviously doing something wrong as this gave me an error and I don't know what ok?_ enabled means? Is it supposed to be on the code because I couldn't find it.
I don't know if this makes difference but i'm using Tsukihime's Core Equip Slots

https://himeworks.com/2015/11/equip-slots-core/​



Can I modify this within that script?


02.06.2021_12.03.59_REC.png



at the risk of making a tool of myself... I am obviously doing something wrong as this gave me an error and I don't know what ok?_ enabled means? Is it supposed to be on the code because I couldn't find it.
Your error was with the , right?
Placing cursor_down there just tells it to call the method cursor_down.
It will trace back and find it in Window_Selectable. Running the code and either give an error or move the cursor down one spot (if it is able to do so).

If you look at the rest of the code in that method (def include?(item)),
they all have return ...
so wouldn't you think that anything you add would need to be the same.
The fact that you are struggling with this means you don't know very much about ruby.
So I would like to ask, are you willing and wanting to learn, or do you just want people to write code for your game?

If you want to learn then please go through some ruby tutorials. There are a few here in the forums and if you wait for a sale you can buy one on Udemy for about 15Can.
Ruby:
class Window_EquipItem < Window_ItemList
  def include?(item)
    return false if @slot_id == 0 && item == nil
    return true if item == nil && @slot_id != 0
    return false unless item.is_a?(RPG::EquipItem)
    return false if @slot_id < 0
    return false if item.etype_id != @actor.equip_slots[@slot_id]
    return @actor.equippable?(item)
  end
end
Yes, I'm starting to understand I should study a bit of Ruby especially if I want to make a bit more complex stuff...

Original thread: https://forums.rpgmakerweb.com/threads/block-actors-classes-from-fighting-bare-handed.137071/