Resource General Thread for OM Code

It is here
Code:
{
		name: "[Gen 7] Linked",
		desc: `The first two moves in a Pokémon's moveset are used simultaneously.`,
		threads: [
			`&bullet; <a href="https://www.smogon.com/forums/threads/3627804/">Linked</a>`,
		],

		mod: 'linked',
		ruleset: ['[Gen 7] OU'],
		banlist: ['Chlorophyll', 'Sand Rush', 'Slush Rush', 'Surge Surfer', 'Swift Swim', 'Unburden', 'King\'s Rock', 'Razor Fang', 'Swampertite'],
		restrictedMoves: ['Baneful Bunker', 'Bounce', 'Detect', 'Dig', 'Dive', 'Fly', 'Nature\'s Madness', 'Night Shade', 'Phantom Force', 'Protect', 'Seismic Toss', 'Shadow Force', 'Sky Drop', 'Spiky Shield', 'Super Fang'],
		onValidateSet: function (set, format) {
			const restrictedMoves = format.restrictedMoves || [];
			let problems = [];
			for (const [i, moveid] of set.moves.entries()) {
				let move = this.getMove(moveid);
				if ((i === 0 || i === 1) && restrictedMoves.includes(move.name)) {
					problems.push(`${set.name || set.species}'s move ${move.name} cannot be linked.`);
				}
			}
			return problems;
		},
},
Code:
'use strict';

exports.BattleItems = {
	leppaberry: {
		inherit: true,
		onUpdate: function (pokemon) {
			if (!pokemon.hp) return;
			let moveSlot = pokemon.getMoveData(pokemon.getLastMoveAbsolute());
			if (moveSlot && moveSlot.pp === 0) {
				pokemon.addVolatile('leppaberry');
				pokemon.volatiles['leppaberry'].moveSlot = moveSlot;
				pokemon.eatItem();
			}
		},
	},
};
mods/linked/moves.js
mods/linked/scripts.js
mods/linked/statuses.js

Code is from Apr 30 2018, PS Main Repo
 
Last edited:
While I'm here, I'll provide u all with the updated Nature Swap code
JavaScript:
    {
        name: "[Gen 7] Nature Swap",
        desc: `Pok&eacute;mon have their base stats swapped depending on their nature.`,
        threads: [
            `&bullet; <a href="http://www.smogon.com/forums/threads/3612727/">Nature Swap</a>`,
        ],

        mod: 'natureswap',
        ruleset: ['[Gen 7] OU'],
        banlist: ['Blissey', 'Chansey', 'Cloyster', 'Hoopa-Unbound', 'Kyurem-Black', 'Stakataka'],
    },
JavaScript:
'use strict';

exports.BattleScripts = {
    spreadModify: function (stats, set) {
        const modStats = {atk: 10, def: 10, spa: 10, spd: 10, spe: 10};
        let nature = this.getNature(set.nature);
        for (let statName in modStats) {
            let stat = stats[statName];
            let usedStat = statName;
            if (nature.plus) {
                if (statName === nature.minus) {
                    usedStat = nature.plus;
                } else if (statName === nature.plus) {
                    usedStat = nature.minus;
                }
            }
            modStats[statName] = Math.floor(Math.floor(2 * stat + set.ivs[usedStat] + Math.floor(set.evs[usedStat] / 4)) * set.level / 100 + 5);
        }
        if ('hp' in stats) {
            let stat = stats['hp'];
            modStats['hp'] = Math.floor(Math.floor(2 * stat + set.ivs['hp'] + Math.floor(set.evs['hp'] / 4) + 100) * set.level / 100 + 10);
        }
        return this.natureModify(modStats, set.nature);
    },
    natureModify: function (stats, nature) {
        nature = this.getNature(nature);
        if (nature.plus) {
            let stat = stats[nature.minus];
            stats[nature.minus] = stats[nature.plus];
            stats[nature.plus] = Math.floor(stat * 1.1);
        }
        return stats;
    },
};


E: also Spandan update your post with the code from my Pullreq, the code there is up-to-date
 
