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

Improved Repel / Lure Menu #3594

Merged
merged 26 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0471e53
First draft of repel lure
pkmnsnfrn Nov 22, 2023
7c69749
Updated all lure and repel scripts
pkmnsnfrn Nov 22, 2023
f601cda
Optimized inc file
pkmnsnfrn Nov 22, 2023
a6d7182
Updated y coord
pkmnsnfrn Nov 22, 2023
9e567d1
optimized sprays.c
pkmnsnfrn Nov 22, 2023
e53b5cf
Removed spray.inc
pkmnsnfrn Nov 22, 2023
720231e
Updated cosnt use
pkmnsnfrn Nov 22, 2023
a530f98
Removed dead repel and lure code
pkmnsnfrn Nov 22, 2023
5023f85
Updated debug for testing
pkmnsnfrn Nov 22, 2023
8651bc3
testing new inc file
pkmnsnfrn Nov 22, 2023
b78fe15
turn on debug and options
pkmnsnfrn Nov 22, 2023
c34ffaa
playground generated inc file without ifs
pkmnsnfrn Nov 22, 2023
4dc3c3a
pory generated inc with ifdef complete
pkmnsnfrn Nov 23, 2023
90f515e
Updated spray.c with new inc
pkmnsnfrn Nov 23, 2023
5ba31cf
reverted item config
pkmnsnfrn Nov 23, 2023
55b2442
Reverted event scripts
pkmnsnfrn Nov 23, 2023
f0c39dd
Reverted event scripts
pkmnsnfrn Nov 23, 2023
a5967a1
Revert config
pkmnsnfrn Nov 23, 2023
8297557
Added testing scripts for debug
pkmnsnfrn Nov 23, 2023
a9bf0d2
Added back specials
pkmnsnfrn Nov 23, 2023
d53e271
reverted debug scripts
pkmnsnfrn Nov 23, 2023
2f472ed
Updated use of constants
pkmnsnfrn Nov 23, 2023
8e66726
Addressed tabs > spaces feedback
pkmnsnfrn Nov 23, 2023
3894772
Updated constant names to avoid confusion
pkmnsnfrn Nov 23, 2023
f07ebe6
Updated constant name of NUM_SPRAY_TYPES to NUM_SPRAY_STRENGTH to be …
pkmnsnfrn Nov 23, 2023
e8dfa2c
Merge branch 'upcoming' into repel_lure_menu
pkmnsnfrn Nov 23, 2023
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
224 changes: 134 additions & 90 deletions data/scripts/repel.inc
Original file line number Diff line number Diff line change
@@ -1,117 +1,161 @@
EventScript_RepelWoreOff::
.if I_REPEL_LURE_MENU == TRUE
checkitem ITEM_REPEL, 1
goto_if_eq VAR_RESULT, TRUE, EventScript_RepelUseAnother
checkitem ITEM_SUPER_REPEL, 1
goto_if_eq VAR_RESULT, TRUE, EventScript_RepelUseAnother
checkitem ITEM_MAX_REPEL, 1
goto_if_eq VAR_RESULT, TRUE, EventScript_RepelUseAnother
.else
checkitem VAR_LAST_REPEL_LURE_USED, 1
goto_if_eq VAR_RESULT, TRUE, EventScript_RepelUseAnother
.set VAR_SPRAY, VAR_0x8004
.set VAR_NUM_SPRAY_STRENGTH, VAR_0x8005
pkmnsnfrn marked this conversation as resolved.
Show resolved Hide resolved
.set VAR_SPRAY_TYPE, VAR_0x8009
.set VAR_NEW_SPRAY, VAR_0x8007

EventScript_BufferSprayName::
.if VAR_LAST_REPEL_LURE_USED != 0
bufferitemname STR_VAR_1, VAR_LAST_REPEL_LURE_USED
return
.endif
lock
msgbox Text_RepelWoreOff, MSGBOX_SIGN
release
end
specialvar VAR_SPRAY_TYPE, GetLastUsedSprayType
compare VAR_SPRAY_TYPE, ITEM_REPEL
goto_if_eq EventScript_BufferSprayName_2
bufferitemname STR_VAR_1, ITEM_LURE
EventScript_BufferSprayName_1:
return

EventScript_RepelUseAnother:
EventScript_BufferSprayName_2:
bufferitemname STR_VAR_1, ITEM_REPEL
goto EventScript_BufferSprayName_1


EventScript_SprayWoreOff::
lock
msgbox Text_UseAnotherRepel, MSGBOX_YESNO
call EventScript_BufferSprayName
specialvar VAR_NUM_SPRAY_STRENGTH, GetNumberSprayStrength
switch VAR_NUM_SPRAY_STRENGTH
case 0, EventScript_SprayWoreOff_2
case 1, EventScript_SprayWoreOff_3
goto EventScript_HandleMultipleSprays
return

EventScript_SprayWoreOff_2:
goto EventScript_SprayWoreOffMessage
pkmnsnfrn marked this conversation as resolved.
Show resolved Hide resolved
return

EventScript_SprayWoreOff_3:
goto EventScript_UseSingleSpray
return


EventScript_HandleMultipleSprays::
.if I_REPEL_LURE_MENU == TRUE
goto_if_eq VAR_RESULT, NO, EventScript_RepelWoreOff_End
callnative TryDrawRepelMenu
goto_if_eq VAR_RESULT, FALSE, EventScript_RepelWoreOff_Chose
waitstate
goto_if_eq VAR_RESULT, 127, EventScript_RepelWoreOff_End
EventScript_RepelWoreOff_Chose:
callnative HandleRepelMenuChoice
bufferitemname 1, VAR_0x8004
removeitem VAR_0x8004, 1
playse SE_REPEL
msgbox Text_UsedNewRepelLure, MSGBOX_SIGN
goto EventScript_ChooseWhichSpray
.else
goto_if_eq VAR_RESULT, YES, EventScript_UsedRepel
goto EventScript_UseSingleSpray
.endif
EventScript_RepelWoreOff_End:
release
end
return

EventScript_UsedRepel:
bufferitemname 1, VAR_LAST_REPEL_LURE_USED
playse SE_REPEL
lock
msgbox Text_UsedNewRepelLure, MSGBOX_SIGN
removeitem VAR_LAST_REPEL_LURE_USED, 1
waitse
callnative HandleUseExpiredRepel
release

EventScript_SprayWoreOffMessage::
msgbox Text_SprayWoreOff, MSGBOX_SIGN
releaseall
end

EventScript_LureWoreOff::
.if I_REPEL_LURE_MENU == TRUE
checkitem ITEM_LURE, 1
goto_if_eq VAR_RESULT, TRUE, EventScript_LureUseAnother
checkitem ITEM_SUPER_LURE, 1
goto_if_eq VAR_RESULT, TRUE, EventScript_LureUseAnother
checkitem ITEM_MAX_LURE, 1
goto_if_eq VAR_RESULT, TRUE, EventScript_LureUseAnother

EventScript_UseSingleSpray::
.if VAR_LAST_REPEL_LURE_USED == 0
call EventScript_UseDifferentSpray
.else
checkitem VAR_LAST_REPEL_LURE_USED, 1
goto_if_eq VAR_RESULT, TRUE, EventScript_LureUseAnother
compare VAR_RESULT, TRUE
goto_if_eq EventScript_UseSingleSpray_2
call EventScript_UseDifferentSpray
.endif
lock
msgbox Text_LureWoreOff, MSGBOX_SIGN
release
EventScript_UseSingleSpray_1:
closemessage
releaseall
end

EventScript_LureUseAnother:
lock
msgbox Text_UseAnotherLure, MSGBOX_YESNO
.if VAR_LAST_REPEL_LURE_USED != 0
EventScript_UseSingleSpray_2:
call EventScript_UseLastUsedSpray
goto EventScript_UseSingleSpray_1
.endif


EventScript_SetSingleSprayAndUse::
setvar VAR_RESULT, 0
call EventScript_UseSpray
return


EventScript_UseDifferentSpray::
specialvar VAR_NEW_SPRAY, GetSprayId
bufferitemname STR_VAR_2, VAR_NEW_SPRAY
msgbox Text_SprayWoreOffAskUseX, MSGBOX_YESNO
compare VAR_RESULT, YES
goto_if_eq EventScript_UseDifferentSpray_2
EventScript_UseDifferentSpray_1:
return

EventScript_UseDifferentSpray_2:
copyvar VAR_SPRAY, VAR_NEW_SPRAY
call EventScript_SetSingleSprayAndUse
goto EventScript_UseDifferentSpray_1


.if VAR_LAST_REPEL_LURE_USED != 0
EventScript_UseLastUsedSpray::
msgbox Text_SprayWoreOffAskUseAnother, MSGBOX_YESNO
compare VAR_RESULT, YES
goto_if_eq EventScript_UseLastUsedSpray_2
EventScript_UseLastUsedSpray_1:
return

