From 48c801245cd893d5965f71d7dbfbf3ac79f7c11c Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Tue, 25 Jun 2019 13:04:14 +0200 Subject: [PATCH] Fix Synchronize --- include/battle.h | 2 +- src/battle_util.c | 48 ++++++++++++++++++++++++++++------------------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/include/battle.h b/include/battle.h index 4f7d59a45..43682348a 100644 --- a/include/battle.h +++ b/include/battle.h @@ -474,7 +474,7 @@ struct BattleStruct u32 savedBattleTypeFlags; u8 abilityPreventingSwitchout; u8 hpScale; - u8 synchronizeMoveEffect; + u16 synchronizeMoveEffect; bool8 anyMonHasTransformed; void (*savedCallback)(void); u16 usedHeldItems[MAX_BATTLERS_COUNT]; diff --git a/src/battle_util.c b/src/battle_util.c index cb968a519..c4158c387 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -3527,32 +3527,42 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA if (gLastUsedAbility == ABILITY_SYNCHRONIZE && (gHitMarker & HITMARKER_SYNCHRONISE_EFFECT)) { gHitMarker &= ~(HITMARKER_SYNCHRONISE_EFFECT); - gBattleStruct->synchronizeMoveEffect &= ~(MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN); - if (gBattleStruct->synchronizeMoveEffect == MOVE_EFFECT_TOXIC) - gBattleStruct->synchronizeMoveEffect = MOVE_EFFECT_POISON; - gBattleScripting.moveEffect = gBattleStruct->synchronizeMoveEffect + MOVE_EFFECT_AFFECTS_USER; - gBattleScripting.battler = gBattlerTarget; - BattleScriptPushCursor(); - gBattlescriptCurrInstr = BattleScript_SynchronizeActivates; - gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; - effect++; + if (!(gBattleMons[gBattlerAttacker].status1 & STATUS1_ANY)) + { + gBattleStruct->synchronizeMoveEffect &= ~(MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN); + if (gBattleStruct->synchronizeMoveEffect == MOVE_EFFECT_TOXIC) + gBattleStruct->synchronizeMoveEffect = MOVE_EFFECT_POISON; + + gBattleScripting.moveEffect = gBattleStruct->synchronizeMoveEffect + MOVE_EFFECT_AFFECTS_USER; + gBattleScripting.battler = gBattlerAbility = gBattlerTarget; + PREPARE_ABILITY_BUFFER(gBattleTextBuff1, ABILITY_SYNCHRONIZE); + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_SynchronizeActivates; + gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; + effect++; + } } break; case ABILITYEFFECT_ATK_SYNCHRONIZE: // 8 if (gLastUsedAbility == ABILITY_SYNCHRONIZE && (gHitMarker & HITMARKER_SYNCHRONISE_EFFECT)) { gHitMarker &= ~(HITMARKER_SYNCHRONISE_EFFECT); - gBattleStruct->synchronizeMoveEffect &= ~(MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN); - if (gBattleStruct->synchronizeMoveEffect == MOVE_EFFECT_TOXIC) - gBattleStruct->synchronizeMoveEffect = MOVE_EFFECT_POISON; - gBattleScripting.moveEffect = gBattleStruct->synchronizeMoveEffect; - gBattleScripting.battler = gBattlerAttacker; - BattleScriptPushCursor(); - gBattlescriptCurrInstr = BattleScript_SynchronizeActivates; - gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; - effect++; + if (!(gBattleMons[gBattlerTarget].status1 & STATUS1_ANY)) + { + gBattleStruct->synchronizeMoveEffect &= ~(MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN); + if (gBattleStruct->synchronizeMoveEffect == MOVE_EFFECT_TOXIC) + gBattleStruct->synchronizeMoveEffect = MOVE_EFFECT_POISON; + + gBattleScripting.moveEffect = gBattleStruct->synchronizeMoveEffect; + gBattleScripting.battler = gBattlerAbility = gBattlerAttacker; + PREPARE_ABILITY_BUFFER(gBattleTextBuff1, ABILITY_SYNCHRONIZE); + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_SynchronizeActivates; + gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; + effect++; + } } break; case ABILITYEFFECT_INTIMIDATE1: // 9 @@ -3635,7 +3645,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA gBattleResources->flags->flags[i] &= ~(RESOURCE_FLAG_INTIMIDATED); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_IntimidateActivates; - gBattleStruct->intimidateBattler = i; + gBattlerAbility = gBattleStruct->intimidateBattler = i; effect++; break; }