Last edited:
My server continually crashed when I try to add my own OM (Dogmons) to it. The log for the crash is here but it crashed previously when I added
{
name: "Dogmons",
ruleset: ['Pokemon', 'Sleep Clause Mod', 'Species Clause', 'OHKO Clause', 'Moody Clause', 'Evasion Moves Clause', 'Endless Battle Clause', 'HP Percentage Mod', 'Team Preview', 'Swagger Clause', 'Baton Pass Clause'],
banlist: ['Abomasnow', 'Abra', 'Accelgor', 'Aegislash', 'Aerodactyl', 'Aggron', 'Aipom', 'Alakazam', 'Alomomola', 'Altaria', 'Amaura', 'Ambipom', 'Amoonguss', 'Ampharos', 'Anorith', 'Araquanid', 'Arbok', 'Arceus', 'Archen', 'Archeops', 'Ariados', 'Armaldo', 'Aron', 'Articuno', 'Audino', 'Aurorus', 'Avalugg', 'Axew', 'Azelf', 'Bagon', 'Baltoy', 'Banette', 'Barbaracle', 'Barboach', 'Basculin', 'Bastiodon', 'Bayleef', 'Beartic', 'Beautifly', 'Beedrill', 'Beheeyem', 'Beldum', 'Bellossom', 'Bellsprout', 'Bergmite', 'Bewear', 'Bibarel', 'Bidoof', 'Binacle', 'Bisharp', 'Blacephalon', 'Blastoise', 'Blaziken', 'Blissey', 'Blitzle', 'Boldore', 'Bonsly', 'Bouffalant', 'Bounsweet', 'Braixen', 'Braviary', 'Breloom', 'Brionne', 'Bronzong', 'Bronzor', 'Bruxish', 'Budew', 'Buizel', 'Bulbasaur', 'Buneary', 'Bunnelby', 'Burmy', 'Butterfree', 'Buzzwole', 'Cacnea', 'Cacturne', 'Camerupt', 'Carnivine', 'Carracosta', 'Carvanha', 'Cascoon', 'Castform', 'Caterpie', 'Celebi', 'Celesteela', 'Chandelure', 'Chansey', 'Charizard', 'Charjabug', 'Charmander', 'Charmeleon', 'Chatot', 'Cherrim', 'Cherubi', 'Chesnaught', 'Chespin', 'Chikorita', 'Chimchar', 'Chimecho', 'Chinchou', 'Chingling', 'Cinccino', 'Clamperl', 'Clauncher', 'Clawitzer', 'Claydol', 'Cloyster', 'Cobalion', 'Cofagrigus', 'Combee', 'Combusken', 'Conkeldurr', 'Corphish', 'Corsola', 'Cosmoem', 'Cosmog', 'Crabominable', 'Crabrawler', 'Cradily', 'Cranidos', 'Crawdaunt', 'Cresselia', 'Croagunk', 'Crobat', 'Croconaw', 'Crustle', 'Cryogonal', 'Cubchoo', 'Cubone', 'Cyndaquil', 'Darkrai', 'Darmanitan', 'Dartrix', 'Darumaka', 'Decidueye', 'Deerling', 'Deino', 'Delcatty', 'Delibird', 'Delphox', 'Deoxys', 'Dewgong', 'Dewott', 'Dewpider', 'Dhelmise', 'Dialga', 'Diggersby', 'Diglett', 'Ditto', 'Dodrio', 'Doduo', 'Donphan', 'Doublade', 'Dragalge', 'Dragonair', 'Dragonite', 'Drampa', 'Drapion', 'Dratini', 'Drifblim', 'Drifloon', 'Drilbur', 'Drowzee', 'Druddigon', 'Ducklett', 'Dugtrio', 'Dunsparce', 'Duosion', 'Durant', 'Dusclops', 'Dusknoir', 'Duskull', 'Dustox', 'Dwebble', 'Eelektrik', 'Eelektross', 'Ekans', 'Electabuzz', 'Electivire', 'Electrode', 'Elekid', 'Elgyem', 'Emboar', 'Emolga', 'Empoleon', 'Escavalier', 'Espeon', 'Espurr', 'Excadrill', 'Exeggcute', 'Exeggutor', 'Exploud', 'Farfetch'd', 'Fearow', 'Feebas', 'Fennekin', 'Feraligatr', 'Ferroseed', 'Ferrothorn', 'Finneon', 'Flaaffy', 'Fletchinder', 'Fletchling', 'Floatzel', 'Flygon', 'Fomantis', 'Foongus', 'Forretress', 'Fraxure', 'Frillish', 'Froakie', 'Frogadier', 'Froslass', 'Furret', 'Gabite', 'Gallade', 'Galvantula', 'Garbodor', 'Garchomp', 'Gastly', 'Gastrodon', 'Genesect', 'Gengar', 'Geodude', 'Gible', 'Gigalith', 'Girafarig', 'Giratina', 'Glalie', 'Glameow', 'Gligar', 'Gliscor', 'Gloom', 'Gogoat', 'Golbat', 'Goldeen', 'Golduck', 'Golem', 'Golett', 'Golisopod', 'Golurk', 'Goodra', 'Goomy', 'Gorebyss', 'Gothita', 'Gothitelle', 'Gothorita', 'Gourgeist', 'Graveler', 'Greninja', 'Grimer', 'Grotle', 'Groudon', 'Grovyle', 'Grubbin', 'Grumpig', 'Gulpin', 'Gumshoos', 'Gurdurr', 'Guzzlord', 'Gyarados', 'Hakamo-o', 'Happiny', 'Hariyama', 'Haunter', 'Hawlucha', 'Haxorus', 'Heatmor', 'Heatran', 'Heliolisk', 'Helioptile', 'Heracross', 'Hippopotas', 'Hippowdon', 'Hitmonchan', 'Hitmonlee', 'Hitmontop', 'Ho-Oh', 'Honchkrow', 'Honedge', 'Hoopa', 'Hoothoot', 'Hoppip', 'Horsea', 'Huntail', 'Hydreigon', 'Hypno', 'Illumise', 'Incineroar', 'Infernape', 'Inkay', 'Ivysaur', 'Jangmo-o', 'Jellicent', 'Jirachi', 'Joltik', 'Jumpluff', 'Jynx', 'Kabuto', 'Kabutops', 'Kadabra', 'Kakuna', 'Kangaskhan', 'Karrablast', 'Kartana', 'Kecleon', 'Keldeo', 'Kingdra', 'Kingler', 'Klang', 'Klink', 'Klinklang', 'Koffing', 'Komala', 'Kommo-o', 'Krabby', 'Kricketot', 'Kricketune', 'Krokorok', 'Krookodile', 'Kyogre', 'Kyurem', 'Lairon', 'Lampent', 'Landorus', 'Lanturn', 'Lapras', 'Larvesta', 'Larvitar', 'Latias', 'Latios', 'Leafeon', 'Leavanny', 'Ledian', 'Ledyba', 'Lickilicky', 'Lickitung', 'Liepard', 'Lileep', 'Lilligant', 'Linoone', 'Litleo', 'Litten', 'Litwick', 'Lombre', 'Lopunny', 'Lotad', 'Loudred', 'Ludicolo', 'Lugia', 'Lumineon', 'Lunala', 'Lunatone', 'Lurantis', 'Luvdisc', 'Luxio', 'Luxray', 'Machamp', 'Machoke', 'Machop', 'Magby', 'Magcargo', 'Magikarp', 'Magmar', 'Magmortar', 'Magnemite', 'Magneton', 'Magnezone', 'Makuhita', 'Malamar', 'Mamoswine', 'Manaphy', 'Mandibuzz', 'Mankey', 'Mantine', 'Mantyke', 'Maractus', 'Mareanie', 'Mareep', 'Marowak', 'Marshadow', 'Marshtomp', 'Masquerain', 'Medicham', 'Meditite', 'Meganium', 'Meloetta', 'Meowstic', 'Meowth', 'Mesprit', 'Metagross', 'Metang', 'Metapod', 'Mew', 'Mewtwo', 'Mienfoo', 'Mienshao', 'Milotic', 'Miltank', 'Minccino', 'Minior', 'Minun', 'Misdreavus', 'Mismagius', 'Moltres', 'Monferno', 'Mothim', 'Mudbray', 'Mudkip', 'Mudsdale', 'Muk', 'Munchlax', 'Munna', 'Murkrow', 'Musharna', 'Naganadel', 'Natu', 'Necrozma', 'Nidoking', 'Nidoqueen', 'Nidoran-F', 'Nidoran-M', 'Nidorina', 'Nidorino', 'Nihilego', 'Nincada', 'Ninetales', 'Ninjask', 'Noctowl', 'Noibat', 'Noivern', 'Nosepass', 'Numel', 'Nuzleaf', 'Octillery', 'Oddish', 'Omanyte', 'Omastar', 'Onix', 'Oranguru', 'Oricorio', 'Oshawott', 'Pachirisu', 'Palkia', 'Palossand', 'Palpitoad', 'Pancham', 'Pangoro', 'Panpour', 'Pansage', 'Pansear', 'Paras', 'Parasect', 'Passimian', 'Patrat', 'Pawniard', 'Pelipper', 'Persian', 'Petilil', 'Phanpy', 'Phantump', 'Pheromosa', 'Phione', 'Pichu', 'Pidgeot', 'Pidgeotto', 'Pidgey', 'Pidove', 'Pignite', 'Pikachu', 'Pikipek', 'Piloswine', 'Pineco', 'Pinsir', 'Piplup', 'Plusle', 'Poipole', 'Politoed', 'Poliwag', 'Poliwhirl', 'Poliwrath', 'Ponyta', 'Popplio', 'Porygon', 'Porygon-Z', 'Porygon2', 'Primeape', 'Prinplup', 'Probopass', 'Psyduck', 'Pumpkaboo', 'Pupitar', 'Purrloin', 'Purugly', 'Pyroar', 'Pyukumuku', 'Quagsire', 'Quilava', 'Quilladin', 'Qwilfish', 'Raichu', 'Rampardos', 'Rapidash', 'Raticate', 'Rattata', 'Rayquaza', 'Regice', 'Regigigas', 'Regirock', 'Registeel', 'Relicanth', 'Remoraid', 'Reshiram', 'Reuniclus', 'Rhydon', 'Rhyhorn', 'Rhyperior', 'Roggenrola', 'Roselia', 'Roserade', 'Rotom', 'Rowlet', 'Rufflet', 'Sableye', 'Salamence', 'Salandit', 'Salazzle', 'Samurott', 'Sandile', 'Sandshrew', 'Sandslash', 'Sandygast', 'Sawk', 'Sawsbuck', 'Scatterbug', 'Sceptile', 'Scizor', 'Scolipede', 'Scrafty', 'Scraggy', 'Scyther', 'Seadra', 'Seaking', 'Sealeo', 'Seedot', 'Seel', 'Seismitoad', 'Sentret', 'Serperior', 'Servine', 'Seviper', 'Sewaddle', 'Sharpedo', 'Shaymin-Land', 'Shedinja', 'Shelgon', 'Shellder', 'Shellos', 'Shelmet', 'Shieldon', 'Shiftry', 'Shinx', 'Shroomish', 'Shuckle', 'Shuppet', 'Sigilyph', 'Silcoon', 'Silvally', 'Simipour', 'Simisage', 'Simisear', 'Skarmory', 'Skiddo', 'Skiploom', 'Skitty', 'Skorupi', 'Skrelp', 'Skuntank', 'Slaking', 'Slakoth', 'Sliggoo', 'Slowbro', 'Slowking', 'Slowpoke', 'Slugma', 'Smoochum', 'Sneasel', 'Snivy', 'Snorlax', 'Snorunt', 'Snover', 'Solgaleo', 'Solosis', 'Solrock', 'Spearow', 'Spewpa', 'Spheal', 'Spinarak', 'Spinda', 'Spiritomb', 'Spoink', 'Squirtle', 'Stakataka', 'Stantler', 'Staraptor', 'Staravia', 'Starly', 'Starmie', 'Staryu', 'Steelix', 'Steenee', 'Stufful', 'Stunfisk', 'Stunky', 'Sudowoodo', 'Sunflora', 'Sunkern', 'Surskit', 'Swablu', 'Swadloon', 'Swalot', 'Swampert', 'Swanna', 'Swellow', 'Swinub', 'Swoobat', 'Taillow', 'Talonflame', 'Tangela', 'Tangrowth', 'Tauros', 'Teddiursa', 'Tentacool', 'Tentacruel', 'Tepig', 'Terrakion', 'Throh', 'Thundurus', 'Timburr', 'Tirtouga', 'Togedemaru', 'Torchic', 'Torkoal', 'Tornadus', 'Torracat', 'Torterra', 'Totodile', 'Toucannon', 'Toxapex', 'Toxicroak', 'Tranquill', 'Trapinch', 'Treecko', 'Trevenant', 'Tropius', 'Trubbish', 'Trumbeak', 'Tsareena', 'Turtonator', 'Turtwig', 'Tympole', 'Tynamo', 'Type: Null', 'Typhlosion', 'Tyranitar', 'Tyrantrum', 'Tyrogue', 'Tyrunt', 'Umbreon', 'Unfezant', 'Unown', 'Ursaring', 'Uxie', 'Vanillish', 'Vanillite', 'Vanilluxe', 'Venipede', 'Venomoth', 'Venonat', 'Venusaur', 'Vespiquen', 'Vibrava', 'Victini', 'Victreebel', 'Vigoroth', 'Vikavolt', 'Vileplume', 'Virizion', 'Vivillon', 'Volbeat', 'Volcarona', 'Voltorb', 'Vullaby', 'Vulpix', 'Wailmer', 'Wailord', 'Walrein', 'Wartortle', 'Watchog', 'Weavile', 'Weedle', 'Weepinbell', 'Weezing', 'Whirlipede', 'Whiscash'', ''Whismur', 'Wimpod', 'Wingull', 'Wishiwashi', 'Wobbuffet', 'Woobat', 'Wooper', 'Wormadam', 'Wurmple', 'Wynaut', 'Xatu', 'Xurkitree', 'Yamask', 'Yanma', 'Yanmega', 'Yungoos', 'Yveltal', 'Zangoose', 'Zapdos', 'Zebstrika', 'Zekrom', 'Zigzagoon', 'Zoroark', 'Zorua', 'Zubat', 'Zweilous', 'Zygarde', 'Zygarde-Complete', '
Altaria-Mega', 'Arceus-Fairy', 'Aromatisse', 'Audino-Mega', 'Azumarill', 'Azurill', 'Carbink', 'Clefable', 'Clefairy', 'Cleffa', 'Comfey', 'Cottonee', 'Cutiefly', 'Dedenne', 'Diancie', 'Flabébé', 'Floette', 'Florges', 'Gardevoir', 'Igglybuff', 'Jigglypuff', 'Kirlia', 'Klefki', 'Magearna', 'Marill', 'Mawile', 'Mime Jr.', 'Mimikyu', 'Morelull', 'Mr. Mime', 'Ninetales-Alola', 'Primarina', 'Ralts', 'Ribombee', 'Shiinotic', 'Silvally-Fairy', 'Slurpuff', 'Spritzee', 'Swirlix', 'Sylveon', 'Tapu Bulu', 'Tapu Fini', 'Tapu Koko', 'Tapu Lele', 'Togekiss', 'Togepi', 'Togetic', 'Whimsicott', 'Wigglytuff', 'Xerneas'],

}
}
}
},
to it. I at first assumed it was too many values in the banlist, so I adapted it to a
dogmondex: {
effectType: 'ValidatorRule',
name: 'Dogmons',
desc: "Only allows Pokémon with canine features",
onValidateSet: function (set, format) {
let dogmonDex = [
"Absol", "Arcanine", "Eevee", "Electrike", "Entei", "Flareon", "Furfrou", "Glaceon", "Granbull", "Growlithe", "Herdier", "Houndoom", "Houndour", "Jolteon", "Lillipup", "Lucario", "Lycanroc", "Manetric", "Mightyena", "Poochyena", "Raikou", "Riolu", "Rockruff", "Shaymin-Sky", "Smeargle", "Snubbull", "Stoutland", "Suicune", "Vaporeon", "Volcanion", "Zygarde-10%",
];
let template = this.getTemplate(set.species || set.name);
if (!dogmonDex.includes(template.baseSpecies) && !this.getRuleTable(format).has('+' + template.speciesid)) {
return [template.baseSpecies + " is not canine."];
}
},
},
to reduce the program in formats.js to
{
name: "Dogmons",
ruleset: ['Pokemon', 'Sleep Clause Mod', 'Species Clause', 'OHKO Clause', 'Moody Clause', 'Evasion Moves Clause', 'Endless Battle Clause', 'HP Percentage Mod', 'Team Preview', 'Swagger Clause', 'Baton Pass Clause', 'Dogmons'],

}
}
}
},
and it gave the linked error. What does this mean and how can I fix it?
 
