Merge pull request #1512 from ghoulslash/utility_umbrella

Utility Umbrella
This commit is contained in:
BuffelSaft 2021-11-02 16:28:52 +13:00 committed by GitHub
commit b97a250acc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 98 additions and 51 deletions

View File

@ -1861,6 +1861,12 @@
.macro applyplasmafists
various BS_ATTACKER, VARIOUS_APPLY_PLASMA_FISTS
.endm
.macro jumpifweatheraffected battler:req, weather:req, ptr:req
various \battler, VARIOUS_JUMP_IF_WEATHER_AFFECTED
.4byte \weather
.4byte \ptr
.endm
.macro jumpifspecies battler:req, species:req, ptr:req
various \battler, VARIOUS_JUMP_IF_SPECIES
@ -1987,10 +1993,9 @@
goto \jumpptr
.endm
.macro jumpifleafguard jumpptr:req
jumpifhalfword CMP_NO_COMMON_BITS, gBattleWeather, WEATHER_SUN_ANY, 1f
jumpifability BS_TARGET, ABILITY_LEAF_GUARD, \jumpptr
1:
.macro jumpifleafguardprotected battler:req, jumpptr:req
various \battler, VARIOUS_JUMP_IF_LEAF_GUARD_PROTECTED
.4byte \jumpptr
.endm
.macro jumpifsafeguard jumpptr:req

View File

