Hopefully this question isn’t too obscure, but I’m having trouble designing a certain type of common event in battle.
I’m using DreamX’s Instant Turn Battle plugin in my project (link below), which is similar to Yanfly’s STB in that each battler’s actions happen immediately after command input.
The difficulty is the timing and targeting of this event. I want to make an event which triggers at the very beginning of each individual battler’s turn, and which sets the active battler’s MP to 1. It should apply for all actors/enemies, and it should trigger even before the player has a chance to select any battle commands for their actor.
That last bit is the tricky part. If the player selects an action and then the event runs, that’s too late for my purposes. I could just use something like an Action Start Effect notetag in Yanfly’s Buffs and States Core if I wanted that. It’s very important that the event runs before an actor’s battle commands are selectable during their individual turn.
The best idea I had so far to achieve this very particular event timing is to make a common event which triggers at the end of each battler’s action and targets the next battler in queue. Here’s how I imagine it should run:
1) After a battler completes their action, the event would trigger and compare the AGI of all battlers who haven’t acted yet during the current turn. I would probably have a battler’s skills self-apply a unique “flag” state. This state would be used to record who had already acted and should be excluded from the AGI comparison.
2) The event would then find the battler with the highest AGI value who was still waiting to act during that turn (i.e. the next battler in the turn queue).
3) After identifying the next battler to act, the event would set their MP to 1. If the battler was an actor, the player would then be able to select the actor’s action for the turn.
4) If all battlers had already acted during the current round of battle, the event would remove the flag state from all battlers, and then change the MP of the battler with the highest overall AGI.
5) Repeat this cycle every time a battler completes their individual turn.
I found a JS snippet in an old thread here which I thought could be adjusted to fit my needs. Here’s the original code:
Code:
var currentStrongestActor = $gameParty.members(0);
var currentStrongestAtk = currentStrongestActor.atk;
$gameParty.members().forEach(function(a) {
if (a.atk > currentStrongestAtk) {
currentStrongestAtk = a.atk;
currentStrongestActor = a;
};
});
Original Thread:
https://forums.rpgmakerweb.com/inde...s-highest-parameter-variable-whatever.109025/
Here’s how I adjusted it:
Code:
var currentFastestActor = $gameParty.members(0);
var currentFastestAgi = currentFastestActor.agi;
$gameParty.aliveMembers().forEach(function(a) {
if (a.agi > currentFastestAgi && !a.isStateAffected(13)) {
currentFastestAgi = a.agi;
currentFastestActor = a;
currentFastestActor.setMp(1);
};
});
State 13 is the flag state. Note that this version is incomplete, since it only affects actors, rather than both actors and enemies. I also haven’t written the code to remove the flag state yet, because I didn’t get that far before running into problems.
My issue right now is that neither the original code nor the adjusted version will run from a common event (the event is called during the Finish Action of a skill using Yanfly’s Action Sequence Pack 1). Other common events run fine when substituted, so the problem is somewhere in the JS content of these specific events.
Apologies for the lengthy description here, but hopefully the details help. Any advice on how to get things running is very much appreciated. Thanks!
DreamX Instant Turn Battle Plugin:
https://forums.rpgmakerweb.com/index.php?threads/instant-turn-battle.58464/