Adding New Abilities - koreanpanda345/Pokemon-Showdown-Server-Guide GitHub Wiki

So to add a new ability, we first need to know what the structure looks like, and what some of the stuff does.

So in the abilities.ts file, the structure looks something like this.

name_lower_case: { // The ability's name to lower case.
 	desc?: String, // The Long Description of the ability.
    shortDesc: String, // The Short Description of the ability.
    // Some methods, that you should look into.
    name: String, // The ability's name.
    rating?: Number, // The ability's rating.
    num: Number, // The id of the ability.
},

so Cloak of Nightmares would look something like this.

cloakofnightmares: {
    desc: "The user hides behind a cloak, that when a living creature touches it, the see a nightmare, causing them to shake in fear.",
    shortDesc: "If the attacking pokemon makes contact with the user, the attacking pokemon's atk is lowered by 1 stage.",
    onDamagingHit(damage, target, source, move) { // onDamagingHit() is called on when the target is hit by a damaging move.
    	if(move.flags['contact']) { // Checks if the move that was used against the target makes contact.
         	this.add('-ability', target, 'Cloak of Nightmares'); // Write to the battle logs.
            this.boost({atk: -1}, source, target, null, true); // Lowers the source's attack by 1 stage.
        }
    },
    name: "Cloak of Nightmares",
    rating: 5,
        
}

onDamagingHit() is an event that is triggered when the target was hit by a damaging move. As you can see we are doing something very similar to Cotton Down, except we are Lowering the Source(The attacking Pokemon)'s Attack, instead of speed.

There are other events, that I will not list, as there is a lot of them. It is easier to look pre-existing abilities, to understand what they do.