Implemented Lures using the same vars as repels

This commit is contained in:
Eduardo Quezada 2022-09-11 19:48:27 -04:00
parent e3c19f5df5
commit 2d78ac0192
10 changed files with 175 additions and 39 deletions

View File

@ -19,7 +19,7 @@ EventScript_UsedRepel:
bufferitemname 0, VAR_LAST_REPEL_USED bufferitemname 0, VAR_LAST_REPEL_USED
playse SE_REPEL playse SE_REPEL
lock lock
msgbox Text_UsedNewRepel, MSGBOX_SIGN msgbox Text_UsedNewRepelLure, MSGBOX_SIGN
removeitem VAR_LAST_REPEL_USED, 1 removeitem VAR_LAST_REPEL_USED, 1
waitse waitse
callnative HandleUseExpiredRepel callnative HandleUseExpiredRepel
@ -33,6 +33,41 @@ Text_UseAnother::
.string "REPEL's effect wore off!\n" .string "REPEL's effect wore off!\n"
.string "Use another?$" .string "Use another?$"
Text_UsedNewRepel:: Text_UsedNewRepelLure::
.string "{PLAYER} used the\n" .string "{PLAYER} used the\n"
.string "{STR_VAR_1}.$" .string "{STR_VAR_1}.$"
EventScript_LureWoreOff::
checkitem VAR_LAST_REPEL_USED, 1
compare VAR_RESULT, TRUE
goto_if_eq EventScript_LureUseAnother
lock
msgbox Text_LureWoreOff, MSGBOX_SIGN
release
end
EventScript_LureUseAnother:
lock
msgbox Text_UseAnotherLure, MSGBOX_YESNO
compare VAR_RESULT, YES
goto_if_eq EventScript_UsedLure
release
end
EventScript_UsedLure:
bufferitemname 0, VAR_LAST_REPEL_USED
playse SE_REPEL
lock
msgbox Text_UsedNewRepelLure, MSGBOX_SIGN
removeitem VAR_LAST_REPEL_USED, 1
waitse
callnative HandleUseExpiredLure
release
end
Text_LureWoreOff:
.string "Lure's effect wore off…$"
Text_UseAnotherLure::
.string "Lure's effect wore off!\n"
.string "Use another?$"

View File

@ -16,4 +16,10 @@
#define KEYITEMS_POCKET 4 #define KEYITEMS_POCKET 4
#define POCKETS_COUNT 5 #define POCKETS_COUNT 5
#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)
#endif // GUARD_ITEM_CONSTANTS_H #endif // GUARD_ITEM_CONSTANTS_H

View File

@ -47,7 +47,7 @@
// general purpose vars // general purpose vars
#define VAR_RECYCLE_GOODS 0x4020 #define VAR_RECYCLE_GOODS 0x4020
#define VAR_REPEL_STEP_COUNT 0x4021 #define VAR_REPEL_LURE_STEP_COUNT 0x4021
#define VAR_ICE_STEP_COUNT 0x4022 #define VAR_ICE_STEP_COUNT 0x4022
#define VAR_STARTER_MON 0x4023 // 0=Treecko, 1=Torchic, 2=Mudkip #define VAR_STARTER_MON 0x4023 // 0=Treecko, 1=Torchic, 2=Mudkip
#define VAR_MIRAGE_RND_H 0x4024 #define VAR_MIRAGE_RND_H 0x4024

View File

@ -20,6 +20,7 @@ void ItemUseOutOfBattle_PPUp(u8);
void ItemUseOutOfBattle_RareCandy(u8); void ItemUseOutOfBattle_RareCandy(u8);
void ItemUseOutOfBattle_TMHM(u8); void ItemUseOutOfBattle_TMHM(u8);
void ItemUseOutOfBattle_Repel(u8); void ItemUseOutOfBattle_Repel(u8);
void ItemUseOutOfBattle_Lure(u8);
void ItemUseOutOfBattle_EscapeRope(u8); void ItemUseOutOfBattle_EscapeRope(u8);
void ItemUseOutOfBattle_BlackWhiteFlute(u8); void ItemUseOutOfBattle_BlackWhiteFlute(u8);
void ItemUseOutOfBattle_EvolutionStone(u8); void ItemUseOutOfBattle_EvolutionStone(u8);