My server continually crashed when I try to add my own OM (Dogmons) to it. What does this mean and how can I fix it?
Your code has a syntax error, possibly because you were pasting it in the wrong place in the file. Unfortunately node has no way of knowing this, so it tries to do the best it can but eventually gives up on a later line when it can no longer make sense of what you pasted.
 
I am not sure wether this is the correct place to ask, but I've been looking for the code of a meta called "Got Talent?". Would anyone here happen to know about the code? (It's a Gen 6 meta too, if that's of any relevance)
 
I am not sure wether this is the correct place to ask, but I've been looking for the code of a meta called "Got Talent?". Would anyone here happen to know about the code? (It's a Gen 6 meta too, if that's of any relevance)
I'm pretty sure Got Talent can't be coded because Contests don't exist in Gen 7, meaning that Gen 7 moves can't get a category.
 
I'm pretty sure Got Talent can't be coded because Contests don't exist in Gen 7, meaning that Gen 7 moves can't get a category.
I'm looking for the Gen 6 code. I reckon some stuff may have changed for Gen 7, but I still want to take a look at the old gen code
 
I'm looking for the Gen 6 code. I reckon some stuff may have changed for Gen 7, but I still want to take a look at the old gen code
Code:
{
		name: "Got Talent",
		desc: ["&bullet; <a href=\"https://www.smogon.com/forums/threads/3569554/\">Got Talent</a>"],
		section: "OM of the Month",
		column: 2,

		mod: 'gottalent',
		ruleset: ['Pokemon', 'Standard', 'Swagger Clause', 'Baton Pass Clause', 'Team Preview'],
		banlist: ['Arceus', 'Blaziken', 'Darkrai', 'Deoxys', 'Deoxys-Attack', 'Deoxys-Defense', 'Deoxys-Speed', 'Dialga',
			'Genesect', 'Giratina', 'Giratina-Origin', 'Greninja', 'Groudon', 'Ho-Oh', 'Kyogre', 'Kyurem-White', 'Landorus',
			'Lugia', 'Mewtwo', 'Palkia', 'Rayquaza', 'Reshiram', 'Shaymin-Sky', 'Shuckle', 'Xerneas', 'Yveltal', 'Zekrom',
			'Shadow Tag', 'Speed Boost', 'Gengarite', 'Kangaskhanite', 'Lucarionite', 'Mawilite', 'Salamencite', 'Soul Dew',
		],
},
Code:
'use strict';

