Baneful Bunker + King's Shield

Both apply a move effect from atk49. King's Shield swaps attacker and defender for the sake of Defiant etc. and then swaps them back!
This commit is contained in:
Papa Cancer 2019-04-15 12:02:25 +01:00
parent a7f098d8d1
commit 754befe393
6 changed files with 57 additions and 14 deletions

View file

@ -6416,6 +6416,7 @@ BattleScript_RoughSkinActivates::
BattleScript_SpikyShieldEffect::
orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000
bichalfword gMoveResultFlags, MOVE_RESULT_NO_EFFECT
healthbarupdate BS_ATTACKER
datahpupdate BS_ATTACKER
printstring STRINGID_PKMNHURTSWITH
@ -6423,6 +6424,23 @@ BattleScript_SpikyShieldEffect::
tryfaintmon BS_ATTACKER, FALSE, NULL
return
BattleScript_KingsShieldEffect::
orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000
bichalfword gMoveResultFlags, MOVE_RESULT_NO_EFFECT
seteffectsecondary
setmoveeffect 0
copybyte sBATTLER, gBattlerTarget
copybyte gBattlerTarget, gBattlerAttacker
copybyte gBattlerAttacker, sBATTLER
return
BattleScript_BanefulBunkerEffect::
orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_IGNORE_SAFEGUARD | HITMARKER_x100000
bichalfword gMoveResultFlags, MOVE_RESULT_NO_EFFECT
seteffectsecondary
setmoveeffect 0
return
BattleScript_CuteCharmActivates::
call BattleScript_AbilityPopUp
status2animation BS_ATTACKER, STATUS2_INFATUATION

View file

@ -300,6 +300,8 @@ extern const u8 BattleScript_PowderMoveNoEffect[];
extern const u8 BattleScript_GrassyTerrainLoop[];
extern const u8 BattleScript_VCreateStatLoss[];
extern const u8 BattleScript_SpikyShieldEffect[];
extern const u8 BattleScript_KingsShieldEffect[];
extern const u8 BattleScript_BanefulBunkerEffect[];
extern const u8 BattleScript_FlowerVeilProtectsRet[];
extern const u8 BattleScript_SweetVeilProtectsRet[];

View file

@ -162,7 +162,7 @@
#define ATK48_DONT_CHECK_LOWER 0x8
// atk49, moveend cases
#define ATK49_SPIKY_SHIELD 0
#define ATK49_PROTECT_LIKE_EFFECT 0
#define ATK49_RAGE 1
#define ATK49_DEFROST 2
#define ATK49_SYNCHRONIZE_TARGET 3

View file

@ -87,7 +87,7 @@ static const u8 sText_PkmnAlreadyAsleep[] = _("{B_DEF_NAME_WITH_PREFIX} is\nalre
static const u8 sText_PkmnAlreadyAsleep2[] = _("{B_ATK_NAME_WITH_PREFIX} is\nalready asleep!");
static const u8 sText_PkmnWasntAffected[] = _("{B_DEF_NAME_WITH_PREFIX}\nwasn't affected!");
static const u8 sText_PkmnWasPoisoned[] = _("{B_EFF_NAME_WITH_PREFIX}\nwas poisoned!");
static const u8 sText_PkmnPoisonedBy[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX}'s {B_SCR_ACTIVE_ABILITY}\npoisoned {B_EFF_NAME_WITH_PREFIX}!");
static const u8 sText_PkmnPoisonedBy[] = _("{B_EFF_NAME_WITH_PREFIX} was poisoned by\n{B_SCR_ACTIVE_NAME_WITH_PREFIX}'s {B_BUFF1}!");
static const u8 sText_PkmnHurtByPoison[] = _("{B_ATK_NAME_WITH_PREFIX} is hurt\nby poison!");
static const u8 sText_PkmnAlreadyPoisoned[] = _("{B_DEF_NAME_WITH_PREFIX} is already\npoisoned.");
static const u8 sText_PkmnBadlyPoisoned[] = _("{B_EFF_NAME_WITH_PREFIX} is badly\npoisoned!");

View file

@ -4214,12 +4214,11 @@ static void atk49_moveend(void)
{
switch (gBattleScripting.atk49_state)
{
case ATK49_SPIKY_SHIELD:
if (gProtectStructs[gBattlerTarget].spikyShielded
&& gBattleMoves[gCurrentMove].flags & FLAG_MAKES_CONTACT
&& GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD)
case ATK49_PROTECT_LIKE_EFFECT:
if (gBattleMoves[gCurrentMove].flags & FLAG_MAKES_CONTACT)
{
if (gProtectStructs[gBattlerTarget].spikyShielded && GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD)
{
gMoveResultFlags &= ~(MOVE_RESULT_NO_EFFECT);
gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 8;
if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1;
@ -4228,6 +4227,25 @@ static void atk49_moveend(void)
gBattlescriptCurrInstr = BattleScript_SpikyShieldEffect;
effect = 1;
}
else if (gProtectStructs[gBattlerTarget].kingsShielded)
{
i = gBattlerAttacker;
gBattlerAttacker = gBattlerTarget;
gBattlerTarget = i; // gBattlerTarget and gBattlerAttacker are swapped in order to activate Defiant, if applicable
gBattleScripting.moveEffect = MOVE_EFFECT_ATK_MINUS_2;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_KingsShieldEffect;
effect = 1;
}
else if (gProtectStructs[gBattlerTarget].banefulBunkered)
{
gBattleScripting.moveEffect = MOVE_EFFECT_POISON | MOVE_EFFECT_AFFECTS_USER;
PREPARE_MOVE_BUFFER(gBattleTextBuff1, MOVE_BANEFUL_BUNKER);
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_BanefulBunkerEffect;
effect = 1;
}
}
gBattleScripting.atk49_state++;
break;
case ATK49_RAGE: // rage check

View file

@ -3275,6 +3275,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
gBattleScripting.moveEffect += MOVE_EFFECT_AFFECTS_USER;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_AbilityStatusEffect;
PREPARE_ABILITY_BUFFER(gBattleTextBuff1, ABILITY_EFFECT_SPORE);
gHitMarker |= HITMARKER_IGNORE_SAFEGUARD;
effect++;
}
@ -3288,6 +3289,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
&& (Random() % 3) == 0)
{
gBattleScripting.moveEffect = MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_POISON;
PREPARE_ABILITY_BUFFER(gBattleTextBuff1, ABILITY_POISON_POINT);
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_AbilityStatusEffect;
gHitMarker |= HITMARKER_IGNORE_SAFEGUARD;
@ -5630,6 +5632,9 @@ static inline void MulByTypeEffectiveness(u16 *modifier, u16 move, u8 moveType,
if (moveType == TYPE_GROUND && defType == TYPE_FLYING && IsBattlerGrounded(battlerDef))
mod = UQ_4_12(1.0);
if (gProtectStructs[battlerDef].kingsShielded && gBattleMoves[move].effect != EFFECT_FEINT)
mod = UQ_4_12(1.0);
MulModifier(modifier, mod);
}