MV "Speed" does not play well with YEP_BattleAiCore "Dynamic Actions"

Hello everyone.

Let me get straight to the point.

It seems that "Dynamic Actions" from YEP_BattleAiCore does not play well with the "speed" parameter from the default database. And by speed, I mean the box to the left of "success rate" and above the "hit type" on items and skills.

And as a quick explaination; "Dynamic Actions" means that any given enemy choses their skill at the start of their action instead of at the start of the turn.



Here is an example scenario that outlines the problem:

Starting conditions:
1 Enemy and 1 Actor, both having equal agility (10) and attack speed (0).

Turn 1: Both combatants use an ability X with speed 0 = it is random which one goes first
Turn 2: The enemy uses ability Y with speed 100 = the enemy goes first as expected
Turn 3: Both combatants use an ability X with speed 0 = for some reason, the enemy will still go first every time
Turn 4: Both combatants use an ability X with speed 0 = it is random which one goes first again



Now I need to say that I actually modified the function that calculated "speed", but I tested this phenomenon with both my modified function and the default function and the results are the same.
But to whom it may concern, here is the snippet of the modified function:

Spoiler: "Speed" Function
JavaScript:
Game_Action.prototype.speed = function() {
    var speed = this.subject().agi * (1 + (Math.max((this.subject().attackSpeed() / 100), 0.05)));
    if (this.item() && this.item().speed !== 0) {
        speed += (this.item().speed * 50000);
    }
    return speed;
};

With this modification, I basically wanted to recreate a "priority" system similar to pokemon, whereas a higher "speed" number would essentially guarantee you going first even if your agility was lower than that of others.

I also repurposed the "attack speed" trait to modify the agility by an % amount instead of a flat amount.



So it seems that for some reason the "speed" of the enemy persists across one turn. Which does not only destroy consistency but also some of the gameplay mechanics I want to employ.

Does anyone know if there is some way to "fix" this?
The speed value is defined as "a value that is added to the character's agility when determining the action order." The dynamic actions plugin changes the battle system so the actions aren't chosen until action order.

So these two things are inherently incompatible - it's impossible to say this chosen skill makes you act sooner if you can't choose it until you're acting. You'd be going back in time.
The system you describe, having a priority system like Pokémon, is how the default battle system works without plugins.

So I just don't understand what you want. Why are you even using the dynamic actions option?
Why are you even using the dynamic actions option?
Because I want to?
My enemies all have specific attack patterns with conditions and prerequisites.
And these conditions can be met *during* a turn, so it makes sense for the enemy to change their strategy on the fly.

For example, they may use a healing skill only when an ally is hurt. So if the enemy 1 decides use an offensive ability but the first action you take damages enemy 2, then enemy 1 may choose to use a healing ability instead.

Also for clarification on the whole "priority system", here is how it is roughly set up right now:

Spoiler: Priority Table
8 Always Used First
7 Items & Defending
6 Very High Priority Offensive Skills
5 Buffs
4 Healing Skills
3 Debuffs
2 Utility
1 Priority Offensive Skills
0 All other Moves
-1 Low Priority Moves
-2 Very Low Priority Moves
-3 Always Used Last

*The numbers represent the "speed" parameter

What you said about the system makes sense, but my question still remains open.
Because I did some testing and the "speed" parameter does still affect the action order.
It may not be taken into account if the character changes their action "on the fly", but they are still calculated at the start of the turn.

Using the table from above, let me rephrase the problem:

Turn 1:
Actor uses skill with priority 1
Enemy uses skill with priority 0
-> The Actor goes first (Correct)

Turn 2:
Actor uses skill with priority 1
Enemy uses skill with priority 2
-> The Enemy goes first (Correct)

Turn 3:
Actor uses skill with priority 1
Enemy uses skill with priority 0
-> The Enemy still goes first (Wrong)

Turn 4:
Actor uses skill with priority 1
Enemy uses skill with priority 0
-> The Actor goes first again (Correct)

My problem is simply, that the enemy seems to retain his "priority" (speed) accross one turn.
If you look at the example, on Turn 3 the enemy goes first even though his skill has the priority of 0 and the actor has 1. That is likely due to the fact that in the prior turn he used a skill with priority 2.
Because I want to?
Except you apparently don't, you want to be able to have some actions resolve sooner or later after they're chosen - that's logically incompatible with choosing what the action will be during the course of the turn.

What you said about the system makes sense, but my question still remains open.
Because I did some testing and the "speed" parameter does still affect the action order.
It may not be taken into account if the character changes their action "on the fly", but they are still calculated at the start of the turn.
No, they're calculated at the end of the battler's action.
If you look at the example, on Turn 3 the enemy goes first even though his skill has the priority of 0 and the actor has 1. That is likely due to the fact that in the prior turn he used a skill with priority 2.
Exactly. So the only thing you can do with speed and dynamic actions is affect the next round. You can do something to set up, or prepare, or charge, and act sooner the next round, but it's impossible to change when you act this round when you're deciding the action as you act.

That's like walking up to someone, shaking their hand, and deciding "I actually shook your hand five minutes ago."

It should work normally for players, though.

