From 27ddd0145c70bdf7e6c13442636477c649404ee0 Mon Sep 17 00:00:00 2001 From: GGbond Date: Sat, 21 Feb 2026 11:54:12 +0800 Subject: [PATCH 1/2] adjust --- src/battle_script_commands.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index cefe4f64ea..5405fa02f1 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8513,8 +8513,9 @@ static void Cmd_transformdataexecution(void) else { s32 i; - u8 *battleMonAttacker, *battleMonTarget; u8 timesGotHit; + struct BattlePokemon *battleMonAttacker; + struct BattlePokemon *battleMonTarget; gBattleMons[gBattlerAttacker].volatiles.transformed = TRUE; gBattleMons[gBattlerAttacker].volatiles.disabledMove = MOVE_NONE; @@ -8533,11 +8534,26 @@ static void Cmd_transformdataexecution(void) PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gBattlerTarget].species) - battleMonAttacker = (u8 *)(&gBattleMons[gBattlerAttacker]); - battleMonTarget = (u8 *)(&gBattleMons[gBattlerTarget]); + battleMonAttacker = &gBattleMons[gBattlerAttacker]; + battleMonTarget = &gBattleMons[gBattlerTarget]; - for (i = 0; i < offsetof(struct BattlePokemon, pp); i++) - battleMonAttacker[i] = battleMonTarget[i]; + battleMonAttacker->species = battleMonTarget->species; + battleMonAttacker->attack = battleMonTarget->attack; + battleMonAttacker->defense = battleMonTarget->defense; + battleMonAttacker->speed = battleMonTarget->speed; + battleMonAttacker->spAttack = battleMonTarget->spAttack; + battleMonAttacker->spDefense = battleMonTarget->spDefense; + memcpy(battleMonAttacker->moves, battleMonTarget->moves, sizeof(battleMonAttacker->moves)); + battleMonAttacker->hpIV = battleMonTarget->hpIV; + battleMonAttacker->attackIV = battleMonTarget->attackIV; + battleMonAttacker->defenseIV = battleMonTarget->defenseIV; + battleMonAttacker->speedIV = battleMonTarget->speedIV; + battleMonAttacker->spAttackIV = battleMonTarget->spAttackIV; + battleMonAttacker->spDefenseIV = battleMonTarget->spDefenseIV; + battleMonAttacker->abilityNum = battleMonTarget->abilityNum; + memcpy(battleMonAttacker->statStages, battleMonTarget->statStages, sizeof(battleMonAttacker->statStages)); + battleMonAttacker->ability = battleMonTarget->ability; + memcpy(battleMonAttacker->types, battleMonTarget->types, sizeof(battleMonAttacker->types)); gBattleMons[gBattlerAttacker].volatiles.overwrittenAbility = GetBattlerAbility(gBattlerTarget); for (i = 0; i < MAX_MON_MOVES; i++) From 2804c9ee1dac2ce13bffcaf38419a42cbd3fcd69 Mon Sep 17 00:00:00 2001 From: GGbond Date: Mon, 23 Feb 2026 11:32:52 +0800 Subject: [PATCH 2/2] Update battle_script_commands.c --- src/battle_script_commands.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 5405fa02f1..e9da3352e9 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8537,23 +8537,8 @@ static void Cmd_transformdataexecution(void) battleMonAttacker = &gBattleMons[gBattlerAttacker]; battleMonTarget = &gBattleMons[gBattlerTarget]; - battleMonAttacker->species = battleMonTarget->species; - battleMonAttacker->attack = battleMonTarget->attack; - battleMonAttacker->defense = battleMonTarget->defense; - battleMonAttacker->speed = battleMonTarget->speed; - battleMonAttacker->spAttack = battleMonTarget->spAttack; - battleMonAttacker->spDefense = battleMonTarget->spDefense; - memcpy(battleMonAttacker->moves, battleMonTarget->moves, sizeof(battleMonAttacker->moves)); - battleMonAttacker->hpIV = battleMonTarget->hpIV; - battleMonAttacker->attackIV = battleMonTarget->attackIV; - battleMonAttacker->defenseIV = battleMonTarget->defenseIV; - battleMonAttacker->speedIV = battleMonTarget->speedIV; - battleMonAttacker->spAttackIV = battleMonTarget->spAttackIV; - battleMonAttacker->spDefenseIV = battleMonTarget->spDefenseIV; - battleMonAttacker->abilityNum = battleMonTarget->abilityNum; - memcpy(battleMonAttacker->statStages, battleMonTarget->statStages, sizeof(battleMonAttacker->statStages)); - battleMonAttacker->ability = battleMonTarget->ability; - memcpy(battleMonAttacker->types, battleMonTarget->types, sizeof(battleMonAttacker->types)); + // Fields before pp are copied by Transform. Keep new transformable fields above pp. + memcpy(battleMonAttacker, battleMonTarget, offsetof(struct BattlePokemon, pp)); gBattleMons[gBattlerAttacker].volatiles.overwrittenAbility = GetBattlerAbility(gBattlerTarget); for (i = 0; i < MAX_MON_MOVES; i++)