{
    onStart(pokemon, target, source, move) {
      this.add("-ability", pokemon, "Deathsong");
      let result = false;
      let message = false;
      for (const pokemon of this.getAllActive()) {
        if (this.runEvent("Invulnerability", pokemon, source, this.dex.moves.get("perishsong")) === false) {
          this.add("-miss", source, pokemon);
          result = true;
        } else if (this.runEvent("TryHit", pokemon, source, this.dex.moves.get("perishsong")) === null) {
          result = true;
        } else if (!pokemon.volatiles["perishsong"]) {
          pokemon.addVolatile("perishsong");
          this.add("-start", pokemon, "perish3", "[silent]");
          result = true;
          message = true;
        }
      }
      if (!result)
        return false;
      if (message)
        this.add("-fieldactivate", "move: Perish Song");
    },
    onTryAddVolatile(status, pokemon) {
      if (status.id === "perishsong")
        return null;
    },
    onHit(target, source, move) {
      if (move?.volatileStatus === "perishsong") {
        this.add("-immune", target, "perishsong", "[from] ability: Deathsong");
      }
    },
    flags: {},
    name: "Deathsong",
    rating: 4,
    num: -32014
}