General Thread for OM Code

This is the list of OMs that I'm currently running on rom.psim.us:
  • 0v0
  • AbNormal
  • Ability Unity
  • Accessorize
  • Acid Rain
  • Alphabet Cup
  • Alphability
  • Atk-Def Equality
  • Averagemons
  • Balanced Hackmons Plus
  • BasePowerMons
  • Burning 'Mon
  • Camomons
  • Cross Evolution
  • Custom Power
  • Enchanted Items
  • Field Control
  • Follow the Leader
  • Genmons
  • Gods and Followers
  • Got Talent?
  • Head Start
  • Immunimons
  • Inaccuratemons
  • Inheritance
  • Inverse Battle
  • Itemize
  • Mediocremons
  • Megamons
  • Mix and Mega
  • Mix and Mega Anything Goes
  • Monogen
  • Monotype
  • Move Pass LC
  • Multitype Mansion
  • NOSTABmons
  • Nature's Blessing
  • Noobmons
  • Pacifistmons
  • Powered Up
  • Priority Cup
  • Protean Palace
  • Protect: The Metagame
  • Reliablemons
  • Return'd
  • Setupmons
  • Sketchmons
  • SlowMons
  • Stat Switch
  • Suicide Cup
  • Super-Effectivemons
  • The Power Within
  • Tiermons
  • Tormenting Spirits
  • Type Control
  • Type Reflectors
Anyone want code for any of them?
Can u give me the code for Tormenting Spirits and Pacifistmons?Thank u <3
 
Tormenting Spirits and Pacifistmons?
Code:
	{
		name: "Pacifistmons",
		desc: [
			"Only status moves are allowed.",
			"&bullet; <a href=\"https://www.smogon.com/forums/threads/3501123/\">Pacifistmons</a>",
		],
		section: "Other Metagames",

		searchShow: false,
		ruleset: ['Uber'],
		banlist: [
			'Gengar-Mega', 'Heatran',
			'Magic Guard', 'Regenerator',
			'Heal Order', 'Milk Drink', 'Moonlight', 'Morning Sun', 'Recover', 'Rest', 'Roost', 'Slack Off', 'Soft-Boiled', 'Swallow', 'Synthesis', 'Wish',
		],
		onValidateSet: function (set) {
			let problems = [];
			for (let i = 0; i < set.moves.length; i++) {
				let move = this.getMove(set.moves[i]);
				if (move.category !== 'Status') problems.push(move.name + ' is banned because it is a ' + move.category + ' move.');
			}
			return problems;
		},
	},
Code:
	{
		name: "Tormenting Spirits",
		desc: [
			"All Pok&eacute;mon are permanently under the effect of Torment.",
			"&bullet; <a href=\"https://www.smogon.com/forums/threads/3524117/\">Tormenting Spirits</a>",
		],
		section: "Other Metagames",

		searchShow: false,
		ruleset: ['OU'],
		banlist: ['Encore', 'Switcheroo + Choice Band', 'Switcheroo + Choice Scarf', 'Switcheroo + Choice Specs', 'Trick + Choice Band', 'Trick + Choice Scarf', 'Trick + Choice Specs'],
		onDisableMove: function (pokemon) {
			if (pokemon.lastMove !== 'struggle') pokemon.disableMove(pokemon.lastMove);
		},
	},
 
  • Like
Reactions: Mq

I run in to this bug,can u help?

Code:
TypeError: this.p1.active.any is not a function
    at Tools.exports.BattleScripts.runDecision (C:\Users\ADMIN\Desktop\Vietnam\Showdown-Boilerplate-master Testing\mods\linked\scripts.js:343:47)
    at Tools.process.on.require.start.process.on.Battle.construct.Battle.eachEvent.Battle.makeRequest.switchTable.some.switchTable.some.Battle.nextTurn.Battle.damage.Battle.resolveTarget.Battle.runDecision.Battle.go (C:\Users\ADMIN\Desktop\Vietnam\Showdown-Boilerplate-master Testing\battle-engine.js:4178:9)
    at Tools.process.on.require.start.process.on.Battle.construct.Battle.eachEvent.Battle.makeRequest.switchTable.some.switchTable.some.Battle.nextTurn.Battle.damage.Battle.resolveTarget.Battle.runDecision.Battle.commitDecisions (C:\Users\ADMIN\Desktop\Vietnam\Showdown-Boilerplate-master Testing\battle-engine.js:4259:8)
    at Tools.process.on.require.start.process.on.Battle.construct.Battle.eachEvent.Battle.makeRequest.switchTable.some.switchTable.some.Battle.nextTurn.Battle.damage.Battle.resolveTarget.Battle.runDecision.Battle.choose (C:\Users\ADMIN\Desktop\Vietnam\Showdown-Boilerplate-master Testing\battle-engine.js:4233:9)
    at Tools.process.on.require.start.process.on.Battle.construct.Battle.eachEvent.Battle.makeRequest.switchTable.some.switchTable.some.Battle.nextTurn.Battle.damage.Battle.resolveTarget.Battle.runDecision.Battle.parseChoice.Battle.add.Battle.receive (C:\Users\ADMIN\Desktop\Vietnam\Showdown-Boilerplate-master Testing\battle-engine.js:4738:9)
    at process.<anonymous> (C:\Users\ADMIN\Desktop\Vietnam\Showdown-Boilerplate-master Testing\battle-engine.js:74:12)
    at emitTwo (events.js:100:13)
    at process.emit (events.js:185:7)
    at handleMessage (internal/child_process.js:695:10)
    at Pipe.channel.onread (internal/child_process.js:440:11)

Additional information:
  message = battle-linked-80|choose|p2|team 623451|2
  currentRequest = teampreview
  log =
|player|p1|yugi2002x|281
|player|p2|KoritsuDFM|1
|gametype|singles
|gen|6
|tier|Linked
|seed|16521,25606,45141,7690
|rule|Sleep Clause Mod: Limit one foe put to sleep
|rule|Species Clause: Limit one of each Pokémon
|rule|OHKO Clause: OHKO moves are banned
|rule|Moody Clause: Moody is banned
|rule|Evasion Moves Clause: Evasion moves are banned
|rule|Endless Battle Clause: Forcing endless battles is banned
|rule|HP Percentage Mod: HP is shown in percentages
|clearpoke
|poke|p1|Gardevoir, F|item
|poke|p1|Serperior, M|item
|poke|p1|Lucario, F|item
|poke|p1|Garchomp, F|item
|poke|p1|Scyther, M|item
|poke|p1|Volcanion|item
|poke|p2|Excadrill, F|item
|poke|p2|Ludicolo, M|item
|poke|p2|Swampert, F|item
|poke|p2|Shuckle, F|item
|poke|p2|Garchomp, M|item
|poke|p2|Wobbuffet, F|item
|rule|Swagger Clause: Swagger is banned
|rule|Baton Pass Clause: Limit one Baton Passer, can't pass Spe and other stats simultaneously
|teampreview
|choice|team 523416|team 123456
|
|start
|switch|p1a: Scyther|Scyther, M|282/282
|switch|p2a: Excadrill|Excadrill, F|361/361
|html|<div class="broadcast-red"><b>The battle crashed</b><br />You can keep playing but it might crash again.</div>
|teampreview
|choice|team 123456|team 623451
|
 
  • Like
