- Joined
- Jun 29, 2017
- Messages
- 267
- Reaction score
- 81
- First Language
- English
- Primarily Uses
- RMMV
Hello there. I wanted to find a way that would make certain equipment unstealable, but with YEP_StealSnatch, no such feature is there. http://yanfly.moe/2016/02/05/yep-66-steal-snatch/
I'm mainly using this "Enemy Thieves" script below that will allow the enemy to steal not just items, but also weaponry, armory, and gold when they use the skill on the player.
Enemy Thieves - Weapons, Armor, Items, Gold
----------------------------------------------------
To explain, I have certain special weaponry, armory, and certain items that are essential story-wise, weapons that are solely bound to main characters.
With the enemy thieves skill, the enemy would successfully steal that weapon or armory that wasn't equipped, leaving the protagonist with no hope of getting that special weapon / armor / item back, let alone be able to finish a certain mission, enemy, etc.
The idea to resolve this would be the use of notetags like:
- <Steal Resist> - Actors (Makes the actor resistant against stealing. Can apply to his / her inventory of weapons, armor, gold).
- <Unstealable> - Weapons / Armor / Item (Prevents the weapon, armor, and item in the player's inventory from being stolen).
I would be very grateful if this was manageable, as I would no longer have to worry about the story-essential weapons / armor / items being stolen by enemies.
I'm mainly using this "Enemy Thieves" script below that will allow the enemy to steal not just items, but also weaponry, armory, and gold when they use the skill on the player.
Enemy Thieves - Weapons, Armor, Items, Gold
----------------------------------------------------
Code:
<After Eval>
if (user.isEnemy()) {
var successRate = 0.50;
if (Math.random() < successRate) {
var items = [];
var weapons = [];
var armors = [];
var gold = 0;
var kind = Math.randomInt(4);
if (kind === 0) {
var total = $gameParty.items().length;
for (var i = 0; i < total; ++i) {
var item = $gameParty.items()[i];
if (item.itypeId !== 2) {
items.push(item);
}
}
} else if (kind === 1) {
var total = $gameParty.weapons().length;
for (var i = 0; i < total; ++i) {
var weapon = $gameParty.weapons()[i];
var isEquipped = false;
for (var j = 0; j < $gameParty.members().length; j++) {
if ($gameParty.members()[j].isEquipped(weapon)) {
isEquipped = true;
break;
}
}
if (!isEquipped) weapons.push(weapon);
}
} else if (kind === 2) {
var total = $gameParty.armors().length;
for (var i = 0; i < total; ++i) {
var armor = $gameParty.armors()[i];
var isEquipped = false;
for (var j = 0; j < $gameParty.members().length; j++) {
if ($gameParty.members()[j].isEquipped(armor)) {
isEquipped = true;
break;
}
if (!isEquipped) armors.push(armor);
}
}
} else if (kind === 3) {
gold = $gameParty.gold();
}
if (items.length > 0) {
var random = Math.floor(Math.random() * items.length);
var item = items[random];
$gameParty.loseItem(item, 1);
var text = user.name() + ' pilfered ' + item.name + ' from ' + target.name() + '!';
obj = { name: "FE_WeaponBreak", pan: 0, pitch: 120, volume: 100 };
AudioManager.playSe(obj);
var stealableItem = {
type: 'item',
id: item.id,
rate: 0.50,
isStolen: false,
isDrop: false
}
user._stealableItems.push(stealableItem);
} else if (weapons.length > 0) {
var random = Math.floor(Math.random() * weapons.length);
var weapon = weapons[random];
$gameParty.loseItem(weapon, 1);
var text = user.name() + ' pilfered ' + weapon.name + ' from ' + target.name() + '!';
obj = { name: "FE_WeaponBreak", pan: 0, pitch: 120, volume: 100 };
AudioManager.playSe(obj);
var stealableItem = {
type: 'weapon',
id: weapon.id,
rate: 0.50,
isStolen: false,
isDrop: false
}
user._stealableItems.push(stealableItem);
} else if (armors.length > 0) {
var random = Math.floor(Math.random() * armors.length);
var armor = armors[random];
$gameParty.loseItem(armor, 1);
var text = user.name() + ' pilfered ' + armor.name + ' from ' + target.name() + '!';
obj = { name: "FE_WeaponBreak", pan: 0, pitch: 120, volume: 100 };
AudioManager.playSe(obj);
var stealableItem = {
type: 'armor',
id: armor.id,
rate: 0.50,
isStolen: false,
isDrop: false
}
user._stealableItems.push(stealableItem);
} else if (gold > 0) {
var stolengold = Math.min(gold, Math.floor(user.atk * Math.random()));
$gameParty.loseGold(stolengold);
var text = user.name() + ' pilfered ' + stolengold + ' ' + TextManager.currencyUnit + ' from ' + target.name() + '!';
obj = { name: "FE_WeaponBreak", pan: 0, pitch: 120, volume: 100 };
AudioManager.playSe(obj);
var stealableItem = {
type: 'armor',
id: stolengold,
rate: Yanfly.Param.StealGoldRate * 100,
isStolen: false,
isDrop: false
}
user._stealableItems.push(stealableItem);
} else {
var text = user.name() + ' failed to pilfer an item from ' + target.name() + '!';
obj = { name: "FE_Buzzer", pan: 0, pitch: 100, volume: 100 };
AudioManager.playSe(obj);
}
var wait = 60;
text = '<CENTER>' + text;
BattleManager.addText(text, wait);
}
}
</After Eval>
With the enemy thieves skill, the enemy would successfully steal that weapon or armory that wasn't equipped, leaving the protagonist with no hope of getting that special weapon / armor / item back, let alone be able to finish a certain mission, enemy, etc.
The idea to resolve this would be the use of notetags like:
- <Steal Resist> - Actors (Makes the actor resistant against stealing. Can apply to his / her inventory of weapons, armor, gold).
- <Unstealable> - Weapons / Armor / Item (Prevents the weapon, armor, and item in the player's inventory from being stolen).
I would be very grateful if this was manageable, as I would no longer have to worry about the story-essential weapons / armor / items being stolen by enemies.
