Corrosion (#306)

* Status move poisoning for Steel and Poison types.

* Can poison itself with Toxic Orb.

* Secondary effect poisoning now working.

* Created a function that checks if abilities can bypass type immunities.

* Created macro to handle typeimmunity

* Applied review changes.

* Applied review requests.

* Left more readable version of HOLD_EFFECT_TOXIC_ORB.
This commit is contained in:
Eduardo Alvaro Quezada D'Ottone 2020-04-21 09:59:19 -04:00 committed by GitHub
parent a80150f890
commit c5a6acc7db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 29 additions and 11 deletions

View File

@ -1714,6 +1714,12 @@
.4byte \ptr .4byte \ptr
.endm .endm
.macro trypoisontype attacker:req, target:req, ptr:req
various \attacker, VARIOUS_HANDLE_TYPE_IMMUNITY
.byte \target
.4byte \ptr
.endm
.macro trysetfairylock ptr:req .macro trysetfairylock ptr:req
various BS_ATTACKER, VARIOUS_TRY_FAIRY_LOCK various BS_ATTACKER, VARIOUS_TRY_FAIRY_LOCK
.4byte \ptr .4byte \ptr

View File

@ -2650,8 +2650,7 @@ BattleScript_EffectToxic::
jumpifsubstituteblocks BattleScript_ButItFailed jumpifsubstituteblocks BattleScript_ButItFailed
jumpifstatus BS_TARGET, STATUS1_POISON | STATUS1_TOXIC_POISON, BattleScript_AlreadyPoisoned jumpifstatus BS_TARGET, STATUS1_POISON | STATUS1_TOXIC_POISON, BattleScript_AlreadyPoisoned
jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_ButItFailed jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_ButItFailed
jumpiftype BS_TARGET, TYPE_POISON, BattleScript_NotAffected trypoisontype BS_ATTACKER, BS_TARGET, BattleScript_NotAffected
jumpiftype BS_TARGET, TYPE_STEEL, BattleScript_NotAffected
accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE
jumpifsideaffecting BS_TARGET, SIDE_STATUS_SAFEGUARD, BattleScript_SafeguardProtected jumpifsideaffecting BS_TARGET, SIDE_STATUS_SAFEGUARD, BattleScript_SafeguardProtected
attackanimation attackanimation
@ -2971,8 +2970,7 @@ BattleScript_EffectPoison::
jumpifsubstituteblocks BattleScript_ButItFailed jumpifsubstituteblocks BattleScript_ButItFailed
jumpifstatus BS_TARGET, STATUS1_POISON, BattleScript_AlreadyPoisoned jumpifstatus BS_TARGET, STATUS1_POISON, BattleScript_AlreadyPoisoned
jumpifstatus BS_TARGET, STATUS1_TOXIC_POISON, BattleScript_AlreadyPoisoned jumpifstatus BS_TARGET, STATUS1_TOXIC_POISON, BattleScript_AlreadyPoisoned
jumpiftype BS_TARGET, TYPE_POISON, BattleScript_NotAffected trypoisontype BS_ATTACKER, BS_TARGET, BattleScript_NotAffected
jumpiftype BS_TARGET, TYPE_STEEL, BattleScript_NotAffected
jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_ButItFailed jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_ButItFailed
accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE
jumpifsideaffecting BS_TARGET, SIDE_STATUS_SAFEGUARD, BattleScript_SafeguardProtected jumpifsideaffecting BS_TARGET, SIDE_STATUS_SAFEGUARD, BattleScript_SafeguardProtected

View File

@ -17,6 +17,7 @@ void HandleBattleWindow(u8 xStart, u8 yStart, u8 xEnd, u8 yEnd, u8 flags);
bool8 UproarWakeUpCheck(u8 battlerId); bool8 UproarWakeUpCheck(u8 battlerId);
bool32 DoesSubstituteBlockMove(u8 battlerAtk, u8 battlerDef, u32 move); bool32 DoesSubstituteBlockMove(u8 battlerAtk, u8 battlerDef, u32 move);
bool32 DoesDisguiseBlockMove(u8 battlerAtk, u8 battlerDef, u32 move); bool32 DoesDisguiseBlockMove(u8 battlerAtk, u8 battlerDef, u32 move);
bool32 CanPoisonType(u8 battlerAttacker, u8 battlerTarget);
bool32 CanUseLastResort(u8 battlerId); bool32 CanUseLastResort(u8 battlerId);
u32 IsFlowerVeilProtected(u32 battler); u32 IsFlowerVeilProtected(u32 battler);
u32 IsLeafGuardProtected(u32 battler); u32 IsLeafGuardProtected(u32 battler);

View File

@ -1,6 +1,7 @@
#ifndef GUARD_BATTLE_SCRIPTS_H #ifndef GUARD_BATTLE_SCRIPTS_H
#define GUARD_BATTLE_SCRIPTS_H #define GUARD_BATTLE_SCRIPTS_H
extern const u8 BattleScript_NotAffected[];
extern const u8 BattleScript_HitFromCritCalc[]; extern const u8 BattleScript_HitFromCritCalc[];
extern const u8 BattleScript_MoveEnd[]; extern const u8 BattleScript_MoveEnd[];
extern const u8 BattleScript_MakeMoveMissed[]; extern const u8 BattleScript_MakeMoveMissed[];

View File

@ -156,6 +156,7 @@
#define VARIOUS_JUMP_IF_SHIELDS_DOWN_PROTECTED 93 #define VARIOUS_JUMP_IF_SHIELDS_DOWN_PROTECTED 93
#define VARIOUS_TRY_FAIRY_LOCK 94 #define VARIOUS_TRY_FAIRY_LOCK 94
#define VARIOUS_JUMP_IF_NO_ALLY 95 #define VARIOUS_JUMP_IF_NO_ALLY 95
#define VARIOUS_HANDLE_TYPE_IMMUNITY 96
// Cmd_manipulatedamage // Cmd_manipulatedamage
#define DMG_CHANGE_SIGN 0 #define DMG_CHANGE_SIGN 0

View File

@ -2254,7 +2254,7 @@ void SetMoveEffect(bool32 primary, u32 certain)
} }
RESET_RETURN RESET_RETURN
} }
if ((IS_BATTLER_OF_TYPE(gEffectBattler, TYPE_POISON) || IS_BATTLER_OF_TYPE(gEffectBattler, TYPE_STEEL)) if (!CanPoisonType(gBattleScripting.battler, gEffectBattler)
&& (gHitMarker & HITMARKER_IGNORE_SAFEGUARD) && (gHitMarker & HITMARKER_IGNORE_SAFEGUARD)
&& (primary == TRUE || certain == MOVE_EFFECT_CERTAIN)) && (primary == TRUE || certain == MOVE_EFFECT_CERTAIN))
{ {
@ -2264,9 +2264,7 @@ void SetMoveEffect(bool32 primary, u32 certain)
gBattleCommunication[MULTISTRING_CHOOSER] = 2; gBattleCommunication[MULTISTRING_CHOOSER] = 2;
RESET_RETURN RESET_RETURN
} }
if (IS_BATTLER_OF_TYPE(gEffectBattler, TYPE_POISON)) if (!CanPoisonType(gBattleScripting.battler, gEffectBattler))
break;
if (IS_BATTLER_OF_TYPE(gEffectBattler, TYPE_STEEL))
break; break;
if (gBattleMons[gEffectBattler].status1) if (gBattleMons[gEffectBattler].status1)
break; break;
@ -2401,7 +2399,7 @@ void SetMoveEffect(bool32 primary, u32 certain)
} }
RESET_RETURN RESET_RETURN
} }
if ((IS_BATTLER_OF_TYPE(gEffectBattler, TYPE_POISON) || IS_BATTLER_OF_TYPE(gEffectBattler, TYPE_STEEL)) if (!CanPoisonType(gBattleScripting.battler, gEffectBattler)
&& (gHitMarker & HITMARKER_IGNORE_SAFEGUARD) && (gHitMarker & HITMARKER_IGNORE_SAFEGUARD)
&& (primary == TRUE || certain == MOVE_EFFECT_CERTAIN)) && (primary == TRUE || certain == MOVE_EFFECT_CERTAIN))
{ {
@ -2413,7 +2411,7 @@ void SetMoveEffect(bool32 primary, u32 certain)
} }
if (gBattleMons[gEffectBattler].status1) if (gBattleMons[gEffectBattler].status1)
break; break;
if (!IS_BATTLER_OF_TYPE(gEffectBattler, TYPE_POISON) && !IS_BATTLER_OF_TYPE(gEffectBattler, TYPE_STEEL)) if (CanPoisonType(gBattleScripting.battler, gEffectBattler))
{ {
if (GetBattlerAbility(gEffectBattler) == ABILITY_IMMUNITY if (GetBattlerAbility(gEffectBattler) == ABILITY_IMMUNITY
|| GetBattlerAbility(gEffectBattler) == ABILITY_COMATOSE || GetBattlerAbility(gEffectBattler) == ABILITY_COMATOSE
@ -6672,6 +6670,13 @@ static void HandleTerrainMove(u32 moveEffect)
} }
} }
bool32 CanPoisonType(u8 battlerAttacker, u8 battlerTarget)
{
return (GetBattlerAbility(battlerAttacker) == ABILITY_CORROSION
|| !(IS_BATTLER_OF_TYPE(battlerTarget, TYPE_POISON)
|| IS_BATTLER_OF_TYPE(battlerTarget, TYPE_STEEL)));
}
bool32 CanUseLastResort(u8 battlerId) bool32 CanUseLastResort(u8 battlerId)
{ {
u32 i; u32 i;
@ -6885,6 +6890,12 @@ static void Cmd_various(void)
gBattleStruct->friskedBattler = 0; gBattleStruct->friskedBattler = 0;
gBattleStruct->friskedAbility = FALSE; gBattleStruct->friskedAbility = FALSE;
break; break;
case VARIOUS_HANDLE_TYPE_IMMUNITY:
if (!CanPoisonType(gActiveBattler, GetBattlerForBattleScript(gBattlescriptCurrInstr[3])))
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 4);
else
gBattlescriptCurrInstr += 8;
return;
case VARIOUS_TRACE_ABILITY: case VARIOUS_TRACE_ABILITY:
gBattleMons[gActiveBattler].ability = gBattleStruct->tracedAbility[gActiveBattler]; gBattleMons[gActiveBattler].ability = gBattleStruct->tracedAbility[gActiveBattler];
RecordAbilityBattle(gActiveBattler, gBattleMons[gActiveBattler].ability); RecordAbilityBattle(gActiveBattler, gBattleMons[gActiveBattler].ability);

View File

@ -4865,7 +4865,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
{ {
case HOLD_EFFECT_TOXIC_ORB: case HOLD_EFFECT_TOXIC_ORB:
if (!gBattleMons[battlerId].status1 if (!gBattleMons[battlerId].status1
&& !IS_BATTLER_OF_TYPE(battlerId, TYPE_POISON) && !IS_BATTLER_OF_TYPE(battlerId, TYPE_STEEL) && CanPoisonType(battlerId, battlerId)
&& GetBattlerAbility(battlerId) != ABILITY_IMMUNITY) && GetBattlerAbility(battlerId) != ABILITY_IMMUNITY)
{ {
effect = ITEM_STATUS_CHANGE; effect = ITEM_STATUS_CHANGE;