From a165f9926d430ab7866d5faebcdc09a87a5257b6 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Sun, 23 Jan 2022 13:46:30 -0500 Subject: [PATCH 1/2] canbestatused for psycho shift --- src/battle_script_commands.c | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 478dba5d22..43280a7294 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8661,19 +8661,13 @@ static void Cmd_various(void) i = TRUE; if (gBattleMons[gBattlerAttacker].status1 & STATUS1_PARALYSIS) { - if (targetAbility == ABILITY_LIMBER) + if (!(CanBeParalyzed(gBattlerTarget))) { gBattlerAbility = gBattlerTarget; BattleScriptPush(T1_READ_PTR(gBattlescriptCurrInstr + 3)); gBattlescriptCurrInstr = BattleScript_PRLZPrevention; i = FALSE; } - else if (IS_BATTLER_OF_TYPE(gBattlerTarget, TYPE_ELECTRIC)) - { - BattleScriptPush(T1_READ_PTR(gBattlescriptCurrInstr + 3)); - gBattlescriptCurrInstr = BattleScript_PRLZPrevention; - i = FALSE; - } else { gBattleCommunication[MULTISTRING_CHOOSER] = 3; @@ -8681,19 +8675,13 @@ static void Cmd_various(void) } else if (gBattleMons[gBattlerAttacker].status1 & STATUS1_PSN_ANY) { - if (targetAbility == ABILITY_IMMUNITY) + if (!CanBePoisoned(gBattlerTarget, targetAbility)) { gBattlerAbility = gBattlerTarget; BattleScriptPush(T1_READ_PTR(gBattlescriptCurrInstr + 3)); gBattlescriptCurrInstr = BattleScript_PSNPrevention; i = FALSE; } - else if (IS_BATTLER_OF_TYPE(gBattlerTarget, TYPE_POISON) || IS_BATTLER_OF_TYPE(gBattlerTarget, TYPE_STEEL)) - { - BattleScriptPush(T1_READ_PTR(gBattlescriptCurrInstr + 3)); - gBattlescriptCurrInstr = BattleScript_PSNPrevention; - i = FALSE; - } else { if (gBattleMons[gBattlerAttacker].status1 & STATUS1_POISON) @@ -8704,20 +8692,13 @@ static void Cmd_various(void) } else if (gBattleMons[gBattlerAttacker].status1 & STATUS1_BURN) { - if (targetAbility == ABILITY_WATER_VEIL - || targetAbility == ABILITY_WATER_BUBBLE) + if (!CanBeBurned(gBattlerTarget)) { gBattlerAbility = gBattlerTarget; BattleScriptPush(T1_READ_PTR(gBattlescriptCurrInstr + 3)); gBattlescriptCurrInstr = BattleScript_BRNPrevention; i = FALSE; } - else if (IS_BATTLER_OF_TYPE(gBattlerTarget, TYPE_FIRE)) - { - BattleScriptPush(T1_READ_PTR(gBattlescriptCurrInstr + 3)); - gBattlescriptCurrInstr = BattleScript_BRNPrevention; - i = FALSE; - } else { gBattleCommunication[MULTISTRING_CHOOSER] = 2; @@ -8725,7 +8706,7 @@ static void Cmd_various(void) } else if (gBattleMons[gBattlerAttacker].status1 & STATUS1_SLEEP) { - if (targetAbility == ABILITY_INSOMNIA || targetAbility == ABILITY_VITAL_SPIRIT) + if (!CanSleep(gBattlerTarget)) { gBattlerAbility = gBattlerTarget; // BattleScriptPush(T1_READ_PTR(gBattlescriptCurrInstr + 3)); From 209279c207f0dfbd62e9d5b96c2d69a81657cd98 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Wed, 9 Feb 2022 14:30:30 -0500 Subject: [PATCH 2/2] fix psycho shift string printing --- data/battle_scripts_1.s | 2 +- src/battle_script_commands.c | 69 +++++------------------------------- 2 files changed, 9 insertions(+), 62 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index ad31bb4e36..624e911bcf 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -1532,7 +1532,7 @@ BattleScript_EffectPsychoShift: BattleScript_EffectPsychoShiftCanWork: jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_ButItFailed jumpifsafeguard BattleScript_SafeguardProtected - trypsychoshift BattleScript_MoveEnd + trypsychoshift BattleScript_ButItFailed attackanimation waitanimation copybyte gEffectBattler, gBattlerTarget diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 43280a7294..a078122b2d 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8657,70 +8657,17 @@ static void Cmd_various(void) return; case VARIOUS_PSYCHO_SHIFT: { - u16 targetAbility = GetBattlerAbility(gBattlerTarget); - i = TRUE; - if (gBattleMons[gBattlerAttacker].status1 & STATUS1_PARALYSIS) + if ((gBattleMons[gBattlerAttacker].status1 & STATUS1_PARALYSIS && !CanBeParalyzed(gBattlerTarget)) + || (gBattleMons[gBattlerAttacker].status1 & STATUS1_PSN_ANY && !CanBePoisoned(gBattlerAttacker, gBattlerTarget)) + || (gBattleMons[gBattlerAttacker].status1 & STATUS1_BURN && !CanBeBurned(gBattlerTarget)) + || (gBattleMons[gBattlerAttacker].status1 & STATUS1_SLEEP && !CanSleep(gBattlerTarget))) { - if (!(CanBeParalyzed(gBattlerTarget))) - { - gBattlerAbility = gBattlerTarget; - BattleScriptPush(T1_READ_PTR(gBattlescriptCurrInstr + 3)); - gBattlescriptCurrInstr = BattleScript_PRLZPrevention; - i = FALSE; - } - else - { - gBattleCommunication[MULTISTRING_CHOOSER] = 3; - } + // fails + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); } - else if (gBattleMons[gBattlerAttacker].status1 & STATUS1_PSN_ANY) - { - if (!CanBePoisoned(gBattlerTarget, targetAbility)) - { - gBattlerAbility = gBattlerTarget; - BattleScriptPush(T1_READ_PTR(gBattlescriptCurrInstr + 3)); - gBattlescriptCurrInstr = BattleScript_PSNPrevention; - i = FALSE; - } - else - { - if (gBattleMons[gBattlerAttacker].status1 & STATUS1_POISON) - gBattleCommunication[MULTISTRING_CHOOSER] = 0; - else - gBattleCommunication[MULTISTRING_CHOOSER] = 1; - } - } - else if (gBattleMons[gBattlerAttacker].status1 & STATUS1_BURN) - { - if (!CanBeBurned(gBattlerTarget)) - { - gBattlerAbility = gBattlerTarget; - BattleScriptPush(T1_READ_PTR(gBattlescriptCurrInstr + 3)); - gBattlescriptCurrInstr = BattleScript_BRNPrevention; - i = FALSE; - } - else - { - gBattleCommunication[MULTISTRING_CHOOSER] = 2; - } - } - else if (gBattleMons[gBattlerAttacker].status1 & STATUS1_SLEEP) - { - if (!CanSleep(gBattlerTarget)) - { - gBattlerAbility = gBattlerTarget; - // BattleScriptPush(T1_READ_PTR(gBattlescriptCurrInstr + 3)); - // gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); - i = FALSE; - } - else - { - gBattleCommunication[MULTISTRING_CHOOSER] = 4; - } - } - - if (i == TRUE) + else { + // Psycho shift works gBattleMons[gBattlerTarget].status1 = gBattleMons[gBattlerAttacker].status1 & STATUS1_ANY; gActiveBattler = gBattlerTarget; BtlController_EmitSetMonData(BUFFER_A, REQUEST_STATUS_BATTLE, 0, sizeof(gBattleMons[gActiveBattler].status1), &gBattleMons[gActiveBattler].status1);