This commit is contained in:
DizzyEggg 2018-09-23 19:03:53 +02:00
parent 6b7a171dbe
commit 3f2beff554
9 changed files with 111 additions and 6 deletions

View file

@ -1505,6 +1505,12 @@
various \battler, VARIOUS_ABILITY_POPUP
.endm
.macro defogclear battler, clear, ptr
various \battler, VARIOUS_DEFOG
.byte \clear
.4byte \ptr
.endm
@ helpful macros
.macro setstatchanger stat, stages, down
setbyte sSTATCHANGER \stat | \stages << 4 | \down << 7

View file

@ -317,6 +317,41 @@ gBattleScriptsForMoveEffects:: @ 82D86A8
.4byte BattleScript_EffectJudgment
.4byte BattleScript_EffectAutonomize
.4byte BattleScript_EffectCopycat
.4byte BattleScript_EffectDefog
BattleScript_EffectDefog:
setstatchanger STAT_EVASION, 1, TRUE
attackcanceler
jumpifsubstituteblocks BattleScript_DefogIfCanClearHazards
jumpifstat BS_TARGET, CMP_NOT_EQUAL, STAT_EVASION, 0x0, BattleScript_DefogWorks
BattleScript_DefogIfCanClearHazards:
defogclear BS_ATTACKER, FALSE, BattleScript_ButItFailedAtkStringPpReduce
BattleScript_DefogWorks:
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
attackstring
ppreduce
statbuffchange 0x1, BattleScript_DefogTryHazardsWithAnim
jumpifbyte CMP_LESS_THAN, cMULTISTRING_CHOOSER, 0x2, BattleScript_DefogDoAnim
jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x3, BattleScript_DefogTryHazardsWithAnim
pause 0x20
goto BattleScript_DefogPrintString
BattleScript_DefogDoAnim::
attackanimation
waitanimation
setgraphicalstatchangevalues
playanimation BS_TARGET, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1
BattleScript_DefogPrintString::
printfromtable gStatDownStringIds
waitmessage 0x40
BattleScript_DefogTryHazards::
copybyte gEffectBattler, gBattlerAttacker
defogclear BS_ATTACKER, TRUE, NULL
copybyte gBattlerAttacker, gEffectBattler
goto BattleScript_MoveEnd
BattleScript_DefogTryHazardsWithAnim:
attackanimation
waitanimation
goto BattleScript_DefogTryHazards
BattleScript_EffectCopycat:
attackcanceler
@ -4370,10 +4405,10 @@ BattleScript_SideStatusWoreOff::
waitmessage 0x40
end2
BattleScript_AuroraVeilEnds::
printstring STRINGID_AURORAVEILENDS
BattleScript_SideStatusWoreOffReturn::
printstring STRINGID_PKMNSXWOREOFF
waitmessage 0x40
end2
return
BattleScript_LuckyChantEnds::
printstring STRINGID_LUCKYCHANTENDS

View file

@ -157,7 +157,7 @@
{ \
textVar[0] = B_BUFF_PLACEHOLDER_BEGIN; \
textVar[1] = B_BUFF_MOVE; \
textVar[2] = move; \
textVar[2] = move & 0xFF; \
textVar[3] = (move & 0xFF00) >> 8; \
textVar[4] = B_BUFF_EOS; \
}

View file

@ -277,5 +277,6 @@ extern const u8 BattleScript_MoveEffectRecoilWithStatus[];
extern const u8 BattleScript_EffectWithChance[];
extern const u8 BattleScript_MoveEffectClearSmog[];
extern const u8 BattleScript_ForceRandomSwitch[];
extern const u8 BattleScript_SideStatusWoreOffReturn[];
#endif // GUARD_BATTLE_SCRIPTS_H

View file

@ -306,5 +306,6 @@
#define EFFECT_JUDGMENT 300
#define EFFECT_AUTONOMIZE 301
#define EFFECT_COPYCAT 302
#define EFFECT_DEFOG 303
#endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H

View file

@ -107,6 +107,7 @@
#define VARIOUS_TRY_AUTONOMIZE 55
#define VARIOUS_TRY_COPYCAT 56
#define VARIOUS_ABILITY_POPUP 57
#define VARIOUS_DEFOG 58
// atk80, dmg manipulation
#define ATK80_DMG_CHANGE_SIGN 0

