//============================================================================= // SRPG_AfterMove.js 2024/05/17 //Copyright (C) 2024 Nino「」 // This software is released under the MIT License. // http://opensource.org/licenses/mit-license.php // ============================================================================ /*: * @plugindesc 再移動スキル実装プラグイン * @author ニノ「」 * * @help 再移動スキルを実装するプラグインです。 * * スキルを所持させた上で、スキルのメモ欄に以下の記述を追加してください。 * * * @param SwitchID * @desc 再移動フラグを起動するスイッチIDです * @type switch * @default 2 */ (function(_global) { var pluginName = "SRPG_AfterMove"; var parameters = PluginManager.parameters(pluginName); var _srpgActorCommandList = parameters['srpgActorCommandList'] || 'talk,attack,skill,item,equip,wait'; var switchID = Number(parameters['SwitchID'] || 2); var coreParameters = PluginManager.parameters('SRPG_core_MZ'); var _defaultMove = Number(coreParameters['defaultMove'] || 4); var _srpgBestSearchRouteSize = Number(coreParameters['srpgBestSearchRouteSize'] || 25); var _textSrpgEquip = coreParameters['textSrpgEquip'] || '装備'; //var _SRPG_SceneMap_update = Scene_Map.prototype.update; //Scene_mapのupdateを上書き //勿論部分的にやりたかったんだけど出来ない!助けて!Todo:部分的に上書きする方法を調べる Scene_Map.prototype.update = function() { //ここまでツクールデフォルト Scene_Message.prototype.update.call(this); this.updateDestination(); this.updateMenuButton(); this.updateMapNameWindow(); this.updateMainMultiply(); if (this.isSceneChangeOk()) { this.updateScene(); } else if (SceneManager.isNextScene(Scene_Battle)) { this.updateEncounterEffect(); } this.updateWaitCount(); //ここからSRPG // SRPG戦闘中でなければ、以下の処理はスキップする if (!$gameSystem.isSRPGMode()) return; // プレイヤーの移動中は、以下の処理はスキップする if ($gameSystem.srpgWaitMoving() === true || $gameTemp.isAutoMoveDestinationValid() === true) return; // ターン終了コマンドの実行 if ($gameTemp.isTurnEndFlag() === true) { this.menuActorTurnEnd(); return; } // アクターコマンドからの装備変更の後処理 if ($gameTemp.isSrpgActorEquipFlag() === true) { this.srpgAfterActorEquip(); return; } // ウィンドウの開閉 this.srpgWindowOpenClose(); // イベント実行中は以下の処理をスキップする if ($gameMap.isEventRunning() === true) return; // 戦闘開始の処理 if (this._callSrpgBattle === true && this._mapSrpgBattleWindow.isClosed()) { this._callSrpgBattle = false; SceneManager.push(Scene_Battle); return; } // 戦闘終了後の処理 if ($gameSystem.isSubBattlePhase() === 'after_battle') { this.srpgBattlerDeadAfterBattle(); // ここから追加 // 再移動スキル持ちかチェック var actionArray = $gameSystem.EventToUnit($gameTemp.activeEvent().eventId()); var user = actionArray[1]; var flgMove = 0; if (actionArray[0] === 'actor') { console.log("actor"); user.skills().forEach(function(item) { if (item.meta.SRPGAfterMove) { //そのうち数値に対応する //flgMove = flgMove < item.meta.SRPGAfterMove ? item.meta.SRPGAfterMove : flgMove; flgMove = true; } }); //console.log("flgMove:"+flgMove); if (flgMove) { $gameSwitches.setValue(2, true); // 戦闘後移動のフラグを立てる var event = $gameMap.event($gameTemp.activeEvent().eventId()); $gameTemp.clearMoveTable(); $gameSystem.srpgMakeMoveTable(event); $gameTemp.setResetMoveList(true); $gameParty.pushSrpgBattleActors(actionArray[1]); $gameTemp.reserveOriginalPos($gameTemp.activeEvent().posX(), $gameTemp.activeEvent().posY()); $gameSystem.setSrpgActorCommandStatusWindowNeedRefresh(actionArray); $gameTemp.setAutoMoveDestinationValid(true); $gameTemp.setAutoMoveDestination(event.posX(), event.posY()); $gameSystem.setSubBattlePhase('actor_move'); // 戦闘後移動のフラグを立てる //フェーズをactor_moveに移動してリターン return; } } //ここまで追加 this.srpgAfterAction(); return; } this.srpgControlPhase(); // 戦闘フェーズの制御 }; // cancel movement or target, plus quick targeting var _updateCallMenu = Scene_Map.prototype.updateCallMenu; Scene_Map.prototype.updateCallMenu = function() { if ($gameSystem.isSRPGMode() && !$gameSystem.srpgWaitMoving()) { // return cursor when deselecting if (($gameSystem.isSubBattlePhase() === 'actor_move' || $gameSystem.isSubBattlePhase() === 'actor_target' || $gameSystem.isSubBattlePhase() === 'actor_targetArea') && this.isMenuCalled()) { var event = $gameTemp.activeEvent(); $gamePlayer.slideTo(event.posX(), event.posY()); console.log("returning cursor to actor"); } // page through valid selections if ($gameSystem.isSubBattlePhase() === 'actor_move') { if ((Input.isTriggered('cancel') || TouchInput.isCancelled())&& $gameSwitches.value(switchID)) { SoundManager.playBuzzer() return; } } _updateCallMenu.call(this); } } Game_BattlerBase.prototype.canAttack = function() { return this.canUse($dataSkills[this.attackSkillId()]) && !$gameSwitches.value(switchID); }; Window_ActorCommand.prototype.addSkillCommands = function() { const skillTypes = this._actor.skillTypes(); for (const stypeId of skillTypes) { const name = $dataSystem.skillTypes[stypeId]; this.addCommand(name, "skill", true && !$gameSwitches.value(switchID), stypeId); } }; Window_ActorCommand.prototype.addItemCommand = function() { this.addCommand(TextManager.item, "item",!$gameSwitches.value(switchID)); }; Window_ActorCommand.prototype.addEquipCommand = function() { this.addCommand(_textSrpgEquip, 'equip', this._actor.canSrpgEquip()&& !$gameSwitches.value(switchID)); }; const _Scene_map_commandWait = Scene_Map.prototype.commandWait; // アクターコマンド・待機 Scene_Map.prototype.commandWait = function() { $gameSwitches.setValue(switchID, false); _Scene_map_commandWait.call(this); }; var _Game_Actor_SRPGMove= Game_Actor.prototype.srpgMove; Game_Actor.prototype.srpgMove = function() { //再移動フラグが立っているなら移動力固定 if ($gameSwitches.value(switchID)){ var actionArray = $gameSystem.EventToUnit($gameTemp.activeEvent().eventId()); var user = actionArray[1]; var flgMove = 0; if (actionArray[0] === 'actor') { console.log("actor"); user.skills().forEach(function(item) { if (item.meta.SRPGAfterMove) { //そのうち数値に対応する flgMove = flgMove < item.meta.SRPGAfterMove ? item.meta.SRPGAfterMove : flgMove; //flgMove = true; } }); } return flgMove;//面倒なので一旦固定 } return _Game_Actor_SRPGMove.call(this); }; })(this);