View File

@ -936,6 +936,7 @@ extern const u8 gText_BootedUpTM[];
extern const u8 gText_TMHMContainedVar1[]; extern const u8 gText_TMHMContainedVar1[];
extern const u8 gText_PlayerUsedVar2[]; extern const u8 gText_PlayerUsedVar2[];
extern const u8 gText_RepelEffectsLingered[]; extern const u8 gText_RepelEffectsLingered[];
extern const u8 gText_LureEffectsLingered[];
extern const u8 gText_UsedVar2WildLured[]; extern const u8 gText_UsedVar2WildLured[];
extern const u8 gText_UsedVar2WildRepelled[]; extern const u8 gText_UsedVar2WildRepelled[];
extern const u8 gText_BoxFull[]; extern const u8 gText_BoxFull[];

View File

@ -1565,7 +1565,7 @@ const struct Item gItems[] =
.description = sLureDesc, .description = sLureDesc,
.pocket = POCKET_ITEMS, .pocket = POCKET_ITEMS,
.type = ITEM_USE_BAG_MENU, .type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_CannotUse, .fieldUseFunc = ItemUseOutOfBattle_Lure,
.secondaryId = 0, .secondaryId = 0,
.flingPower = 30, .flingPower = 30,
}, },
@ -1579,7 +1579,7 @@ const struct Item gItems[] =
.description = sSuperLureDesc, .description = sSuperLureDesc,
.pocket = POCKET_ITEMS, .pocket = POCKET_ITEMS,
.type = ITEM_USE_BAG_MENU, .type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_CannotUse, .fieldUseFunc = ItemUseOutOfBattle_Lure,
.secondaryId = 0, .secondaryId = 0,
.flingPower = 30, .flingPower = 30,
}, },
@ -1593,7 +1593,7 @@ const struct Item gItems[] =
.description = sMaxLureDesc, .description = sMaxLureDesc,
.pocket = POCKET_ITEMS, .pocket = POCKET_ITEMS,
.type = ITEM_USE_BAG_MENU, .type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_CannotUse, .fieldUseFunc = ItemUseOutOfBattle_Lure,
.secondaryId = 0, .secondaryId = 0,
.flingPower = 30, .flingPower = 30,
}, },

View File

@ -952,8 +952,3 @@ u8 ItemId_GetFlingPower(u16 itemId)
{ {
return gItems[SanitizeItemId(itemId)].flingPower; return gItems[SanitizeItemId(itemId)].flingPower;
} }
void HandleUseExpiredRepel(void)
{
VarSet(VAR_REPEL_STEP_COUNT, ItemId_GetHoldEffectParam(VarGet(VAR_LAST_REPEL_USED)));
}

View File

