查看: 2000|回复: 0

[已经过期] 关于Yanfly Engine Plugins 的 Party System帮助栏问题

[复制链接]
梦石
0
星屑
69
在线时间
227 小时
注册时间
2010-8-10
回帖
50
发表于 2016-3-14 10:22:16 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 余烬之中 于 2016-8-3 10:05 编辑

在系统上已经设置了显示帮助栏,进入游戏帮助栏也确实显示了,但是里面是空的,难道还需要再设置帮助内容吗》?如何操作


  1. //=============================================================================
  2. // Yanfly Engine Plugins - Party System
  3. // YEP_PartySystem.js
  4. //=============================================================================

  5. var Imported = Imported || {};
  6. Imported.YEP_PartySystem = true;

  7. var Yanfly = Yanfly || {};
  8. Yanfly.Party = Yanfly.Party || {};

  9. //=============================================================================
  10. /*:
  11. * @plugindesc v1.07 Replaces the default 'Formation' command with a new
  12. * menu for players to easily change party formations.
  13. * @author Yanfly Engine Plugins
  14. *
  15. * @param ---General---
  16. * @default
  17. *
  18. * @param Max Battle Members
  19. * @desc Maximum amount of actors that can participate in battle.
  20. * Default: 4
  21. * @default 4
  22. *
  23. * @param Show Battle Command
  24. * @desc Show the 'Formation' command in the Party Command Window?
  25. * NO - false     YES - true
  26. * @default true
  27. *
  28. * @param Enable Battle Command
  29. * @desc Enable the 'Formation' command in the Party Command Window?
  30. * NO - false     YES - true
  31. * @default true
  32. *
  33. * @param Battle Cooldown
  34. * @desc How many turns must the player wait after changing party?
  35. * @default 1
  36. *
  37. * @param Maximum Followers
  38. * @desc Maximum number of followers on the map.
  39. * Default: 4
  40. * @default 4
  41. *
  42. * @param ---Menu---
  43. * @default
  44. *
  45. * @param Help Window
  46. * @desc Show the Help Window in the party menu?
  47. * NO - false     YES - true
  48. * @default true
  49. *
  50. * @param Text Alignment
  51. * @desc The text alignment for the command window.
  52. * left     center     right
  53. * @default center
  54. *
  55. * @param Change Command
  56. * @desc How the 'Change' command appears in the command menu.
  57. * Leave this blank to remove it.
  58. * @default Change
  59. *
  60. * @param Remove Command
  61. * @desc How the 'Remove' command appears in the command menu.
  62. * Leave this blank to remove it.
  63. * @default Remove
  64. *
  65. * @param Revert Command
  66. * @desc How the 'Revert' command appears in the command menu.
  67. * Leave this blank to remove it.
  68. * @default Revert
  69. *
  70. * @param Finish Command
  71. * @desc How the 'Finish' command appears in the command menu.
  72. * Leave this blank to remove it.
  73. * @default Finish
  74. *
  75. * @param ---Selection---
  76. * @default
  77. *
  78. * @param Empty Text
  79. * @desc What text to display in an empty party slot.
  80. * @default - Empty -
  81. *
  82. * @param Actor Face
  83. * @desc Show the actor's face?
  84. * NO - false     YES - true
  85. * @default true
  86. *
  87. * @param Actor Sprite
  88. * @desc Show the actor's sprite?
  89. * NO - false     YES - true
  90. * @default true
  91. *
  92. * @param ---List---
  93. * @default
  94. *
  95. * @param Remove Text
  96. * @desc The text used to display the "Remove" command in the party
  97. * member list.
  98. * @default Remove
  99. *
  100. * @param Remove Icon
  101. * @desc The icon used to display next to the "Remove" command in the
  102. * party member list.
  103. * @default 16
  104. *
  105. * @param Sprite Y Buffer
  106. * @desc This is the amount to adjust the actor graphic by.
  107. * @default 16
  108. *
  109. * @param In Party Text Color
  110. * @desc This is the text color to be used if the actor is currently
  111. * in the party.
  112. * @default 6
  113. *
  114. * @param ---Locking---
  115. * @default
  116. *
  117. * @param Lock First Actor
  118. * @desc Allows you to lock the first actor in the game by default.
  119. * OFF - false     ON - true
  120. * @default false
  121. *
  122. * @param Locked Icon
  123. * @desc This sets what icon to be used when an actor is locked.
  124. * @default 195
  125. *
  126. * @param Required Icon
  127. * @desc This sets what icon to be used when an actor is required.
  128. * @default 205
  129. *
  130. * @param ---Detail Window---
  131. * @default
  132. *
  133. * @param Enable Detail Window
  134. * @desc Make use of the detailed party window next to the list.
  135. * NO - false     YES - true
  136. * @default true
  137. *
  138. * @param List Width
  139. * @desc If detail window is enabled, what is the width of the
  140. * party list window?
  141. * @default 300
  142. *
  143. * @param Actor Parameters
  144. * @desc If there is enough room, this is the text shown to list
  145. * the actor's parameters.
  146. * @default Parameters
  147. *
  148. * @param Actor Equipment
  149. * @desc If there is enough room, this is the text shown to list
  150. * the actor's equipment.
  151. * @default Equipment
  152. *
  153. * @help
  154. * ============================================================================
  155. * Introduction
  156. * ============================================================================
  157. *
  158. * This plugin replaces the "Formation" command found in the in-game menu with
  159. * a new scene where the player can adjust the party he or she wants in a more
  160. * comfortable way.
  161. *
  162. * If you are using YEP_BattleEngineCore.js and would like to enable party
  163. * switching mid-battle, place this plugin under YEP_BattleEngineCore.js in
  164. * the plugin's list.
  165. *
  166. * This plugin is plug and play. All you have to do is just turn it on and
  167. * change the parameters to your liking.
  168. *
  169. * ============================================================================
  170. * Plugin Commands
  171. * ============================================================================
  172. *
  173. * Here are some plugin commands you can use!
  174. *
  175. * Plugin Command:
  176. *   OpenPartyMenu     Opens up the Party Menu from the field.
  177. *
  178. * Actors can also be required, meaning the player must have that actor(s) in
  179. * the party before the player is able to leave the party menu. Required actors
  180. * can be moved around, unlike locked actors. Keep in mind if you do make some
  181. * actors required, do not make the game require more actors than the possible
  182. * maximum battle members or else the player will be stuck in the party menu.
  183. *
  184. * Plugin Command:
  185. *   ShowBattleFormation    - Shows 'Formation' command in battle.
  186. *   HideBattleFormation    - Hides 'Formation' command in battle.
  187. *   EnableBattleFormation  - Enables 'Formation' command in battle.
  188. *   DisableBattleFormation - Disables 'Formation' command in battle.
  189. *
  190. *   LockActor 3          - Locks actor 3.
  191. *   LockActor 4 5 6      - Locks actors 4, 5, and 6.
  192. *   UnlockActor 3        - Unlocks actor 3.
  193. *   UnlockActor 4 5 6    - Unlocks actors 4, 5, and 6.
  194. *                        * Locked Actors cannot be moved out of their current
  195. *                          position and must be in the party.
  196. *
  197. *   RequireActor 3       - Player must have actor 3 in party.
  198. *   RequireActor 4 5 6   - Player must have actors 4, 5, and 6 in party.
  199. *   UnrequireActor 3     - Player no longer needs actor 3 in party.
  200. *   UnrequireActor 4 5 6 - Player no longer needs actors 4, 5, and 6 in party.
  201. *                        * Required Actors must be in the party in order for
  202. *                          the player to be able to exit the party menu.
  203. *
  204. *   ChangePartyMax 5     - Changes max party size to 5.
  205. *
  206. * ============================================================================
  207. * Changelog
  208. * ============================================================================
  209. *
  210. * Version 1.07:
  211. * - Fixed a bug that caused music to not replay properly when accessing the
  212. * Party change menu from battle.
  213. *
  214. * Version 1.06:
  215. * - Fixed a bug with certain actors not drawing properly.
  216. *
  217. * Version 1.05:
  218. * - Added 'Maximum Followers' parameter. This number should be the maximum
  219. * number you have in your game if you ever increase the maximum party size
  220. * midway through your game.
  221. *
  222. * Version 1.04:
  223. * - Fixed a visual bug with mid-battle formation changing against backgrounds
  224. * without battlebacks.
  225. * - Formation changes during mid-battle will resume bgm/bgs currently played.
  226. *
  227. * Version 1.03:
  228. * - Fixed a bug that would cause AutoBattlers to stall if they got added into
  229. * the party mid-battle.
  230. *
  231. * Version 1.02:
  232. * - Made a change so that the number of followers updates properly when you
  233. * increase the maximum number of battle members.
  234. *
  235. * Version 1.01:
  236. * - Added 'Battle Cooldown' plugin parameter.
  237. * - Added 'ChangePartyMax x' plugin command.
  238. * - Added feature where if you leave the class comand name empty, it will
  239. * remove the command.
  240. *
  241. * Version 1.00:
  242. * - Finished Plugin!
  243. */
  244. //=============================================================================

  245. //=============================================================================
  246. // Parameter Variables
  247. //=============================================================================

  248. Yanfly.Parameters = PluginManager.parameters('YEP_PartySystem');
  249. Yanfly.Param = Yanfly.Param || {};
  250. Yanfly.Icon = Yanfly.Icon || {};

  251. Yanfly.Param.MaxBattleMembers = Number(Yanfly.Parameters['Max Battle Members']);
  252. Yanfly.Param.PartyShowBattle = String(Yanfly.Parameters['Show Battle Command']);
  253. Yanfly.Param.PartyEnBattle = String(Yanfly.Parameters['Enable Battle Command']);
  254. Yanfly.Param.PartyCooldown = Number(Yanfly.Parameters['Battle Cooldown']);
  255. Yanfly.Param.PartyMaxFollower = Number(Yanfly.Parameters['Maximum Followers']);
  256. Yanfly.Param.PartyHelpWindow = String(Yanfly.Parameters['Help Window']);
  257. Yanfly.Param.PartyLockFirst = String(Yanfly.Parameters['Lock First Actor']);
  258. Yanfly.Param.PartyTextAlign = String(Yanfly.Parameters['Text Alignment']);
  259. Yanfly.Param.PartyCommand1 = String(Yanfly.Parameters['Change Command']);
  260. Yanfly.Param.PartyCommand2 = String(Yanfly.Parameters['Remove Command']);
  261. Yanfly.Param.PartyCommand3 = String(Yanfly.Parameters['Revert Command']);
  262. Yanfly.Param.PartyCommand4 = String(Yanfly.Parameters['Finish Command']);
  263. Yanfly.Param.PartyEmptyText = String(Yanfly.Parameters['Empty Text']);
  264. Yanfly.Param.PartyShowFace = String(Yanfly.Parameters['Actor Face']);
  265. Yanfly.Param.PartyShowCharacter = String(Yanfly.Parameters['Actor Sprite']);
  266. Yanfly.Icon.PartyLocked = Number(Yanfly.Parameters['Locked Icon']);
  267. Yanfly.Icon.PartyRequired = Number(Yanfly.Parameters['Required Icon']);
  268. Yanfly.Icon.PartyRemove = Number(Yanfly.Parameters['Remove Icon']);
  269. Yanfly.Param.PartySpriteBufferY = Number(Yanfly.Parameters['Sprite Y Buffer']);
  270. Yanfly.Param.ColorInParty = Number(Yanfly.Parameters['In Party Text Color']);
  271. Yanfly.Param.PartyDetailWin = String(Yanfly.Parameters['Enable Detail Window']);
  272. Yanfly.Param.PartyListWidth = Number(Yanfly.Parameters['List Width']);
  273. Yanfly.Param.PartyDetailParam = String(Yanfly.Parameters['Actor Parameters']);
  274. Yanfly.Param.PartyDetailEquip = String(Yanfly.Parameters['Actor Equipment']);

  275. //=============================================================================
  276. // Game_System
  277. //=============================================================================

  278. Yanfly.Party.Game_System_initialize = Game_System.prototype.initialize;
  279. Game_System.prototype.initialize = function() {
  280.     Yanfly.Party.Game_System_initialize.call(this);
  281.     this.initPartySettings();
  282. };

  283. Game_System.prototype.initPartySettings = function() {
  284.     this._showBattleFormation = eval(Yanfly.Param.PartyShowBattle);
  285.     this._battleFormationEnabled = eval(Yanfly.Param.PartyEnBattle);
  286. };

  287. Game_System.prototype.isShowBattleFormation = function() {
  288.     if (this._showBattleFormation === undefined) this.initPartySettings();
  289.     return this._showBattleFormation;
  290. };

  291. Game_System.prototype.setShowBattleFormation = function(value) {
  292.     if (this._showBattleFormation === undefined) this.initPartySettings();
  293.     this._showBattleFormation = value;
  294. };

  295. Game_System.prototype.isBattleFormationEnabled = function() {
  296.     if (this._battleFormationEnabled === undefined) this.initPartySettings();
  297.     if (this._battleFormationCooldown === undefined) {
  298.       this.resetBattleFormationCooldown();
  299.     }
  300.     if (this._battleFormationCooldown > 0) return false;
  301.     return this._battleFormationEnabled;
  302. };

  303. Game_System.prototype.setBattleFormationEnabled = function(value) {
  304.     if (this._battleFormationEnabled === undefined) this.initPartySettings();
  305.     this._battleFormationEnabled = value;
  306. };

  307. Game_System.prototype.resetBattleFormationCooldown = function() {
  308.     this._battleFormationCooldown = 0;
  309. };

  310. Game_System.prototype.updateBattleFormationCooldown = function() {
  311.     if (this._battleFormationCooldown === undefined) {
  312.       this.resetBattleFormationCooldown();
  313.     }
  314.     this._battleFormationCooldown--;
  315. };

  316. Game_System.prototype.setBattleFormationCooldown = function() {
  317.     this._battleFormationCooldown = Yanfly.Param.PartyCooldown;
  318. };

  319. //=============================================================================
  320. // Game_Actor
  321. //=============================================================================

  322. Yanfly.Party.Game_Actor_setup = Game_Actor.prototype.setup;
  323. Game_Actor.prototype.setup = function(actorId) {
  324.     Yanfly.Party.Game_Actor_setup.call(this, actorId);
  325.     this.initLocked();
  326. };

  327. Game_Actor.prototype.initLocked = function() {
  328.     this._locked = false;
  329.     this._required = false;
  330. };

  331. Yanfly.Party.Game_Actor_isFormationChangeOk =
  332.     Game_Actor.prototype.isFormationChangeOk;
  333. Game_Actor.prototype.isFormationChangeOk = function() {
  334.     if (this._locked) return false;
  335.     return Yanfly.Party.Game_Actor_isFormationChangeOk.call(this);
  336. };

  337. //=============================================================================
  338. // Game_Party
  339. //=============================================================================

  340. Yanfly.Party.Game_Party_initialize = Game_Party.prototype.initialize;
  341. Game_Party.prototype.initialize = function() {
  342.     Yanfly.Party.Game_Party_initialize.call(this);
  343.     this.initBattleMaxSize();
  344.     this.initializeBattleMembers();
  345. };

  346. Game_Party.prototype.initBattleMaxSize = function() {
  347.     this._BattleMaxSize = Yanfly.Param.MaxBattleMembers;
  348.     this.initializeBattleMembers();
  349. };

  350. Game_Party.prototype.changeBattleMax = function(value) {
  351.     this._BattleMaxSize = value;
  352.     this.initializeBattleMembers();
  353. };

  354. Game_Party.prototype.loadActorImages = function() {
  355.     for (var i = 0; i < this.members().length; ++i) {
  356.       var actor = this.members()[i];
  357.       if (!actor) continue;
  358.       ImageManager.loadFace(actor.faceName());
  359.       ImageManager.loadCharacter(actor.characterName());
  360.     }
  361. };

  362. Game_Party.prototype.battleMembers = function() {
  363.     if (this.toInitializeBattleMembers()) this.initializeBattleMembers();
  364.     var battleParty = [];
  365.     for (var i = 0; i < this._battleMembers.length; ++i) {
  366.       var actorId = this._battleMembers[i];
  367.       if (battleParty.length > this.maxBattleMembers()) break;
  368.       if (actorId === null) continue;
  369.       if (!$gameActors.actor(actorId)) continue;
  370.       if (!$gameActors.actor(actorId).isAppeared()) continue;
  371.       battleParty.push($gameActors.actor(actorId));
  372.     }
  373.     return battleParty;
  374. };

  375. Game_Party.prototype.maxBattleMembers = function() {
  376.     if (this._BattleMaxSize === undefined) this.initBattleMaxSize();
  377.     return Math.max(this._BattleMaxSize, 1);
  378. };

  379. Yanfly.Party.Game_Party_setupStartingMembers =
  380.     Game_Party.prototype.setupStartingMembers;
  381. Game_Party.prototype.setupStartingMembers = function() {
  382.     Yanfly.Party.Game_Party_setupStartingMembers.call(this);
  383.     this.initializeBattleMembers();
  384.     if (eval(Yanfly.Param.PartyLockFirst)) this.lockActor(this._actors[0]);
  385. };

  386. Game_Party.prototype.toInitializeBattleMembers = function() {
  387.     if (this._battleMembers === null) return true;
  388.     if (!this._battleMembers) this.initializeBattleMembers();
  389.     return (this._battleMembers.length !== this.maxBattleMembers());
  390. };

  391. Yanfly.Party.Game_Party_setupBattleTestMembers =
  392.     Game_Party.prototype.setupBattleTestMembers;
  393. Game_Party.prototype.setupBattleTestMembers = function() {
  394.     Yanfly.Party.Game_Party_setupBattleTestMembers.call(this);
  395.     if (eval(Yanfly.Param.PartyLockFirst)) this.lockActor(this._actors[0]);
  396.     for (var i = 0; i < $dataActors.length; ++i) {
  397.       var actor = $dataActors[i];
  398.       if (!actor) continue;
  399.       if (this._battleMembers.contains(actor.id)) continue;
  400.       this._actors.push(actor.id);
  401.     }
  402.     this.loadActorImages();
  403. };

  404. Game_Party.prototype.initializeBattleMembers = function() {
  405.     this._battleMembers = [];
  406.     for (var i = 0; i < this.maxBattleMembers(); ++i) {
  407.       if (this._actors[i]) {
  408.         this._battleMembers.push(this._actors[i]);
  409.       } else {
  410.         this._battleMembers.push(0);
  411.       }
  412.     }
  413.     if ($gamePlayer) $gamePlayer.refresh();
  414. };

  415. Yanfly.Party.Game_Party_addActor = Game_Party.prototype.addActor;
  416. Game_Party.prototype.addActor = function(actorId) {
  417.     Yanfly.Party.Game_Party_addActor.call(this, actorId);
  418.     if (this._battleMembers.contains(actorId)) return;
  419.     if (!this._battleMembers.contains(0)) return;
  420.     var index = this._battleMembers.indexOf(0);
  421.     this._battleMembers[index] = actorId;
  422.     $gamePlayer.refresh();
  423.     $gameMap.requestRefresh();
  424.     this.rearrangeActors();
  425. };

  426. Yanfly.Party.Game_Party_removeActor = Game_Party.prototype.removeActor;
  427. Game_Party.prototype.removeActor = function(actorId) {
  428.     Yanfly.Party.Game_Party_removeActor.call(this, actorId);
  429.     if (!this._battleMembers.contains(actorId)) return;
  430.     var index = this._battleMembers.indexOf(actorId);
  431.     this._battleMembers[index] = 0;
  432.     $gamePlayer.refresh();
  433.     $gameMap.requestRefresh();
  434.     this.rearrangeActors();
  435. };

  436. Game_Party.prototype.rearrangeActors = function() {
  437.     if (this._battleMembers === null) this.initializeBattleMembers();
  438.     var battleArray = [];
  439.     for (var i = 0; i < this._battleMembers.length; ++i) {
  440.       var actorId = this._battleMembers[i];
  441.       if (actorId === null) continue;
  442.       if ($gameActors.actor(actorId)) battleArray.push(actorId);
  443.     }
  444.     var reserveArray = [];
  445.     for (var i = 0; i < this._actors.length; ++i) {
  446.       var actorId = this._actors[i];
  447.       if (battleArray.contains(actorId)) continue;
  448.       if ($gameActors.actor(actorId) === null) continue;
  449.       reserveArray.push(actorId);
  450.     }
  451.     reserveArray = this.sortReserveParty(reserveArray);
  452.     this._actors = battleArray.concat(reserveArray);
  453. };

  454. Game_Party.prototype.sortReserveParty = function(party) {
  455.     party.sort(function(a, b) { return a - b; });
  456.     return party;
  457. };

  458. Game_Party.prototype.lockActor = function(actorId) {
  459.     var actor = $gameActors.actor(actorId);
  460.     if (actor) actor._locked = true;
  461. };

  462. Game_Party.prototype.reconstructActions = function(actorId) {
  463.     for (var i = 0; i < this.members().length; ++i) {
  464.       var member = this.members()[i];
  465.       if (!member) continue;
  466.       if (member.currentAction() && member.currentAction().item()) continue;
  467.       member.makeActions();
  468.     }
  469. };

  470. Yanfly.Party.Game_Party_swapOrder = Game_Party.prototype.swapOrder;
  471. Game_Party.prototype.swapOrder = function(index1, index2) {
  472.     this.swapOrderBattleMembers(index1, index2);
  473.     Yanfly.Party.Game_Party_swapOrder.call(this, index1, index2);
  474.     this.rearrangeActors();
  475.     $gamePlayer.refresh();
  476. };

  477. Game_Party.prototype.swapOrderBattleMembers = function(index1, index2) {
  478.     var bm = this._battleMembers;
  479.     if (bm.length > index1 && bm.length > index2) {
  480.       var actorId1 = this._battleMembers[index1];
  481.       var actorId2 = this._battleMembers[index2];
  482.     } else if (bm.length > index1) {
  483.       var actorId1 = this._battleMembers[index1];
  484.       var actorId2 = this._actors[index2];
  485.     } else if (bm.length > index2) {
  486.       var actorId1 = this._actors[index1];
  487.       var actorId2 = this._battleMembers[index2];
  488.     }
  489.     if (bm.length > index1) this._battleMembers[index1] = actorId2;
  490.     if (bm.length > index2) this._battleMembers[index2] = actorId1;
  491. };

  492. //=============================================================================
  493. // Game_Troop
  494. //=============================================================================

  495. Yanfly.Party.Game_Troop_increaseTurn = Game_Troop.prototype.increaseTurn;
  496. Game_Troop.prototype.increaseTurn = function() {
  497.     Yanfly.Party.Game_Troop_increaseTurn.call(this);
  498.     $gameSystem.updateBattleFormationCooldown();
  499. };

  500. //=============================================================================
  501. // Game_Player
  502. //=============================================================================

  503. Game_Followers.prototype.initialize = function() {
  504.     this._visible = $dataSystem.optFollowers;
  505.     this._gathering = false;
  506.     this._data = [];
  507.     var max = Yanfly.Param.PartyMaxFollower || $gameParty.maxBattleMembers();
  508.     for (var i = 1; i < max; i++) {
  509.         this._data.push(new Game_Follower(i));
  510.     }
  511. };

  512. //=============================================================================
  513. // Game_Interpreter
  514. //=============================================================================

  515. Yanfly.Party.Game_Interpreter_pluginCommand =
  516.     Game_Interpreter.prototype.pluginCommand;
  517. Game_Interpreter.prototype.pluginCommand = function(command, args) {
  518.     Yanfly.Party.Game_Interpreter_pluginCommand.call(this, command, args)
  519.     if (command === 'OpenPartyMenu') this.gotoSceneParty();
  520.     if (command === 'ChangePartyMax') $gameParty.changeBattleMax(args[0]);
  521.     if (command === 'LockActor') this.lockActor(args, true);
  522.     if (command === 'UnlockActor') this.lockActor(args, false);
  523.     if (command === 'RequireActor') this.requireActor(args, true);
  524.     if (command === 'UnrequireActor') this.requireActor(args, false);
  525.     if (command === 'ShowBattleFormation') {
  526.       $gameSystem.setShowBattleFormation(true);
  527.     }
  528.     if (command === 'HideBattleFormation') {
  529.       $gameSystem.setShowBattleFormation(false);
  530.     }
  531.     if (command === 'EnableBattleFormation') {
  532.       $gameSystem.setBattleFormationEnabled(true);
  533.     }
  534.     if (command === 'DisableBattleFormation') {
  535.       $gameSystem.setBattleFormationEnabled(false);
  536.     }
  537. };

  538. Game_Interpreter.prototype.gotoSceneParty = function() {
  539.     if ($gameParty.inBattle()) return;
  540.     $gameParty.loadActorImages();
  541.     SceneManager.push(Scene_Party);
  542. };

  543. Game_Interpreter.prototype.lockActor = function(args, value) {
  544.     for (i = 0; i < args.length; i++) {
  545.       var actorId = Number(args[i]);
  546.       if ($gameActors.actor(actorId)) {
  547.         $gameActors.actor(actorId)._locked = value;
  548.       }
  549.     }
  550. };

  551. Game_Interpreter.prototype.requireActor = function(args, value) {
  552.     for (i = 0; i < args.length; i++) {
  553.       var actorId = Number(args[i]);
  554.       if ($gameActors.actor(actorId)) {
  555.         $gameActors.actor(actorId)._required = value;
  556.       }
  557.     }
  558. };

  559. //=============================================================================
  560. // Window_PartyMenuCommand
  561. //=============================================================================

  562. Window_PartyMenuCommand = function() {
  563.     this.initialize.apply(this, arguments);
  564. }

  565. Window_PartyMenuCommand.prototype = Object.create(Window_Command.prototype);
  566. Window_PartyMenuCommand.prototype.constructor = Window_PartyMenuCommand;

  567. Window_PartyMenuCommand.prototype.initialize = function(x, y) {
  568.     Window_Command.prototype.initialize.call(this, x, y);
  569. };

  570. Window_PartyMenuCommand.prototype.windowWidth = function() {
  571.     var ww = $gameParty.maxBattleMembers() * Window_Base._faceWidth;
  572.     ww += this.standardPadding() * 2;
  573.     return (Graphics.boxWidth - ww).clamp(Graphics.boxWidth / 4, 240);
  574. };

  575. Window_PartyMenuCommand.prototype.numVisibleRows = function() {
  576.     return 4;
  577. };

  578. Window_PartyMenuCommand.prototype.itemTextAlign = function() {
  579.     return Yanfly.Param.PartyTextAlign;
  580. };

  581. Window_PartyMenuCommand.prototype.makeCommandList = function() {
  582.     this.addChangeCommand();
  583.     this.addRemoveCommand();
  584.     this.addRevertCommand();
  585.     this.addCustomCommand();
  586.     this.addCancelCommand();
  587. };

  588. Window_PartyMenuCommand.prototype.addChangeCommand = function() {
  589.     if (Yanfly.Param.PartyCommand1 === '') return;
  590.     this.addCommand(Yanfly.Param.PartyCommand1, 'change');
  591. };

  592. Window_PartyMenuCommand.prototype.addRemoveCommand = function() {
  593.     if (Yanfly.Param.PartyCommand2 === '') return;
  594.     this.addCommand(Yanfly.Param.PartyCommand2, 'remove');
  595. };

  596. Window_PartyMenuCommand.prototype.addRevertCommand = function() {
  597.     if (Yanfly.Param.PartyCommand3 === '') return;
  598.     this.addCommand(Yanfly.Param.PartyCommand3, 'revert');
  599. };

  600. Window_PartyMenuCommand.prototype.addCustomCommand = function() {
  601. };

  602. Window_PartyMenuCommand.prototype.addCancelCommand = function() {
  603.     var enabled = this.isCancelEnabled();
  604.     if (Yanfly.Param.PartyCommand4 === '') return;
  605.     this.addCommand(Yanfly.Param.PartyCommand4, 'cancel', enabled);
  606. };

  607. Window_PartyMenuCommand.prototype.inParty = function(actor) {
  608.     return ($gameParty.battleMembers().contains(actor));
  609. };

  610. Window_PartyMenuCommand.prototype.isCancelEnabled = function() {
  611.     if ($gameParty.aliveMembers().length <= 0) return false;
  612.     if ($gameParty.battleMembers().length <= 0) return false;
  613.     for (var i = 0; i < $gameParty._actors.length; ++i) {
  614.       var actorId = $gameParty._actors[i];
  615.       if (this.refuseCancel(actorId)) return false;
  616.     }
  617.     return true
  618. };

  619. Window_PartyMenuCommand.prototype.refuseCancel = function(actorId) {
  620.     if ($gameParty._battleMembers.contains(actorId)) return false;
  621.     if ($gameActors.actor(actorId)._required) return true;
  622.     return false;
  623. };

  624. //=============================================================================
  625. // Window_PartySelect
  626. //=============================================================================

  627. Window_PartySelect = function() {
  628.     this.initialize.apply(this, arguments);
  629. }

  630. Window_PartySelect.prototype = Object.create(Window_Selectable.prototype);
  631. Window_PartySelect.prototype.constructor = Window_PartySelect;

  632. Window_PartySelect.prototype.initialize = function(commandWindow) {
  633.     var wx = commandWindow.width;
  634.     var wy = commandWindow.y;
  635.     var ww = Graphics.boxWidth - commandWindow.width;
  636.     var wh = commandWindow.height;
  637.     Window_Selectable.prototype.initialize.call(this, wx, wy, ww, wh);
  638.     this.select(-1);
  639.     this.deactivate();
  640.     this.refresh();
  641. };

  642. Window_PartySelect.prototype.maxCols = function() {
  643.     return $gameParty.maxBattleMembers();
  644. };

  645. Window_PartySelect.prototype.maxItems = function() {
  646.     return $gameParty.maxBattleMembers();
  647. };

  648. Window_PartySelect.prototype.itemRect = function(index) {
  649.     var rect = new Rectangle();
  650.     rect.width = this.contents.width / this.maxItems();
  651.     rect.height = this.contents.height;
  652.     rect.x = index * rect.width;
  653.     rect.y = 0;
  654.     return rect;
  655. };

  656. Window_PartySelect.prototype.refresh = function() {
  657.     this.makeItemList();
  658.     this.createContents();
  659.     this.drawAllItems();
  660. };

  661. Window_PartySelect.prototype.makeItemList = function() {
  662.     this._data = $gameParty._battleMembers.slice(0);
  663. };

  664. Window_PartySelect.prototype.drawItem = function(index) {
  665.     var actor = $gameActors.actor(this._data[index]);
  666.     var rect = this.itemRect(index);
  667.     rect.x += this.textPadding() / 2;
  668.     rect.y += this.textPadding() / 2;
  669.     rect.width -= this.textPadding();
  670.     rect.height -= this.textPadding();
  671.     if (actor) {
  672.       this.drawActor(rect, actor);
  673.     } else {
  674.       this.drawEmpty(rect);
  675.     }
  676. };

  677. Window_PartySelect.prototype.drawEmpty = function(rect) {
  678.     var color = this.gaugeBackColor();
  679.     this.changePaintOpacity(false);
  680.     this.contents.fillRect(rect.x, rect.y, rect.width, rect.height, color);
  681.     this.changePaintOpacity(true);
  682.     this.resetFontSettings();
  683.     var text = Yanfly.Param.PartyEmptyText
  684.     this.contents.drawText(text, rect.x, rect.y, rect.width,
  685.         rect.height, 'center');
  686. };

  687. Window_PartySelect.prototype.drawActor = function(rect, actor) {
  688.     if (eval(Yanfly.Param.PartyShowFace)) {
  689.       this.drawActorFace(actor, rect.x, rect.y, rect.width, rect.height);
  690.     }
  691.     if (eval(Yanfly.Param.PartyShowCharacter)) {
  692.       var ry = rect.height * 19/20;
  693.       this.drawActorCharacter(actor, rect.x + rect.width / 2, ry);
  694.     }
  695.     this.drawActorName(actor, rect.x, rect.y, rect.width);
  696.     this.drawLockedIcon(actor, rect);
  697.     this.drawRequiredIcon(actor, rect);
  698. };

  699. Window_PartySelect.prototype.drawLockedIcon = function(actor, rect) {
  700.     if (!actor._locked) return;
  701.     var ix = rect.x + rect.width - Window_Base._iconWidth - 2;
  702.     var iy = rect.y + rect.height - Window_Base._iconHeight - 2;
  703.     this.drawIcon(Yanfly.Icon.PartyLocked, ix, iy)
  704. };

  705. Window_PartySelect.prototype.drawRequiredIcon = function(actor, rect) {
  706.     if (!actor._required) return;
  707.     var ix = rect.x + 2;
  708.     var iy = rect.y + rect.height - Window_Base._iconHeight - 2;
  709.     this.drawIcon(Yanfly.Icon.PartyRequired, ix, iy)
  710. };

  711. Window_PartySelect.prototype.curActor = function() {
  712.     if (!this._data) return null;
  713.     var actorId = this._data[this._index];
  714.     return $gameActors.actor(actorId);
  715. };

  716. Window_PartySelect.prototype.prevActor = function() {
  717.     var id = this._index === 0 ? this._data.length - 1 : this._index - 1;
  718.     var actorId = this._data[id];
  719.     return $gameActors.actor(actorId);
  720. };

  721. Window_PartySelect.prototype.nextActor = function() {
  722.     var id = this._index === this._data.length - 1 ? 0 : this._index + 1;
  723.     var actorId = this._data[id];
  724.     return $gameActors.actor(actorId);
  725. };

  726. Window_PartySelect.prototype.processActor = function(value) {
  727.     return true;
  728. };

  729. Window_PartySelect.prototype.isCurrentItemEnabled = function() {
  730.     if (this.curActor()) return this.curActor().isFormationChangeOk();
  731.     return true;
  732. };

  733. Window_PartySelect.prototype.processPageup = function() {
  734.     if (this.curActor() && this.curActor()._locked) {
  735.       this.playBuzzerSound();
  736.     } else if (this.prevActor() && this.prevActor()._locked) {
  737.       this.playBuzzerSound();
  738.     } else if (this.processActor('prevActor')) {
  739.       Window_Selectable.prototype.processPageup.call(this);
  740.       this.activate();
  741.       this.select(this._index === 0 ? this._data.length - 1 : this._index - 1)
  742.     } else {
  743.       this.playBuzzerSound();
  744.     }
  745. };

  746. Window_PartySelect.prototype.processPagedown = function() {
  747.     if (this.curActor() && this.curActor()._locked) {
  748.       this.playBuzzerSound();
  749.     } else if (this.nextActor() && this.nextActor()._locked) {
  750.       this.playBuzzerSound();
  751.     } else if (this.processActor('nextActor')) {
  752.       Window_Selectable.prototype.processPagedown.call(this);
  753.       this.activate();
  754.       this.select(this._index === this._data.length - 1 ? 0 : this._index + 1)
  755.     } else {
  756.       this.playBuzzerSound();
  757.     }
  758. };

  759. Window_PartySelect.prototype.setDetailWindow = function(win) {
  760.     this._detailWindow = win;
  761.     this.callUpdateHelp();
  762. };

  763. Window_PartySelect.prototype.callUpdateHelp = function() {
  764.     this.setHelpWindowItem(this.curActor());
  765.     this.setDetailWindowItem(this.curActor());
  766. };

  767. Window_PartySelect.prototype.setHelpWindowItem = function(actor) {
  768.     if (this._helpWindow && actor) {
  769.       this._helpWindow.setText(actor.profile());
  770.     } else if (this._helpWindow) {
  771.       this._helpWindow.clear();
  772.     }
  773. };

  774. Window_PartySelect.prototype.setDetailWindowItem = function(actor) {
  775.     if (this._detailWindow) this._detailWindow.setActor(actor);
  776. };

  777. Window_PartySelect.prototype.item = function() {
  778.     var index = this.index();
  779.     return this._data && index >= 0 ? this._data[index] : null;
  780. };

  781. //=============================================================================
  782. // Window_PartyList
  783. //=============================================================================

  784. Window_PartyList = function() {
  785.     this.initialize.apply(this, arguments);
  786. }

  787. Window_PartyList.prototype = Object.create(Window_Selectable.prototype);
  788. Window_PartyList.prototype.constructor = Window_PartyList;

  789. Window_PartyList.prototype.initialize = function(partyWindow) {;
  790.     var wy = partyWindow.y + partyWindow.height;
  791.     this._detailedWindow = eval(Yanfly.Param.PartyDetailWin);
  792.     var ww = this.windowWidth();
  793.     var wh = Graphics.boxHeight - wy;
  794.     Window_Selectable.prototype.initialize.call(this, 0, wy, ww, wh);
  795.     this.select(1);
  796.     this.deactivate();
  797.     this.refresh();
  798. };

  799. Window_PartyList.prototype.windowWidth = function() {
  800.     if (this._detailedWindow) {
  801.       return Yanfly.Param.PartyListWidth;
  802.     } else {
  803.       return Graphics.boxWidth;
  804.     }
  805. };

  806. Window_PartyList.prototype.maxItems = function() {
  807.     return this._data ? this._data.length : 1;
  808. };

  809. Window_PartyList.prototype.refresh = function() {
  810.     this.makeItemList();
  811.     this.createContents();
  812.     this.drawAllItems();
  813. };

  814. Window_PartyList.prototype.makeItemList = function() {
  815.     this._data = [0];
  816.     this.createActorOrder();
  817.     this._data.push(0);
  818. };

  819. Window_PartyList.prototype.createActorOrder = function() {
  820.     for (var i = 0; i < $gameParty._actors.length; ++i) {
  821.       var actorId = $gameParty._actors[i];
  822.       if ($gameActors.actor(actorId)) this._data.push(actorId);
  823.     }
  824. };

  825. Window_PartyList.prototype.drawAllItems = function() {
  826.     var topIndex = this.topIndex();
  827.     for (var i = 0; i < this.maxPageItems(); i++) {
  828.         var index = topIndex + i;
  829.         if (index < this.maxItems()) {
  830.             this.drawItem(index);
  831.             this.clearItem(index + 1);
  832.         }
  833.     }
  834. };

  835. Window_PartyList.prototype.drawItem = function(index) {
  836.     var actor = $gameActors.actor(this._data[index]);
  837.     if (actor) {
  838.       var bitmap = ImageManager.loadCharacter(actor.characterName());
  839.       if (bitmap.width <= 0) {
  840.         return setTimeout(this.drawItem.bind(this, index), 5);
  841.       }
  842.     }
  843.     this.clearItem(index);
  844.     var rect = this.itemRect(index);
  845.     if (this._data[index] === 0) {
  846.       this.drawRemove(rect);
  847.       return;
  848.     }
  849.     this.drawActor(actor, rect);
  850. };

  851. Window_PartyList.prototype.drawRemove = function(rect) {
  852.     var ibw = Window_Base._iconWidth + 4;
  853.     rect.width -= this.textPadding();
  854.     this.drawIcon(Yanfly.Icon.PartyRemove, rect.x + 2, rect.y + 2);
  855.     this.drawText(Yanfly.Param.PartyCommand2, rect.x + ibw, rect.y,
  856.       rect.width - ibw);
  857. };

  858. Window_PartyList.prototype.drawActor = function(actor, rect) {
  859.     this.drawBasic(actor, rect);
  860.     if (this._detailedWindow) return;
  861.     this.drawExtra(actor, rect);
  862. };

  863. Window_PartyList.prototype.drawBasic = function(actor, rect) {
  864.     var wx = Window_Base._iconWidth / 2 + this.textPadding() / 2;
  865.     var wy = rect.y + rect.height + Yanfly.Param.PartySpriteBufferY
  866.     this.drawActorCharacter(actor, wx, wy);
  867.     this.changeTextColor(this.listColor(actor));
  868.     this.changePaintOpacity(this.actorIsEnabled(actor));
  869.     var ibw = Window_Base._iconWidth + 4;
  870.     this.drawText(actor.name(), rect.x + ibw, rect.y, rect.width - ibw);
  871.     this.changePaintOpacity(true);
  872.     this.drawRestrictions(actor, rect);
  873.     this.resetFontSettings();
  874. };

  875. Window_PartyList.prototype.drawExtra = function(actor, rect) {
  876.     var section = this.itemSection();
  877.     this.drawActorLevel(actor, section * 2, rect.y);
  878.     this.drawActorHp(actor, section * 3, rect.y, section - 6);
  879.     this.drawActorMp(actor, section * 4, rect.y, section - 6);
  880.     if ($dataSystem.optDisplayTp) {
  881.       this.drawActorTp(actor, section * 5, rect.y, section - 6);
  882.     }
  883.     this.drawRestrictions(actor, rect);
  884. };

  885. Window_PartyList.prototype.drawRestrictions = function(actor, rect) {
  886.     if (this._detailedWindow) {
  887.       var wx = this.contents.width - Window_Base._iconWidth - 2;
  888.     } else {
  889.       var section = this.itemSection();
  890.       var wx = section * 2 - Window_Base._iconWidth - 2;
  891.     }
  892.     if (actor._locked) {
  893.       this.drawIcon(Yanfly.Icon.PartyLocked, wx, rect.y);
  894.       wx -= Window_Base._iconWidth;
  895.     }
  896.     if (actor._required) {
  897.       this.drawIcon(Yanfly.Icon.PartyRequired, wx, rect.y);
  898.     }
  899. };

  900. Window_PartyList.prototype.itemSection = function() {
  901.     var sections = 5;
  902.     if ($dataSystem.optDisplayTp) sections += 1;
  903.     return this.contents.width / sections;
  904. };

  905. Window_PartyList.prototype.drawCurrentAndMax = function(current, max, x, y,
  906.                                                    width, color1, color2) {
  907.     var labelWidth = this.textWidth('HP');
  908.     var valueWidth = this.textWidth(Yanfly.Util.toGroup(max));
  909.     var slashWidth = this.textWidth('/');
  910.     var x1 = x + width - valueWidth;
  911.     this.changeTextColor(color1);
  912.     this.drawText(Yanfly.Util.toGroup(current), x1, y, valueWidth, 'right');
  913. };

  914. Window_PartyList.prototype.listColor = function(actor) {
  915.     if (actor.isBattleMember()) {
  916.       return this.textColor(Yanfly.Param.ColorInParty);
  917.     }
  918.     return this.normalColor()
  919. };

  920. Window_PartyList.prototype.curActor = function() {
  921.     var actorId = this._data[this._index];
  922.     return $gameActors.actor(actorId);
  923. };

  924. Window_PartyList.prototype.isCurrentItemEnabled = function() {
  925.     if (this.curActor()) return this.curActor().isFormationChangeOk();
  926.     return true;
  927. };

  928. Window_PartyList.prototype.actorIsEnabled = function(actor) {
  929.     return actor.isAppeared();
  930. };

  931. Window_PartyList.prototype.setDetailWindow = function(win) {
  932.     this._detailWindow = win;
  933.     this.callUpdateHelp();
  934. };

  935. Window_PartyList.prototype.callUpdateHelp = function() {
  936.     this.setHelpWindowItem($gameActors.actor(this.item()));
  937.     this.setDetailWindowItem($gameActors.actor(this.item()));
  938. };

  939. Window_PartyList.prototype.setHelpWindowItem = function(actor) {
  940.     if (this._helpWindow && actor) {
  941.         this._helpWindow.setText(actor.profile());
  942.     } else if (this._helpWindow) {
  943.         this._helpWindow.clear();
  944.     }
  945. };

  946. Window_PartyList.prototype.setDetailWindowItem = function(actor) {
  947.     if (this._detailWindow) this._detailWindow.setActor(actor);
  948. };

  949. Window_PartyList.prototype.item = function() {
  950.     var index = this.index();
  951.     return this._data && index >= 0 ? this._data[index] : null;
  952. };

  953. //=============================================================================
  954. // Window_PartyDetail
  955. //=============================================================================

  956. function Window_PartyDetail() {
  957.     this.initialize.apply(this, arguments);
  958. }

  959. Window_PartyDetail.prototype = Object.create(Window_Base.prototype);
  960. Window_PartyDetail.prototype.constructor = Window_PartyDetail;

  961. Window_PartyDetail.prototype.initialize = function(x, y, width, height) {
  962.     Window_Base.prototype.initialize.call(this, x, y, width, height);
  963.     this._actor = null;
  964. };

  965. Window_PartyDetail.prototype.setActor = function(actor) {
  966.     if (this._actor === actor) return;
  967.     this._actor = actor;
  968.     this.refresh();
  969. };

  970. Window_PartyDetail.prototype.clear = function() {
  971.     this.contents.clear();
  972.     this.drawDarkRect(0, 0, this.contents.width, this.contents.height);
  973.     this.changeTextColor(this.systemColor());
  974.     var text = Yanfly.Param.PartyEmptyText
  975.     this.contents.drawText(text, 0, 0, this.contents.width,
  976.         this.contents.height, 'center');
  977. };

  978. Window_PartyDetail.prototype.refresh = function() {
  979.     if (!this._actor) return this.clear();
  980.     this.contents.clear();
  981.     this.drawActorBasicInfo();
  982.     this.calculateAvailableLines();
  983.     this.drawDarkRectangles();
  984.     this.drawActorParams();
  985.     this.drawActorEquips();
  986. };

  987. Window_PartyDetail.prototype.drawDarkRectangles = function() {
  988.     var ww = this.contents.width / 2;
  989.     var wy = this.lineHeight() * 4;
  990.     if (this._linesAvailable >= 7) wy += this.lineHeight();
  991.     if (this._linesAvailable === 4) wy += this.lineHeight();
  992.     var max = this._linesAvailable;
  993.     max = Math.min(this._linesAvailable, this._actor.equipSlots().length);
  994.     for (var i = 0; i < max; ++i) {
  995.       if (wy + this.lineHeight() > this.contents.height) break;
  996.       this.drawDarkRect(ww, wy, ww, this.lineHeight());
  997.       wy += this.lineHeight();
  998.     }
  999.     var wy = this.lineHeight() * 4;
  1000.     if (this._linesAvailable >= 7) wy += this.lineHeight();
  1001.     if (this._linesAvailable === 4) wy += this.lineHeight();
  1002.     for (var i = 0; i < 6; ++i) {
  1003.       var rect = this.paramRect(i);
  1004.       this.drawDarkRect(rect.x, rect.y, rect.width, rect.height);
  1005.     }
  1006. };

  1007. Window_PartyDetail.prototype.drawDarkRect = function(dx, dy, dw, dh) {
  1008.     var color = this.gaugeBackColor();
  1009.     this.changePaintOpacity(false);
  1010.     this.contents.fillRect(dx + 1, dy + 1, dw - 2, dh - 2, color);
  1011.     this.changePaintOpacity(true);
  1012. };

  1013. Window_PartyDetail.prototype.paramRect = function(index) {
  1014.     var rect = new Rectangle();
  1015.     rect.x = 0;
  1016.     rect.y = this.lineHeight() * 4;
  1017.     rect.height = this.lineHeight();
  1018.     rect.width = this.contents.width / 2
  1019.     if (this._linesAvailable >= 7) rect.y += this.lineHeight();
  1020.     if (this._linesAvailable === 4) rect.y += this.lineHeight();
  1021.     if (this._linesAvailable >= 6) {
  1022.       rect.y += this.lineHeight() * index;
  1023.     } else {
  1024.       rect.width /= 2;
  1025.       rect.x = index % 2 === 0 ? 0 : rect.width;
  1026.       rect.y += this.lineHeight() * Math.floor(index / 2);
  1027.     }
  1028.     return rect;
  1029. };

  1030. Window_PartyDetail.prototype.drawActorBasicInfo = function() {
  1031.     var w = this.width - this.padding * 2;
  1032.     var h = this.height - this.padding * 2;
  1033.     var y = 0;
  1034.     var padding = 0;
  1035.     var xpad = padding + Window_Base._faceWidth;
  1036.     var width = w - 162 - this.textPadding();
  1037.     h = Window_Base._faceHeight;
  1038.     this.drawActorFace(this._actor, 0, 0, Window_Base._faceWidth, h);
  1039.     this.drawActorSimpleStatus(this._actor, xpad, y, width);
  1040. };

  1041. Window_PartyDetail.prototype.calculateAvailableLines = function() {
  1042.     if (this._linesAvailable) return;
  1043.     this._linesAvailable = this.contents.height - this.lineHeight() * 4;
  1044.     this._linesAvailable /= this.lineHeight();
  1045.     this._linesAvailable = Math.floor(this._linesAvailable);
  1046. };

  1047. Window_PartyDetail.prototype.drawActorParams = function() {
  1048.     this.drawActorParamsTitle();
  1049.     for (var i = 0; i < 6; ++i) {
  1050.       var rect = this.paramRect(i);
  1051.       if (this._linesAvailable > 4) {
  1052.         rect.x += 8;
  1053.         rect.width -= 16;
  1054.       } else {
  1055.         rect.x += 4;
  1056.         rect.width -= 8;
  1057.       }
  1058.       var paramId = i + 2;
  1059.       var text = TextManager.param(paramId);
  1060.       this.changeTextColor(this.systemColor());
  1061.       this.drawText(text, rect.x, rect.y, rect.width);
  1062.       var paramValue = Yanfly.Util.toGroup(this._actor.param(paramId));
  1063.       this.changeTextColor(this.normalColor());
  1064.       this.drawText(paramValue, rect.x, rect.y, rect.width, 'right');
  1065.     }
  1066. };

  1067. Window_PartyDetail.prototype.drawActorParamsTitle = function() {
  1068.     var wy = this.lineHeight() * 4;
  1069.     var ww = this.contents.width / 2;
  1070.     if (this._linesAvailable >= 7) {
  1071.       var text = Yanfly.Param.PartyDetailParam;
  1072.       this.changeTextColor(this.systemColor());
  1073.       this.drawText(text, 0, wy, ww, 'center');
  1074.     } else if (this._linesAvailable === 4) {
  1075.       var text = Yanfly.Param.PartyDetailParam;
  1076.       this.changeTextColor(this.systemColor());
  1077.       this.drawText(text, 0, wy, ww, 'center');
  1078.     }
  1079. };

  1080. Window_PartyDetail.prototype.drawActorEquips = function() {
  1081.     this.drawActorEquipsTitle();
  1082.     var equips = this.getActorEquips();
  1083.     this.drawActorEquipsList(equips);
  1084. };

  1085. Window_PartyDetail.prototype.drawActorEquipsTitle = function() {
  1086.     var wy = this.lineHeight() * 4;
  1087.     var ww = this.contents.width / 2;
  1088.     if (this._linesAvailable >= 7) {
  1089.       var text = Yanfly.Param.PartyDetailEquip;
  1090.       this.changeTextColor(this.systemColor());
  1091.       this.drawText(text, ww, wy, ww, 'center');
  1092.     } else if (this._linesAvailable === 4) {
  1093.       var text = Yanfly.Param.PartyDetailEquip;
  1094.       this.changeTextColor(this.systemColor());
  1095.       this.drawText(text, ww, wy, ww, 'center');
  1096.     }
  1097. };

  1098. Window_PartyDetail.prototype.getActorEquips = function() {
  1099.     var equips = [];
  1100.     for (var i = 0; i < this._actor.equips().length; ++i) {
  1101.       var equip = this._actor.equips()[i];
  1102.       if (equip) equips.push(equip);
  1103.     }
  1104.     return equips;
  1105. };

  1106. Window_PartyDetail.prototype.drawActorEquipsList = function(equips) {
  1107.     this._lastSlot = false;
  1108.     var max = this._linesAvailable;
  1109.     var ww = this.contents.width / 2;
  1110.     var wh = this.lineHeight();
  1111.     var wy = this.lineHeight() * 4;
  1112.     var wx = ww + 6;
  1113.     ww -= 12;
  1114.     if (this._linesAvailable >= 7) {
  1115.       max -= 1;
  1116.       wy += this.lineHeight();
  1117.     }
  1118.     if (this._linesAvailable === 4) {
  1119.       max -= 1;
  1120.       wy += this.lineHeight();
  1121.     }
  1122.     for (var i = 0; i < equips.length; ++i) {
  1123.       var equip = equips[i];
  1124.       if (!equip) break;
  1125.       if (i >= max - 1 && i < equips.length - 1) this._lastSlot = true;
  1126.       if (this._lastSlot) {
  1127.         var iconIndex = equip.iconIndex;
  1128.         this.drawIcon(iconIndex, wx + 2, wy + 2);
  1129.         wx += Window_Base._iconWidth;
  1130.         continue;
  1131.       } else if (this._lastSlot && i === equips.length - 1) {
  1132.         var iconIndex = equip.iconIndex;
  1133.         this.drawIcon(iconIndex, wx + 2, wy + 2);
  1134.         wx += Window_Base._iconWidth;
  1135.       } else {
  1136.         this.drawItemName(equip, wx, wy, ww);
  1137.       }
  1138.       wy += this.lineHeight();
  1139.     }
  1140. };

  1141. //=============================================================================
  1142. // Battle Engine Core Implementation
  1143. //=============================================================================

  1144. if (Imported.YEP_BattleEngineCore) {

  1145. //=============================================================================
  1146. // BattleManager
  1147. //=============================================================================

  1148. Yanfly.Party.BattleManager_startBattle = BattleManager.startBattle;
  1149. BattleManager.startBattle = function() {
  1150.     if (!$gameTemp._partyBattle) {
  1151.       Yanfly.Party.BattleManager_startBattle.call(this);
  1152.     }
  1153.     $gameTemp._partyBattle = false;
  1154.     this._bypassMoveToStartLocation = false;
  1155. };

  1156. Yanfly.Party.BattleManager_playBattleBgm = BattleManager.playBattleBgm;
  1157. BattleManager.playBattleBgm = function() {
  1158.     var restartBgm = true;
  1159.     if (Yanfly.Party.SavedBattleBgm) {
  1160.       AudioManager.playBgm(Yanfly.Party.SavedBattleBgm);
  1161.       Yanfly.Party.SavedBattleBgm = undefined;
  1162.       restartBgm = false;
  1163.     }
  1164.     if (Yanfly.Party.SavedBattleBgs) {
  1165.       AudioManager.playBgs(Yanfly.Party.SavedBattleBgs);
  1166.       Yanfly.Party.SavedBattleBgs = undefined;
  1167.       restartBgm = false;
  1168.     }
  1169.     if (restartBgm) Yanfly.Party.BattleManager_playBattleBgm.call(this);
  1170. };

  1171. //=============================================================================
  1172. // Game_Unit
  1173. //=============================================================================

  1174. Yanfly.Party.Game_Unit_onBattleStart = Game_Unit.prototype.onBattleStart;
  1175. Game_Unit.prototype.onBattleStart = function() {
  1176.     if ($gameTemp._partyBattle) return;
  1177.     Yanfly.Party.Game_Unit_onBattleStart.call(this);
  1178.     $gameSystem.resetBattleFormationCooldown();
  1179. };

  1180. Yanfly.Party.Game_Unit_onBattleEnd = Game_Unit.prototype.onBattleEnd;
  1181. Game_Unit.prototype.onBattleEnd = function() {
  1182.     if ($gameTemp._partyBattle) return;
  1183.     Yanfly.Party.Game_Unit_onBattleEnd.call(this);
  1184.     $gameSystem.resetBattleFormationCooldown();
  1185. };

  1186. //=============================================================================
  1187. // Window_Command
  1188. //=============================================================================

  1189. Window_Command.prototype.addCommandAt = function(index, name, symbol, en, ext) {
  1190.     if (en === undefined) enabled = true;
  1191.     if (ext === undefined) ext = null;
  1192.     var obj = { name: name, symbol: symbol, enabled: en, ext: ext};
  1193.     this._list.splice(index, 0, obj);
  1194. };

  1195. //=============================================================================
  1196. // Window_PartyCommand
  1197. //=============================================================================

  1198. Yanfly.Party.Window_PartyCommand_makeCommandList =
  1199.     Window_PartyCommand.prototype.makeCommandList;
  1200. Window_PartyCommand.prototype.makeCommandList = function() {
  1201.     Yanfly.Party.Window_PartyCommand_makeCommandList.call(this);
  1202.     this.addFormationCommand();
  1203. };

  1204. Window_PartyCommand.prototype.addFormationCommand = function() {
  1205.     if (!$gameSystem.isShowBattleFormation()) return;
  1206.     var index = this.findSymbol('escape');
  1207.     var enabled = $gameSystem.isBattleFormationEnabled();
  1208.     this.addCommandAt(index, TextManager.formation, 'formation', enabled);
  1209. };

  1210. //=============================================================================
  1211. // Sprite_Actor
  1212. //=============================================================================

  1213. Yanfly.Party.Sprite_Actor_moveToStartPosition =
  1214.     Sprite_Actor.prototype.moveToStartPosition;
  1215. Sprite_Actor.prototype.moveToStartPosition = function() {
  1216.     if (BattleManager._bypassMoveToStartLocation) return;
  1217.     Yanfly.Party.Sprite_Actor_moveToStartPosition.call(this);
  1218. };

  1219. //=============================================================================
  1220. // Spriteset_Battle
  1221. //=============================================================================

  1222. Yanfly.Party.Spriteset_Battle_createBackground =
  1223.     Spriteset_Battle.prototype.createBackground;
  1224. Spriteset_Battle.prototype.createBackground = function() {
  1225.     Yanfly.Party.Spriteset_Battle_createBackground.call(this);
  1226.     if (Yanfly.Party.SavedBackgroundBitmap) {
  1227.       var spr = this._backgroundSprite;
  1228.       spr.bitmap = Yanfly.Party.SavedBackgroundBitmap;
  1229.       Yanfly.Party.SavedBackgroundBitmap = undefined;
  1230.     }
  1231. };

  1232. //=============================================================================
  1233. // Scene_Map
  1234. //=============================================================================

  1235. Yanfly.Party.Scene_Map_create = Scene_Map.prototype.create;
  1236. Scene_Map.prototype.create = function() {
  1237.     Yanfly.Party.Scene_Map_create.call(this);
  1238.     $gameParty.loadActorImages();
  1239. };

  1240. //=============================================================================
  1241. // Scene_Battle
  1242. //=============================================================================

  1243. Yanfly.Party.Scene_Battle_createDisplayObjects =
  1244.     Scene_Battle.prototype.createDisplayObjects;
  1245. Scene_Battle.prototype.createDisplayObjects = function() {
  1246.     Yanfly.Party.Scene_Battle_createDisplayObjects.call(this);
  1247.     $gameParty.loadActorImages();
  1248. };

  1249. Yanfly.Party.Scene_Battle_createPartyCommandWindow =
  1250.     Scene_Battle.prototype.createPartyCommandWindow;
  1251. Scene_Battle.prototype.createPartyCommandWindow = function() {
  1252.     Yanfly.Party.Scene_Battle_createPartyCommandWindow.call(this);
  1253.     var win = this._partyCommandWindow;
  1254.     win.setHandler('formation', this.partyCommandFormation.bind(this));
  1255. };

  1256. Scene_Battle.prototype.partyCommandFormation = function() {
  1257.     BattleManager._bypassMoveToStartLocation = true;
  1258.     $gameParty.loadActorImages();
  1259.     this.prepareBackground();
  1260.     BattleManager._savedActor = BattleManager.actor();
  1261.     $gameSystem.setBattleFormationCooldown();
  1262.     Yanfly.Party.SavedBattleBgm = AudioManager.saveBgm();
  1263.     Yanfly.Party.SavedBattleBgs = AudioManager.saveBgs();
  1264.     SceneManager.push(Scene_Party);
  1265.     BattleManager._phase = 'input';
  1266.     $gameTemp._partyBattle = true;
  1267. };

  1268. Scene_Battle.prototype.prepareBackground = function() {
  1269.     Yanfly.Party.SavedBackgroundBitmap = SceneManager._backgroundBitmap;
  1270.     this._prevWindowLayer = this._windowLayer.y;
  1271.     this._windowLayer.y = Graphics.boxHeight * 495;
  1272.     SceneManager.snapForBackground();
  1273.     this._windowLayer.y = this._prevWindowLayer;
  1274. };

  1275. }; // Imported.YEP_BattleEngineCore

  1276. //=============================================================================
  1277. // Scene_Menu
  1278. //=============================================================================

  1279. Scene_Menu.prototype.commandFormation = function() {
  1280.     $gameParty.loadActorImages();
  1281.     SceneManager.push(Scene_Party);
  1282. };

  1283. //=============================================================================
  1284. // Scene_Party
  1285. //=============================================================================

  1286. Scene_Party = function() {
  1287.     this.initialize.apply(this, arguments);
  1288. }

  1289. Scene_Party.prototype = Object.create(Scene_MenuBase.prototype);
  1290. Scene_Party.prototype.constructor = Scene_Party;

  1291. Scene_Party.prototype.initialize = function() {
  1292.     Scene_MenuBase.prototype.initialize.call(this);
  1293.     this._formerParty = $gameParty._battleMembers.slice(0);
  1294. };

  1295. Scene_Party.prototype.create = function() {
  1296.     Scene_MenuBase.prototype.create.call(this);
  1297.     if (eval(Yanfly.Param.PartyHelpWindow)) this.createHelpWindow();
  1298.     this.createCommandWindow();
  1299.     this.createPartyWindow();
  1300.     this.createListWindow();
  1301.     this.createDetailWindow();
  1302. };

  1303. Scene_Party.prototype.createCommandWindow = function() {
  1304.     this._commandWindow = new Window_PartyMenuCommand(0, 0);
  1305.     if (this._helpWindow) this._commandWindow.y = this._helpWindow.height;
  1306.     this._commandWindow.setHandler('change', this.commandAdjust.bind(this));
  1307.     this._commandWindow.setHandler('remove', this.commandAdjust.bind(this));
  1308.     this._commandWindow.setHandler('revert', this.commandRevert.bind(this));
  1309.     this._commandWindow.setHandler('cancel', this.commandFinish.bind(this));
  1310.     this.addWindow(this._commandWindow);
  1311. };

  1312. Scene_Party.prototype.createPartyWindow = function() {
  1313.     this._partyWindow = new Window_PartySelect(this._commandWindow);
  1314.     if (this._helpWindow) this._partyWindow.setHelpWindow(this._helpWindow);
  1315.     this._partyWindow.setHandler('ok',       this.onPartyOk.bind(this));
  1316.     this._partyWindow.setHandler('cancel',   this.onPartyCancel.bind(this));
  1317.     this._partyWindow.setHandler('pageup',   this.onPartyPageUp.bind(this));
  1318.     this._partyWindow.setHandler('pagedown', this.onPartyPageDown.bind(this));
  1319.     this.addWindow(this._partyWindow);
  1320. };

  1321. Scene_Party.prototype.createListWindow = function() {
  1322.     this._listWindow = new Window_PartyList(this._partyWindow);
  1323.     if (this._helpWindow) this._listWindow.setHelpWindow(this._helpWindow);
  1324.     this._listWindow.setHandler('ok',     this.onListOk.bind(this));
  1325.     this._listWindow.setHandler('cancel', this.onListCancel.bind(this));
  1326.     this.addWindow(this._listWindow);
  1327. };

  1328. Scene_Party.prototype.createDetailWindow = function() {
  1329.     if (!eval(Yanfly.Param.PartyDetailWin)) return;
  1330.     var wx = this._listWindow.width;
  1331.     var wy = this._listWindow.y;
  1332.     var ww = Graphics.boxWidth - wx;
  1333.     var wh = Graphics.boxHeight - wy;
  1334.     this._detailWindow = new Window_PartyDetail(wx, wy, ww, wh);
  1335.     this.addWindow(this._detailWindow);
  1336.     this._partyWindow.setDetailWindow(this._detailWindow);
  1337.     this._listWindow.setDetailWindow(this._detailWindow);
  1338.     this._detailWindow.clear();
  1339. };

  1340. Scene_Party.prototype.refreshWindows = function() {
  1341.     $gameParty.rearrangeActors();
  1342.     this._commandWindow.refresh();
  1343.     this._partyWindow.refresh();
  1344.     this._listWindow.refresh();
  1345.     $gamePlayer.refresh();
  1346.     $gameMap.requestRefresh();
  1347. };

  1348. Scene_Party.prototype.commandAdjust = function() {
  1349.     this._partyWindow.activate();
  1350.     this._partyWindow.select(0);
  1351. };

  1352. Scene_Party.prototype.commandRevert = function() {
  1353.     this._commandWindow.activate();
  1354.     $gameParty._battleMembers = this._formerParty.slice(0);
  1355.     this.refreshWindows();
  1356. };

  1357. Scene_Party.prototype.commandFinish = function() {
  1358.     if ($gameParty.inBattle()) {
  1359.       $gameParty.reconstructActions();
  1360.       if (BattleManager._savedActor) {
  1361.         BattleManager._actorIndex = BattleManager._savedActor.index();
  1362.       }
  1363.     }
  1364.     this.popScene();
  1365. };

  1366. Scene_Party.prototype.onPartyOk = function() {
  1367.     var symbol = this._commandWindow.currentSymbol();
  1368.     if (symbol === 'change') {
  1369.       this._listWindow.activate()
  1370.     } else if (symbol === 'remove') {
  1371.       SoundManager.playEquip();
  1372.       var index = this._partyWindow._index;
  1373.       var actor = $gameActors.actor($gameParty._battleMembers[index]);
  1374.       $gameParty._battleMembers[index] = 0
  1375.       this.refreshWindows();
  1376.       this._partyWindow.activate();
  1377.     }
  1378. };

  1379. Scene_Party.prototype.onPartyCancel = function() {
  1380.     this._partyWindow.select(-1);
  1381.     this._commandWindow.activate();
  1382.     if (this._helpWindow) this._helpWindow.setItem(null);
  1383. };

  1384. Scene_Party.prototype.onPartyPageUp = function() {
  1385.     SoundManager.playEquip();
  1386.     var actorId1 = this._partyWindow.item();
  1387.     if (!this._partyWindow.prevActor()) {
  1388.       var actorId2 = 0;
  1389.     } else {
  1390.       var actorId2 = this._partyWindow.prevActor().actorId();
  1391.     }
  1392.     var max = this._partyWindow.maxItems() - 1;
  1393.     var index1 = this._partyWindow._index;
  1394.     var index2 = this._partyWindow._index === 0 ? max : index1 - 1;
  1395.     $gameParty._battleMembers[index1] = actorId2;
  1396.     $gameParty._battleMembers[index2] = actorId1;
  1397.     this.refreshWindows();
  1398. };

  1399. Scene_Party.prototype.onPartyPageDown = function() {
  1400.     SoundManager.playEquip();
  1401.     var actorId1 = this._partyWindow.item();
  1402.     if (!this._partyWindow.nextActor()) {
  1403.       var actorId2 = 0;
  1404.     } else {
  1405.       var actorId2 = this._partyWindow.nextActor().actorId();
  1406.     }
  1407.     var max = this._partyWindow.maxItems() - 1;
  1408.     var index1 = this._partyWindow._index;
  1409.     var index2 = this._partyWindow._index === max ? 0 : index1 + 1;
  1410.     $gameParty._battleMembers[index1] = actorId2;
  1411.     $gameParty._battleMembers[index2] = actorId1;
  1412.     this.refreshWindows();
  1413. };

  1414. Scene_Party.prototype.onListCancel = function() {
  1415.     this._partyWindow.activate();
  1416. };

  1417. Scene_Party.prototype.onListOk = function() {
  1418.     SoundManager.playEquip();
  1419.     if (this._listWindow.item() <= 0) {
  1420.       this.otherAction();
  1421.     } else {
  1422.       this.switchActors();
  1423.     }
  1424.     this.refreshWindows();
  1425.     this._partyWindow.activate();
  1426. };

  1427. Scene_Party.prototype.otherAction = function() {
  1428.     if (this._listWindow.item() === 0) {
  1429.       $gameParty._battleMembers[this._partyWindow._index] = 0;
  1430.     }
  1431. };

  1432. Scene_Party.prototype.switchActors = function() {
  1433.     var targetId = this._listWindow.item();
  1434.     var targetIndex = this._partyWindow._index;
  1435.     if ($gameParty._battleMembers.contains(targetId)) {
  1436.       var switchId = this._partyWindow.item();
  1437.       var switchIndex = $gameParty._battleMembers.indexOf(targetId);
  1438.       $gameParty._battleMembers[switchIndex] = switchId;
  1439.     };
  1440.     $gameParty._battleMembers[targetIndex] = targetId;
  1441. };

  1442. //=============================================================================
  1443. // Utilities
  1444. //=============================================================================

  1445. Yanfly.Util = Yanfly.Util || {};

  1446. if (!Yanfly.Util.toGroup) {
  1447.     Yanfly.Util.toGroup = function(inVal) {
  1448.         return inVal;
  1449.     }
  1450. };

  1451. //=============================================================================
  1452. // End of File
  1453. //=============================================================================
复制代码
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部