diff --git a/include/constants/item.h b/include/constants/item.h index 9b574417a..a32f4545a 100644 --- a/include/constants/item.h +++ b/include/constants/item.h @@ -19,7 +19,7 @@ #define REPEL_LURE_MASK (1 << 15) #define IS_LAST_USED_LURE(var) (var & REPEL_LURE_MASK) #define REPEL_LURE_STEPS(var) (var & (REPEL_LURE_MASK - 1)) -#define LURE_STEPS(var) (IS_LAST_USED_LURE(var) ? REPEL_LURE_STEPS(var) : 0) -#define REPEL_STEPS(var) (!IS_LAST_USED_LURE(var) ? REPEL_LURE_STEPS(var) : 0) +#define LURE_STEP_COUNT (IS_LAST_USED_LURE(VarGet(VAR_REPEL_STEP_COUNT)) ? REPEL_LURE_STEPS(VarGet(VAR_REPEL_STEP_COUNT)) : 0) +#define REPEL_STEP_COUNT (!IS_LAST_USED_LURE(VarGet(VAR_REPEL_STEP_COUNT)) ? REPEL_LURE_STEPS(VarGet(VAR_REPEL_STEP_COUNT)) : 0) #endif // GUARD_ITEM_CONSTANTS_H diff --git a/include/constants/vars.h b/include/constants/vars.h index a7a229a61..8128b6f32 100644 --- a/include/constants/vars.h +++ b/include/constants/vars.h @@ -47,7 +47,7 @@ // general purpose vars #define VAR_RECYCLE_GOODS 0x4020 -#define VAR_REPEL_LURE_STEP_COUNT 0x4021 +#define VAR_REPEL_STEP_COUNT 0x4021 #define VAR_ICE_STEP_COUNT 0x4022 #define VAR_STARTER_MON 0x4023 // 0=Treecko, 1=Torchic, 2=Mudkip #define VAR_MIRAGE_RND_H 0x4024 diff --git a/src/item_use.c b/src/item_use.c index 995798331..e3d65d5a3 100644 --- a/src/item_use.c +++ b/src/item_use.c @@ -848,7 +848,7 @@ static void RemoveUsedItem(void) void ItemUseOutOfBattle_Repel(u8 taskId) { - if (REPEL_STEPS(VarGet(VAR_REPEL_LURE_STEP_COUNT)) == 0) + if (REPEL_STEP_COUNT == 0) gTasks[taskId].func = Task_StartUseRepel; else if (!InBattlePyramid()) DisplayItemMessage(taskId, FONT_NORMAL, gText_RepelEffectsLingered, CloseItemMessage); @@ -872,7 +872,7 @@ static void Task_UseRepel(u8 taskId) { if (!IsSEPlaying()) { - VarSet(VAR_REPEL_LURE_STEP_COUNT, ItemId_GetHoldEffectParam(gSpecialVar_ItemId)); + VarSet(VAR_REPEL_STEP_COUNT, ItemId_GetHoldEffectParam(gSpecialVar_ItemId)); #if I_VAR_LAST_REPEL_LURE_USED != 0 VarSet(I_VAR_LAST_REPEL_LURE_USED, gSpecialVar_ItemId); #endif @@ -886,13 +886,13 @@ static void Task_UseRepel(u8 taskId) void HandleUseExpiredRepel(void) { #if I_VAR_LAST_REPEL_LURE_USED != 0 - VarSet(VAR_REPEL_LURE_STEP_COUNT, ItemId_GetHoldEffectParam(VarGet(I_VAR_LAST_REPEL_LURE_USED))); + VarSet(VAR_REPEL_STEP_COUNT, ItemId_GetHoldEffectParam(VarGet(I_VAR_LAST_REPEL_LURE_USED))); #endif } void ItemUseOutOfBattle_Lure(u8 taskId) { - if (LURE_STEPS(VarGet(VAR_REPEL_LURE_STEP_COUNT)) == 0) + if (LURE_STEP_COUNT == 0) gTasks[taskId].func = Task_StartUseLure; else if (!InBattlePyramid()) DisplayItemMessage(taskId, FONT_NORMAL, gText_LureEffectsLingered, CloseItemMessage); @@ -916,7 +916,7 @@ static void Task_UseLure(u8 taskId) { if (!IsSEPlaying()) { - VarSet(VAR_REPEL_LURE_STEP_COUNT, ItemId_GetHoldEffectParam(gSpecialVar_ItemId) | REPEL_LURE_MASK); + VarSet(VAR_REPEL_STEP_COUNT, ItemId_GetHoldEffectParam(gSpecialVar_ItemId) | REPEL_LURE_MASK); #if I_VAR_LAST_REPEL_LURE_USED != 0 VarSet(I_VAR_LAST_REPEL_LURE_USED, gSpecialVar_ItemId); #endif @@ -931,7 +931,7 @@ static void Task_UseLure(u8 taskId) void HandleUseExpiredLure(void) { #if I_VAR_LAST_REPEL_LURE_USED != 0 - VarSet(VAR_REPEL_LURE_STEP_COUNT, ItemId_GetHoldEffectParam(VarGet(I_VAR_LAST_REPEL_LURE_USED)) | REPEL_LURE_MASK); + VarSet(VAR_REPEL_STEP_COUNT, ItemId_GetHoldEffectParam(VarGet(I_VAR_LAST_REPEL_LURE_USED)) | REPEL_LURE_MASK); #endif } diff --git a/src/pokemon.c b/src/pokemon.c index 19498810a..2e6cee221 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -3308,6 +3308,8 @@ void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV, if (CheckBagHasItem(ITEM_SHINY_CHARM, 1)) totalRerolls += I_SHINY_CHARM_REROLLS; + if (LURE_STEP_COUNT != 0) + totalRerolls += 1; while (GET_SHINY_VALUE(value, personality) >= SHINY_ODDS && totalRerolls > 0) { diff --git a/src/wild_encounter.c b/src/wild_encounter.c index 2a68f4e4d..bbf444d3a 100644 --- a/src/wild_encounter.c +++ b/src/wild_encounter.c @@ -212,7 +212,7 @@ static u8 ChooseWildMonIndex_Land(void) else wildMonIndex = 11; - if (LURE_STEPS(VarGet(VAR_REPEL_LURE_STEP_COUNT)) && (Random() % 10 < 2)) + if (LURE_STEP_COUNT != 0 && (Random() % 10 < 2)) swap = TRUE; if (swap) @@ -239,7 +239,7 @@ static u8 ChooseWildMonIndex_WaterRock(void) else wildMonIndex = 4; - if (LURE_STEPS(VarGet(VAR_REPEL_LURE_STEP_COUNT)) && (Random() % 10 < 2)) + if (LURE_STEP_COUNT != 0 && (Random() % 10 < 2)) swap = TRUE; if (swap) @@ -256,7 +256,7 @@ static u8 ChooseWildMonIndex_Fishing(u8 rod) u8 rand = Random() % max(max(ENCOUNTER_CHANCE_FISHING_MONS_OLD_ROD_TOTAL, ENCOUNTER_CHANCE_FISHING_MONS_GOOD_ROD_TOTAL), ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_TOTAL); - if (LURE_STEPS(VarGet(VAR_REPEL_LURE_STEP_COUNT)) && (Random() % 10 < 2)) + if (LURE_STEP_COUNT != 0 && (Random() % 10 < 2)) swap = TRUE; switch (rod) @@ -556,7 +556,7 @@ static bool8 DoWildEncounterRateTest(u32 encounterRate, bool8 ignoreAbility) encounterRate = encounterRate * 80 / 100; ApplyFluteEncounterRateMod(&encounterRate); ApplyCleanseTagEncounterRateMod(&encounterRate); - if (LURE_STEPS(VarGet(VAR_REPEL_LURE_STEP_COUNT)) != 0) + if (LURE_STEP_COUNT != 0) encounterRate *= 2; if (!ignoreAbility && !GetMonData(&gPlayerParty[0], MON_DATA_SANITY_IS_EGG)) { @@ -929,7 +929,7 @@ u16 GetLocalWaterMon(void) bool8 UpdateRepelCounter(void) { - u16 repelLureVar = VarGet(VAR_REPEL_LURE_STEP_COUNT); + u16 repelLureVar = VarGet(VAR_REPEL_STEP_COUNT); u16 steps = REPEL_LURE_STEPS(repelLureVar); bool32 isLure = IS_LAST_USED_LURE(repelLureVar); @@ -943,7 +943,7 @@ bool8 UpdateRepelCounter(void) steps--; if (!isLure) { - VarSet(VAR_REPEL_LURE_STEP_COUNT, steps); + VarSet(VAR_REPEL_STEP_COUNT, steps); if (steps == 0) { ScriptContext_SetupScript(EventScript_RepelWoreOff); @@ -952,7 +952,7 @@ bool8 UpdateRepelCounter(void) } else { - VarSet(VAR_REPEL_LURE_STEP_COUNT, steps | REPEL_LURE_MASK); + VarSet(VAR_REPEL_STEP_COUNT, steps | REPEL_LURE_MASK); if (steps == 0) { ScriptContext_SetupScript(EventScript_LureWoreOff); @@ -968,7 +968,7 @@ static bool8 IsWildLevelAllowedByRepel(u8 wildLevel) { u8 i; - if (!REPEL_STEPS(VarGet(VAR_REPEL_LURE_STEP_COUNT))) + if (!REPEL_STEP_COUNT) return TRUE; for (i = 0; i < PARTY_SIZE; i++)