EventScript_UseLastUsedSpray_2:
copyvar VAR_SPRAY, VAR_LAST_REPEL_LURE_USED
call EventScript_SetSingleSprayAndUse
goto EventScript_UseLastUsedSpray_1
.endif


.if I_REPEL_LURE_MENU == TRUE
goto_if_eq VAR_RESULT, NO, EventScript_LureWoreOff_End
callnative TryDrawLureMenu
goto_if_eq VAR_RESULT, FALSE, EventScript_LureWoreOff_Chose
EventScript_ChooseWhichSpray::
message Text_SprayWoreOffAskUseAnother
waitmessage
callnative DrawSprayMenu
waitstate
goto_if_eq VAR_RESULT, 127, EventScript_LureWoreOff_End
EventScript_LureWoreOff_Chose:
callnative HandleLureMenuChoice
bufferitemname 1, VAR_0x8004
removeitem VAR_0x8004, 1
playse SE_REPEL
msgbox Text_UsedNewRepelLure, MSGBOX_SIGN
.else
goto_if_eq VAR_RESULT, YES, EventScript_UsedLure
.endif
EventScript_LureWoreOff_End:
release
compare VAR_RESULT, MULTI_B_PRESSED
goto_if_ne EventScript_ChooseWhichSpray_3
EventScript_ChooseWhichSpray_1:
closemessage
releaseall
end

EventScript_UsedLure:
bufferitemname 1, VAR_LAST_REPEL_LURE_USED
EventScript_ChooseWhichSpray_2:
call EventScript_UseSpray
goto EventScript_ChooseWhichSpray_1

EventScript_ChooseWhichSpray_3:
compare VAR_RESULT, VAR_0x8003
goto_if_ne EventScript_ChooseWhichSpray_2
goto EventScript_ChooseWhichSpray_1
.endif


EventScript_UseSpray::
playse SE_REPEL
lock
msgbox Text_UsedNewRepelLure, MSGBOX_SIGN
removeitem VAR_LAST_REPEL_LURE_USED, 1
waitse
callnative HandleUseExpiredLure
release
end
callnative HandleSprayMenuChoice
removeitem VAR_SPRAY, 1
bufferitemname STR_VAR_2, VAR_SPRAY
msgbox Text_SprayWoreOffUseX, MSGBOX_SIGN
return

Text_RepelWoreOff:
.string "REPEL's effect wore off…$"

Text_UseAnotherRepel::
.string "REPEL's effect wore off!\n"
.string "Use another?$"
Text_SprayWoreOff::
.string "{STR_VAR_1}'s effect wore off…$"

Text_LureWoreOff:
.string "Lure's effect wore off…$"

Text_UseAnotherLure::
.string "Lure's effect wore off!\n"
Text_SprayWoreOffAskUseAnother::
.string "{STR_VAR_1}'s effect wore off!\n"
.string "Use another?$"

Text_UsedNewRepelLure::
Text_SprayWoreOffAskUseX::
.string "{STR_VAR_1}'s effect wore off…\n"
.string "Use a {STR_VAR_2}?$"

Text_SprayWoreOffUseX::
.string "{PLAYER} used the\n"
.string "{STR_VAR_2}.$"
3 changes: 3 additions & 0 deletions data/specials.inc
Original file line number Diff line number Diff line change
Expand Up @@ -536,3 +536,6 @@ gSpecials::
def_special TrySetBattleTowerLinkType
def_special SetTotemBoost
def_special TrySpecialOverworldEvo
def_special GetNumberSprayStrength
def_special GetSprayId
def_special GetLastUsedSprayType
pkmnsnfrn marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 2 additions & 0 deletions include/script_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
#define GUARD_SCRIPT_MENU_H

#include "constants/script_menu.h"
#include "menu.h"

extern const u8 *const gStdStrings[];

bool8 ScriptMenu_Multichoice(u8 left, u8 top, u8 multichoiceId, bool8 ignoreBPress);
bool8 ScriptMenu_MultichoiceWithDefault(u8 left, u8 top, u8 multichoiceId, bool8 ignoreBPress, u8 defaultChoice);
void DrawMultichoiceMenuInternal(u8 left, u8 top, u8 multichoiceId, bool8 ignoreBPress, u8 cursorPos, const struct MenuAction *actions, int count);
bool8 ScriptMenu_YesNo(u8 left, u8 top);
bool8 ScriptMenu_MultichoiceGrid(u8 left, u8 top, u8 multichoiceId, bool8 ignoreBPress, u8 columnCount);
bool8 ScriptMenu_ShowPokemonPic(u16 species, u8 x, u8 y);
Expand Down
75 changes: 1 addition & 74 deletions src/script_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static u16 UNUSED GetLengthWithExpandedPlayerName(const u8 *str)
return length;
}

