From 1339256d5dd43a079427b757f5528ee8700972e3 Mon Sep 17 00:00:00 2001 From: Alex <93446519+AlexOn1ine@users.noreply.github.com> Date: Mon, 25 Dec 2023 01:43:57 +0100 Subject: [PATCH] Adds Ability Hospitality (#3818) * Adds Ability Hospitality * fix agbcc --- data/battle_scripts_1.s | 10 ++++ include/battle_scripts.h | 1 + include/constants/battle_string_ids.h | 3 +- src/battle_message.c | 2 + src/battle_util.c | 14 ++++++ test/battle/ability/hospitality.c | 70 +++++++++++++++++++++++++++ 6 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 test/battle/ability/hospitality.c diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index b4d9c0c794..fd19ed79cc 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -8853,6 +8853,16 @@ BattleScript_ZeroToHeroActivates:: waitmessage B_WAIT_TIME_LONG end3 +BattleScript_HospitalityActivates:: + pause B_WAIT_TIME_SHORT + call BattleScript_AbilityPopUp + printstring STRINGID_HOSPITALITYRESTORATION + waitmessage B_WAIT_TIME_LONG + orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE + healthbarupdate BS_TARGET + datahpupdate BS_TARGET + end3 + BattleScript_AttackWeakenedByStrongWinds:: pause B_WAIT_TIME_SHORT printstring STRINGID_ATTACKWEAKENEDBSTRONGWINDS diff --git a/include/battle_scripts.h b/include/battle_scripts.h index bc534b69af..db9db4fb82 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -461,6 +461,7 @@ extern const u8 BattleScript_CudChewActivates[]; extern const u8 BattleScript_SupremeOverlordActivates[]; extern const u8 BattleScript_CostarActivates[]; extern const u8 BattleScript_ZeroToHeroActivates[]; +extern const u8 BattleScript_HospitalityActivates[]; extern const u8 BattleScript_ToxicDebrisActivates[]; extern const u8 BattleScript_EarthEaterActivates[]; extern const u8 BattleScript_MimicryActivates_End3[]; diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index 6263f87a38..5b571c9fb2 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -696,8 +696,9 @@ #define STRINGID_SWAMPENVELOPEDSIDE 694 #define STRINGID_THESWAMPDISAPPEARED 695 #define STRINGID_PKMNTELLCHILLINGRECEPTIONJOKE 696 +#define STRINGID_HOSPITALITYRESTORATION 697 -#define BATTLESTRINGS_COUNT 697 +#define BATTLESTRINGS_COUNT 698 // This is the string id that gBattleStringsTable starts with. // String ids before this (e.g. STRINGID_INTROMSG) are not in the table, diff --git a/src/battle_message.c b/src/battle_message.c index b5e4db71aa..35ff5379ec 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -833,9 +833,11 @@ static const u8 sText_HurtByTheSeaOfFire[] = _("{B_ATK_TEAM1} {B_ATK_NAME_WITH_P static const u8 sText_TheSeaOfFireDisappeared[] = _("The sea of fire around {B_ATK_TEAM2}\nteam disappeared!"); static const u8 sText_SwampEnvelopedSide[] = _("A swamp enveloped\n{B_DEF_TEAM2} team!"); static const u8 sText_TheSwampDisappeared[] = _("The swamp around {B_ATK_TEAM2}\nteam disappeared!"); +static const u8 sText_HospitalityRestoration[] = _("The {B_ATK_PARTNER_NAME} drank down all\nthe matcha that Sinistcha made!"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { + [STRINGID_HOSPITALITYRESTORATION - BATTLESTRINGS_TABLE_START] = sText_HospitalityRestoration, [STRINGID_THESWAMPDISAPPEARED - BATTLESTRINGS_TABLE_START] = sText_TheSwampDisappeared, [STRINGID_SWAMPENVELOPEDSIDE - BATTLESTRINGS_TABLE_START] = sText_SwampEnvelopedSide, [STRINGID_THESEAOFFIREDISAPPEARED - BATTLESTRINGS_TABLE_START] = sText_TheSeaOfFireDisappeared, diff --git a/src/battle_util.c b/src/battle_util.c index 359ba8226b..b720c5c832 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4314,6 +4314,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32 u32 moveType, move; u32 side; u32 i, j; + u32 partner, partnerMaxHP; struct Pokemon *mon; if (gBattleTypeFlags & BATTLE_TYPE_SAFARI) @@ -4922,6 +4923,19 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32 effect++; } break; + case ABILITY_HOSPITALITY: + partner = BATTLE_PARTNER(battler); + partnerMaxHP = GetNonDynamaxMaxHP(partner); + + if (!gSpecialStatuses[battler].switchInAbilityDone && IsDoubleBattle() && gBattleMons[partner].hp < partnerMaxHP) + { + gBattlerTarget = partner; + gSpecialStatuses[battler].switchInAbilityDone = TRUE; + gBattleMoveDamage = (partnerMaxHP / 4) * -1; + BattleScriptPushCursorAndCallback(BattleScript_HospitalityActivates); + effect++; + } + break; } break; case ABILITYEFFECT_ENDTURN: // 1 diff --git a/test/battle/ability/hospitality.c b/test/battle/ability/hospitality.c new file mode 100644 index 0000000000..8bb78bffc0 --- /dev/null +++ b/test/battle/ability/hospitality.c @@ -0,0 +1,70 @@ +#include "global.h" +#include "test/battle.h" + +DOUBLE_BATTLE_TEST("Hospitality user restores 25% of ally's health") +{ + s16 health; + + PARAMETRIZE { health = 75; } + PARAMETRIZE { health = 100; } + + GIVEN { + PLAYER(SPECIES_POLTCHAGEIST) { Ability(ABILITY_HOSPITALITY); } + PLAYER(SPECIES_WOBBUFFET) { HP(health); MaxHP(100); } + OPPONENT(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { } + } SCENE { + if (health == 75) { + ABILITY_POPUP(playerLeft, ABILITY_HOSPITALITY); + MESSAGE("The Wobbuffet drank down all the matcha that Sinistcha made!"); + HP_BAR(playerRight, damage: -25); + } else { + NONE_OF { + ABILITY_POPUP(playerLeft, ABILITY_HOSPITALITY); + MESSAGE("The Wobbuffet drank down all the matcha that Sinistcha made!"); + HP_BAR(playerRight, damage: -25); + } + } + } +} + +DOUBLE_BATTLE_TEST("Hospitality user restores 25% of ally's health on switch-in") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET) + PLAYER(SPECIES_WOBBUFFET) { HP(75); MaxHP(100); } + PLAYER(SPECIES_POLTCHAGEIST) { Ability(ABILITY_HOSPITALITY); } + OPPONENT(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { SWITCH(playerLeft, 2); } + } SCENE { + MESSAGE("Wobbuffet, that's enough! Come back!"); + MESSAGE("Go! Ptchageist!"); + ABILITY_POPUP(playerLeft, ABILITY_HOSPITALITY); + MESSAGE("The Wobbuffet drank down all the matcha that Sinistcha made!"); + HP_BAR(playerRight, damage: -25); + } +} + +DOUBLE_BATTLE_TEST("Hospitality ignores Substitute") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + PLAYER(SPECIES_WOBBUFFET); + PLAYER(SPECIES_POLTCHAGEIST) { Ability(ABILITY_HOSPITALITY); } + OPPONENT(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(playerRight, MOVE_SUBSTITUTE); } + TURN { SWITCH(playerLeft, 2); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_SUBSTITUTE, playerRight); + MESSAGE("Wobbuffet, that's enough! Come back!"); + MESSAGE("Go! Ptchageist!"); + ABILITY_POPUP(playerLeft, ABILITY_HOSPITALITY); + MESSAGE("The Wobbuffet drank down all the matcha that Sinistcha made!"); + } +}