//============================================================================= // SEK_ChangeActor.js //============================================================================= /*: * @plugindesc Adds the possibility to change an actor with a not fighting one, jumping your turn. * @author SEK * * *@param Command Name *@desc The command name that will be shown in battle. Default is "Change". *@default Change * *@param Show Animation on battler change *@desc Default is "true". *@default true * *@param Animation Id to show *@desc Default is "42". *@default 42 * *@param Enabled *@desc Set this true to enable the command. You can change it with plugin commands whenever you want. Default is true. *@default true * *@param Using DoubleX RMMV Popularized ATB Core *@desc Set this true if you're using DoubleX RMMV Popularized ATB Core. Default is false. *@default false * * * @help * Plugin Commands: * * ac on Activates the command * ac off Deactivates the command * * ac showon Shows an animation when you change an actor * ac showoff Doesn't show an animation when you change an actor * * ac show x Sets the animation to x * * ac lockon x Lock actor x in battle, you won't be able to change it * ac lockoff x Removes the lock on actor x * *You are free to use this plugin. If you do use it, I'd like to have my name and my plugin's name included in credits. */ var params=PluginManager.parameters('SEK_ChangeActor'); var cambio=String(params['Command Name']||"Change"); var enabled=(params['Enabled'] || "true").toLowerCase()==="true"; var usingpatb=(params['Using DoubleX RMMV Popularized ATB Core'] || "true").toLowerCase()==="true"; var show=(params['Show Animation on battler change'] || "false").toLowerCase()==="true"; var animation = Number(params['Animation Id to show'] || 42); var aliasinterpreter = Game_Interpreter.prototype.pluginCommand; Game_Interpreter.prototype.pluginCommand = function(command, args) { aliasinterpreter.call(this, command, args); if (command.toLowerCase() === "ac") { switch (args[0].toLowerCase()) { case 'on': { enabled=true; } break; case 'off': { enabled=false; } break; case 'showon': { show=true; } break; case 'showoff': { show=false; } break; case 'show': { animation = Number(args[1] || 42);; } break; case 'lockon': { $gameActors.actor([args[1]])._lock=true; } break; case 'lockoff': { $gameActors.actor([args[1]])._lock=false; } break; } } }; var initact = Game_Actor.prototype.initMembers; var initactb = Game_Battler.prototype.initMembers; Game_Actor.prototype.initMembers = function() { initact.call(this); initactb.call(this); this._lock=false; } var prpr=Window_PartyCommand.prototype.makeCommandList; Window_PartyCommand.prototype.makeCommandList = function() { prpr.call(this); this.addChangeCommand(); }; Window_PartyCommand.prototype.addChangeCommand = function() { var changing=false; if($gameParty.hiddenAlive().length>0&&!this.allLocked()) changing=true; this.addCommand(cambio, 'change', (changing&&enabled)); }; Window_PartyCommand.prototype.allLocked=function(){ for (i=0;i<$gameParty.members().length; i++) { if ($gameParty.members()[i]._lock==false) return false; } return true; } var aliasetto=Scene_Battle.prototype.createPartyCommandWindow; Scene_Battle.prototype.createPartyCommandWindow = function() { aliasetto.call(this); this._partyCommandWindow.setHandler('change', this.commandChange.bind(this),$gameParty.hiddenAlive().length>0); this._partyCommandWindow.deselect(); this.addWindow(this._partyCommandWindow); }; Scene_Battle.prototype.onActorOk = function() { var action = BattleManager.inputtingAction(); action.setTarget(this._actorWindow.index()); this._actorWindow.hide(); this._skillWindow.hide(); this._changeWindow.refresh(); this._changeWindow.hide(); this._itemWindow.hide(); this.selectNextCommand(); }; Scene_Battle.prototype.onActorCancel = function() { this._actorWindow.hide(); switch (this._actorCommandWindow.currentSymbol()) { case 'skill': this._skillWindow.show(); this._skillWindow.activate(); break; case 'item': this._itemWindow.show(); this._itemWindow.activate(); break; case 'change': this._changeWindow.refresh(); this._changeWindow.show(); this._changeWindow.activate(); break; } }; var isanyinput = Scene_Battle.prototype.isAnyInputWindowActive; Scene_Battle.prototype.isAnyInputWindowActive = function() { return (isanyinput.call(this)||this._changeWindow.active); }; var aliascreatewindows =Scene_Battle.prototype.createAllWindows; Scene_Battle.prototype.createAllWindows = function() { aliascreatewindows.call(this); this.createChangeWindow(); }; Scene_Battle.prototype.createChangeWindow = function() { var wh = this._statusWindow.y; this._changeWindow = new Window_BattleChange(0, 0, Graphics.boxWidth, wh); this._changeWindow.setHelpWindow(this._helpWindow); this._changeWindow.setHandler('ok', this.onChangeOk.bind(this)); this._changeWindow.setHandler('cancel', this.onChangeCancel.bind(this)); this.addWindow(this._changeWindow); this.refreshStatus(); }; Scene_Battle.prototype.commandChange = function() { windowChangeActive=true; x=null; this._changeWindow.refresh(); this._changeWindow.show(); this._changeWindow.activate(); }; var x; var y; Scene_Battle.prototype.onChangeOk = function() { if (usingpatb){ $gameParty.clearActions(); BattleManager.need_patb_refresh = true; } if (x==null){ x = $gameParty.allMembers().indexOf(this._changeWindow._inCampo[this._changeWindow.item()]); this._changeWindow.refresh(); this._changeWindow.hide(); this.c2();} else { y = $gameParty.allMembers().indexOf($gameParty.hiddenAlive()[this._changeWindow.item()]);; if (show) $gameParty.allMembers()[x].startAnimation(animation, true, 0); $gameParty.swap(x, y); this._actorWindow.hide(); this._skillWindow.hide(); this._itemWindow.hide(); this._changeWindow.refresh(); this._changeWindow.hide(); this.refreshStatus(); if (usingpatb){ windowChangeActive=false; this.select_next_patb_command(); } if (!usingpatb) this.jumpNextCommand(); } }; Game_Party.prototype.hiddenMembers = function() { return this.allMembers().slice(this.maxBattleMembers()) }; Game_Party.prototype.hiddenAlive = function() { return this.hiddenMembers().filter(function(member) { return member.hp!=0; }); }; Game_Party.prototype.swap = function(x,y) { var safe; var aggiungi=$gameParty.allMembers().clone(); var temp=aggiungi[x]; aggiungi[x]=aggiungi[y]; aggiungi[y]=temp; for (var k=0;k