Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed EVO_OVERWORLD_STEPS to use an EWRAM variable #5047

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions data/scripts/debug.inc
Original file line number Diff line number Diff line change
Expand Up @@ -439,4 +439,14 @@ Debug_EventScript_InflictStatus1_Text_Freeze:
Debug_EventScript_InflictStatus1_Text_Frostbite:
.string "Frostbite$"

Debug_EventScript_EWRAMCounters::
callnative CheckEWRAMCounters
msgbox Debug_EventScript_EWRAMCounters_Text, MSGBOX_DEFAULT
release
end

Debug_EventScript_EWRAMCounters_Text::
.string "Follower Steps: {STR_VAR_1}.\n"
.string "Fishing Chain: {STR_VAR_2}.$"

.endif
2 changes: 1 addition & 1 deletion include/constants/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@
#define EVO_RECOIL_DAMAGE_FEMALE 49 // Pokémon levels up after having suffered specified amount of non-fainting recoil damage as a female
#define EVO_ITEM_COUNT_999 50 // Pokémon levels up after trainer has collected 999 of a specific item
#define EVO_DEFEAT_WITH_ITEM 51 // Pokémon levels up after having defeat 3 Pokémon of the same species holding the specified item
#define EVO_OVERWORLD_STEPS 52 // Pokémon levels up after having taken a specific amount of steps in the overworld
#define EVO_OVERWORLD_STEPS 52 // Pokémon levels up after having taken a specific amount of steps in the overworld (or as the party lead if OW_FOLLOWERS_ENABLED is FALSE) without switching

// Evolution 'modes,' for GetEvolutionTargetSpecies
#define EVO_MODE_NORMAL 0
Expand Down
1 change: 1 addition & 0 deletions include/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,7 @@ extern struct Pokemon gPlayerParty[PARTY_SIZE];
extern u8 gEnemyPartyCount;
extern struct Pokemon gEnemyParty[PARTY_SIZE];
extern struct SpriteTemplate gMultiuseSpriteTemplate;
extern u16 gFollowerSteps;

extern const struct MoveInfo gMovesInfo[];
extern const u8 gFacilityClassToPicIndex[];
Expand Down
17 changes: 17 additions & 0 deletions src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ enum UtilDebugMenu
DEBUG_UTIL_MENU_ITEM_CHEAT,
DEBUG_UTIL_MENU_ITEM_EXPANSION_VER,
DEBUG_UTIL_MENU_ITEM_BERRY_FUNCTIONS,
DEBUG_UTIL_MENU_ITEM_EWRAM_COUNTERS,
};

enum GivePCBagDebugMenu
Expand Down Expand Up @@ -374,6 +375,7 @@ static void DebugAction_Util_Player_Id(u8 taskId);
static void DebugAction_Util_CheatStart(u8 taskId);
static void DebugAction_Util_ExpansionVersion(u8 taskId);
static void DebugAction_Util_BerryFunctions(u8 taskId);
static void DebugAction_Util_CheckEWRAMCounters(u8 taskId);

static void DebugAction_OpenPCBagFillMenu(u8 taskId);
static void DebugAction_PCBag_Fill_PCBoxes_Fast(u8 taskId);
Expand Down Expand Up @@ -476,6 +478,7 @@ extern const u8 Debug_CheckSaveBlock[];
extern const u8 Debug_CheckROMSpace[];
extern const u8 Debug_BoxFilledMessage[];
extern const u8 Debug_ShowExpansionVersion[];
extern const u8 Debug_EventScript_EWRAMCounters[];