@ -1672,7 +1672,7 @@ BattleScript_GrowthDoMoveAnim::
waitanimation
setbyte sSTAT_ANIM_PLAYED, FALSE
playstatchangeanimation BS_ATTACKER, BIT_ATK | BIT_SPATK, 0
jumpifhalfword CMP_COMMON_BITS, gBattleWeather, WEATHER_SUN_ANY, BattleScript_GrowthAtk2
jumpifweatheraffected BS_ATTACKER, WEATHER_SUN_ANY, BattleScript_GrowthAtk2
setstatchanger STAT_ATK, 1, FALSE
goto BattleScript_GrowthAtk
BattleScript_GrowthAtk2:
@ -1683,7 +1683,7 @@ BattleScript_GrowthAtk:
printfromtable gStatUpStringIds
waitmessage B_WAIT_TIME_LONG
BattleScript_GrowthTrySpAtk::
jumpifhalfword CMP_COMMON_BITS, gBattleWeather, WEATHER_SUN_ANY, BattleScript_GrowthSpAtk2
jumpifweatheraffected BS_ATTACKER, WEATHER_SUN_ANY, BattleScript_GrowthSpAtk2
setstatchanger STAT_SPATK, 1, FALSE
goto BattleScript_GrowthSpAtk
BattleScript_GrowthSpAtk2:
@ -2512,7 +2512,7 @@ BattleScript_EffectSleep::
jumpifability BS_TARGET, ABILITY_COMATOSE, BattleScript_LeafGuardProtects
jumpifflowerveil BattleScript_FlowerVeilProtects
jumpifability BS_TARGET_SIDE, ABILITY_SWEET_VEIL, BattleScript_SweetVeilProtects
jumpifleafguard BattleScript_LeafGuardProtects
jumpifleafguardprotected BS_TARGET, BattleScript_LeafGuardProtects
jumpifshieldsdown BS_TARGET, BattleScript_LeafGuardProtects
jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_ButItFailed
jumpifterrainaffected BS_TARGET, STATUS_FIELD_ELECTRIC_TERRAIN, BattleScript_ElectricTerrainPrevents
@ -3054,7 +3054,7 @@ BattleScript_EffectToxic::
jumpifability BS_TARGET, ABILITY_IMMUNITY, BattleScript_ImmunityProtected
jumpifability BS_TARGET, ABILITY_COMATOSE, BattleScript_LeafGuardProtects
jumpifflowerveil BattleScript_FlowerVeilProtects
jumpifleafguard BattleScript_LeafGuardProtects
jumpifleafguardprotected BS_TARGET, BattleScript_LeafGuardProtects
jumpifshieldsdown BS_TARGET, BattleScript_LeafGuardProtects
jumpifsubstituteblocks BattleScript_ButItFailed
jumpifstatus BS_TARGET, STATUS1_POISON | STATUS1_TOXIC_POISON, BattleScript_AlreadyPoisoned
@ -3409,7 +3409,7 @@ BattleScript_EffectPoison::
jumpifability BS_TARGET, ABILITY_IMMUNITY, BattleScript_ImmunityProtected
jumpifability BS_TARGET, ABILITY_COMATOSE, BattleScript_LeafGuardProtects
jumpifflowerveil BattleScript_FlowerVeilProtects
jumpifleafguard BattleScript_LeafGuardProtects
jumpifleafguardprotected BS_TARGET, BattleScript_LeafGuardProtects
jumpifshieldsdown BS_TARGET, BattleScript_LeafGuardProtects
jumpifsubstituteblocks BattleScript_ButItFailed
jumpifstatus BS_TARGET, STATUS1_POISON, BattleScript_AlreadyPoisoned
@ -3434,7 +3434,7 @@ BattleScript_EffectParalyze:
jumpifability BS_TARGET, ABILITY_LIMBER, BattleScript_LimberProtected
jumpifability BS_TARGET, ABILITY_COMATOSE, BattleScript_LeafGuardProtects
jumpifflowerveil BattleScript_FlowerVeilProtects
jumpifleafguard BattleScript_LeafGuardProtects
jumpifleafguardprotected BS_TARGET, BattleScript_LeafGuardProtects
jumpifshieldsdown BS_TARGET, BattleScript_LeafGuardProtects
jumpifsubstituteblocks BattleScript_ButItFailed
.if B_GLARE_GHOST >= GEN_4
@ -4557,9 +4557,7 @@ BattleScript_EffectGust::
goto BattleScript_EffectHit
BattleScript_EffectSolarbeam::
jumpifabilitypresent ABILITY_CLOUD_NINE, BattleScript_SolarbeamDecideTurn
jumpifabilitypresent ABILITY_AIR_LOCK, BattleScript_SolarbeamDecideTurn
jumpifhalfword CMP_COMMON_BITS, gBattleWeather, WEATHER_SUN_TEMPORARY | WEATHER_SUN_PERMANENT, BattleScript_SolarbeamOnFirstTurn
jumpifweatheraffected BS_ATTACKER, WEATHER_SUN_ANY, BattleScript_SolarbeamOnFirstTurn
BattleScript_SolarbeamDecideTurn::
jumpifstatus2 BS_ATTACKER, STATUS2_MULTIPLETURNS, BattleScript_TwoTurnMovesSecondTurn
jumpifword CMP_COMMON_BITS, gHitMarker, HITMARKER_NO_ATTACKSTRING, BattleScript_TwoTurnMovesSecondTurn
@ -4876,7 +4874,7 @@ BattleScript_EffectWillOWisp::
jumpifability BS_TARGET, ABILITY_WATER_BUBBLE, BattleScript_WaterVeilPrevents
jumpifability BS_TARGET, ABILITY_COMATOSE, BattleScript_LeafGuardProtects
jumpifflowerveil BattleScript_FlowerVeilProtects
jumpifleafguard BattleScript_LeafGuardProtects
jumpifleafguardprotected BS_TARGET, BattleScript_LeafGuardProtects
jumpifshieldsdown BS_TARGET, BattleScript_LeafGuardProtects
jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_ButItFailed
jumpifterrainaffected BS_TARGET, STATUS_FIELD_MISTY_TERRAIN, BattleScript_MistyTerrainPrevents
@ -5154,7 +5152,7 @@ BattleScript_EffectYawn::
jumpifability BS_TARGET, ABILITY_INSOMNIA, BattleScript_PrintBankAbilityMadeIneffective
jumpifability BS_TARGET, ABILITY_COMATOSE, BattleScript_PrintBankAbilityMadeIneffective
jumpifflowerveil BattleScript_FlowerVeilProtects
jumpifleafguard BattleScript_LeafGuardProtects
jumpifleafguardprotected BS_TARGET, BattleScript_LeafGuardProtects
jumpifshieldsdown BS_TARGET, BattleScript_LeafGuardProtects
jumpifsubstituteblocks BattleScript_ButItFailed
jumpifsafeguard BattleScript_SafeguardProtected

