From d695a6240dbbd6bcdd7785fd172119efb3e49146 Mon Sep 17 00:00:00 2001 From: ghoulslash <41651341+ghoulslash@users.noreply.github.com> Date: Sun, 22 Sep 2024 05:25:42 -0400 Subject: [PATCH] Convert settotemboost command to callnative (#5418) * settotemboost use callnative * Update src/battle_main.c --------- Co-authored-by: ghoulslash Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com> --- asm/macros/event.inc | 18 +++++++++--------- data/specials.inc | 1 - src/battle_main.c | 16 ++++++++-------- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/asm/macros/event.inc b/asm/macros/event.inc index 83338673cf..c5a83a28f7 100644 --- a/asm/macros/event.inc +++ b/asm/macros/event.inc @@ -2105,15 +2105,15 @@ @ The rest of the arguments are the stat change values to each stat. @ For example, giving the first opponent +1 to atk and -2 to speed would be: settotemboost B_POSITION_OPPONENT_LEFT, 1, 0, -2 .macro settotemboost battler:req, atk=0,def=0,speed=0,spatk=0,spdef=0,acc=0,evas=0 - setvar VAR_0x8000, \battler - setvar VAR_0x8001, \atk - setvar VAR_0x8002, \def - setvar VAR_0x8003, \speed - setvar VAR_0x8004, \spatk - setvar VAR_0x8005, \spdef - setvar VAR_0x8006, \acc - setvar VAR_0x8007, \evas - special SetTotemBoost + callnative ScriptSetTotemBoost + .2byte \battler + .2byte \atk + .2byte \def + .2byte \speed + .2byte \spatk + .2byte \spdef + .2byte \acc + .2byte \evas .endm @ useful totem boost macros diff --git a/data/specials.inc b/data/specials.inc index f02497d603..5ebb3d0ee1 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -534,7 +534,6 @@ gSpecials:: def_special RemoveRecordsWindow def_special CloseDeptStoreElevatorWindow def_special TrySetBattleTowerLinkType - def_special SetTotemBoost def_special TrySpecialOverworldEvo def_special GetNumberSprayStrength def_special GetSprayId diff --git a/src/battle_main.c b/src/battle_main.c index d011cde1db..a9336c3f8b 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -43,6 +43,7 @@ #include "roamer.h" #include "safari_zone.h" #include "scanline_effect.h" +#include "script.h" #include "sound.h" #include "sprite.h" #include "string_util.h" @@ -5935,21 +5936,20 @@ void SetTypeBeforeUsingMove(u32 move, u32 battlerAtk) } } -// special to set a field's totem boost(s) -// inputs: -// var8000: battler -// var8001 - var8007: stat changes -void SetTotemBoost(void) +// Queues stat boosts for a given battler for totem battles +void ScriptSetTotemBoost(struct ScriptContext *ctx) { - u32 battler = gSpecialVar_0x8000; + u32 battler = VarGet(ScriptReadHalfword(ctx)); + u32 stat; u32 i; for (i = 0; i < (NUM_BATTLE_STATS - 1); i++) { - if (*(&gSpecialVar_0x8001 + i)) + stat = VarGet(ScriptReadHalfword(ctx)); + if (stat) { gQueuedStatBoosts[battler].stats |= (1 << i); - gQueuedStatBoosts[battler].statChanges[i] = *(&gSpecialVar_0x8001 + i); + gQueuedStatBoosts[battler].statChanges[i] = stat; gQueuedStatBoosts[battler].stats |= 0x80; // used as a flag for the "totem flared to life" script } }