Advertisement
Dekita

Untitled

Jun 14th, 2014
783
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.98 KB | None | 0 0
  1. if true # << Make true to use this script, false to disable.
  2. #===============================================================================
  3. #
  4. # ☆ $D13x - MMO Style Regen
  5. # -- Author : Dekita
  6. # -- Version : 1.2
  7. # -- Level : Easy
  8. # -- Requires : $D13x Core v1.6+
  9. # -- Engine : RPG Maker VX Ace.
  10. #
  11. #===============================================================================
  12. # ☆ Import
  13. #-------------------------------------------------------------------------------
  14. $D13x={}if$D13x==nil
  15. $D13x[:MMO_Regen]=true
  16. #===============================================================================
  17. # ☆ Updates
  18. #-------------------------------------------------------------------------------
  19. # D /M /Y
  20. # 14/o6/2o14 - Updated efficiency,
  21. # - Added :second/:frames time counters
  22. # 18/o5/2o13 - Update, (Key Menu HUD now shows regen key)
  23. # o4/o4/2o13 - Started, Finished,
  24. #
  25. #===============================================================================
  26. # ☆ Introduction
  27. #-------------------------------------------------------------------------------
  28. # This script adds a MMO style regeneration method into the game.
  29. # Each second you (all battle members) will regenerate hp/mp/tp according
  30. # to the formulas within this script. Can also enable for enemies.
  31. #
  32. # you can have extra regen bonuses for holding down a key
  33. # and disable all regen unless a key is being pressed.
  34. #
  35. # The default formulas will allow for more hp to be regenerated based on
  36. # the actors max hp, but you can make the formula check whatever actor stats
  37. # you want, for example, you could easily base the regen method against
  38. # an actors equipment or skills... ( << needs coding know-how )
  39. #
  40. # This script requires my $D13x Core, therefor most keyboard keys are available
  41. # as the "Regen" key. (By default its the 'R' Key)
  42. #
  43. #===============================================================================
  44. # ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
  45. #===============================================================================
  46. # 1. You MUST give credit to "Dekita" !!
  47. # 2. You are NOT allowed to repost this script.(or modified versions)
  48. # 3. You are NOT allowed to convert this script.
  49. # 4. You are NOT allowed to use this script for Commercial games.
  50. # 5. ENJOY!
  51. #
  52. # "FINE PRINT"
  53. # By using this script you hereby agree to the above terms and conditions,
  54. # if any violation of the above terms occurs "legal action" may be taken.
  55. # Not understanding the above terms and conditions does NOT mean that
  56. # they do not apply to you.
  57. # If you wish to discuss the terms and conditions in further detail you can
  58. # contact me at http://dekitarpg.wordpress.com/
  59. #
  60. #===============================================================================
  61. # ☆ Instructions
  62. #-------------------------------------------------------------------------------
  63. # Place Below " ▼ Materials " and Above " ▼ Main " in your script editor.
  64. #
  65. #===============================================================================
  66. # ☆ HELP
  67. #-------------------------------------------------------------------------------
  68. # You really should'nt need any...
  69. #
  70. #===============================================================================
  71. module MMO_Regen
  72. #===============================================================================
  73. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  74. # ☆ General Settings
  75. #-----------------------------------------------------------------------------
  76. # MODES:
  77. # :second = regen triggers every second.
  78. # :frames = regen triggers at a frequency equal to the number of frames equal
  79. # to the value of MMO_FRAME
  80. Regen_Mode = :frames
  81. #-----------------------------------------------------------------------------
  82. # If Regen_Mode is :frames this will be used.
  83. MMO_FRAME = 180
  84. #-----------------------------------------------------------------------------
  85. # The key to press for 'bonus' Regeneration
  86. Regen_Key = :E
  87. #-----------------------------------------------------------------------------
  88. # The animation displayed for 'bonus' regen
  89. Animation = 2
  90. #-----------------------------------------------------------------------------
  91. # Allow base regen to happen without key press
  92. Regen_Per_Sec = true
  93. #-----------------------------------------------------------------------------
  94. # Allow Regen in battle scene ?
  95. Allow_In_Battle = true
  96. #-----------------------------------------------------------------------------
  97. # Allow Regen on the game map ?
  98. Allow_On_Map = true
  99. #-----------------------------------------------------------------------------
  100. # Allow Enemies the stndard regen each second ? (disregard key press)
  101. Enemy_Can_Regen = true
  102. #-----------------------------------------------------------------------------
  103. # Disable Default Regen Method ? (eg. hrg, mrg, trg)
  104. Disable_Default_Regen = true
  105. #-----------------------------------------------------------------------------
  106. # Requires $D13x Key Menu HUD v1.2+
  107. # = [switch, show, x, y, icon, hue]
  108. Regen_HUD = [10 , true, 512, 268, 112, 0]
  109.  
  110. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  111. # ☆ Basic Calculation Settings
  112. #-----------------------------------------------------------------------------
  113. # The Min Value of regen each second.
  114. Base_HP = 1
  115. Base_MP = 1
  116. Base_TP = 0
  117.  
  118. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  119. # ☆ Advanced Calculation Settings
  120. #-----------------------------------------------------------------------------
  121. # This is where you would change the calculations used in determining
  122. # the total hp/mp/tp gained each regen.
  123. # if you wish to completely disable one of the regen methods,
  124. # simply put a ' # ' at the start of each line in the method.
  125. #-----------------------------------------------------------------------------
  126. # The Total Value for HP regen each second.
  127. def self.hp_regen(actor)
  128. sum = Base_HP + (actor.mhp/500) + (actor.hrg * 100)
  129. sum += (actor.mhp/100) if Keys.press?(Keys::Key[Regen_Key])
  130. actor.hp += sum.to_i
  131. end
  132. #-----------------------------------------------------------------------------
  133. # The Total Value for MP regen each second.
  134. def self.mp_regen(actor)
  135. sum = Base_MP + (actor.mmp/500) + (actor.mrg * 100)
  136. sum += (actor.mmp/100) if Keys.press?(Keys::Key[Regen_Key])
  137. actor.mp += sum.to_i
  138. end
  139. #-----------------------------------------------------------------------------
  140. # The Total Value for TP regen each second.
  141. def self.tp_regen(actor)
  142. sum = Base_TP
  143. sum += Base_TP + (actor.trg * 100) if Keys.press?(Keys::Key[Regen_Key])
  144. actor.tp += sum
  145. end
  146. #####################
  147. # CUSTOMISATION END #
  148. end #####################
  149. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
  150. # #
  151. # http://dekitarpg.wordpress.com/ #
  152. # #
  153. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
  154. #===============================================================================#
  155. # ARE YOU MODIFYING BEYOND THIS POINT? \.\. #
  156. # YES?\.\. #
  157. # OMG, REALLY? \| #
  158. # WELL SLAP MY FACE AND CALL ME A DRAGONITE.\..\.. #
  159. # I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\.. #
  160. #===============================================================================#
  161. module MMO_Regen
  162. #===============================================================================
  163. #-----------------------------------------------------------------------------
  164. #
  165. #-----------------------------------------------------------------------------
  166. def setup_regen
  167. @last_regen = Time.now.sec
  168. @regen_frames = MMO_FRAME
  169. end
  170. #-----------------------------------------------------------------------------
  171. #
  172. #-----------------------------------------------------------------------------
  173. def do_deki_regen
  174. @regen_frames -= 1
  175. return unless can_do_mmo_regen?
  176. reset_last_regen
  177. perform_mmo_regen
  178. mmo_battle_regen_for_enemies
  179. end
  180. #-----------------------------------------------------------------------------
  181. #
  182. #-----------------------------------------------------------------------------
  183. def can_do_mmo_regen?
  184. case Regen_Mode
  185. when :frames
  186. return false if @regen_frames > 0
  187. return false if !Regen_Per_Sec unless Keys.press?(Keys::Key[Regen_Key])
  188. else
  189. return false if @last_regen == Time.now.sec
  190. return false if !Regen_Per_Sec unless Keys.press?(Keys::Key[Regen_Key])
  191. end
  192. return true
  193. end
  194. #-----------------------------------------------------------------------------
  195. #
  196. #-----------------------------------------------------------------------------
  197. def reset_last_regen
  198. setup_regen
  199. end
  200. #-----------------------------------------------------------------------------
  201. #
  202. #-----------------------------------------------------------------------------
  203. def perform_mmo_regen
  204. $game_party.battle_members.each do |actor|
  205. next if actor.hp <= 0
  206. MMO_Regen.hp_regen(actor)
  207. MMO_Regen.mp_regen(actor)
  208. MMO_Regen.tp_regen(actor)
  209. if Keys.press?(Keys::Key[Regen_Key])
  210. perform_mmo_regen_ani
  211. end
  212. actor.refresh
  213. end
  214. end
  215. #-----------------------------------------------------------------------------
  216. #
  217. #-----------------------------------------------------------------------------
  218. def perform_mmo_regen_ani
  219. get_mmo_regen_ani_targets.each do |char|
  220. next unless char.actor != nil
  221. char.animation_id = Animation
  222. end
  223. end
  224. #-----------------------------------------------------------------------------
  225. #
  226. #-----------------------------------------------------------------------------
  227. def get_mmo_regen_ani_targets
  228. [$game_player] + $game_player.followers
  229. end
  230. #-----------------------------------------------------------------------------
  231. #
  232. #-----------------------------------------------------------------------------
  233. def mmo_battle_regen_for_enemies
  234. return unless SceneManager.scene_is?(Scene_Battle)
  235. $game_troop.compact.members.each do |actor|
  236. next if actor.hp <= 0
  237. break unless Enemy_Can_Regen
  238. MMO_Regen.hp_regen(actor)
  239. MMO_Regen.mp_regen(actor)
  240. MMO_Regen.tp_regen(actor)
  241. actor.refresh
  242. end
  243. @status_window.refresh if @status_window
  244. end
  245. #-----------------------------------------------------------------------------
  246. #
  247. #-----------------------------------------------------------------------------
  248. end
  249. #===============================================================================
  250. class Game_Battler < Game_BattlerBase
  251. #===============================================================================
  252. #-----------------------------------------------------------------------------
  253. #
  254. #-----------------------------------------------------------------------------
  255. alias :regen_all_SM :regenerate_all
  256. #-----------------------------------------------------------------------------
  257. #
  258. #-----------------------------------------------------------------------------
  259. def regenerate_all
  260. return if MMO_Regen::Disable_Default_Regen
  261. return regen_all_SM
  262. end
  263. #-----------------------------------------------------------------------------
  264. #
  265. #-----------------------------------------------------------------------------
  266. end
  267. #===============================================================================
  268. class Scene_Map < Scene_Base
  269. #===============================================================================
  270. #-----------------------------------------------------------------------------
  271. #
  272. #-----------------------------------------------------------------------------
  273. include MMO_Regen
  274. #-----------------------------------------------------------------------------
  275. #
  276. #-----------------------------------------------------------------------------
  277. alias :start_deki_regen_SM :start
  278. alias :update_deki_regen_SM :update
  279. #-----------------------------------------------------------------------------
  280. #
  281. #-----------------------------------------------------------------------------
  282. def start
  283. setup_regen if MMO_Regen::Allow_On_Map
  284. start_deki_regen_SM
  285. end
  286. #-----------------------------------------------------------------------------
  287. #
  288. #-----------------------------------------------------------------------------
  289. def update
  290. update_deki_regen_SM
  291. do_deki_regen if MMO_Regen::Allow_On_Map
  292. end
  293. #-----------------------------------------------------------------------------
  294. #
  295. #-----------------------------------------------------------------------------
  296. end
  297. #===============================================================================
  298. class Scene_Battle < Scene_Base
  299. #===============================================================================
  300. #-----------------------------------------------------------------------------
  301. #
  302. #-----------------------------------------------------------------------------
  303. include MMO_Regen
  304. #-----------------------------------------------------------------------------
  305. #
  306. #-----------------------------------------------------------------------------
  307. alias :start_deki_regen_SB :start
  308. alias :update_deki_regen_SB :update
  309. #-----------------------------------------------------------------------------
  310. #
  311. #-----------------------------------------------------------------------------
  312. def start
  313. start_deki_regen_SB
  314. setup_regen if MMO_Regen::Allow_In_Battle
  315. end
  316. #-----------------------------------------------------------------------------
  317. #
  318. #-----------------------------------------------------------------------------
  319. def update
  320. update_deki_regen_SB
  321. do_deki_regen if MMO_Regen::Allow_In_Battle
  322. end
  323. #-----------------------------------------------------------------------------
  324. #
  325. #-----------------------------------------------------------------------------
  326. end
  327. #==============================================================================#
  328. # http://dekitarpg.wordpress.com/ #
  329. #==============================================================================#
  330. end # if true # << Make true to use this script, false to disable.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement