//=============================================================================
// SRPG_MapForceAction.js
//=============================================================================
/*:
* @plugindesc v1.0 Adds <SRPG_MapForceAction> ScriptCall to SRPG
* @author dopan
*
* @param DisableText_SwitchID
* @desc SwitchID of DisableText_Switch for MapActionText
* @type switch
* @default 0
*
* @param UsedCE_ID
* @desc Variable ID of the Used-CommonEvent for MapActionText
* @type common_event
* @default 1
*
* @param UsedSkillVarID
* @desc Variable ID of the Used-Skill for MapActionText
* @type variable
* @default 1
*
*
*
* @help
*
* This Plugin helps to replicate the "force Action" Function for skills in: MapBattle"True" BattleMode.
* the Plugin ScriptCall will activate a "force Action" on Map without using "SV battleMode"
* Note: the Plugin is still experimental pls report any Bugs or Issues u might find.
*
* -> the "SkillAction" from this ScriptCall, wont work with a Skill that uses "minRange" or if,
* the Target is Outside of SkillRange from the User-position.
*
*
* => this plugin needs the Plugin SRPG_Mapbattle.js & SRPG_Core.js and works as Extension..
*
* Plugin Scriptcalls:
*---------------------
*-------------------------------------------------------------------------------------------------------
*-------------------------------------------------------------------------------------------------------
* - "this.isMapForceAction(userId, targetId, skillId, payCost);"
*-------------------------------------------------------------------------------------------------------
*-------------------------------------------------------------------------------------------------------
* Example : "this.isMapForceAction(9, 28, 1, true);"
*
* => this will forceAction, with "user"(event id 9 ),"target"(event id 28 ),using "Skill 1" with "PayCost"= true
*
* => there is an Example for this in the Updated-SRPG_demo
*
*
*-------------------------------------------------------------------------------------------------------
*-------------------------------------------------------------------------------------------------------
* - "this.isMapForceActionNote(userId, targetId, skillId, payCost); // THIS DOESNT WORK IN THIS PLUGIN VERSION
*-------------------------------------------------------------------------------------------------------
*-------------------------------------------------------------------------------------------------------
* Example : "this.isMapForceAction(9, 28, 1, false);"
*
* => this will add a second attack if used in a Custom Ex SkillNoteTag ,..
* .. with "user"(event id 9 ),"target"(event id 28 ),using "Skill 1" with "PayCost"= false
*
* => I advive to use the Following ScriptCall instead of using numbers on "user" and "target":
*
* var user = $gameTemp.activeEvent().eventId();
* var target = $gameTemp.targetEvent().eventId();
*
* this.isMapForceActionNote(user, target, 11, false); // Skill 11 as another example
*
* => However this can be used in different ways it will add the Action but without a battlestartAction,...
* ..so the action will happen as soon there is a battlestart.
*
* => there is an Example for this in the Updated-SRPG_demo ..
*-------------------------------------------------------------------------------------------------------
*-------------------------------------------------------------------------------------------------------
* The MapActionText Function is basicly A Plugin Common Event that get triggered at MapBattleStart
*
* => there is an Example for this in the Updated-SRPG_demo ..
*
*
* ============================================================================
* Terms of Use
* ============================================================================
* Free for any commercial or non-commercial project!
* (edits are allowed but pls dont claim it as yours without Credits.thx)
* ============================================================================
* Changelog
* ============================================================================
* Version 1.0:
* - first Release 01.09.2020 for SRPG (rpg mv)!
*/
(function() {
// Plugin param Variables:
var parameters = $plugins.filter(function (plugin) { return plugin.description.contains('SRPG_MapForceAction'); });
var parameters = PluginManager.parameters("SRPG_MapForceAction");
var _usedCE = Number(parameters['UsedCE_ID'] || 1);
var _usedSkill = Number(parameters['UsedSkillVarID'] || 1);
var _disableTextSwitch = Number(parameters['DisableText_SwitchID'] || 0);
var coreParameters = PluginManager.parameters('SRPG_core');
var _srpgTroopID = Number(coreParameters['srpgTroopID'] || 1);
var _mapForceUserNote = 1 || userNoteId;
var _mapForceTargetNote = 1 || targetNoteId;
var _mapForceSkillNote = 1 || skillNoteId;
var _mapForceUser = 1 || userId;
var _mapForceTarget = 1 || targetId;
var _mapForceSkill = 1 || skillId;
var _mapForcePayCost = 'true' || 'false' || payCost;
var _sceneMapProto = Scene_Map.prototype;
var mapbattleParameters = PluginManager.parameters('SRPG_MapBattle');
var _animDelay = Number(mapbattleParameters['SRPG_MapBattle'] || -1);
//-----------------------------------------------------------------------------------------
//Plugin Function:
// this.isMapForceAction(userId, targetId, skillId, payCost);
Game_Interpreter.prototype.isMapForceAction = function(userId, targetId, skillId, payCost) {
_mapForceUser = userId;
_mapForceTarget = targetId;
_mapForceSkill = skillId;
_mapForcePayCost = payCost;
if ($gameSystem.isSRPGMode()) {
var actionArray = $gameSystem.EventToUnit(_mapForceUser);
var targetArray = $gameSystem.EventToUnit(_mapForceTarget);
if ((!actionArray[1].isDead()) && (!targetArray[1].isDead())) {
// prepare Map Battle Actions, set user and target ect
$gameTemp.setActiveEvent($gameMap.event(_mapForceUser));
$gameTemp.setTargetEvent($gameMap.event(_mapForceTarget));
$gameTemp.setShouldPayCost(_mapForcePayCost);
$gameSystem.forceSRPGBattleMode('map');
actionArray[1].forceAction(_mapForceSkill, targetArray[1]);
$gameSystem.setSubBattlePhase('invoke_action');
this.playerMoveTo($gameTemp.targetEvent().posX(), $gameTemp.targetEvent().posY());
// get the data //
var user = actionArray[1];
var target = targetArray[1];
var action = user.action(0);
//var reaction = null; // = not needed yet in this Setup
//Command Setup for the Chain of Functions
var aniCom = 212; // Show Animation command
var scriptCom = 355; // Script command
var ind = this._indent; // interpreter branch depth
var p1 = ['this.isTest();']; // script happens at first // trigger Pre Action Phase
var p2 = ['this.isTestBlue();']; // trigger Skill Note And Skill Common Event
var p3 = ['this.isTestRed();']; // set Animations and trigger MapActionText for this Plugin
var p4 = ['this.isAnotherTest();']; // script happens at the end // trigger DMG effect ect
// Make command objects
var com1 = { code: scriptCom, indent: ind, parameters: p1 };
var com2 = { code: scriptCom, indent: ind, parameters: p2 };
var com3 = { code: scriptCom, indent: ind, parameters: p3 };
var com4 = { code: scriptCom, indent: ind, parameters: p4 };
// Insert commands at next position
this._list.splice(this._index + 1, 0, com1, com2, com3, com4);
// prepare action timing
user.setActionTiming(0);
if (user != target) target.setActionTiming(1);
// make free actions work
var addActionTimes = Number(action.item().meta.addActionTimes || 0);
if (addActionTimes > 0) {
user.SRPGActionTimesAdd(addActionTimes);
}
}
return true;
}
};
// "this.isTest();" // First Phase
Game_Interpreter.prototype.isTest = function() {
var actionArray = $gameSystem.EventToUnit(_mapForceUser);
var targetArray = $gameSystem.EventToUnit(_mapForceTarget);
var user = actionArray[1];
var target = targetArray[1];
var action = user.action(0);
// add pre battle phase
$gameMap.events().forEach(function(event) {
if (event.isType() === 'beforeBattle') {
if (event.pageIndex() >= 0) event.start();
$gameTemp.pushSrpgEventList(event);
}
});
};
// "this.isTestBlue();" // trigger Skill Note And Skill Common Event
Game_Interpreter.prototype.isTestBlue = function() {
var actionArray = $gameSystem.EventToUnit(_mapForceUser);
var targetArray = $gameSystem.EventToUnit(_mapForceTarget);
var user = actionArray[1];
var target = targetArray[1];
var action = user.action(0);
// trigger Skill Note And Skill Common Event
user.useItem(action.item());
action.applyGlobal();
};
// "this.isTestRed();" // set Animations and trigger MapActionText for this Plugin
Game_Interpreter.prototype.isTestRed = function() {
var actionArray = $gameSystem.EventToUnit(_mapForceUser);
var targetArray = $gameSystem.EventToUnit(_mapForceTarget);
var user = actionArray[1];
var target = targetArray[1];
var action = user.action(0);
// Command Setup for Animations
var aniCom = 212; // Show Animation command
var ind = this._indent; // interpreter branch depth
var ap1 = [_mapForceUser, action.item().castAnimation, true]; // params (char, anim, wait)
var ap2 = [_mapForceTarget, action.item().animationId, true]; // params (char, anim, wait)
// Make command objects
var acom1 = { code: aniCom, indent: ind, parameters: ap1 };
var acom2 = { code: aniCom, indent: ind, parameters: ap2 };
// Insert commands at next position
this._list.splice(this._index + 1, 0, acom1, acom2);
// add MapTextAction Common Event trigger
var commonEvent = $dataCommonEvents[_usedCE];
if (commonEvent) {
var eventId = this.isOnCurrentMap() ? this._eventId : 0;
this.setupChild(commonEvent.list, eventId);
}
};
// "this.isAnotherTest();" // Last Phase
Game_Interpreter.prototype.isAnotherTest = function() {
var actionArray = $gameSystem.EventToUnit(_mapForceUser);
var targetArray = $gameSystem.EventToUnit(_mapForceTarget);
var user = actionArray[1];
var target = targetArray[1];
var action = user.action(0);
// trigger Action Dmg and show results (dmg popUp)
action.apply(target);
user.srpgShowResults();
target.srpgShowResults();
};
// "this.srpgMapActionText();" // made to connect the Mapbattle plugin to this Function
var _srpgMapActionText = Scene_Map.prototype.srpgMapActionText;
Scene_Map.prototype.srpgMapActionText = function() {
for (_usedSkill = 1; _usedSkill <= $dataSkills.length; _usedSkill++) {
if (_usedSkill === $gameSystem.EventToUnit( $gameTemp.activeEvent().eventId() )[1]._actions[0]._item._itemId) {
$gameTemp.reserveCommonEvent(_usedCE);
}
}
};
//-----------------------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------------------
//--End:
})();