//============================================================================= // SRPG_AttackState.js 2024/05/09 //Copyright (C) 2024 Nino「」 // This software is released under the MIT License. // http://opensource.org/licenses/mit-license.php // ============================================================================ /*: * @plugindesc SRPG攻撃時ステート追加プラグイン * @target MZ * @author ニノ「」 * * @help SRPG戦闘の攻撃時に発動するパッシブスキルを追加するプラグインです。 *  スキルを所持させた上で、スキルのメモ欄に以下の記述を追加してください。 *   * xにはステートIDを入力してください。 *  このスキルを持つユニットが攻撃時にステートxを付与します。 * ステートの効果時間はステートの設定に依存します。 * 即座に解除したい場合は行動終了時 1ターンで解除されるようにしてください * * 更新履歴 * v1.0.0 2024/05/09 初版 * */ (function(_global) { const pluginName = "SRPG_AttackState"; var parameters = PluginManager.parameters(pluginName); //State付与トリガー //エネミーはウィンドウを起動しないのでこのトリガーだと使えない const _Game_System_setSrpgBattleWindowNeedRefresh = Game_System.prototype.setSrpgBattleWindowNeedRefresh; Game_System.prototype.setSrpgBattleWindowNeedRefresh = function(actionBattlerArray, targetBattlerArray) { $gameTemp.activateAttack(actionBattlerArray); _Game_System_setSrpgBattleWindowNeedRefresh.call(this, actionBattlerArray, targetBattlerArray); }; //State付与トリガー //エネミー用のトリガー const _Scene_Map_srpgInvokeAction = Scene_Map.prototype.srpgInvokeAutoUnitAction; Scene_Map.prototype.srpgInvokeAutoUnitAction = function() { // battlerArrayの設定 var actionArray = $gameSystem.EventToUnit($gameTemp.activeEvent().eventId()); $gameTemp.activateAttack(actionArray); _Scene_Map_srpgInvokeAction.call(this); } //State解除トリガー //戦闘しない場合はキャンセル時に解除する const _Scene_Map_selectPreviousSrpgBattleStart= Scene_Map.prototype.selectPreviousSrpgBattleStart; Scene_Map.prototype.selectPreviousSrpgBattleStart = function() { var activeBattlerArray = $gameSystem.EventToUnit($gameTemp.activeEvent().eventId()); $gameTemp.deactivateAttack(activeBattlerArray); _Scene_Map_selectPreviousSrpgBattleStart.call(this); } Game_Temp.prototype.activateAttack = function( actionBattlerArray,flgAttack =true) {//flgAttackは攻撃時のみtrue.それ以外はfalse//拡張性を考えて引数にしている var user = actionBattlerArray[1]; user.skills().forEach( function(item){//check all skills if (item.meta.SRPGAttackState) { //console.log("add state"); user.addState(Number(item.meta.SRPGAttackState)); } }); }; Game_Temp.prototype.deactivateAttack = function(actionBattlerArray) { var user = actionBattlerArray[1]; user.skills().forEach( function(item){//check all skills if (item.meta.SRPGAttackState) { //console.log("remove state"); user.removeState(Number(item.meta.SRPGAttackState)); } }); }; })(this);