From cd2a99b7c44bb875135c2c97589ecc160dad71f0 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sat, 17 Apr 2021 00:49:51 -0400 Subject: Doc storage - misc cleanup, some item/cursor --- src/battle_script_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/battle_script_commands.c') diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 33c6ce0e5..0492caeb5 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -6045,7 +6045,7 @@ static void PutLevelAndGenderOnLvlUpBox(void) var = (u32)(txtPtr); txtPtr = ConvertIntToDecimalStringN(txtPtr, monLevel, STR_CONV_MODE_LEFT_ALIGN, 3); var = (u32)(txtPtr) - var; - txtPtr = StringFill(txtPtr, CHAR_UNK_SPACER, 4 - var); + txtPtr = StringFill(txtPtr, CHAR_GENDERLESS, 4 - var); if (monGender != MON_GENDERLESS) { -- cgit v1.2.3 From ffbbc88801de3fc56d0bf5f0af1418ca7cfcfa4f Mon Sep 17 00:00:00 2001 From: gAlfonso-bit <83477269+gAlfonso-bit@users.noreply.github.com> Date: Sun, 23 May 2021 10:35:03 -0400 Subject: BUGFIX: battle scripts (#1436) --- src/battle_script_commands.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'src/battle_script_commands.c') diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 0492caeb5..15e44dd75 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3357,7 +3357,7 @@ static void Cmd_getexp(void) // get exp getter battlerId if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { - if (!(gBattlerPartyIndexes[2] != gBattleStruct->expGetterMonId) && !(gAbsentBattlerFlags & gBitTable[2])) + if (gBattlerPartyIndexes[2] == gBattleStruct->expGetterMonId && !(gAbsentBattlerFlags & gBitTable[2])) gBattleStruct->expGetterBattlerId = 2; else { @@ -3431,14 +3431,13 @@ static void Cmd_getexp(void) gBattleMons[0].maxHP = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_MAX_HP); gBattleMons[0].attack = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_ATK); gBattleMons[0].defense = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_DEF); - // Why is this duplicated? + // Speed is duplicated, likely due to a copy-paste error. gBattleMons[0].speed = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPEED); gBattleMons[0].speed = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPEED); - gBattleMons[0].spAttack = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPATK); gBattleMons[0].spDefense = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPDEF); } - // What is else if? + if (gBattlerPartyIndexes[2] == gBattleStruct->expGetterMonId && gBattleMons[2].hp && (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) { gBattleMons[2].level = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_LEVEL); @@ -3446,10 +3445,13 @@ static void Cmd_getexp(void) gBattleMons[2].maxHP = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_MAX_HP); gBattleMons[2].attack = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_ATK); gBattleMons[2].defense = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_DEF); - // Duplicated again, but this time there's no Sp Defense gBattleMons[2].speed = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPEED); + // Speed is duplicated again, but Special Defense is missing. +#ifdef BUGFIX + gBattleMons[2].spDefense = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPDEF); +#else gBattleMons[2].speed = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPEED); - +#endif gBattleMons[2].spAttack = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPATK); } gBattleScripting.getexpState = 5; @@ -6168,7 +6170,13 @@ static void Cmd_recordlastability(void) { gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); RecordAbilityBattle(gActiveBattler, gLastUsedAbility); - gBattlescriptCurrInstr += 1; // UB: Should be + 2, one byte for command and one byte for battlerId argument. + +#ifdef BUGFIX + // This command occupies two bytes (one for the command id, and one for the battler id parameter). + gBattlescriptCurrInstr += 2; +#else + gBattlescriptCurrInstr += 1; +#endif } void BufferMoveToLearnIntoBattleTextBuff2(void) -- cgit v1.2.3 From 93188ef0a8aac4855903543c3b059285baccebc2 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 1 Jul 2021 00:18:52 -0400 Subject: Fix divide by 0 in Cmd_getexp --- src/battle_script_commands.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/battle_script_commands.c') diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 15e44dd75..d927ffb76 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3269,7 +3269,7 @@ static void Cmd_getexp(void) if (viaExpShare) // at least one mon is getting exp via exp share { - *exp = calculatedExp / 2 / viaSentIn; + *exp = SAFE_DIV(calculatedExp / 2, viaSentIn); if (*exp == 0) *exp = 1; @@ -3279,7 +3279,7 @@ static void Cmd_getexp(void) } else { - *exp = calculatedExp / viaSentIn; + *exp = SAFE_DIV(calculatedExp, viaSentIn); if (*exp == 0) *exp = 1; gExpShareExp = 0; -- cgit v1.2.3 From 810ca5f8ff79aeec6ffe8e982f4786aade616b4d Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 7 Jul 2021 09:11:52 -0400 Subject: Flatten pos fields in struct Sprite --- src/battle_script_commands.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/battle_script_commands.c') diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index d927ffb76..cea30bb21 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -6118,9 +6118,9 @@ static void PutMonIconOnLvlUpBox(void) static void SpriteCB_MonIconOnLvlUpBox(struct Sprite* sprite) { - sprite->pos2.x = sprite->sSavedLvlUpBoxXPosition - gBattle_BG2_X; + sprite->x2 = sprite->sSavedLvlUpBoxXPosition - gBattle_BG2_X; - if (sprite->pos2.x != 0) + if (sprite->x2 != 0) { sprite->sDestroy = TRUE; } -- cgit v1.2.3