Disguise ability (#258)

* Protection from attacks.

* Changes form when Busting Disguise.

* Ability changing moves set to fail.

- Simple Beam and Worry Seed now fail if the target has Disguise.
- Role Play and Skill Swap now fail if either the attacker or the target have Disguise.

* Disguise no longer triggers when transformed.

* Mimikyu reverts to Disguised

* No longer blocks from entry hazards and weather.

* Applied review changes

* Oops, new line

* yeah
This commit is contained in:
Eduardo Alvaro Quezada D'Ottone 2020-02-08 15:29:51 -03:00 committed by GitHub
parent 14bc2f65f3
commit 33e8e20118
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 74 additions and 27 deletions

View File

@ -5903,6 +5903,19 @@ BattleScript_StanceChangeActivates::
waitanimation waitanimation
handleformchange BS_ATTACKER, 2 handleformchange BS_ATTACKER, 2
return return
BattleScript_DisguiseBustedActivates::
pause 0x5
copybyte gBattlerAbility, gBattlerTarget
call BattleScript_AbilityPopUp
printstring STRINGID_EMPTYSTRING3
waitmessage 0x1
handleformchange BS_TARGET, 0
handleformchange BS_TARGET, 1
playanimation BS_TARGET, B_ANIM_FORM_CHANGE, NULL
waitanimation
handleformchange BS_TARGET, 2
return
BattleScript_IllusionOff:: BattleScript_IllusionOff::
spriteignore0hp TRUE spriteignore0hp TRUE

View File

@ -14,6 +14,7 @@ void BufferMoveToLearnIntoBattleTextBuff2(void);
void HandleBattleWindow(u8 xStart, u8 yStart, u8 xEnd, u8 yEnd, u8 flags); 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 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

@ -329,5 +329,6 @@ extern const u8 BattleScript_IllusionOff[];
extern const u8 BattleScript_DancerActivates[]; extern const u8 BattleScript_DancerActivates[];
extern const u8 BattleScript_AftermathDmg[]; extern const u8 BattleScript_AftermathDmg[];
extern const u8 BattleScript_StanceChangeActivates[]; extern const u8 BattleScript_StanceChangeActivates[];
extern const u8 BattleScript_DisguiseBustedActivates[];
#endif // GUARD_BATTLE_SCRIPTS_H #endif // GUARD_BATTLE_SCRIPTS_H

View File

@ -11,6 +11,8 @@
#define SPECIES_GENESECT 0 #define SPECIES_GENESECT 0
#define SPECIES_AEGISLASH 0 #define SPECIES_AEGISLASH 0
#define SPECIES_AEGISLASH_BLADE 10000 #define SPECIES_AEGISLASH_BLADE 10000
#define SPECIES_MIMIKYU 0
#define SPECIES_MIMIKYU_BUSTED 10001
// Items with peculiar battle effects. Remove them if they're properly placed in constant/items.h // Items with peculiar battle effects. Remove them if they're properly placed in constant/items.h
#define ITEM_GRISEOUS_ORB 0 #define ITEM_GRISEOUS_ORB 0

View File

@ -1532,6 +1532,8 @@ static void Cmd_adjustdamage(void)
if (DoesSubstituteBlockMove(gBattlerAttacker, gBattlerTarget, gCurrentMove)) if (DoesSubstituteBlockMove(gBattlerAttacker, gBattlerTarget, gCurrentMove))
goto END; goto END;
if (DoesDisguiseBlockMove(gBattlerAttacker, gBattlerTarget, gCurrentMove))
goto END;
if (gBattleMons[gBattlerTarget].hp > gBattleMoveDamage) if (gBattleMons[gBattlerTarget].hp > gBattleMoveDamage)
goto END; goto END;
@ -1709,17 +1711,9 @@ static void Cmd_healthbarupdate(void)
{ {
PrepareStringBattle(STRINGID_SUBSTITUTEDAMAGED, gActiveBattler); PrepareStringBattle(STRINGID_SUBSTITUTEDAMAGED, gActiveBattler);
} }
else else if (!DoesDisguiseBlockMove(gBattlerAttacker, gActiveBattler, gCurrentMove))
{ {
s16 healthValue; s16 healthValue = min(gBattleMoveDamage, 10000); // Max damage (10000) not present in R/S, ensures that huge damage values don't change sign
s32 currDmg = gBattleMoveDamage;
s32 maxPossibleDmgValue = 10000; // not present in R/S, ensures that huge damage values don't change sign
if (currDmg <= maxPossibleDmgValue)
healthValue = currDmg;
else
healthValue = maxPossibleDmgValue;
BtlController_EmitHealthBarUpdate(0, healthValue); BtlController_EmitHealthBarUpdate(0, healthValue);
MarkBattlerForControllerExec(gActiveBattler); MarkBattlerForControllerExec(gActiveBattler);
@ -1774,6 +1768,12 @@ static void Cmd_datahpupdate(void)
return; return;
} }
} }
else if (DoesDisguiseBlockMove(gBattlerAttacker, gActiveBattler, gCurrentMove))
{
gBattleMons[gActiveBattler].species = SPECIES_MIMIKYU_BUSTED;
BattleScriptPush(gBattlescriptCurrInstr + 2);
gBattlescriptCurrInstr = BattleScript_DisguiseBustedActivates;
}
else else
{ {
gHitMarker &= ~(HITMARKER_IGNORE_SUBSTITUTE); gHitMarker &= ~(HITMARKER_IGNORE_SUBSTITUTE);
@ -7132,6 +7132,7 @@ static void Cmd_various(void)
case ABILITY_SIMPLE: case ABILITY_SIMPLE:
case ABILITY_TRUANT: case ABILITY_TRUANT:
case ABILITY_STANCE_CHANGE: case ABILITY_STANCE_CHANGE:
case ABILITY_DISGUISE:
case ABILITY_MULTITYPE: case ABILITY_MULTITYPE:
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3);
break; break;
@ -10570,16 +10571,18 @@ static void Cmd_tryswapitems(void) // trick
static void Cmd_trycopyability(void) // role play static void Cmd_trycopyability(void) // role play
{ {
if (gBattleMons[gBattlerTarget].ability != 0 switch (gBattleMons[gBattlerTarget].ability)
&& gBattleMons[gBattlerTarget].ability != ABILITY_WONDER_GUARD)
{ {
gBattleMons[gBattlerAttacker].ability = gBattleMons[gBattlerTarget].ability; case ABILITY_NONE:
gLastUsedAbility = gBattleMons[gBattlerTarget].ability; case ABILITY_WONDER_GUARD:
gBattlescriptCurrInstr += 5; case ABILITY_DISGUISE:
} gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
else break;
{ default:
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); gBattleMons[gBattlerAttacker].ability = gBattleMons[gBattlerTarget].ability;
gLastUsedAbility = gBattleMons[gBattlerTarget].ability;
gBattlescriptCurrInstr += 5;
break;
} }
} }
@ -10718,14 +10721,28 @@ static void Cmd_setroom(void)
static void Cmd_tryswapabilities(void) // skill swap static void Cmd_tryswapabilities(void) // skill swap
{ {
if ((gBattleMons[gBattlerAttacker].ability == 0 switch (gBattleMons[gBattlerAttacker].ability)
&& gBattleMons[gBattlerTarget].ability == 0) {
|| gBattleMons[gBattlerAttacker].ability == ABILITY_WONDER_GUARD case ABILITY_NONE:
|| gBattleMons[gBattlerTarget].ability == ABILITY_WONDER_GUARD case ABILITY_WONDER_GUARD:
|| gMoveResultFlags & MOVE_RESULT_NO_EFFECT) case ABILITY_DISGUISE:
{ gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); return;
} }
switch (gBattleMons[gBattlerTarget].ability)
{
case ABILITY_NONE:
case ABILITY_WONDER_GUARD:
case ABILITY_DISGUISE:
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
return;
}
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT))
{
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
}
else else
{ {
u8 abilityAtk = gBattleMons[gBattlerAttacker].ability; u8 abilityAtk = gBattleMons[gBattlerAttacker].ability;
@ -11133,6 +11150,17 @@ bool32 DoesSubstituteBlockMove(u8 battlerAtk, u8 battlerDef, u32 move)
return TRUE; return TRUE;
} }
bool32 DoesDisguiseBlockMove(u8 battlerAtk, u8 battlerDef, u32 move)
{
if (GetBattlerAbility(battlerDef) != ABILITY_DISGUISE
|| gBattleMons[battlerDef].species != SPECIES_MIMIKYU
|| gBattleMons[battlerDef].status2 & STATUS2_TRANSFORMED
|| gBattleMoves[move].power == 0)
return FALSE;
else
return TRUE;
}
static void Cmd_jumpifsubstituteblocks(void) static void Cmd_jumpifsubstituteblocks(void)
{ {
if (DoesSubstituteBlockMove(gBattlerAttacker, gBattlerTarget, gCurrentMove)) if (DoesSubstituteBlockMove(gBattlerAttacker, gBattlerTarget, gCurrentMove))
@ -11740,6 +11768,7 @@ static void Cmd_tryworryseed(void)
case ABILITY_MULTITYPE: case ABILITY_MULTITYPE:
case ABILITY_TRUANT: case ABILITY_TRUANT:
case ABILITY_STANCE_CHANGE: case ABILITY_STANCE_CHANGE:
case ABILITY_DISGUISE:
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
break; break;
default: default:

View File

@ -6314,6 +6314,7 @@ void UndoFormChange(u32 monId, u32 side)
static const u16 species[][2] = // changed form id, default form id static const u16 species[][2] = // changed form id, default form id
{ {
{SPECIES_AEGISLASH_BLADE, SPECIES_AEGISLASH}, {SPECIES_AEGISLASH_BLADE, SPECIES_AEGISLASH},
{SPECIES_MIMIKYU_BUSTED, SPECIES_MIMIKYU},
}; };
currSpecies = GetMonData(&party[monId], MON_DATA_SPECIES, NULL); currSpecies = GetMonData(&party[monId], MON_DATA_SPECIES, NULL);