MZ Modifying JS: Draw Equip Data in Visustella ItemEquips Core

Greetings,

I have been struggling today trying to figure out how to make a specific modification to the way the Visustella ItemEquipsCore draws equipment data, and I thought it best at this point to reach out for some advice.

Basically, what I am trying to do is modify the JS: Draw Equip Data in the plugin parameters to check if an item is a weapon, and if so, draw the Weapon Type for that weapon from the database. Else, if the equipment is not a weapon, I want it to draw the Equipment Type from the database.

Here is the (mostly) default JavaScript code from JS: Draw Equip Data:

// Draw Item Name, Type, and Quantity this.drawItemName(this._item, x + this.itemPadding(), y, width - this.itemPadding() * 2); this.drawItemDarkRect(x, y, width); y += lineHeight; if (this.drawItemEquipType(x, y, hw)) y += 0; if (this.drawItemQuantity(hx+50, y, hw-50)) y += lineHeight;

If you aren't familiar with the VisuStella ItemEquipsCore, the above code (more or less) creates the following window in game when inspecting a piece of equipment in the item menu:

itemequipspic.png


In this picture, Main Hand is the Equipment Type as drawn from the database. However, since Hunting Knife is a weapon, I want it to show the Weapon Type instead (which would be Short Blade).

If anyone could offer some coding advice on how to make this idea reality, I would greatly appreciate it 🙂.

Thank you in advance and have a wonderful weekend.

-Niniann
The drawItemEquipType() function is what is drawing that information. So what you'd need to do is check if the item is a weapon (if this._item.etypeID == 1), and then calla different function if that is true.

As for what would be in that function, you'd have to define one yourself, possibly inside this plugin parameter, but I'm not sure how or if that would work. The function needs to return a true value in order for it to properly space the following lines, from what I gather from the drawItemEquipType() function. Otherwise it would look like the actual text drawing happens inside that function. You can do a drawText function with the text being something like $dataSystem.weaponTypes[this._item.wtypeId] for starters, and then go from there.

Good luck.
Ramza,

Thank you so much for the reply. With your insight I've been able to move a little further along with this problem, though haven't been able to solve it quite just yet.

So this is where I'm at now:

First, I can replace the drawItemEquipType with drawText.$dataSystem.weaponTypes[this._item.wtypeId] to get the following picture:

itemequipspic2.png


Which is exactly what I want (minus the formatting). However, for armor pieces, this way of handling the code makes them display "undefined" where "Armor" used to be (i.e. where "Short Blade" is in the above picture). Makes sense, as Armor does not have a Weapon Type 😛.

So, as Ramza mentioned, there needs to be some sort of check for the Equipment Type in order to get both weapons and armor to display their type in the box.

I am attempting the following code:

// Draw Item Name, Type, and Quantity this.drawItemName(this._item, x + this.itemPadding(), y, width - this.itemPadding() * 2); this.drawItemDarkRect(x, y, width); y += lineHeight; if (this._item.etypeID == 1) { if (this.drawText($dataSystem.weaponTypes[this._item.wtypeId], x, y, hw)) y += 0; } else { if (this.drawItemEquipType(x, y, hw)) y += 0; } if (this.drawItemQuantity(hx, y, hw)) y += lineHeight;

However, this code doesn't do the check correctly (at all?). The game runs fine, but now I am back to the original picture in my first post, with Main Hand (the Equipment Type) showing up for weapons.

Would anyone be able to point me in the right direction towards what I'm doing incorrectly with this code?

Edit: Just wanted to post some further (kind of?) progress. Here is some new code I've been working on:

// Draw Item Name, Type, and Quantity this.drawItemName(this._item, x + this.itemPadding(), y, width - this.itemPadding() * 2); this.drawItemDarkRect(x, y, width); y += lineHeight; if (this._item.etypeId = 1 && this._item.etypeId != 3) { this.drawText($dataSystem.weaponTypes[this._item.wtypeId], x, y, hw); } if (this._item.etypeId = 3 && this._item.etypeId != 1) { this.drawText($dataSystem.armorTypes[this._item.atypeId], x, y, hw); } if (this.drawItemQuantity(hx, y, hw)) y += lineHeight;

This code here will temporarily display the Short Blade for the Hunting Knife and Light Armor for an armor item, but only the first time they are inspected in items. If one scrolls back up to Hunting Knife it will still show Short Blade, but then the armor piece will go back to showing "undefined" as its type...

Worse yet, somehow this code makes the items entirely unequippable by any actor in the game...no clue why that happens.

Original thread: https://forums.rpgmakerweb.com/threads/modifying-js-draw-equip-data-in-visustella-itemequips-core.163034/