I was wondering if it was possible to make a statement that checks if a certain equipment slot (such as .equips(1)[]) contains a certain weapon type equipped? Also, what's the script call to forcibly unequip something from a specific slot?
MV .isWTypeEquipped & .equips()[]
Javascript/Plugin SupportCould you use a little more elaboration but I think this is what you want
and for your other question
just set the slot id to 0 to remove the equip
JavaScript:
$gameActors.actor(actorId).equips().forEach(function(e){
if(e.isWtypeEquipped(ID OF WEAPON TYPE)){
// do whatever
}
})
and for your other question
$gameActors.actor(actorId).changeEquip(slotId, item);
just set the slot id to 0 to remove the equip
JavaScript:
$gameActors.actor(actorId).equips().forEach(function(e){
if(e.isWtypeEquipped(ID OF WEAPON TYPE)){
// do whatever
}
})
JavaScript:
$gameActors.actor(actorId).equips()[1]{
if(e.isWtypeEquipped(ID OF WEAPON TYPE)){
// do whatever
}
})
The first slot would be 0, and if you only want to check the first slot then you can do something like
JavaScript:
var e = $gameActors.actor(actorId).equips()[0]
if (e.isWtypeEquipped(ID OF WEAPON TYPE)) {
// do whatever
}
isWTypeEquipped is a method of Game_Actor that loops through that actor's equipped weapons and checks each of them for the specified weapon type:
JavaScript:
Game_Actor.prototype.isWtypeEquipped = function(wtypeId) {
return this.weapons().some(function(weapon) {
return weapon.wtypeId === wtypeId;
});
};
if or via Conditional Branch > Script, e.g.
JavaScript:
var w = $gameActors.actor(1).weapons()[0]; w ? w.wtypeId === 5 : false
w equal actor 1's first weapon; if the weapon exists, return true iff it is of type 5, else return false". You can reference weapon types via the Types tab in the database.For changing equipment, note that
changeEquip expects item arguments; 0 works here because JavaScript treats it as falsy, but the standard "empty slot object" used in the core scripts is null. An alternative is changeEquipById:
JavaScript:
$gameActors.actor(1).changeEquipById(1, 0);
Original thread: https://forums.rpgmakerweb.com/threads/iswtypeequipped-equips.129489/