Implement B2W2 Repel System

The game now asks if the player would like to use another Repel when the one they used runs out.

# Conflicts:
#	include/constants/vars.h
This commit is contained in:
Deokishisu 2022-08-27 19:46:59 -04:00 committed by Eduardo Quezada
parent 66177e7958
commit e3c19f5df5
4 changed files with 39 additions and 1 deletions

View File

@ -1,6 +1,38 @@
EventScript_RepelWoreOff:: EventScript_RepelWoreOff::
checkitem VAR_LAST_REPEL_USED, 1
compare VAR_RESULT, TRUE
goto_if_eq EventScript_UseAnother
lock
msgbox Text_RepelWoreOff, MSGBOX_SIGN msgbox Text_RepelWoreOff, MSGBOX_SIGN
release
end
EventScript_UseAnother:
lock
msgbox Text_UseAnother, MSGBOX_YESNO
compare VAR_RESULT, YES
goto_if_eq EventScript_UsedRepel
release
end
EventScript_UsedRepel:
bufferitemname 0, VAR_LAST_REPEL_USED
playse SE_REPEL
lock
msgbox Text_UsedNewRepel, MSGBOX_SIGN
removeitem VAR_LAST_REPEL_USED, 1
waitse
callnative HandleUseExpiredRepel
release
end end
Text_RepelWoreOff: Text_RepelWoreOff:
.string "REPEL's effect wore off…$" .string "REPEL's effect wore off…$"
Text_UseAnother::
.string "REPEL's effect wore off!\n"
.string "Use another?$"
Text_UsedNewRepel::
.string "{PLAYER} used the\n"
.string "{STR_VAR_1}.$"

View File

@ -271,7 +271,7 @@
#define VAR_UNUSED_0x40FC 0x40FC // Unused Var #define VAR_UNUSED_0x40FC 0x40FC // Unused Var
#define VAR_UNUSED_0x40FD 0x40FD // Unused Var #define VAR_UNUSED_0x40FD 0x40FD // Unused Var
#define VAR_UNUSED_0x40FE 0x40FE // Unused Var #define VAR_UNUSED_0x40FE 0x40FE // Unused Var
#define VAR_UNUSED_0x40FF 0x40FF // Unused Var #define VAR_LAST_REPEL_USED 0x40FF // Unused Var
#define VARS_END 0x40FF #define VARS_END 0x40FF
#define VARS_COUNT (VARS_END - VARS_START + 1) #define VARS_COUNT (VARS_END - VARS_START + 1)

View File

@ -952,3 +952,8 @@ 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

@ -871,6 +871,7 @@ static void Task_UseRepel(u8 taskId)
if (!IsSEPlaying()) if (!IsSEPlaying())
{ {
VarSet(VAR_REPEL_STEP_COUNT, ItemId_GetHoldEffectParam(gSpecialVar_ItemId)); VarSet(VAR_REPEL_STEP_COUNT, ItemId_GetHoldEffectParam(gSpecialVar_ItemId));
VarSet(VAR_LAST_REPEL_USED, gSpecialVar_ItemId);
RemoveUsedItem(); RemoveUsedItem();
if (!InBattlePyramid()) if (!InBattlePyramid())
DisplayItemMessage(taskId, FONT_NORMAL, gStringVar4, CloseItemMessage); DisplayItemMessage(taskId, FONT_NORMAL, gStringVar4, CloseItemMessage);