{
    
    onTryHit(pokemon, target, move) {
        if (move.ohko) {
            this.add("-immune", pokemon, "[from] ability: The Head");
            return null;
        }
    },
    
    onDamagePriority: -30,
    onDamage(damage, target, source, effect) {
        if (target.hp === target.maxhp && damage >= target.hp && effect && effect.effectType === "Move") {
            this.add("-ability", target, "The Head");
            return target.hp - 1;
        }
    },
    
    
    onModifyMovePriority: -5,
    onModifyMove(move) {
        if (!move.ignoreImmunity)
            move.ignoreImmunity = {};
        if (move.ignoreImmunity !== true) {
            move.ignoreImmunity["Fighting"] = true;
            move.ignoreImmunity["Normal"] = true;
        }
    },
    
    onTryBoost(boost, target, source, effect) {
        if (effect.name === "Intimidate" && boost.atk) {
            delete boost.atk;
            this.add("-fail", target, "unboost", "Attack", "[from] ability: The Head", "[of] " + target);
        }
    },
    
    
    
    onSetStatus(status, target, source, effect) {
        if (effect?.status) {
            this.add("-immune", target, "[from] ability: The Head");
        }
        return false;
    },
    
    
    onTryAddVolatile(status, target) {
        if (status.id === "yawn") {
            this.add("-immune", target, "[from] ability: The Head");
            return null;
        }
    },
    
    
    onResidualOrder: 5,
    onResidualSubOrder: 5,
    onResidual(pokemon) {
        if (!pokemon.hp) return;
        const healAmount = Math.floor(pokemon.maxhp / 8);
        if (healAmount) {
            this.heal(healAmount, pokemon, pokemon);
            this.add("-activate", pokemon, "ability: The Head", "[heal]");
        }
    },
    
    
    flags: {},
    name: "The Head",
    rating: 9.9, 
    num: -1001,
}