exports.BattleScripts = {
	getDamage: function (pokemon, target, move, suppressMessages) {
		if (typeof move === 'string') move = this.getMove(move);

		if (typeof move === 'number') {
			move = {
				basePower: move,
				type: '???',
				category: 'Physical',
				willCrit: false,
				flags: {},
			};
		}

		if (!move.ignoreImmunity || (move.ignoreImmunity !== true && !move.ignoreImmunity[move.type])) {
			if (!target.runImmunity(move.type, !suppressMessages)) {
				return false;
			}
		}

		if (move.ohko) return target.maxhp;

		if (move.damageCallback) return move.damageCallback.call(this, pokemon, target);
		if (move.damage === 'level') return pokemon.level;
		if (move.damage) return move.damage;

		if (!move) move = {};
		if (!move.type) move.type = '???';
		let type = move.type;
		let category = this.getCategory(move);
		let defensiveCategory = move.defensiveCategory || category;

		let basePower = move.basePower;
		if (move.basePowerCallback) basePower = move.basePowerCallback.call(this, pokemon, target, move);
		if (!basePower) {
			if (basePower === 0) return;
			return basePower;
		}
		basePower = this.clampIntRange(basePower, 1);

		let critMult;
		let critRatio = this.runEvent('ModifyCritRatio', pokemon, target, move, move.critRatio || 0);
		critRatio = this.clampIntRange(critRatio, 0, 4);
		critMult = [0, 16, 8, 2, 1];

		move.crit = move.willCrit || false;
		if (move.willCrit === undefined && critRatio) move.crit = (this.random(critMult[critRatio]) === 0);

		if (move.crit) move.crit = this.runEvent('CriticalHit', target, null, move);

		basePower = this.runEvent('BasePower', pokemon, target, move, basePower, true);

		if (!basePower) return 0;
		basePower = this.clampIntRange(basePower, 1);

		let level = pokemon.level;

		let attacker = pokemon;
		let defender = target;
		let attackStat = {Beautiful:'spa', Clever: 'spd', Cool:'atk', Cute:'spe', Tough:'def'}[move.contestType];
		let defenseStat = defensiveCategory === 'Physical' ? 'def' : 'spd';
		let statTable = {atk:'Atk', def:'Def', spa:'SpA', spd:'SpD', spe:'Spe'};
		let attack;
		let defense;

		let atkBoosts = move.useTargetOffensive ? defender.boosts[attackStat] : attacker.boosts[attackStat];
		let defBoosts = move.useSourceDefensive ? attacker.boosts[defenseStat] : defender.boosts[defenseStat];

		let ignoreNegativeOffensive = !!move.ignoreNegativeOffensive;
		let ignorePositiveDefensive = !!move.ignorePositiveDefensive;

		if (move.crit) {
			ignoreNegativeOffensive = true;
			ignorePositiveDefensive = true;
		}
		let ignoreOffensive = !!(move.ignoreOffensive || (ignoreNegativeOffensive && atkBoosts < 0));
		let ignoreDefensive = !!(move.ignoreDefensive || (ignorePositiveDefensive && defBoosts > 0));

		if (ignoreOffensive) atkBoosts = 0;
		if (ignoreDefensive) defBoosts = 0;

		if (move.useTargetOffensive) {
			attack = defender.calculateStat(attackStat, atkBoosts);
		} else {
			attack = attacker.calculateStat(attackStat, atkBoosts);
		}

		if (move.useSourceDefensive) {
			defense = attacker.calculateStat(defenseStat, defBoosts);
		} else {
			defense = defender.calculateStat(defenseStat, defBoosts);
		}

		attack = this.runEvent('Modify' + statTable[attackStat], attacker, defender, move, attack);
		defense = this.runEvent('Modify' + statTable[defenseStat], defender, attacker, move, defense);

		let baseDamage = Math.floor(Math.floor(Math.floor(2 * level / 5 + 2) * basePower * attack / defense) / 50) + 2;

		baseDamage = this.runEvent('WeatherModifyDamage', pokemon, target, move, baseDamage);

		if (move.crit) baseDamage = this.modify(baseDamage, move.critModifier || (this.gen >= 6 ? 1.5 : 2));

		baseDamage = this.randomizer(baseDamage);

		if (move.hasSTAB || pokemon.hasType(type)) baseDamage = this.modify(baseDamage, move.stab || 1.5);
		move.typeMod = target.runEffectiveness(move);

		move.typeMod = this.clampIntRange(move.typeMod, -6, 6);
		if (move.typeMod > 0) {
			if (!suppressMessages) this.add('-supereffective', target);

			for (let i = 0; i < move.typeMod; i++) {
				baseDamage *= 2;
			}
		}
		if (move.typeMod < 0) {
			if (!suppressMessages) this.add('-resisted', target);

			for (let i = 0; i > move.typeMod; i--) {
				baseDamage = Math.floor(baseDamage / 2);
			}
		}

		if (move.crit && !suppressMessages) this.add('-crit', target);

		if (pokemon.status === 'brn' && basePower && move.category === 'Physical' && move.id !== 'facade' && !pokemon.hasAbility('guts')) {
			baseDamage = this.modify(baseDamage, 0.5);
		}

		baseDamage = this.runEvent('ModifyDamage', pokemon, target, move, baseDamage);

		if (basePower && !Math.floor(baseDamage)) return 1;

		return Math.floor(baseDamage);
	},
};
Source: Main PS Repo, commits from June 2016
 
I'm messing around with coding a petmod just editing the pokedex.js, moves.js and abilities.js but when I try to battle it says I crashed the team validator. Anyone know what I'm doing wrong?
 

charizard8888

Catch The Wave
is a Pre-Contributor
I'm messing around with coding a petmod just editing the pokedex.js, moves.js and abilities.js but when I try to battle it says I crashed the team validator. Anyone know what I'm doing wrong?
There might be an error in the code which you would be getting in the server as a red crashlog message with error's file name and error line.
If that's not the case then telling what you exactly changed might help in finding what's wrong.
 
Does anyone know how to change the type that moves appear as?

For example, in Camomons, the pokemon's types are shown below it. I am trying to implement Type Cycle, and I don't know how to make moves change type. For example, I would like all Normal moves to appear as Dark type.

Thanks!
 
Does anyone know how to change the type that moves appear as?
The request data sent from the server to the client only contains the move ids, except for Hidden Power, when the type and power are sent as part of the move id, and the client then displays the type it thinks the move will have.
 

Users Who Are Viewing This Thread (Users: 1, Guests: 0)

Top