Initial commit

This commit is contained in:
sneed 2022-05-02 06:04:16 +03:00
parent f0d74b60ff
commit 23870a40a8
3 changed files with 40 additions and 9 deletions

View File

@ -133,6 +133,7 @@ u16 CalcTypeEffectivenessMultiplier(u16 move, u8 moveType, u8 battlerAtk, u8 bat
u16 CalcPartyMonTypeEffectivenessMultiplier(u16 move, u16 speciesDef, u16 abilityDef);
u16 GetTypeModifier(u8 atkType, u8 defType);
s32 GetStealthHazardDamage(u8 hazardType, u8 battlerId);
s32 GetStealthHazardDamageByTypesAndHP(u8 hazardType, u8 type1, u8 type2, u32 maxHp);
u16 GetMegaEvolutionSpecies(u16 preEvoSpecies, u16 heldItemId);
u16 GetWishMegaEvolutionSpecies(u16 preEvoSpecies, u16 moveId1, u16 moveId2, u16 moveId3, u16 moveId4);
bool32 CanMegaEvolve(u8 battlerId);

View File

@ -2437,19 +2437,43 @@ static bool32 PartyBattlerShouldAvoidHazards(u8 currBattler, u8 switchBattler)
{
struct Pokemon *mon = GetPartyBattlerPartyData(currBattler, switchBattler);
u16 ability = GetMonAbility(mon); // we know our own party data
u16 holdEffect = GetBattlerHoldEffect(GetMonData(mon, MON_DATA_HELD_ITEM), TRUE);
u16 holdEffect;
u16 species = GetMonData(mon, MON_DATA_SPECIES);
u32 flags = gSideStatuses[GetBattlerSide(currBattler)] & (SIDE_STATUS_SPIKES | SIDE_STATUS_STEALTH_ROCK | SIDE_STATUS_STICKY_WEB | SIDE_STATUS_TOXIC_SPIKES);
s32 hazardDamage = 0;
u8 type1 = gBaseStats[species].type1;
u8 type2 = gBaseStats[species].type2;
u32 maxHp = GetMonData(mon, MON_DATA_MAX_HP);
if (flags == 0)
return FALSE;
if (ability == ABILITY_MAGIC_GUARD || ability == ABILITY_LEVITATE
|| holdEffect == HOLD_EFFECT_HEAVY_DUTY_BOOTS)
if (ability == ABILITY_MAGIC_GUARD)
return FALSE;
if (!(gFieldStatuses & STATUS_FIELD_MAGIC_ROOM || ability == ABILITY_KLUTZ))
holdEffect = gItems[GetMonData(mon, MON_DATA_HELD_ITEM)].holdEffect;
else
holdEffect = HOLD_EFFECT_NONE;
if (holdEffect == HOLD_EFFECT_HEAVY_DUTY_BOOTS)
return FALSE;
if (flags & (SIDE_STATUS_SPIKES | SIDE_STATUS_STEALTH_ROCK) && GetMonData(mon, MON_DATA_HP) < (GetMonData(mon, MON_DATA_MAX_HP) / 8))
return TRUE;
if (flags & SIDE_STATUS_STEALTH_ROCK)
{
hazardDamage += GetStealthHazardDamageByTypesAndHP(gBattleMoves[MOVE_STEALTH_ROCK].type, type1, type2, maxHp);
}
if (flags & SIDE_STATUS_SPIKES && ((type1 != TYPE_FLYING && type2 != TYPE_FLYING
&& ability != ABILITY_LEVITATE && holdEffect != HOLD_EFFECT_AIR_BALLOON)
|| holdEffect == HOLD_EFFECT_IRON_BALL || gFieldStatuses & STATUS_FIELD_GRAVITY))
{
u8 spikesDmg = maxHp / ((5 - gSideTimers[GetBattlerSide(currBattler)].spikesAmount) * 2);
if (spikesDmg == 0)
spikesDmg = 1;
hazardDamage += spikesDmg;
}
if (hazardDamage >= GetMonData(mon, MON_DATA_HP))
return TRUE;
return FALSE;
}

View File

@ -9216,11 +9216,8 @@ u16 GetTypeModifier(u8 atkType, u8 defType)
return sTypeEffectivenessTable[atkType][defType];
}
s32 GetStealthHazardDamage(u8 hazardType, u8 battlerId)
s32 GetStealthHazardDamageByTypesAndHP(u8 hazardType, u8 type1, u8 type2, u32 maxHp)
{
u8 type1 = gBattleMons[battlerId].type1;
u8 type2 = gBattleMons[battlerId].type2;
u32 maxHp = gBattleMons[battlerId].maxHP;
s32 dmg = 0;
u16 modifier = UQ_4_12(1.0);
@ -9263,6 +9260,15 @@ s32 GetStealthHazardDamage(u8 hazardType, u8 battlerId)
return dmg;
}
s32 GetStealthHazardDamage(u8 hazardType, u8 battlerId)
{
u8 type1 = gBattleMons[battlerId].type1;
u8 type2 = gBattleMons[battlerId].type2;
u32 maxHp = gBattleMons[battlerId].maxHP;
return GetStealthHazardDamageByTypesAndHP(hazardType, type1, type2, maxHp);
}
bool32 IsPartnerMonFromSameTrainer(u8 battlerId)
{
if (GetBattlerSide(battlerId) == B_SIDE_OPPONENT && gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)