From 150dd7c6339d6bb8e14ebb2792e49efd0d9c64b4 Mon Sep 17 00:00:00 2001 From: Xavion3 Date: Tue, 19 Oct 2021 22:39:07 +1100 Subject: [PATCH 1/4] Add damage information to the debug menus --- include/battle.h | 1 + src/battle_ai_main.c | 8 ++++++-- src/battle_debug.c | 8 +++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/include/battle.h b/include/battle.h index 26c6b3e40a..2ceced61cd 100644 --- a/include/battle.h +++ b/include/battle.h @@ -596,6 +596,7 @@ struct BattleStruct bool8 spriteIgnore0Hp; struct Illusion illusion[MAX_BATTLERS_COUNT]; s8 aiFinalScore[MAX_BATTLERS_COUNT][MAX_BATTLERS_COUNT][MAX_MON_MOVES]; // AI, target, moves to make debugging easier + s32 aiSimulatedDamage[MAX_BATTLERS_COUNT][MAX_BATTLERS_COUNT][MAX_MON_MOVES]; // attacker, target, move to make debugging easier u8 soulheartBattlerId; u8 friskedBattler; // Frisk needs to identify 2 battlers in double battles. bool8 friskedAbility; // If identifies two mons, show the ability pop-up only once. diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index c5ed7d9a33..ecea5b2ca5 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -266,8 +266,10 @@ static u8 ChooseMoveOrAction_Singles(void) AI_THINKING_STRUCT->movesetIndex = 0; } - for (i = 0; i < MAX_MON_MOVES; i++) + for (i = 0; i < MAX_MON_MOVES; i++) { gBattleStruct->aiFinalScore[sBattler_AI][gBattlerTarget][i] = AI_THINKING_STRUCT->score[i]; + gBattleStruct->aiSimulatedDamage[sBattler_AI][gBattlerTarget][i] = AI_THINKING_STRUCT->simulatedDmg[sBattler_AI][gBattlerTarget][i]; + } // Check special AI actions. if (AI_THINKING_STRUCT->aiAction & AI_ACTION_FLEE) @@ -432,8 +434,10 @@ static u8 ChooseMoveOrAction_Doubles(void) } } - for (j = 0; j < MAX_MON_MOVES; j++) + for (j = 0; j < MAX_MON_MOVES; j++) { gBattleStruct->aiFinalScore[sBattler_AI][gBattlerTarget][j] = AI_THINKING_STRUCT->score[j]; + gBattleStruct->aiSimulatedDamage[sBattler_AI][gBattlerTarget][i] = AI_THINKING_STRUCT->simulatedDmg[sBattler_AI][gBattlerTarget][i]; + } } } diff --git a/src/battle_debug.c b/src/battle_debug.c index ce5aa4a97f..ff89207537 100644 --- a/src/battle_debug.c +++ b/src/battle_debug.c @@ -713,6 +713,12 @@ static void PutMovesPointsText(struct BattleDebugMenu *data) gBattleStruct->aiFinalScore[data->aiBattlerId][gSprites[data->aiIconSpriteIds[j]].data[0]][i], STR_CONV_MODE_RIGHT_ALIGN, 3); AddTextPrinterParameterized(data->aiMovesWindowId, 1, text, 83 + count * 54, i * 15, 0, NULL); + + ConvertIntToDecimalStringN(text, + gBattleStruct->aiSimulatedDamage[data->aiBattlerId][gSprites[data->aiIconSpriteIds[j]].data[0]][i], + STR_CONV_MODE_RIGHT_ALIGN, 3); + AddTextPrinterParameterized(data->aiMovesWindowId, 1, text, 110 + count * 54, i * 15, 0, NULL); + count++; } } @@ -780,7 +786,7 @@ static void Task_ShowAiPoints(u8 taskId) break; // Put text case 1: - winTemplate = CreateWindowTemplate(1, 0, 4, 27, 14, 15, 0x200); + winTemplate = CreateWindowTemplate(1, 0, 4, 30, 14, 15, 0x200); data->aiMovesWindowId = AddWindow(&winTemplate); PutWindowTilemap(data->aiMovesWindowId); PutMovesPointsText(data); From 055c1c47b7410d8d92085c4578dd60ab66ffd788 Mon Sep 17 00:00:00 2001 From: Xavion3 Date: Tue, 19 Oct 2021 23:00:04 +1100 Subject: [PATCH 2/4] Fix double battles damage scoring --- src/battle_ai_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index ecea5b2ca5..b830507a11 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -436,7 +436,7 @@ static u8 ChooseMoveOrAction_Doubles(void) for (j = 0; j < MAX_MON_MOVES; j++) { gBattleStruct->aiFinalScore[sBattler_AI][gBattlerTarget][j] = AI_THINKING_STRUCT->score[j]; - gBattleStruct->aiSimulatedDamage[sBattler_AI][gBattlerTarget][i] = AI_THINKING_STRUCT->simulatedDmg[sBattler_AI][gBattlerTarget][i]; + gBattleStruct->aiSimulatedDamage[sBattler_AI][gBattlerTarget][j] = AI_THINKING_STRUCT->simulatedDmg[sBattler_AI][gBattlerTarget][j]; } } } From 4673ff30e47f3a08a3f7ad2418c36aad9a508014 Mon Sep 17 00:00:00 2001 From: Xavion3 Date: Tue, 19 Oct 2021 23:00:40 +1100 Subject: [PATCH 3/4] Allow the AI to see damage against it's partner --- src/battle_ai_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index b830507a11..a2d97f785e 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -177,10 +177,10 @@ void BattleAI_SetupAIData(u8 defaultScoreMoves) } sBattler_AI = gActiveBattler; - // Simulate dmg for all AI moves against all opposing targets + // Simulate dmg for all AI moves against all other targets for (gBattlerTarget = 0; gBattlerTarget < gBattlersCount; gBattlerTarget++) { - if (GET_BATTLER_SIDE2(sBattler_AI) == GET_BATTLER_SIDE2(gBattlerTarget)) + if (sBattler_AI == gBattlerTarget) continue; for (i = 0; i < MAX_MON_MOVES; i++) { From 6a16813ce8ca3887d02b329c869cd3f20c139431 Mon Sep 17 00:00:00 2001 From: Xavion3 Date: Tue, 19 Oct 2021 23:01:07 +1100 Subject: [PATCH 4/4] Rename menu option to be more appropriate to changed info --- src/battle_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_debug.c b/src/battle_debug.c index ff89207537..ef78f13fd4 100644 --- a/src/battle_debug.c +++ b/src/battle_debug.c @@ -228,7 +228,7 @@ static const u8 sText_InDoubles[] = _("In Doubles"); static const u8 sText_HpAware[] = _("HP aware"); static const u8 sText_Unknown[] = _("Unknown"); static const u8 sText_InLove[] = _("In Love"); -static const u8 sText_AIMovePts[] = _("AI Move Pts"); +static const u8 sText_AIMovePts[] = _("AI Pts/Dmg"); static const u8 sText_AiKnowledge[] = _("AI Info"); static const u8 sText_EffectOverride[] = _("Effect Override");