Advertisement
Dekita

adv regen

Jan 29th, 2013
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.67 KB | None | 0 0
  1. =begin =========================================================================
  2. Dekita's v1.0
  3. ★ Advanced Regen™ ★
  4.  
  5. ================================================================================
  6. Script Information:
  7. ====================
  8. This script allows for more advanced regeneration features for states.
  9. for example , elements resistance / weakness can now be taken into account
  10. for each state. This allows for poison states to be of a poison element,
  11. and if target absorbs poison element, the regen effects would be reversed ie.
  12. absorbed.
  13. each actor and enemy can also have various regen amounts.
  14. this allows for bosses ect to regen less / more than regular enemies.
  15.  
  16. ================================================================================
  17. ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
  18. ================================================================================
  19. 1. You must give credit to "Dekita"
  20. 2. You are NOT allowed to repost this script.(or modified versions)
  21. 3. You are NOT allowed to convert this script.(into other game engines e.g RGSS2)
  22. 4. You are NOT allowed to use this script for Commercial games.
  23. 5. ENJOY!
  24.  
  25. "FINE PRINT"
  26. By using this script you hereby agree to the above terms and conditions,
  27. if any violation of the above terms occurs "legal action" may be taken.
  28. Not understanding the above terms and conditions does NOT mean that
  29. they do not apply to you.
  30. If you wish to discuss the terms and conditions in further detail you can
  31. contact me at http://dekitarpg.wordpress.com/ or DekitaRPG@gmail.com
  32.  
  33. ================================================================================
  34. History:
  35. =========
  36. D /M /Y
  37. 26/o1/2o13 - started && finished,
  38.  
  39. ================================================================================
  40. Credit and Thanks to :
  41. =======================
  42. Liak - for giving me the inspiration :p
  43.  
  44. ================================================================================
  45. Known Bugs:
  46. ============
  47. N/A
  48.  
  49. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  50. If a new bug is found please contact me at
  51. http://dekitarpg.wordpress.com/
  52.  
  53. ================================================================================
  54. INSTRUCTIONS:
  55. ==============
  56. Place this script UNDER "▼ Materials" and ABOVE "▼ Main" in your script editor.
  57.  
  58. ================================================================================
  59. Notetags :
  60. ===========
  61. States:
  62. <hp_regen: X>
  63. <mp_regen: X>
  64. <tp_regen: X>
  65. X = a flaot value, e.g 0.1. CAN BE NEGATIVE e.g -0.1
  66. This decideds the % of hp/mp/tp to be regenerated/depleted when this state
  67. is inflicted.
  68.  
  69. <regen ele: element_id>
  70. element_id = the id of the element (from the database)
  71. This is used for the elemental modifier for all regen effects within the
  72. state (providing the settings in the moule are true )
  73.  
  74. Actors / Enemies:
  75. <hp_regen: X>
  76. <mp_regen: X>
  77. <tp_regen: X>
  78. X = a flaot value, default = 1.0
  79. you can use this to make actors/enemies overall regen rates differ
  80. e.g
  81. <hp_regen: 0.1>
  82. would mean that all hp regenerated from states that have advanced regen effects
  83. would be multiplied by 0.1 before the damage is dealt. this enabled you to
  84. have lower regen effects for bosses ect..
  85.  
  86. =end #=========================================================================#
  87. module Advanced_Regen
  88.  
  89. Mp_Regen_Checks_Elements = true
  90.  
  91. Tp_Regen_Checks_Elements = true
  92.  
  93. end #####################
  94. # CUSTOMISATION END #
  95. #################################################################################
  96. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
  97. # #
  98. # http://dekitarpg.wordpress.com/ #
  99. # #
  100. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
  101. #===============================================================================#
  102. # ARE YOU MODIFYING BEYOND THIS POINT? \.\. #
  103. # YES?\.\. #
  104. # OMG, REALLY? \| #
  105. # WELL SLAP MY FACE AND CALL ME A DRAGONITE.\..\.. #
  106. # I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\.. #
  107. #################################################################################
  108.  
  109. $imported = {} if $imported.nil?
  110. $imported[:Dekita_Adv_Regen] = true
  111.  
  112. #==============================================================================
  113. module DataManager
  114. #==============================================================================
  115.  
  116. class << self
  117. alias :load_database_regen :load_database
  118. end
  119.  
  120. def self.load_database
  121. load_database_regen
  122. load_notetags_regen
  123. end
  124.  
  125. def self.load_notetags_regen
  126. groups = [$data_actors, $data_enemies, $data_states]
  127. for group in groups
  128. for obj in group
  129. next if obj.nil?
  130. obj.load_notetags_regen
  131. end
  132. end
  133. end
  134.  
  135. end # DataManager
  136.  
  137. #==============================================================================
  138. class RPG::Actor < RPG::BaseItem
  139. #==============================================================================
  140.  
  141. attr_reader :hp_regen_rate
  142. attr_reader :mp_regen_rate
  143. attr_reader :tp_regen_rate
  144.  
  145. def load_notetags_regen
  146. @hp_regen_rate = 1.0
  147. @mp_regen_rate = 1.0
  148. @tp_regen_rate = 1.0
  149. self.note.split(/[\r\n]+/).each { |line|
  150. case line
  151. when /<hp_regen: (.*)>/i
  152. @hp_regen_rate = $1.to_f
  153. when /<mp_regen: (.*)>/i
  154. @mp_regen_rate = $1.to_f
  155. when /<tp_regen: (.*)>/i
  156. @tp_regen_rate = $1.to_f
  157. end
  158. } # self.note.split
  159. end
  160.  
  161. end
  162.  
  163. #==============================================================================
  164. class RPG::Enemy < RPG::BaseItem
  165. #==============================================================================
  166.  
  167. attr_reader :hp_regen_rate
  168. attr_reader :mp_regen_rate
  169. attr_reader :tp_regen_rate
  170.  
  171. def load_notetags_regen
  172. @hp_regen_rate = 1.0
  173. @mp_regen_rate = 1.0
  174. @tp_regen_rate = 1.0
  175. self.note.split(/[\r\n]+/).each { |line|
  176. case line
  177. when /<hp_regen: (.*)>/i
  178. @hp_regen_rate = $1.to_f
  179. when /<mp_regen: (.*)>/i
  180. @mp_regen_rate = $1.to_f
  181. when /<tp_regen: (.*)>/i
  182. @tp_regen_rate = $1.to_f
  183. end
  184. } # self.note.split
  185. end
  186.  
  187. end
  188.  
  189. #==============================================================================
  190. class RPG::State < RPG::BaseItem
  191. #==============================================================================
  192.  
  193. attr_reader :adv_hp_regen
  194. attr_reader :adv_mp_regen
  195. attr_reader :adv_tp_regen
  196. attr_reader :regen_element_id
  197.  
  198. def load_notetags_regen
  199. @adv_hp_regen = [false, nil]
  200. @adv_mp_regen = [false, nil]
  201. @adv_tp_regen = [false, nil]
  202. @regen_element_id = 0
  203. self.note.split(/[\r\n]+/).each { |line|
  204. case line
  205. when /<hp_regen: (.*)>/i
  206. @adv_hp_regen = [true, $1.to_f]
  207. when /<mp_regen: (.*)>/i
  208. @adv_mp_regen = [true, $1.to_f]
  209. when /<tp_regen: (.*)>/i
  210. @adv_tp_regen = [true, $1.to_f]
  211. when /<regen ele: (\d+)>/i
  212. @regen_element_id = $1.to_i
  213. #---
  214. end
  215. } # self.note.split
  216. #---
  217. end
  218.  
  219. end
  220.  
  221. #==============================================================================
  222. class Game_Battler < Game_BattlerBase
  223. #==============================================================================
  224.  
  225. def advanced_hp_regen(state)
  226. e = state.regen_element_id == 0 ? 1.0 :
  227. element_rate(state.regen_element_id)
  228. state_hrg = state.adv_hp_regen[1] * e
  229. damage = -(mhp * state_hrg * self.hp_regen_rate).to_i
  230. perform_map_damage_effect if $game_party.in_battle && damage > 0
  231. @result.hp_damage = [damage, max_slip_damage].min
  232. self.hp -= @result.hp_damage
  233. end
  234.  
  235. def advanced_mp_regen(state)
  236. if Advanced_Regen::Mp_Regen_Checks_Elements
  237. e = state.regen_element_id == 0 ? 1.0 :
  238. element_rate(state.regen_element_id)
  239. state_mrg = state.adv_mp_regen[1] * e
  240. else
  241. state_mrg = state.adv_mp_regen[1]
  242. end
  243. damage = -(mmp * state_mrg * self.mp_regen_rate).to_i
  244. @result.mp_damage = [damage, max_slip_damage].min
  245. self.mp -= @result.mp_damage
  246. end
  247.  
  248. def advanced_tp_regen(state)
  249. if Advanced_Regen::Tp_Regen_Checks_Elements
  250. e = state.regen_element_id == 0 ? 1.0 :
  251. element_rate(state.regen_element_id)
  252. state_trg = state.adv_tp_regen[1] * e
  253. else
  254. state_trg = state.adv_tp_regen[1]
  255. end
  256. damage = (100 * state_trg * self.tp_regen_rate).to_i
  257. self.tp += damage
  258. end
  259.  
  260. alias :adv_regenerate_all :regenerate_all
  261. def regenerate_all
  262. adv_regenerate_all
  263. if alive?
  264. @states.each {|id|
  265. advanced_hp_regen($data_states[id]) if $data_states[id].adv_hp_regen[0]
  266. advanced_mp_regen($data_states[id]) if $data_states[id].adv_mp_regen[0]
  267. advanced_tp_regen($data_states[id]) if $data_states[id].adv_tp_regen[0]
  268. }
  269. end
  270. end
  271.  
  272. end
  273.  
  274. #==============================================================================
  275. class Game_Actor < Game_Battler
  276. #==============================================================================
  277.  
  278. def hp_regen_rate
  279. actor.hp_regen_rate
  280. end
  281.  
  282. def mp_regen_rate
  283. actor.mp_regen_rate
  284. end
  285.  
  286. def tp_regen_rate
  287. actor.tp_regen_rate
  288. end
  289.  
  290. end
  291.  
  292. #==============================================================================
  293. class Game_Enemy < Game_Battler
  294. #==============================================================================
  295.  
  296. def hp_regen_rate
  297. enemy.hp_regen_rate
  298. end
  299.  
  300. def mp_regen_rate
  301. enemy.mp_regen_rate
  302. end
  303.  
  304. def tp_regen_rate
  305. enemy.tp_regen_rate
  306. end
  307.  
  308. end
  309.  
  310. #===============================================================================#
  311. # - SCRIPT END - #
  312. #===============================================================================#
  313. # http://dekitarpg.wordpress.com/ #
  314. #===============================================================================#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement