Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <After Eval>
- if (user.isEnemy()) {
- // Determine the success rate of stealing.
- var successRate = 0.5;
- // Check to see if the steal passes.
- if (Math.random() < successRate) {
- // Create an empty pool for what are valid items.
- var items = [];
- // Let's get the length of the all items in the player's party.
- var total = $gameParty.items().length;
- // A for-loop is used to check each of those items.
- for (var i = 0; i < total; ++i) {
- // Define each item for checking.
- var item = $gameParty.items()[i];
- // Check to see if the item is NOT a key item.
- if (item.itypeId !== 2) {
- // If it isn't a key item, add it to the legal pool.
- items.push(item);
- }
- }
- // Get a random number based on the size of the item pool.
- var random = Math.floor(Math.random() * items.length);
- // Get a random item by using that random number.
- var item = items[random];
- // Have the player party lose 1 of that item.
- $gameParty.loseItem(item, 1);
- // Create a message to let the player know what item was stolen.
- var text = user.name() + ' stole ' + item.name + ' from the party!';
- // Let's play a sound effect!
- SoundManager.playEquip();
- } else {
- // The steal attempt has failed. Make a message to indicate it.
- var text = user.name() + ' failed to steal an item!';
- // Play a sound effect to indicate failure.
- SoundManager.playBuzzer();
- }
- // Get the battle log menu from the battle scene.
- var window = SceneManager._scene._logWindow;
- // Make that text show up in the battle log. Let's center it, too.
- window._lines.push(text + '<CENTER>');
- // And finally, let's refresh that battle log window to display it.
- window.refresh();
- }
- </After Eval>
Advertisement
Add Comment
Please, Sign In to add comment