From b7ca63d151cbe7fbe2dac25cf4f5e0041aa9f2b6 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Wed, 24 Aug 2022 13:45:27 -0300 Subject: [PATCH] =?UTF-8?q?Implemented=20Ice=20Face=20Thanks=20to=20Ben?= =?UTF-8?q?=C3=ADcio=20Gon=C3=A7alves#3454=20who=20provided=20a=20base=20t?= =?UTF-8?q?o=20work=20with.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/battle_scripts_1.s | 48 ++++++++++++++++++++++++++++++++++++++++ include/battle.h | 1 + include/battle_scripts.h | 5 +++++ src/battle_main.c | 6 +++-- src/battle_message.c | 1 - src/battle_util.c | 39 +++++++++++++++++++++++++++++++- 6 files changed, 96 insertions(+), 4 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 5e6ab33921..152443151a 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7591,6 +7591,44 @@ BattleScript_TargetFormChange:: handleformchange BS_TARGET, 2 return +BattleScript_TargetFormChangeWithString:: + pause 5 + copybyte gBattlerAbility, gBattlerTarget + call BattleScript_AbilityPopUp + printstring STRINGID_EMPTYSTRING3 + waitmessage 1 + handleformchange BS_TARGET, 0 + handleformchange BS_TARGET, 1 + playanimation BS_TARGET, B_ANIM_FORM_CHANGE, NULL + waitanimation + handleformchange BS_TARGET, 2 + printstring STRINGID_PKMNTRANSFORMED + waitmessage B_WAIT_TIME_LONG + return + +BattleScript_TargetFormChangeWithStringEnd3:: + call BattleScript_TargetFormChangeWithString + end3 + +BattleScript_AttackerFormChangeWithString:: + pause 5 + copybyte gBattlerAbility, gBattlerAttacker + call BattleScript_AbilityPopUp + printstring STRINGID_EMPTYSTRING3 + waitmessage 1 + handleformchange BS_ATTACKER, 0 + handleformchange BS_ATTACKER, 1 + playanimation BS_ATTACKER, B_ANIM_FORM_CHANGE, NULL + waitanimation + handleformchange BS_ATTACKER, 2 + printstring STRINGID_PKMNTRANSFORMED + waitmessage B_WAIT_TIME_LONG + return + +BattleScript_AttackerFormChangeWithStringEnd3:: + call BattleScript_AttackerFormChangeWithString + end3 + BattleScript_IllusionOff:: spriteignore0hp TRUE playanimation BS_TARGET, B_ANIM_ILLUSION_OFF @@ -8547,6 +8585,16 @@ BattleScript_SoundproofProtected:: orhalfword gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE goto BattleScript_MoveEnd +BattleScript_IceFaceNullsDamage:: + attackstring + attackanimation + waitanimation + effectivenesssound + hitanimation BS_TARGET + waitstate + call BattleScript_TargetFormChangeWithString + goto BattleScript_MoveEnd + BattleScript_DazzlingProtected:: attackstring ppreduce diff --git a/include/battle.h b/include/battle.h index 931b13b2f4..d52d23429c 100644 --- a/include/battle.h +++ b/include/battle.h @@ -619,6 +619,7 @@ struct BattleStruct u8 stickyWebUser; u8 appearedInBattle; // Bitfield to track which Pokemon appeared in battle. Used for Burmy's form change u8 skyDropTargets[MAX_BATTLERS_COUNT]; // For Sky Drop, to account for if multiple Pokemon use Sky Drop in a double battle. + bool8 allowedToChangeFormInWeather[PARTY_SIZE][2]; // For each party member and side, used by Ice Face. }; #define F_DYNAMIC_TYPE_1 (1 << 6) diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 09e11bd8c0..a8147314cb 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -420,6 +420,11 @@ extern const u8 BattleScript_MagicianActivates[]; extern const u8 BattleScript_BeakBlastSetUp[]; extern const u8 BattleScript_BeakBlastBurn[]; extern const u8 BattleScript_DefDownSpeedUp[]; +extern const u8 BattleScript_IceFaceNullsDamage[]; +extern const u8 BattleScript_TargetFormChangeWithString[]; +extern const u8 BattleScript_TargetFormChangeWithStringEnd3[]; +extern const u8 BattleScript_AttackerFormChangeWithString[]; +extern const u8 BattleScript_AttackerFormChangeWithStringEnd3[]; // zmoves extern const u8 BattleScript_ZMoveActivateDamaging[]; diff --git a/src/battle_main.c b/src/battle_main.c index 5c03a18b46..50b8a10681 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -2987,10 +2987,12 @@ static void BattleStartClearSetData(void) for (i = 0; i < PARTY_SIZE; i++) { - gBattleStruct->usedHeldItems[i][0] = 0; - gBattleStruct->usedHeldItems[i][1] = 0; + gBattleStruct->usedHeldItems[i][B_SIDE_PLAYER] = 0; + gBattleStruct->usedHeldItems[i][B_SIDE_OPPONENT] = 0; gBattleStruct->itemStolen[i].originalItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM); gPartyCriticalHits[i] = 0; + gBattleStruct->allowedToChangeFormInWeather[i][B_SIDE_PLAYER] = 0; + gBattleStruct->allowedToChangeFormInWeather[i][B_SIDE_OPPONENT] = 0; } gBattleStruct->swapDamageCategory = FALSE; // Photon Geyser, Shell Side Arm, Light That Burns the Sky diff --git a/src/battle_message.c b/src/battle_message.c index 688a48f256..01e401cf7f 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -754,7 +754,6 @@ static const u8 sText_MeteorBeamCharging[] = _("{B_ATK_NAME_WITH_PREFIX} is over static const u8 sText_HeatingUpBeak[] = _("{B_ATK_NAME_WITH_PREFIX} started\nheating up its beak!"); static const u8 sText_CourtChange[] = _("{B_ATK_NAME_WITH_PREFIX} swapped the battle\neffects affecting each side!"); - const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { [STRINGID_ZPOWERSURROUNDS - BATTLESTRINGS_TABLE_START] = sText_ZPowerSurrounds, diff --git a/src/battle_util.c b/src/battle_util.c index fd9b699b8e..e88b723b52 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -3999,6 +3999,21 @@ static const u16 sWeatherFlagsInfo[][3] = [ENUM_WEATHER_STRONG_WINDS] = {B_WEATHER_STRONG_WINDS, B_WEATHER_STRONG_WINDS, HOLD_EFFECT_NONE}, }; +static void ShouldChangeFormInWeather(u8 battler) +{ + int i; + int side = GetBattlerSide(battler); + struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty; + + for (i = 0; i < PARTY_SIZE; i++) + { + if (GetMonData(&party[i], MON_DATA_SPECIES) == SPECIES_EISCUE_NOICE_FACE) + gBattleStruct->allowedToChangeFormInWeather[i][side] = 1; + else + gBattleStruct->allowedToChangeFormInWeather[i][side] = 0; + } +} + bool32 TryChangeBattleWeather(u8 battler, u32 weatherEnumId, bool32 viaAbility) { u16 battlerAbility = GetBattlerAbility(battler); @@ -4007,6 +4022,7 @@ bool32 TryChangeBattleWeather(u8 battler, u32 weatherEnumId, bool32 viaAbility) && !(gBattleWeather & sWeatherFlagsInfo[weatherEnumId][1])) { gBattleWeather = (sWeatherFlagsInfo[weatherEnumId][0] | sWeatherFlagsInfo[weatherEnumId][1]); + ShouldChangeFormInWeather(battler); return TRUE; } else if (gBattleWeather & B_WEATHER_PRIMAL_ANY @@ -4023,7 +4039,7 @@ bool32 TryChangeBattleWeather(u8 battler, u32 weatherEnumId, bool32 viaAbility) gWishFutureKnock.weatherDuration = 8; else gWishFutureKnock.weatherDuration = 5; - + ShouldChangeFormInWeather(battler); return TRUE; } @@ -4862,6 +4878,18 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move effect++; } break; + case ABILITY_ICE_FACE: + if (IsBattlerWeatherAffected(battler, B_WEATHER_HAIL) + && gBattleMons[battler].species == SPECIES_EISCUE_NOICE_FACE + && !(gBattleMons[battler].status2 & STATUS2_TRANSFORMED) + && gBattleStruct->allowedToChangeFormInWeather[gBattlerPartyIndexes[battler]][GetBattlerSide(battler)]) + { + gBattleStruct->allowedToChangeFormInWeather[gBattlerPartyIndexes[battler]][GetBattlerSide(battler)] = 0; + gBattleMons[battler].species = SPECIES_EISCUE; + gBattleScripting.battler = battler; // For STRINGID_PKMNTRANSFORMED + BattleScriptPushCursorAndCallback(BattleScript_AttackerFormChangeWithStringEnd3); + effect++; + } } } break; @@ -4898,6 +4926,15 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move gBattlescriptCurrInstr = BattleScript_DarkTypePreventsPrankster; effect = 1; } + else if (gLastUsedAbility == ABILITY_ICE_FACE && IS_MOVE_PHYSICAL(move) && gBattleMons[gBattlerTarget].species == SPECIES_EISCUE) + { + gBattleMons[gBattlerTarget].species = SPECIES_EISCUE_NOICE_FACE; + if (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS) + gHitMarker |= HITMARKER_NO_PPDEDUCT; + gBattleScripting.battler = gBattlerTarget; // For STRINGID_PKMNTRANSFORMED + gBattlescriptCurrInstr = BattleScript_IceFaceNullsDamage; + effect = 1; + } break; } case ABILITYEFFECT_ABSORBING: // 3