mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-19 22:09:27 +02:00
Add additional checks to prevent damage to pokemon not on the field
This commit is contained in:
parent
812f81d0ca
commit
72f431143d
@ -3720,16 +3720,16 @@ export class PostTurnHurtIfSleepingAbAttr extends PostTurnAbAttr {
|
||||
|
||||
/**
|
||||
* Deals damage to all sleeping opponents equal to 1/8 of their max hp (min 1)
|
||||
* @param {Pokemon} pokemon Pokemon that has this ability
|
||||
* @param {boolean} passive N/A
|
||||
* @param {boolean} simulated true if applying in a simulated call.
|
||||
* @param {any[]} args N/A
|
||||
* @returns {boolean} true if any opponents are sleeping
|
||||
* @param pokemon Pokemon that has this ability
|
||||
* @param passive N/A
|
||||
* @param simulated `true` if applying in a simulated call.
|
||||
* @param args N/A
|
||||
* @returns `true` if any opponents are sleeping
|
||||
*/
|
||||
applyPostTurn(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean | Promise<boolean> {
|
||||
let hadEffect: boolean = false;
|
||||
for (const opp of pokemon.getOpponents()) {
|
||||
if ((opp.status?.effect === StatusEffect.SLEEP || opp.hasAbility(Abilities.COMATOSE)) && !opp.hasAbilityWithAttr(BlockNonDirectDamageAbAttr)) {
|
||||
if ((opp.status?.effect === StatusEffect.SLEEP || opp.hasAbility(Abilities.COMATOSE)) && !opp.hasAbilityWithAttr(BlockNonDirectDamageAbAttr) && !opp.switchOutStatus) {
|
||||
if (!simulated) {
|
||||
opp.damageAndUpdate(Utils.toDmgValue(opp.getMaxHp() / 8), HitResult.OTHER);
|
||||
pokemon.scene.queueMessage(i18next.t("abilityTriggers:badDreams", { pokemonName: getPokemonNameWithAffix(opp) }));
|
||||
|
@ -1144,7 +1144,7 @@ class FireGrassPledgeTag extends ArenaTag {
|
||||
? arena.scene.getPlayerField()
|
||||
: arena.scene.getEnemyField();
|
||||
|
||||
field.filter(pokemon => !pokemon.isOfType(Type.FIRE)).forEach(pokemon => {
|
||||
field.filter(pokemon => !pokemon.isOfType(Type.FIRE) && !pokemon.switchOutStatus).forEach(pokemon => {
|
||||
// "{pokemonNameWithAffix} was hurt by the sea of fire!"
|
||||
pokemon.scene.queueMessage(i18next.t("arenaTag:fireGrassPledgeLapse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }));
|
||||
// TODO: Replace this with a proper animation
|
||||
|
@ -1843,7 +1843,7 @@ export class FlameBurstAttr extends MoveEffectAttr {
|
||||
applyAbAttrs(BlockNonDirectDamageAbAttr, targetAlly, cancelled);
|
||||
}
|
||||
|
||||
if (cancelled.value || !targetAlly) {
|
||||
if (cancelled.value || !targetAlly || targetAlly.switchOutStatus) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -59,8 +59,12 @@ export class WeatherEffectPhase extends CommonAnimPhase {
|
||||
}
|
||||
}
|
||||
|
||||
this.scene.ui.showText(getWeatherLapseMessage(this.weather.weatherType)!, null, () => { // TODO: is this bang correct?
|
||||
this.executeForAll((pokemon: Pokemon) => applyPostWeatherLapseAbAttrs(PostWeatherLapseAbAttr, pokemon, this.weather));
|
||||
this.scene.ui.showText(getWeatherLapseMessage(this.weather.weatherType) ?? "", null, () => {
|
||||
this.executeForAll((pokemon: Pokemon) => {
|
||||
if (!pokemon.switchOutStatus) {
|
||||
applyPostWeatherLapseAbAttrs(PostWeatherLapseAbAttr, pokemon, this.weather);
|
||||
}
|
||||
});
|
||||
|
||||
super.start();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user