You could use battle events each round to manipulate the enemies' Agility based on whatever conditions you want, that would change when they choose their actions.
As I said:

What you said about the system makes sense, but my question still remains open.
Because I did some testing and the "speed" parameter does still affect the action order.
It may not be taken into account if the character changes their action "on the fly", but they are still calculated at the start of the turn.

The main point is this:

I want all actions to go off according to their given priority at the start of the turn.
Not more, not less.

I don't care how the priority is handled *during* the turn.
The only thing that bugs me is that the "speed" is carried over to the next turn.

I don't want the enemies to use -2 priority moves *first*, just because they used a +6 priority move in the last turn.

Essentially, I need the "speed" to reset back after each turn, which apparantly does not happen.
I don't understand what part of this doesn't make sense to you. If you don't want to change when their actions go off next turn, don't use different numbers in Speed.
Maybe there is a slight misunderstanding here.

I want the speed to only affect the initial turn order at the start of the turn.
Which is the case by the way, with the only caveat being that the speed seems to carry over to the next round.
I don't care about during the turn.

No, they're calculated at the end of the battler's action.
You say that, but my testing says otherwise. Atleast partially.
If my Actor with 10 agility uses a skill with priority 1 and the enemy with 10000 agility uses a skill with priority 0, the actor still goes first. So there has to be some kind of calculation at the turn start.

I should say that despite the "dynamic actions", I still have the default turn-based battle system. Meaning that at the start of each round, you chose all of your actors actions and then everything plays out by itself.

And everything does work properly. Every combatant can chose a skill of different priority and then then everyone acts beautifully in order of their skill priorities.

But then the turn after that, they STILL do act in the same order. That's what I don't want.
Atleast the enemies do, the actors DO seem to reset their speed each round.
I want the speed to only affect the initial turn order at the start of the turn.
It can't. You have turned on dynamic actions. I have talked you through this multiple times and somehow you still don't understand. Look:

Beginning of turn:
1 - Player chooses actions for all of the actors in the party.
2 - The actors' agility is added to the speed of their action to determine when the action goes off
3 - The enemies have not chosen actions because you turned on dynamic actions. Their agility is used to determine when they will choose later

Agility 50
- The actor that has an agility of 46 and chose a skill with speed 4 happens now

Agility 40
- The actor that has an agility of 42 and chose a skill with speed -2 happens now

Agility 35
-
The enemy that has an agility of 35 chooses his action now. Even if it has a high speed, it is impossible for him to go back in time and make the action happen at Agility 40

Good luck with your game.
3 - The enemies have not chosen actions because you turned on dynamic actions. Their agility is used to determine when they will choose later

But that's NOT how it goes in practice.


*Remember, "priority" in this context just means that x agility gets added to the agility value.
-> x being 50000 * priority value

From my testing, the actual behaviour looks like this:

Actor 1 has 30 Agility and choses a skill with priority 0.
Actor 2 has 32 Agility and choses a skill with priority 0.
Actor 3 has 18 Agility and choses a skill with priority 1.

And consequently, the ordering goes like this:
Actor 3 -> Actor 2 -> Actor 1



Now lets throw some enemies in there:

Enemy 1 has 50 Agility and choses a skill with priority 0.
Enemy 2 has 100 Agility and choses a skill with priority -1.
Enemy 3 has 10 Agility and choses a skill with priority 1.

And consequently, the ordering goes like this:
Actor 3 -> Enemy 3 -> Enemy 1 -> Actor 2 -> Actor 1 -> Enemy 2



Also, here are some other important points that could help you understand whats going on:

- The Actors AND enemies chose a "starting skill" at the START OF THE TURN that takes speed (priority) into account

- The action order of all combatants is determined at the start of the turn, using their agility and the priority of their chosen starting skill

- During the turn, enemies MAY chose to change their action to another skill, retaining their position in the turn order however

-> This means that an enemy that initially wants to use a -2 priority skill but changes to a +4 priority skill during the turn, will STILL likely go last, keeping their -2 priority



I don't know the exact code, but from what I have seen in practice, the speed parameter does play a role, not just the agility.

And if you still don't believe my word, you can just try it out for yourself, in order to test your assertions and my own, I even tested this on a blank-slate project with just BattleAiCore and my priority plugin.

You can download it and try it. I replicated the exact scenario mentioned above.
If you're willing to explore my original problem, you can try to re-create that aswell and see my problem for yourself.


Mediafire Link
- The Actors AND enemies chose a "starting skill" at the START OF THE TURN that takes speed (priority) into account

And as a quick explaination; "Dynamic Actions" means that any given enemy choses their skill at the start of their action instead of at the start of the turn.
Fine then, I concede that this was unfortunate phrasing on my part.
But at the time of my original post, I didn't consider that this detail would become to prevalent later on.

For clarity,
Let's just say then, at the start of the turn, each enemy choses a placeholder skill which priority will be taken for calculation to create a turn order.

And then when the enemy is on, they can either go on to use that placeholder skill or chose another skill if the given conditions mandate it.
Bumping

Original thread: https://forums.rpgmakerweb.com/threads/speed-does-not-play-well-with-yep_battleaicore-dynamic-actions.135231/