diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 9ad159ef3..11f643487 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1941,6 +1941,31 @@ .macro shellsidearmcheck various BS_ATTACKER, VARIOUS_SHELL_SIDE_ARM_CHECK .endm + + .macro jumpifrodaffected battler:req, ptr:req + various \battler, VARIOUS_JUMP_IF_ROD + .4byte \ptr + .endm + + .macro jumpifabsorbaffected battler:req, ptr:req + various \battler, VARIOUS_JUMP_IF_ABSORB + .4byte \ptr + .endm + + .macro jumpifmotoraffected battler:req, ptr:req + various \battler, VARIOUS_JUMP_IF_MOTOR + .4byte \ptr + .endm + + .macro jumpifteanoberry ptr:req + various BS_ATTACKER, VARIOUS_TEATIME_TARGETS + .4byte \ptr + .endm + + .macro jumpifteainvulnerable battler:req, ptr:req + various \battler, VARIOUS_TEATIME_INVUL + .4byte \ptr + .endm .macro jumpifcantfling battler:req, ptr:req various \battler, VARIOUS_JUMP_IF_CANT_FLING diff --git a/data/battle_anim_scripts.s b/data/battle_anim_scripts.s index 1deac0890..e19f4c993 100644 --- a/data/battle_anim_scripts.s +++ b/data/battle_anim_scripts.s @@ -13478,7 +13478,18 @@ Move_DRAGON_DARTS:: end Move_TEATIME:: - goto Move_MILK_DRINK + loadspritegfx ANIM_TAG_TEAPOT + loadspritegfx ANIM_TAG_THOUGHT_BUBBLE + createsprite gThoughtBubbleSpriteTemplate, ANIM_ATTACKER, 11, 0, 100 + playsewithpan SE_M_ICY_WIND, SOUND_PAN_ATTACKER + delay 6 + createsprite gTeapotSpriteTemplate, ANIM_ATTACKER, 12, 0 + createvisualtask AnimTask_RockMonBackAndForth, 5, ANIM_ATTACKER, 2, 0 + createvisualtask AnimTask_RockMonBackAndForth, 5, ANIM_ATK_PARTNER, 2, 0 + delay 24 + loopsewithpan SE_M_HEAL_BELL, SOUND_PAN_ATTACKER, 22, 3 + waitforvisualfinish + end Move_OCTOLOCK:: loadspritegfx ANIM_TAG_TENDRILS diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 244faf2c6..4c71c67fb 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -416,6 +416,74 @@ gBattleScriptsForMoveEffects:: .4byte BattleScript_EffectDoubleShock @ EFFECT_DOUBLE_SHOCK .4byte BattleScript_EffectSpecialAttackUpHit @ EFFECT_SPECIAL_ATTACK_UP_HIT .4byte BattleScript_EffectVictoryDance @ EFFECT_VICTORY_DANCE + .4byte BattleScript_EffectTeatime @ EFFECT_TEATIME + +BattleScript_EffectTeatime:: + attackcanceler + attackstring + ppreduce + jumpifteanoberry BattleScript_ButItFailed +@ at least one battler is affected + attackanimation + waitanimation +BattleScript_TeatimeLoop: + jumpifteainvulnerable BS_TARGET, BattleScript_Teatimevul + jumpifrodaffected BS_TARGET, BattleScript_Teatimerod + jumpifabsorbaffected BS_TARGET, BattleScript_Teatimesorb + jumpifmotoraffected BS_TARGET, BattleScript_Teatimemotor + orword gHitMarker, HITMARKER_NO_ANIMATIONS | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_IGNORE_DISGUISE + setbyte sBERRY_OVERRIDE, TRUE @ override the requirements for eating berries + consumeberry BS_TARGET, TRUE @ consume the berry, then restore the item from changedItems + bicword gHitMarker, HITMARKER_NO_ANIMATIONS | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_IGNORE_DISGUISE + setbyte sBERRY_OVERRIDE, FALSE + removeitem BS_TARGET + moveendto MOVEEND_NEXT_TARGET + jumpifnexttargetvalid BattleScript_TeatimeLoop + moveendcase MOVEEND_CLEAR_BITS + goto BattleScript_MoveEnd +BattleScript_Teatimevul: + moveendto MOVEEND_NEXT_TARGET + jumpifnexttargetvalid BattleScript_TeatimeLoop + moveendcase MOVEEND_CLEAR_BITS + goto BattleScript_MoveEnd +BattleScript_Teatimesorb: + copybyte gBattlerAbility, gBattlerTarget + call BattleScript_AbilityPopUp + moveendto MOVEEND_NEXT_TARGET + jumpifnexttargetvalid BattleScript_TeatimeLoop + moveendcase MOVEEND_CLEAR_BITS + goto BattleScript_MoveEnd +BattleScript_Teatimerod: + copybyte gBattlerAbility, gBattlerTarget + call BattleScript_AbilityPopUp + playstatchangeanimation BS_TARGET, BIT_SPATK, STAT_CHANGE_BY_TWO + setstatchanger STAT_SPATK, 1, FALSE + statbuffchange STAT_CHANGE_ALLOW_PTR, BattleScript_TeatimeBuffer + jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_TeatimeBuffer + printfromtable gStatUpStringIds + waitmessage 0x40 + moveendto MOVEEND_NEXT_TARGET + jumpifnexttargetvalid BattleScript_TeatimeLoop + moveendcase MOVEEND_CLEAR_BITS + goto BattleScript_MoveEnd +BattleScript_Teatimemotor: + copybyte gBattlerAbility, gBattlerTarget + call BattleScript_AbilityPopUp + playstatchangeanimation BS_TARGET, BIT_SPEED, STAT_CHANGE_BY_TWO + setstatchanger STAT_SPEED, 1, FALSE + statbuffchange STAT_CHANGE_ALLOW_PTR, BattleScript_TeatimeBuffer + jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_TeatimeBuffer + printfromtable gStatUpStringIds + waitmessage 0x40 + moveendto MOVEEND_NEXT_TARGET + jumpifnexttargetvalid BattleScript_TeatimeLoop + moveendcase MOVEEND_CLEAR_BITS + goto BattleScript_MoveEnd +BattleScript_TeatimeBuffer: + moveendto MOVEEND_NEXT_TARGET + jumpifnexttargetvalid BattleScript_TeatimeLoop + moveendcase MOVEEND_CLEAR_BITS + goto BattleScript_MoveEnd BattleScript_AffectionBasedEndurance:: playanimation BS_TARGET, B_ANIM_AFFECTION_HANGED_ON diff --git a/graphics/battle_anims/sprites/new/teapot.pal b/graphics/battle_anims/sprites/new/teapot.pal new file mode 100644 index 000000000..9b59309ba --- /dev/null +++ b/graphics/battle_anims/sprites/new/teapot.pal @@ -0,0 +1,19 @@ +JASC-PAL +0100 +16 +10 247 12 +144 141 173 +255 255 255 +207 232 255 +106 104 120 +190 211 255 +166 169 214 +214 171 113 +162 119 89 +72 71 81 +251 255 211 +232 207 121 +255 255 153 +124 86 73 +0 0 0 +0 0 0 diff --git a/graphics/battle_anims/sprites/new/teapot.png b/graphics/battle_anims/sprites/new/teapot.png new file mode 100644 index 000000000..6be0680df Binary files /dev/null and b/graphics/battle_anims/sprites/new/teapot.png differ diff --git a/include/constants/battle_anim.h b/include/constants/battle_anim.h index 52b20ecaa..0e8aaea83 100644 --- a/include/constants/battle_anim.h +++ b/include/constants/battle_anim.h @@ -394,6 +394,8 @@ #define ANIM_TAG_OMEGA_SYMBOL (ANIM_SPRITES_START + 382) #define ANIM_TAG_STEEL_BEAM (ANIM_SPRITES_START + 383) #define ANIM_TAG_POLTERGEIST (ANIM_SPRITES_START + 384) +#define ANIM_TAG_TEAPOT (ANIM_SPRITES_START + 385) + // battlers #define ANIM_ATTACKER 0 diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index 5af1017a9..9f126de06 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -397,7 +397,9 @@ #define EFFECT_DOUBLE_SHOCK 391 #define EFFECT_SPECIAL_ATTACK_UP_HIT 392 #define EFFECT_VICTORY_DANCE 393 +#define EFFECT_TEATIME 394 + +#define NUM_BATTLE_MOVE_EFFECTS 395 -#define NUM_BATTLE_MOVE_EFFECTS 394 #endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 0fcb2bbb0..2e3cab2ec 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -247,6 +247,11 @@ #define VARIOUS_GET_BATTLER_SIDE 156 #define VARIOUS_CHECK_PARENTAL_BOND_COUNTER 157 #define VARIOUS_SWAP_STATS 158 +#define VARIOUS_JUMP_IF_ROD 159 +#define VARIOUS_JUMP_IF_ABSORB 160 +#define VARIOUS_JUMP_IF_MOTOR 161 +#define VARIOUS_TEATIME_INVUL 162 +#define VARIOUS_TEATIME_TARGETS 163 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/include/graphics.h b/include/graphics.h index 512038b5f..78074a9d3 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -9957,6 +9957,8 @@ extern const u32 gBattleAnimSpriteGfx_Tornado[]; extern const u32 gBattleAnimSpritePal_Tornado[]; extern const u32 gBattleAnimSpriteGfx_ZMoveSymbol[]; extern const u32 gBattleAnimSpritePal_ZMoveSymbol[]; +extern const u32 gBattleAnimSpriteGfx_Teapot[]; +extern const u32 gBattleAnimSpritePal_Teapot[]; extern const u32 gBattleAnimBgImage_Dark[]; extern const u32 gBattleAnimBgImage_Ghost[]; diff --git a/src/battle_anim_effects_1.c b/src/battle_anim_effects_1.c index 0db7f69d5..ea36b2eac 100644 --- a/src/battle_anim_effects_1.c +++ b/src/battle_anim_effects_1.c @@ -2447,6 +2447,39 @@ const struct SpriteTemplate gFollowMeFingerSpriteTemplate = .callback = AnimFollowMeFinger, }; +const union AffineAnimCmd gTeaAffineAnimCmds1[] = +{ + AFFINEANIMCMD_FRAME(0x10, 0x10, 0, 0), + AFFINEANIMCMD_FRAME(0x1E, 0x1E, 0, 8), + AFFINEANIMCMD_END, +}; + +const union AffineAnimCmd gTeaAffineAnimCmds2[] = +{ + AFFINEANIMCMD_FRAME(0x0, 0x0, -3, 11), + AFFINEANIMCMD_FRAME(0x0, 0x0, 3, 11), + AFFINEANIMCMD_LOOP(2), + AFFINEANIMCMD_FRAME(0xFFE2, 0xFFE2, 0, 8), + AFFINEANIMCMD_END, +}; + +const union AffineAnimCmd *const gTeaAffineAnimTable[] = +{ + gTeaAffineAnimCmds1, + gTeaAffineAnimCmds2, +}; + +const struct SpriteTemplate gTeapotSpriteTemplate = +{ + .tileTag = ANIM_TAG_TEAPOT, + .paletteTag = ANIM_TAG_TEAPOT, + .oam = &gOamData_AffineDouble_ObjNormal_64x64, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gTeaAffineAnimTable, + .callback = AnimMetronomeFinger, +}; + const union AnimCmd gTauntFingerAnimCmds1[] = { ANIMCMD_FRAME(0, 1), diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 44cc43227..5a54bc65b 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8130,6 +8130,67 @@ static bool32 IsRototillerAffected(u32 battlerId) return TRUE; } + +static bool32 IsAbilityRodAffected(void) +{ + u32 moveType; + + if (gBattleStruct->dynamicMoveType == 0) + moveType = gBattleMoves[gCurrentMove].type; + else if (!(gBattleStruct->dynamicMoveType & 0x40)) + moveType = gBattleStruct->dynamicMoveType & 0x3F; + else + moveType = gBattleMoves[gCurrentMove].type; + + if (moveType == TYPE_ELECTRIC && GetBattlerAbility(gBattlerTarget) == ABILITY_LIGHTNING_ROD) + return TRUE; + else + return FALSE; +} + +static bool32 IsAbilityMotorAffected(void) +{ + u32 moveType; + + if (gBattleStruct->dynamicMoveType == 0) + moveType = gBattleMoves[gCurrentMove].type; + else if (!(gBattleStruct->dynamicMoveType & 0x40)) + moveType = gBattleStruct->dynamicMoveType & 0x3F; + else + moveType = gBattleMoves[gCurrentMove].type; + + if (moveType == TYPE_ELECTRIC && GetBattlerAbility(gBattlerTarget) == ABILITY_MOTOR_DRIVE) + return TRUE; + else + return FALSE; +} + +static bool32 IsAbilityAbsorbAffected(void) +{ + u32 moveType; + + if (gBattleStruct->dynamicMoveType == 0) + moveType = gBattleMoves[gCurrentMove].type; + else if (!(gBattleStruct->dynamicMoveType & 0x40)) + moveType = gBattleStruct->dynamicMoveType & 0x3F; + else + moveType = gBattleMoves[gCurrentMove].type; + + if (moveType == TYPE_ELECTRIC && GetBattlerAbility(gBattlerTarget) == ABILITY_VOLT_ABSORB) + return TRUE; + else + return FALSE; +} + +static bool32 IsTeatimeAffected(u32 battlerId) +{ + if (ItemId_GetPocket(gBattleMons[battlerId].item) != POCKET_BERRIES) + return FALSE; // Only berries + if (gStatuses3[battlerId] & STATUS3_SEMI_INVULNERABLE) + return FALSE; // Teatime doesn't affected semi-invulnerable battlers + return TRUE; +} + #define COURTCHANGE_SWAP(status, structField, temp) \ { \ temp = gSideStatuses[B_SIDE_PLAYER]; \ @@ -10098,6 +10159,45 @@ static void Cmd_various(void) PREPARE_STAT_BUFFER(gBattleTextBuff1, statId); } break; + case VARIOUS_TEATIME_TARGETS: + { + u32 count = 0; + + for (i = 0; i < gBattlersCount; i++) + { + if (IsTeatimeAffected(i)) + count++; + } + if (count == 0) + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); // Teatime fails + else + gBattlescriptCurrInstr += 7; + } + return; + case VARIOUS_TEATIME_INVUL: + if (ItemId_GetPocket(gBattleMons[gActiveBattler].item) == POCKET_BERRIES && !(gStatuses3[gBattlerTarget] & (STATUS3_SEMI_INVULNERABLE))) + gBattlescriptCurrInstr += 7; + else + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); + return; + case VARIOUS_JUMP_IF_ROD: + if (IsAbilityRodAffected()) + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); + else + gBattlescriptCurrInstr += 7; + return; + case VARIOUS_JUMP_IF_MOTOR: + if (IsAbilityMotorAffected()) + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); + else + gBattlescriptCurrInstr += 7; + return; + case VARIOUS_JUMP_IF_ABSORB: + if (IsAbilityAbsorbAffected()) + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); + else + gBattlescriptCurrInstr += 7; + return; } // End of switch (gBattlescriptCurrInstr[2]) gBattlescriptCurrInstr += 3; diff --git a/src/battle_util.c b/src/battle_util.c index 75e77a86b..bc5d8bf71 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -420,7 +420,7 @@ void HandleAction_UseMove(void) battlerAbility = GetBattlerAbility(gActiveBattler); RecordAbilityBattle(gActiveBattler, gBattleMons[gActiveBattler].ability); - if (battlerAbility == ABILITY_LIGHTNING_ROD) + if (battlerAbility == ABILITY_LIGHTNING_ROD && gCurrentMove != MOVE_TEATIME) gSpecialStatuses[gActiveBattler].lightningRodRedirected = TRUE; else if (battlerAbility == ABILITY_STORM_DRAIN) gSpecialStatuses[gActiveBattler].stormDrainRedirected = TRUE; @@ -7982,6 +7982,11 @@ bool32 IsBattlerProtected(u8 battlerId, u16 move) else if (gProtectStructs[battlerId].protected) return FALSE; } + + if (move == MOVE_TEATIME) + { + return FALSE; + } // Protective Pads doesn't stop Unseen Fist from bypassing Protect effects, so IsMoveMakingContact() isn't used here. // This means extra logic is needed to handle Shell Side Arm. diff --git a/src/data/battle_anim.h b/src/data/battle_anim.h index e6e03f06c..5be53fe66 100644 --- a/src/data/battle_anim.h +++ b/src/data/battle_anim.h @@ -1450,6 +1450,7 @@ const struct CompressedSpriteSheet gBattleAnimPicTable[] = {gBattleAnimSpriteGfx_OmegaSymbol, 0x0200, ANIM_TAG_OMEGA_SYMBOL}, {gBattleAnimSpriteGfx_Orbs, 0x0180, ANIM_TAG_STEEL_BEAM}, {gBattleAnimSpriteGfx_AuraSphere, 0x200, ANIM_TAG_POLTERGEIST}, + {gBattleAnimSpriteGfx_Teapot, 0x1800, ANIM_TAG_TEAPOT}, }; const struct CompressedSpritePalette gBattleAnimPaletteTable[] = @@ -1900,6 +1901,7 @@ const struct CompressedSpritePalette gBattleAnimPaletteTable[] = {gBattleAnimSpritePal_OmegaSymbol, ANIM_TAG_OMEGA_SYMBOL}, {gBattleAnimSpritePal_SteelBeam, ANIM_TAG_STEEL_BEAM}, {gBattleAnimSpritePal_Poltergeist, ANIM_TAG_POLTERGEIST}, + {gBattleAnimSpritePal_Teapot, ANIM_TAG_TEAPOT}, }; const struct BattleAnimBackground gBattleAnimBackgroundTable[] = diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index ef4d15039..8351c7db2 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -12351,13 +12351,13 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = [MOVE_TEATIME] = { - .effect = EFFECT_PLACEHOLDER, //TODO + .effect = EFFECT_TEATIME, .power = 0, .type = TYPE_NORMAL, .accuracy = 0, .pp = 10, .secondaryEffectChance = 0, - .target = MOVE_TARGET_ALL_BATTLERS, + .target = MOVE_TARGET_USER, .priority = 0, .flags = 0, .split = SPLIT_STATUS, diff --git a/src/graphics.c b/src/graphics.c index 0126150fd..b8ba41666 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -286,6 +286,8 @@ const u32 gBattleAnimSpritePal_Tornado[] = INCBIN_U32("graphics/battle_anims/spr const u32 gBattleAnimSpriteGfx_ZMoveSymbol[] = INCBIN_U32("graphics/battle_anims/sprites/z_move_symbol.4bpp.lz"); const u32 gBattleAnimSpritePal_ZMoveSymbol[] = INCBIN_U32("graphics/battle_anims/sprites/z_move_symbol.gbapal.lz"); +const u32 gBattleAnimSpriteGfx_Teapot[] = INCBIN_U32("graphics/battle_anims/sprites/new/teapot.4bpp.lz"); +const u32 gBattleAnimSpritePal_Teapot[] = INCBIN_U32("graphics/battle_anims/sprites/new/teapot.gbapal.lz"); // Battle anims const u32 gBattleAnimSpriteGfx_Bubble[] = INCBIN_U32("graphics/battle_anims/sprites/bubble.4bpp.lz");