adiktuzmiko

Chest Drop Randomizer v1.1

May 22nd, 2013
1,081
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 8.93 KB | None | 0 0
  1. #==============================================================================
  2. #
  3. # Chest Drop Randomizer Ace v1.1
  4. # by AdiktuzMiko
  5. # --- Date Created: 04/11/2012
  6. # --- Last Date Updated: 05/29/2013
  7. # --- Level: Normal
  8. # Requires: n/a
  9. #
  10. # Basically, this allows you to easily randomize items that you obtain from
  11. # chests, etc. It also displays a message which tells you what item and how
  12. # many of it was obtained.
  13. #
  14. #==============================================================================
  15.  
  16.  
  17. #==============================================================================
  18. # How To Install:
  19. #
  20. # Just put this anywhere before main and you're good to go.
  21. #==============================================================================
  22.  
  23.  
  24. #==============================================================================
  25. # How To Use:
  26. #
  27. # Just call one of these functions:
  28. #
  29. # Chest::AddGold(low,high) -> for gold/currency
  30. # Chest::AddArmor(value, low, high, equip) -> for armor type items
  31. # Chest::AddWeapon(value, low, high, equip) -> for weapon type items
  32. # Chest::AddItem(value, low, high) -> for other items
  33. #
  34. # Loop methods
  35. #
  36. # Chest::AddGoldEx(times, low,high) -> for gold/currency
  37. # Chest::AddArmorEx(times, value, low, high, equip) -> for armor type items
  38. # Chest::AddWeaponEx(times, value, low, high, equip) -> for weapon type items
  39. # Chest::AddItemEx(times, value, low, high) -> for other items
  40. #
  41. # times -> how many times the randomization will be done
  42. # value = the amount of item to be added
  43. # low = the low bound for the randomization [corresponds to id in the database]
  44. # high = the high bound for the randomization [corresponds to id in the database]
  45. # equip = whether to include the equipped items when checking
  46. #         for the maximum amount of item that the player can have
  47. #        -> by default, this is false
  48. #
  49. # Array methods
  50. #
  51. # These methods take in an array of values instead of a low and high value.
  52. # They randomize the result from the array of values passed into it.
  53. #
  54. # Chest::AddGold2([gold values]) -> for gold/currency
  55. # Chest::AddArmor2(value, [armor ids], equip) -> for armor type items
  56. # Chest::AddWeapon2(value, [weapon ids], equip) -> for weapon type items
  57. # Chest::AddItem2(value,[item ids]) -> for other items
  58. #
  59. # Loop methods
  60. #
  61. # Chest::AddGold2Ex(times, [gold values]) -> for gold/currency
  62. # Chest::AddArmor2Ex(times, value, [armor ids], equip) -> for armor type items
  63. # Chest::AddWeapon2Ex(times, value, [weapon ids], equip) -> for weapon type items
  64. # Chest::AddItem2Ex(times, value, [item ids]) -> for other items
  65. #
  66. # Example:
  67. #
  68. # Chest::AddArmor(2, 1, 3)
  69. #
  70. # this will result to having 2 pieces of an armor which is randomized from
  71. # the armor with the id of 1 up to the armor with an id of 3 at the database
  72. #
  73. # Since equip was not set, it will be false by default, so if for example
  74. # the armor I obtained was armor 1, then I have 1 of it equipped and 97
  75. # on the inventory, if the item limit is set to 99, then I will now have
  76. # 99 armor 1 in the inventory + 1 equipped
  77. #
  78. # if I set it to true, I will only have 98 on my inventory even I originally have
  79. # 97 only and the value was set to 2, since the 1 equipped will be included
  80. # in the counting of item number
  81. #
  82. # Chest::AddGoldEx(2, 100,200)
  83. #
  84. # This will give you random gold twice, the value of each will be between 100
  85. # and 200. so it can be like  100 and 200 or 101 and 150 and so on.
  86. #
  87. # Chest::AddGold2([100,2,50,15,1,1,1,1,8,9])
  88. #
  89. # This will give you random gold from the array given.
  90. #
  91. # To show the item obtain message just call
  92. # Chest::ShowItemMessage()
  93. #
  94. # Note: Only call this function after you have finished adding all the item
  95. # drops for the specific event, else it might malfunction.
  96. #
  97. # See the example events for a concrete look at how it is used.
  98. #
  99. #==============================================================================
  100.  
  101. module Chest
  102.  
  103.   POPUP_SOUND = 'Chime2'
  104.   POSITION = 2 # 0 - top, 1 - mid, 2 - bottom
  105.   POPUP_SOUND_VOLUME = 100
  106.   POPUP_SOUND_PITCH = 150
  107.   COLOR = 2
  108.  
  109. #==============================================================================
  110. # Do not touch anything below this line unless you know what you are doing.
  111. #==============================================================================
  112.  
  113.   $textitem = []
  114.   $textcount = 0
  115.  
  116.   def self.ShowItemMessage
  117.     unless $game_message.busy?
  118.       Audio.se_play('Audio/SE/' + POPUP_SOUND, POPUP_SOUND_VOLUME, POPUP_SOUND_PITCH)
  119.       $game_message.face_name = ""
  120.       $game_message.face_index = 0
  121.       $game_message.background = 1
  122.       $game_message.position = POSITION
  123.       for i in 1..$textcount
  124.         $game_message.texts.push("\\C[" + COLOR.to_s + "]" + $textitem[i])
  125.       end
  126.       $textitem.clear()
  127.       $textcount = 0
  128.     end
  129.     return false
  130.   end
  131.  
  132.   def self.AddGold(low,high)
  133.     value = low + rand(high - low + 1)
  134.     $game_party.gain_gold(value)
  135.     $textcount += 1
  136.     $textitem[$textcount] = (value.to_s + " gold acquired!")
  137.   end
  138.  
  139.   def self.AddGoldEx(times, low,high)
  140.     for i in 1..times
  141.       value = low + rand(high - low + 1)
  142.       $game_party.gain_gold(value)
  143.       $textcount += 1
  144.       $textitem[$textcount] = (value.to_s + " gold acquired!")
  145.     end
  146.   end
  147.  
  148.   def self.AddGold2(gold)
  149.     value = gold[rand(gold.length)]
  150.     $game_party.gain_gold(value)
  151.     $textcount += 1
  152.     $textitem[$textcount] = (value.to_s + " gold acquired!")
  153.   end
  154.  
  155.   def self.AddGold2Ex(times, gold)
  156.     for i in 1..times
  157.       value = gold[rand(gold.length)]
  158.       $game_party.gain_gold(value)
  159.       $textcount += 1
  160.       $textitem[$textcount] = (value.to_s + " gold acquired!")
  161.     end
  162.   end
  163.  
  164.   def self.AddArmor(value, low, high,equip = false)
  165.     ite = $data_armors[low + rand(high - low + 1)]
  166.     $game_party.gain_item(ite, value, equip)
  167.     $textcount += 1
  168.     $textitem[$textcount] = (ite.name + " (x" + value.to_s + ") acquired!")
  169.   end
  170.  
  171.   def self.AddArmor2(value, armor,equip = false)
  172.     ite = $data_armors[armor[rand(armor.length)]]
  173.     $game_party.gain_item(ite, value, equip)
  174.     $textcount += 1
  175.     $textitem[$textcount] = (ite.name + " (x" + value.to_s + ") acquired!")
  176.   end
  177.  
  178.   def self.AddArmorEx(times, value, low, high,equip = false)
  179.     for i in 1..times
  180.       ite = $data_armors[low + rand(high - low + 1)]
  181.       $game_party.gain_item(ite, value, equip)
  182.       $textcount += 1
  183.       $textitem[$textcount] = (ite.name + " (x" + value.to_s + ") acquired!")
  184.     end
  185.   end
  186.  
  187.   def self.AddArmor2Ex(times, value, armor,equip = false)
  188.     for i in 1..times
  189.       ite = $data_armors[armor[rand(armor.length)]]
  190.       $game_party.gain_item(ite, value, equip)
  191.       $textcount += 1
  192.       $textitem[$textcount] = (ite.name + " (x" + value.to_s + ") acquired!")
  193.     end
  194.   end
  195.  
  196.   def self.AddItem(value, low, high)
  197.     ite = $data_items[low + rand(high - low + 1) ]
  198.     $game_party.gain_item(ite, value, false)
  199.     $textcount += 1
  200.     $textitem[$textcount] = (ite.name + " (x" + value.to_s + ") acquired!")
  201.   end
  202.  
  203.   def self.AddItem2(value, item)
  204.     ite = $data_items[item[rand(item.length)] ]
  205.     $game_party.gain_item(ite, value, false)
  206.     $textcount += 1
  207.     $textitem[$textcount] = (ite.name + " (x" + value.to_s + ") acquired!")
  208.   end
  209.  
  210.   def self.AddItemEx(times,value, low, high)
  211.     for i in 1..times
  212.       ite = $data_items[low + rand(high - low + 1) ]
  213.       $game_party.gain_item(ite, value, false)
  214.       $textcount += 1
  215.       $textitem[$textcount] = (ite.name + " (x" + value.to_s + ") acquired!")
  216.     end
  217.   end
  218.  
  219.   def self.AddItem2Ex(times,value, item)
  220.     for i in 1..times
  221.       ite = $data_items[item[rand(item.length)] ]
  222.       $game_party.gain_item(ite, value, false)
  223.       $textcount += 1
  224.       $textitem[$textcount] = (ite.name + " (x" + value.to_s + ") acquired!")
  225.     end
  226.   end
  227.  
  228.   def self.AddWeapon(value, low, high,equip = false)
  229.     ite = $data_weapons[low + rand(high - low + 1)]
  230.     $game_party.gain_item(ite, value, equip)
  231.     $textcount += 1
  232.     $textitem[$textcount] = (ite.name + " (x" + value.to_s + ") acquired!")
  233.   end
  234.  
  235.   def self.AddWeapon2(value, weapon,equip = false)
  236.     ite = $data_weapons[weapon[rand(weapon.length)]]
  237.     $game_party.gain_item(ite, value, equip)
  238.     $textcount += 1
  239.     $textitem[$textcount] = (ite.name + " (x" + value.to_s + ") acquired!")
  240.   end
  241.  
  242.   def self.AddWeaponEx(times, value, low, high,equip = false)
  243.     for i in 1..times
  244.       ite = $data_weapons[low + rand(high - low + 1)]
  245.       $game_party.gain_item(ite, value, equip)
  246.       $textcount += 1
  247.       $textitem[$textcount] = (ite.name + " (x" + value.to_s + ") acquired!")
  248.     end
  249.   end
  250.  
  251.   def self.AddWeapon2Ex(times, value, weapon,equip = false)
  252.     for i in 1..times
  253.       ite = $data_weapons[weapon[rand(weapon.length)]]
  254.       $game_party.gain_item(ite, value, equip)
  255.       $textcount += 1
  256.       $textitem[$textcount] = (ite.name + " (x" + value.to_s + ") acquired!")
  257.     end
  258.   end
  259.  
  260. end #Chest
Advertisement
Add Comment
Please, Sign In to add comment