vindaca510

Event Item Containers v1.0

Aug 4th, 2014
447
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.24 KB | None | 0 0
  1.  
  2. ################################################################################
  3. #↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓#
  4. #↓ ↓#
  5. #↓ Event Item Containers: Version 1.0 ↓#
  6. #↓ ↓#
  7. #↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕#
  8. #↑ ↑#
  9. #↑ Written By: Joe Pro ↑#
  10. #↑ Last Edited: July 31, 2014 ↑#
  11. #↑ ↑#
  12. #↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑#
  13. ################################################################################
  14.  
  15. #◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙#
  16. #◙ ** Disclaimer ◙#
  17. #◙••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••◙#
  18. #◙ ◙#
  19. #◙ This script is not for commercial, if you wish to use this script in a ◙#
  20. #◙ game please PM me. All credit is to be given to me as the author of this ◙#
  21. #◙ script. ◙#
  22. #◙ ◙#
  23. #◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙#
  24. #◙ ** How To Use ◙#
  25. #◙••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••◙#
  26. #◙ ◙#
  27. #◙ * Acts just like $game_party's item system fo events. ◙#
  28. #◙ ◙#
  29. #◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙#
  30. #◙ ** Updates / Version Notes ◙#
  31. #◙••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••◙#
  32. #◙ ◙#
  33. #◙ v0.1 ◙#
  34. #◙ ~◄◙◙◙◙►~ ◙#
  35. #◙ * This script is a base for other scripts. It allows you to add/remove ◙#
  36. #◙ items, weapons and/or armors to an event. You can then use that to ◙#
  37. #◙ create other scenes or whatever you can think up. ◙#
  38. #◙ ◙#
  39. #◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙#
  40.  
  41.  
  42.  
  43. ################################################################################
  44. #↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓#
  45. #↓ ↓#
  46. #↕ Event Item Containers: Version 0.1 ↕#
  47. #↑ ↑#
  48. #↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑#
  49. ################################################################################
  50.  
  51.  
  52.  
  53. #==============================================================================
  54. # ** Game_Event
  55. #------------------------------------------------------------------------------
  56. # This class handles events. Functions include event page switching via
  57. # condition determinants and running parallel process events. Used within the
  58. # Game_Map class.
  59. #==============================================================================
  60.  
  61. class Game_Event < Game_Character
  62.  
  63. #--------------------------------------------------------------------------
  64. # * Aliasing Method: Initialize Public Member Variables
  65. #--------------------------------------------------------------------------
  66. alias :geipm040546400000654 :init_public_members
  67.  
  68. #--------------------------------------------------------------------------
  69. # * Initialize Public Member Variables
  70. #--------------------------------------------------------------------------
  71. def init_public_members
  72. geipm040546400000654()
  73. init_all_items
  74. end
  75.  
  76. #--------------------------------------------------------------------------
  77. # * Initialize All Item Lists
  78. #--------------------------------------------------------------------------
  79. def init_all_items
  80. @items = {}
  81. @weapons = {}
  82. @armors = {}
  83. end
  84.  
  85. #--------------------------------------------------------------------------
  86. # * Get Item Object Array
  87. #--------------------------------------------------------------------------
  88. def items
  89. @items.keys.sort.collect {|id| $data_items[id] }
  90. end
  91.  
  92. #--------------------------------------------------------------------------
  93. # * Get Item Object Array
  94. #--------------------------------------------------------------------------
  95. def weapons
  96. @weapons.keys.sort.collect {|id| $data_weapons[id] }
  97. end
  98.  
  99. #--------------------------------------------------------------------------
  100. # * Get Item Object Array
  101. #--------------------------------------------------------------------------
  102. def armors
  103. @armors.keys.sort.collect {|id| $data_armors[id] }
  104. end
  105.  
  106. #--------------------------------------------------------------------------
  107. # * Get Array of All Item Objects
  108. #--------------------------------------------------------------------------
  109. def all_items
  110. items + (weapons + armors)
  111. end
  112.  
  113. #--------------------------------------------------------------------------
  114. # * Get Container Object Corresponding to Item Class
  115. #--------------------------------------------------------------------------
  116. def item_container(item_class)
  117. return @items if item_class == RPG::Item
  118. return @weapons if item_class == RPG::Weapon
  119. return @armors if item_class == RPG::Armor
  120. return nil
  121. end
  122.  
  123. #--------------------------------------------------------------------------
  124. # * Get Number of Items Possessed
  125. #--------------------------------------------------------------------------
  126. def item_number(item)
  127. container = item_container(item.class)
  128. container ? container[item.id] || 0 : 0
  129. end
  130.  
  131.  
  132. #--------------------------------------------------------------------------
  133. # * Get Maximum Number of Items Possessed
  134. #--------------------------------------------------------------------------
  135. def max_item_number(item)
  136. return 99
  137. end
  138.  
  139. #--------------------------------------------------------------------------
  140. # * Determine if Maximum Number of Items Are Possessed
  141. #--------------------------------------------------------------------------
  142. def item_max?(item)
  143. item_number(item) >= max_item_number(item)
  144. end
  145.  
  146. #--------------------------------------------------------------------------
  147. # * Determine Item Possession Status
  148. # include_equip : Include equipped items
  149. #--------------------------------------------------------------------------
  150. def has_item?(item)
  151. return item_number(item) > 0
  152. end
  153.  
  154. #--------------------------------------------------------------------------
  155. # * Increase/Decrease Items
  156. #--------------------------------------------------------------------------
  157. def gain_item(item, amount)
  158. container = item_container(item.class)
  159. return unless container
  160. last_number = item_number(item)
  161. new_number = last_number + amount
  162. container[item.id] = [[new_number, 0].max, max_item_number(item)].min
  163. container.delete(item.id) if container[item.id] == 0
  164. $game_map.need_refresh = true
  165. end
  166.  
  167. #--------------------------------------------------------------------------
  168. # * Lose Items
  169. # include_equip : Include equipped items
  170. #--------------------------------------------------------------------------
  171. def lose_item(item, amount, include_equip = false)
  172. gain_item(item, -amount, include_equip)
  173. end
  174.  
  175. end
Advertisement
Add Comment
Please, Sign In to add comment