Reactions: Mq
I run in to this bug,can u help?
Unfortunately the Linked code is probably going to be out of date, as it was designed to work with the server code that existed at the time; for instance I think the line you're crashing on was obsoleted 5 months ago.
 
  • Like
Reactions: Mq
KoritsuDFM , glad you asked!

I am always a fan of Linked, so if it breaks, just ping me and I'll post an updated version.

So, here are the /mods/ files:

http://pastebin.com/z4KdKezn
http://pastebin.com/dz8Fi51L
http://pastebin.com/bir4aGYC
http://pastebin.com/a2TH9CP4

(Yes, this is not the posting format described in the OP, but I ultimately feel that it's really clunky :|)
Now its run in to this problem,lol XD Can u help me?

Code:
TypeError: Cannot set property 'position' of undefined
    at Tools.exports.BattleScripts.runDecision.p1switch [as runDecision] (C:\Users\ADMIN\Desktop\Vietnam\Showdown-Boilerplate-master Testing\mods\linked\scripts.js:254:39)
    at Tools.process.on.require.start.process.on.Battle.construct.Battle.eachEvent.Battle.makeRequest.switchTable.some.switchTable.some.Battle.nextTurn.Battle.damage.Battle.resolveTarget.Battle.runDecision.Battle.go (C:\Users\ADMIN\Desktop\Vietnam\Showdown-Boilerplate-master Testing\battle-engine.js:4178:9)
    at Tools.process.on.require.start.process.on.Battle.construct.Battle.eachEvent.Battle.makeRequest.switchTable.some.switchTable.some.Battle.nextTurn.Battle.damage.Battle.resolveTarget.Battle.runDecision.Battle.commitDecisions (C:\Users\ADMIN\Desktop\Vietnam\Showdown-Boilerplate-master Testing\battle-engine.js:4259:8)
    at Tools.process.on.require.start.process.on.Battle.construct.Battle.eachEvent.Battle.makeRequest.switchTable.some.switchTable.some.Battle.nextTurn.Battle.damage.Battle.resolveTarget.Battle.runDecision.Battle.choose (C:\Users\ADMIN\Desktop\Vietnam\Showdown-Boilerplate-master Testing\battle-engine.js:4233:9)
    at Tools.process.on.require.start.process.on.Battle.construct.Battle.eachEvent.Battle.makeRequest.switchTable.some.switchTable.some.Battle.nextTurn.Battle.damage.Battle.resolveTarget.Battle.runDecision.Battle.parseChoice.Battle.add.Battle.receive (C:\Users\ADMIN\Desktop\Vietnam\Showdown-Boilerplate-master Testing\battle-engine.js:4738:9)
    at process.<anonymous> (C:\Users\ADMIN\Desktop\Vietnam\Showdown-Boilerplate-master Testing\battle-engine.js:74:12)
    at emitTwo (events.js:100:13)
    at process.emit (events.js:185:7)
    at handleMessage (internal/child_process.js:695:10)
    at Pipe.channel.onread (internal/child_process.js:440:11)

Additional information:
  message = battle-linked-89|choose|p2|team 1|1
  currentRequest = teampreview
  log =
|player|p1|JustinVu|266
|player|p2|KoritsuDFM|170
|gametype|singles
|gen|6
|tier|Linked
|seed|4335,56547,50,65089
|rule|Sleep Clause Mod: Limit one foe put to sleep
|rule|Species Clause: Limit one of each Pokémon
|rule|OHKO Clause: OHKO moves are banned
|rule|Moody Clause: Moody is banned
|rule|Evasion Moves Clause: Evasion moves are banned
|rule|Endless Battle Clause: Forcing endless battles is banned
|rule|HP Percentage Mod: HP is shown in percentages
|clearpoke
|poke|p1|Zubat, M, shiny|item
|poke|p2|Charizard, M|item
|rule|Swagger Clause: Swagger is banned
|rule|Baton Pass Clause: Limit one Baton Passer, can't pass Spe and other stats simultaneously
|teampreview
|choice|team 1|team 1
|


TypeError: Cannot read property 'fullname' of undefined
    at BattleSide.process.on.require.start.process.on.BattleSide.getData (C:\Users\ADMIN\Desktop\Vietnam\Showdown-Boilerplate-master Testing\battle-engine.js:1446:19)
    at Tools.process.on.require.start.process.on.Battle.construct.Battle.eachEvent.Battle.makeRequest.switchTable.some.switchTable.some.activeData [as makeRequest] (C:\Users\ADMIN\Desktop\Vietnam\Showdown-Boilerplate-master Testing\battle-engine.js:2690:50)
    at process.<anonymous> (C:\Users\ADMIN\Desktop\Vietnam\Showdown-Boilerplate-master Testing\battle-engine.js:86:13)
    at emitTwo (events.js:100:13)
    at process.emit (events.js:185:7)
    at handleMessage (internal/child_process.js:695:10)
    at Pipe.channel.onread (internal/child_process.js:440:11)
 
Now its run in to this problem,lol XD Can u help me?

Code:
TypeError: Cannot set property 'position' of undefined
    at Tools.exports.BattleScripts.runDecision.p1switch [as runDecision] (C:\Users\ADMIN\Desktop\Vietnam\Showdown-Boilerplate-master Testing\mods\linked\scripts.js:254:39)
    at Tools.process.on.require.start.process.on.Battle.construct.Battle.eachEvent.Battle.makeRequest.switchTable.some.switchTable.some.Battle.nextTurn.Battle.damage.Battle.resolveTarget.Battle.runDecision.Battle.go (C:\Users\ADMIN\Desktop\Vietnam\Showdown-Boilerplate-master Testing\battle-engine.js:4178:9)
    at Tools.process.on.require.start.process.on.Battle.construct.Battle.eachEvent.Battle.makeRequest.switchTable.some.switchTable.some.Battle.nextTurn.Battle.damage.Battle.resolveTarget.Battle.runDecision.Battle.commitDecisions (C:\Users\ADMIN\Desktop\Vietnam\Showdown-Boilerplate-master Testing\battle-engine.js:4259:8)
    at Tools.process.on.require.start.process.on.Battle.construct.Battle.eachEvent.Battle.makeRequest.switchTable.some.switchTable.some.Battle.nextTurn.Battle.damage.Battle.resolveTarget.Battle.runDecision.Battle.choose (C:\Users\ADMIN\Desktop\Vietnam\Showdown-Boilerplate-master Testing\battle-engine.js:4233:9)
    at Tools.process.on.require.start.process.on.Battle.construct.Battle.eachEvent.Battle.makeRequest.switchTable.some.switchTable.some.Battle.nextTurn.Battle.damage.Battle.resolveTarget.Battle.runDecision.Battle.parseChoice.Battle.add.Battle.receive (C:\Users\ADMIN\Desktop\Vietnam\Showdown-Boilerplate-master Testing\battle-engine.js:4738:9)
    at process.<anonymous> (C:\Users\ADMIN\Desktop\Vietnam\Showdown-Boilerplate-master Testing\battle-engine.js:74:12)
    at emitTwo (events.js:100:13)
    at process.emit (events.js:185:7)
    at handleMessage (internal/child_process.js:695:10)
    at Pipe.channel.onread (internal/child_process.js:440:11)

Additional information:
  message = battle-linked-89|choose|p2|team 1|1
  currentRequest = teampreview
  log =
|player|p1|JustinVu|266
|player|p2|KoritsuDFM|170
|gametype|singles
|gen|6
|tier|Linked
|seed|4335,56547,50,65089
|rule|Sleep Clause Mod: Limit one foe put to sleep
|rule|Species Clause: Limit one of each Pokémon
|rule|OHKO Clause: OHKO moves are banned
|rule|Moody Clause: Moody is banned
|rule|Evasion Moves Clause: Evasion moves are banned
|rule|Endless Battle Clause: Forcing endless battles is banned
|rule|HP Percentage Mod: HP is shown in percentages
|clearpoke
|poke|p1|Zubat, M, shiny|item
|poke|p2|Charizard, M|item
|rule|Swagger Clause: Swagger is banned
|rule|Baton Pass Clause: Limit one Baton Passer, can't pass Spe and other stats simultaneously
|teampreview
|choice|team 1|team 1
|


TypeError: Cannot read property 'fullname' of undefined
    at BattleSide.process.on.require.start.process.on.BattleSide.getData (C:\Users\ADMIN\Desktop\Vietnam\Showdown-Boilerplate-master Testing\battle-engine.js:1446:19)
    at Tools.process.on.require.start.process.on.Battle.construct.Battle.eachEvent.Battle.makeRequest.switchTable.some.switchTable.some.activeData [as makeRequest] (C:\Users\ADMIN\Desktop\Vietnam\Showdown-Boilerplate-master Testing\battle-engine.js:2690:50)
    at process.<anonymous> (C:\Users\ADMIN\Desktop\Vietnam\Showdown-Boilerplate-master Testing\battle-engine.js:86:13)
    at emitTwo (events.js:100:13)
    at process.emit (events.js:185:7)
    at handleMessage (internal/child_process.js:695:10)
    at Pipe.channel.onread (internal/child_process.js:440:11)
You don't seem to be running the server at https://github.com/Zarel/Pokemon-Showdown :|
 
This is the list of OMs that I'm currently running on rom.psim.us:
  • 0v0
  • AbNormal
  • Ability Unity
  • Accessorize
  • Acid Rain
  • Alphabet Cup
  • Alphability
  • Atk-Def Equality
  • Averagemons
  • Balanced Hackmons Plus
  • BasePowerMons
  • Burning 'Mon
  • Camomons
  • Cross Evolution
  • Custom Power
  • Enchanted Items
  • Field Control
  • Follow the Leader
  • Genmons
  • Gods and Followers
  • Got Talent?
  • Head Start
  • Immunimons
  • Inaccuratemons
  • Inheritance
  • Inverse Battle
  • Itemize
  • Mediocremons
  • Megamons
  • Mix and Mega
  • Monogen
  • Monotype
  • Move Pass LC
  • Multitype Mansion
  • NOSTABmons
  • Nature's Blessing
  • Noobmons
  • Pacifistmons
  • Pikachu Cup
  • Powered Up
  • Priority Cup
  • Protean Palace
  • Protect: The Metagame
  • Reliablemons
  • Return'd
  • Setupmons
  • Sketchmons
  • SlowMons
  • Stat Switch
  • Suicide Cup
  • Super-Effectivemons
  • The Power Within
  • Tiermons
  • Tormenting Spirits
  • Type Control
  • Type Reflectors
Anyone want code for any of them?
Could you also paste the code for cross evolution? Also thanks for doing this!
 
Could you also paste the code for cross evolution?
Code:
	{
		name: "Cross Evolution",
		desc: ["&bullet; <a href=\"http://www.smogon.com/forums/threads/3569577/\">Cross Evolution</a>"],
		section: "Other Metagames",

		ruleset: ['Ubers', 'Baton Pass Clause'],
		banlist: ['Rule:nicknameclause'],
		onValidateTeam: function (team) {
			let nameTable = {};
			for (let i = 0; i < team.length; i++) {
				let name = team[i].name;
				if (name) {
					if (nameTable[name]) {
						return ["Your Pokémon must have different nicknames.", "(You have more than one " + name + ")"];
					}
					nameTable[name] = true;
				}
			}
		},
		validateSet: function (set, teamHas) {
			let crossTemplate = this.tools.getTemplate(set.name);
			if (!crossTemplate.exists) return this.validateSet(set, teamHas);
			let template = this.tools.getTemplate(set.species);
			if (!template.exists) return ["The Pokemon '" + set.species + "' does not exist."];
			if (!template.evos.length) return ["" + template.species + " cannot cross evolve because it doesn't evolve."];
			if (crossTemplate.species == 'Shedinja') return ["" + template.species + " cannot cross evolve into " + crossTemplate.species + " because it is banned."];
			if (crossTemplate.battleOnly || !crossTemplate.prevo) return ["" + template.species + " cannot cross evolve into " + crossTemplate.species + " because it isn't an evolution."];
			let crossPrevoTemplate = this.tools.getTemplate(crossTemplate.prevo);
			if (!crossPrevoTemplate.prevo !== !template.prevo) return ["" + template.species + " cannot cross into " + crossTemplate.species + " because they are not consecutive evolutionary stages."];

			// Make sure no stat is too high/low to cross evolve to
			let stats = {'hp': 'HP', 'atk': 'Attack', 'def': 'Defense', 'spa': 'Special Attack', 'spd': 'Special Defense', 'spe': 'Speed'};
			for (let statid in template.baseStats) {
				let evoStat = template.baseStats[statid] + crossTemplate.baseStats[statid] - crossPrevoTemplate.baseStats[statid];
				if (evoStat < 1) {
					return ["" + template.species + " cannot cross evolve to " + crossTemplate.species + " because its " + stats[statid] + " would be too low."];
				} else if (evoStat > 255) {
					return ["" + template.species + " cannot cross evolve to " + crossTemplate.species + " because its " + stats[statid] + " would be too high."];
				}
			}

			let mixedTemplate = Object.assign({}, template);
			// Ability test
			let ability = this.tools.getAbility(set.ability);
			if (ability.name !== 'Huge Power' && ability.name !== 'Pure Power' && ability.name !== 'Shadow Tag') mixedTemplate.abilities = crossTemplate.abilities;

			mixedTemplate.learnset = Object.assign({}, template.learnset);
			let newMoves = 0;
			for (let i in set.moves) {
				let move = toId(set.moves[i]);
				if (!this.checkLearnset(move, template)) continue;
				if (this.checkLearnset(move, crossTemplate)) continue;
				if (++newMoves > 2) continue;
				mixedTemplate.learnset[move] = ['6T'];
			}
			return this.validateSet(set, teamHas, mixedTemplate);
		},
		onBegin: function () {
			let allPokemon = this.p1.pokemon.concat(this.p2.pokemon);
			for (let i = 0, len = allPokemon.length; i < len; i++) {
				let pokemon = allPokemon[i];
                                if (pokemon.set.name === pokemon.set.species) continue;
				let crossTemplate = this.getTemplate(pokemon.name);
				if (!crossTemplate.exists) continue;
				try {
				let template = pokemon.baseTemplate;
				let crossPrevoTemplate = this.getTemplate(crossTemplate.prevo);
				let mixedTemplate = Object.assign({}, template);
				mixedTemplate.baseSpecies = mixedTemplate.species = template.species + '-' + crossTemplate.species;
				mixedTemplate.weightkg = Math.max(0.1, template.weightkg + crossTemplate.weightkg - crossPrevoTemplate.weightkg);
				mixedTemplate.nfe = false;

				mixedTemplate.baseStats = {};
				for (let statid in template.baseStats) {
					mixedTemplate.baseStats[statid] = template.baseStats[statid] + crossTemplate.baseStats[statid] - crossPrevoTemplate.baseStats[statid];
				}
				pokemon.hp = pokemon.maxhp = Math.floor(Math.floor(2 * mixedTemplate.baseStats['hp'] + pokemon.set.ivs['hp'] + Math.floor(pokemon.set.evs['hp'] >> 2) + 100) * pokemon.level / 100 + 10);

				mixedTemplate.types = template.types.slice();
				if (crossTemplate.types[0] !== crossPrevoTemplate.types[0]) mixedTemplate.types[0] = crossTemplate.types[0];
				if (crossTemplate.types[1] !== crossPrevoTemplate.types[1]) mixedTemplate.types[1] = crossTemplate.types[1] || crossTemplate.types[0];
				if (mixedTemplate.types[0] === mixedTemplate.types[1]) mixedTemplate.types.length = 1;

				pokemon.baseTemplate = mixedTemplate;
				pokemon.formeChange(mixedTemplate);
				pokemon.crossEvolved = true;
				} catch (e) {
					this.add('-hint', 'Failed to cross evolve ' + pokemon.baseTemplate.species + ' to ' + crossTemplate.species + '. Please report this error so that it can be fixed.');
				}
			}
		},
		onSwitchInPriority: 1,
		onSwitchIn: function (pokemon) {
			if (pokemon.crossEvolved) {
				this.add('-start', pokemon, 'typechange', pokemon.types.join('/'), '[silent]');
			}
		},
	},
Note: It's vaguely possible that this relies on changes to rulesets.js, tools.js, validator.js, or other system functions, but offhand I don't know which. Edit: Added a line to fix a bug that stopped non-cross evolved Pokémon from working. Also updated the code for its new Ubers base.
 
Last edited:
  • Like
Reactions: Mq
As requested in PM:
Code:
	{
		name: "Follow the Leader",
		desc: [
			"All Pok&eacute;mon must use the abilities and moves of the Pok&eacute;mon in the first slot.",
			"&bullet; <a href=\"https://www.smogon.com/forums/threads/3565685/\">Follow the Leader</a>",
		],
		section: "Other Metagames",

		ruleset: ['OU'],
		banlist: ['Chatter', 'Smeargle', 'Shedinja', 'Regigigas', 'Slaking', 'Huge Power', 'Pure Power', 'Shadow Tag', 'Arena Trap', 'Imposter'],
		overrides: ['Aegislash'],
		validateSet: function (set, teamHas) {
			if (!teamHas.donorTemplate) {
				teamHas.donorTemplate = this.tools.getTemplate(set.species);
				return this.validateSet(set, teamHas);
			}
			let template = Object.assign({}, this.tools.getTemplate(set.species));
			template.abilities = teamHas.donorTemplate.abilities;
			template.baseSpecies = teamHas.donorTemplate.species;
			delete template.learnset;
			delete template.eventOnly;
			return this.validateSet(set, teamHas, template);
		},
	},
Edit: Rewrote the Follow the Leader validator because it was buggy. (I think it must have been one of the OMs that I accidentally deleted trying to update my server and the backup I had was of a buggy version.) That doesn't mean to say that this version works, but feel free to test it out on ROM.
Code:
	{
		name: "Nature Swap",
		desc: ["&bullet; <a href=\"https://www.smogon.com/forums/threads/3577739/\">Nature Swap</a>"],
		section: "Other Metagames",

		ruleset: ['OU'],
		banlist: ['Chansey', 'Talonflame'],
		onBegin: function () {
			let allPokemon = this.p1.pokemon.concat(this.p2.pokemon);
			for (let i = 0, len = allPokemon.length; i < len; i++) {
				let pokemon = allPokemon[i];
				let nature = pokemon.battle.getNature(pokemon.set.nature);
				if (nature.plus !== nature.minus) {
					["baseTemplate", "canMegaEvo"].forEach(key => {
						if (pokemon[key]) {
							let template = Object.assign({}, this.getTemplate(pokemon[key]));
							template.baseStats = Object.assign({}, template.baseStats);
							let plus = template.baseStats[nature.plus];
							let minus = template.baseStats[nature.minus];
							template.baseStats[nature.plus] = minus;
							template.baseStats[nature.minus] = plus;
							pokemon[key] = template;
						}
					});
					pokemon.formeChange(pokemon.baseTemplate);
				}
			}
		},
	},
 
Last edited:
Code:
 {
name: "Cross Evolution",
desc: ["&bullet; <a href=\"http://www.smogon.com/forums/threads/3569577/\">Cross Evolution</a>"],
section: "Other Metagames",

searchShow: false,
ruleset: ['OU'],
banlist: ['Rule:nicknameclause'],
onValidateTeam: function (team) {
let nameTable = {};
for (let i = 0; i < team.length; i++) {
let name = team[i].name;
if (name) {
if (nameTable[name]) {
return ["Your Pokémon must have different nicknames.", "(You have more than one " + name + ")"];
}
nameTable[name] = true;
}
}
},
validateSet: function (set, teamHas) {
let crossTemplate = this.tools.getTemplate(set.name);
if (!crossTemplate.exists) return this.validateSet(set, teamHas);
let template = this.tools.getTemplate(set.species);
if (!template.exists) return ["The Pokemon '" + set.species + "' does not exist."];
if (template.species == 'Archen' || template.species === 'Scyther' || template.species === 'Sneasel') return["" + template.species + " is banned from cross evolving."];
if (!template.evos.length) return ["" + template.species + " cannot cross evolve because it doesn't evolve."];
if (crossTemplate.species === 'Gyarados' || crossTemplate.species == 'Shedinja') return ["" + template.species + " cannot cross evolve into " + crossTemplate.species + " because it is banned."];
if (crossTemplate.battleOnly || !crossTemplate.prevo) return ["" + template.species + " cannot cross evolve into " + crossTemplate.species + " because it isn't an evolution."];
let crossPrevoTemplate = this.tools.getTemplate(crossTemplate.prevo);
if (!crossPrevoTemplate.prevo !== !template.prevo) return ["" + template.species + " cannot cross into " + crossTemplate.specieis + " because they are not consecutive evolutionary stages."];

// Make sure no stat is too high/low to cross evolve to
let stats = {'hp': 'HP', 'atk': 'Attack', 'def': 'Defense', 'spa': 'Special Attack', 'spd': 'Special Defense', 'spe': 'Speed'};
for (let statid in template.baseStats) {
let evoStat = template.baseStats[statid] + crossTemplate.baseStats[statid] - crossPrevoTemplate.baseStats[statid];
if (evoStat < 1) {
return ["" + template.species + " cannot cross evolve to " + crossTemplate.species + " because its " + stats[statid] + " would be too low."];
} else if (evoStat > 255) {
return ["" + template.species + " cannot cross evolve to " + crossTemplate.species + " because its " + stats[statid] + " would be too high."];
}
}

let mixedTemplate = Object.assign({}, template);
// Ability test
let ability = this.tools.getAbility(set.ability);
if (ability.name !== 'Huge Power' && ability.name !== 'Pure Power') mixedTemplate.abilities = crossTemplate.abilities;

mixedTemplate.learnset = Object.assign({}, template.learnset);
let newMoves = 0;
for (let i in set.moves) {
let move = toId(set.moves[i]);
if (!this.checkLearnset(move, template)) continue;
if (this.checkLearnset(move, crossTemplate)) continue;
if (++newMoves > 2) continue;
mixedTemplate.learnset[move] = ['6T'];
}
return this.validateSet(set, teamHas, mixedTemplate);
},
onBegin: function () {
let allPokemon = this.p1.pokemon.concat(this.p2.pokemon);
for (let i = 0, len = allPokemon.length; i < len; i++) {
let pokemon = allPokemon[i];
let crossTemplate = this.getTemplate(pokemon.name);
if (!crossTemplate.exists) continue;
let template = pokemon.baseTemplate;
let crossPrevoTemplate = this.getTemplate(crossTemplate.prevo);
let mixedTemplate = Object.assign({}, template);
mixedTemplate.baseSpecies = mixedTemplate.species = template.species + '-' + crossTemplate.species;
mixedTemplate.weightkg = Math.max(0.1, template.weightkg + crossTemplate.weightkg - crossPrevoTemplate.weightkg);
mixedTemplate.nfe = false;

mixedTemplate.baseStats = {};
for (let statid in template.baseStats) {
mixedTemplate.baseStats[statid] = template.baseStats[statid] + crossTemplate.baseStats[statid] - crossPrevoTemplate.baseStats[statid];
}
pokemon.hp = pokemon.maxhp = Math.floor(Math.floor(2 * mixedTemplate.baseStats['hp'] + pokemon.set.ivs['hp'] + Math.floor(pokemon.set.evs['hp'] >> 2) + 100) * pokemon.level / 100 + 10);

mixedTemplate.types = template.types.slice();
if (crossTemplate.types[0] !== crossPrevoTemplate.types[0]) mixedTemplate.types[0] = crossTemplate.types[0];
if (crossTemplate.types[1] !== crossPrevoTemplate.types[1]) mixedTemplate.types[1] = crossTemplate.types[1] || crossTemplate.types[0];
if (mixedTemplate.types[0] === mixedTemplate.types[1]) mixedTemplate.types.length = 1;

pokemon.baseTemplate = mixedTemplate;
pokemon.formeChange(mixedTemplate);
pokemon.crossEvolved = true;
}
},
onSwitchInPriority: 1,
onSwitchIn: function (pokemon) {
if (pokemon.crossEvolved) {
this.add('-start', pokemon, 'typechange', pokemon.types.join('/'), '[silent]');
}
},
},
Note: It's vaguely possible that this relies on changes to rulesets.js, tools.js, validator.js, or other system functions, but offhand I don't know which.
Is there an updated version of Cross Evolution? This code doesn't seem to work correctly for me.
 
  • Like
Reactions: Mq
As requested in PM:
Code:
	{
		name: "Camomons",
		desc: [
			"Pok&eacute;mon change type to match their first two moves.",
			"&bullet; <a href=\"https://www.smogon.com/forums/threads/3513059/\">Camomons</a>",
		],
		section: "Other Metagames",

		ruleset: ['OU'],
		onBegin: function () {
			let allPokemon = this.p1.pokemon.concat(this.p2.pokemon);
			for (let i = 0, len = allPokemon.length; i < len; i++) {
				let pokemon = allPokemon[i];
				let types = [this.getMove(pokemon.move[0]).type];
				if (pokemon.move[1] && this.getMove(pokemon.move[1]).type !== types[0]) types.push(this.getMove(pokemon.move[1]).type);
				pokemon.baseTemplate = pokemon.template = Object.assign({}, pokemon.template);
				pokemon.types = pokemon.template.types = types;
			}
		},
		onAfterMega: function (pokemon) {
			let types = [this.getMove(pokemon.move[0]).type];
			if (pokemon.move[1] && this.getMove(pokemon.move[1]).type !== types[0]) types.push(this.getMove(pokemon.move[1]).type);
			pokemon.baseTemplate = pokemon.template = Object.assign({}, pokemon.template);
			pokemon.types = pokemon.template.types = types;
		},
	},
Note: doesn't apply the Mimic/Sketch type change.
 
formats.js:
Code:
	{
		name: "Mix and Mega",
		desc: ["&bullet; <a href=\"https://www.smogon.com/forums/threads/3540979/\">Mix and Mega</a>"],
		section: "Other Metagames",

		mod: 'mixandmega',
		ruleset: ['Ubers', 'Baton Pass Clause'],
		banlist: ['Gengarite', 'Shadow Tag', 'Dynamic Punch', 'Electrify', 'Zap Cannon'],
		onValidateTeam: function (team, format) {
			let itemTable = [];
			for (let i = 0; i < team.length; i++) {
				let item = this.getItem(team[i].item);
				if (!item) continue;
				if (itemTable[item] && item.megaStone) return ["You are limited to one of each Mega Stone.", "(You have more than one " + item.name + ".)"];
				if (itemTable[item] && (item.id === 'redorb' || item.id === 'blueorb')) return ["You are limited to one of each Primal Orb.", "(You have more than one " + item.name + ".)"];
				itemTable[item] = true;
			}
		},
		onValidateSet: function (set) {
			let template = this.getTemplate(set.species || set.name);
			let item = this.getItem(set.item);
			if (!item.megaEvolves && item.id !== 'blueorb' && item.id !== 'redorb') return;
			if (template.baseSpecies === item.megaEvolves || (item.id === 'redorb' && template.baseSpecies === 'Groudon') || (item.id === 'blueorb' && template.baseSpecies === 'Kyogre')) return;
			if (template.evos.length) return [template.species + " is not allowed to hold " + item.name + " because it isn't fully evolved."];
			if (template.tier === 'Uber') {
				return [template.species + " is not allowed to hold a Mega Stone."];
			}
			switch (item.id) {
			case 'beedrillite': case 'kangaskhanite':
				return [item.name + " is only allowed to be held by " + item.megaEvolves + "."];
			case 'blazikenite':
				if (set.ability === 'Speed Boost') break;
				return ["You are only allowed to hold Blazikenite if your Ability is Speed Boost."];
			case 'mawilite': case 'medichamite':
				if (set.ability === 'Huge Power' || set.ability === 'Pure Power') break;
				if (template.species === "Mawile" || template.species === "Medicham") break;
				return ["You are only allowed to hold " + item.name + " if your Ability is Huge Power or Pure Power."];
			}
		},
		onBegin: function () {
			let allPokemon = this.p1.pokemon.concat(this.p2.pokemon);
			for (let i = 0, len = allPokemon.length; i < len; i++) {
				let pokemon = allPokemon[i];
				pokemon.originalSpecies = pokemon.baseTemplate.species;
			}
		},
		onSwitchInPriority: -6,
		onSwitchIn: function (pokemon) {
			let item = pokemon.getItem();
			if (pokemon.isActive && !pokemon.template.isMega && !pokemon.template.isPrimal && (item.id === 'redorb' || item.id === 'blueorb') && pokemon.baseTemplate.tier !== 'Uber' && !pokemon.template.evos.length) {
				let template = this.getMixedTemplate(pokemon.originalSpecies, item.id === 'redorb' ? 'Groudon-Primal' : 'Kyogre-Primal');
				pokemon.formeChange(template);
				pokemon.baseTemplate = template;
				if (pokemon.originalSpecies === (item.id === 'redorb' ? 'Groudon' : 'Kyogre')) {
					pokemon.details = template.species + (pokemon.level === 100 ? '' : ', L' + pokemon.level) + (pokemon.gender === '' ? '' : ', ' + pokemon.gender) + (pokemon.set.shiny ? ', shiny' : '');
					this.add('detailschange', pokemon, pokemon.details);
				} else {
					let oTemplate = this.getTemplate(pokemon.originalSpecies);
					this.add('-formechange', pokemon, oTemplate.species, template.requiredItem);
					this.add('-start', pokemon, this.getTemplate(template.originalMega).requiredItem, '[silent]');
					if (oTemplate.types.length !== pokemon.types.length || oTemplate.types[1] !== pokemon.template.types[1]) {
						this.add('-start', pokemon, 'typechange', pokemon.template.types.join('/'), '[silent]');
					}
				}
				this.add('-activate', pokemon, pokemon.getItem());
				this.add('-primal', pokemon);
				pokemon.setAbility(template.abilities['0']);
				pokemon.baseAbility = pokemon.ability;
				pokemon.canMegaEvo = false;
			} else {
				let oMegaTemplate = this.getTemplate(pokemon.template.originalMega);
				if (oMegaTemplate.exists && pokemon.originalSpecies !== oMegaTemplate.baseSpecies) {
					this.add('-start', pokemon, oMegaTemplate.requiredItem || oMegaTemplate.requiredMove, '[silent]');
					let oTemplate = this.getTemplate(pokemon.originalSpecies);
					if (oTemplate.types.length !== pokemon.template.types.length || oTemplate.types[1] !== pokemon.template.types[1]) {
						this.add('-start', pokemon, 'typechange', pokemon.template.types.join('/'), '[silent]');
					}
				}
			}
		},
		onSwitchOut: function (pokemon) {
			let oMegaTemplate = this.getTemplate(pokemon.template.originalMega);
			if (oMegaTemplate.exists && pokemon.originalSpecies !== oMegaTemplate.baseSpecies) {
				this.add('-end', pokemon, oMegaTemplate.requiredItem || oMegaTemplate.requiredMove, '[silent]');
			}
		},
	},
mods/mixandmega/formats-data.js
Code:
'use strict';

exports.BattleFormatsData = {
	aegislash: {
		inherit: true,
		tier: 'OU',
	},
	cresselia: {
		inherit: true,
		tier: 'Uber',
	},
	dragonite: {
		inherit: true,
		tier: 'Uber',
	},
	greninja: {
		inherit: true,
		tier: 'OU',
	},
	hoopaunbound: {
		inherit: true,
		tier: 'OU',
	},
	kyuremblack: {
		inherit: true,
		tier: 'Uber',
	},
	landorus: {
		inherit: true,
		tier: 'OU',
	},
	lucario: {
		inherit: true,
		tier: 'Uber',
	},
	manaphy: {
		inherit: true,
		tier: 'Uber',
	},
	regigigas: {
		inherit: true,
		tier: 'Uber',
	},
	slaking: {
		inherit: true,
		tier: 'Uber',
	},
};
mods/mixandmega/scripts.js
Code:
'use strict';

exports.BattleScripts = {
	init: function () {
		let onTakeMegaStone = function (item, source) {
			return false;
		};
		for (let id in this.data.Items) {
			if (id !== 'redorb' && id !== 'blueorb' && !this.data.Items[id].megaStone) continue;
			this.modData('Items', id).onTakeItem = onTakeMegaStone;
		}
	},
	canMegaEvo: function (pokemon) {
		if (pokemon.template.isMega || pokemon.template.isPrimal) return false;

		let item = pokemon.getItem();
		if (item.megaStone) {
			if (item.megaStone === pokemon.species) return false;
			return item.megaStone;
		} else if (pokemon.set.moves.indexOf('dragonascent') >= 0) {
			return 'Rayquaza-Mega';
		} else {
			return false;
		}
	},
	runMegaEvo: function (pokemon) {
		if (pokemon.template.isMega || pokemon.template.isPrimal) return false;
		let template = this.getMixedTemplate(pokemon.originalSpecies, pokemon.canMegaEvo);
		let side = pokemon.side;

		// Pokémon affected by Sky Drop cannot mega evolve. Enforce it here for now.
		let foeActive = side.foe.active;
		for (let i = 0; i < foeActive.length; i++) {
			if (foeActive[i].volatiles['skydrop'] && foeActive[i].volatiles['skydrop'].source === pokemon) {
				return false;
			}
		}

		pokemon.formeChange(template);
		pokemon.baseTemplate = template; // mega evolution is permanent

		// Do we have a proper sprite for it?
		if (this.getTemplate(pokemon.canMegaEvo).baseSpecies === pokemon.originalSpecies) {
			pokemon.details = template.species + (pokemon.level === 100 ? '' : ', L' + pokemon.level) + (pokemon.gender === '' ? '' : ', ' + pokemon.gender) + (pokemon.set.shiny ? ', shiny' : '');
			this.add('detailschange', pokemon, pokemon.details);
			this.add('-mega', pokemon, template.baseSpecies, template.requiredItem);
		} else {
			let oTemplate = this.getTemplate(pokemon.originalSpecies);
			let oMegaTemplate = this.getTemplate(template.originalMega);
			if (template.originalMega === 'Rayquaza-Mega') {
				this.add('message', "" + pokemon.side.name + "'s fervent wish has reached " + pokemon.name + "!");
			} else {
				this.add('message', "" + pokemon.name + "'s " + pokemon.getItem().name + " is reacting to " + pokemon.side.name + "'s Mega Bracelet!");
			}
			this.add('-formechange', pokemon, oTemplate.species, template.requiredItem);
			this.add('message', pokemon.name + " has Mega Evolved into Mega " + template.baseSpecies + "!");
			this.add('-start', pokemon, oMegaTemplate.requiredItem || oMegaTemplate.requiredMove, '[silent]');
			if (oTemplate.types.length !== pokemon.template.types.length || oTemplate.types[1] !== pokemon.template.types[1]) {
				this.add('-start', pokemon, 'typechange', pokemon.template.types.join('/'), '[silent]');
			}
		}

		pokemon.setAbility(template.abilities['0']);
		pokemon.baseAbility = pokemon.ability;
		pokemon.canMegaEvo = false;
		return true;
	},
	doGetMixedTemplate: function (template, deltas) {
		if (!deltas) throw new TypeError("Must specify deltas!");
		if (!template || typeof template === 'string') template = this.getTemplate(template);
		template = Object.assign({}, template); // shallow is enough
		template.abilities = {'0': deltas.ability};
		if (template.types[0] === deltas.type) template.types = [deltas.type];
		else if (deltas.type) template.types = [template.types[0], deltas.type];
		let baseStats = template.baseStats;
		template.baseStats = {};
		for (let statName in baseStats) template.baseStats[statName] = this.clampIntRange(baseStats[statName] + deltas.baseStats[statName], 1, 255);
		template.weightkg = Math.max(0.1, template.weightkg + deltas.weightkg);
		template.originalMega = deltas.originalMega;
		template.requiredItem = deltas.requiredItem;
		if (deltas.isMega) template.isMega = true;
		if (deltas.isPrimal) template.isPrimal = true;
		return template;
	},
	getMixedTemplate: function (originalSpecies, megaSpecies) {
		let originalTemplate = this.getTemplate(originalSpecies);
		let megaTemplate = this.getTemplate(megaSpecies);
		if (originalTemplate.baseSpecies === megaTemplate.baseSpecies) return megaTemplate;
		let deltas = this.getMegaDeltas(megaTemplate);
		let template = this.doGetMixedTemplate(originalTemplate, deltas);
		return template;
	},
	getMegaDeltas: function (megaTemplate) {
		let baseTemplate = this.getTemplate(megaTemplate.baseSpecies);
		let deltas = {
			ability: megaTemplate.abilities['0'],
			baseStats: {},
			weightkg: megaTemplate.weightkg - baseTemplate.weightkg,
			originalMega: megaTemplate.species,
			requiredItem: megaTemplate.requiredItem,
		};
		for (let statId in megaTemplate.baseStats) deltas.baseStats[statId] = megaTemplate.baseStats[statId] - baseTemplate.baseStats[statId];
		if (megaTemplate.types.length > baseTemplate.types.length) {
			deltas.type = megaTemplate.types[1];
		} else if (megaTemplate.types.length < baseTemplate.types.length) {
			deltas.type = baseTemplate.types[0];
		} else if (megaTemplate.types[1] !== baseTemplate.types[1]) {
			deltas.type = megaTemplate.types[1];
		}
		if (megaTemplate.isMega) deltas.isMega = true;
		if (megaTemplate.isPrimal) deltas.isPrimal = true;
		return deltas;
	},
};
 
This is the list of OMs that I'm currently running on rom.psim.us:
  • 0v0
  • AbNormal
  • Ability Unity
  • Accessorize
  • Acid Rain
  • Alphabet Cup
  • Alphability
  • Atk-Def Equality
  • Averagemons
  • Balanced Hackmons Plus
  • BasePowerMons
  • Burning 'Mon
  • Camomons
  • Cross Evolution
  • Custom Power
  • Enchanted Items
  • Field Control
  • Follow the Leader
  • Genmons
  • Gods and Followers
  • Got Talent?
  • Head Start
  • Immunimons
  • Inaccuratemons
  • Inheritance
  • Inverse Battle
  • Itemize
  • Mediocremons
  • Megamons
  • Mix and Mega
  • Monogen
  • Monotype
  • Move Pass LC
  • Multitype Mansion
  • NOSTABmons
  • Nature's Blessing
  • Noobmons
  • Pacifistmons
  • Pikachu Cup
  • Powered Up
  • Priority Cup
  • Protean Palace
  • Protect: The Metagame
  • Reliablemons
  • Return'd
  • Setupmons
  • Sketchmons
  • SlowMons
  • Stat Switch
  • Suicide Cup
  • Super-Effectivemons
  • The Power Within
  • Tiermons
  • Tormenting Spirits
  • Type Control
  • Type Reflectors
Anyone want code for any of them?
Could you share the Passive Aggressive and 0v0 ones please? Thanks in advance
 
Could you share the Passive Aggressive and 0v0 ones please? Thanks in advance
I can't remember whether Passive Aggressive works correctly, I should check. Also, 0v0 requires a tweak to battle-engine.js to stop it getting confused, are you OK with that?
 
Yeah, no problem ^_^
Code:
		if (format.onBegin) {
			format.onBegin.call(this);
			if (this.ended) return; // fix for 0v0
		}
Code:
	{
		name: "0v0",

		team: 'random', // Just so a team can be generated so the "battle" can occur
		ruleset: [],
		onBegin: function () {
			this.p1.team = this.p2.team = [];
			this.p1.pokemon = this.p2.pokemon = [];
			this.p1.pokemonLeft = this.p2.pokemonLeft = 0;
			let p = 'p' + (this.random(2) + 1);
			this.win(this[p]);
		},
	},
 
Code:
 if (format.onBegin) {
format.onBegin.call(this);
if (this.ended) return; // fix for 0v0
}
Code:
 {
name: "0v0",

team: 'random', // Just so a team can be generated so the "battle" can occur
ruleset: [],
onBegin: function () {
this.p1.team = this.p2.team = [];
this.p1.pokemon = this.p2.pokemon = [];
this.p1.pokemonLeft = this.p2.pokemonLeft = 0;
let p = 'p' + (this.random(2) + 1);
this.win(this[p]);
},
},
Doesn't work. Causes players to disconnect from each other (even though they are still in battle). Is something amiss or I'm doing something wrong (by placing this fix in Battle.prototype.start)?
 
Doesn't work. Causes players to disconnect from each other (even though they are still in battle). Is something amiss or I'm doing something wrong (by placing this fix in Battle.prototype.start)?
Well, try it with your original battle-engine.js first, just to see where the problem lies. The format should still work, except that it generates some undesirable error messages. Also, here's some code for Passive Aggressive which seems to work:
Code:
	{
		name: "Passive Aggressive",
		desc: [
			"Type effectiveness applies to passive damage.",
			"&bullet; <a href=\"https://www.smogon.com/forums/threads/3576924/\">Passive Aggressive</a>",
		],

		ruleset: ['OU'],
		onDamage: function (damage, target, source, effect) {
			let type;
			switch (effect.id) {
			default:
				return;
			case 'blacksludge':
				type = 'Poison';
				damage = target.maxhp / 8;
				break;
			case 'curse':
			case 'nightmare':
				type = 'Ghost';
				damage = target.maxhp / 4;
				break;
			case 'leechseed':
			case 'spikyshield':
				type = 'Grass';
				damage = target.maxhp / 8;
				break;
			case 'spikes':
				type = 'Ground';
				damage = target.maxhp / 2 / (5 - target.side.sideConditions.spikes.layers);
				break;
			case 'brn':
				type = 'Fire';
				damage = target.maxhp / 8;
				break;
			case 'psn':
				type = 'Poison';
				damage = target.maxhp / 8;
				break;
			case 'tox':
				return this.clampIntRange(target.maxhp >> 4 - this.getEffectiveness('Poison', target), 1) * target.statusData.stage;
			case 'partiallytrapped':
				let effectData = target.volatiles.partiallytrapped;
				damage = target.maxhp / (effectData.source.hasItem('bindingband') ? 6 : 8);
				type = effectData.sourceEffect;
				break;
			case 'sandstorm':
				type = 'Rock';
				damage = target.maxhp / 16;
				break;
			case 'hail':
				type = 'Ice';
				damage = target.maxhp / 16;
				break;
			case 'recoil':
				type = this.activeMove;
				break;
			}
			return damage * Math.pow(2, this.getEffectiveness(type, target));
		},
	},
 
Last edited:
As requested in PM:
Code:
	{
		name: "Gifts of the Gods",
		desc: [
			"Each Pok&eacute;mon receives one base stat from your God depending on its position in your team.",
			"&bullet; <a href=\"https://www.smogon.com/forums/threads/3579610/\">Gifts of the Gods</a>",
		],
		section: "Other Metagames",

		ruleset: ['Ubers', 'Baton Pass Clause'],
		banlist: ['Huge Power', 'Pure Power', 'Blissey', 'Chansey', 'Mega Mawile', 'Mega Medicham', 'Eviolite', 'Uber > 1', 'AG ++ Uber'],
		onBegin: function() {
			let stats = ['hp', 'atk', 'def', 'spa', 'spd', 'spe'];
			for (let j = 0; j < this.sides.length; j++) {
				// onBegin happens before Mega Rayquaza clause
				let uber = this.sides[j].pokemon.find(pokemon => ['AG', 'Uber'].includes(this.getTemplate(pokemon.canMegaEvo || pokemon.baseTemplate).tier)) || this.sides[j].pokemon[0];
				for (let i = 0, len = this.sides[j].pokemon.length; i < len; i++) {
					let pokemon = this.sides[j].pokemon[i];
					["baseTemplate", "canMegaEvo"].forEach(key => {
						if (pokemon[key]) {
							let template = Object.assign({}, this.getTemplate(pokemon[key]));
							template.baseStats = Object.assign({}, template.baseStats);
							template.baseStats[stats[i]] = uber.baseTemplate.baseStats[stats[i]];
							pokemon[key] = template;
						}
					});
					pokemon.formeChange(pokemon.baseTemplate);
					if (i === 0 && !pokemon.template.maxHP) pokemon.hp = pokemon.maxhp = Math.floor(Math.floor(2 * pokemon.template.baseStats['hp'] + pokemon.set.ivs['hp'] + Math.floor(pokemon.set.evs['hp'] / 4) + 100) * pokemon.level / 100 + 10);
				}
			}
		},
	},
The AG ++ Uber is needed to stop people sneaking Rayquaza with Dragon Ascent into their team (except as their God). Only handles Mega Evolutions, not other forme changes.
 
Well, try it with your original battle-engine.js first, just to see where the problem lies. The format should still work, except that it generates some undesirable error messages. Also, here's some code for Passive Aggressive which seems to work:
Code:
 {
name: "Passive Aggressive",
desc: [
"Type effectiveness applies to passive damage.",
"&bullet; <a href=\"https://www.smogon.com/forums/threads/3576924/\">Passive Aggressive</a>",
],

ruleset: ['OU'],
onDamage: function (damage, target, source, effect) {
let type;
switch (effect.id) {
default:
return;
case 'blacksludge':
type = 'Poison';
damage = target.maxhp / 8;
break;
case 'curse':
case 'nightmare':
type = 'Ghost';
damage = target.maxhp / 4;
break;
case 'leechseed':
case 'spikyshield':
type = 'Grass';
damage = target.maxhp / 8;
break;
case 'spikes':
type = 'Ground';
damage = target.maxhp / 2 / (5 - target.side.sideConditions.spikes.layers);
break;
case 'brn':
type = 'Fire';
damage = target.maxhp / 8;
break;
case 'psn':
type = 'Poison';
damage = target.maxhp / 8;
break;
case 'tox':
return this.clampIntRange(target.maxhp >> 4 - this.getEffectiveness('Poison', target), 1) * target.statusData.stage;
case 'partiallytrapped':
let effectData = target.volatiles.partiallytrapped;
damage = target.maxhp / (effectData.source.hasItem('bindingband') ? 6 : 8);
type = effectData.sourceEffect;
break;
case 'sandstorm':
type = 'Rock';
damage = target.maxhp / 16;
break;
case 'hail':
type = 'Ice';
damage = target.maxhp / 16;
break;
case 'recoil':
type = this.activeMove;
break;
}
return damage * Math.pow(2, this.getEffectiveness(type, target));
},
},
Nothing for now. Guess I should just dig into the code to find where the problem is.
Anyway, thanks a lot for Passive Aggressive! Works as intended!
 

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

Top