Advertisement
Dekita

Perfect MMORPG Meditate

Aug 30th, 2012
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 16.44 KB | None | 0 0
  1. #Dekita's=======================================================================
  2. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  3. #===============================================================================
  4. #                                                                          v1.0
  5. #                        ★ Perfect MMORPG Meditate™ ★
  6. #
  7. #===============================================================================
  8. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  9. #===============================================================================
  10. #
  11. # -- Last updated: 29/08/2o12
  12. #
  13. # -- Difficulty: N/A
  14. #
  15. # -- Customisation: Better Than A Kick In The Nuts - (Low)
  16. #
  17. # -- Requires: N/A
  18. #
  19. # -- Recommended: N/A
  20. #
  21. # -- Compatable: RPG Maker VX Ace ONLY!
  22. #                
  23. #===============================================================================
  24. #===============================================================================
  25. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  26. #===============================================================================
  27. #===============================================================================
  28. # ☆ Script Information:
  29. #=======================
  30. # This script is simply a replica of most mmorpg games meditate function, e.g
  31. # press [x] button and regenerate hp/mp/ect (works on the map not in battle)
  32. #
  33. # NOTE: if testing this script out for the first time i recommend setting your
  34. # actors hp and mp to 100. As well as playing around with your hrg/mrg/trg rates.
  35. #
  36. # NOTE2: This will automatically play the sound effect for your chosen animation.
  37. #===============================================================================
  38. # ☆ TERMS OF USE:
  39. #===============================================================================
  40. #
  41. # 1. You must give credit to Dekita.
  42. #
  43. # 2. This script is for NON-Commercial use ONLY!*
  44. #
  45. # 3. You CANNOT give credit to yourself for Re-posting this script
  46. #    or Posting a modified version.*
  47. #
  48. # 4. Do not Re-Distribute this script.
  49. #
  50. # 5. You are NOT allowed to convert this script to any other engine,
  51. #    E.G converting it from RGSS3 into RGSS2.*
  52. #
  53. # 6. ENJOY!
  54. #
  55. #-------------------------------------------------------------------------------
  56. # * = Unless permissions are given by Dekita. < e-mail DekitaRPG@gmail.com
  57. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  58. #===============================================================================
  59.  
  60. #===============================================================================
  61. # ☆ History:
  62. #============
  63. # D - M - Y
  64. # 29/08/2o12 - Added a lil bit of customisation,
  65. #            - Added TP Regen/Gain,
  66. #            - Improved regeneration formula,
  67. # 28/08/2o12 - Fixed Meditate wait,
  68. # 25/08/2o12 - started,
  69. #===============================================================================
  70.  
  71. #===============================================================================
  72. # ☆ Credit and Thanks to :
  73. #==========================
  74. # N/A
  75. #===============================================================================
  76.  
  77. #===============================================================================
  78. # ☆ Foresight Into The Future:
  79. #==============================
  80. # N/A
  81. #-------------------------------------------------------------------------------
  82. # If you have any ideas e-mail me at DekitaRPG@gmail.com
  83. #===============================================================================
  84.  
  85. #===============================================================================
  86. # ☆ Known Bugs:
  87. #=================
  88. # N/A
  89. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  90. # If a new bug is found please e-mail me at DekitaRPG@gmail.com
  91. #===============================================================================
  92.  
  93. #===============================================================================
  94. # ☆ INSTRUCTIONS:
  95. #=================
  96. # Place this script UNDER "▼ Materials" and ABOVE "▼ Main" in your script editor.
  97. #===============================================================================
  98.  
  99. #===============================================================================
  100. # ☆ Import:
  101. #===========
  102. $imported = {} if $imported.nil?
  103. $imported["DPB-PMEDI"] = true
  104. #
  105. #===============================================================================
  106. module DPB
  107.   module PMEDITATE
  108. #===============================================================================#
  109. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
  110. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
  111. #                                                                               #
  112. #                        ★ Perfect MMORPG Meditate™ ★
  113. #
  114. #                              - CUSTOMISATION -                                #
  115. #                                                                               #                                                                               #
  116. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
  117. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
  118. #===============================================================================#
  119. #                           - DekitaRPG@gmail.com -                             #
  120. #===============================================================================#
  121. # make this false if you dont want to draw the gauges on screen.
  122. # you can also go to line 270 if using a real hud script and delete everything
  123. # below it.(if you dont plan on ever using the gauges).
  124.  
  125. SHOW_GAUGES_ON_MAP_SCREEN = true
  126. #
  127. # NOTE:
  128. # Meditate regeneration has a formula for how much hp/mp you regain
  129. # the formula is:
  130. # HPgain (the base hp gain defined below)
  131. # + (actors hrg/mrg/trg * 100)(1% hrg/mrg/trg = 1 extra hp/mp/tp gained)
  132. # = total recovery value,
  133. # therefor more hp/mp/tp regen the more you gain per increase.
  134. #
  135. #
  136. #
  137. # Meditate_wait_time time also has a formula
  138. # the formula is:
  139. # Meditate_wait_time / Actors recovery rate.
  140. # therefor more rec value = faster regen , less = slower regen time
  141.    
  142.     #the keyboard key for meditating.
  143.     MEDITATEKEY = :L
  144.     #other keys:
  145.     #   :Button    Default Keyboard Button
  146.     #      :L        Q
  147.     #      :R        W
  148.     #      :X        A
  149.     #      :Y        S
  150.     #      :Z        D
  151.  
  152.     #Base wait time for meditate regeneration.
  153.     Meditate_wait_time = 20 #(frames)
  154.    
  155.     #animation_id for meditate
  156.     MEDIANI = 38
  157.  
  158.     #TURN_OFF_HP to not gain hp during meditate.
  159.     GAIN_HP = true
  160.     #BASE HP gain while meditating(in between wait time's (defined above))
  161.     HPgain = 1
  162.    
  163.     #TURN_OFF_MP to not gain hp during meditate.
  164.     GAIN_MP = true
  165.     #BASE MP gain while meditating(in between wait time's (defined above))
  166.     MPgain = 1
  167.    
  168.     #TURN_OFF_TP to not gain hp during meditate.
  169.     GAIN_TP = false
  170.     #BASE TP gain while meditating(in between wait time's (defined above))
  171.     TPgain = 1
  172.      
  173.   end #Pmeditate
  174. end # DPB
  175. #===============================================================================#
  176. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
  177. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
  178. #                                                                               #
  179. #                        ★ Perfect MMORPG Meditate™ ★
  180. #
  181. #                               - SCRIPT BEGIN -                                #
  182. #                                                                               #                                                                               #
  183. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
  184. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
  185. #===============================================================================#
  186. #                           - DekitaRPG@gmail.com -                             #
  187. #===============================================================================#
  188. # Keyboard four de map ? no
  189. class Scene_Map < Scene_Base
  190.   alias dpbzmediscene update_scene
  191.     def update_scene
  192.       dpbzmediscene
  193. # Define call meditate from map  
  194.      update_call_meditate unless scene_changing? or $game_player.moving?    
  195. end # update scene
  196.  
  197. # Define call meditate from map  
  198. def update_call_meditate
  199.    if Input.press?(DPB::PMEDITATE::MEDITATEKEY)
  200.        call_meditate
  201. end
  202. end
  203. # Define call meditate from map  
  204.   def call_meditate
  205.     $game_player.animation_id = DPB::PMEDITATE::MEDIANI
  206.     dpbzwait((DPB::PMEDITATE::Meditate_wait_time / $game_party.members[0].rec).to_i)
  207. if DPB::PMEDITATE::GAIN_HP  
  208.     hpplusvaltote
  209.   end
  210.   if DPB::PMEDITATE::GAIN_MP
  211.     mpplusvaltote
  212.   end
  213.   if DPB::PMEDITATE::GAIN_TP
  214.     tpplusvaltote
  215.   end
  216.     ##
  217. end
  218.   #--------------------------------------------------------------------------
  219.   # * dpbzwait
  220.   #--------------------------------------------------------------------------
  221.   def dpbzwait(duration)
  222.     fade_loop(duration) {|v| Graphics.frame_count = v }
  223.   end
  224.  
  225. # formula for hp regen during meditate
  226. def hpplusvaltote
  227.     hpval1 = DPB::PMEDITATE::HPgain
  228.     hpval2 = ($game_party.members[0].hrg * 100).to_i
  229.     hpvaltote = (hpval1 + hpval2)
  230.     $game_party.members[0].hp += hpvaltote
  231. end
  232.  
  233. # formula for mp regen during meditate  
  234.  def mpplusvaltote
  235.     mpval1 = DPB::PMEDITATE::MPgain
  236.     mpval2 = ($game_party.members[0].mrg * 100).to_i
  237.     mpvaltote = (mpval1 + mpval2)
  238.     $game_party.members[0].mp += mpvaltote
  239. end
  240.  
  241. # formula for mp regen during meditate  
  242.  def tpplusvaltote
  243.     tpval1 = DPB::PMEDITATE::TPgain
  244.     tpval2 = ($game_party.members[0].trg * 100).to_i
  245.     tpvaltote = (tpval1 + tpval2)
  246.     $game_party.members[0].tp += tpvaltote
  247. end
  248.  
  249. end# scenemap
  250.  
  251. class Game_Player < Game_Character    
  252.   #--------------------------------------------------------------------------
  253.   # * Determine if Movement is Possible
  254.   #--------------------------------------------------------------------------
  255.   alias dpbzmedimove? movable?
  256.   def movable?
  257.     return false if Input.press?(DPB::PMEDITATE::MEDITATEKEY)
  258.     dpbzmedimove?
  259.   end
  260. end
  261. #===============================================================================#
  262. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
  263. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
  264. #                                                                               #
  265. #                        ★ Perfect MMORPG Meditate™ ★
  266. #
  267. #                                - SCRIPT END -                                 #
  268. #                                                                               #                                                                               #
  269. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
  270. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
  271. #===============================================================================#
  272. #                           - DekitaRPG@gmail.com -                             #
  273. #===============================================================================#
  274. #
  275. #
  276. # YOU CAN DELETE EVERYTHING BELOW THIS IF YOU DONT WANT TO SHOW THE HP/MP AND TP
  277. # GAUGES. I RECOMMEND USING A BETTER HUD SO YOU CAN "APPRECIATE" THE MEDITATE
  278. # FUNCTION (I find it "pleasing" to see my hp ect rise in the gauges lol)
  279. #
  280. #
  281. module DPB
  282.   module PHUD    
  283. HP_FONT_SIZE = 15
  284. MP_FONT_SIZE = 15
  285. TP_FONT_SIZE = 15
  286. HUDG_Z = 99 # the z for the hud graphic (from graphics folder)
  287. FACE_Z = 98 # the z value for the face image  
  288.   HP_Z = 98 # the z value for hp gauge
  289.   MP_Z = 98 # the z value for mp gauge
  290.   TP_Z = 98 # the z value for tp gauge    
  291.   end#phud
  292. end#DPB
  293.  
  294. if DPB::PMEDITATE::SHOW_GAUGES_ON_MAP_SCREEN
  295. class HP_HudThing < Window_Base
  296. #----------------------------------------------------
  297. # * Object Initialization
  298. #----------------------------------------------------
  299.   def initialize
  300.         super(-12, -12, Graphics.width, Graphics.height + 10)
  301.         create_contents
  302.         self.opacity = 0
  303.         @actor = $game_party.members[0]
  304.         refresh
  305.   end
  306.   def dpbzhp_gauge_color1;   text_color(28);  end;    # HP gauge 1
  307.   def dpbzhp_gauge_color2;   text_color(29);  end;    # HP gauge 2
  308.   def dpbzmp_gauge_color1;   text_color(22);  end;    # MP gauge 1
  309.   def dpbzmp_gauge_color2;   text_color(23);  end;    # MP gauge 2
  310.   def dpbztp_gauge_color1;   text_color(10);  end;    # TP gauge 1
  311.   def dpbztp_gauge_color2;   text_color(2);  end;     # TP gauge 2
  312. #----------------------------------------------------
  313. # * Refresh
  314. #----------------------------------------------------
  315.   def refresh
  316.         self.contents.clear
  317.         contents.clear
  318.         draw_window_content
  319.         end
  320.   def draw_window_content
  321.      dpbzhp
  322.      dpbzmp
  323.      dpbztp
  324.   end
  325.   def dpbzhp
  326.     self.z = DPB::PHUD::HP_Z
  327.     contents.font.size = DPB::PHUD::HP_FONT_SIZE
  328.     @hp = @actor.hp
  329.     rate = [@actor.hp_rate, 1.0].min
  330.     draw_dpbzhp_gauge(5, -5, 112, rate, dpbzhp_gauge_color1, dpbzhp_gauge_color2)
  331.     change_color(normal_color)
  332.     draw_current_and_max_values(5, 0, 112, @actor.hp, @actor.mhp,
  333.     hp_color(@actor), normal_color)
  334.   end
  335.   def draw_dpbzhp_gauge(dx, dy, dw, rate, color1, color2)
  336.     dw -= 2
  337.     fill_w = [(dw * rate).to_i, dw].min
  338.     gauge_h = 14
  339.     gauge_y = dy + line_height - 2 - gauge_h
  340.     contents.gradient_fill_rect(dx, gauge_y, fill_w, gauge_h, color1, color2)
  341.   end  
  342.   def dpbzmp
  343.     self.z = DPB::PHUD::MP_Z  
  344.     contents.font.size = DPB::PHUD::MP_FONT_SIZE
  345.     @mp = @actor.mp
  346.     rate = [@actor.mp_rate, 1.0].min
  347.     draw_dpbzmp_gauge(5, 15, 112, rate, dpbzmp_gauge_color1, dpbzmp_gauge_color2)
  348.     change_color(normal_color)
  349.     draw_current_and_max_values(5, 20, 112, @actor.mp, @actor.mmp,
  350.     mp_color(@actor), normal_color)
  351.   end
  352.   def draw_dpbzmp_gauge(dx, dy, dw, rate, color1, color2)
  353.     dw -= 2
  354.     fill_w = [(dw * rate).to_i, dw].min
  355.     gauge_h = 14
  356.     gauge_y = dy + line_height - 2 - gauge_h
  357.     contents.gradient_fill_rect(dx, gauge_y, fill_w, gauge_h, color1, color2)
  358.   end  
  359.   def dpbztp
  360.     self.z = DPB::PHUD::TP_Z
  361.     contents.font.size = DPB::PHUD::TP_FONT_SIZE
  362.     @tp = @actor.tp
  363.     rate = [@actor.tp_rate, 1.0].min
  364.     draw_dpbztp_gauge(5, 35, 112, rate, dpbztp_gauge_color1, dpbztp_gauge_color2)
  365.     draw_text(62, 40, 112, line_height, @actor.tp)
  366.     end
  367.   def draw_dpbztp_gauge(dx, dy, dw, rate, color1, color2)
  368.     dw -= 2
  369.     fill_w = [(dw * rate).to_i, dw].min
  370.     gauge_h = 14
  371.     gauge_y = dy + line_height - 2 - gauge_h
  372.     contents.gradient_fill_rect(dx, gauge_y, fill_w, gauge_h, color1, color2)
  373.   end  
  374.   def update
  375.         super
  376.         return if !self.visible
  377.         if @level != @actor.level or @hp != @actor.hp or @mp != @actor.mp or
  378.           @tp != @actor.tp or @exp != @actor.exp or @gold != $game_party.gold
  379.           refresh
  380.         end
  381.       end
  382. end
  383. class Spriteset_Map
  384.   alias dpbzhud_initialize initialize
  385.   alias dpbzhud_dispose dispose
  386.   alias dpbzhud_update update
  387.   def initialize
  388.     @trash = []
  389.     @winhud = HP_HudThing.new    
  390.      dpbzhud_initialize
  391.   end
  392.   def dispose
  393.     dpbzhud_dispose
  394.     @winhud.dispose
  395.   end
  396.   def update
  397.     dpbzhud_update
  398.     @winhud.update
  399.       end
  400.     end#spriteset map
  401.   end
  402.   ############################################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement