Forbid the character from unequipping weapon in inventory.

Kurot

Villager
Member
Joined
Jun 5, 2016
Messages
17
Reaction score
5
First Language
Portuguese
Primarily Uses
RMMV
How do I forbid the character from unequipping the weapon he starts in the game and being left with nothing in place?

I need that somehow he can only exchange the weapons for other weapons, so that he can never be without anything. Is it possible?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
33,741
Reaction score
8,519
First Language
German
Primarily Uses
RMMV
you can seal or fix the equipment slots with traits, but that would stop them from changing the weapons at all.
you can use a parallel process event to re-equip something but that will either increase lag or not be immediatly as well as having a few other quirks.

to really prevent the "unequip" option only you'll need a plugin.
 

Kurot

Villager
Member
Joined
Jun 5, 2016
Messages
17
Reaction score
5
First Language
Portuguese
Primarily Uses
RMMV
Just to conclude, I got what I wanted with the Zevia plugin, which I found on this link:


I had only a small problem with the plugin. Because despite preventing him from removing the weapon with the Clear command, when I clicked on Optimize or Formation he removed the weapon anyway.

So I just added a few more commands and managed to fix.

JavaScript:
/*:
* @plugindesc This plugin allows users to specify equipment slots on an Actor that cannot be unequipped
* in a way that would leave them empty.
* @author Zevia
*
* @help If the option to prevent all actors from unequipping items without replacing
* them is true, then this Plugin does not require any further configuration and no
* Actor will be able to unequip an item without replacing it.
* If the option is false, then within an Actor's note box, you can specify which
* slot IDs should not be unequippable without a replacement. By default, the
* slots are:
* 0: Weapon
* 1: Shield
* 2: Head
* 3: Body
* 4: Accessory
*
* So, if you wanted an Actor to always require an item in the Body slot, you would
* put <preventBlankEquip: 3>. You can prevent multiple slots by comma-separating
* each slot ID. If you want to prevent unequipping without replacements for the
* weapon and shield slot, you would put <preventBlankEquip: 0, 1>
*
* If the Prevent All Actors & Slots option is true, then the clear command will be
* removed from the equip menu.
*
* @param shouldPreventAll
* @text Prevent All Actors & Slots
* @type boolean
* @desc Whether every Actor should be unable to unequip an item without a replacement for all equipment slots.
* @default false
*/

(function(module) {
    'use strict';

    module.Zevia = module.Zevia || {};
    var PreventBlankEquip = module.Zevia.PreventBlankEquip = {};
    var shouldPreventAll = !!PluginManager.parameters('PreventBlankEquip').shouldPreventAll.match(/true/i);

    PreventBlankEquip.shouldPreventEquip = function(actor, slotId) {
        if (shouldPreventAll) { return true; }

        var meta = $dataActors[actor._actorId].meta.preventBlankEquip;
        if (!meta) { return false; }

        var slotIds = meta.match(/\d+/g);
        if (!slotIds || !slotIds.length) { return false; }

        return slotIds.indexOf('' + slotId) !== -1;
    };

    PreventBlankEquip.onItemOk = Scene_Equip.prototype.onItemOk;
    Scene_Equip.prototype.onItemOk = function() {
        if (this._itemWindow.item() || !PreventBlankEquip.shouldPreventEquip(this._actor, this._slotWindow.index())) {
            PreventBlankEquip.onItemOk.call(this);
            return;
        }

        SoundManager.playBuzzer();
        this._itemWindow.activate();
    };

    PreventBlankEquip.clearEquipments = Game_Actor.prototype.clearEquipments;
    Game_Actor.prototype.clearEquipments = function() {
        var maxSlots = this.equipSlots().length;
        for (var i = 0; i < maxSlots; i++) {
            if (this.isEquipChangeOk(i) && !PreventBlankEquip.shouldPreventEquip(this, i)) {
                this.changeEquip(i, null);
            }
        }
    };

    PreventBlankEquip.optimizeEquipments = Game_Actor.prototype.optimizeEquipments;
    Game_Actor.prototype.optimizeEquipments = function() {
        var maxSlots = this.equipSlots().length;
        this.clearEquipments();
        for (var i = 0; i < maxSlots; i++) {
            if (this.isEquipChangeOk(i) && !PreventBlankEquip.shouldPreventEquip(this, i)) {
                this.changeEquip(i, this.bestEquipItem(i));
            }
        }
    };

    PreventBlankEquip.makeCommandList = Window_EquipCommand.prototype.makeCommandList;
    Window_EquipCommand.prototype.makeCommandList = function() {
        if (!shouldPreventAll) {
            PreventBlankEquip.makeCommandList.call(this);
            return;
        }

        this.addCommand(TextManager.equip2, 'equip');
        this.addCommand(TextManager.optimize, 'optimize');
    };
})(window);
 
Last edited:

Aesica

undefined
Veteran
Joined
May 12, 2018
Messages
1,826
Reaction score
1,731
First Language
English
Primarily Uses
RMMV
I know it's kind of cliche, but... "there's a Yanfly plugin for that." YEP_EquipCore I think is the one that lets you force slots to always have something equipped.
 

Kurot

Villager
Member
Joined
Jun 5, 2016
Messages
17
Reaction score
5
First Language
Portuguese
Primarily Uses
RMMV
Yeah, I'm aware. The problem is that his plugin is incompatible with several others that I am using, so I was looking for one more ..., simple, haha.

But thanks anyway.
 

Latest Threads

Latest Posts

Latest Profile Posts

Day 2 of my redesign journey, as a follow up from the previous post :kaothx:
pXiRJSm.jpg

This is Cedric's son, Apollo!
New pet peeve: Telling tech support personnel what something is doing, only for them to tell me (in excessively condescending tones) what it should be doing. Yes, I know what it should be doing, and if it was doing that, I wouldn’t be talking to you and your attitude problem about it right now, would I? >.<
uglywolf wrote on Khulse's profile.
Hello.
The rules I makes pun about on your last thread is about "Verify Files" before anything else, if the stuff comes from STEAM. Which means, if it could be fixed with just that, there is no need to redownload the whole stuff.
But glad the reinstall worked, hope you enjoy it and your days too.
uh oh, I just tapped into a fresh, deep vein of nightmare fuel right here guys:

Forum statistics

Threads
115,430
Messages
1,089,799
Members
150,186
Latest member
DarkPurplePrince
Top