From 194adf0ab2753a9ec16bdf39a93a5a6087a257f2 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 22 Jul 2018 22:41:13 +0200 Subject: [PATCH] Abilities affected by weather conditions --- data/battle_scripts_1.s | 8 +++++++- src/battle_script_commands.c | 28 +++++++++++++++++++--------- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index c2116784e..6500a2488 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -3486,11 +3486,17 @@ BattleScript_DamagingWeatherLoop:: copyarraywithindex gBattlerAttacker, gBattlerByTurnOrder, gBattleCommunication, 0x1 weatherdamage jumpifword CMP_EQUAL, gBattleMoveDamage, 0x0, BattleScript_DamagingWeatherLoopIncrement + jumpifword CMP_COMMON_BITS gBattleMoveDamage, 1 << 31, BattleScript_DamagingWeatherHeal printfromtable gSandStormHailDmgStringIds waitmessage 0x40 - orword gHitMarker, HITMARKER_x20 | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 | HITMARKER_GRUDGE effectivenesssound hitanimation BS_ATTACKER + goto BattleScript_DamagingWeatherHpChange +BattleScript_DamagingWeatherHeal: + printstring STRINGID_ICEBODYHPGAIN + waitmessage 0x40 +BattleScript_DamagingWeatherHpChange: + orword gHitMarker, HITMARKER_x20 | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 | HITMARKER_GRUDGE healthbarupdate BS_ATTACKER datahpupdate BS_ATTACKER tryfaintmon BS_ATTACKER, FALSE, NULL diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 5306822ed..effce629f 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -7608,15 +7608,15 @@ static void atk96_weatherdamage(void) { if (WEATHER_HAS_EFFECT) { + u32 ability = GetBattlerAbility(gBattlerAttacker); if (gBattleWeather & WEATHER_SANDSTORM_ANY) { - if (gBattleMons[gBattlerAttacker].type1 != TYPE_ROCK - && gBattleMons[gBattlerAttacker].type1 != TYPE_STEEL - && gBattleMons[gBattlerAttacker].type1 != TYPE_GROUND - && gBattleMons[gBattlerAttacker].type2 != TYPE_ROCK - && gBattleMons[gBattlerAttacker].type2 != TYPE_STEEL - && gBattleMons[gBattlerAttacker].type2 != TYPE_GROUND - && gBattleMons[gBattlerAttacker].ability != ABILITY_SAND_VEIL + if (!IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_ROCK) + && !IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_GROUND) + && !IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_STEEL) + && ability != ABILITY_SAND_VEIL + && ability != ABILITY_SAND_FORCE + && ability != ABILITY_SAND_RUSH && !(gStatuses3[gBattlerAttacker] & STATUS3_UNDERGROUND) && !(gStatuses3[gBattlerAttacker] & STATUS3_UNDERWATER)) { @@ -7629,9 +7629,19 @@ static void atk96_weatherdamage(void) gBattleMoveDamage = 0; } } - if (gBattleWeather & WEATHER_HAIL) + if (gBattleWeather & WEATHER_HAIL_ANY) { - if (!IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_ICE) + if (ability == ABILITY_ICE_BODY + && !(gStatuses3[gBattlerAttacker] & STATUS3_UNDERGROUND) + && !(gStatuses3[gBattlerAttacker] & STATUS3_UNDERWATER)) + { + gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 16; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + gBattleMoveDamage *= -1; + } + else if (!IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_ICE) + && ability != ABILITY_SNOW_CLOAK && !(gStatuses3[gBattlerAttacker] & STATUS3_UNDERGROUND) && !(gStatuses3[gBattlerAttacker] & STATUS3_UNDERWATER)) {