extern const u8 Debug_BerryPestsDisabled[];
extern const u8 Debug_BerryWeedsDisabled[];
Expand Down Expand Up @@ -532,6 +535,7 @@ static const u8 sDebugText_Util_Player_Id[] = _("New Trainer ID")
static const u8 sDebugText_Util_CheatStart[] = _("Cheat start");
static const u8 sDebugText_Util_ExpansionVersion[] = _("Expansion Version");
static const u8 sDebugText_Util_BerryFunctions[] = _("Berry Functions…{CLEAR_TO 110}{RIGHT_ARROW}");
static const u8 sDebugText_Util_EWRAMCounters[] = _("EWRAM Counters…{CLEAR_TO 110}{RIGHT_ARROW}");
// PC/Bag Menu
static const u8 sDebugText_PCBag_Fill[] = _("Fill…{CLEAR_TO 110}{RIGHT_ARROW}");
static const u8 sDebugText_PCBag_Fill_Pc_Fast[] = _("Fill PC Boxes Fast");
Expand Down Expand Up @@ -720,6 +724,7 @@ static const struct ListMenuItem sDebugMenu_Items_Utilities[] =
[DEBUG_UTIL_MENU_ITEM_CHEAT] = {sDebugText_Util_CheatStart, DEBUG_UTIL_MENU_ITEM_CHEAT},
[DEBUG_UTIL_MENU_ITEM_EXPANSION_VER] = {sDebugText_Util_ExpansionVersion, DEBUG_UTIL_MENU_ITEM_EXPANSION_VER},
[DEBUG_UTIL_MENU_ITEM_BERRY_FUNCTIONS] = {sDebugText_Util_BerryFunctions, DEBUG_UTIL_MENU_ITEM_BERRY_FUNCTIONS},
[DEBUG_UTIL_MENU_ITEM_EWRAM_COUNTERS] = {sDebugText_Util_EWRAMCounters, DEBUG_UTIL_MENU_ITEM_EWRAM_COUNTERS},
};

static const struct ListMenuItem sDebugMenu_Items_PCBag[] =
Expand Down Expand Up @@ -889,6 +894,7 @@ static void (*const sDebugMenu_Actions_Utilities[])(u8) =
[DEBUG_UTIL_MENU_ITEM_CHEAT] = DebugAction_Util_CheatStart,
[DEBUG_UTIL_MENU_ITEM_EXPANSION_VER] = DebugAction_Util_ExpansionVersion,
[DEBUG_UTIL_MENU_ITEM_BERRY_FUNCTIONS] = DebugAction_Util_BerryFunctions,
[DEBUG_UTIL_MENU_ITEM_EWRAM_COUNTERS] = DebugAction_Util_CheckEWRAMCounters,
};

static void (*const sDebugMenu_Actions_PCBag[])(u8) =
Expand Down Expand Up @@ -5113,4 +5119,15 @@ static void DebugAction_Party_ClearParty(u8 taskId)
Debug_DestroyMenu_Full(taskId);
}

void CheckEWRAMCounters(struct ScriptContext *ctx)
{
ConvertIntToDecimalStringN(gStringVar1, gFollowerSteps, STR_CONV_MODE_LEFT_ALIGN, 5);
ConvertIntToDecimalStringN(gStringVar2, gChainFishingDexNavStreak, STR_CONV_MODE_LEFT_ALIGN, 5);
}

static void DebugAction_Util_CheckEWRAMCounters(u8 taskId)
{
Debug_DestroyMenu_Full_Script(taskId, Debug_EventScript_EWRAMCounters);
}

#endif //DEBUG_OVERWORLD_MENU == TRUE
26 changes: 5 additions & 21 deletions src/field_control_avatar.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static bool8 TryStartWarpEventScript(struct MapPosition *, u16);
static bool8 TryStartMiscWalkingScripts(u16);
static bool8 TryStartStepCountScript(u16);
static void UpdateFriendshipStepCounter(void);
static void UpdateLetsGoEvolutionTracker(void);
static void UpdateFollowerStepCounter(void);
#if OW_POISON_DAMAGE < GEN_5
static bool8 UpdatePoisonStepCounter(void);
#endif // OW_POISON_DAMAGE
Expand Down Expand Up @@ -566,7 +566,7 @@ static bool8 TryStartStepCountScript(u16 metatileBehavior)
IncrementRematchStepCounter();
UpdateFriendshipStepCounter();
UpdateFarawayIslandStepCounter();
UpdateLetsGoEvolutionTracker();
UpdateFollowerStepCounter();

if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_FORCED_MOVE) && !MetatileBehavior_IsForcedMovementTile(metatileBehavior))
{
Expand Down Expand Up @@ -660,26 +660,10 @@ static void UpdateFriendshipStepCounter(void)
}
}

