Fix Intimidate affecting fainted mons

This commit is contained in:
DizzyEggg 2021-12-07 12:19:27 +01:00 committed by GitHub
parent dff72b97dd
commit 0a7dd2edd6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1731,7 +1731,7 @@ u8 TrySetCantSelectMoveBattleScript(void)
limitations++;
}
}
if (move == MOVE_STUFF_CHEEKS && ItemId_GetPocket(gBattleMons[gActiveBattler].item) != POCKET_BERRIES)
{
gCurrentMove = move;
@ -1776,7 +1776,7 @@ u8 TrySetCantSelectMoveBattleScript(void)
limitations++;
}
}
if ((GetBattlerAbility(gActiveBattler) == ABILITY_GORILLA_TACTICS) && *choicedMove != 0
if ((GetBattlerAbility(gActiveBattler) == ABILITY_GORILLA_TACTICS) && *choicedMove != 0
&& *choicedMove != 0xFFFF && *choicedMove != move)
{
gCurrentMove = *choicedMove;
@ -2710,9 +2710,9 @@ u8 DoBattlerEndTurnEffects(void)
gBattleStruct->turnEffectsTracker++;
break;
case ENDTURN_OCTOLOCK:
if (gDisableStructs[gActiveBattler].octolock
&& !(GetBattlerAbility(gActiveBattler) == ABILITY_CLEAR_BODY
|| GetBattlerAbility(gActiveBattler) == ABILITY_FULL_METAL_BODY
if (gDisableStructs[gActiveBattler].octolock
&& !(GetBattlerAbility(gActiveBattler) == ABILITY_CLEAR_BODY
|| GetBattlerAbility(gActiveBattler) == ABILITY_FULL_METAL_BODY
|| GetBattlerAbility(gActiveBattler) == ABILITY_WHITE_SMOKE))
{
gBattlerTarget = gActiveBattler;
@ -3750,7 +3750,7 @@ u8 TryWeatherFormChange(u8 battler)
u8 ret = 0;
bool32 weatherEffect = WEATHER_HAS_EFFECT;
u16 holdEffect = GetBattlerHoldEffect(battler, TRUE);
if (gBattleMons[battler].species == SPECIES_CASTFORM)
{
if (GetBattlerAbility(battler) != ABILITY_FORECAST || gBattleMons[battler].hp == 0)
@ -4698,7 +4698,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
gBattlescriptCurrInstr = BattleScript_DarkTypePreventsPrankster;
effect = 1;
}
break;
case ABILITYEFFECT_ABSORBING: // 3
if (move != MOVE_NONE)
@ -5525,10 +5525,11 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
case ABILITYEFFECT_INTIMIDATE2:
for (i = 0; i < gBattlersCount; i++)
{
if (GetBattlerAbility(i) == ABILITY_INTIMIDATE && gBattleResources->flags->flags[i] & RESOURCE_FLAG_INTIMIDATED)
if (GetBattlerAbility(i) == ABILITY_INTIMIDATE && gBattleResources->flags->flags[i] & RESOURCE_FLAG_INTIMIDATED
&& (IsBattlerAlive(BATTLE_OPPOSITE(i)) || IsBattlerAlive(BATTLE_PARTNER(BATTLE_OPPOSITE(i))))) // At least one opposing mon has to be alive.
{
gLastUsedAbility = ABILITY_INTIMIDATE;
gBattleResources->flags->flags[i] &= ~(RESOURCE_FLAG_INTIMIDATED);
gLastUsedAbility = ABILITY_INTIMIDATE;
if (caseID == ABILITYEFFECT_INTIMIDATE1)
{
BattleScriptPushCursorAndCallback(BattleScript_IntimidateActivatesEnd3);
@ -5604,7 +5605,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
effect++;
}
if (effect)
break;
}
@ -5659,10 +5660,10 @@ u32 GetBattlerAbility(u8 battlerId)
{
if (gStatuses3[battlerId] & STATUS3_GASTRO_ACID)
return ABILITY_NONE;
if (IsNeutralizingGasOnField() && !IsNeutralizingGasBannedAbility(gBattleMons[battlerId].ability))
return ABILITY_NONE;
if ((((gBattleMons[gBattlerAttacker].ability == ABILITY_MOLD_BREAKER
|| gBattleMons[gBattlerAttacker].ability == ABILITY_TERAVOLT
|| gBattleMons[gBattlerAttacker].ability == ABILITY_TURBOBLAZE)
@ -5673,7 +5674,7 @@ u32 GetBattlerAbility(u8 battlerId)
&& gActionsByTurnOrder[gBattlerByTurnOrder[gBattlerAttacker]] == B_ACTION_USE_MOVE
&& gCurrentTurnActionNumber < gBattlersCount)
return ABILITY_NONE;
return gBattleMons[battlerId].ability;
}
@ -5785,7 +5786,7 @@ bool32 IsBattlerTerrainAffected(u8 battlerId, u32 terrainFlag)
return FALSE;
else if (gStatuses3[battlerId] & STATUS3_SEMI_INVULNERABLE)
return FALSE;
return IsBattlerGrounded(battlerId);
}
@ -5807,7 +5808,7 @@ bool32 CanSleep(u8 battlerId)
bool32 CanBePoisoned(u8 battlerAttacker, u8 battlerTarget)
{
u16 ability = GetBattlerAbility(battlerTarget);
if (!(CanPoisonType(battlerAttacker, battlerTarget))
|| gSideStatuses[GetBattlerSide(battlerTarget)] & SIDE_STATUS_SAFEGUARD
|| gBattleMons[battlerTarget].status1 & STATUS1_ANY
@ -6009,7 +6010,7 @@ static u8 RandomStatRaiseBerry(u32 battlerId, u32 itemId, bool32 end2)
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_BerryStatRaiseRet;
}
return ITEM_STATS_CHANGE;
}
return 0;
@ -6123,7 +6124,7 @@ static bool32 UnnerveOn(u32 battlerId, u32 itemId)
static bool32 GetMentalHerbEffect(u8 battlerId)
{
bool32 ret = FALSE;
// Check infatuation
if (gBattleMons[battlerId].status2 & STATUS2_INFATUATION)
{
@ -7259,11 +7260,11 @@ u32 GetMoveTarget(u16 move, u8 setTarget)
moveTarget = setTarget - 1;
else
moveTarget = gBattleMoves[move].target;
// Special cases
if (move == MOVE_CURSE && !IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_GHOST))
moveTarget = MOVE_TARGET_USER;
switch (moveTarget)
{
case MOVE_TARGET_SELECTED:
@ -9266,7 +9267,7 @@ bool32 CanBattlerGetOrLoseItem(u8 battlerId, u16 itemId)
{
u16 species = gBattleMons[battlerId].species;
u16 holdEffect = ItemId_GetHoldEffect(itemId);
// Mail can be stolen now
if (itemId == ITEM_ENIGMA_BERRY)
return FALSE;
@ -9546,7 +9547,7 @@ void SortBattlersBySpeed(u8 *battlers, bool8 slowToFast)
{
int i, j, currSpeed, currBattler;
u16 speeds[4] = {0};
for (i = 0; i < gBattlersCount; i++)
speeds[i] = GetBattlerTotalSpeedStat(battlers[i]);
@ -9584,7 +9585,7 @@ void TryRestoreStolenItems(void)
{
u32 i;
u16 stolenItem = ITEM_NONE;
for (i = 0; i < PARTY_SIZE; i++)
{
if (gBattleStruct->itemStolen[i].stolen)
@ -9599,10 +9600,10 @@ void TryRestoreStolenItems(void)
bool32 CanStealItem(u8 battlerStealing, u8 battlerItem, u16 item)
{
u8 stealerSide = GetBattlerSide(battlerStealing);
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER_HILL)
return FALSE;
// Check if the battler trying to steal should be able to
if (stealerSide == B_SIDE_OPPONENT
&& !(gBattleTypeFlags &
@ -9628,11 +9629,11 @@ bool32 CanStealItem(u8 battlerStealing, u8 battlerItem, u16 item)
{
return FALSE;
}
if (!CanBattlerGetOrLoseItem(battlerItem, item) // Battler with item cannot have it stolen
||!CanBattlerGetOrLoseItem(battlerStealing, item)) // Stealer cannot take the item
return FALSE;
return TRUE;
}
@ -9680,7 +9681,7 @@ bool32 CompareStat(u8 battlerId, u8 statId, u8 cmpTo, u8 cmpKind)
{
bool8 ret = FALSE;
u8 statValue = gBattleMons[battlerId].statStages[statId];
// Because this command is used as a way of checking if a stat can be lowered/raised,
// we need to do some modification at run-time.
if (GetBattlerAbility(battlerId) == ABILITY_CONTRARY)
@ -9723,7 +9724,7 @@ bool32 CompareStat(u8 battlerId, u8 statId, u8 cmpTo, u8 cmpKind)
ret = TRUE;
break;
}
return ret;
}
@ -9782,7 +9783,7 @@ void DoBurmyFormChange(u32 monId)
if ((GET_BASE_SPECIES_ID(currSpecies) == SPECIES_BURMY) && (gBitTable[monId] & sentIn))
{
switch (gBattleTerrain)
{
{
case BATTLE_TERRAIN_GRASS:
case BATTLE_TERRAIN_LONG_GRASS:
case BATTLE_TERRAIN_POND:
@ -9823,7 +9824,7 @@ bool32 BlocksPrankster(u16 move, u8 battlerPrankster, u8 battlerDef, bool32 chec
return FALSE;
if (gStatuses3[battlerDef] & STATUS3_SEMI_INVULNERABLE)
return FALSE;
return TRUE;
#endif
return FALSE;
@ -9838,13 +9839,13 @@ 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;