Fear3d

Merc_LockPartyLeader

Feb 7th, 2026 (edited)
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // Mercury Lock Party Leader
  3. // Merc_LockPartyLeader.js
  4. //=============================================================================
  5.  
  6. var Imported = Imported || {};
  7. Imported.Merc_LockPartyLeader = true;
  8.  
  9. var Mercury = Mercury || {};
  10. Mercury.LockPartyLeader = Mercury.LockPartyLeader || {};
  11. Mercury.LockPartyLeader.version = 1.00;
  12.  
  13. /*:
  14. * @target MZ
  15. * @plugindesc [Version 1.00] Lock Party Leader
  16. * @author Mercury
  17. *
  18. * @param isLockEnabled
  19. * @text Lock Enabled
  20. * @desc Whether or not to lock the party leader by default.
  21. * @type boolean
  22. * @default true
  23. *
  24. * @command setLock
  25. * @text Set Lock
  26. * @desc Enable or disable the lock on the party leader.
  27. *
  28. * @arg enabled
  29. * @text Enabled
  30. * @desc Whether to enable the lock (true) or disable it (false).
  31. * @type boolean
  32. * @default true
  33. *
  34. * @command setLeader
  35. * @text Set Leader
  36. * @desc Change which party member is considered the leader.
  37. *
  38. * @arg actorId
  39. * @text Actor ID
  40. * @desc The ID of the actor to set as the leader.
  41. * @type actor
  42. * @default 1
  43. *
  44. * @command openFormation
  45. * @text Open Formation Menu
  46. * @desc Open the party formation menu.
  47. *
  48. * @help
  49. *
  50. * ------------------------------------------------------------------------
  51. * Information
  52. * ------------------------------------------------------------------------
  53. * This plugin allows you to lock the party leader in the party formation menu.
  54. *
  55. * There is also a plugin command to enable or disable the lock, and a plugin command
  56. * to change which actor is considered the leader. I have also included a plugin
  57. * command that allows you to open the party formation menu directly from an event.
  58. *
  59. * ------------------------------------------------------------------------
  60. * Terms of Use
  61. * ------------------------------------------------------------------------
  62. * - Free for commercial and non-commercial use.
  63. * - You may do whatever you want with this plugin, aside from directly selling it.
  64. */
  65.  
  66. //=============================================================================
  67. // Settings
  68. //=============================================================================
  69.  
  70. Mercury.LockPartyLeader.parameters = PluginManager.parameters('Merc_LockPartyLeader');
  71. Mercury.LockPartyLeader.isLockEnabled = Mercury.LockPartyLeader.parameters['isLockEnabled'] === 'true';
  72. Mercury.LockPartyLeader.needFormationMenu = false;
  73.  
  74. //=============================================================================
  75. // Plugin Commands
  76. //=============================================================================
  77.  
  78. PluginManager.registerCommand('Merc_LockPartyLeader', 'setLock', function(args) {
  79.     Mercury.LockPartyLeader.isLockEnabled = args.enabled === 'true';
  80. });
  81.  
  82. PluginManager.registerCommand('Merc_LockPartyLeader', 'setLeader', function(args) {
  83.     $gameParty.setLeader(Number(args.actorId));
  84. });
  85.  
  86. PluginManager.registerCommand('Merc_LockPartyLeader', 'openFormation', function() {
  87.     Mercury.LockPartyLeader.needFormationMenu = true;
  88.     SceneManager.push(Scene_Menu);
  89. });
  90.  
  91. //=============================================================================
  92. // Game_Actor
  93. //=============================================================================
  94.  
  95. Mercury.LockPartyLeader.Game_Actor_isFormationChangeOk = Game_Actor.prototype.isFormationChangeOk;
  96. Game_Actor.prototype.isFormationChangeOk = function() {
  97.     if (Mercury.LockPartyLeader.isLockEnabled && this.index() === 0) {
  98.         return false;
  99.     }
  100.     return Mercury.LockPartyLeader.Game_Actor_isFormationChangeOk.call(this);
  101. };
  102.  
  103. //=============================================================================
  104. // Game_Party
  105. //=============================================================================
  106.  
  107. Game_Party.prototype.setLeader = function(actorId) {
  108.     const actorIndex = this._actors.indexOf(actorId);
  109.     if (actorIndex > -1) {
  110.         this.swapOrder(0, actorIndex);
  111.     } else {
  112.         console.warn(`Actor ID ${actorId} is not in the party.`);
  113.     }
  114. };
  115.  
  116. //=============================================================================
  117. // Scene_Menu
  118. //=============================================================================
  119.  
  120. Mercury.LockPartyLeader.Scene_Menu_start = Scene_Menu.prototype.start;
  121. Scene_Menu.prototype.start = function() {
  122.     Mercury.LockPartyLeader.Scene_Menu_start.call(this);
  123.     if (Mercury.LockPartyLeader.needFormationMenu) {
  124.         this._commandWindow.selectSymbol('formation');
  125.         this._commandWindow.deactivate();
  126.         this.commandFormation();
  127.         Mercury.LockPartyLeader.needFormationMenu = false;
  128.     }
  129. };
  130.  
  131. //=============================================================================
  132. // Window_MenuCommand
  133. //=============================================================================
  134.  
  135. Mercury.LockPartyLeader.Window_MenuCommand_needsCommand = Window_MenuCommand.prototype.needsCommand;
  136. Window_MenuCommand.prototype.needsCommand = function(name) {
  137.     if (name === 'formation' && Mercury.LockPartyLeader.needFormationMenu) {
  138.         return true;
  139.     }
  140.     return Mercury.LockPartyLeader.Window_MenuCommand_needsCommand.call(this, name);
  141. };
Advertisement
Add Comment
Please, Sign In to add comment