static void DrawMultichoiceMenuInternal(u8 left, u8 top, u8 multichoiceId, bool8 ignoreBPress, u8 cursorPos, const struct MenuAction *actions, int count)
void DrawMultichoiceMenuInternal(u8 left, u8 top, u8 multichoiceId, bool8 ignoreBPress, u8 cursorPos, const struct MenuAction *actions, int count)
{
int i;
u8 windowId;
Expand All @@ -116,79 +116,6 @@ static void DrawMultichoiceMenu(u8 left, u8 top, u8 multichoiceId, bool8 ignoreB
DrawMultichoiceMenuInternal(left, top, multichoiceId, ignoreBPress, cursorPos, sMultichoiceLists[multichoiceId].list, sMultichoiceLists[multichoiceId].count);
}

#if I_REPEL_LURE_MENU == TRUE
void TryDrawRepelMenu(struct ScriptContext *ctx)
{
static const u16 repelItems[] = {ITEM_REPEL, ITEM_SUPER_REPEL, ITEM_MAX_REPEL};
struct MenuAction menuItems[ARRAY_COUNT(repelItems) + 1] = {NULL};
int i, count = 0, menuPos = 0;

for (i = 0; i < ARRAY_COUNT(repelItems); i++)
{
if (CheckBagHasItem(repelItems[i], 1))
{
VarSet(VAR_0x8004 + count, repelItems[i]);
#if VAR_LAST_REPEL_LURE_USED != 0
if (VarGet(VAR_LAST_REPEL_LURE_USED) == repelItems[i])
menuPos = count;
#endif
menuItems[count].text = ItemId_GetName(repelItems[i]);
count++;
}
}

if (count > 1)
DrawMultichoiceMenuInternal(0, 0, 0, FALSE, menuPos, menuItems, count);

gSpecialVar_Result = (count > 1);
}

void HandleRepelMenuChoice(struct ScriptContext *ctx)
{
gSpecialVar_0x8004 = VarGet(VAR_0x8004 + gSpecialVar_Result); // Get item Id;
VarSet(VAR_REPEL_STEP_COUNT, ItemId_GetHoldEffectParam(gSpecialVar_0x8004));
#if VAR_LAST_REPEL_LURE_USED != 0
VarSet(VAR_LAST_REPEL_LURE_USED, gSpecialVar_0x8004);
#endif
}

void TryDrawLureMenu(struct ScriptContext *ctx)
{
static const u16 lureItems[] = {ITEM_LURE, ITEM_SUPER_LURE, ITEM_MAX_LURE};
struct MenuAction menuItems[ARRAY_COUNT(lureItems) + 1] = {NULL};
int i, count = 0, menuPos = 0;


for (i = 0; i < ARRAY_COUNT(lureItems); i++)
{
if (CheckBagHasItem(lureItems[i], 1))
{
VarSet(VAR_0x8004 + count, lureItems[i]);
#if VAR_LAST_REPEL_LURE_USED != 0
if (VarGet(VAR_LAST_REPEL_LURE_USED) == lureItems[i])
menuPos = count;
#endif
menuItems[count].text = ItemId_GetName(lureItems[i]);
count++;
}
}

if (count > 1)
DrawMultichoiceMenuInternal(0, 0, 0, FALSE, menuPos, menuItems, count);

gSpecialVar_Result = (count > 1);
}

void HandleLureMenuChoice(struct ScriptContext *ctx)
{
gSpecialVar_0x8004 = VarGet(VAR_0x8004 + gSpecialVar_Result); // Get item Id;
VarSet(VAR_REPEL_STEP_COUNT, ItemId_GetHoldEffectParam(gSpecialVar_0x8004) | REPEL_LURE_MASK);
#if VAR_LAST_REPEL_LURE_USED != 0
VarSet(VAR_LAST_REPEL_LURE_USED, gSpecialVar_0x8004);
#endif
}
#endif //I_REPEL_LURE_MENU == TRUE

#define tLeft data[0]
#define tTop data[1]
#define tRight data[2]
Expand Down
Loading
Loading