Advertisement
Double_X

DoubleX RMMV Minimalized ATB v100a

Dec 9th, 2015 (edited)
578
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*============================================================================
  2.  *    ## Plugin Info                                                          
  3.  *----------------------------------------------------------------------------
  4.  *    # Plugin Name                                                          
  5.  *      DoubleX RMMV Minimalized ATB                                          
  6.  *----------------------------------------------------------------------------
  7.  *    # Terms Of Use                                                          
  8.  *      You shall keep this plugin's Plugin Info part's contents intact      
  9.  *      You shalln't claim that this plugin's written by anyone other than    
  10.  *      DoubleX or his aliases                                                
  11.  *      None of the above applies to DoubleX or his aliases                  
  12.  *----------------------------------------------------------------------------
  13.  *    # Prerequisites                                                        
  14.  *      Abilities:                                                            
  15.  *      1. Little Javascript coding proficiency to fully utilize this plugin  
  16.  *----------------------------------------------------------------------------
  17.  *    # Links                                                                
  18.  *      This plugin:                                                          
  19.  *      1. http://pastebin.com/znV2ZQmi                                      
  20.  *      Video:                                                                
  21.  *      1. https://www.youtube.com/watch?v=zkrXZTQnjFc                        
  22.  *      Mentioned Patreon Supporters:
  23.  *      https://www.patreon.com/posts/71738797
  24.  *----------------------------------------------------------------------------
  25.  *    # Author                                                                
  26.  *      DoubleX                                                              
  27.  *----------------------------------------------------------------------------
  28.  *    # Changelog                                                            
  29.  *      v1.00a(GMT 1400 22-1-2015):                                          
  30.  *      1. 1st completed version of this plugin finished                      
  31.  *      v0.00a(GMT 1200 9-12-2015):                                          
  32.  *      1. 1st testing version of this plugin finished                        
  33.  *============================================================================*/
  34. /*:
  35.  * @plugindesc To be the easiest, smallest and simplest atb system plugin ever
  36.  * @author DoubleX
  37.  *
  38.  * @param maxTurnUnit
  39.  * @desc Sets the maximum battle turn clock unit as maxTurnUnit
  40.  *       maxTurnUnit must return a Number and should return a positive one
  41.  * @default 5
  42.  *
  43.  * @param actorNameW
  44.  * @desc Sets the maximum width allocated for actor name display on the status
  45.  *       window as actorNameW
  46.  *       actorNameW must return a positive Number
  47.  * @default 123
  48.  *
  49.  * @param actorIconOx
  50.  * @desc Sets the actor icon display area x offset relative to the actor name
  51.  *       display area on the status window as actorIconOx
  52.  *       actorIconOx must return a positive Number
  53.  * @default 6
  54.  *
  55.  * @param hpBarOx
  56.  * @desc Sets the actor hp bar display area x offset relative to the actor icon
  57.  *       display area on the status window as hpBarOx
  58.  *       hpBarOx must return a positive Number
  59.  * @default 6
  60.  *
  61.  * @param hpBarW
  62.  * @desc Sets the maximum width allocated for actor hp bar display on the status
  63.  *       window as hpBarW
  64.  *       hpBarW must return a positive Number
  65.  * @default 87
  66.  *
  67.  * @param mpBarOx
  68.  * @desc Sets the actor mp bar display area x offset relative to the actor hp
  69.  *       bar display area on the status window as mpBarOx
  70.  *       mpBarOx must return a positive Number
  71.  * @default 6
  72.  *
  73.  * @param mpBarW
  74.  * @desc Sets the maximum width allocated for actor mp bar display on the status
  75.  *       window as mpBarW
  76.  *       mpBarW must return a positive Number
  77.  * @default 87
  78.  *
  79.  * @param tpBarOx
  80.  * @desc Sets the actor tp bar display area x offset relative to the actor mp
  81.  *       bar display area on the status window as tpBarOx
  82.  *       tpBarOx must return a positive Number
  83.  * @default 6
  84.  *
  85.  * @param tpBarW
  86.  * @desc Sets the maximum width allocated for actor tp bar display on the status
  87.  *       window as tpBarW
  88.  *       tpBarW must return a positive Number
  89.  * @default 87
  90.  *
  91.  * @param atbBarOx
  92.  * @desc Sets the actor atb bar display area x offset relative to the actor
  93.  *       mp/tp bar display area on the status window as atbBarOx
  94.  *       atbBarOx must return a positive Number
  95.  * @default 6
  96.  *
  97.  * @param atbBarW
  98.  * @desc Sets the maximum width allocated for actor atb bar display on the
  99.  *       status window as atbBarW
  100.  *       atbBarW must return a positive Number
  101.  * @default 87
  102.  *
  103.  * @param atbC1
  104.  * @desc Sets the 1st atb bar color as text color atbC1
  105.  *       atbC1 must return a valid text color code
  106.  *       atbC1 should return the same value during the same battle to ensure
  107.  *       proper atb bar color displays
  108.  * @default 7
  109.  *
  110.  * @param atbC2
  111.  * @desc Sets the 2nd atb bar color as text color atbC2
  112.  *       atbC2 must return a valid text color code
  113.  *       atbC2 should return the same value during the same battle to ensure
  114.  *       proper atb bar color displays
  115.  * @default 8
  116.  *
  117.  * @help
  118.  * The plugin file name must be the same as DoubleX_RMMV.MATB_File, which must
  119.  * be edited by editing this plugin js file directly
  120.  * The default value of DoubleX_RMMV.MATB_File is
  121.  * DoubleX RMMV Minimalized ATB v100a
  122.  *============================================================================
  123.  *    ## Plugin Call Info                                                    
  124.  *----------------------------------------------------------------------------
  125.  *    # Configuration manipulations                                          
  126.  *      1. $gameSystem._matb.param                                            
  127.  *         - Returns the value of param listed in the plugin manager          
  128.  *      2. $gameSystem._matb.param = val                                      
  129.  *         - Sets the value of param listed in the plugin manager as val      
  130.  *         - All $gameSystem._matb.param changes will be saved                
  131.  *    # Battle manipulations                                                  
  132.  *      1. _matbTurnClock                                                    
  133.  *         Returns the number of frames the turn clock has run in a turn      
  134.  *      2. _matbTurnClock = frame                                            
  135.  *         Sets the number of frames the turn clock has run in a turn as frame
  136.  *    # Battler manipulations                                                
  137.  *      1. _matbVal                                                          
  138.  *         - Returns the battler's atb value                                  
  139.  *      2. _matbVal = val                                                    
  140.  *         - Sets the battler's atb value as val which ranges from 0 to 100  
  141.  *      3. _matbValChange                                                    
  142.  *         - Returns whether the battler's atb value has just changed        
  143.  *      4. _matbValChange = true                                              
  144.  *         - Marks that the battler's atb value has just changed              
  145.  *           It must be used when any configuration other than maxTurnUnit  
  146.  *           changes during battles                                          
  147.  *      4. resetMatb()                                                        
  148.  *         - Clears all battler's actions and resets the battler's atb value  
  149.  *============================================================================
  150.  */
  151.  
  152. 'use strict';
  153. var DoubleX_RMMV = DoubleX_RMMV || {};
  154. DoubleX_RMMV['MATB'] = 'v0.00a';
  155.  
  156. // The plugin file name must be the same as DoubleX_RMMV.MATB_File
  157. DoubleX_RMMV.MATB_File = 'DoubleX RMMV Minimalized ATB v100a';
  158.  
  159. /*============================================================================
  160.  *    ## Plugin Implementations                                              
  161.  *       You need not edit this part as it's about how this plugin works      
  162.  *----------------------------------------------------------------------------
  163.  *    # Plugin Support Info:                                                  
  164.  *      1. Prerequisites                                                      
  165.  *         - Basic knowledge of this plugin on the user level, the default    
  166.  *           battle system implementations and the atb system concepts        
  167.  *         - Some Javascript coding proficiency to fully comprehend this      
  168.  *           plugin                                                          
  169.  *      2. Function documentation                                            
  170.  *         - The 1st part describes why this function's rewritten/extended for
  171.  *           rewritten/extended functions or what the function does for new  
  172.  *           functions                                                        
  173.  *         - The 2nd part describes what the arguments of the function are    
  174.  *         - The 3rd part informs which version rewritten, extended or created
  175.  *           this function                                                    
  176.  *         - The 4th part informs whether the function's rewritten or new    
  177.  *         - The 5th part informs whether the function's a real or potential  
  178.  *           hotspot                                                          
  179.  *         - The 6th part describes how this function works for new functions
  180.  *           only, and describes the parts added, removed or rewritten for    
  181.  *           rewritten or extended functions only                            
  182.  *         Example:                                                          
  183.  * /*----------------------------------------------------------------------
  184.  *  *    Why rewrite/extended/What this function does                      
  185.  *  *----------------------------------------------------------------------*/
  186. /* // arguments: What these arguments are                                    
  187.  * functionName = function(arguments) { // Version X+; Rewrite/New; Hotspot  
  188.  *     // Added/Removed/Rewritten to do something/How this function works    
  189.  *     functionNameCode;                                                      
  190.  *     //                                                                    
  191.  * } // functionName                                                          
  192.  *----------------------------------------------------------------------------*/
  193.  
  194. /*----------------------------------------------------------------------------
  195.  *    # Edit class: BattleManager                                            
  196.  *      - Reimplements the the whole battle flow to run the atb system        
  197.  *----------------------------------------------------------------------------*/
  198.  
  199. /*----------------------------------------------------------------------------
  200.  *    New private instance variable                                          
  201.  *----------------------------------------------------------------------------*/
  202. // _matbTurnClock: The battle turn atb clock
  203.  
  204. /*----------------------------------------------------------------------------
  205.  *    Keeps the appropriate input window opened if there are inputable actors
  206.  *----------------------------------------------------------------------------*/
  207. BattleManager.isInputting = function() { // Rewrite; Hotspot
  208.     return $gameParty.canInput(); // Rewritten
  209. }; // BattleManager.isInputting
  210.  
  211. BattleManager.startTurn = function() {}; // Rewrite
  212.  
  213. BattleManager.initMembersMatb = BattleManager.initMembers;
  214. BattleManager.initMembers = function() {
  215.     this.initMembersMatb();
  216.     this._matbTurnClock = 0; // Added
  217. }; // BattleManager.initMembers
  218.  
  219. BattleManager.startBattleMatb = BattleManager.startBattle;
  220. BattleManager.startBattle = function() {
  221.     this.startBattleMatb();
  222.     this.startMatbBattle(); // Added
  223. }; // BattleManager.startBattle
  224.  
  225. BattleManager.selectNextCommandMatb = BattleManager.selectNextCommand;
  226. BattleManager.selectNextCommand = function() {
  227.     this.actor().confirmMatbAct(); // Added
  228.     this.selectNextCommandMatb();
  229. }; // BattleManager.selectNextCommand
  230.  
  231. BattleManager.startMatbBattle = function() { // New
  232.     this._phase = 'turn';
  233.     var s = this._preemptive ? 'preempt' : this._surprise ? 'surprise' : 'norm';
  234.     this.allBattleMembers().forEach(function(mem) { mem.setStartMatbVal(s); });
  235. }; // BattleManager.startMatbBattle
  236.  
  237. BattleManager.canUpdateMatb = function() { // New; Hotspot
  238.     return this._phase && this._phase !== 'init';
  239. }; // BattleManager.canUpdateMatb
  240.  
  241. BattleManager.updateMatb = function() { // New; Hotspot
  242.     $gameParty.movableMembers().forEach(function(mem) { mem.updateMatb(); });
  243.     $gameTroop.movableMembers().forEach(function(mem) { mem.updateMatb(); });
  244.     this.processMatbTurn();
  245.     this.updateMatbTurn();
  246. }; // BattleManager.updateMatb
  247.  
  248. BattleManager.processMatbTurn = function() { // New; Hotspot
  249.     this._subject = this._subject || this._actionBattlers[0];
  250.     if (this._subject) this.processTurn();
  251. }; // BattleManager.processMatbTurn
  252.  
  253. BattleManager.updateMatbTurn = function() { // New; Hotspot
  254.     // The fps is assumed to be always 60
  255.     if ((this._matbTurnClock += 1) < $gameSystem._matb.maxTurnUnit * 60) return;
  256.     this._matbTurnClock = 0;
  257.     this.endMatbTurn();
  258.     //
  259. }; // BattleManager.updateMatbTurn
  260.  
  261. BattleManager.endMatbTurn = function() { // New
  262.     this.allBattleMembers().forEach(function(mem) {
  263.         mem.onTurnEnd();
  264.         this.refreshStatus();
  265.         this._logWindow.displayAutoAffectedStatus(mem);
  266.         this._logWindow.displayRegeneration(mem);
  267.     }, this);
  268.     $gameTroop.increaseTurn();
  269. }; // BattleManager.endMatbTurn
  270.  
  271. // battler: The battler to become eligible to be the action execution subject
  272. BattleManager.addMatbActionBattler = function(battler) { // New
  273.     if (this._actionBattlers.indexOf(battler) >= 0) return;
  274.     this._actionBattlers.push(battler);
  275. }; // BattleManager.addMatbActionBattler
  276.  
  277. // battler: The battler to have its atb value reset
  278. BattleManager.resetMatb = function(battler) { // New
  279.     var index = this._actionBattlers.indexOf(battler);
  280.     if (index >= 0) this._actionBattlers.splice(index, 1);
  281.     if (this.actor() === battler) this.clearActor();
  282. }; // BattleManager.resetMatb
  283.  
  284. /*----------------------------------------------------------------------------
  285.  *    # Edit class: Game_System                                              
  286.  *----------------------------------------------------------------------------*/
  287.  
  288. /*----------------------------------------------------------------------------
  289.  *    New private instance variable                                          
  290.  *----------------------------------------------------------------------------*/
  291. // _matb: The container of all configuration values
  292.  
  293. Game_System.prototype.initializeMatb = Game_System.prototype.initialize;
  294. Game_System.prototype.initialize = function() {
  295.     this.initializeMatb();
  296.     this.initMatbParams(); // Added
  297. }; // Game_System.prototype.initialize
  298.  
  299. Game_System.prototype.initMatbParams = function() { // New
  300.     var val, params = PluginManager.parameters(DoubleX_RMMV.MATB_File);
  301.     this._matb = {};
  302.     Object.keys(params).forEach(function(param) {
  303.         val = +params[param];
  304.         this._matb[param] = isNaN(val) ? params[param] : val;
  305.     }, this);
  306. }; // Game_System.prototype.initMatbParams
  307.  
  308. /*----------------------------------------------------------------------------
  309.  *    # Edit class: Game_BattlerBase                                          
  310.  *----------------------------------------------------------------------------*/
  311.  
  312. /*----------------------------------------------------------------------------
  313.  *    Updates state turns with different removal timings at different timings
  314.  *----------------------------------------------------------------------------*/
  315. Game_BattlerBase.prototype.updateStateTurns = function() { // Rewrite
  316.     this.updateMatbStateTurns(2); // Rewritten
  317. }; // Game_BattlerBase.prototype.updateStateTurns
  318.  
  319. Game_BattlerBase.prototype.hideMatb = Game_BattlerBase.prototype.hide;
  320. Game_BattlerBase.prototype.hide = function() {
  321.     this.hideMatb();
  322.     this.resetMatb(); // Added
  323. }; // Game_BattlerBase.prototype.hide
  324.  
  325. // start: The battle start type
  326. Game_BattlerBase.prototype.setStartMatbVal = function(start) { // New
  327.     if (!this.canMove()) return this._matbVal = 0;
  328.     if (start === 'preempt' && this.isActor()) return this._matbVal = 100;
  329.     if (start === 'surprise' && this.isEnemy()) return this._matbVal = 100;
  330.     this._matbVal = 0;
  331. }; // Game_BattlerBase.prototype.setStartMatbVal
  332.  
  333. /*----------------------------------------------------------------------------
  334.  *    # Edit class: Game_Battler                                              
  335.  *      - Implements the battler's atb actions, clock, control flow and logics
  336.  *----------------------------------------------------------------------------*/
  337.  
  338. /*----------------------------------------------------------------------------
  339.  *    New private instance variables                                          
  340.  *----------------------------------------------------------------------------*/
  341. // _matbVal: The atb value
  342. // _matbValChange: The atb value change flag
  343.  
  344. Game_Battler.prototype.initMembersMatb = Game_Battler.prototype.initMembers;
  345. Game_Battler.prototype.initMembers = function() {
  346.     Game_Battler.prototype.initMembersMatb.call(this); // Prevents name clashes
  347.     this._matbVal = 0, this._matbValChange = true; // Added
  348. }; // Game_Battler.prototype.initMembers
  349.  
  350. Game_Battler.prototype.onRestrictMatb = Game_Battler.prototype.onRestrict;
  351. Game_Battler.prototype.onRestrict = function() {
  352.     this.onRestrictMatb();
  353.     // Added to fix nil action battlers bugs and edge cases as well
  354.     if (BattleManager._actionBattlers) this.resetMatb();
  355.     //
  356. }; // Game_Battler.prototype.onRestrict
  357.  
  358. Game_Battler.prototype.onAllActionsEndMatb =
  359. Game_Battler.prototype.onAllActionsEnd;
  360. Game_Battler.prototype.onAllActionsEnd = function() {
  361.     this.onAllActionsEndMatb();
  362.     // Added
  363.     this.updateMatbStateTurns(1);
  364.     this.resetMatb();
  365.     //
  366. }; // Game_Battler.prototype.onAllActionsEnd
  367.  
  368. Game_Battler.prototype.onTurnEndMatb = Game_Battler.prototype.onTurnEnd;
  369. Game_Battler.prototype.onTurnEnd = function() {
  370.     this.onTurnEndMatb();
  371.     this.removeBuffsAuto(); // Added
  372. }; // Game_Battler.prototype.onTurnEnd
  373.  
  374. /*----------------------------------------------------------------------------
  375.  *    Ensures battlers added after the battle starts won't carry statuses over
  376.  *----------------------------------------------------------------------------*/
  377. Game_Battler.prototype.onBattleEndMatb = Game_Battler.prototype.onBattleEnd;
  378. Game_Battler.prototype.onBattleEnd = function() {
  379.     this.onBattleEndMatb();
  380.     this.resetMatb(); // Added
  381. }; // Game_Battler.prototype.onBattleEnd
  382.  
  383. // start: The battle start type
  384. Game_Battler.prototype.setStartMatbVal = function(start) { // New
  385.     this._matbVal = 0, this._matbValChange = true;
  386.     Game_BattlerBase.prototype.setStartMatbVal.call(this, start);
  387.     if (this._matbVal >= 100) this.makeActions();
  388. }; // Game_Battler.prototype.setStartMatbVal
  389.  
  390. Game_Battler.prototype.updateMatb = function() { // New; Hotspot
  391.     if (this._matbVal >= 100) return;
  392.     this._matbValChange = this._matbVal !== (this._matbVal += this.agi / 100);
  393.     if (this._matbVal < 100) return;
  394.     this._matbVal = 100;
  395.     this.makeActions();
  396. }; // Game_Battler.prototype.updateMatb
  397.  
  398. Game_Battler.prototype.resetMatb = function() { // New
  399.     this._matbVal = 0, this._matbValChange = true;
  400.     this.clearActions();
  401.     BattleManager.resetMatb(this);
  402. }; // Game_Battler.prototype.resetMatb
  403.  
  404. // timing: The state auto removal timing
  405. Game_Battler.prototype.updateMatbStateTurns = function(timing) { // New
  406.     this.states().forEach(function(s) {
  407.         if (s.autoRemovalTiming === timing && this._stateTurns[s.id] > 0) {
  408.             this._stateTurns[s.id] -= 1;
  409.         }
  410.     }, this);
  411. }; // Game_Battler.prototype.updateMatbStateTurns
  412.  
  413. /*----------------------------------------------------------------------------
  414.  *    # Edit class: Game_Actor                                                
  415.  *----------------------------------------------------------------------------*/
  416.  
  417. /*----------------------------------------------------------------------------
  418.  *    New private instance variables                                          
  419.  *----------------------------------------------------------------------------*/
  420. // _matbReserve: The actor added during battles flag
  421.  
  422. /*----------------------------------------------------------------------------
  423.  *    Ensures actors added during battles are properly initialized as well    
  424.  *----------------------------------------------------------------------------*/
  425. Game_Actor.prototype.initMembersMatb = Game_Actor.prototype.initMembers;
  426. Game_Actor.prototype.initMembers = function() {
  427.     this.initMembersMatb();
  428.     this._matbReserve = true; // Added
  429. }; // Game_Actor.prototype.initMembers
  430.  
  431. Game_Actor.prototype.makeAutoBattleActionsMatb =
  432. Game_Actor.prototype.makeAutoBattleActions;
  433. Game_Actor.prototype.makeAutoBattleActions = function() {
  434.     this.makeAutoBattleActionsMatb();
  435.     BattleManager.addMatbActionBattler(this); // Added
  436. }; // Game_Actor.prototype.makeAutoBattleActions
  437.  
  438. Game_Actor.prototype.makeConfusionActionsMatb =
  439. Game_Actor.prototype.makeConfusionActions;
  440. Game_Actor.prototype.makeConfusionActions = function() {
  441.     this.makeConfusionActionsMatb();
  442.     BattleManager.addMatbActionBattler(this); // Added
  443. }; // Game_Actor.prototype.makeConfusionActions
  444.  
  445. Game_Actor.prototype.canInput = function() { // New; Hotspot
  446.     if (!Game_BattlerBase.prototype.canInput.call(this)) return false;
  447.     if (this.numActions() <= 0) return false;
  448.     if (this._actionInputIndex >= this.numActions() - 1) return false;
  449.     return BattleManager._actionBattlers.indexOf(this) < 0;
  450. }; // Game_Actor.prototype.canInput
  451.  
  452. /*----------------------------------------------------------------------------
  453.  *    Ensures actors added during battles are properly initialized as well    
  454.  *----------------------------------------------------------------------------*/
  455. Game_Actor.prototype.onBattleEnd = function() { // New
  456.     Game_Battler.prototype.onBattleEnd.call(this);
  457.     this._matbReserve = true; // Added
  458. }; // Game_Actor.prototype.onBattleEnd
  459.  
  460. /*----------------------------------------------------------------------------
  461.  *    Ensures actors added during battles are properly initialized as well    
  462.  *----------------------------------------------------------------------------*/
  463. // start: The battle start type
  464. Game_Actor.prototype.setStartMatbVal = function(start) { // New
  465.     Game_Battler.prototype.setStartMatbVal.call(this, start);
  466.     this._matbReserve = false; // Added
  467. }; // Game_Actor.prototype.setStartMatbVal
  468.  
  469. /*----------------------------------------------------------------------------
  470.  *    Ensures actors added during battles are properly initialized as well    
  471.  *----------------------------------------------------------------------------*/
  472. Game_Actor.prototype.updateMatb = function() { // New; Hotspot
  473.     // Added
  474.     if (this._matbReserve) {
  475.         this._matbVal = 0, this._matbValChange = true;
  476.         this._matbReserve = false;
  477.     }
  478.     //
  479.     Game_Battler.prototype.updateMatb.call(this);
  480. }; // Game_Actor.prototype.updateMatb
  481.  
  482. Game_Actor.prototype.confirmMatbAct = function() { // New
  483.     if (this._actionInputIndex < this.numActions() - 1) return;
  484.     BattleManager.addMatbActionBattler(this); // Added
  485. }; // Game_Actor.prototype.confirmMatbAct
  486.  
  487. /*----------------------------------------------------------------------------
  488.  *    # Edit class: Game_Enemy                                                
  489.  *----------------------------------------------------------------------------*/
  490.  
  491. Game_Enemy.prototype.makeActionsMatb = Game_Enemy.prototype.makeActions;
  492. Game_Enemy.prototype.makeActions = function() {
  493.     this.makeActionsMatb();
  494.     BattleManager.addMatbActionBattler(this); // Added
  495. }; // Game_Enemy.prototype.makeActions
  496.  
  497. /*----------------------------------------------------------------------------
  498.  *    # Edit class: Game_Party                                                
  499.  *----------------------------------------------------------------------------*/
  500.  
  501. Game_Party.prototype.clearActions = function() { // New
  502.     Game_Unit.prototype.clearActions.call(this);
  503.     // Added to reset all party members' atb values upon failed party escapes
  504.     this.aliveMembers().forEach(function(mem) { mem.resetMatb(); });
  505.     //
  506. }; // Game_Party.prototype.clearActions
  507.  
  508. Game_Party.prototype.matbInputableMemIndices = function() {
  509.     return this.members().filter(function(mem) {
  510.         return mem.canInput();
  511.     }).map(function(mem) { return mem.index(); });
  512. }; // Game_Party.prototype.matbInputableMemIndices
  513.  
  514. /*----------------------------------------------------------------------------
  515.  *    # Edit class: Window_BattleStatus                                      
  516.  *----------------------------------------------------------------------------*/
  517.  
  518. Window_BattleStatus.prototype.basicAreaRect = function(index) { // Rewrite
  519.     // Rewritten to reallocate spaces to draw the atb bars
  520.     var rect = this.itemRectForText(index);
  521.     rect.width -= this.gaugeAreaWidth() + $gameSystem._matb.hpBarOx;
  522.     return rect;
  523.     //
  524. }; // Window_BattleStatus.prototype.basicAreaRect
  525.  
  526. Window_BattleStatus.prototype.gaugeAreaWidth = function() { // Rewrite; Hotspot
  527.     // Rewritten to reallocate spaces to draw the atb bars
  528.     var m = $gameSystem._matb, w = m.hpBarW + m.mpBarOx + m.mpBarW;
  529.     if ($dataSystem.optDisplayTp) w += m.tpBarOx + m.tpBarW;
  530.     return w + m.atbBarOx + m.atbBarW;
  531.     //
  532. }; // Window_BattleStatus.prototype.gaugeAreaWidth
  533.  
  534. Window_BattleStatus.prototype.drawBasicArea = function(rect, actor) { // Rewrite
  535.     // Rewritten to reallocate spaces to draw the atb bars
  536.     var w = $gameSystem._matb.actorNameW;
  537.     this.drawActorName(actor, rect.x, rect.y, w);
  538.     var ox = w + $gameSystem._matb.actorIconOx;
  539.     this.drawActorIcons(actor, rect.x + ox, rect.y, rect.width - w);
  540.     //
  541. }; // Window_BattleStatus.prototype.drawBasicArea
  542.  
  543. Window_BattleStatus.prototype.drawGaugeAreaWithTp = function(rect, actor) {
  544. // Rewrite
  545.     // Rewritten to reallocate spaces to draw the atb bars
  546.     var matb = $gameSystem._matb;
  547.     this.drawActorHp(actor, rect.x, rect.y, matb.hpBarW);
  548.     var ox = matb.hpBarW + matb.mpBarOx;
  549.     this.drawActorMp(actor, rect.x + ox, rect.y, matb.mpBarW);
  550.     ox += matb.mpBarW + matb.tpBarOx;
  551.     this.drawActorTp(actor, rect.x + ox, rect.y, matb.tpBarW);
  552.     ox += matb.tpBarW + matb.atbBarOx;
  553.     this.drawActorMatb(actor._matbVal / 100, rect.x + ox, rect.y);
  554.     //
  555. }; // Window_BattleStatus.prototype.drawGaugeAreaWithTp
  556.  
  557. Window_BattleStatus.prototype.drawGaugeAreaWithoutTp = function(rect, actor) {
  558. // Rewrite
  559.     // Rewritten to reallocate spaces to draw the atb bars
  560.     var matb = $gameSystem._matb;
  561.     this.drawActorHp(actor, rect.x, rect.y, matb.hpBarW);
  562.     var ox = matb.hpBarW + matb.mpBarOx;
  563.     this.drawActorMp(actor, rect.x + ox, rect.y, matb.mpBarW);
  564.     ox += matb.mpBarW + matb.atbBarOx;
  565.     this.drawActorMatb(actor._matbVal / 100, rect.x + ox, rect.y);
  566.     //
  567. }; // Window_BattleStatus.prototype.drawGaugeAreaWithoutTp
  568.  
  569. Window_BattleStatus.prototype.refreshMatbBars = function() { // New; Hotspot
  570.     var matb = $gameSystem._matb, actor, rect;
  571.     var ox = matb.hpBarW + matb.mpBarOx + matb.mpBarW + matb.atbBarOx;
  572.     if ($dataSystem.optDisplayTp) ox += matb.tpBarOx + matb.tpBarW;
  573.     for (var index = 0, max = this.maxItems(); index < max; index++) {
  574.         actor = $gameParty.battleMembers()[index];
  575.         if (!actor || !actor._matbValChange) continue;
  576.         rect = this.gaugeAreaRect(index);
  577.         this.drawActorMatb(actor._matbVal / 100, rect.x + ox, rect.y);
  578.         actor._matbValChange = false;
  579.     }
  580. }; // Window_BattleStatus.prototype.refreshMatbBars
  581.  
  582. /* actor: The actor using the atb bar
  583.  * x: The atb bar x position
  584.  * y: The atb bar y position
  585.  */
  586. Window_BattleStatus.prototype.drawActorMatb = function(matbRate, x, y) {
  587. // New; Hotspot
  588.     var matb = $gameSystem._matb, w = matb.atbBarW;
  589.     var c0 = this.textColor(matb.atbC1), c1 = this.textColor(matb.atbC2);
  590.     this.drawGauge(x, y, w, matbRate, c0, c1);
  591.     this.changeTextColor(this.systemColor());
  592.     this.drawText('AP', x, y, this.textWidth('AP'));
  593. }; // Window_BattleStatus.prototype.drawActorMatb
  594.  
  595. /*----------------------------------------------------------------------------
  596.  *    # Edit class: Scene_Battle                                              
  597.  *----------------------------------------------------------------------------*/
  598.  
  599. Scene_Battle.prototype.updateBattleProcess = function() { // Rewrite; Hotspot
  600.     // Rewritten to reconstruct the action input and execution flows for atb
  601.     if (BattleManager.isAborting() || BattleManager.isBattleEnd()) {
  602.         return BattleManager.update();
  603.     }
  604.     if (BattleManager.isBusy() || BattleManager.updateEvent()) return;
  605.     if (BattleManager._phase === 'action') return BattleManager.updateAction();
  606.     if (BattleManager.canUpdateMatb() && !this.isAnyInputWindowActive()) {
  607.         this.updateMatb();
  608.     }
  609.     //
  610. }; // Scene_Battle.prototype.updateBattleProcess
  611.  
  612. Scene_Battle.prototype.updateWindowPositionsMatb =
  613. Scene_Battle.prototype.updateWindowPositions;
  614. Scene_Battle.prototype.updateWindowPositions = function() { // Hotspot
  615.     this.updateWindowPositionsMatb();
  616.     // Added to ensure the actor window will complete cover the status window
  617.     if (this._actorWindow.active) this._actorWindow.x = this._statusWindow.x;
  618.     //
  619. }; // Scene_Battle.prototype.updateWindowPositions
  620.  
  621. Scene_Battle.prototype.commandEscapeMatb = Scene_Battle.prototype.commandEscape;
  622. Scene_Battle.prototype.commandEscape = function() { // v1.00a+
  623.     // Rewritten to ensure party escape attempt won't trigger when battle's busy
  624.     if (BattleManager._phase !== 'action') return this.commandEscapeMatb();
  625.     this.startPartyCommandSelection();
  626.     //
  627. }; // Scene_Battle.prototype.commandEscape
  628.  
  629. Scene_Battle.prototype.updateMatb = function() { // New; Hotspot
  630.     BattleManager.updateMatb();
  631.     this.updateMatbActorSelection();
  632.     this._statusWindow.refreshMatbBars();
  633. }; // Scene_Battle.prototype.updateMatb
  634.  
  635. Scene_Battle.prototype.updateMatbActorSelection = function() {
  636. // New; Hotspot
  637.     var actor_indices = $gameParty.matbInputableMemIndices();
  638.     if (actor_indices.indexOf(this._statusWindow.index()) >= 0) return;
  639.     if (this._statusWindow.index() > 0) this._statusWindow.deselect();
  640.     if (actor_indices.length <= 0) return;
  641.     BattleManager._actorIndex = actor_indices[0];
  642.     this.startActorCommandSelection();
  643. }; // Scene_Battle.prototype.updateMatbActorSelection
  644.  
  645. /*============================================================================*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement