RMMV Using "wait" in a Plugin (help request)

Status
Not open for further replies.

Dopan

Veteran
Veteran
Joined
Mar 27, 2020
Messages
328
Reaction score
92
First Language
German
Primarily Uses
RMMV
I want to build a plugin and i got a Problem:

if i use following JS code as Scriptcall in an Event that works just fine:

Code:
this._character = $gameMap.event(9);
$gameMap.event(9).requestAnimation(120); this.setWaitMode('animation');

// ..than another Scriptcall in the same event,
// in order to see if the "wait" Part from the first Scriptcall worked..

this._character = $gameMap.event(28);
$gameMap.event(28).requestAnimation(120); this.setWaitMode('animation');
-that will play Animation_120 on Event_9 and as soon the first Animation has finished, the Animation_120 will be played on Event_28.

But if i do that in a Mini Plugin like this:
Code:
(function() {

//Plugin Function:
       
        // Scriptcall = "this.isTest();"
        Game_Interpreter.prototype.isTest = function() {
       
            this._character = $gameMap.event(9);
            $gameMap.event(9).requestAnimation(120); this.setWaitMode('animation');
           
            this._character = $gameMap.event(28);
            $gameMap.event(28).requestAnimation(120); this.setWaitMode('animation');
        };    
       
//--End:

})();
than both Animations will be played at the same time,so the "wait" part doesnt work here..atleast not so easy^^
(No Error in console F8)
As far i understood it from googling this forum,a loop or a repeating Prozess is needed to make this work.(i got no idea how to do this..)
Can anyone explain me with this Mini plugin Example how this can be done?
(the Plugin which i want to build is more complex ,but i think as soon i understood how to solve this part,i can handle the rest alone ,and i wanted to keep the Example as simple as possible)
Thanks in advance!
 
