Advertisement
WCouillard

Coolie_BattleTurnCount

Sep 16th, 2021 (edited)
747
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var Imported = Imported || {};
  2. Imported.Coolie_BattleTurnCount = true;
  3.  
  4. var Coolie = Coolie || {};
  5. Coolie.BTW = Coolie.BTW || {};
  6. Coolie.BTW.version = 1.00;
  7.  
  8. /*:
  9.  * @plugindesc v1.0 Displays a turn count window in battle
  10.  * @author William Couillard
  11.  *
  12.  * @help
  13.  * About This Plugin
  14.  * -----------------------------------------------------------------------------
  15.  * Adds a window to Scene_Battle that shows the turn count.
  16.  * Compatibility should be very high.
  17.  *
  18.  * Terms and Conditions
  19.  * -----------------------------------------------------------------------------
  20.  * It is OK to use this plugin in both non-commercial and commercial projects,
  21.  * as long as proper credit is given to William Couillard in your game.
  22.  *
  23.  * Helpful Tips
  24.  * -----------------------------------------------------------------------------
  25.  * - With the use of Yanfly's YEP_MessageCore and biud436's RS_MessageAlign
  26.  *   plugins, it becomes possible to use escape codes with the text in this
  27.  *   plugin, like so:
  28.  *
  29.  *   \\c[2]Turn\\c[0]
  30.  *
  31.  *   If you are using those two plugins, place this plugin BELOW them.
  32.  *
  33.  * - With escape codes enabled, you could even set the Window Text to something
  34.  *   else in-game using a variable, and changing the Window Text setting in the
  35.  *   plugin to call that variable, like so: \\v[x] where X is the variable ID.
  36.  *
  37.  *   Using a variable in the escape code will allow you to change the text
  38.  *   displayed in battle on the fly. You can also use other codes like \\i[x] to
  39.  *   display an icon before the text.
  40.  *
  41.  * - If you are using AB_EnemyBook plugin, place this plugin ABOVE it to avoid
  42.  *   a visual bug.
  43.  *
  44.  * - If you are using "Nasty Replace Window With Picture" plugin, the name of the
  45.  *   window to use is Window_TurnCount.
  46.  *
  47.  * Version & Update History
  48.  * -----------------------------------------------------------------------------
  49.  * - v1.0 : Initial Release
  50.  *          Sept. 16th, 2021
  51.  *
  52.  * @param Window Settings
  53.  *
  54.  * @param Window Width
  55.  * @parent Window Settings
  56.  * @type number
  57.  * @min 0
  58.  * @desc The width, in pixels, of the Turn Count Window
  59.  * Default: 160
  60.  * @default 160
  61.  
  62.  * @param Window X Position
  63.  * @parent Window Settings
  64.  * @type number
  65.  * @min 0
  66.  * @desc The X position, in pixels, of the Turn Count Window
  67.  * Default: 0
  68.  * @default 0
  69.  
  70.  * @param Window Y Position
  71.  * @parent Window Settings
  72.  * @type number
  73.  * @min 0
  74.  * @desc The Y position, in pixels, of the Turn Count Window
  75.  * Default: 372
  76.  * @default 372
  77.  
  78.  * @param Window Text
  79.  * @parent Window Settings
  80.  * @type text
  81.  * @desc The width, in pixels, of the Turn Count Window
  82.  * Default: Turn
  83.  * @default Turn
  84.  */
  85.  
  86. Coolie.Parameters = PluginManager.parameters('Coolie_BattleTurnCount');
  87. Coolie.Param = Coolie.Param || {};
  88.  
  89. Coolie.Param.BTWWindowWidth = Number(Coolie.Parameters['Window Width']);
  90. Coolie.Param.BTWWindowX = Number(Coolie.Parameters['Window X Position']);
  91. Coolie.Param.BTWWindowY = Number(Coolie.Parameters['Window Y Position']);
  92. Coolie.Param.BTWWindowText = String(Coolie.Parameters['Window Text']);
  93.  
  94. //-----------------------------------------------------------------------------
  95. // Window_TurnCount
  96. //
  97. // The window for displaying the battle's turn count
  98.  
  99. function Window_TurnCount() {
  100.     this.initialize.apply(this, arguments);
  101. }
  102.  
  103. Window_TurnCount.prototype = Object.create(Window_Selectable.prototype);
  104. Window_TurnCount.prototype.constructor = Window_TurnCount;
  105.  
  106. Window_TurnCount.prototype.initialize = function() {
  107.     var width = Coolie.Param.BTWWindowWidth;
  108.     var height = this.fittingHeight(1);
  109.     var x = Coolie.Param.BTWWindowX;
  110.     var y = Coolie.Param.BTWWindowY;
  111.     Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  112.     this.refresh();
  113.     this.openness = 0;
  114. };
  115.  
  116. Window_TurnCount.prototype.refresh = function() {
  117.     var x = 0;
  118.     var y = 0;
  119.     text = Coolie.Param.BTWWindowText;
  120.     text2 = Math.floor($gameTroop.turnCount() + 1).toString();
  121.     this.contents.clear();
  122.     if (Imported.RS_MessageAlign) {
  123.         this.drawTextEx(text + '\\i[0]' + text2, x, y)
  124.     } else {
  125.         this.drawTextEx(text + ' ' + text2, x, y)
  126.     }
  127. };
  128.  
  129. Window_TurnCount.prototype.open = function() {
  130.     this.refresh();
  131.     Window_Selectable.prototype.open.call(this);
  132. };
  133.  
  134. //-----------------------------------------------------------------------------
  135. // Scene_Battle
  136. //
  137. // The scene class of the battle screen.
  138.  
  139. var alias_Coolie_BattleTurnCount_createAllWindows = Scene_Battle.prototype.createAllWindows;
  140. Scene_Battle.prototype.createAllWindows = function() {
  141.     alias_Coolie_BattleTurnCount_createAllWindows.call(this);
  142.     this.createTurnsWindow();
  143. };
  144.  
  145. Scene_Battle.prototype.createTurnsWindow = function() {
  146.     this._turnsWindow = new Window_TurnCount();
  147.     this.addWindow(this._turnsWindow);
  148.     this._turnsWindow.open();
  149. };
  150.  
  151. Scene_Battle.prototype.refreshTurnCount = function() {
  152.     this._turnsWindow.refresh();
  153. };
  154.  
  155. var alias_Coolie_BattleTurnCount_startPartyCommandSelection = Scene_Battle.prototype.startPartyCommandSelection;
  156. Scene_Battle.prototype.startPartyCommandSelection = function() {
  157.     alias_Coolie_BattleTurnCount_startPartyCommandSelection.call(this);
  158.     this.refreshTurnCount();
  159. };
  160.  
  161. //-----------------------------------------------------------------------------
Tags: Plugin RMMV
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement