cooldoode325

Equip_Levels_Up

Jan 8th, 2014
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.95 KB | None | 0 0
  1. =begin
  2. Equipment Levels Up
  3. by Fomar0153
  4. Version 1.0
  5. ----------------------
  6. Notes
  7. ----------------------
  8. This script allows weapons to grow stronger and level up when they
  9. gain exp or ap.
  10. ----------------------
  11. Instructions
  12. ----------------------
  13. Requires my individual equipment script. (Make sure it is version 1.1+)
  14. Requires an AP script if leveling weapons using AP.
  15. Customise the variables in the module below to set up the script to your
  16. liking.
  17.  
  18. Notetags
  19. <maxlevel x> - adds a non-default max level to the tagged equipment.
  20. ----------------------
  21. Known bugs
  22. ----------------------
  23. None
  24. =end
  25.  
  26. module Fomar
  27.  
  28. # If you only want to implement this for weapons or armours set
  29. # the following to false as you see fit
  30. WLU_WEAPONS_LEVEL_UP = true
  31. WLU_ARMOURS_LEVEL_UP = true
  32. # This script can be set up to use either EXP or AP
  33. # For AP you will also need an AP system.
  34. # true -> uses AP
  35. # false -> uses EXP
  36. WLU_USE_AP = false
  37. # Determines the order of the substitutions
  38. # true -> level, name
  39. # false -> name, level
  40. WLU_PREFIX = false
  41. # the %s are replaced by the level and name of the weapon
  42. WLU_VOCAB_WEAPON_NAME = "%s LV %s"
  43. # Default max level
  44. # set to 0 to only allow chosen weapons to level up
  45. WLU_DEF_MAX_LEVEL = 0
  46. # Default stat increase per level (percentage)
  47. WLU_DEF_PARAM_INC = 25
  48. # Set to false if you want the price of the item to be unaffected
  49. # by leveling up
  50. WLU_PRICE_LEVEL_UP = true
  51. # Default experience per level
  52. # I have provided two defaults, one designed for EXP and one for AP
  53. def self.WLU_EXP_FOR_LEVEL(item); return item.performance * 100; end
  54. def self.WLU_AP_FOR_LEVEL(item); return item.performance; end
  55.  
  56. end
  57.  
  58.  
  59. class Game_CustomEquip < Game_BaseItem
  60.  
  61. alias wlu_initialize initialize
  62. def initialize
  63. wlu_initialize
  64. @exp = 0
  65. @level = 1
  66. end
  67.  
  68. def gain_exp(exp)
  69. return unless levels?
  70. @exp += exp
  71. last_level = @level
  72. unless Fomar::WLU_USE_AP
  73. while @exp >= @level * Fomar.WLU_EXP_FOR_LEVEL(object) and @level < object.max_level
  74. @level += 1
  75. $game_message.add(object.name + " levels up.")
  76. end
  77. else
  78. while @exp >= @level * Fomar.WLU_AP_FOR_LEVEL(object) and @level < object.max_level
  79. @level += 1
  80. $game_message.add(object.name + " levels up.")
  81. end
  82. end
  83. end
  84.  
  85. def levels?
  86. return false if is_nil?
  87. return (((is_weapon? and Fomar::WLU_WEAPONS_LEVEL_UP) or
  88. (is_armor? and Fomar::WLU_ARMOURS_LEVEL_UP)) and
  89. object.max_level > 0)
  90. end
  91.  
  92. alias wlu_name name
  93. def name
  94. return nil if is_nil?
  95. return wlu_name unless levels?
  96. return sprintf(Fomar::WLU_VOCAB_WEAPON_NAME,@level,wlu_name) if Fomar::WLU_PREFIX
  97. return sprintf(Fomar::WLU_VOCAB_WEAPON_NAME,wlu_name,@level)
  98. end
  99.  
  100. alias wlu_price price
  101. def price
  102. return nil if is_nil?
  103. return wlu_price unless levels?
  104. return wlu_price unless Fomar::WLU_PRICE_LEVEL_UP
  105. return (100 + Fomar::WLU_DEF_PARAM_INC * @level + object.price)/100
  106. end
  107.  
  108. def params
  109. return nil if is_nil?
  110. par = object.params.clone
  111. for i in 0..par.size - 1
  112. par[i] *= 100 + Fomar::WLU_DEF_PARAM_INC * (@level - 1)
  113. par[i] /= 100
  114. end
  115. return par
  116. end
  117.  
  118. alias wlu_performance performance
  119. def performance
  120. return nil if is_nil?
  121. return wlu_performance unless levels?
  122. par = params
  123. p = 0
  124. for pa in par
  125. p += pa
  126. end
  127. if is_weapon?
  128. p += par[2] + par[4]
  129. else
  130. p += par[3] + par[5]
  131. end
  132. return p
  133. end
  134.  
  135. end
  136.  
  137. module RPG
  138. class EquipItem
  139. def max_level
  140. if self.note =~ /<maxlevel (.*)>/i
  141. return $1.to_i
  142. else
  143. return Fomar::WLU_DEF_MAX_LEVEL
  144. end
  145. end
  146. end
  147. end
  148.  
  149. class Game_Actor < Game_Battler
  150.  
  151. alias wlu_gain_exp gain_exp
  152. def gain_exp(exp)
  153. for equip in @equips
  154. equip.gain_exp(exp)
  155. end
  156. wlu_gain_exp(exp)
  157. end
  158.  
  159. def gain_ap(ap)
  160. for equip in @equips
  161. equip.gain_exp(ap)
  162. end
  163. end
  164.  
  165. def custom_equips
  166. return @equips
  167. end
  168.  
  169. # rewrites param_plus
  170. def param_plus(param_id)
  171. p = super(param_id)
  172. for equip in @equips
  173. p += equip.params[param_id] unless equip.is_nil?
  174. end
  175. return p
  176. end
  177.  
  178. end
  179.  
  180.  
  181. class Window_Base < Window
  182.  
  183. alias wlu_draw_item_name draw_item_name
  184. def draw_item_name(item, x, y, enabled = true, width = 172)
  185. return unless item
  186. if item.is_a?(Game_CustomEquip)
  187. return if item.is_nil?
  188. end
  189. wlu_draw_item_name(item, x, y, enabled = true, width)
  190. end
  191.  
  192. end
  193.  
  194. class Window_EquipSlot < Window_Selectable
  195.  
  196. # rewrites draw_item
  197. def draw_item(index)
  198. return unless @actor
  199. rect = item_rect_for_text(index)
  200. change_color(system_color, enable?(index))
  201. draw_text(rect.x, rect.y, 92, line_height, slot_name(index))
  202. draw_item_name(@actor.custom_equips[index], rect.x + 92, rect.y, enable?(index))
  203. end
  204.  
  205. end
Advertisement
Add Comment
Please, Sign In to add comment