Last edited:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,918
Reaction score
7,450
First Language
German
Primarily Uses
RMMV
The problem is that you aren't waiting, and that wait is not a command.
Your function sets a wait-mode, but the wait itself is not in your plugin (it can't be), so of course both animations are proceeding at the same time.

In a simplyfied way it can be described as following:
The wait is handled by the main game loop. Everything that has to wait will be registered as a timed object on the game loop until that time is up and it is triggered one loop.
Since you register both animations at the same time, they will work parallel to each other.

To have them appear one after another you'll need to wait with the second command until you get a return that the first command has completed its animation cycle, and that requires a defferent handling, including an object to be registered in the game loop that doesn't do anything itself but just calls a function with your second animation function after the time for the first one is up.
(there are probably other ways to do this as well, but I can't give you no details because I never did something like this myself)
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,929
Reaction score
1,372
First Language
EN
Primarily Uses
RMMZ
One solution would be to add the animations to the event command queue in the appropriate format, e.g.
JavaScript:
var c = 212;              // Show Animation command
var i = this._indent;     // interpreter branch depth
var p1 = [9, 120, true];  // params (char, anim, wait)
var p2 = [28, 120, true]; // params again
// Make command objects
var com1 = { code: c, indent: i, parameters: p1 };
var com2 = { code: c, indent: i, parameters: p2 };
// Insert commands at next position
this._list.splice(this._index + 1, 0, com1, com2);
This just sticks a couple of extra Show Animation commands into the interpreter at the current position, then leaves the interpreter to handle those commands as usual. :)
 

Dopan

Veteran
Veteran
Joined
Mar 27, 2020
Messages
328
Reaction score
92
First Language
German
Primarily Uses
RMMV
first of all thanks for the reply! (@caethyril @Andar)
I dont understand everything,but atleast i got something to work with^^

@Andar
->
thx for the Info about why this doesnt work,even if i dont understand everything.
(i got very low JS knowlegde and can just read some simple parts in order to replicate those things which i can understand)

@caethyril
->
i have to admit ,i dont understand this solution.But i will try to figure it out..
I never saw " var i = this._indent; " berfore^^,
aswell as "this._list.splice(this._index + 1, 0, com1, com2);"
And why is "var c = 212; " , what is the 212 ?
-> i dont know how to add this solution into the mini Plugin Example,..
edit
Code:
        // Scriptcall = "this.isTest();"
        Game_Interpreter.prototype.isTest = function() {
            var c = 212;              // Show Animation command
            var i = this._indent;     // interpreter branch depth
            var p1 = [9, 120, true];  // params (char, anim, wait)
            var p2 = [28, 120, true]; // params again
            // Make command objects
            var com1 = { code: c, indent: i, parameters: p1 };
            var com2 = { code: c, indent: i, parameters: p2 };
            // Insert commands at next position
            this._list.splice(this._index + 1, 0, com1, com2);


        };
this works ! i dont understand it, but i can work with that, and try to understand it later^^ Thank you!

Any other solutions or explanations are very welcome,sry that i dont understand everything for me its like having to decrypt 2 languages ,Englisch and JS.
(even if Englisch is the easy part ^^)
Most
successes i had with JS are made by "trial and error till it works" ^^
 
Last edited:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,918
Reaction score
7,450
First Language
German
Primarily Uses
RMMV
even if i dont understand everything.
OK, perhaps a different example might help.

Assume you are in school and two different teachers give you two different homeworks for later.
The functions you're using is not you doing homework, it is you being told to do homework.
In both cases the homework happens at home and not in school where the orders are given, and it depends on what is home to decide when and where the homework really happens.

And in this specific case someone helps you with the second homework because the teacher hasn't told you that the first homework needs to be completed before the helper can start with the second homework, so both homeworks are done at the same time.
 

Dopan

Veteran
Veteran
Joined
Mar 27, 2020
Messages
328
Reaction score
92
First Language
German
Primarily Uses
RMMV
ok i used the solution from caethyril and tried to add more Code to the mini-plugin..

-the next Example:
Code:
        // "this.isTest();" (first solution)
        Game_Interpreter.prototype.isTest = function() {
            var c = 212;              // Show Animation command
            var i = this._indent;     // interpreter branch depth
            var p1 = [9, 120, true];  // params (char, anim, wait)
            var p2 = [28, 120, true]; // params again
            var p3 = [30, 120, true]; // params again  // added for second example
            // Make command objects
            var com1 = { code: c, indent: i, parameters: p1 };
            var com2 = { code: c, indent: i, parameters: p2 };
            var com3 = { code: c, indent: i, parameters: p3 }; // added for second example
            // Insert commands at next position
            this._list.splice(this._index + 1, 0, com1, com2, com3); // ", com3"added for second example
//------- Second Example starts here:
            // try to add more Code // additional animation as example
            this.isAnotherTest(); // happens first and parrallel

            // try to add more Code // additional animation as example
            this._character = $gameMap.event(3);
            $gameMap.event(3).requestAnimation(120);  this.setWaitMode('animation'); // happens first and parrallel

        };
   
        // "this.isAnotherTest();"
        Game_Interpreter.prototype.isAnotherTest = function() {
            this._character = $gameMap.event(28);
            $gameMap.event(28).requestAnimation(120);  this.setWaitMode('animation');

        };
this will play 2 additional Animations ,and they will both happen at the same time ,but before the Main solution from caethyril happens. The Code from caethyril will even wait for those 2 parrallel Animations to finish before starting.
(that is really nice because it shows another solution..)
Thats fine so far, atleast i know how to add stuff that has to happen before the "first solution",but i would also like to add Code that has to happen after the Animations are played.
Has anyone an Idea how to add Code into this Example-Plugin that happens after the Main solution from caethyril is finished?
i would like to just use the First Scriptcall("this.isTest();") and let it trigger the whole chain of functions or JS code ,without using another Scriptcall in addition if thats possible.
(The other code which i want to add is not "Playing-Animations" ,so i cant just extend the first solution, like i did it with "com3" in the Second Example)
 
Last edited:

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,929
Reaction score
1,372
First Language
EN
Primarily Uses
RMMZ
Yes, this is quite advanced; if you don't have much experience with JavaScript or RMMV's engine then I'm not surprised that you don't understand! But I'll try to explain some things anyway~

Event commands, like Show Animation, are not actually JavaScript. When an event starts, all its commands are put into an "interpreter", which is a part of the RPG Maker engine that turns commands into JavaScript. An event interpreter has a complex structure to determine when it should update and when it should just wait for the next frame. Interpreters process each command within a single frame, so if you do several things in a single Script command, those things will all happen that frame. (There are ways around this, e.g. setTimeout, but I would strongly recommend sticking with the native engine structure where possible. :kaoslp:)

Now, the editor is nice and easy to use! :kaopride: It takes those inputs that are easy for people to understand and converts them into values that are easier for the engine to understand. For example, a command that looks like this in the editor:
Code:
◆Show Animation:Player, Hit Physical (Wait)
...might look like this in the map file:
Code:
{"code":212,"indent":0,"parameters":[-1,1,true]}
Each event command has these values:
  • Code: this decides what the command does. Each command has a unique code to identify it. The command code for Show Animation happens to be 212.

  • Indent: this is used for things like the Conditional Branch ("if statement") and Loop commands. You can see the commands indented in the editor, e.g.
    Code:
    ◆If:Introduction is OFF
      ◆Text:None, Window, Bottom
      :    :This command is indented
      :    :because it's inside the branch.
      ◆
    :End
    The engine uses indent to decide what commands to skip, e.g. if the "Introduction" switch in the above example is turned on, the interpreter will know to skip the Show Text command because it is indented.

  • Parameters: these are the command settings, e.g. "character", "animation", and "wait for completion". Different commands have different settings.
For more details, you can check out either:
  • The code for Game_Interpreter (rpg_objects.js). Command names are commented with their English names, e.g. try searching for Show Text.

  • The project map files, e.g. data/Map001.json. These are not particularly easy to read, but it's possible to set up a map with an event featuring the commands you're interested in, save your project, then check the map data file.

For your specific questions:
  1. var i = this._indent;
    This says "store the interpreter's current indent in a new variable, i". The new Show Animation commands use this indent value. See above for a brief explanation of what the indent is for.

  2. this._list.splice(this._index + 1, 0, com1, com2);
    This says "at position this._index + 1 of this interpreter's command list: remove 0 values, then add com1 and com2". splice is a native JavaScript method for adding/removing values from arrays. You can find more details here:
    Interpreters keep track of which command they are running using an "index". When the current command is done, the index gets increased so that the next time the interpreter runs, it will run the next command in its list. That's why we insert at this._index + 1. :kaophew:

  3. (The other code which i want to add is not "Playing-Animations" ,so i cant just extend the first solution, like i did it with "com3" in the Second Example)
    You could add a Script command to the interpreter after those Show Animation commands. The Script command has code = 355 and a single parameter: the text to evaluate. Example:
    JavaScript:
    var i = this._indent;     // interpreter branch depth
    var p1 = [9, 120, true];  // params (char, anim, wait)
    var p2 = [28, 120, true];
    var p3 = ['this.isAnotherTest();'];
    // Make command objects
    var anim1  = { code: 212, indent: i, parameters: p1 };
    var anim2  = { code: 212, indent: i, parameters: p2 };
    var script = { code: 355, indent: i, parameters: p3 };
    // Insert commands at next position
    this._list.splice(this._index + 1, 0, anim1, anim2, script);
 
Last edited:

Dopan

Veteran
Veteran
Joined
Mar 27, 2020
Messages
328
Reaction score
92
First Language
German
Primarily Uses
RMMV
Yes, this is quite advanced; if you don't have much experience with JavaScript or RMMV's engine then I'm not surprised that you don't understand! But I'll try to explain some things anyway~

Event commands, like Show Animation, are not actually JavaScript. When an event starts, all its commands are put into an "interpreter", which is a part of the RPG Maker engine that turns commands into JavaScript. An event interpreter has a complex structure to determine when it should update and when it should just wait for the next frame. Interpreters process each command within a single frame, so if you do several things in a single Script command, those things will all happen that frame. (There are ways around this, e.g. setTimeout, but I would strongly recommend sticking with the native engine structure where possible. :kaoslp:)

Now, the editor is nice and easy to use! :kaopride: It takes those inputs that are easy for people to understand and converts them into values that are easier for the engine to understand. For example, a command that looks like this in the editor:
Code:
◆Show Animation:Player, Hit Physical (Wait)
...might look like this in the map file:
Code:
{"code":212,"indent":0,"parameters":[-1,1,true]}
Each event command has these values:
  • Code: this decides what the command does. Each command has a unique code to identify it. The command code for Show Animation happens to be 212.

  • Indent: this is used for things like the Conditional Branch ("if statement") and Loop commands. You can see the commands indented in the editor, e.g.
    Code:
    ◆If:Introduction is OFF
    ◆Text:None, Window, Bottom
    : :This command is indented
    : :because it's inside the branch.
    ◆
    :End
    The engine uses indent to decide what commands to skip, e.g. if the "Introduction" switch in the above example is turned on, the interpreter will know to skip the Show Text command because it is indented.

  • Parameters: these are the command settings, e.g. "character", "animation", and "wait for completion". Different commands have different settings.
For more details, you can check out either:
  • The code for Game_Interpreter (rpg_objects.js). Command names are commented with their English names, e.g. try searching for Show Text.

  • The project map files, e.g. data/Map001.json. These are not particularly easy to read, but it's possible to set up a map with an event featuring the commands you're interested in, save your project, then check the map data file.

For your specific questions:
  1. var i = this._indent;
    This says "store the interpreter's current indent in a new variable, i". The new Show Animation commands use this indent value. See above for a brief explanation of what the indent is for.

  2. this._list.splice(this._index + 1, 0, com1, com2);
    This says "at position this._index + 1 of this interpreter's command list: remove 0 values, then add com1 and com2". splice is a native JavaScript method for adding/removing values from arrays. You can find more details here:
    Interpreters keep track of which command they are running using an "index". When the current command is done, the index gets increased so that the next time the interpreter runs, it will run the next command in its list. That's why we insert at this._index + 1. :kaophew:


  3. You could add a Script command to the event after those Show Animation commands. The Script command has code = 355 and a single parameter: the text to evaluate. Example:
    JavaScript:
    var i = this._indent;     // interpreter branch depth
    var p1 = [9, 120, true]; // params (char, anim, wait)
    var p2 = [28, 120, true];
    var p3 = ['this.isAnotherTest();'];
    // Make command objects
    var anim1 = { code: 212, indent: i, parameters: p1 };
    var anim2 = { code: 212, indent: i, parameters: p2 };
    var script = { code: 355, indent: i, parameters: p3 };
    // Insert commands at next position
    this._list.splice(this._index + 1, 0, anim1, anim2, script);
Wow ! sometimes i fear that some things which i show in the Updated-SRPG_Demo are to complicated to understand for other people who are not familiar with it.
But this shows me again that i still got a lot to learn and most things i can do at the moment are "just a little step"..
I got much respect for your JS knowledge and i am very thankfull for your help!
I think this("example script V2"-spoiler info) will solve all my Problems (atleast with the Plugin which i am working on).
But i will leave this thread open just incase i get other unexpected Problems till i finished my plugin!

-> And these Infos might be very helpfull for other people as well, so thank you also for the extra Clarifications (nice tutorial).

(probably i will have to "double post" in order to "refresh" this.. if i get another problem with this.. or if i wanna show the Final solution after i finished my plugin.. sry in advance!)
(i will report this Thread to be closed as soon i finished my plugin)
 
Last edited:

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,929
Reaction score
1,372
First Language
EN
Primarily Uses
RMMZ
You're welcome! :)

RPG Maker's event interpreters are just a system. That SRPG plugin is a system, too, and you know more about that than I do. Everyone has stuff to learn~ :kaothx:

(Also, now you won't have to double-post if you run into another problem. ;))
 

Dopan

Veteran
Veteran
Joined
Mar 27, 2020
Messages
328
Reaction score
92
First Language
German
Primarily Uses
RMMV
well i got some more Questions.. but first i will give more informations..
About SRPG_MapForceAction.js : (made to Immitate the Force Action function for mapBattles)
The Plugin i want to build here is a new Version of a plugin which is allready in the Updated-SRPG_Demo.The Version in the Demo is mostly a "half edited clone of SRPG_Mapbattle.js."
(SRPG_Mapbattle.js Info in Spoiler)
JavaScript:
//-----------------------------------------------------------------------------
// copyright 2020 Doktor_Q all rights reserved.
// Released under the MIT license.
// http://opensource.org/licenses/mit-license.php
//=============================================================================

/*:
* @plugindesc SRPG show skills on the map (v1.0)
* @author Dr. Q (edited Version.. edited by dopan)
*
* @param Use Map Battle
* @desc Default Map Battle usage
* @type select
* @option Always
* @value 2
* @option When Switch is On
* @value 1
* @option Never
* @value 0
* @default 2
*
* @param Map Battle Switch
* @parent Use Map Battle
* @desc Switch that activates map battle
* @type switch
* @default 0
*
*
* @param Animation Delay
* @desc Frames between animation start and skill effect
* Set to -1 to wait for all animations to finish
* @type number
* @min -1
* @default 25
* -dopan edit start-
* @param ChangeAniDelaySwitch_ID
* @desc Switch ID:0 or Switch "false" ->*Enable*animationDelay      Switch "true" ->delay=30。
* @type switch
* @default 0
*
* @param ChangeAniDelayVarID
* @desc variable ID of ChangedDelay.Default if disabled is 30Frames. Set VarID to 0 to disable.
* @type variable
* @default 0
*
*
* -dopan edit end-
*
* @help
* Runs SRPG combat on the map. May be incompatible with other battle system
* plugins.
*
* In lunatic mode tags, script calls, or damage formulas, .event()
* gets the event associated with that unit on the map, if you want
* to manipulate it (movement, change appearance, etc).
*
* /!\ IMPORTANT /!\
* Some plugins and mechanics can work differently between the Map Battle and
* normal battles, especially if you use action sequences. Anything that can be
* used in both, such as counter attacks, should be thoroughly tested to ensure
* its works the same.
* In lunatic mode tags or formulas, $gameSystem.useMapBattle() returns true if
* the skill is being run on the map, instead of in the battle scene.
*
*
*
* New skill / item tags:
* <mapBattle:true>     always uses this skill on the map
* <mapBattle:false>    never uses this skill on the map
* <targetAnimation:X>  shows animation X on the target cell
* <animationDelay:X>   waits X frames between the animation and effect
*                      overrides the default settings
* <animationDelay:-1>  waits for animations to finish before the effect
*
* <directionalAnimation:X> shows an animation on the target cell based on
* the direction the user is facing, following the usual direction order.
* For example, <directionalAnimation:20> will show the following:
* Animation 20 when facing down
* Animation 21 when facing left
* Animation 22 when facing right
* Animation 23 when facing up
*
* Known incompatible plugins with map battle:
* - SRPG_AgiAttackPlus
* - SRPG_UncounterableAttack (see below)
*
* MapBattle mode is incompatible with SRPG_UncounterableAttack, so the
* <srpgUncounterable> tag has been directly integrated. Skills and items
* with this tag will not trigger an SRPG counter attack during map battles.
*/

(function(){
    var parameters = PluginManager.parameters('SRPG_MapBattle');
    var _useMapBattle = Number(parameters['Use Map Battle'] || 2);
    var _mapBattleSwitch = Number(parameters['Map Battle Switch'] || 0);
    var _animDelay = Number(parameters['Animation Delay'] || -1);

    var coreParameters = PluginManager.parameters('SRPG_core');
    var _srpgTroopID = Number(coreParameters['srpgTroopID'] || 1);
    var _rewardSe = coreParameters['rewardSound'] || 'Item3';

        var _changeAnimationDelaySwitchID = Number(parameters['ChangeAniDelaySwitch_ID'] || 0); //edit dopan
        var _changeAniDelayVarID = Number(parameters['ChangeAniDelayVarID'] || 0); //edit dopan

//====================================================================
// utility functions for finding unit events
//====================================================================

    // get the event for a general battler
    Game_BattlerBase.prototype.event = function() {
        var currentBattler = this;
        var eventId = 0;
        $gameSystem._EventToUnit.forEach(function (battleArray, index) {
            if (battleArray && battleArray[1] === currentBattler) eventId = index;
        });
        return $gameMap.event(eventId);
    };

    // get the event for an actor specifically
    Game_Actor.prototype.event = function() {
        var currentActor = this.actorId();
        var eventId = 0;
        $gameSystem._EventToUnit.forEach(function (battleArray, index) {
            if (battleArray && battleArray[1] === currentActor) eventId = index;
        });
        return $gameMap.event(eventId);
    };

//====================================================================
// process attacks directly on the map scene
//====================================================================

    // force a specific style of battle for one exchange
    Game_System.prototype.forceSRPGBattleMode = function(type) {
        this._battleMode = type;
    };
    Game_System.prototype.clearSRPGBattleMode = function() {
        this._battleMode = null;
    };

    // control whether to use map battle or not
    Game_System.prototype.useMapBattle = function() {
        // forced mode
        if (this._battleMode === 'map') return true;
        else if (this._battleMode === 'normal') return false;
        // system defaults
        else if (_useMapBattle == 2) return true;
        else if (_useMapBattle == 0) return false;
        else return (_mapBattleSwitch > 0 && $gameSwitches.value(_mapBattleSwitch));
    };

    // set up the map attacks
    var _srpgBattleStart = Scene_Map.prototype.srpgBattleStart;
    Scene_Map.prototype.srpgBattleStart = function(userArray, targetArray) {
        // get the data
        var user = userArray[1];
        var target = targetArray[1];
        var action = user.action(0);
        var reaction = null;

        // check if we're using map battle on this skill
        if (action && action.item()) {
            var mapBattleTag = action.item().meta.mapBattle;
            if (mapBattleTag == 'true') $gameSystem.forceSRPGBattleMode('map');
            else if (mapBattleTag == 'false') $gameSystem.forceSRPGBattleMode('normal');
        }
        if (!$gameSystem.useMapBattle()) {
            _srpgBattleStart.call(this, userArray, targetArray);
            return;
        }

        // prepare action timing
        user.setActionTiming(0);
        if (user != target) target.setActionTiming(1);

        // pre-skill setup
        $gameSystem.clearSrpgStatusWindowNeedRefresh();
        $gameSystem.clearSrpgBattleWindowNeedRefresh();

        // make free actions work
        var addActionTimes = Number(action.item().meta.addActionTimes || 0);
        if (addActionTimes > 0) {
            user.SRPGActionTimesAdd(addActionTimes);
        }

        this.preBattleSetDirection();
        this.eventBeforeBattle();
        this.srpgMapActionText(); // EDIT dopan (for mapActionText Usage)

        // set up the troop and the battle party
        $gameTroop.clearSrpgBattleEnemys();
        $gameTroop.clear();
        $gameParty.clearSrpgBattleActors();
        if (userArray[0] === 'enemy') $gameTroop.pushSrpgBattleEnemys(user);
        else $gameParty.pushSrpgBattleActors(user);
        if (targetArray[0] === 'enemy') $gameTroop.pushSrpgBattleEnemys(target);
        else $gameParty.pushSrpgBattleActors(target);
        BattleManager.setup(_srpgTroopID, false, true);
        action.setSubject(user);

        // queue the action
        this.srpgAddMapSkill(action, user, target);

        // queue up counterattack
        if (userArray[0] !== targetArray[0] && target.canMove() && !action.item().meta.srpgUncounterable) {
            target.srpgMakeNewActions();
            reaction = target.action(0);
            reaction.setSubject(target);
            reaction.setAttack();
            var actFirst = (reaction.speed() > action.speed());
            this.srpgAddMapSkill(reaction, target, user, actFirst);
        }
    };

    // work through the queue of attacks
    var _SRPG_SceneMap_update = Scene_Map.prototype.update;
    Scene_Map.prototype.update = function() {
        _SRPG_SceneMap_update.call(this);

        // there are definitely no map skills in play
        if (!$gameSystem.isSRPGMode() || $gameSystem.isSubBattlePhase() !== 'invoke_action' ||
        !$gameSystem.useMapBattle()) {
            return;
        }

        // update map skills
        if (!this.waitingForSkill() && !this._srpgBattleResultWindow.isChangeExp()) {
            // process skills
            while (this.srpgHasMapSkills() && !this.waitingForSkill()) {
                this.srpgUpdateMapSkill();
            }

            // process the battle results window
            if (!this.srpgHasMapSkills() && !this._srpgBattleResultWindow.isOpen() &&
            !this._srpgBattleResultWindow.isOpening()) {
                var showResults = this.processSrpgVictory();
                if (!showResults) $gameSystem.setSubBattlePhase('after_battle');
            } else if (this._srpgBattleResultWindow.isOpen() &&
            (Input.isPressed('ok') || Input.isPressed('cancel') ||
            TouchInput.isPressed() || TouchInput.isCancelled())) {
                this._srpgBattleResultWindow.close();
                $gameSystem.setSubBattlePhase('after_battle');
            }
        } else {
            // time-based waiting
            this.updateSkillWait();
        }
    };

    // reset battle mode between skills
    var _srpgAfterAction = Scene_Map.prototype.srpgAfterAction;
    Scene_Map.prototype.srpgAfterAction = function() {
        $gameSystem.clearSRPGBattleMode();
        _srpgAfterAction.call(this);
    };

    // time-based skill wait!
    Scene_Map.prototype.setSkillWait = function(time) {
        this._skillWait = time;
    };
    Scene_Map.prototype.updateSkillWait = function() {
        if (this._skillWait > 0) this._skillWait--;
    };
    Scene_Map.prototype.resetSkillWait = function() {
        this._skillWait = undefined;
    };
    Scene_Map.prototype.skillWait = function() {
        return this._skillWait || 0;
    };
    Scene_Map.prototype.skillAnimWait = function() {
        return (this._skillWait == undefined);
    };

    // check if we're still waiting for a skill to finish
    Scene_Map.prototype.waitingForSkill = function() {
        if ($gameTemp.isCommonEventReserved()) return true;
        if ($gamePlayer.isAnimationPlaying() || !$gamePlayer.isStopping() ||
        $gameTemp.isAutoMoveDestinationValid()) return true;

        if (this.skillAnimWait()) {
            var active = $gameTemp.activeEvent();
            if (active.isAnimationPlaying() || !active.isStopping()) return true;

            var target = $gameTemp.targetEvent();
            if (!target) return false;
            if (target.isAnimationPlaying() || !target.isStopping()) return true;
        } else if (this.skillWait() > 0) return true;

        return false;
    };

    // no moving during a skill!
    var _Game_Player_canMove = Game_Player.prototype.canMove;
    Game_Player.prototype.canMove = function() {
        if ($gameSystem.isSRPGMode() && $gameSystem.isSubBattlePhase() === 'invoke_action') {
            return false;
        }
        return _Game_Player_canMove.call(this);
    };

    // no pausing, either!
    var _updateCallMenu = Scene_Map.prototype.updateCallMenu;
    Scene_Map.prototype.updateCallMenu = function() {
        if ($gameSystem.isSRPGMode() && $gameSystem.isSubBattlePhase() === 'invoke_action') {
            this.menuCalling = false;
            return;
        }
        _updateCallMenu.call(this);
    };

//====================================================================
// queue of skills being executed on the map
//====================================================================

    // queue up a skill for the on-map battle
    Scene_Map.prototype.srpgAddMapSkill = function(action, user, target, addToFront) {
        this._srpgSkillList = this._srpgSkillList || [];
        var data = {
            action: action,
            user: user,
            target: target,
            phase: 'start',
            count: action.numRepeats() + action.item()._srpgRepeats,
        };
        if (addToFront) this._srpgSkillList.unshift(data);
        else this._srpgSkillList.push(data);
    };

    // build the physical counter attack
    Scene_Map.prototype.srpgAddCounterAttack = function(user, target) {
        target.srpgMakeNewActions();
        target.action(0).setSubject(target);
        target.action(0).setAttack();
        this.srpgAddMapSkill(target.action(0), target, user, true);
        this._srpgSkillList[0].counter = true;
    };

    // check how many skills are left on the queue
    Scene_Map.prototype.srpgHasMapSkills = function() {
        this._srpgSkillList = this._srpgSkillList || [];
        return this._srpgSkillList.length;
    };

    // clear all enqueued skills
    Scene_Map.prototype.srpgClearMapSkills = function() {
        this._srpgSkillList = this._srpgSkillList || [];
        this._srpgSkillList.clear();
    };

    // get the next skill off the queue and invoke it
    Scene_Map.prototype.srpgUpdateMapSkill = function() {
        this._srpgSkillList = this._srpgSkillList || [];
        var data = this._srpgSkillList.shift();
        if (!data) return false;
        return this.srpgInvokeMapSkill(data);
    };

    // invoke skill effects
    Scene_Map.prototype.srpgInvokeMapSkill = function(data) {
        var action = data.action;
        var user = data.user;
        var target = data.target;

        switch (data.phase) {
            // skill cost and casting animations
            case 'start':
                if (!user.canMove() || !user.canUse(action.item())) {
                    data.phase = 'cancel';
                    this._srpgSkillList.unshift(data);
                    break;
                }
                user.useItem(action.item());
                if (!$gameTemp.isFirstAction || $gameTemp.isFirstAction()) {
                    var castAnim = false;
                    // cast animation, is a skill, isn't an attack or guard
                    if (action.item().castAnimation && action.isSkill() && !action.isAttack() && !action.isGuard()) {
                        user.event().requestAnimation(action.item().castAnimation);
                        castAnim = true;
                    }
                    // target animation
                    if (action.item().meta.targetAnimation) {
                        $gamePlayer.requestAnimation(Number(action.item().meta.targetAnimation));
                        castAnim = true;
                    }
                    // directional target animation
                    if (action.item().meta.directionalAnimation) {
                        var dir = user.event().direction()/2 - 1;
                        $gamePlayer.requestAnimation(dir + Number(action.item().meta.directionalAnimation));
                        castAnim = true;
                    }
                }
                // check for reflection
                if (user != target && Math.random() < action.itemMrf(target)) {
                    data.phase = 'reflect';
                } else {
                    data.phase = 'animation';
                }
                this._srpgSkillList.unshift(data);
                break;

            // reflected magic
            case 'reflect':
                target.performReflection();
                if (target.reflectAnimationId) {
                    target.event().requestAnimation(target.reflectAnimationId());
                }
                data.target = user;
                data.phase = 'animation';
                this._srpgSkillList.unshift(data);
                break;

            // show skill animation
            case 'animation':
                var animation = action.item().animationId;
                if (animation < 0) animation = (user.isActor() ? user.attackAnimationId1() : user.attackAnimationId());
                target.event().requestAnimation(animation);
                data.phase = 'effect';
                this._srpgSkillList.unshift(data);
                // time-based delay /dopan edit = adds variable & switch to AniDelay
                var delay = _animDelay;
                if (action.item().meta.animationDelay) delay = Number(action.item().meta.animationDelay);
                if (delay >= 0) {                 //dopan edit starts with " {"
                                    if (_changeAnimationDelaySwitchID == 0 || ($gameSwitches.value(_changeAnimationDelaySwitchID)==false)) {
                                        this.setSkillWait(delay); //dopan edit:Default is this line instead of edit start = " {"
                                    }
                                    if ($gameSwitches.value(_changeAnimationDelaySwitchID)==true) {
                                        if (_changeAniDelayVarID >= 1) {
                                            delay = ($gameVariables.value(_changeAniDelayVarID));                                                
                                            this.setSkillWait(delay);
                                        }
                                        if (_changeAniDelayVarID == 0) {
                                            delay = 30;
                                            this.setSkillWait(delay);
                                        }
                                    }
                                }                                 //dopan edit end
                       break;

            // apply skill effects
            case 'effect':
                // skill effect repeats
                data.count--;
                if (data.count > 0) {
                    data.phase = 'animation';
                } else {
                    data.phase = 'global';
                }
                this._srpgSkillList.unshift(data);
                this.resetSkillWait();

                // apply effects or trigger a counter
                if (!data.counter && user != target && Math.random() < action.itemCnt(target)) {
                    target.performCounter();
                    this.srpgAddCounterAttack(user, target);
                } else {
                    action.apply(target);
                }
                break;

            // run the common events and such
            case 'global':
                action.applyGlobal();
                data.phase = 'end';
                this._srpgSkillList.unshift(data);
                break;

            // clean up at the end
            case 'cancel':
            case 'end':
                user.setLastTarget(target);
                user.removeCurrentAction();
                user.onAllActionsEnd();
                break;
        }

        // Show the results
        user.srpgShowResults();
        target.srpgShowResults();
        return true;
    };

    // show the results of the action
    Game_BattlerBase.prototype.srpgShowResults = function() {
        var result = this.result();
        // ways to hit
        if (result.i****()) {
            if (result.hpDamage > 0 && !result.drain) this.performDamage();
            if (result.hpDamage < 0 || result.mpDamage < 0 || result.tpDamage < 0) this.performRecovery();
            var target = this;
            result.addedStateObjects().forEach(function(state) {
                if (state.id === target.deathStateId()) target.performCollapse();
            });
        }
        // ways to miss
        else {
            if (result.missed) this.performMiss();
            if (result.evaded && result.physical) this.performEvasion();
            if (result.evaded && !result.physical) this.performMagicEvasion();
        }
        // show pop-ups
        this.startDamagePopup();
    };

//====================================================================
// Handle battle rewards
//====================================================================

    // add "rewards" object to the map scene
    var _scene_map_initialize = Scene_Map.prototype.initialize;
    Scene_Map.prototype.initialize = function() {
        _scene_map_initialize.call(this);
        this._rewards = {};
    };

    // properly initialize, even without a battler
    Window_SrpgBattleResult.prototype.initialize = function(battler) {
        var width = this.windowWidth();
        var height = this.windowHeight();
        var x = (Graphics.boxWidth - width) / 2;
        var y = Graphics.boxHeight / 2 - height;
        this.setBattler(battler);
        this._rewards = null;
        this._changeExp = 0;
        Window_Base.prototype.initialize.call(this, x, y, width, height);
    };

    // update the battler between showings of the window
    Window_SrpgBattleResult.prototype.setBattler = function(battler) {
        this._battler = battler;
        if (battler) {
            this._reserveExp = this._battler.currentExp();
            this._level = this._battler.level;
        } else {
            this._reserveExp = 0;
            this._level = 0;
        }
    };

    // put a results window in the scene
    var _scene_map_createAllWindows = Scene_Map.prototype.createAllWindows;
    Scene_Map.prototype.createAllWindows = function() {
        _scene_map_createAllWindows.call(this);
        this.createSrpgBattleResultWindow();
    };
    Scene_Map.prototype.createSrpgBattleResultWindow = function() {
        this._srpgBattleResultWindow = new Window_SrpgBattleResult($gameParty.battleMembers()[0]);
        this._srpgBattleResultWindow.openness = 0;
        this.addWindow(this._srpgBattleResultWindow);
    };

    // use all the existing code for rewards, so it can inherit plugin modifications
    Scene_Map.prototype.makeRewards = BattleManager.makeRewards;
    Scene_Map.prototype.gainRewards = BattleManager.gainRewards;
    Scene_Map.prototype.gainExp = BattleManager.gainExp;
    Scene_Map.prototype.gainGold = BattleManager.gainGold;
    Scene_Map.prototype.gainDropItems = BattleManager.gainDropItems;

    // process victory
    Scene_Map.prototype.processSrpgVictory = function() {
        if ($gameParty.battleMembers()[0] && $gameParty.battleMembers()[0].isAlive()) {
            this.makeRewards();
            if (this._rewards.exp > 0 || this._rewards.gold > 0 || this._rewards.items.length > 0) {
                this._srpgBattleResultWindow.setBattler($gameParty.battleMembers()[0]);
                this._srpgBattleResultWindow.setRewards(this._rewards);
                var se = {};
                se.name = _rewardSe;
                se.pan = 0;
                se.pitch = 100;
                se.volume = 90;
                AudioManager.playSe(se);
                this._srpgBattleResultWindow.open();
                this.gainRewards();
                return true;
            }
            return false;
        }
    };

//====================================================================
// show popups for tile and status damage
//====================================================================

    // show pop-up for regeneration
    var _battler_regenerateAll = Game_Battler.prototype.regenerateAll;
    Game_Battler.prototype.regenerateAll = function() {
        _battler_regenerateAll.call(this);
        if ($gameSystem.isSRPGMode()) {
            this._result.used = true;
            this.srpgShowResults();
        }
    };

    // show pop-up for floor damage
    var _srpgExecuteFloorDamage = Game_Battler.prototype.srpgExecuteFloorDamage;
    Game_Battler.prototype.srpgExecuteFloorDamage = function() {
        _srpgExecuteFloorDamage.call(this);
        if (this._result.hpDamage != 0) {
            this._result.used = true;
            this.srpgShowResults();
        }
    };

    // suppress the screen flash from damage in SRPG mode
    var _startFlashForDamage = Game_Screen.prototype.startFlashForDamage;
    Game_Screen.prototype.startFlashForDamage = function() {
        if (!$gameSystem.isSRPGMode()) _startFlashForDamage.call(this);
    };

//====================================================================
// on-map damage pop-ups
//====================================================================

    // initialize the damage popups
    var _sprite_character_initMembers = Sprite_Character.prototype.initMembers;
    Sprite_Character.prototype.initMembers = function() {
        _sprite_character_initMembers.call(this);
        this._damages = [];
    };

    // update the damage popups
    var _sprite_character_update = Sprite_Character.prototype.update;
    Sprite_Character.prototype.update = function (){
        _sprite_character_update.call(this);
        if (this._character.isEvent()) {
            this.updateDamagePopup();
        }
    };

    // update the damage pop-ups each frame
    Sprite_Character.prototype.updateDamagePopup = function() {
        this.setupDamagePopup();
        if (this._damages.length > 0) {
            for (var i = 0; i < this._damages.length; i++) {
                this._damages[i].update();
            }
            if (!this._damages[0].isPlaying()) {
                this.parent.removeChild(this._damages[0]);
                this._damages.shift();
            }
        }
    };

    // create the damage pop-up
    Sprite_Character.prototype.setupDamagePopup = function() {
        var array = $gameSystem.EventToUnit(this._character.eventId());
        if ($gameSystem.isSRPGMode() && array && array[1]) {
            var battler = array[1];
            if (battler.isDamagePopupRequested()) {
                var sprite = new Sprite_Damage();
                sprite.x = this.x;
                sprite.y = this.y;
                sprite.z = 9;
                sprite.setup(battler);
                this._damages.push(sprite);
                this.parent.addChild(sprite);
            }
            battler.clearDamagePopup();
            battler.clearResult();
        }
    };

//====================================================================
// compatability overrides
//====================================================================

    // track intended repeats from before BattleEngineCore
    if (DataManager.addActionEffects) {
        var _addActionEffects = DataManager.addActionEffects;
        DataManager.addActionEffects = function(obj, array) {
            var initialRepeats = obj.repeats;
            _addActionEffects.call(this, obj, array);
            obj._srpgRepeats = initialRepeats - obj.repeats;
        };
    }





})();
But this new (experimental Version) is my try to rebuild it in another way ,because even if the first MapForceAction Version(3rd Spoiler) works better at the moment ,it has a few inacceptable compatiblety issues with other functions.
(It dont understand why these Compatiblety issues are there ,thats why i cant fix this other Version)

JavaScript:
//=============================================================================
// 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:

})();
Thats how far i got by now and there are still some functions missing .
(Counter and Reflect -Check for eg)

For those who want to compare both plugin Versions.. here is the "half edited clone of SRPG_Mapbattle.js." = first MapForceAction Version (same like in the current demo)
JavaScript:
//=============================================================================
// SRPG_MapForceAction.js
//=============================================================================
/*:
* @plugindesc v1.0 Adds <SRPG_MapForceAction> ScritCall to SRPG
* @author dopan
*
*
*
*
*
*
* @param Blank_Skill ID
* @desc Skill ID: ID of the Blank Skill that is used in the "this.isCreateMapForceAction();"-ScriptCall
* @type skill
* @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.It will also trigger Counters,
*   if the added Skill would do that (ignoring range on counters).
*
*
*
* 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);
*-------------------------------------------------------------------------------------------------------
*-------------------------------------------------------------------------------------------------------
* 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 battlestart,...
*    ..so the action will happen as soon there is a battlestart.
*
* => there is an Example for this in the Updated-SRPG_demo
*-------------------------------------------------------------------------------------------------------
*-------------------------------------------------------------------------------------------------------
* - "this.isCreateMapForceAction();"
*-------------------------------------------------------------------------------------------------------
*-------------------------------------------------------------------------------------------------------
* => use this Scriptcall one time at the Start of a battle. Its a not very elegant walkaround,
*   that should make the other Scriptcalls work properly and must be used till i found a better solution.
*
* => this make sure that the First action that happens is an action from this plugin,i dont know exactly why,
*    but this has to happen in order to let the "Scene_Map.prototype;" of this Plugin work properly..
*
* => there is an Example for this in the Updated-SRPG_demo
*
*
*
* Known Issue:
*             -> 1 Action from this Plugin Must happen at battleMap start, that means there will be a delay,
*                and a pre&post Action Phase.. This issue is nothing gamebreaking and can be handled ,
*                but i will try to find a better solution in the Future..
*                ( at this moment i just dont know enough about JS and "Scene_Map.prototype;" to solve it properly.)
*
*
* ============================================================================
* 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 _blankSkill = Number(parameters['Blank_Skill ID'] || 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;

//-----------------------------------------------------------------------------------------

    // set up the map attacks
    var _forceMapBattleStart = Scene_Map.prototype.forceMapBattleStart;
    Scene_Map.prototype.forceMapBattleStart = function(userArray, targetArray) {
        // get the data
        var user = userArray[1];
        var target = targetArray[1];
        var action = user.action(0);
        var reaction = null;

        // check if we're using map battle on this skill
        if (action && action.item()) {
            var mapBattleTag = action.item().meta.mapBattle;
            if (mapBattleTag == 'true') $gameSystem.forceSRPGBattleMode('map');
            else if (mapBattleTag == 'false') $gameSystem.forceSRPGBattleMode('normal');
        }
        if (!$gameSystem.useMapBattle()) {
            _srpgBattleStart.call(this, userArray, targetArray);
            return;
        }

        // prepare action timing
        user.setActionTiming(0);
        if (user != target) target.setActionTiming(1);

        // pre-skill setup
        $gameSystem.clearSrpgStatusWindowNeedRefresh();
        $gameSystem.clearSrpgBattleWindowNeedRefresh();

        // make free actions work
        var addActionTimes = Number(action.item().meta.addActionTimes || 0);
        if (addActionTimes > 0) {
            user.SRPGActionTimesAdd(addActionTimes);
        }

        this.preBattleSetDirection();
        //this.eventBeforeBattle(); // this will be used elsewhere depending on the Scriptcall..
        this.srpgMapActionText(); // EDIT dopan (for mapActionText Usage)

        // set up the troop and the battle party
        $gameTroop.clearSrpgBattleEnemys();
        $gameTroop.clear();
        $gameParty.clearSrpgBattleActors();
        if (userArray[0] === 'enemy') $gameTroop.pushSrpgBattleEnemys(user);
        else $gameParty.pushSrpgBattleActors(user);
        if (targetArray[0] === 'enemy') $gameTroop.pushSrpgBattleEnemys(target);
        else $gameParty.pushSrpgBattleActors(target);
        BattleManager.setup(_srpgTroopID, false, true);
        action.setSubject(user);

        // queue the action
        this.srpgAddMapSkill(action, user, target);this.processSrpgVictory();

        // queue up counterattack
        if (userArray[0] !== targetArray[0] && target.canMove() && !action.item().meta.srpgUncounterable) {
            target.srpgMakeNewActions();
            reaction = target.action(0);
            reaction.setSubject(target);
            reaction.setAttack();
            var actFirst = (reaction.speed() > action.speed());
            this.srpgAddMapSkill(reaction, target, user, actFirst);
        }
    };

//Plugin  ScriptCalls:

        //"this.isMapForceAction(userId, targetId, skillId, payCost);"
        Game_Interpreter.prototype.isMapForceAction = function(userId, targetId, skillId, payCost) {
            _mapForceUser = userId;
            _mapForceTarget = targetId;
            _mapForceSkill = skillId;
            _mapForcePayCost = payCost;
            _sceneMapProto.srpgMapForceAction();

        };

        //"this.isMapForceActionNote(userId, targetId, skillId, payCost);"
        Game_Interpreter.prototype.isMapForceActionNote = function(userNoteId, targetNoteId, skillNoteId, payCost) {
            _mapForceUserNote = userNoteId;
            _mapForceTargetNote = targetNoteId;
            _mapForceSkillNote = skillNoteId;
            _mapForcePayCost = payCost;
            _sceneMapProto.srpgMapForceActionNote();

        };

        //"this.isCreateMapForceAction();"
        Game_Interpreter.prototype.isCreateMapForceAction = function() {
            _sceneMapProto.srpgCreateMapForceAction();

        };

//Plugin Function:


        var _srpgCreateMapForceAction = Scene_Map.prototype.srpgCreateMapForceAction;
        Scene_Map.prototype.srpgCreateMapForceAction = function() {
             if ($gameSystem.isSRPGMode()) {
                  var lastUnit = $gameSystem._EventToUnit.length - 1;
                  var user = $gameSystem.EventToUnit(lastUnit);
                  var target = $gameSystem.EventToUnit(lastUnit);
                  if ((!user[1].isDead()) && (!target[1].isDead())) {

                       $gameTemp.setActiveEvent($gameMap.event(lastUnit));

                       $gameTemp.setTargetEvent($gameMap.event(lastUnit));

                       $gameSystem.forceSRPGBattleMode('map');

                       user[1].forceAction(_blankSkill, target[1]);

                       //$gameSystem.setSubBattlePhase('invoke_action');

                       _sceneMapProto.forceMapBattleStart.call(this, user, target);

                  }

             }
             return true;
        };


        var _srpgMapForceAction = Scene_Map.prototype.srpgMapForceAction;
        Scene_Map.prototype.srpgMapForceAction = function() {
             if ($gameSystem.isSRPGMode()) {
                  var user = $gameSystem.EventToUnit(_mapForceUser);
                  var target = $gameSystem.EventToUnit(_mapForceTarget);
                  if ((!user[1].isDead()) && (!target[1].isDead())) {

                       $gameTemp.setActiveEvent($gameMap.event(_mapForceUser));

                       $gameTemp.setTargetEvent($gameMap.event(_mapForceTarget));

                       $gameTemp.setShouldPayCost(_mapForcePayCost);

                       $gameSystem.forceSRPGBattleMode('map');

                       user[1].forceAction(_mapForceSkill, target[1]);

                       $gameSystem.setSubBattlePhase('invoke_action');
                       this.eventBeforeBattle();
                       _sceneMapProto.forceMapBattleStart.call(this, user, target);

                  }

             }
             return true;
        };

        var _srpgMapForceActionNote = Scene_Map.prototype.srpgMapForceActionNote;
        Scene_Map.prototype.srpgMapForceActionNote = function() {
             if ($gameSystem.isSRPGMode()) {
                  var user = $gameSystem.EventToUnit(_mapForceUserNote);
                  var target = $gameSystem.EventToUnit(_mapForceTargetNote);
                  if ((!user[1].isDead()) && (!target[1].isDead())) {

                       $gameTemp.setActiveEvent($gameMap.event(_mapForceUserNote));

                       $gameTemp.setTargetEvent($gameMap.event(_mapForceTargetNote));

                       $gameTemp.setShouldPayCost(_mapForcePayCost);

                       $gameSystem.forceSRPGBattleMode('map');

                       user[1].forceAction(_mapForceSkillNote, target[1]);

                       _sceneMapProto.forceMapBattleStart.call(this, user, target);

                  }

             }
             return true;
        };

//-----------------------------------------------------------------------------------------

//-----------------------------------------------------------------------------------------


//--End:

})();
About the "new experimental Plugin Version":
My problem now is that i cant make the right timing on some parts, and i want to know if there is a better way to make sure that every thing triggers at the timing how i want it.
I also tried to use "Scene_Map.prototype" instead of "Game_Interpreter.prototype",
but in such case the "this._list.splice(this._index + 1, 0, acom1, acom2);" wont work.
(it probably needs to be in a "Game_Interpreter.prototype",)


About the right Timing:
- For Example in this Spoiler-EG-Plugin(experimental Version) a "CustomExecution-CommonEvent" from Yep skill Core will trigger to late .

Custom Execution is a SkillNote and is used in SRPG with "$gameTemp.reserveCommonEvent(ID);" to trigger the CE earlier than a default Skill attached CE..
it supposed to trigger betwen both animations but even if i put it before both animations it will happen after them,like it does in this eg Plugin.
(just a little bit,but it has to trigger at the same timing like in the SRPG_Mapbattle.js)
- also the "pre action Phase" will trigger later than it should in this Setup.(happens at the end)
(thats no problem because SRPG_Mapbattle.js has the same Issue and i want to keep this equal)
- i want to know more about how to Control the Timing if thats possible
(even if this needs another approach/solution)
- I could use the Common Event from the "MapActionText"-function as walkaround ,
for the "CustomExecution-CommonEvent"-Issue ,but i dont like this solution.Because it has to work the same way like with SRPG_Mapbattle.js for people who use "CustomExecution-CommonEvent" in their Skill Setup.

(i used another approach to instant trigger the "MapActionText"-Common Event)
=>the "custom Ex" itself seem to trigger early enough but a "$gameTemp.reserveCommonEvent(ID);",
which is in that "custom Ex" seems to wait a little bit to long..


Any Ideas are welcome:
this "experimental Version-Plugin"(second spoiler) can be tested with the Updated SRPG Demo ..

(just replace the old Plugin in the Demo with this Version from the 2nd_spoiler and use "Chucks Default Map 0" and the "MapForceAction" Function from the little girl next to the Clown)

As it looks now i will probably have to rebuild the whole plugin in another way or try the "half edited clone of SRPG_Mapbattle.js." Version again with another Approach..

Edit (video EG with the new experimental Plugin Version)
Here a video in addition to show the tiny difference in the "Custom Execution-CommonEvent" timing.
Fire Skill is triggerd by "SRPG_MapBattle.js", Ice Skill is triggerd by "SRPG_MapForceAction.js".
Both skills should work the same..they use the same "Custom Ex"-CommonEvent(nr.18) which trigger the Zoom.
But the Fire Skill Zooms in a bit earlier than the Ice Skill..
This tiny difference is importent because "moving animations" which are used in other Skills and are created in another "Custom Ex-CommonEvent" need to trigger earlier in order to work correctly..

Edit2
i also tried to put :
"this.wait(frames)"
At the End of every "Game_Interpreter.prototype".. the delay betwen each of the "Game_Interpreter.prototype" there works but it doesnt affect that the Animations happen before the "CustomExecution triggered CommonEvent" starts..
(i cant say why this happens)

Edit3
If i use this in the Custom Execution SkillNote:
Code:
$gameSwitches.setValue(ID, true);
as trigger for a parrallel CE instead of :
Code:
"$gameTemp.reserveCommonEvent(ID);"
->that will happen early enough .. and it will work for both Plugins the same way.

(earlier than the "$gameTemp.reserveCommonEvent(ID);")
=> that could solve my Issue from outside of the Plugin but it will need more Switches..
(and i would still like to know why "$gameTemp.reserveCommonEvent(ID);", has a diefferent timing if its used as Custom Execution SkillNote in both Plugins.. like the fire & Ice EG from the Video shows)
 
Last edited:

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,610
Reaction score
5,152
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Its been almost 6 months since i've been here last and 5 years before that. the worst part is losing the game you were working on in a cpu fire.

Well time to go at it again.
my game is coming together im so happy
In this day and age, i might switch back to RMXP. I’ve lost faith in all the new plugins.
Wow it's been forever since I last logged in! I STILL want to make a game... I'll start it one day for sure!! It's a dream of mine.
This days I couldn't do anything... My mind is so confused and I couldn't work at all, I only wanted to play video games with my friends and that made all my projects delay a lot. Someone else feels this kind of thing sometimes? :/

Forum statistics

Threads
104,287
Messages
1,005,264
Members
135,797
Latest member
Famas
Top