View file

@ -6190,6 +6190,49 @@ bool32 CanUseLastResort(u8 battlerId)
return FALSE;
}
#define DEFOG_CLEAR(status, structField, battlescript, move)\
{ \
if (*sideStatuses & status) \
{ \
if (clear) \
{ \
if (move) \
PREPARE_MOVE_BUFFER(gBattleTextBuff1, move);\
*sideStatuses &= ~(status); \
sideTimer->structField = 0; \
BattleScriptPushCursor(); \
gBattlescriptCurrInstr = battlescript; \
} \
return TRUE; \
} \
}
static bool32 ClearDefogHazards(u8 battlerAtk, bool32 clear)
{
s32 i;
for (i = 0; i < 2; i++)
{
struct SideTimer *sideTimer = &gSideTimers[i];
u32 *sideStatuses = &gSideStatuses[i];
gBattlerAttacker = i;
if (GetBattlerSide(battlerAtk) != i)
{
DEFOG_CLEAR(SIDE_STATUS_REFLECT, reflectTimer, BattleScript_SideStatusWoreOffReturn, MOVE_REFLECT);
DEFOG_CLEAR(SIDE_STATUS_LIGHTSCREEN, lightscreenTimer, BattleScript_SideStatusWoreOffReturn, MOVE_LIGHT_SCREEN);
DEFOG_CLEAR(SIDE_STATUS_MIST, mistTimer, BattleScript_SideStatusWoreOffReturn, MOVE_MIST);
DEFOG_CLEAR(SIDE_STATUS_AURORA_VEIL, auroraVeilTimer, BattleScript_SideStatusWoreOffReturn, MOVE_AURORA_VEIL);
DEFOG_CLEAR(SIDE_STATUS_SAFEGUARD, safeguardTimer, BattleScript_SideStatusWoreOffReturn, MOVE_SAFEGUARD);
}
DEFOG_CLEAR(SIDE_STATUS_SPIKES, spikesAmount, BattleScript_SpikesFree, 0);
DEFOG_CLEAR(SIDE_STATUS_STEALTH_ROCK, stealthRockAmount, BattleScript_StealthRockFree, 0);
DEFOG_CLEAR(SIDE_STATUS_TOXIC_SPIKES, toxicSpikesAmount, BattleScript_ToxicSpikesFree, 0);
DEFOG_CLEAR(SIDE_STATUS_STICKY_WEB, stickyWebAmount, BattleScript_StickyWebFree, 0);
}
return FALSE;
}
static void atk76_various(void)
{
struct Pokemon *mon;
@ -6779,6 +6822,22 @@ static void atk76_various(void)
case VARIOUS_ABILITY_POPUP:
CreateAbilityPopUp(gActiveBattler, ABILITY_SPEED_BOOST);
break;
case VARIOUS_DEFOG:
if (T1_READ_8(gBattlescriptCurrInstr + 3)) // Clear
{
if (ClearDefogHazards(gEffectBattler, TRUE))
return;
else
gBattlescriptCurrInstr += 8;
}
else
{
if (ClearDefogHazards(gActiveBattler, FALSE))
gBattlescriptCurrInstr += 8;
else
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 4);
}
return;
}
gBattlescriptCurrInstr += 3;

View file

@ -950,7 +950,9 @@ u8 DoFieldEndTurnEffects(void)
if (--gSideTimers[side].auroraVeilTimer == 0)
{
gSideStatuses[side] &= ~SIDE_STATUS_AURORA_VEIL;
BattleScriptExecute(BattleScript_AuroraVeilEnds);
BattleScriptExecute(BattleScript_SideStatusWoreOff);
gBattleCommunication[MULTISTRING_CHOOSER] = side;
PREPARE_MOVE_BUFFER(gBattleTextBuff1, MOVE_AURORA_VEIL);
effect++;
}
}

View file

@ -5193,7 +5193,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
.split = SPLIT_PHYSICAL,
},
{ // MOVE_DEFOG
.effect = EFFECT_PLACEHOLDER, // Needs a custom move effect
.effect = EFFECT_DEFOG,
.power = 0,
.type = TYPE_FLYING,
.accuracy = 0,