Jragyn

[MV] J_MapTime

Sep 27th, 2016
51
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* -------------------------------------------------------------------------- */
  2. // J_MapTime
  3. // V: 1.0
  4.  
  5. /*:@plugindesc Provides functionality for HRG/MRG/TRG while on the map.
  6. @author J
  7.  
  8. @param useTPforDash
  9. @desc Enable/Disable to control dashing with TP availability.
  10. @default true
  11.  
  12. @help This plugin adds the functionality of HP/MP/TP regeneration on the map.
  13.   Ideally, this system would be used in conjunction with an ABS of sorts,
  14.   as it was originally designed to hold hands with qABS, but it does work all
  15.   by itself, too.
  16.  
  17. MATH BREAKDOWN: actor's HRG = 50(%).
  18.   formula per tick = ((actor.hrg * 100) / 2) / 5;
  19.  ((0.5 * 100) / 2) / 5
  20.  (50 / 2)  / 5
  21.  25 / 5
  22.  5 per tick (1 tick = 30 frames = 0.5 seconds)
  23.  
  24. In short, the actor will regenerate 1/10 of whatever his HRG/MRG is, per tick.
  25. I opted into making it flatHP instead of %maxHP since % would be pretty op.
  26.  
  27. NOTE: TRG's regeneration is updated 10x faster (1 tick = 3 frames = 0.05s)
  28.   Currently, it is being used as "stamina".
  29.   Try making a skill cost like, 15 TP or something and use it as a basic
  30.   attack limiter to prevent the player from swinging excessively.
  31.   If you don't like it, you can just turn it off, too.
  32.   For reference, it takes 15% TRG to cancel out TP depletion while dashing.
  33.  
  34.  If you intend to use this, I highly recommend you make use of a couple other
  35.  plugins as well:
  36.     > Some ABS (qABS works, but I don't have a link to the original code)
  37.     > A functional HUD: http://pastebin.com/53UjUNiZ (I made it myself :] )
  38. */
  39. /* -------------------------------------------------------------------------- */
  40. var Imported = Imported || {};
  41. Imported.J_MapTime = true;
  42.  
  43. var J = J || {};
  44. J.mapTime = J.mapTime || {};
  45. J.mapTime.Parameters = PluginManager.parameters('J_MapTime');
  46. J.mapTime.useTPforDash = String(J.mapTime.Parameters['useTPforDash']);
  47.  
  48. (function() { // start plugin.
  49. /* -------------------------------------------------------------------------- */
  50. //  Game_Map Modifications
  51. //    Handles all the extra variables and adds functionality for the xRG stuff.
  52. /* -------------------------------------------------------------------------- */
  53.  
  54.   // adds in timing variables for monitoring when to tick the regenerations.
  55.   var _Game_Map_jRegen_initialize = Game_Map.prototype.initialize;
  56.   Game_Map.prototype.initialize = function() {
  57.     _Game_Map_jRegen_initialize.call(this);
  58.     this._timingHPMP = 0;
  59.     this._timingTP = 0;
  60.   };
  61.  
  62.   // processes the function that provides HRG/MRG/TRG on the map.
  63.   var _Game_Map_jRegen_update = Game_Map.prototype.update;
  64.   Game_Map.prototype.update = function(sceneActive) {
  65.       _Game_Map_jRegen_update.call(this, sceneActive);
  66.       this.regenOnMap();
  67.   };
  68.  
  69.   // Checks if party exists, then performs the onMapFX once per 30 frames.
  70.   // Effects are divided into HP+MP, and TP, so that TP can regenerate at
  71.   //   a faster rate for purpose of being like "stamina".
  72.   Game_Map.prototype.regenOnMap = function() {
  73.     if ($gameParty != null) { var actor = $gameParty.leader(); }
  74.     if (actor) {
  75.       if (this._timingHPMP <= 0) {
  76.         this.doHPMPregen(actor);
  77.         this._timingHPMP = 30;
  78.       }
  79.       else { this._timingHPMP--; }
  80.       if (this._timingTP <= 0) {
  81.         this.doTPregen(actor);
  82.         this._timingTP = 3;
  83.       }
  84.       else { this._timingTP--; }
  85.     }
  86.   };
  87.  
  88.   // Here, HP/MP regeneration is handled based on HRG/MRG.
  89.   // It is significantly slower than TP Regeneration.
  90.   // Additionally, it is flat regen, not %max regen.
  91.   Game_Map.prototype.doHPMPregen = function(actor) {
  92.     var hpRegen = ((actor.hrg * 100) / 2) / 5;
  93.     var mpRegen = ((actor.mrg * 100) / 2) / 5;
  94.     actor.gainHp(hpRegen);
  95.     actor.gainMp(mpRegen);
  96.   };
  97.  
  98.   // this rapidly regenerates the player's TP.
  99.   // and also deplete stamina while dashing.
  100.   Game_Map.prototype.doTPregen = function(actor) {
  101.     var mod = 0;
  102.     if (J.mapTime.useTPforDash === "true")
  103.       mod = Game_Player.prototype.isDashButtonPressed() ? 2.5 : 0.0;
  104.     var tpRegen = (((actor.trg + 0.1) * 100) / 10) - mod;
  105.     actor.gainTp(tpRegen);
  106.   };
  107.  
  108.   // this forces the player to be unable to run while out of TP.
  109.   // note: hopefully this is okay since only actor's can dash (?).
  110.   var _Game_CharacterBase_jqmt_realMoveSpeed = Game_CharacterBase.prototype.realMoveSpeed;
  111.   Game_CharacterBase.prototype.realMoveSpeed = function() {
  112.     if (J.mapTime.useTPforDash === "true") {
  113.       if ($gameParty != null) { var actor = $gameParty.leader(); }
  114.       return this._moveSpeed + ((this.isDashing() && actor.tp > 0) ? 1 : 0);
  115.     }
  116.     else { return _Game_CharacterBase_jqmt_realMoveSpeed.call(this); }
  117.   };
  118. /* -------------------------------------------------------------------------- */
  119. //  Window_Base Modification
  120. //    Because floats are innately messy, this is cleans them up visually.
  121. /* -------------------------------------------------------------------------- */
  122.  
  123.   // this fixes the issue of drawing excessively long decimal numbers
  124.   // in places like the menu that draw gauges for HP/MP.
  125.   var _Window_Base_jqmt_drawCurrentAndMax = Window_Base.prototype.drawCurrentAndMax;
  126.   Window_Base.prototype.drawCurrentAndMax = function(current, max, x, y, width, color1, color2) {
  127.     current = current.toFixed(0);
  128.     _Window_Base_jqmt_drawCurrentAndMax.call(this, current, max, x, y, width, color1, color2);
  129.   };
  130. /* -------------------------------------------------------------------------- */
  131. })(); // end plugin.
RAW Paste Data