Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Can I get item/skill ID used while using hotbar? Let's say I used item ID 1 from hotbar which runs common event, where I want to check if the used item ID=1, 2, 3 and so on.

(1 edit) (+1)

I think, usually each hotbar slot should have its unique common event (whether it's called directly or via item/skill doesn't matter here), so I don't see the benefit yet.

However, I quickly made a plugin that puts the value of item/skill/equip/common event of the latest hotbar interaction into a Variable. Hope this helps!

Change the Variable ID at the top to your needs, and then save it as a plugin with any name.

/*:
 * @target MZ
 */
(function() {
const variableId = 1; // <--
const _GameParty_onHotbarItemEquipWeapon = Game_Party.prototype.onHotbarItemEquipWeapon;
Game_Party.prototype.onHotbarItemEquipWeapon = function(weaponId) {
    $gameVariables.setValue(variableId, weaponId);
    _GameParty_onHotbarItemEquipWeapon.call(this, weaponId);
}
const _GameParty_onHotbarItemEquipArmor = Game_Party.prototype.onHotbarItemEquipArmor;
Game_Party.prototype.onHotbarItemEquipArmor = function(armorId) {
    $gameVariables.setValue(variableId, armorId);
    _GameParty_onHotbarItemEquipArmor.call(this, armorId);
}
const _GameParty_onHotbarItemRegularItem = Game_Party.prototype.onHotbarItemRegularItem;
Game_Party.prototype.onHotbarItemRegularItem = function(itemId) {
    $gameVariables.setValue(variableId, itemId);
    _GameParty_onHotbarItemRegularItem.call(this, itemId);
}
const _GameParty_onHotbarItemCastSkill = Game_Party.prototype.onHotbarItemCastSkill;
Game_Party.prototype.onHotbarItemCastSkill = function(skillId) {
    $gameVariables.setValue(variableId, skillId);
    _GameParty_onHotbarItemCastSkill.call(this, skillId);
}
const _GameParty_onHotbarItemCommonEvent = Game_Party.prototype.onHotbarItemCommonEvent;
Game_Party.prototype.onHotbarItemCommonEvent = function(commonEventId) {
    $gameVariables.setValue(variableId, commonEventId);
    _GameParty_onHotbarItemCommonEvent.call(this, commonEventId);
}
})()
(1 edit)

Thank you so much, so nice of you! Works like  a charm, exactly what I needed.