MZ Attempt to improve the Turn order - in Turn based combat mode

Hello fellow RPGMaker users!

This is my first attempt to publish one of my plugins, so let's start with something small.

In my own game I use the most basic combat system: Turn based (and front view).
So this plugin is designed for this type of combat. I have not tested how it would behave with any ATB system. Sorry!

Context:

Recently, I read two interesting topics about the turn order and action speed.

In this one: https://forums.rpgmakerweb.com/inde...not-factoring-in-for-the-current-turn.167587/
The issue is that when AGI/speed gets changed during combat (by states or buffs/debuffs) the order of the current turn is not changed, while you would expect that the battlers (actors and enemies) that did not have their turn yet would be reordered according to their new speed/AGI values.
As I'm reusing the code suggested by "Another Fen" in this post, some credit must go to them!

In this one: https://forums.rpgmakerweb.com/inde...actions-of-the-same-actor-independent.167585/
The user had an issue with the bonus actions (Action times +): when a battler has two actions, they both are performed consecutively, and the speed of both of them is equal to the speed of the slowest one.
So if you use Guard as first action and attack as the second action, even if your guard has a 2000 bonus speed, it will be performed at your normal attack speed - which can be slower than enemy attacks - so because you have an extra action you cannot defend properly!

In my game I also have a character who can ocasionally get extra actions (as part of the character rotation), and I was a little bit frustrated that if you need to Guard effectively, you had to pick Guard for both actions or risk being hit before it is applied.

So here is the snippet I wrote in an attempt to fix it. I decided to share it with the community. Maybe it will help someone here, but as it is very experimental my main hope is to get bug reports, or experts explaining me where/why this code is so bad 😉

This plugin will make sure that when a character can do two actions during the same turn, they both are performed with the correct speed (and not the lower one of the two actions).

Example: Ralph (20 AGI) is fighting an Orc (25 AGI). None of them has any attack speed bonus. Ralph has an extra action. You decide to use his actions to Guard and Attack, and the Orc will attack. The Guard command has a bonus speed of 2000.

Without this plugin the turn order will be :
  • Orc attacks (speed 25)
  • Ralph guards (speed 20)
  • Ralph attacks (speed 20)
With this plugin the turn order will be :
  • Ralph guards (speed 2020)
  • Orc attacks (speed 25)
  • Ralph attacks (speed 20)


If AGI/speed is modified during combat (buff, states...) is it applied immediately to all battlers that have remaining actions for this turn.

Another example:

What if instead of using guard Ralph was using an "Entangle" skill, that applies a debuff to the enemy, reducing agi by 50%, and the Entangle skill has a +50 speed bonus itself?

Without this plugin the turn order will be :
  • Orc attacks (speed 25)
  • Ralph entangles (speed 20)
  • Ralph attacks (speed 20)
With this plugin the turn order will be :
  • Ralph entangles (speed 70)
  • Ralph attacks (speed 20)
  • Orc attacks (speed 12)

Term of use : Free for any type of game (any theme, any business model, any engine). No credit.
Don't ask for a compatibility patch with any obfuscated plugin.
Edits are allowed, and I'd be very happy if you would show them to me!

Notes:
  • This plugin has only been tested with the default turn based combat mode, if you use anything more exotic, it will probably not work for you.
  • At the moment (version Alpha 1) the code is overwriting three important methods (BattleManager.getNextSubject, BattleManager.updateAction and Game_Battler.prototype.makeSpeed ) so the compatibility is probably rather low. Put it as high as possible in the plugin list if you want to test it.
I haven't tried it at all, but just as a bit of terminology - it seems odd to go to great lengths warning about "erased" functions that still 100% exist. They're not erased at all, you've just overwritten them with new code.

Thanks for sharing.
Thanks! I meant "overwriting" instead of erasing of course.

Original thread: https://forums.rpgmakerweb.com/threads/attempt-to-improve-the-turn-order-in-turn-based-combat-mode.168014/