I've seen Yanfly provide a way to make this work in his plugin for MV. But nobody's even asked for this for MZ. I did send a request to VisuStella to replicate this feature in their plugin, but it's been a while since I asked and they still haven't done it so far. Is there some other method to do this in the meantime?
MZ A way for enemies to steal from the player.
RPG Maker MZ SupportPut this code in the "Steal" skill(s)'s notes:
You can replace "item-02" and "miss_new" with your own sfx.
Code:
//For enemies
<JS Post-Apply>
if (user.isEnemy()) {
const successRate = 0.5;
if (Math.random() < successRate) {
let items = [];
const total = $gameParty.items().length;
for (let i = 0; i < total; ++i) {
const item = $gameParty.items()[i];
if (item.itypeId !== 2) {
items.push(item);
}
}
if (items.length > 0) {
const random = Math.randomInt(items.length);
const item = items[random];
$gameParty.loseItem(item, 1);
$gameVariables.value(2).push(item.id);
var text = user.name() + ' stole ' + item.name + ' from the party!';
AudioManager.playSe({name: "item-02", volume: 90, pan: 0, pitch: 100});
}
} else {
var text = user.name() + ' failed to steal an item!';
AudioManager.playSe({name: "miss_new", volume: 90, pan: 0, pitch: 100});
}
const window = SceneManager._scene._logWindow;
if (text) {
window.addStealText(text + '<CENTER>');
interpreter.wait(800);
}
}
</JS Post-Apply>
You can replace "item-02" and "miss_new" with your own sfx.
The code is working, but the message for when an enemy successfully steals an item doesn't show up, nor does any sound play. That isn't the case if the enemy fails, however.
The message is on the top of the screen:
As for the sounds, like I said, you'll have to replace "item-02" and "miss_new" with the names of your own sfx.
As for the sounds, like I said, you'll have to replace "item-02" and "miss_new" with the names of your own sfx.
just as a note, Trihan has a thread for visustella ports of yanfly's tips and tricks. no idea if he did them all, but the thief one was already there
How to implement every possible Yanfly Tips & Tricks effect in MZ with VisuStella plugins
Hi all. This is by far one of the biggest topics I've seen people asking about, to the point where I've been commissioned twice to make an MZ project containing all of the T&T effects. So I figured I'd make a topic about how to implement them all yourselves. If no other plugins are specified...
forums.rpgmakerweb.com
Yo, that's super nice! Thanks for sharing.
I believe I had the sound replacing "item-02" correct. Yet the message didn't pop up along with the sound still not playing.
Doesn't matter though, the link Robro33 provided has what I was looking for and it works well. Thanks for your help either way.
Original thread: https://forums.rpgmakerweb.com/threads/a-way-for-enemies-to-steal-from-the-player.179558/