MZ [SOLVED] Assistance with Triacontane's Zweihander Plugin

Hey all.

Like the title says, I'm using Triancontane's Zweihander plugin.

It seems to apply the effects of the plugin if a weapon in slot 1 seals slot 2, which is well and good.

What I would like is for the second slot to not just be 'greyed out' but have the weapon name appear there as well, so you can visually see that weapon is taking both hands to use.

I currently also have this bit of code edited to label empty slots with "Empty," in case this would affect any js that will do what I'd like.

Code:
Window_EquipSlot.prototype.drawItem = function(index) {
    if (this._actor) {
        const slotName = this.actorSlotName(this._actor, index);
        const item = this.itemAt(index);
        const slotNameWidth = this.slotNameWidth();
        const rect = this.itemLineRect(index);
        const itemWidth = rect.width - slotNameWidth;
        const itemNameY = rect.y + 3;
        this.changeTextColor(ColorManager.systemColor());
        this.changePaintOpacity(this.isEnabled(index));
        this.drawText(slotName, rect.x, rect.y, slotNameWidth, rect.height);
        if (item) {
            this.drawItemName(item, rect.x + slotNameWidth, itemNameY, itemWidth);
        } else {
            this.drawText('Empty', rect.x + slotNameWidth, itemNameY, itemWidth);
        }
        this.changePaintOpacity(true);
    }
};

Again, any and all help is appreciated! Thanks!
Maybe try replacing this:
JavaScript:
'Empty'
...with this:
JavaScript:
(this.isTwoHanded() && this.weapons()[0].name) || 'Empty'
I.e. "if we're in 2-handed mode, use the name of the first equipped weapon; otherwise, use Empty".
Maybe try replacing this:
JavaScript:
'Empty'
...with this:
JavaScript:
(this.isTwoHanded() && this.weapons()[0].name) || 'Empty'
I.e. "if we're in 2-handed mode, use the name of the first equipped weapon; otherwise, use Empty".
Ah, sorry, I should mention my Window_EquipSlot portion is in another .js file that houses most of my menu UI stuff!

So when I plugged (this.isTwoHanded() && this.weapons()[0].name) || 'Empty' like this:
Code:
Window_EquipSlot.prototype.drawItem = function(index) {
    if (this._actor) {
        const slotName = this.actorSlotName(this._actor, index);
        const item = this.itemAt(index);
        const slotNameWidth = this.slotNameWidth();
        const rect = this.itemLineRect(index);
        const itemWidth = rect.width - slotNameWidth;
        const itemNameY = rect.y + 3;
        this.changeTextColor(ColorManager.systemColor());
        this.changePaintOpacity(this.isEnabled(index));
        this.drawText(slotName, rect.x, rect.y, slotNameWidth, rect.height);
        if (item) {
            this.drawItemName(item, rect.x + slotNameWidth, itemNameY, itemWidth);
        } else {
            this.drawText((this.isTwoHanded() && this.weapons()[0].name) || 'Empty', rect.x + slotNameWidth, itemNameY, itemWidth);
        }
        this.changePaintOpacity(true);
    }
};
It tells me that this.isTwoHandedis not a function.

I DID try out copying the isTwoHanded function from the Zweihander.js into my menu js file, but it still didn't read.
It tells me that this.isTwoHandedis not a function.
"this._actor" mind you.
its the actor that has the isTwoHanded function, not the window
"this._actor" mind you.
its the actor that has the isTwoHanded function, not the window
Sheesh! Of course, thank you haha.

That works-ish! It now writes the weapon name, without the icon (would like the icon), in all empty spaces as opposed to the only the second slot. Almost there! I've tried a few things out in the meantime and still haven't landed on something that works.
Almost there! I've tried a few things out in the meantime and still haven't landed on something that works.
did you try using drawItemName() instead of drawText()? it includes both the item's name and icon.

