Guest User

Untitled

a guest
Feb 17th, 2016
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. <After Eval>
  2. if (user.isEnemy()) {
  3. // Determine the success rate of stealing.
  4. var successRate = 0.5;
  5. // Check to see if the steal passes.
  6. if (Math.random() < successRate) {
  7. // Create an empty pool for what are valid items.
  8. var items = [];
  9. // Let's get the length of the all items in the player's party.
  10. var total = $gameParty.items().length;
  11. // A for-loop is used to check each of those items.
  12. for (var i = 0; i < total; ++i) {
  13. // Define each item for checking.
  14. var item = $gameParty.items()[i];
  15. // Check to see if the item is NOT a key item.
  16. if (item.itypeId !== 2) {
  17. // If it isn't a key item, add it to the legal pool.
  18. items.push(item);
  19. }
  20. }
  21. // Get a random number based on the size of the item pool.
  22. var random = Math.floor(Math.random() * items.length);
  23. // Get a random item by using that random number.
  24. var item = items[random];
  25. // Have the player party lose 1 of that item.
  26. $gameParty.loseItem(item, 1);
  27. // Create a message to let the player know what item was stolen.
  28. var text = user.name() + ' stole ' + item.name + ' from the party!';
  29. // Let's play a sound effect!
  30. SoundManager.playEquip();
  31. } else {
  32. // The steal attempt has failed. Make a message to indicate it.
  33. var text = user.name() + ' failed to steal an item!';
  34. // Play a sound effect to indicate failure.
  35. SoundManager.playBuzzer();
  36. }
  37. // Get the battle log menu from the battle scene.
  38. var window = SceneManager._scene._logWindow;
  39. // Make that text show up in the battle log. Let's center it, too.
  40. window._lines.push(text + '<CENTER>');
  41. // And finally, let's refresh that battle log window to display it.
  42. window.refresh();
  43. }
  44. </After Eval>
Advertisement
Add Comment
Please, Sign In to add comment