static void UpdateLetsGoEvolutionTracker(void)
static void UpdateFollowerStepCounter(void)
{
u32 i;
u16 count;
struct Pokemon *followingMon = GetFirstLiveMon();
const struct Evolution *evolutions = GetSpeciesEvolutions(GetMonData(followingMon, MON_DATA_SPECIES));

if (evolutions == NULL)
return;

for (i = 0; evolutions[i].method != EVOLUTIONS_END; i++)
{
if (evolutions[i].method != EVO_OVERWORLD_STEPS || SanitizeSpeciesId(evolutions[i].targetSpecies) == SPECIES_NONE)
continue;

// We only have 10 bits to use
count = min(1023, GetMonData(followingMon, MON_DATA_EVOLUTION_TRACKER) + 1);
SetMonData(followingMon, MON_DATA_EVOLUTION_TRACKER, &count);
return;
}
if (gPlayerPartyCount > 0 && gFollowerSteps < (u16)-1)
gFollowerSteps++;
}

void ClearPoisonStepCounter(void)
Expand Down
3 changes: 3 additions & 0 deletions src/party_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2987,6 +2987,9 @@ static void CB2_ReturnToPartyMenuFromSummaryScreen(void)

static void CursorCb_Switch(u8 taskId)
{
// Reset follower steps when the party leader is changed
if (gPartyMenu.slotId == 0 || gPartyMenu.slotId2 == 0)
gFollowerSteps = 0;
PlaySE(SE_SELECT);
gPartyMenu.action = PARTY_ACTION_SWITCH;
PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[1]);
Expand Down
3 changes: 2 additions & 1 deletion src/pokemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ EWRAM_DATA struct Pokemon gEnemyParty[PARTY_SIZE] = {0};
EWRAM_DATA struct SpriteTemplate gMultiuseSpriteTemplate = {0};
EWRAM_DATA static struct MonSpritesGfxManager *sMonSpritesGfxManagers[MON_SPR_GFX_MANAGERS_COUNT] = {NULL};
EWRAM_DATA static u8 sTriedEvolving = 0;
EWRAM_DATA u16 gFollowerSteps = 0;

#include "data/moves_info.h"
#include "data/abilities.h"
Expand Down Expand Up @@ -4708,7 +4709,7 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 mode, u16 evolutionItem, s
targetSpecies = evolutions[i].targetSpecies;
break;
case EVO_OVERWORLD_STEPS:
if (evolutionTracker >= evolutions[i].param)
if (mon == GetFirstLiveMon() && gFollowerSteps >= evolutions[i].param)
targetSpecies = evolutions[i].targetSpecies;
break;
}
Expand Down
13 changes: 13 additions & 0 deletions src/pokemon_storage_system.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "dma3.h"
#include "dynamic_placeholder_text_util.h"
#include "event_data.h"
#include "event_object_movement.h"
#include "field_screen_effect.h"
#include "field_weather.h"
#include "fldeff_misc.h"
Expand Down Expand Up @@ -6412,9 +6413,15 @@ static void RefreshDisplayMon(void)
static void SetMovingMonData(u8 boxId, u8 position)
{
if (boxId == TOTAL_BOXES_COUNT)
{
sStorage->movingMon = gPlayerParty[sCursorPosition];
if (&gPlayerParty[sCursorPosition] == GetFirstLiveMon())
gFollowerSteps = 0;
}
else
{
BoxMonAtToMon(boxId, position, &sStorage->movingMon);
}

PurgeMonOrBoxMon(boxId, position);
sMovingMonOrigBoxId = boxId;
Expand All @@ -6427,9 +6434,15 @@ static void SetPlacedMonData(u8 boxId, u8 position)
HealPokemon(&sStorage->movingMon);

if (boxId == TOTAL_BOXES_COUNT)
{
gPlayerParty[position] = sStorage->movingMon;
if (&gPlayerParty[position] == GetFirstLiveMon())
gFollowerSteps = 0;
}
else
{
SetBoxMonAt(boxId, position, &sStorage->movingMon.box);
}
}

static void PurgeMonOrBoxMon(u8 boxId, u8 position)
Expand Down
3 changes: 0 additions & 3 deletions test/species.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,6 @@ TEST("No species has two evolutions that use the evolution tracker")
#ifdef EVO_DEFEAT_WITH_ITEM
|| evolutions[i].method == EVO_DEFEAT_WITH_ITEM
#endif //EVO_DEFEAT_WITH_ITEM
#ifdef EVO_OVERWORLD_STEPS
|| evolutions[i].method == EVO_OVERWORLD_STEPS
#endif //EVO_OVERWORLD_STEPS
)
evolutionTrackerEvolutions++;

Expand Down
Loading