From 979c9994f76c0823b3d221e4c94d67c87a07ee74 Mon Sep 17 00:00:00 2001 From: pkmnsnfrn Date: Thu, 12 Sep 2024 05:47:12 -0700 Subject: [PATCH] Set VAR_RESULT to the number of removed items from removeallitem per https://github.com/rh-hideout/pokeemerald-expansion/pull/5177\#issuecomment-2294980531 --- .swo | Bin 4096 -> 0 bytes asm/macros/event.inc | 2 +- src/scrcmd.c | 4 +++- 3 files changed, 4 insertions(+), 2 deletions(-) delete mode 100644 .swo diff --git a/.swo b/.swo deleted file mode 100644 index dac352690102655cc3a6e5f5a7fee17b83ce8ed2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4096 zcmYc?2=nw+u+%eP00IFJ0RcOh7#IqQ(_mb@w2N!7cZh$0uBAm-n5(H7UbUl=qaiRF z0s|ESoT0`>hTyEOtfZ(QEEGCW4jHv~Gz3ONU^E0qLtr!nMnhmU1V%$(Gz3ONU;sh@ E055zBfdBvi diff --git a/asm/macros/event.inc b/asm/macros/event.inc index a4057b22db..dff3faf83a 100644 --- a/asm/macros/event.inc +++ b/asm/macros/event.inc @@ -2339,7 +2339,7 @@ callnative ScriptHideItemDescription .endm - @ Remove all of specified item from the player's bag + @ Remove all of specified item from the player's bag and return the number of removed items to VAR_RESULT .macro removeallitem itemId:req callnative RemoveAllItem .2byte \itemId diff --git a/src/scrcmd.c b/src/scrcmd.c index 12ec041895..7062721a94 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -2477,5 +2477,7 @@ void ScriptSetDoubleBattleFlag(struct ScriptContext *ctx) void RemoveAllItem(struct ScriptContext *ctx) { u32 itemId = VarGet(ScriptReadHalfword(ctx)); - RemoveBagItem(itemId, CountTotalItemQuantityInBag(itemId)); + u32 count = CountTotalItemQuantityInBag(itemId); + gSpecialVar_Result = count; + RemoveBagItem(itemId, count); }