Conversation
|
In its current state, the timing for auto-battle in 2k3 is off by enough to grant a second, player-controlled turn to AI characters after their standard turn. However, the issue was strangely intermittent - in one case, it happened with two out of three characters, with the third never getting an extra turn. After further testing, it appears to be dependent on stats or more likely animation timing. |
700654f to
6536569
Compare
| } | ||
|
|
||
| void AlgorithmBase::SetAutoBattleAction(Game_Actor& source) { | ||
| vSetAutoBattleAction(source); |
There was a problem hiding this comment.
Is this some convention to use v?
I have a similiar "call forwarder to virtual" in my unfinished Filesystem code.
There I use XXXXX and for virtual XXXXImpl.
Opinion?
There was a problem hiding this comment.
This is the non-virtual idiom NVI
http://www.gotw.ca/publications/mill18.htm
If I were a more disciplined NVI folllower, I would do this for all virtual functions. I like the v prefix, but I don't really care that much what naming scheme is used.
This is also a good way to fix the clang-tidy warnings on GetBaseAtk() etc..
|
More Todos: For later (editor, pls): |
069dc29 to
b1572eb
Compare
b1572eb to
f606d6d
Compare
|
I created I don't think we need anything else for this iteration. Now this just has to be tested. |
|
I checked all the RPG_RT versions and found something really strange. Every version of the engine uses double division for maxhp, maxsp, etc.. math. except 2ke. For some reason I can't grasp, it looks like 2ke developers actually decided to go into the auto battle code and switch to using integer division. Other than that there are no differences. Given the amount of randomness here and the pain required to support both integer and double (templates), I'm inclined to leave it with double division. |
|
Maybe @CherryDT as 2ke developer can give some insight here? |
f606d6d to
8903fae
Compare
|
Weird indeed, I didn't change anything. How is the behavior in the Japanese Value!+ version 1.52? This is the version that I changed to become 1.60. Unlike 2k3e, I actually changed the code and compiled from source - it should be the same compiler (Delphi 5) but maybe originally some different compiler flags were used or something (although I'd expect those settings to be stored in the project file)... If it changed only between 1.52 and 1.60 then it's a bit of a mystery... |
|
I got an RPG_RT binary from here https://tkool.jp/products/trial.html which I believe is 1.5.2 JP? I checked that one and it is using double math. |
|
I went to check what's going on there, and there is no change in Git for the relevant file. So if anything was changed, it must have happened before I got the code. I wonder if it's indeed a subtle compiler difference or something like that because the calculation (if that's the one you meant, that is) looks like this (in pseudocode): x = min(p, maxHp - hp) / maxHp;
But actually that doesn't sound right either, because I checked the help file in my Delphi version and it says that 🤷♂️ |
Yes that is the division I'm talking about, that and the I guess this one will remain a mystery.. |
|
Sorry but it looks like this was a red herring. I was looking at the wrong disassembly. It indeed appears that double division is being used by all version, including 2ke. Sorry about that |
|
I have checked out your auto battle implementation and I like it so far! But I noticed some weird behavior in RPG Maker 2003 battles: In auto battle mode, after an actor executed his automatic selected action, the game switches to manual battle mode and even grants the actor an extra turn (automatic and manual action in the same turn despite ATB being zero after the automatic action). |
8903fae to
f866a06
Compare
|
Thanks, I fixed the auto battle 2k3 bug you mentioned. |
733534a to
39a51a5
Compare
|
Jenkins: test this please |
82a3529 to
2ff9527
Compare
2ca3656 to
90e47a4
Compare
|
I've added a start for some unit tests. This is as far as I will go on this PR. |
src/scene_battle.cpp
Outdated
| Output::Debug("Starting battle {} ({})", troop_id, troop->name); | ||
| autobattle_algo = AutoBattle::CreateAlgorithm(Player::player_config.autobattle_algo.Get()); | ||
|
|
||
| Output::Debug("Starting battle {} ({}) : autobattle={}", troop_id, troop->name, autobattle_algo->GetName()); |
There was a problem hiding this comment.
isn't it a bit verbose to print the constant autobattle algo everytime a battle starts?
btw is the algorithm name case sensitive or can I also specify "attack" on the command line?
There was a problem hiding this comment.
My original design was printing this once on startup in it's own logfile line. I was thinking of future extensibility where you could change the algo at runtime, but since we don't have that yet this is a bit overkill.
The algo name is case sensitive, I can fix that
There was a problem hiding this comment.
Added the case insensitive name compare. I left the log message in as it seems to me it'll be better for debugging when the algo is changeable in scene settings etc..
That being said if you feel strongly I'll remove it.
There was a problem hiding this comment.
well keep it but please get rid of the whitespace before the ":". (Also imo a comma or a semi-colon would fit better here.)
|
Sorry I wanted to review this and comparing with RPG_RT on the weekend but I'm away from my dev-station until wednesday so this has to wait a bit longer. |
Ghabry
left a comment
There was a problem hiding this comment.
some remarks, but imo the algorithms are correct
| #_filedir '@(lmu|emu)' | ||
| return | ||
| ;; | ||
| # load map files |
src/autobattle.cpp
Outdated
|
|
||
| auto rank = static_cast<double>(max_effect) / static_cast<double>(tgt_max_hp); | ||
| if (src_max_sp > 0) { | ||
| const double cost = source.CalculateSkillCost(skill.ID); |
There was a problem hiding this comment.
For CalculateSkillCost RPG_RT appears to ignore the "Half SP" (or I missed it). Maybe also emulate this bug?
There was a problem hiding this comment.
Nice catch, you're right this is another RPG_RT bug
src/autobattle.cpp
Outdated
| } | ||
| if (src_max_sp > 0) { | ||
| const double cost = source.CalculateSkillCost(skill.ID); | ||
| // Note: RPG_RT 2ke only uses integer division for cost / src_max_sp here. |
src/autobattle.cpp
Outdated
| const double tgt_hp = target.GetHp(); | ||
|
|
||
| if (target.GetHp() > 0) { | ||
| // Can the skill can heal the target? |
| Possible options: | ||
| RPG_RT - The default RPG_RT compatible algo, including RPG_RT bugs | ||
| RPG_RT+ - The default RPG_RT compatible algo, with bug fixes | ||
| ATTACK - RPG_RT+ but only physical attacks, no skills |
There was a problem hiding this comment.
The lines are too long (>80) but this is a problem in many parts of the help output
There was a problem hiding this comment.
Would like to punt until we have a wholistic answer to this one
src/scene_battle.cpp
Outdated
| Output::Debug("Starting battle {} ({})", troop_id, troop->name); | ||
| autobattle_algo = AutoBattle::CreateAlgorithm(Player::player_config.autobattle_algo.Get()); | ||
|
|
||
| Output::Debug("Starting battle {} ({}) : autobattle={}", troop_id, troop->name, autobattle_algo->GetName()); |
There was a problem hiding this comment.
well keep it but please get rid of the whitespace before the ":". (Also imo a comma or a semi-colon would fit better here.)
|
Addressed review comments. I also found and fixed and off by 1 bug in The question of the algo logging will come up again in #2381 as I log the enemyai algo too. Let's figure it out for good when we get to that PR. |
Adds: 3 algorithms * RPG_RT - bug compatible with RPG_RT * ATTACK - only physical attacks + bug fixes * RPG_RT+ - RPG_RT algo + bug fixes
When halfSpCost() modifier is used, we add 1 to flat sp cost but not percent sp cost.
RPG_RT ignores half sp cost modifier

Fix: #1586
This implements RPG_RT compatible auto battle. I've designed auto battle to support different auto battle algorithms. The end goal will be Player ships a few algos that you can choose from. Game developers customizing player could also add their own to the
AutoBattle::CreateAlgorithmfactory function.This PR provides 3 algorithms:
RPG_RT- RPG_RT compatible including bugs - this is the defaultATTACK- RPG_RT, only physical attacks, bug fixes includedRPG_RT+- RPG_RT with bug fixes - Also open to further improvementsFor now I just added a
--autobattle-algocommand line parameter to select the algo, later this can probably be part ofScene_Settingsetc.. Or maybe even a custom save chunk.TODO
DynRPG Addresses
RPG_RT bugs ❗
reverse_stateflag, and so a skill which inflicts death on an ally would be highly ranked and probably used on a dead ally.