From 4c9446ed0a35e841c813774a90206a568c20dcc2 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Wed, 14 Dec 2022 11:49:55 -0300 Subject: [PATCH 1/3] Fixed Speed Swap's effect --- asm/macros/battle_script.inc | 5 +++ data/battle_scripts_1.s | 4 +-- include/constants/battle_script_commands.h | 1 + include/constants/battle_string_ids.h | 3 +- src/battle_message.c | 2 ++ src/battle_script_commands.c | 36 ++++++++++++++++++++++ 6 files changed, 48 insertions(+), 3 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 8f55c1edb..61ad67549 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -2000,6 +2000,11 @@ .4byte \ptr .endm + .macro swapstats stat:req + various BS_ATTACKER, VARIOUS_SWAP_STATS + .byte \stat + .endm + @ helpful macros .macro setstatchanger stat:req, stages:req, down:req setbyte sSTATCHANGER, \stat | \stages << 3 | \down << 7 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 69eb5a904..94a220608 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -2732,10 +2732,10 @@ BattleScript_EffectSpeedSwap: attackstring ppreduce accuracycheck BattleScript_ButItFailed, NO_ACC_CALC_CHECK_LOCK_ON - swapstatstages STAT_SPEED + swapstats STAT_SPEED attackanimation waitanimation - printstring STRINGID_PKMNSWITCHEDSTATCHANGES + printstring STRINGID_ATTACKERSWITCHEDSTATWITHTARGET waitmessage B_WAIT_TIME_LONG goto BattleScript_MoveEnd diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 2d6db1fbb..0fcb2bbb0 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -246,6 +246,7 @@ #define VARIOUS_CAN_TELEPORT 155 #define VARIOUS_GET_BATTLER_SIDE 156 #define VARIOUS_CHECK_PARENTAL_BOND_COUNTER 157 +#define VARIOUS_SWAP_STATS 158 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index e1bcf983a..8dd94cca4 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -631,8 +631,9 @@ #define STRINGID_ATTACKERMELTEDTHEICE 629 #define STRINGID_TARGETTOUGHEDITOUT 630 #define STRINGID_ATTACKERLOSTELECTRICTYPE 631 +#define STRINGID_ATTACKERSWITCHEDSTATWITHTARGET 632 -#define BATTLESTRINGS_COUNT 632 +#define BATTLESTRINGS_COUNT 633 // This is the string id that gBattleStringsTable starts with. // String ids before this (e.g. STRINGID_INTROMSG) are not in the table, diff --git a/src/battle_message.c b/src/battle_message.c index 416b10613..031261a28 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -760,9 +760,11 @@ static const u8 sText_AttackerHealedItsBurn[] = _("{B_ATK_NAME_WITH_PREFIX} heal static const u8 sText_AttackerMeltedTheIce[] = _("{B_ATK_NAME_WITH_PREFIX} melted the ice with\nits fiery determination!"); static const u8 sText_TargetToughedItOut[] = _("{B_DEF_NAME_WITH_PREFIX} toughed it out\nto show you its best side!"); static const u8 sText_AttackerLostElectricType[] = _("{B_ATK_NAME_WITH_PREFIX} used up all\nof its electricity!"); +static const u8 sText_AttackerSwitchedStatWithTarget[] = _("{B_ATK_NAME_WITH_PREFIX} switched {B_BUFF1}\nwith its target!"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { + [STRINGID_ATTACKERSWITCHEDSTATWITHTARGET - BATTLESTRINGS_TABLE_START] = sText_AttackerSwitchedStatWithTarget, [STRINGID_TARGETTOUGHEDITOUT - BATTLESTRINGS_TABLE_START] = sText_TargetToughedItOut, [STRINGID_ATTACKERMELTEDTHEICE - BATTLESTRINGS_TABLE_START] = sText_AttackerMeltedTheIce, [STRINGID_ATTACKERHEALEDITSBURN - BATTLESTRINGS_TABLE_START] = sText_AttackerHealedItsBurn, diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 6838fcf9e..576e3a466 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -10073,6 +10073,42 @@ static void Cmd_various(void) return; } break; + case VARIOUS_SWAP_STATS: + { + u8 statId = T1_READ_8(gBattlescriptCurrInstr + 3); + u16 temp; + + switch (statId) + { + case STAT_HP: + SWAP(gBattleMons[gBattlerAttacker].hp, gBattleMons[gBattlerTarget].hp, temp); + PREPARE_STAT_BUFFER(gBattleTextBuff1, statId); + break; + case STAT_ATK: + SWAP(gBattleMons[gBattlerAttacker].attack, gBattleMons[gBattlerTarget].attack, temp); + PREPARE_STAT_BUFFER(gBattleTextBuff1, statId); + break; + case STAT_DEF: + SWAP(gBattleMons[gBattlerAttacker].defense, gBattleMons[gBattlerTarget].defense, temp); + PREPARE_STAT_BUFFER(gBattleTextBuff1, statId); + break; + case STAT_SPEED: + SWAP(gBattleMons[gBattlerAttacker].speed, gBattleMons[gBattlerTarget].speed, temp); + PREPARE_STAT_BUFFER(gBattleTextBuff1, statId); + break; + case STAT_SPATK: + SWAP(gBattleMons[gBattlerAttacker].spAttack, gBattleMons[gBattlerTarget].spAttack, temp); + PREPARE_STAT_BUFFER(gBattleTextBuff1, statId); + break; + case STAT_SPDEF: + SWAP(gBattleMons[gBattlerAttacker].spDefense, gBattleMons[gBattlerTarget].spDefense, temp); + PREPARE_STAT_BUFFER(gBattleTextBuff1, statId); + break; + default: + break; + } + } + break; } // End of switch (gBattlescriptCurrInstr[2]) gBattlescriptCurrInstr += 3; From 7c447a1f62fad83032aa7b4286aa3cbe01b591b5 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Wed, 14 Dec 2022 12:09:16 -0300 Subject: [PATCH 2/3] Small corrections --- src/battle_script_commands.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 576e3a466..852af284c 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -10082,31 +10082,24 @@ static void Cmd_various(void) { case STAT_HP: SWAP(gBattleMons[gBattlerAttacker].hp, gBattleMons[gBattlerTarget].hp, temp); - PREPARE_STAT_BUFFER(gBattleTextBuff1, statId); break; case STAT_ATK: SWAP(gBattleMons[gBattlerAttacker].attack, gBattleMons[gBattlerTarget].attack, temp); - PREPARE_STAT_BUFFER(gBattleTextBuff1, statId); break; case STAT_DEF: SWAP(gBattleMons[gBattlerAttacker].defense, gBattleMons[gBattlerTarget].defense, temp); - PREPARE_STAT_BUFFER(gBattleTextBuff1, statId); break; case STAT_SPEED: SWAP(gBattleMons[gBattlerAttacker].speed, gBattleMons[gBattlerTarget].speed, temp); - PREPARE_STAT_BUFFER(gBattleTextBuff1, statId); break; case STAT_SPATK: SWAP(gBattleMons[gBattlerAttacker].spAttack, gBattleMons[gBattlerTarget].spAttack, temp); - PREPARE_STAT_BUFFER(gBattleTextBuff1, statId); break; case STAT_SPDEF: SWAP(gBattleMons[gBattlerAttacker].spDefense, gBattleMons[gBattlerTarget].spDefense, temp); - PREPARE_STAT_BUFFER(gBattleTextBuff1, statId); - break; - default: break; } + PREPARE_STAT_BUFFER(gBattleTextBuff1, statId); } break; } // End of switch (gBattlescriptCurrInstr[2]) From bd7d949f5f9a3eecb3f1edadc258f2a0a628d37b Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sun, 18 Dec 2022 13:49:02 -0300 Subject: [PATCH 3/3] Fixed B_DOUBLE_WILD_CHANCE becoming 1% less than what's set --- src/wild_encounter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wild_encounter.c b/src/wild_encounter.c index fe6af5a20..2c9730cd5 100644 --- a/src/wild_encounter.c +++ b/src/wild_encounter.c @@ -1104,7 +1104,7 @@ bool8 TryDoDoubleWildBattle(void) return TRUE; #endif #if B_DOUBLE_WILD_CHANCE != 0 - else if ((Random() % 100) + 1 < B_DOUBLE_WILD_CHANCE) + else if ((Random() % 100) + 1 <= B_DOUBLE_WILD_CHANCE) return TRUE; #endif return FALSE;