add wandering spirit

This commit is contained in:
ghoulslash 2021-10-12 10:32:51 -04:00
parent e66820e646
commit bbd09fdcf7
10 changed files with 90 additions and 3 deletions

View File

@ -1580,6 +1580,10 @@
.macro showabilitypopup battler:req
various \battler, VARIOUS_ABILITY_POPUP
.endm
.macro updateabilitypopup battler:req
various \battler, VARIOUS_UPDATE_ABILITY_POPUP
.endm
.macro defogclear battler:req, clear:req, ptr:req
various \battler, VARIOUS_DEFOG
@ -1825,6 +1829,10 @@
various BS_ATTACKER, VARIOUS_TRY_TO_CLEAR_PRIMAL_WEATHER
.endm
.macro swapabilities
various BS_ATTACKER, VARIOUS_SWAP_ABILITIES
.endm
@ helpful macros
.macro setstatchanger stat:req, stages:req, down:req
setbyte sSTATCHANGER \stat | \stages << 3 | \down << 7

View File

@ -7676,6 +7676,32 @@ BattleScript_MummyActivates::
waitmessage B_WAIT_TIME_LONG
return
BattleScript_WanderingSpiritActivates::
.if B_ABILITY_POP_UP == TRUE
setbyte sFIXED_ABILITY_POPUP, TRUE
sethword sABILITY_OVERWRITE, ABILITY_WANDERING_SPIRIT
showabilitypopup BS_TARGET
pause 60
sethword sABILITY_OVERWRITE, 0
updateabilitypopup BS_TARGET
pause 20
destroyabilitypopup
pause 40
setbyte sFIXED_ABILITY_POPUP, TRUE
copyhword sABILITY_OVERWRITE, gLastUsedAbility
showabilitypopup BS_ATTACKER
pause 60
sethword sABILITY_OVERWRITE, 0
updateabilitypopup BS_ATTACKER
pause 20
destroyabilitypopup
pause 40
.endif
printstring STRINGID_SWAPPEDABILITIES
waitmessage B_WAIT_TIME_LONG
return
BattleScript_TargetsStatWasMaxedOut::
call BattleScript_AbilityPopUp
statbuffchange STAT_BUFF_NOT_PROTECT_AFFECTED | MOVE_EFFECT_CERTAIN, NULL

View File

@ -97,5 +97,6 @@ bool32 CanThrowLastUsedBall(void);
void TryHideLastUsedBall(void);
void TryRestoreLastUsedBall(void);
void TryAddLastUsedBallItemSprites(void);
void UpdateAbilityPopup(u8 battlerId);
#endif // GUARD_BATTLE_INTERFACE_H

View File

@ -398,5 +398,6 @@ extern const u8 BattleScript_MysteriousAirCurrentBlowsOn[];
extern const u8 BattleScript_AttackWeakenedByStrongWinds[];
extern const u8 BattleScript_BlockedByPrimalWeatherEnd3[];
extern const u8 BattleScript_BlockedByPrimalWeatherRet[];
extern const u8 BattleScript_WanderingSpiritActivates[];
#endif // GUARD_BATTLE_SCRIPTS_H

View File

@ -185,6 +185,7 @@
#define VARIOUS_REMOVE_TERRAIN 113
#define VARIOUS_JUMP_IF_PRANKSTER_BLOCKED 114
#define VARIOUS_TRY_TO_CLEAR_PRIMAL_WEATHER 115
#define VARIOUS_UPDATE_ABILITY_POPUP 116
// Cmd_manipulatedamage
#define DMG_CHANGE_SIGN 0

View File

@ -592,8 +592,9 @@
#define STRINGID_STRONGWINDSDISSIPATED 588
#define STRINGID_MYSTERIOUSAIRCURRENTBLOWSON 589
#define STRINGID_ATTACKWEAKENEDBSTRONGWINDS 590
#define STRINGID_SWAPPEDABILITIES 591
#define BATTLESTRINGS_COUNT 591
#define BATTLESTRINGS_COUNT 592
// The below IDs are all indexes into battle message tables,
// used to determine which of a set of messages to print.

View File