you can adjust your code a bit so that if "this._actor.isTwoHanded()" is true, it uses drawItemName() with "this._actor.weapons()[0]" and uses drawText() with "Empty" otherwise
Did more testing, and yet it writes empty in every slot. Trying to figure out how to write in only the second slot, as well.

This is what I've got. I've done other variations and not have yet to work! Still plugging away.


Code:
Window_EquipSlot.prototype.drawItem = function(index) {
    if (this._actor) {
        const slotName = this.actorSlotName(this._actor, index);
        const item = this.itemAt(index);
        const slotNameWidth = this.slotNameWidth();
        const rect = this.itemLineRect(index);
        const itemWidth = rect.width - slotNameWidth;
        const itemNameY = rect.y + 3;
        this.changeTextColor(ColorManager.systemColor());
        this.changePaintOpacity(this.isEnabled(index));
        this.drawText(slotName, rect.x, rect.y, slotNameWidth, rect.height);
        if (item) {
            this.drawItemName(item, rect.x + slotNameWidth, itemNameY, itemWidth);
        } else if (item && this._actor.isTwoHanded() && this._slotId == 1) {
                this.drawItemName(this._actor.weapons()[0].name, rect.x + slotNameWidth, itemNameY, itemWidth);
        } else {
            this.drawText('Empty', rect.x + slotNameWidth, itemNameY, itemWidth)
        }
        
        this.changePaintOpacity(true);
    }
};
if (item) {
this.drawItemName(item, rect.x + slotNameWidth, itemNameY, itemWidth);
} else if (item && this._actor.isTwoHanded() && this._slotId == 1) {
this.drawItemName(this._actor.weapons()[0].name, rect.x + slotNameWidth, itemNameY, itemWidth);
} else { this.drawText('Empty', rect.x + slotNameWidth, itemNameY, itemWidth)
}
im not sure where this.itemAt(index) comes from, but im assuming its using the actor's equips()

theres a bit of a logical error there. if item exists, itll do the first branch. your else if condition cannot ever be true. in order to get to it, item needs to not exist, but since the condition is a few ANDs, it can only be true if item exists.

try something like this:
Code:
if (item) {
    this.drawItemName(item, rect.x + slotNameWidth, itemNameY, itemWidth);
} else {
    if (this._slotId === 1 && this._actor.isTwoHanded())
        this.drawItemName(this._actor.weapons()[0], rect.x + slotNameWidth, itemNameY, itemWidth);
    else
        this.drawText('Empty', rect.x + slotNameWidth, itemNameY, itemWidth);
}
im not sure where this.itemAt(index) comes from, but im assuming its using the actor's equips()

theres a bit of a logical error there. if item exists, itll do the first branch. your else if condition cannot ever be true. in order to get to it, item needs to not exist, but since the condition is a few ANDs, it can only be true if item exists.

try something like this:
Code:
if (item) {
    this.drawItemName(item, rect.x + slotNameWidth, itemNameY, itemWidth);
} else {
    if (this._slotId === 1 && this._actor.isTwoHanded())
        this.drawItemName(this._actor.weapons()[0], rect.x + slotNameWidth, itemNameY, itemWidth);
    else
        this.drawText('Empty', rect.x + slotNameWidth, itemNameY, itemWidth);
}
Gotcha, awesome. We're almost there! lol

It seems like checking the slot ID is what's tripping this up. If I remove that portion of the conditions, it'll write the weapon name and icon in all empty spots. Kind of weird since all references to checking a slot id I came across read as this._slotID == x.
then you know what, drop this._slotId entirely and use index instead
then you know what, drop this._slotId entirely and use index instead

HEYOOOO! That worked! Fantastic, thanks @Robro33. Man, using index didn't even cross my mind. Now I've got more knowledge going forward, haha.
This thread is closed due to being marked solved. Report the next one so we can find it! If you need this one reopened, report it to let us know. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/solved-assistance-with-triacontanes-zweihander-plugin.174755/