From 203bbe826f601ca4e899d96407a0b1e18ce5d44e Mon Sep 17 00:00:00 2001 From: Icebound777 Date: Thu, 7 Nov 2024 18:50:22 +0100 Subject: [PATCH] fix: inverted logic for fleeing battles Variable and enum names related to allowing to run from battle are logically inverted. This fixes that --- include/npc.h | 2 +- src/battle/btl_states_actions.c | 6 +++--- src/battle/btl_states_menus.c | 2 +- src/encounter.c | 2 +- src/encounter_api.c | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/npc.h b/include/npc.h index b1d822e1e1..bf89bcf020 100644 --- a/include/npc.h +++ b/include/npc.h @@ -390,7 +390,7 @@ typedef struct EncounterStatus { /* 0x00D */ char unk_0D; /* 0x00E */ s16 coinsEarned; /* valid after battle */ /* 0x010 */ s8 instigatorValue; - /* 0x011 */ s8 allowFleeing; + /* 0x011 */ s8 disallowFleeing; /* 0x012 */ s8 scriptedBattle; ///< battle started by StartBattle but not by encounter /* 0x013 */ s8 dropWhackaBump; /* 0x014 */ s32 songID; diff --git a/src/battle/btl_states_actions.c b/src/battle/btl_states_actions.c index 059c2044b1..4490d6ce05 100644 --- a/src/battle/btl_states_actions.c +++ b/src/battle/btl_states_actions.c @@ -273,9 +273,9 @@ void btl_state_update_normal_start(void) { battleStatus->jumpCharge = 0; battleStatus->unk_98 = 0; battleStatus->hpDrainCount = 0; - gBattleStatus.flags2 |= BS_FLAGS2_CANT_FLEE; - if (currentEncounter->allowFleeing) { - gBattleStatus.flags2 &= ~BS_FLAGS2_CANT_FLEE; + gBattleStatus.flags2 |= BS_FLAGS2_CAN_FLEE; + if (currentEncounter->disallowFleeing) { + gBattleStatus.flags2 &= ~BS_FLAGS2_CAN_FLEE; } battleStatus->endBattleFadeOutRate = 10; battleStatus->waitForState = BATTLE_STATE_0; diff --git a/src/battle/btl_states_menus.c b/src/battle/btl_states_menus.c index 68ce8b2a42..7b4f2bcd9f 100644 --- a/src/battle/btl_states_menus.c +++ b/src/battle/btl_states_menus.c @@ -3581,7 +3581,7 @@ void btl_state_update_player_menu(void) { D_802AD690[entryIdx] = 1; D_802AD658[entryIdx] = BattleMenu_LeftJustMessages[BTL_MENU_TYPE_RUN_AWAY]; D_802AD6C0[entryIdx] = MSG_Menus_Action_RunAway; - if (!(gBattleStatus.flags2 & BS_FLAGS2_CANT_FLEE)) { + if (!(gBattleStatus.flags2 & BS_FLAGS2_CAN_FLEE)) { D_802AD640[entryIdx] = battle_menu_FleeHudScripts.disabled; D_802AD690[entryIdx] = 0; D_802AD6A8[entryIdx] = 1; diff --git a/src/encounter.c b/src/encounter.c index c6e2b7e380..48e84b70d7 100644 --- a/src/encounter.c +++ b/src/encounter.c @@ -522,7 +522,7 @@ void update_encounters_neutral(void) { currentEncounter->songID = -1; currentEncounter->unk_18 = -1; currentEncounter->hitType = 0; - currentEncounter->allowFleeing = FALSE; + currentEncounter->disallowFleeing = FALSE; currentEncounter->dropWhackaBump = FALSE; currentEncounter->flags &= ~ENCOUNTER_FLAG_THUMBS_UP; currentEncounter->flags &= ~ENCOUNTER_FLAG_CANT_SKIP_WIN_DELAY; diff --git a/src/encounter_api.c b/src/encounter_api.c index f737f4f1e0..207af9cdb5 100644 --- a/src/encounter_api.c +++ b/src/encounter_api.c @@ -206,7 +206,7 @@ void start_battle(Evt* script, s32 songID) { currentEncounter->curEnemy = enemy; currentEncounter->curEncounter = currentEncounter->encounterList[enemy->encounterIndex]; currentEncounter->firstStrikeType = FIRST_STRIKE_NONE; - currentEncounter->allowFleeing = FALSE; + currentEncounter->disallowFleeing = FALSE; currentEncounter->songID = songID; currentEncounter->unk_18 = -1; @@ -277,7 +277,7 @@ API_CALLABLE(StartBossBattle) { currentEncounter->curEnemy = enemy; currentEncounter->curEncounter = currentEncounter->encounterList[enemy->encounterIndex]; currentEncounter->firstStrikeType = FIRST_STRIKE_NONE; - currentEncounter->allowFleeing = TRUE; + currentEncounter->disallowFleeing = TRUE; currentEncounter->songID = songID; currentEncounter->unk_18 = -1; @@ -326,7 +326,7 @@ API_CALLABLE(SetBattleMusic) { Bytecode songID = evt_get_variable(script, *args++); EncounterStatus* currentEncounter = &gCurrentEncounter; - currentEncounter->allowFleeing = TRUE; + currentEncounter->disallowFleeing = TRUE; currentEncounter->songID = songID; currentEncounter->unk_18 = -1; return ApiStatus_DONE2;