@ -3065,8 +3065,8 @@ void CreateAbilityPopUp(u8 battlerId, u32 ability, bool32 isDoubleBattle)
gSprites[spriteId2].tRightToLeft = FALSE;
}
gBattleStruct->abilityPopUpSpriteIds[gBattleAnimAttacker][0] = spriteId1;
gBattleStruct->abilityPopUpSpriteIds[gBattleAnimAttacker][1] = spriteId2;
gBattleStruct->abilityPopUpSpriteIds[battlerId][0] = spriteId1;
gBattleStruct->abilityPopUpSpriteIds[battlerId][1] = spriteId2;
taskId = CreateTask(Task_FreeAbilityPopUpGfx, 5);
gTasks[taskId].tSpriteId1 = spriteId1;
@ -3084,6 +3084,16 @@ void CreateAbilityPopUp(u8 battlerId, u32 ability, bool32 isDoubleBattle)
RestoreOverwrittenPixels((void*)(OBJ_VRAM0) + (gSprites[spriteId1].oam.tileNum * 32));
}
void UpdateAbilityPopup(u8 battlerId)
{
u8 spriteId1 = gBattleStruct->abilityPopUpSpriteIds[battlerId][0];
u8 spriteId2 = gBattleStruct->abilityPopUpSpriteIds[battlerId][1];
u16 ability = (gBattleScripting.abilityPopupOverwrite != 0) ? gBattleScripting.abilityPopupOverwrite : gBattleMons[battlerId].ability;
PrintAbilityOnAbilityPopUp(ability, spriteId1, spriteId2);
RestoreOverwrittenPixels((void*)(OBJ_VRAM0) + (gSprites[spriteId1].oam.tileNum * 32));
}
#define FRAMES_TO_WAIT 48
static void SpriteCb_AbilityPopUp(struct Sprite *sprite)

View File

@ -718,9 +718,11 @@ static const u8 sText_MysteriousAirCurrent[] = _("A mysterious air current is\np
static const u8 sText_StrongWindsDissipated[] = _("The mysterious strong winds\nhave dissipated!{PAUSE 64}");
static const u8 sText_MysteriousAirCurrentBlowsOn[] = _("The mysterious air current\nblows on regardless!");
static const u8 sText_AttackWeakenedByStrongWinds[] = _("The mysterious strong winds\nweakened the attack!");
static const u8 sText_SwappedAbilities[] = _("{B_DEF_NAME_WITH_PREFIX} swapped Abilities\nwith its target!");
const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] =
{
[STRINGID_SWAPPEDABILITIES - 12] = sText_SwappedAbilities,
[STRINGID_ATTACKWEAKENEDBSTRONGWINDS - 12] = sText_AttackWeakenedByStrongWinds,
[STRINGID_MYSTERIOUSAIRCURRENTBLOWSON - 12] = sText_MysteriousAirCurrentBlowsOn,
[STRINGID_STRONGWINDSDISSIPATED - 12] = sText_StrongWindsDissipated,

View File

@ -8317,6 +8317,9 @@ static void Cmd_various(void)
case VARIOUS_ABILITY_POPUP:
CreateAbilityPopUp(gActiveBattler, gBattleMons[gActiveBattler].ability, (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) != 0);
break;
case VARIOUS_UPDATE_ABILITY_POPUP:
UpdateAbilityPopup(gActiveBattler);
break;
case VARIOUS_DEFOG:
if (T1_READ_8(gBattlescriptCurrInstr + 3)) // Clear
{

View File

@ -4803,6 +4803,40 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
}
}
break;
case ABILITY_WANDERING_SPIRIT:
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& IsBattlerAlive(gBattlerAttacker)
&& TARGET_TURN_DAMAGED
&& (gBattleMoves[move].flags & FLAG_MAKES_CONTACT))
{
switch (gBattleMons[gBattlerAttacker].ability)
{
case ABILITY_DISGUISE:
case ABILITY_FLOWER_GIFT:
case ABILITY_GULP_MISSILE:
case ABILITY_ICE_FACE:
case ABILITY_ILLUSION:
case ABILITY_IMPOSTER:
case ABILITY_RECEIVER:
case ABILITY_RKS_SYSTEM:
case ABILITY_SCHOOLING:
case ABILITY_STANCE_CHANGE:
case ABILITY_WONDER_GUARD:
case ABILITY_ZEN_MODE:
break;
default:
gLastUsedAbility = gBattleMons[gBattlerAttacker].ability;
gBattleMons[gBattlerAttacker].ability = gBattleMons[gBattlerTarget].ability;
gBattleMons[gBattlerTarget].ability = gLastUsedAbility;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_WanderingSpiritActivates;
effect++;
break;
}
}
break;
case ABILITY_ANGER_POINT:
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& gIsCriticalHit