@ -67,7 +67,9 @@ static void Task_ShowTMHMContainedMessage(u8);
static void UseTMHMYesNo(u8); static void UseTMHMYesNo(u8);
static void UseTMHM(u8); static void UseTMHM(u8);
static void Task_StartUseRepel(u8); static void Task_StartUseRepel(u8);
static void Task_StartUseLure(u8 taskId);
static void Task_UseRepel(u8); static void Task_UseRepel(u8);
static void Task_UseLure(u8 taskId);
static void Task_CloseCantUseKeyItemMessage(u8); static void Task_CloseCantUseKeyItemMessage(u8);
static void SetDistanceOfClosestHiddenItem(u8, s16, s16); static void SetDistanceOfClosestHiddenItem(u8, s16, s16);
static void CB2_OpenPokeblockFromBag(void); static void CB2_OpenPokeblockFromBag(void);
@ -846,7 +848,7 @@ static void RemoveUsedItem(void)
void ItemUseOutOfBattle_Repel(u8 taskId) void ItemUseOutOfBattle_Repel(u8 taskId)
{ {
if (VarGet(VAR_REPEL_STEP_COUNT) == 0) if (REPEL_STEPS(VarGet(VAR_REPEL_LURE_STEP_COUNT)) == 0)
gTasks[taskId].func = Task_StartUseRepel; gTasks[taskId].func = Task_StartUseRepel;
else if (!InBattlePyramid()) else if (!InBattlePyramid())
DisplayItemMessage(taskId, FONT_NORMAL, gText_RepelEffectsLingered, CloseItemMessage); DisplayItemMessage(taskId, FONT_NORMAL, gText_RepelEffectsLingered, CloseItemMessage);
@ -870,7 +872,7 @@ static void Task_UseRepel(u8 taskId)
{ {
if (!IsSEPlaying()) if (!IsSEPlaying())
{ {
VarSet(VAR_REPEL_STEP_COUNT, ItemId_GetHoldEffectParam(gSpecialVar_ItemId)); VarSet(VAR_REPEL_LURE_STEP_COUNT, ItemId_GetHoldEffectParam(gSpecialVar_ItemId));
VarSet(VAR_LAST_REPEL_USED, gSpecialVar_ItemId); VarSet(VAR_LAST_REPEL_USED, gSpecialVar_ItemId);
RemoveUsedItem(); RemoveUsedItem();
if (!InBattlePyramid()) if (!InBattlePyramid())
@ -879,6 +881,51 @@ static void Task_UseRepel(u8 taskId)
DisplayItemMessageInBattlePyramid(taskId, gStringVar4, Task_CloseBattlePyramidBagMessage); DisplayItemMessageInBattlePyramid(taskId, gStringVar4, Task_CloseBattlePyramidBagMessage);
} }
} }
void HandleUseExpiredRepel(void)
{
VarSet(VAR_REPEL_LURE_STEP_COUNT, ItemId_GetHoldEffectParam(VarGet(VAR_LAST_REPEL_USED)));
}
void ItemUseOutOfBattle_Lure(u8 taskId)
{
if (LURE_STEPS(VarGet(VAR_REPEL_LURE_STEP_COUNT)) == 0)
gTasks[taskId].func = Task_StartUseLure;
else if (!InBattlePyramid())
DisplayItemMessage(taskId, FONT_NORMAL, gText_LureEffectsLingered, CloseItemMessage);
else
DisplayItemMessageInBattlePyramid(taskId, gText_LureEffectsLingered, Task_CloseBattlePyramidBagMessage);
}
static void Task_StartUseLure(u8 taskId)
{
s16* data = gTasks[taskId].data;
if (++data[8] > 7)
{
data[8] = 0;
PlaySE(SE_REPEL);
gTasks[taskId].func = Task_UseLure;
}
}
static void Task_UseLure(u8 taskId)
{
if (!IsSEPlaying())
{
VarSet(VAR_REPEL_LURE_STEP_COUNT, ItemId_GetHoldEffectParam(gSpecialVar_ItemId) | REPEL_LURE_MASK);
VarSet(VAR_LAST_REPEL_USED, gSpecialVar_ItemId);
RemoveUsedItem();
if (!InBattlePyramid())
DisplayItemMessage(taskId, FONT_NORMAL, gStringVar4, CloseItemMessage);
else
DisplayItemMessageInBattlePyramid(taskId, gStringVar4, Task_CloseBattlePyramidBagMessage);
}
}
void HandleUseExpiredLure(void)
{
VarSet(VAR_REPEL_LURE_STEP_COUNT, ItemId_GetHoldEffectParam(VarGet(VAR_LAST_REPEL_USED)) | REPEL_LURE_MASK);
}
static void Task_UsedBlackWhiteFlute(u8 taskId) static void Task_UsedBlackWhiteFlute(u8 taskId)
{ {

View File

@ -244,6 +244,7 @@ const u8 gText_BootedUpHM[] = _("Booted up an HM.");
const u8 gText_TMHMContainedVar1[] = _("It contained\n{STR_VAR_1}.\pTeach {STR_VAR_1}\nto a POKéMON?"); const u8 gText_TMHMContainedVar1[] = _("It contained\n{STR_VAR_1}.\pTeach {STR_VAR_1}\nto a POKéMON?");
const u8 gText_PlayerUsedVar2[] = _("{PLAYER} used the\n{STR_VAR_2}.{PAUSE_UNTIL_PRESS}"); const u8 gText_PlayerUsedVar2[] = _("{PLAYER} used the\n{STR_VAR_2}.{PAUSE_UNTIL_PRESS}");
const u8 gText_RepelEffectsLingered[] = _("But the effects of a REPEL\nlingered from earlier.{PAUSE_UNTIL_PRESS}"); const u8 gText_RepelEffectsLingered[] = _("But the effects of a REPEL\nlingered from earlier.{PAUSE_UNTIL_PRESS}");
const u8 gText_LureEffectsLingered[] = _("But the effects of a Lure\nlingered from earlier.{PAUSE_UNTIL_PRESS}");
const u8 gText_UsedVar2WildLured[] = _("{PLAYER} used the\n{STR_VAR_2}.\pWild POKéMON will be lured.{PAUSE_UNTIL_PRESS}"); const u8 gText_UsedVar2WildLured[] = _("{PLAYER} used the\n{STR_VAR_2}.\pWild POKéMON will be lured.{PAUSE_UNTIL_PRESS}");
const u8 gText_UsedVar2WildRepelled[] = _("{PLAYER} used the\n{STR_VAR_2}.\pWild POKéMON will be repelled.{PAUSE_UNTIL_PRESS}"); const u8 gText_UsedVar2WildRepelled[] = _("{PLAYER} used the\n{STR_VAR_2}.\pWild POKéMON will be repelled.{PAUSE_UNTIL_PRESS}");
const u8 gText_BoxFull[] = _("The BOX is full.{PAUSE_UNTIL_PRESS}"); const u8 gText_BoxFull[] = _("The BOX is full.{PAUSE_UNTIL_PRESS}");

View File

@ -20,11 +20,13 @@
#include "constants/abilities.h" #include "constants/abilities.h"
#include "constants/battle_config.h" #include "constants/battle_config.h"
#include "constants/game_stat.h" #include "constants/game_stat.h"
#include "constants/item.h"
#include "constants/items.h" #include "constants/items.h"
#include "constants/layouts.h" #include "constants/layouts.h"
#include "constants/weather.h" #include "constants/weather.h"
extern const u8 EventScript_RepelWoreOff[]; extern const u8 EventScript_RepelWoreOff[];
extern const u8 EventScript_LureWoreOff[];
#define MAX_ENCOUNTER_RATE 2880 #define MAX_ENCOUNTER_RATE 2880
@ -181,58 +183,82 @@ static void FeebasSeedRng(u16 seed)
// LAND_WILD_COUNT // LAND_WILD_COUNT
static u8 ChooseWildMonIndex_Land(void) static u8 ChooseWildMonIndex_Land(void)
{ {
u8 wildMonIndex = 0;
bool8 swap = FALSE;
u8 rand = Random() % ENCOUNTER_CHANCE_LAND_MONS_TOTAL; u8 rand = Random() % ENCOUNTER_CHANCE_LAND_MONS_TOTAL;
if (rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_0) if (rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_0)
return 0; wildMonIndex = 0;
else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_0 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_1) else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_0 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_1)
return 1; wildMonIndex = 1;
else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_1 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_2) else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_1 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_2)
return 2; wildMonIndex = 2;
else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_2 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_3) else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_2 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_3)
return 3; wildMonIndex = 3;
else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_3 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_4) else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_3 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_4)
return 4; wildMonIndex = 4;
else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_4 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_5) else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_4 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_5)
return 5; wildMonIndex = 5;
else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_5 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_6) else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_5 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_6)
return 6; wildMonIndex = 6;
else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_6 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_7) else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_6 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_7)
return 7; wildMonIndex = 7;
else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_7 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_8) else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_7 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_8)
return 8; wildMonIndex = 8;
else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_8 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_9) else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_8 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_9)
return 9; wildMonIndex = 9;
else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_9 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_10) else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_9 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_10)
return 10; wildMonIndex = 10;
else else
return 11; wildMonIndex = 11;
if (LURE_STEPS(VarGet(VAR_REPEL_LURE_STEP_COUNT)) && (Random() % 10 < 2))
swap = TRUE;
if (swap)
wildMonIndex = 11 - wildMonIndex;
return wildMonIndex;
} }
// ROCK_WILD_COUNT / WATER_WILD_COUNT // ROCK_WILD_COUNT / WATER_WILD_COUNT
static u8 ChooseWildMonIndex_WaterRock(void) static u8 ChooseWildMonIndex_WaterRock(void)
{ {
u8 wildMonIndex = 0;
bool8 swap = FALSE;
u8 rand = Random() % ENCOUNTER_CHANCE_WATER_MONS_TOTAL; u8 rand = Random() % ENCOUNTER_CHANCE_WATER_MONS_TOTAL;
if (rand < ENCOUNTER_CHANCE_WATER_MONS_SLOT_0) if (rand < ENCOUNTER_CHANCE_WATER_MONS_SLOT_0)
return 0; wildMonIndex = 0;
else if (rand >= ENCOUNTER_CHANCE_WATER_MONS_SLOT_0 && rand < ENCOUNTER_CHANCE_WATER_MONS_SLOT_1) else if (rand >= ENCOUNTER_CHANCE_WATER_MONS_SLOT_0 && rand < ENCOUNTER_CHANCE_WATER_MONS_SLOT_1)
return 1; wildMonIndex = 1;
else if (rand >= ENCOUNTER_CHANCE_WATER_MONS_SLOT_1 && rand < ENCOUNTER_CHANCE_WATER_MONS_SLOT_2) else if (rand >= ENCOUNTER_CHANCE_WATER_MONS_SLOT_1 && rand < ENCOUNTER_CHANCE_WATER_MONS_SLOT_2)
return 2; wildMonIndex = 2;
else if (rand >= ENCOUNTER_CHANCE_WATER_MONS_SLOT_2 && rand < ENCOUNTER_CHANCE_WATER_MONS_SLOT_3) else if (rand >= ENCOUNTER_CHANCE_WATER_MONS_SLOT_2 && rand < ENCOUNTER_CHANCE_WATER_MONS_SLOT_3)
return 3; wildMonIndex = 3;
else else
return 4; wildMonIndex = 4;
if (LURE_STEPS(VarGet(VAR_REPEL_LURE_STEP_COUNT)) && (Random() % 10 < 2))
swap = TRUE;
if (swap)
wildMonIndex = 4 - wildMonIndex;
return wildMonIndex;
} }
// FISH_WILD_COUNT // FISH_WILD_COUNT
static u8 ChooseWildMonIndex_Fishing(u8 rod) static u8 ChooseWildMonIndex_Fishing(u8 rod)
{ {
u8 wildMonIndex = 0; u8 wildMonIndex = 0;
bool8 swap = FALSE;
u8 rand = Random() % max(max(ENCOUNTER_CHANCE_FISHING_MONS_OLD_ROD_TOTAL, ENCOUNTER_CHANCE_FISHING_MONS_GOOD_ROD_TOTAL), 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); ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_TOTAL);
if (LURE_STEPS(VarGet(VAR_REPEL_LURE_STEP_COUNT)) && (Random() % 10 < 2))
swap = TRUE;
switch (rod) switch (rod)
{ {
case OLD_ROD: case OLD_ROD:
@ -241,6 +267,9 @@ static u8 ChooseWildMonIndex_Fishing(u8 rod)
else else
wildMonIndex = 1; wildMonIndex = 1;
break; break;
if (swap)
wildMonIndex = 1 - wildMonIndex;
case GOOD_ROD: case GOOD_ROD:
if (rand < ENCOUNTER_CHANCE_FISHING_MONS_GOOD_ROD_SLOT_2) if (rand < ENCOUNTER_CHANCE_FISHING_MONS_GOOD_ROD_SLOT_2)
wildMonIndex = 2; wildMonIndex = 2;
@ -248,6 +277,9 @@ static u8 ChooseWildMonIndex_Fishing(u8 rod)
wildMonIndex = 3; wildMonIndex = 3;
if (rand >= ENCOUNTER_CHANCE_FISHING_MONS_GOOD_ROD_SLOT_3 && rand < ENCOUNTER_CHANCE_FISHING_MONS_GOOD_ROD_SLOT_4) if (rand >= ENCOUNTER_CHANCE_FISHING_MONS_GOOD_ROD_SLOT_3 && rand < ENCOUNTER_CHANCE_FISHING_MONS_GOOD_ROD_SLOT_4)
wildMonIndex = 4; wildMonIndex = 4;
if (swap)
wildMonIndex = 6 - wildMonIndex;
break; break;
case SUPER_ROD: case SUPER_ROD:
if (rand < ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_5) if (rand < ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_5)
@ -260,6 +292,9 @@ static u8 ChooseWildMonIndex_Fishing(u8 rod)
wildMonIndex = 8; wildMonIndex = 8;
if (rand >= ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_8 && rand < ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_9) if (rand >= ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_8 && rand < ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_9)
wildMonIndex = 9; wildMonIndex = 9;
if (swap)
wildMonIndex = 14 - wildMonIndex;
break; break;
} }
return wildMonIndex; return wildMonIndex;
@ -521,6 +556,8 @@ static bool8 DoWildEncounterRateTest(u32 encounterRate, bool8 ignoreAbility)
encounterRate = encounterRate * 80 / 100; encounterRate = encounterRate * 80 / 100;
ApplyFluteEncounterRateMod(&encounterRate); ApplyFluteEncounterRateMod(&encounterRate);
ApplyCleanseTagEncounterRateMod(&encounterRate); ApplyCleanseTagEncounterRateMod(&encounterRate);
if (LURE_STEPS(VarGet(VAR_REPEL_LURE_STEP_COUNT)) != 0)
encounterRate *= 2;
if (!ignoreAbility && !GetMonData(&gPlayerParty[0], MON_DATA_SANITY_IS_EGG)) if (!ignoreAbility && !GetMonData(&gPlayerParty[0], MON_DATA_SANITY_IS_EGG))
{ {
u32 ability = GetMonAbility(&gPlayerParty[0]); u32 ability = GetMonAbility(&gPlayerParty[0]);
@ -892,24 +929,37 @@ u16 GetLocalWaterMon(void)
bool8 UpdateRepelCounter(void) bool8 UpdateRepelCounter(void)
{ {
u16 steps; u16 repelLureVar = VarGet(VAR_REPEL_LURE_STEP_COUNT);
u16 steps = REPEL_LURE_STEPS(repelLureVar);
bool32 isLure = IS_LAST_USED_LURE(repelLureVar);
if (InBattlePike() || InBattlePyramid()) if (InBattlePike() || InBattlePyramid())
return FALSE; return FALSE;
if (InUnionRoom() == TRUE) if (InUnionRoom() == TRUE)
return FALSE; return FALSE;
steps = VarGet(VAR_REPEL_STEP_COUNT);
if (steps != 0) if (steps != 0)
{ {
steps--; steps--;
VarSet(VAR_REPEL_STEP_COUNT, steps); if (!isLure)
if (steps == 0)
{ {
ScriptContext_SetupScript(EventScript_RepelWoreOff); VarSet(VAR_REPEL_LURE_STEP_COUNT, steps);
return TRUE; if (steps == 0)
{
ScriptContext_SetupScript(EventScript_RepelWoreOff);
return TRUE;
}
} }
else
{
VarSet(VAR_REPEL_LURE_STEP_COUNT, steps | REPEL_LURE_MASK);
if (steps == 0)
{
ScriptContext_SetupScript(EventScript_LureWoreOff);
return TRUE;
}
}
} }
return FALSE; return FALSE;
} }
@ -918,7 +968,7 @@ static bool8 IsWildLevelAllowedByRepel(u8 wildLevel)
{ {
u8 i; u8 i;
if (!VarGet(VAR_REPEL_STEP_COUNT)) if (!VarGet(VAR_REPEL_LURE_STEP_COUNT))
return TRUE; return TRUE;
for (i = 0; i < PARTY_SIZE; i++) for (i = 0; i < PARTY_SIZE; i++)