Skip to content

Instantly share code, notes, and snippets.

@Spandamn
Last active January 29, 2017 06:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Spandamn/a72bcaddab942a06e52b138a42f24ecf to your computer and use it in GitHub Desktop.
Save Spandamn/a72bcaddab942a06e52b138a42f24ecf to your computer and use it in GitHub Desktop.
Lockdown Code updated for Gen 7. Credits to AWailOfATail and me (If you notice any bugs, please lmk)
/****************************************
config/formats.js
****************************************/
{
name: "[Gen 7] Lockdown",
desc: [
"&bullet; <a href=\"http://www.smogon.com/forums/threads/3593815\">Lockdown</a>",
"At the end of Turn 6, battlefield changes become permanent.",
],
section: "New Other Metagames",
mod: 'lockdown',
ruleset: ['[Gen 7] OU'],
banlist: ['Damp Rock', 'Heat Rock', 'Smooth Rock', 'Icy Rock', 'Terrain Extender'],
unbanlist: ['Genesect'],
onBegin: function() {
this.lockdownMoves = ['sunnyday', 'raindance', 'hail', 'sandstorm', 'magicroom', 'wonderroom', 'trickroom', 'gravity', 'electricterrain', 'mistyterrain', 'grassyterrain', 'psychicterrain', 'mudsport', 'watersport'];
this.lockdownHazards = ['stealthrock', 'spikes', 'toxicspikes', 'stickyweb'];
},
onTryHitSide: function(target, source, move) {
if (this.lockdownHazards.indexOf(move.id) > -1 && this.turn > 6) return false;
},
onTryHitField: function(target, source, move) {
if (this.lockdownMoves.indexOf(move.id) > -1 && this.turn > 6) return false;
},
onResidualOrder: 999,
onResidual: function () {
if(this.turn !== 6) return;
let pseudo = ['magicroom', 'wonderroom', 'trickroom', 'gravity', 'mudsport', 'watersport'];
this.add("-message", "The Lockdown has commenced! Battlefield changes are now permanent!");
if(this.weatherData.duration) this.weatherData.duration = 0;
if(this.terrainData.duration) this.terrainData.duration = 0;
for(let i in this.pseudoWeather) {
if(pseudo.includes(i)) {
this.pseudoWeather[i].duration = 0;
}
}
},
},
/****************************************
mods/lockdown/scripts.js
****************************************/
"use strict";
exports.BattleScripts = {
removeSideCondition: function(status) {
status = this.battle.getEffect(status);
if (!this.sideConditions[status.id]) return false;
if(this.turn > 6 && this.lockdownHazards.includes(status.id)) return false;
this.battle.singleEvent('End', status, this.sideConditions[status.id], this);
delete this.sideConditions[status.id];
return true;
},
setTerrain(status, source, sourceEffect) {
status = this.getEffect(status);
if(this.lockdownMoves.includes(status.id) && this.turn > 6) return false;
if (sourceEffect === undefined && this.effect) sourceEffect = this.effect;
if (source === undefined && this.event && this.event.target) source = this.event.target;
if (this.terrain === status.id) return false;
if (this.terrain && !status.id) {
let oldstatus = this.getTerrain();
this.singleEvent('End', oldstatus, this.terrainData, this);
}
let prevTerrain = this.terrain;
let prevTerrainData = this.terrainData;
this.terrain = status.id;
this.terrainData = {id: status.id};
if (source) {
this.terrainData.source = source;
this.terrainData.sourcePosition = source.position;
}
if (status.duration) {
this.terrainData.duration = status.duration;
}
if (status.durationCallback) {
this.terrainData.duration = status.durationCallback.call(this, source, sourceEffect);
}
if (!this.singleEvent('Start', status, this.terrainData, this, source, sourceEffect)) {
this.terrain = prevTerrain;
this.terrainData = prevTerrainData;
return false;
}
return true;
},
setWeather(status, source, sourceEffect) {
status = this.getEffect(status);
if(this.lockdownMoves.includes(status.id) && this.turn > 6) return false;
if (sourceEffect === undefined && this.effect) sourceEffect = this.effect;
if (source === undefined && this.event && this.event.target) source = this.event.target;
if (this.weather === status.id) {
if (sourceEffect && sourceEffect.effectType === 'Ability') {
if (this.gen > 5 || this.weatherData.duration === 0) {
return false;
}
} else if (this.gen > 2 || status.id === 'sandstorm') {
return false;
}
}
if (status.id) {
let result = this.runEvent('SetWeather', source, source, status);
if (!result) {
if (result === false) {
if (sourceEffect && sourceEffect.weather) {
this.add('-fail', source, sourceEffect, '[from]: ' + this.weather);
} else if (sourceEffect && sourceEffect.effectType === 'Ability') {
this.add('-ability', source, sourceEffect, '[from] ' + this.weather, '[fail]');
}
}
return null;
}
}
if (this.weather && !status.id) {
let oldstatus = this.getWeather();
this.singleEvent('End', oldstatus, this.weatherData, this);
}
let prevWeather = this.weather;
let prevWeatherData = this.weatherData;
this.weather = status.id;
this.weatherData = {id: status.id};
if (source) {
this.weatherData.source = source;
this.weatherData.sourcePosition = source.position;
}
if (status.duration) {
this.weatherData.duration = status.duration;
}
if (status.durationCallback) {
this.weatherData.duration = status.durationCallback.call(this, source, sourceEffect);
}
if (!this.singleEvent('Start', status, this.weatherData, this, source, sourceEffect)) {
this.weather = prevWeather;
this.weatherData = prevWeatherData;
return false;
}
return true;
},
};
@Spandamn
Copy link
Author

Updated code with a shorter one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment