Quick question, couldn't find anything about this on the internet. I want to manually consume a consumable item using a script call in my common event (force consumption). The script $gameParty.useItem does not work, it seems to be conflicting with VisuMZ core in some way. Any alternatives?
Consume item script call
RPG Maker MZ Supportwhen you say you wish to "consume" it, do you mean you want the player to lose one of the item, or are you trying to force a use of the item in battle like how you would force a skill with the force action command?
I think the script requires a little editing because IIRC you have to select a target for an item and that actor gets passed into the consume item function from a previous select target function.
Just usual consuming outside of battle. So say you encounter some kind of event, and it triggers you to drink a health potion. You lose the health potion and recover 10% according to the effects, similar to when you choose to consume it manually from the menu. The reason i need to do this is because I'm custom eventing the menu, so I need a way for players to actually use their items.
I just want a script call for this, given the required itemID, there's bound to be something useful.
How specifically?
why not use the old fashion way to force
player heals 10% hp
item - 1
so you don't need a scriptcall specifically 🙂
otherwise, the consume item or lose Item require a new function
in order to force it like Robro33 said.
player heals 10% hp
item - 1
so you don't need a scriptcall specifically 🙂
otherwise, the consume item or lose Item require a new function
in order to force it like Robro33 said.
As ShadowDragon said, you can do this with events which is much easier.
"Change items" = "Healing Potion" -1
Change Actor HP +15%
Because it doesn't exist - where did you find that? There's no such thing in MZ's code.
There's Game_Actor.useItem(), but that only ends up doing the removing half of it. The rest of it comes from Scene_ItemBase.applyItem().
There is no one script call to do this - there are several lines of code in applyItem(), include pulling data from the scene, as you can see here:
Code:
Scene_ItemBase.prototype.applyItem = function() {
const action = new Game_Action(this.user());
action.setItemObject(this.item());
for (const target of this.itemTargetActors()) {
for (let i = 0; i < action.numRepeats(); i++) {
action.apply(target);
}
}
action.applyGlobal();
};
So if you're trying to recreate this outside of the item scene, you're going to have to find another way to know how you're referencing the item and the actor it's being used on.
Thanks for the help guys. Seems I'll just manually do each item change depending on what item was equipped.
you never said about the "equiped item" and what plugin you use for equiping item(s).
because if we know that, we can do a scriptcall to force this more easely.
you said manually, not by equiped item.
but still, doing so could be done with a variable ID.
but we need to know the plugin you use to equip items as I don't think its default.?
Original thread: https://forums.rpgmakerweb.com/threads/consume-item-script-call.174039/