EasyRPG / Player

RPG Maker 2000/2003 and EasyRPG games interpreter
https://easyrpg.org/player/
GNU General Public License v3.0
982 stars 186 forks source link

Battle Interpreter runtime + 2k3 special battle commands #2405

Open fmatthew5876 opened 3 years ago

fmatthew5876 commented 3 years ago

Verify all the cases where RPG_RT runs the battle interpreter and do the same, to ensure battle events run at the right times.

I'm still not 100% clear on all the edge cases for this one. The code is very hard to follow, especially for 2k3.

Battle 2k

RPG_SceneBattle::CheckEventsAndBattleEnd

RPG_RT 2ke: 0047A8D0

When
During battle start, immediately after monster encounter and first strike messages
When is escape is pressed to go from the first actor back to the Fight/auto/escape window
Before each battler takes their turn (Note: Be careful to account for dead / hidden!)
After all battlers have completed the battle round

Battle 2k3

RPG_SceneBattle::CheckBattleEndAndUpdateEvents

DynRPG: 00499800

If:

Then:

When trigger type
During battle start, after initialization messages, waits, and resetting of actor and monster directions. 3
Immediately before any battle action is executed, including row/escape* 1
Immediately after a switch skill activates switch 2
Immediately after a switch item activates switch 2
Immediately after enemy battle action finishes 2
Immediately after an actor normal attack or skill action finishes 2
Not after actor Defend, item, escape, or row :exclamation:

For the trigger_type == 1, this function is repeated each frame if the battle action is not able to be executed yet. Basically it calls a function to run the algo, which returns 0 and causes the whole cycle to repeat next frame if the algo can't run yet. The cases include:

Each time 2k3 battle runs events, it will only allow events to run with the following triggers

Trigger Type Triggers Required
1 Battle Turn, Monster Turn, 2k3 Hero Turn, 2k3 Battle Command
2 Switch1, Switch2, Exhaustion, Monster Hp, Hero Hp
3 Any
fmatthew5876 commented 3 years ago

Battle 2k Test Case

Create a battle event triggered by a switch which spawns a message

This behavior is maybe a bug. I've seen it before when play testing. Then again, it does give you a way to trigger events before starting the battle round so maybe thats useful?

fmatthew5876 commented 3 years ago

2k3 battle branch commands

These values are used by RPG_RT for the 2k3 battle branch commands.

Class Value meaning
SceneBattle currentEnemyTargetIndex The 0 based index of the last enemy we targeted
SceneBattle currentTargetRange The range of the last action used by an actor
SceneBattle currentActingHeroId The 1 based ID of the last hero to act
Actor comboUsedBattleCommand Shared with combo system, last 1 based battle command id used by an actor

Target Branch command

(currentTargetRange == TARGET_MONSTER || currentTargetRange == TARGET_MONSTERS) && currentEnemyTargetIndex == param[1]

Hero Used Command Branch command

currentActingHeroId == param[1] && actor->comboUsedBattleCommand == param[2]

How the values are affected

User Action currentEnemyTargetIndex currentTargetRange currentActingHeroId comboUsedBattleCommand
Battle Started -1, and then 0 when first actor acts 0 0 0 -1
Hero normal attack enemy target TARGET_MONSTER hero attack
Hero single target skill or skill item enemy TARGET_MONSTER hero skill
Hero multi target skill or skill item unchanged for same hero :exclamation: TARGET_MONSTERS hero skill
Hero switch skill unchanged TARGET_NONE hero item
Hero defend / row / escape unchanged for same hero :exclamation: unchanged for the same hero :exclamation: hero defend / row / escape
Hero medicine actor target TARGET_ALLY hero item
Hero auto battle / confuse / provoke target target range hero -1
Enemy any unchanged unchanged -1 N/A

Bugs in target enemy branch ❗

The unchanged values in the above cause a lot of strange behavior when you do consecutive actions with the same hero.