View File

@ -156,6 +156,7 @@ void BufferStatChange(u8 battlerId, u8 statId, u8 stringId);
void DoBurmyFormChange(u32 monId);
bool32 BlocksPrankster(u16 move, u8 battlerPrankster, u8 battlerDef, bool32 checkTarget);
u16 GetUsedHeldItem(u8 battler);
bool32 IsBattlerWeatherAffected(u8 battlerId, u32 weatherFlags);
// ability checks
bool32 IsRolePlayBannedAbilityAtk(u16 ability);

View File

@ -195,6 +195,8 @@
#define VARIOUS_APPLY_PLASMA_FISTS 122
#define VARIOUS_JUMP_IF_SPECIES 123
#define VARIOUS_UPDATE_ABILITY_POPUP 124
#define VARIOUS_JUMP_IF_WEATHER_AFFECTED 125
#define VARIOUS_JUMP_IF_LEAF_GUARD_PROTECTED 126
// Cmd_manipulatedamage
#define DMG_CHANGE_SIGN 0

View File

@ -22,6 +22,7 @@
#include "constants/rgb.h"
#include "constants/songs.h"
#include "constants/weather.h"
#include "constants/hold_effects.h"
extern const struct SpriteTemplate gThoughtBubbleSpriteTemplate;
@ -5526,10 +5527,12 @@ static void AnimRecycle_Step(struct Sprite *sprite)
void AnimTask_GetWeather(u8 taskId)
{
bool32 utilityUmbrellaAffected = GetBattlerHoldEffect(gBattleAnimAttacker, TRUE) == HOLD_EFFECT_UTILITY_UMBRELLA;
gBattleAnimArgs[ARG_RET_ID] = ANIM_WEATHER_NONE;
if (gWeatherMoveAnim & WEATHER_SUN_ANY)
if (gWeatherMoveAnim & WEATHER_SUN_ANY && !utilityUmbrellaAffected)
gBattleAnimArgs[ARG_RET_ID] = ANIM_WEATHER_SUN;
else if (gWeatherMoveAnim & WEATHER_RAIN_ANY)
else if (gWeatherMoveAnim & WEATHER_RAIN_ANY && !utilityUmbrellaAffected)
gBattleAnimArgs[ARG_RET_ID] = ANIM_WEATHER_RAIN;
else if (gWeatherMoveAnim & WEATHER_SANDSTORM_ANY)
gBattleAnimArgs[ARG_RET_ID] = ANIM_WEATHER_SANDSTORM;

View File

@ -4289,9 +4289,9 @@ u32 GetBattlerTotalSpeedStat(u8 battlerId)
// weather abilities
if (WEATHER_HAS_EFFECT)
{
if (ability == ABILITY_SWIFT_SWIM && gBattleWeather & WEATHER_RAIN_ANY)
if (ability == ABILITY_SWIFT_SWIM && holdEffect != HOLD_EFFECT_UTILITY_UMBRELLA && gBattleWeather & WEATHER_RAIN_ANY)
speed *= 2;
else if (ability == ABILITY_CHLOROPHYLL && gBattleWeather & WEATHER_SUN_ANY)
else if (ability == ABILITY_CHLOROPHYLL && holdEffect != HOLD_EFFECT_UTILITY_UMBRELLA && gBattleWeather & WEATHER_SUN_ANY)
speed *= 2;
else if (ability == ABILITY_SAND_RUSH && gBattleWeather & WEATHER_SANDSTORM_ANY)
speed *= 2;
@ -5123,6 +5123,7 @@ void RunBattleScriptCommands(void)
void SetTypeBeforeUsingMove(u16 move, u8 battlerAtk)
{
u32 moveType, ateType, attackerAbility;
u16 holdEffect = GetBattlerHoldEffect(battlerAtk, TRUE);
if (move == MOVE_STRUGGLE)
return;
@ -5135,11 +5136,11 @@ void SetTypeBeforeUsingMove(u16 move, u8 battlerAtk)
{
if (WEATHER_HAS_EFFECT)
{
if (gBattleWeather & WEATHER_RAIN_ANY)
if (gBattleWeather & WEATHER_RAIN_ANY && holdEffect != HOLD_EFFECT_UTILITY_UMBRELLA)
gBattleStruct->dynamicMoveType = TYPE_WATER | 0x80;
else if (gBattleWeather & WEATHER_SANDSTORM_ANY)
gBattleStruct->dynamicMoveType = TYPE_ROCK | 0x80;
else if (gBattleWeather & WEATHER_SUN_ANY)
else if (gBattleWeather & WEATHER_SUN_ANY && holdEffect != HOLD_EFFECT_UTILITY_UMBRELLA)
gBattleStruct->dynamicMoveType = TYPE_FIRE | 0x80;
else if (gBattleWeather & WEATHER_HAIL_ANY)
gBattleStruct->dynamicMoveType = TYPE_ICE | 0x80;
@ -5163,7 +5164,7 @@ void SetTypeBeforeUsingMove(u16 move, u8 battlerAtk)
}
else if (gBattleMoves[move].effect == EFFECT_CHANGE_TYPE_ON_ITEM)
{
if (GetBattlerHoldEffect(battlerAtk, TRUE) == gBattleMoves[move].argument)
if (holdEffect == gBattleMoves[move].argument)
gBattleStruct->dynamicMoveType = ItemId_GetSecondaryId(gBattleMons[battlerAtk].item) | 0x80;
}
else if (gBattleMoves[move].effect == EFFECT_REVELATION_DANCE)
@ -5223,7 +5224,7 @@ void SetTypeBeforeUsingMove(u16 move, u8 battlerAtk)
// Check if a gem should activate.
GET_MOVE_TYPE(move, moveType);
if (GetBattlerHoldEffect(battlerAtk, TRUE) == HOLD_EFFECT_GEMS
if (holdEffect == HOLD_EFFECT_GEMS
&& moveType == ItemId_GetSecondaryId(gBattleMons[battlerAtk].item))
{
gSpecialStatuses[battlerAtk].gemParam = GetBattlerHoldEffectParam(battlerAtk);

View File

@ -1598,12 +1598,13 @@ static bool32 AccuracyCalcHelper(u16 move)
}
if ((WEATHER_HAS_EFFECT &&
(((gBattleWeather & WEATHER_RAIN_ANY) && (gBattleMoves[move].effect == EFFECT_THUNDER || gBattleMoves[move].effect == EFFECT_HURRICANE))
((IsBattlerWeatherAffected(gBattlerTarget, WEATHER_RAIN_ANY) && (gBattleMoves[move].effect == EFFECT_THUNDER || gBattleMoves[move].effect == EFFECT_HURRICANE))
|| ((B_BLIZZARD_HAIL >= GEN_4 && (gBattleWeather & WEATHER_HAIL_ANY) && move == MOVE_BLIZZARD))))
|| (gBattleMoves[move].effect == EFFECT_VITAL_THROW)
|| (gBattleMoves[move].accuracy == 0)
|| ((B_MINIMIZE_DMG_ACC >= GEN_6) && (gStatuses3[gBattlerTarget] & STATUS3_MINIMIZED) && (gBattleMoves[move].flags & FLAG_DMG_MINIMIZE)))
{
// thunder/hurricane ignore acc checks in rain unless target is holding utility umbrella
JumpIfMoveFailed(7, move);
return TRUE;
}
@ -1646,8 +1647,8 @@ u32 GetTotalAccuracy(u32 battlerAtk, u32 battlerDef, u32 move)
moveAcc = gBattleMoves[move].accuracy;
// Check Thunder and Hurricane on sunny weather.
if (WEATHER_HAS_EFFECT && gBattleWeather & WEATHER_SUN_ANY
&& (gBattleMoves[move].effect == EFFECT_THUNDER || gBattleMoves[move].effect == EFFECT_HURRICANE))
if (IsBattlerWeatherAffected(battlerDef, WEATHER_SUN_ANY)
&& (gBattleMoves[move].effect == EFFECT_THUNDER || gBattleMoves[move].effect == EFFECT_HURRICANE))
moveAcc = 50;
// Check Wonder Skin.
if (defAbility == ABILITY_WONDER_SKIN && gBattleMoves[move].power == 0)
@ -7336,7 +7337,7 @@ u32 IsFlowerVeilProtected(u32 battler)
u32 IsLeafGuardProtected(u32 battler)
{
if (WEATHER_HAS_EFFECT && (gBattleWeather & WEATHER_SUN_ANY))
if (IsBattlerWeatherAffected(battler, WEATHER_SUN_ANY))
return GetBattlerAbility(battler) == ABILITY_LEAF_GUARD;
else
return 0;
@ -8972,6 +8973,15 @@ static void Cmd_various(void)
else
gBattlescriptCurrInstr += 7;
return;
case VARIOUS_JUMP_IF_WEATHER_AFFECTED:
{
u32 weatherFlags = T1_READ_32(gBattlescriptCurrInstr + 3);
if (IsBattlerWeatherAffected(gActiveBattler, weatherFlags))
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 7);
else
gBattlescriptCurrInstr += 11;
}
return;
}
case VARIOUS_APPLY_PLASMA_FISTS:
for (i = 0; i < gBattlersCount; i++)
@ -8983,6 +8993,17 @@ static void Cmd_various(void)
else
gBattlescriptCurrInstr += 9;
return;
case VARIOUS_JUMP_IF_LEAF_GUARD_PROTECTED:
if (IsLeafGuardProtected(gActiveBattler))
{
gBattlerAbility = gActiveBattler;
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3);
}
else
{
gBattlescriptCurrInstr += 7;
}
return;
}
gBattlescriptCurrInstr += 3;
@ -10844,11 +10865,12 @@ static bool8 IsTwoTurnsMove(u16 move)
return FALSE;
}
// unused
static u8 AttacksThisTurn(u8 battlerId, u16 move) // Note: returns 1 if it's a charging turn, otherwise 2
{
// first argument is unused
if (gBattleMoves[move].effect == EFFECT_SOLARBEAM
&& (gBattleWeather & WEATHER_SUN_ANY))
&& IsBattlerWeatherAffected(battlerId, WEATHER_SUN_ANY))
return 2;
if (gBattleMoves[move].effect == EFFECT_SKULL_BASH
@ -11506,7 +11528,7 @@ static void Cmd_recoverbasedonsunlight(void)
}
else
{
if (!(gBattleWeather & WEATHER_ANY) || !WEATHER_HAS_EFFECT)
if (!(gBattleWeather & WEATHER_ANY) || !WEATHER_HAS_EFFECT || GetBattlerHoldEffect(gBattlerAttacker, TRUE) == HOLD_EFFECT_UTILITY_UMBRELLA)
gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 2;
else if (gBattleWeather & WEATHER_SUN_ANY)
gBattleMoveDamage = 20 * gBattleMons[gBattlerAttacker].maxHP / 30;

View File

@ -3679,7 +3679,8 @@ u8 TryWeatherFormChange(u8 battler)
{
u8 ret = 0;
bool32 weatherEffect = WEATHER_HAS_EFFECT;
u16 holdEffect = GetBattlerHoldEffect(battler, TRUE);
if (gBattleMons[battler].species == SPECIES_CASTFORM)
{
if (gBattleMons[battler].ability != ABILITY_FORECAST || gBattleMons[battler].hp == 0)
@ -3695,17 +3696,17 @@ u8 TryWeatherFormChange(u8 battler)
{
ret = 0;
}
else if (!(gBattleWeather & (WEATHER_RAIN_ANY | WEATHER_SUN_ANY | WEATHER_HAIL_ANY)) && !IS_BATTLER_OF_TYPE(battler, TYPE_NORMAL))
else if (holdEffect == HOLD_EFFECT_UTILITY_UMBRELLA || (!(gBattleWeather & (WEATHER_RAIN_ANY | WEATHER_SUN_ANY | WEATHER_HAIL_ANY)) && !IS_BATTLER_OF_TYPE(battler, TYPE_NORMAL)))
{
SET_BATTLER_TYPE(battler, TYPE_NORMAL);
ret = 1;
}
else if (gBattleWeather & WEATHER_SUN_ANY && !IS_BATTLER_OF_TYPE(battler, TYPE_FIRE))
else if (gBattleWeather & WEATHER_SUN_ANY && holdEffect != HOLD_EFFECT_UTILITY_UMBRELLA && !IS_BATTLER_OF_TYPE(battler, TYPE_FIRE))
{
SET_BATTLER_TYPE(battler, TYPE_FIRE);
ret = 2;
}
else if (gBattleWeather & WEATHER_RAIN_ANY && !IS_BATTLER_OF_TYPE(battler, TYPE_WATER))
else if (gBattleWeather & WEATHER_RAIN_ANY && holdEffect != HOLD_EFFECT_UTILITY_UMBRELLA && !IS_BATTLER_OF_TYPE(battler, TYPE_WATER))
{
SET_BATTLER_TYPE(battler, TYPE_WATER);
ret = 3;
@ -3720,9 +3721,9 @@ u8 TryWeatherFormChange(u8 battler)
{
if (gBattleMons[battler].ability != ABILITY_FLOWER_GIFT || gBattleMons[battler].hp == 0)
ret = 0;
else if (gBattleMonForms[battler] == 0 && weatherEffect && gBattleWeather & WEATHER_SUN_ANY)
else if (gBattleMonForms[battler] == 0 && weatherEffect && holdEffect != HOLD_EFFECT_UTILITY_UMBRELLA && gBattleWeather & WEATHER_SUN_ANY)
ret = 2;
else if (gBattleMonForms[battler] != 0 && (!weatherEffect || !(gBattleWeather & WEATHER_SUN_ANY)))
else if (gBattleMonForms[battler] != 0 && (!weatherEffect || holdEffect != HOLD_EFFECT_UTILITY_UMBRELLA || !(gBattleWeather & WEATHER_SUN_ANY)))
ret = 1;
}
@ -4388,7 +4389,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
switch (gLastUsedAbility)
{
case ABILITY_HARVEST:
if (((WEATHER_HAS_EFFECT && gBattleWeather & WEATHER_SUN_ANY) || Random() % 2 == 0)
if ((IsBattlerWeatherAffected(battler, WEATHER_SUN_ANY) || Random() % 2 == 0)
&& gBattleMons[battler].item == ITEM_NONE
&& gBattleStruct->changedItems[battler] == ITEM_NONE // Will not inherit an item
&& ItemId_GetPocket(GetUsedHeldItem(battler)) == POCKET_BERRIES)
@ -4398,12 +4399,11 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
}
break;
case ABILITY_DRY_SKIN:
if (gBattleWeather & WEATHER_SUN_ANY)
if (IsBattlerWeatherAffected(battler, WEATHER_SUN_ANY))
goto SOLAR_POWER_HP_DROP;
// Dry Skin works similarly to Rain Dish in Rain
case ABILITY_RAIN_DISH:
if (WEATHER_HAS_EFFECT
&& (gBattleWeather & WEATHER_RAIN_ANY)
if (IsBattlerWeatherAffected(battler, WEATHER_RAIN_ANY)
&& !BATTLER_MAX_HP(battler)
&& !(gStatuses3[battler] & STATUS3_HEAL_BLOCK))
{
@ -4416,8 +4416,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
}
break;
case ABILITY_HYDRATION:
if (WEATHER_HAS_EFFECT
&& (gBattleWeather & WEATHER_RAIN_ANY)
if (IsBattlerWeatherAffected(battler, WEATHER_RAIN_ANY)
&& gBattleMons[battler].status1 & STATUS1_ANY)
{
goto ABILITY_HEAL_MON_STATUS;
@ -4512,7 +4511,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
break;
SOLAR_POWER_HP_DROP:
case ABILITY_SOLAR_POWER:
if (WEATHER_HAS_EFFECT && gBattleWeather & WEATHER_SUN_ANY)
if (IsBattlerWeatherAffected(battler, WEATHER_SUN_ANY))
{
BattleScriptPushCursorAndCallback(BattleScript_SolarPowerActivates);
gBattleMoveDamage = gBattleMons[battler].maxHP / 8;
@ -5690,7 +5689,7 @@ bool32 CanBeFrozen(u8 battlerId)
{
u16 ability = GetBattlerAbility(battlerId);
if (IS_BATTLER_OF_TYPE(battlerId, TYPE_ICE)
|| (WEATHER_HAS_EFFECT && gBattleWeather & WEATHER_SUN_ANY)
|| IsBattlerWeatherAffected(battlerId, WEATHER_SUN_ANY)
|| gSideStatuses[GetBattlerSide(battlerId)] & SIDE_STATUS_SAFEGUARD
|| ability == ABILITY_MAGMA_ARMOR
|| ability == ABILITY_COMATOSE
@ -8045,7 +8044,7 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe
MulModifier(&modifier, UQ_4_12(2.0));
break;
case EFFECT_SOLARBEAM:
if (WEATHER_HAS_EFFECT && gBattleWeather & (WEATHER_HAIL_ANY | WEATHER_SANDSTORM_ANY | WEATHER_RAIN_ANY))
if (IsBattlerWeatherAffected(battlerAtk, (WEATHER_HAIL_ANY | WEATHER_SANDSTORM_ANY | WEATHER_RAIN_ANY)))
MulModifier(&modifier, UQ_4_12(0.5));
break;
case EFFECT_STOMPING_TANTRUM:
@ -8147,7 +8146,7 @@ static u32 CalcAttackStat(u16 move, u8 battlerAtk, u8 battlerDef, u8 moveType, b
MulModifier(&modifier, UQ_4_12(0.5));
break;
case ABILITY_SOLAR_POWER:
if (IS_MOVE_SPECIAL(move) && WEATHER_HAS_EFFECT && gBattleWeather & WEATHER_SUN_ANY)
if (IS_MOVE_SPECIAL(move) && IsBattlerWeatherAffected(battlerAtk, WEATHER_SUN_ANY))
MulModifier(&modifier, UQ_4_12(1.5));
break;
case ABILITY_DEFEATIST:
@ -8184,7 +8183,7 @@ static u32 CalcAttackStat(u16 move, u8 battlerAtk, u8 battlerDef, u8 moveType, b
}
break;
case ABILITY_FLOWER_GIFT:
if (gBattleMons[battlerAtk].species == SPECIES_CHERRIM && WEATHER_HAS_EFFECT && (gBattleWeather & WEATHER_SUN_ANY) && IS_MOVE_PHYSICAL(move))
if (gBattleMons[battlerAtk].species == SPECIES_CHERRIM && IsBattlerWeatherAffected(battlerAtk, WEATHER_SUN_ANY) && IS_MOVE_PHYSICAL(move))
MulModifier(&modifier, UQ_4_12(1.5));
break;
case ABILITY_HUSTLE:
@ -8224,7 +8223,7 @@ static u32 CalcAttackStat(u16 move, u8 battlerAtk, u8 battlerDef, u8 moveType, b
switch (GetBattlerAbility(BATTLE_PARTNER(battlerAtk)))
{
case ABILITY_FLOWER_GIFT:
if (gBattleMons[BATTLE_PARTNER(battlerAtk)].species == SPECIES_CHERRIM && WEATHER_HAS_EFFECT && (gBattleWeather & WEATHER_SUN_ANY) && IS_MOVE_PHYSICAL(move))
if (gBattleMons[BATTLE_PARTNER(battlerAtk)].species == SPECIES_CHERRIM && IsBattlerWeatherAffected(BATTLE_PARTNER(battlerAtk), WEATHER_SUN_ANY) && IS_MOVE_PHYSICAL(move))
MulModifier(&modifier, UQ_4_12(1.5));
break;
}
@ -8357,7 +8356,7 @@ static u32 CalcDefenseStat(u16 move, u8 battlerAtk, u8 battlerDef, u8 moveType,
}
break;
case ABILITY_FLOWER_GIFT:
if (gBattleMons[battlerDef].species == SPECIES_CHERRIM && WEATHER_HAS_EFFECT && gBattleWeather & WEATHER_SUN_ANY && !usesDefStat)
if (gBattleMons[battlerDef].species == SPECIES_CHERRIM && IsBattlerWeatherAffected(battlerDef, WEATHER_SUN_ANY) && !usesDefStat)
MulModifier(&modifier, UQ_4_12(1.5));
break;
case ABILITY_PUNK_ROCK:
@ -8372,7 +8371,7 @@ static u32 CalcDefenseStat(u16 move, u8 battlerAtk, u8 battlerDef, u8 moveType,
switch (GetBattlerAbility(BATTLE_PARTNER(battlerDef)))
{
case ABILITY_FLOWER_GIFT:
if (gBattleMons[BATTLE_PARTNER(battlerDef)].species == SPECIES_CHERRIM && WEATHER_HAS_EFFECT && gBattleWeather & WEATHER_SUN_ANY && !usesDefStat)
if (gBattleMons[BATTLE_PARTNER(battlerDef)].species == SPECIES_CHERRIM && IsBattlerWeatherAffected(BATTLE_PARTNER(battlerDef), WEATHER_SUN_ANY) && !usesDefStat)
MulModifier(&modifier, UQ_4_12(1.5));
break;
}
@ -8439,14 +8438,14 @@ static u32 CalcFinalDmg(u32 dmg, u16 move, u8 battlerAtk, u8 battlerDef, u8 move
dmg = ApplyModifier(UQ_4_12(0.5), dmg);
// check sunny/rain weather
if (WEATHER_HAS_EFFECT && gBattleWeather & WEATHER_RAIN_ANY)
if (IsBattlerWeatherAffected(battlerAtk, WEATHER_RAIN_ANY))
{
if (moveType == TYPE_FIRE)
dmg = ApplyModifier(UQ_4_12(0.5), dmg);
else if (moveType == TYPE_WATER)
dmg = ApplyModifier(UQ_4_12(1.5), dmg);
}
else if (WEATHER_HAS_EFFECT && gBattleWeather & WEATHER_SUN_ANY)
else if (IsBattlerWeatherAffected(battlerAtk, WEATHER_SUN_ANY))
{
if (moveType == TYPE_FIRE)
dmg = ApplyModifier(UQ_4_12(1.5), dmg);
@ -9578,3 +9577,19 @@ u16 GetUsedHeldItem(u8 battler)
{
return gBattleStruct->usedHeldItems[gBattlerPartyIndexes[battler]][GetBattlerSide(battler)];
}
bool32 IsBattlerWeatherAffected(u8 battlerId, u32 weatherFlags)
{
if (!WEATHER_HAS_EFFECT)
return FALSE;
if (gBattleWeather & weatherFlags)
{
// given weather is active -> check if its sun, rain against utility umbrella ( since only 1 weather can be active at once)
if (gBattleWeather & (WEATHER_SUN_ANY | WEATHER_RAIN_ANY) && GetBattlerHoldEffect(battlerId, TRUE) == HOLD_EFFECT_UTILITY_UMBRELLA)
return FALSE; // utility umbrella blocks sun, rain effects
return TRUE;
}
return FALSE;
}