Advertisement
Pikachuun

skill cup coad

Jul 26th, 2015
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. config/formats.js
  2. ==================================================================
  3.     {
  4.         //★TylerTheDestroyer: this entire game is an easter egg. you try to open it up and hope for something good inside but instead you die.
  5.         name: "Skill Cup",
  6.         desc: ["Skill Cup is a metagame determined purely by each player's skill. Each team is generated using a skill-based algorithm, meaning counterteaming is not possible, and teams aren't required. In Skill Cup tournaments, scouting is allowed, as it takes real skill to be able to deal with such a scenario."],
  7.         section: "Choon-Approved Metagames",
  8.  
  9.         team: 'randomHC', //Team WIP
  10.         mod: 'skills',
  11.         ruleset: ['HP Percentage Mod', 'Cancel Mod'],
  12.         onBegin: function () {
  13.             this.add('message', "WELCOME TO SKILL CUP, WHERE ONLY THOSE WITH SKILLFUL AMOUNTS OF SKILL CAN WIN THE SKILLFUL MEDALLION OF SKILL");
  14.             this.add('message', "YOUR BODY IS NOT READY FOR THIS AMOUNT OF SKILL");
  15.             var allPokemon = this.p1.pokemon.concat(this.p2.pokemon);
  16.             for (var i = 0, len = allPokemon.length; i < len; i++) {
  17.                 var ms = allPokemon[i].moveset;
  18.                 for (var j in ms) {
  19.                     ms[j].maxpp = NaN;
  20.                     ms[j].pp = 1;
  21.                 }
  22.             }
  23.         },
  24.         onModifyPokemon: function (pokemon) {
  25.             for (var q in pokemon.side.pokemon) {
  26.                 var p = pokemon.side.pokemon[q];
  27.                 for (var i in p.baseStats) {
  28.                     p.baseStats[i] = p.stats[i] = Math.floor(Math.floor((this.random(32) + 2*this.random(256) + this.random(64) + 100) * p.level/100 + 5)*(.9 + this.random(3)*.1));
  29.                 }
  30.                 var hprat = p.hp/p.maxhp;
  31.                 p.maxhp = Math.floor((this.random(32) + 2 * this.random(256) + this.random(64) + 100) * p.level/100 + 10);
  32.                 p.hp = Math.round(hprat * p.maxhp);
  33.                 if (!p.hp && hprat) p.hp = 1;
  34.                 var typeNum = this.random(10);
  35.                 var typeMat = Object.keys(Tools.data.TypeChart);
  36.                 var type0 = (typeNum > 0) ? typeMat[this.random(18)] : 'Skillful';
  37.                 var type1 = (typeNum > 4) ? typeMat[this.random(18)] : 'Skillful';
  38.                 p.types = [type0, type1];
  39.                 p.typesData = [
  40.                     {type: type0, suppressed: false,  isAdded: false},
  41.                     {type: type1, suppressed: false,  isAdded: false}
  42.                 ];
  43.                
  44.                 //items, abilities, moves, and natures !_!
  45.                 var itemPool = [''];
  46.                 var j = 1;
  47.                 for (var i in this.data.Items) {
  48.                     itemPool[j] = i;
  49.                     j++;
  50.                 }
  51.                 p.item = itemPool[this.random(itemPool.length)];
  52.                 var abilityPool = [];
  53.                 j = 0;
  54.                 for (var i in this.data.Abilities) {
  55.                     abilityPool[j] = i;
  56.                     j++;
  57.                 }
  58.                 p.ability = abilityPool[this.random(abilityPool.length)];
  59.                 //Skillful moves are done in onResidual
  60.             }
  61.         },
  62.         onModifyPriority: function (priority) {
  63.             return (7 - this.random(15));
  64.         },
  65.         onModifyMove: function (move, pokemon) {
  66.             //Easter egg
  67.             if (!this.random(65536)) move.name = ['o3o', '.3.', 'Skillful Move Name', 'Easter Egg', '42', 'LET IT BE KNOWN BY ALL THAT IMAS IS A HUGE FRICKIN NERD'];
  68.            
  69.             //Accuracy
  70.             move.accuracy = (this.random(5)) ? 70 + this.random(31) : true;
  71.            
  72.             var cate = this.random(5);
  73.            
  74.             //Base Power
  75.             move.basePower = cate === 4 ? 0 : this.random(256);
  76.             delete move.basePowerCallback;
  77.            
  78.             //Category
  79.             move.category = ['Physical', 'Special', 'Physical', 'Special', 'Status'][cate];
  80.            
  81.             //Status/Volatile Status
  82.             delete move.status;
  83.             delete move.volatileStatus;
  84.             if (!move.self) {
  85.                 move.self = {};
  86.             } else {
  87.                 if (move.self.volatileStatus) delete move.self.volatileStatus;
  88.                 if (move.self.status) delete move.self.status;
  89.             }
  90.             var octagon = this.random(64);
  91.             var statusMat = ['tox', 'psn', 'brn', 'frz', 'par', 'slp'];
  92.             var volStatusMat = ['confusion', 'flinch', 'mustrecharge', 'partiallytrapped', 'trapped', 'aquaring', 'attract', 'autotomize', 'bide', 'charge', 'curse', 'DefenseCurl', 'destinybond', 'disable', 'electrify', 'encore', 'endure', 'focusenergy', 'followme', 'foresight', 'gastroacid', 'grudge', 'healblock', 'helpinghand', 'imprison', 'ingrain', 'kingsshield', 'leechseed', 'magiccoat', 'magnetrise', 'matblock', 'minimize', 'miracleeye', 'nightmare', 'powder', 'powertrick', 'protect', 'rage', 'ragepowder', 'roost', 'smackdown', 'snatch', 'spikyshield', 'stockpile', 'Substitute', 'taunt', 'telekinesis', 'torment', 'uproar', 'yawn'];
  93.             if (!octagon || move.id === 'metronome') {
  94.                 move.status = statusMat[this.random(statusMat.length)];
  95.                 move.volatileStatus = volStatusMat[this.random(volStatusMat.length)];
  96.             } else if (octagon > 0 && octagon < 8) {
  97.                 move.status = statusMat[this.random(statusMat.length)];
  98.             } else if (octagon > 7 && octagon < 15) {
  99.                 move.volatileStatus = volStatusMat[this.random(volStatusMat.length)];
  100.             }
  101.             octagon = this.random(64);
  102.             if (!octagon || move.id === 'metronome') {
  103.                 move.self.status = statusMat[this.random(statusMat.length)];
  104.                 move.self.volatileStatus = volStatusMat[this.random(volStatusMat.length)];
  105.             } else if (octagon > 0 && octagon < 8) {
  106.                 move.self.status = statusMat[this.random(statusMat.length)];
  107.             } else if (octagon > 7 && octagon < 15) {
  108.                 move.self.volatileStatus = volStatusMat[this.random(volStatusMat.length)];
  109.             }
  110.            
  111.             //Secondaries
  112.             delete move.secondary;
  113.             delete move.secondaries;
  114.             var coinFlip = 0;
  115.             var otherCoinFlip = 0;
  116.             var chance = 0;
  117.             var fake = false;
  118.             move.secondaries = [];
  119.             while (!fake) {
  120.                 coinFlip = this.random(4);
  121.                 if (!coinFlip) {
  122.                     chance = this.random(101);
  123.                     move.secondaries[move.secondaries.length] = {chance: chance, status: statusMat[this.random(statusMat.length)]};
  124.                 } else if (coinFlip === 1) {
  125.                     chance = this.random(101);
  126.                     move.secondaries[move.secondaries.length] = {chance: chance, volatileStatus: volStatusMat[this.random(volStatusMat.length)]};
  127.                 } else if (coinFlip === 2) {
  128.                     chance = this.random(101);
  129.                     move.secondaries[move.secondaries.length] = {chance: chance, self: {status: statusMat[this.random(statusMat.length)]}};
  130.                 } else {
  131.                     chance = this.random(101);
  132.                     move.secondaries[move.secondaries.length] = {chance: chance, self: {volatileStatus: volStatusMat[this.random(volStatusMat.length)]}};
  133.                 }
  134.                 otherCoinFlip = this.random(2);
  135.                 fake = !!otherCoinFlip;
  136.             }
  137.            
  138.             //Boosts
  139.             delete move.boosts;
  140.             if (move.self) delete move.self.boosts;
  141.             var soMuchCoin = (!this.random(10)) ? this.random(4) : -1;
  142.             if (!soMuchCoin || move.id === 'metronome') {
  143.                 move.boosts = {};
  144.                 if (!move.self) move.self = {boosts: {}};
  145.                 else move.self.boosts = {};
  146.                 var statArr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
  147.                 var statSum = 0;
  148.                 for (var s in statArr) {
  149.                     if (!this.random(statSum + 2)) {
  150.                         statArr[s] = 3 - this.random(7);
  151.                         statSum += statArr[s]
  152.                     }
  153.                 }
  154.                 move.boosts = {atk: statArr[0], def: statArr[1], spa: statArr[2], spd: statArr[3], spe: statArr[4], accuracy: statArr[5], evasion: statArr[6]};
  155.                 move.self.boosts = {atk: statArr[7], def: statArr[8], spa: statArr[9], spd: statArr[10], spe: statArr[11], accuracy: statArr[12], evasion: statArr[13]};
  156.             } else if (soMuchCoin === 1) {
  157.                 move.boosts = {};
  158.                 var statArr = [0, 0, 0, 0, 0, 0, 0];
  159.                 var statSum = 0;
  160.                 for (var s in statArr) {
  161.                     if (!this.random(statSum + 2)) {
  162.                         statArr[s] = 3 - this.random(7);
  163.                         statSum += statArr[s]
  164.                     }
  165.                 }
  166.                 move.boosts = {atk: statArr[0], def: statArr[1], spa: statArr[2], spd: statArr[3], spe: statArr[4], accuracy: statArr[5], evasion: statArr[6]};
  167.             } else if (soMuchCoin === 2) {
  168.                 if (!move.self) move.self = {boosts: {}};
  169.                 else move.self.boosts = {};
  170.                 var statArr = [0, 0, 0, 0, 0, 0, 0];
  171.                 var statSum = 0;
  172.                 for (var s in statArr) {
  173.                     if (!this.random(statSum + 2)) {
  174.                         statArr[s] = 3 - this.random(7);
  175.                         statSum += statArr[s]
  176.                     }
  177.                 }
  178.                 move.self.boosts = {atk: statArr[0], def: statArr[1], spa: statArr[2], spd: statArr[3], spe: statArr[4], accuracy: statArr[5], evasion: statArr[6]};
  179.             }
  180.            
  181.             //Target
  182.             if (move.category === 'Status') move.target = ['normal', 'self', 'self', 'self'][this.random(4)];
  183.             else move.target = ['normal', 'normal', 'normal', 'self'][this.random(4)];
  184.            
  185.             //Type
  186.             move.type = (this.random(19) !== 18) ? Object.keys(Tools.data.TypeChart)[this.random(18)] : 'Skillful';
  187.            
  188.             //Recoil
  189.             delete move.recoil;
  190.             if (!this.random(10) || move.id === 'metronome') move.recoil = [this.random(100), (this.random(100) + 1)];
  191.            
  192.             //OHKO
  193.             move.ohko = (!this.random(100)) ? true : false;
  194.            
  195.             //Multihit
  196.             delete move.multihit;
  197.             if (!this.random(25) || move.id === 'metronome') {
  198.                 var hit1 = this.random(7) + 1;
  199.                 var hit2 = 0;
  200.                 while (hit2 < hit1) hit2 = this.random(15) + 1;
  201.                 move.multihit = [hit1, hit2];
  202.             }
  203.            
  204.             //Side Conditions
  205.             delete move.sideCondition;
  206.             if (!this.random(10) || move.id === 'metronome') move.sideCondition = ['craftyshield', 'healingwish', 'lightscreen', 'luckychant', 'lunardance', 'mist', 'quickguard', 'reflect', 'safeguard', 'spikes', 'stealthrock', 'tailwind', 'toxicspikes', 'wideguard', 'Wish'][this.random(16)];
  207.            
  208.             //Switching
  209.             move.forceSwitch = (!this.random(33)) ? true : false;
  210.             move.selfSwitch = (!this.random(33)) ? true : false;
  211.            
  212.             //misc
  213.             delete move.heal;
  214.             if (!this.random(20)) move.heal = [this.random(100), (this.random(100) + 1)];
  215.             delete move.drain;
  216.             if (!this.random(10) || move.id === 'metronome') move.drain = [this.random(100), (this.random(100) + 1)];
  217.             move.flags = {authentic: !this.random(10), bite: !this.random(10), bullet: !this.random(10), charge: !this.random(10), contact: this.random(2), defrost: !this.random(5), distance: this.random(2), gravity: !this.random(5), heal: !this.random(10), mirror: !this.random(2), nonsky: !this.random(5), powder: !this.random(10), protect: !!this.random(10), pulse: !this.random(10), punch: !this.random(10), recharge: !this.random(10), reflectable: !this.random(10), snatch: !this.random(3), sound: !this.random(10)};
  218.             delete move.selfdestruct;
  219.             if (!this.random(100)) move.selfdestruct = true;
  220.             move.breakProtect = (!this.random(20)) ? true : false;
  221.             delete move.onHit;
  222.             delete move.onTryHit;
  223.             delete move.onPrepareHit;
  224.             delete move.onBeforeHit;
  225.             delete move.onModifyMove;
  226.             delete move.onTry;
  227.             delete move.weather;
  228.             delete move.pseudoWeather;
  229.         },
  230.         onResidual: function (battle) {
  231.             for (var s in battle.sides) {
  232.                 var thisSide = battle.sides[s];
  233.                 for (var n in thisSide.pokemon) {
  234.                     var p = thisSide.pokemon[n];
  235.  
  236.                     var movePool = [];
  237.                     var moves = [];
  238.                     var moveset = [];
  239.                     j = 0;
  240.                     for (var i in this.data.Movedex) {
  241.                         movePool[j] = i;
  242.                         j++;
  243.                     }
  244.                     for (var k = 0; k < 4; k++) {
  245.                         moves[k] = movePool[this.random(movePool.length)];
  246.                         moveset[k] = {move: this.getMove(moves[k]).name, id: moves[k], maxpp: NaN, pp: 1, target: this.getMove(moves[k]).target, disabled: !this.random(50), used: !this.random(2)}
  247.                     }
  248.                     p.moves = moves;
  249.                     p.moveset = moveset;
  250.                 }
  251.             }
  252.             var f = this.random(9);
  253.             if (!f) {
  254.                 var w = this.random(7);
  255.                 var weather = ['sunnyday', 'raindance', 'sandstorm', 'hail',  'desolateland', 'primordialsea', 'deltastream'][w];
  256.                 if (this.effectiveWeather() === weather) {
  257.                     this.clearWeather();
  258.                 } else {
  259.                     this.setWeather(weather);
  260.                 }
  261.             } else if (f === 1) {
  262.                 var pw = this.random(9);
  263.                 var pseudoWeather = ['echoedvoice', 'fairylock', 'gravity', 'iondeluge', 'magicroom', 'mudsport', 'trickroom', 'watersport', 'wonderroom'][pw];
  264.                 if (this.pseudoWeather[pseudoWeather]) {
  265.                     this.removePseudoWeather(pseudoWeather);
  266.                 } else {
  267.                     if (!this.random(2)) {
  268.                         this.addPseudoWeather(pseudoWeather, this.p1.pokemon[0]);
  269.                     } else {
  270.                         this.addPseudoWeather(pseudoWeather, this.p2.pokemon[0]);
  271.                     }
  272.                 }
  273.             } else if (f === 2) {
  274.                 var t = this.random(3);
  275.                 var terrain = ['electricterrain', 'grassyterrain', 'mistyterrain'][t];
  276.                 if (this.isTerrain(terrain)) {
  277.                     this.setTerrain('');
  278.                 } else {
  279.                     this.setTerrain(terrain);
  280.                 }
  281.             }
  282.         }
  283.     },
  284. ==================================================================
  285.  
  286. mods/skills/statuses.js
  287. ==================================================================
  288. exports.BattleStatuses = {
  289.     brn: {
  290.         inherit: true,
  291.         onResidual: function (pokemon) {
  292.             var h = this.random(4);
  293.             if (h) {
  294.                 this.damage(pokemon.maxhp / ((this.random(8) + 1)*(this.random(8) + 1)));
  295.             } else {
  296.                 this.heal(pokemon.maxhp / ((this.random(8) + 1)*(this.random(8) + 1)));
  297.             }
  298.         },
  299.         onBeforeMove: function (pokemon) {
  300.             if (!this.random(16)) {
  301.                 pokemon.cureStatus();
  302.                 return;
  303.             }
  304.         }
  305.     },
  306.     par: {
  307.         inherit: true,
  308.         onModifySpe: function (speMod, pokemon) {
  309.             if (!(pokemon.hasAbility('quickfeet') || !this.random(4))) {
  310.                 return this.chain(speMod, this.random(4)/(this.random(16) + 1));
  311.             } else {
  312.                 return this.chain(speMod, this.random(16)/(this.random(4) + 1))
  313.             }
  314.         },
  315.         onBeforeMove: function (pokemon) {
  316.             if (!this.random(16)) {
  317.                 pokemon.cureStatus();
  318.                 return;
  319.             }
  320.             if (!this.random(this.random(this.random(16) + 1) + 1)) {
  321.                 this.add('cant', pokemon, 'par');
  322.                 return false;
  323.             } else if (!this.random(this.random(this.random(16) + 1) + 1)) {
  324.                 this.add('cant', pokemon, 'par');
  325.                 return false;
  326.             }
  327.         }
  328.     },
  329.     slp: {
  330.         inherit: true,
  331.         onStart: function (target) {
  332.             this.add('-status', target, 'slp');
  333.             // 1-3 turns
  334.             var mat = [this.random(4), this.random(8)];
  335.             this.effectData.startTime = (mat[0] > mat[1]) ? this.random(mat[1], mat[0]) : this.random(mat[0], mat[1]);
  336.             this.effectData.time = this.effectData.startTime;
  337.         },
  338.         onBeforeMove: function (pokemon, target, move) {
  339.             if (pokemon.hasAbility('earlybird') || !this.random(4)) {
  340.                 pokemon.statusData.time--;
  341.             }
  342.             pokemon.statusData.time--;
  343.             if (pokemon.statusData.time <= 0 || !this.random(16)) {
  344.                 pokemon.cureStatus();
  345.                 return;
  346.             }
  347.             this.add('cant', pokemon, 'slp');
  348.             if (move.sleepUsable) {
  349.                 return;
  350.             }
  351.             return false;
  352.         }
  353.     },
  354.     frz: {
  355.         inherit: true,
  356.         onBeforeMove: function (pokemon, target, move) {
  357.             if (move.flags['defrost']) return;
  358.             if (!this.random(5) || !this.random(16) || !this.random(11)) {
  359.                 pokemon.cureStatus();
  360.                 return;
  361.             }
  362.             this.add('cant', pokemon, 'frz');
  363.             return false;
  364.         }
  365.     },
  366.     psn: {
  367.         inherit: true,
  368.         onResidual: function (pokemon) {
  369.             var h = this.random(4);
  370.             if (h) {
  371.                 this.damage(pokemon.maxhp / ((this.random(8) + 1)*(this.random(8) + 1)));
  372.             } else {
  373.                 this.heal(pokemon.maxhp / ((this.random(8) + 1)*(this.random(8) + 1)));
  374.             }
  375.         },
  376.         onBeforeMove: function (pokemon) {
  377.             if (!this.random(16)) {
  378.                 pokemon.cureStatus();
  379.                 return;
  380.             }
  381.         }
  382.     },
  383.     tox: {
  384.         inherit: true,
  385.         onResidual: function (pokemon) {
  386.             this.effectData.stage++; //WE MUST GO FURTHER BEYOND
  387.             var h = this.random(4);
  388.             if (h) {
  389.                 this.damage(pokemon.maxhp * this.effectData.stage / ((this.random(16) + 1)*(this.random(16) + 1)));
  390.             } else {
  391.                 this.heal(pokemon.maxhp * this.effectData.stage / ((this.random(16) + 1)*(this.random(16) + 1)));
  392.             }
  393.         },
  394.         onBeforeMove: function (pokemon) {
  395.             if (!this.random(16)) {
  396.                 pokemon.cureStatus();
  397.                 return;
  398.             }
  399.         }
  400.     },
  401.     //Things I'll get to
  402.     /*confusion: {
  403.         // this is a volatile status
  404.         onStart: function (target, source, sourceEffect) {
  405.             var result = this.runEvent('TryConfusion', target, source, sourceEffect);
  406.             if (!result) return result;
  407.             if (sourceEffect && sourceEffect.id === 'lockedmove') {
  408.                 this.add('-start', target, 'confusion', '[fatigue]');
  409.             } else {
  410.                 this.add('-start', target, 'confusion');
  411.             }
  412.             this.effectData.time = this.random(2, 6);
  413.         },
  414.         onEnd: function (target) {
  415.             this.add('-end', target, 'confusion');
  416.         },
  417.         onBeforeMovePriority: 3,
  418.         onBeforeMove: function (pokemon) {
  419.             pokemon.volatiles.confusion.time--;
  420.             if (!pokemon.volatiles.confusion.time) {
  421.                 pokemon.removeVolatile('confusion');
  422.                 return;
  423.             }
  424.             this.add('-activate', pokemon, 'confusion');
  425.             if (this.random(2) === 0) {
  426.                 return;
  427.             }
  428.             this.damage(this.getDamage(pokemon, pokemon, 40), pokemon, pokemon, {
  429.                 id: 'confused',
  430.                 effectType: 'Move',
  431.                 type: '???'
  432.             });
  433.             return false;
  434.         }
  435.     },
  436.     flinch: {
  437.         duration: 1,
  438.         onBeforeMovePriority: 8,
  439.         onBeforeMove: function (pokemon) {
  440.             if (!this.runEvent('Flinch', pokemon)) {
  441.                 return;
  442.             }
  443.             this.add('cant', pokemon, 'flinch');
  444.             return false;
  445.         }
  446.     },
  447.     trapped: {
  448.         noCopy: true,
  449.         onModifyPokemon: function (pokemon) {
  450.             pokemon.tryTrap();
  451.         },
  452.         onStart: function (target) {
  453.             this.add('-activate', target, 'trapped');
  454.         }
  455.     },
  456.     trapper: {
  457.         noCopy: true
  458.     },
  459.     partiallytrapped: {
  460.         duration: 5,
  461.         durationCallback: function (target, source) {
  462.             if (source.hasItem('gripclaw')) return 8;
  463.             return this.random(5, 7);
  464.         },
  465.         onStart: function (pokemon, source) {
  466.             this.add('-activate', pokemon, 'move: ' + this.effectData.sourceEffect, '[of] ' + source);
  467.         },
  468.         onResidualOrder: 11,
  469.         onResidual: function (pokemon) {
  470.             if (this.effectData.source && (!this.effectData.source.isActive || this.effectData.source.hp <= 0)) {
  471.                 delete pokemon.volatiles['partiallytrapped'];
  472.                 return;
  473.             }
  474.             if (this.effectData.source.hasItem('bindingband')) {
  475.                 this.damage(pokemon.maxhp / 6);
  476.             } else {
  477.                 this.damage(pokemon.maxhp / 8);
  478.             }
  479.         },
  480.         onEnd: function (pokemon) {
  481.             this.add('-end', pokemon, this.effectData.sourceEffect, '[partiallytrapped]');
  482.         },
  483.         onModifyPokemon: function (pokemon) {
  484.             pokemon.tryTrap();
  485.         }
  486.     },
  487.     lockedmove: {
  488.         // Outrage, Thrash, Petal Dance...
  489.         duration: 2,
  490.         onResidual: function (target) {
  491.             if (target.status === 'slp') {
  492.                 // don't lock, and bypass confusion for calming
  493.                 delete target.volatiles['lockedmove'];
  494.             }
  495.             this.effectData.trueDuration--;
  496.         },
  497.         onStart: function (target, source, effect) {
  498.             this.effectData.trueDuration = this.random(2, 4);
  499.             this.effectData.move = effect.id;
  500.         },
  501.         onRestart: function () {
  502.             if (this.effectData.trueDuration >= 2) {
  503.                 this.effectData.duration = 2;
  504.             }
  505.         },
  506.         onEnd: function (target) {
  507.             if (this.effectData.trueDuration > 1) return;
  508.             target.addVolatile('confusion');
  509.         },
  510.         onLockMove: function (pokemon) {
  511.             return this.effectData.move;
  512.         }
  513.     },
  514.     twoturnmove: {
  515.         // Skull Bash, SolarBeam, Sky Drop...
  516.         duration: 2,
  517.         onStart: function (target, source, effect) {
  518.             this.effectData.move = effect.id;
  519.             // source and target are reversed since the event target is the
  520.             // pokemon using the two-turn move
  521.             this.effectData.targetLoc = this.getTargetLoc(source, target);
  522.             target.addVolatile(effect.id, source);
  523.         },
  524.         onEnd: function (target) {
  525.             target.removeVolatile(this.effectData.move);
  526.         },
  527.         onLockMove: function () {
  528.             return this.effectData.move;
  529.         },
  530.         onLockMoveTarget: function () {
  531.             return this.effectData.targetLoc;
  532.         }
  533.     },
  534.     choicelock: {
  535.         onStart: function (pokemon) {
  536.             if (!this.activeMove.id || this.activeMove.sourceEffect && this.activeMove.sourceEffect !== this.activeMove.id) return false;
  537.             this.effectData.move = this.activeMove.id;
  538.         },
  539.         onDisableMove: function (pokemon) {
  540.             if (!pokemon.getItem().isChoice || !pokemon.hasMove(this.effectData.move)) {
  541.                 pokemon.removeVolatile('choicelock');
  542.                 return;
  543.             }
  544.             if (pokemon.ignoringItem()) {
  545.                 return;
  546.             }
  547.             var moves = pokemon.moveset;
  548.             for (var i = 0; i < moves.length; i++) {
  549.                 if (moves[i].id !== this.effectData.move) {
  550.                     pokemon.disableMove(moves[i].id, false, this.effectData.sourceEffect);
  551.                 }
  552.             }
  553.         }
  554.     },
  555.     mustrecharge: {
  556.         duration: 2,
  557.         onBeforeMovePriority: 11,
  558.         onBeforeMove: function (pokemon) {
  559.             this.add('cant', pokemon, 'recharge');
  560.             pokemon.removeVolatile('mustrecharge');
  561.             return false;
  562.         },
  563.         onLockMove: function (pokemon) {
  564.             this.add('-mustrecharge', pokemon);
  565.             return 'recharge';
  566.         }
  567.     },
  568.     futuremove: {
  569.         // this is a side condition
  570.         onStart: function (side) {
  571.             this.effectData.positions = [];
  572.             for (var i = 0; i < side.active.length; i++) {
  573.                 this.effectData.positions[i] = null;
  574.             }
  575.         },
  576.         onResidualOrder: 3,
  577.         onResidual: function (side) {
  578.             var finished = true;
  579.             for (var i = 0; i < side.active.length; i++) {
  580.                 var posData = this.effectData.positions[i];
  581.                 if (!posData) continue;
  582.  
  583.                 posData.duration--;
  584.  
  585.                 if (posData.duration > 0) {
  586.                     finished = false;
  587.                     continue;
  588.                 }
  589.  
  590.                 // time's up; time to hit! :D
  591.                 var target = side.foe.active[posData.targetPosition];
  592.                 var move = this.getMove(posData.move);
  593.                 if (target.fainted) {
  594.                     this.add('-hint', '' + move.name + ' did not hit because the target is fainted.');
  595.                     this.effectData.positions[i] = null;
  596.                     continue;
  597.                 }
  598.  
  599.                 this.add('-end', target, 'move: ' + move.name);
  600.                 target.removeVolatile('Protect');
  601.                 target.removeVolatile('Endure');
  602.  
  603.                 if (posData.moveData.ignoreImmunity === undefined) {
  604.                     posData.moveData.ignoreImmunity = false;
  605.                 }
  606.  
  607.                 if (target.hasAbility('wonderguard') && this.gen > 5) {
  608.                     this.debug('Wonder Guard immunity: ' + move.id);
  609.                     if (target.runEffectiveness(move) <= 0) {
  610.                         this.add('-activate', target, 'ability: Wonder Guard');
  611.                         this.effectData.positions[i] = null;
  612.                         return null;
  613.                     }
  614.                 }
  615.  
  616.                 // Prior to gen 5, these moves had no STAB and no effectiveness.
  617.                 // This is done here and to moveData's type for two reasons:
  618.                 // - modifyMove event happens before the moveHit function is run.
  619.                 // - moveData here is different from move, as one is generated here and the other by the move itself.
  620.                 // So here we centralise any future hit move getting typeless on hit as it should be.
  621.                 if (this.gen < 5) {
  622.                     posData.moveData.type = '???';
  623.                 }
  624.  
  625.                 this.moveHit(target, posData.source, move, posData.moveData);
  626.  
  627.                 this.effectData.positions[i] = null;
  628.             }
  629.             if (finished) {
  630.                 side.removeSideCondition('futuremove');
  631.             }
  632.         }
  633.     },
  634.     stall: {
  635.         // Protect, Detect, Endure counter
  636.         duration: 2,
  637.         counterMax: 729,
  638.         onStart: function () {
  639.             this.effectData.counter = 3;
  640.         },
  641.         onStallMove: function () {
  642.             // this.effectData.counter should never be undefined here.
  643.             // However, just in case, use 1 if it is undefined.
  644.             var counter = this.effectData.counter || 1;
  645.             this.debug("Success chance: " + Math.round(100 / counter) + "%");
  646.             return (this.random(counter) === 0);
  647.         },
  648.         onRestart: function () {
  649.             if (this.effectData.counter < this.effect.counterMax) {
  650.                 this.effectData.counter *= 3;
  651.             }
  652.             this.effectData.duration = 2;
  653.         }
  654.     },
  655.     gem: {
  656.         duration: 1,
  657.         affectsFainted: true,
  658.         onBasePower: function (basePower, user, target, move) {
  659.             this.debug('Gem Boost');
  660.             return this.chainModify([0x14CD, 0x1000]);
  661.         }
  662.     },
  663.     aura: {
  664.         duration: 1,
  665.         onBasePowerPriority: 8,
  666.         onBasePower: function (basePower, user, target, move) {
  667.             var modifier = 0x1547;
  668.             this.debug('Aura Boost');
  669.             if (user.volatiles['aurabreak']) {
  670.                 modifier = 0x0C00;
  671.                 this.debug('Aura Boost reverted by Aura Break');
  672.             }
  673.             return this.chainModify([modifier, 0x1000]);
  674.         }
  675.     },*/
  676.  
  677.     // weather is implemented here since it's "so important" to the game
  678.  
  679.     raindance: {
  680.         inherit: true,
  681.         duration: Math.floor(Math.random()*10),
  682.         durationCallback: function () {
  683.             return Math.floor(Math.random()*10);
  684.         },
  685.         onBasePower: function (basePower, attacker, defender, move) {
  686.             if (move.type === 'Water') {
  687.                 this.debug('rain water boost');
  688.                 return this.chainModify(this.random(27)/(this.random(8) + 1));
  689.             }
  690.             if (move.type === 'Fire') {
  691.                 this.debug('rain fire suppress');
  692.                 return this.chainModify(this.random(8)/(this.random(27) + 1));
  693.             }
  694.         },
  695.         onStart: function (battle, source, effect) {
  696.             this.add('-weather', 'RainDance');
  697.         }
  698.     },
  699.     primordialsea: {
  700.         inherit: true,
  701.         duration: Math.floor(Math.random()*10),
  702.         durationCallback: function () {
  703.             return Math.floor(Math.random()*10);
  704.         },
  705.         onBasePower: function (basePower, attacker, defender, move) {
  706.             if (move.type === 'Water') {
  707.                 this.debug('Rain water boost');
  708.                 return this.chainModify(this.random(27)/(this.random(8) + 1));
  709.             }
  710.         }
  711.     },
  712.     sunnyday: {
  713.         inherit: true,
  714.         duration: Math.floor(Math.random()*10),
  715.         durationCallback: function () {
  716.             return Math.floor(Math.random()*10);
  717.         },
  718.         onBasePower: function (basePower, attacker, defender, move) {
  719.             if (move.type === 'Fire') {
  720.                 this.debug('Sunny Day fire boost');
  721.                 return this.chainModify(this.random(27)/(this.random(8) + 1));
  722.             }
  723.             if (move.type === 'Water') {
  724.                 this.debug('Sunny Day water suppress');
  725.                 return this.chainModify(this.random(8)/(this.random(27) + 1));
  726.             }
  727.         },
  728.         onStart: function (battle, source, effect) {
  729.             this.add('-weather', 'SunnyDay');
  730.         }
  731.     },
  732.     desolateland: {
  733.         inherit: true,
  734.         duration: Math.floor(Math.random()*10),
  735.         durationCallback: function () {
  736.             return Math.floor(Math.random()*10);
  737.         },
  738.         onBasePower: function (basePower, attacker, defender, move) {
  739.             if (move.type === 'Fire') {
  740.                 this.debug('Sunny Day fire boost');
  741.                 return this.chainModify(this.random(27)/(this.random(8) + 1));
  742.             }
  743.         }
  744.     },
  745.     sandstorm: {
  746.         inherit: true,
  747.         duration: Math.floor(Math.random()*10),
  748.         durationCallback: function () {
  749.             return Math.floor(Math.random()*10);
  750.         },
  751.         onModifySpD: function (spd, pokemon) {
  752.             if (pokemon.hasType('Rock') && this.isWeather('sandstorm')) {
  753.                 return this.modify(spd, this.random(27)/(this.random(8) + 1));
  754.             }
  755.         },
  756.         onStart: function (battle, source, effect) {
  757.             this.add('-weather', 'Sandstorm');
  758.             if (!this.random(666)) { //Loomymarty
  759.                 for (var darude = 0; darude < 420/10; darude++) {
  760.                     this.add('-message', 'DUDUDUDUDUDUDDUDUDUDUDUDUDDUDUDUDUDUDUDUDUDUDUDUDDUDUDUDUDDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDDUDUDUDDUDU');
  761.                 }
  762.             }
  763.         },
  764.         onWeather: function (target) {
  765.             var h = this.random(4);
  766.             if (h) {
  767.                 this.damage(target.maxhp / ((this.random(16) + 1)*(this.random(16) + 1)));
  768.             } else {
  769.                 this.heal(target.maxhp / ((this.random(16) + 1)*(this.random(16) + 1)));
  770.             }
  771.         }
  772.     },
  773.     hail: {
  774.         inherit: true,
  775.         duration: Math.floor(Math.random()*10),
  776.         durationCallback: function () {
  777.             return Math.floor(Math.random()*10);
  778.         },
  779.         onStart: function (battle, source, effect) {
  780.             this.add('-weather', 'Hail');
  781.         },
  782.         onWeather: function (target) {
  783.             var h = this.random(4);
  784.             if (h) {
  785.                 this.damage(target.maxhp / ((this.random(16) + 1)*(this.random(16) + 1)));
  786.             } else {
  787.                 this.heal(target.maxhp / ((this.random(16) + 1)*(this.random(16) + 1)));
  788.             }
  789.         },
  790.         onEnd: function () {
  791.             this.add('-weather', 'none');
  792.         }
  793.     },
  794.     deltastream: {
  795.         inherit: true,
  796.         duration: Math.floor(Math.random()*10),
  797.         onEffectiveness: function (typeMod, target, type, move) {
  798.             if (move && move.effectType === 'Move' && type === 'Flying') {
  799.                 this.add('-activate', '', 'deltastream');
  800.                 return this.random(9) - 4; //Who needs a limit of 2x effectiveness in skill cup
  801.             }
  802.         }
  803.     }
  804. };
  805.  
  806. ==================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement