static void udi(int s, int t, BS &b) { if (s == t) return; /* life orb doesn't recoil with self damage */ if (b.koed(s)) return; /* In gen 4, it does not damage the user if the foe has a substitute. In gen 5, it does */ if (b.gen() <= 4 && turn(b,t).contains("DamageTakenBy") && turn(b,t)["DamageTakenBy"].toInt() == s) { turn(b,s)["ActivateLifeOrb"] = true; } else if (b.gen() >= 5 && turn(b,s).contains("DamageInflicted")) { turn(b,s)["ActivateLifeOrb"] = true; turn(b,s)["LOTarget"] = t; } }
static void os(int s, int, BS &b) { b.sendItemMessage(40, s, 0); b.sendItemMessage(40, s, 1); b.inflictStatMod(s, Attack, 2, s, false); b.inflictConfused(s,s); b.disposeItem(s); /* in GSC cart mechanics, infinite confusion */ if (b.isConfused(s)) { if (b.gen() == Gen::GoldSilver || b.gen() == Gen::Crystal) { poke(b,s)["ConfusedCount"] = 255; } } }
static void mp(int s, int, BS &b) { for (int i = 0; i < 4; i++) { if (MoveInfo::Power(b.move(s,i), b.gen()) == 0) { turn(b,s)["Move" + QString::number(i) + "Blocked"] = true; } } }
static void appl(int p, int s, BS &b) { if (b.koed(s)) return; int minmove = 0; int minPP = 100; bool init = false; bool zeroPP = false; for (int i = 0; i < 4; i++) { if (b.move(s, i) == 0) { continue; } if (b.PP(s, i) == 0) { zeroPP = true; init = true; minmove = i; minPP = 0; break; } if (b.PP(s, i) < minPP && (fpoke(b, s).moves[i] == b.poke(s).move(i).num() ? b.PP(s, i) < b.poke(s).move(i).totalPP() : b.PP(s, i) < 5)) { minmove = i; init = true; minPP = b.PP(s, i); } } if (init && (zeroPP || turn(b,p).value("BugBiter").toBool())) { b.eatBerry(s, s==p); b.sendBerryMessage(2,s,0,0,0,b.move(s,minmove)); b.gainPP(s,minmove,b.gen() <= 2 ? 5 : 10); } }
static void bpm(int s, int, BS &b) { if (tmove(b,s).type == poke(b,s)["ItemArg"]) { if (b.gen() >= 4) b.chainBp(s, 4); else b.chainBp(s, 2); } }
static void btd(int s, int t, BS &b) { if(b.poke(s).isFull()) { if (b.gen() <= 4) turn(b,s)["CannotBeKoedBy"] = t; else turn(b,s)["CannotBeKoedAt"] = b.attackCount(); } }
static void btd(int s, int t, BS &b) { if (b.coinflip(1, 10)) { if (b.gen() <= 4) turn(b,s)["CannotBeKoedBy"] = t; else turn(b,s)["CannotBeKoedAt"] = b.attackCount(); } }
static void bpm(int s, int, BS &b) { if (tmove(b,s).type == poke(b,s)["ItemArg"]) { if (b.gen() >= 4) turn(b,s)["BasePowerItemModifier"] = 2; else turn(b,s)["BasePowerItemModifier"] = 1; } }
static void atl(int s, int, BS &b) { if (turn(b,s).value("ActivateLifeOrb").toBool() && !turn(b,s).value("NoLifeOrbActivation").toBool() && !turn(b,s).value("EncourageBug").toBool() && !b.hasWorkingAbility(s, Ability::MagicGuard)) { if (b.gen() >= 5) b.sendItemMessage(21,s); b.inflictDamage(s,b.poke(s).totalLifePoints()/10,s); turn(b,s)["NoLifeOrbActivation"] = true; /* Self KO Clause */ if (b.koed(s)) { /* In VGC 2011 (gen 5), the user of the Life Orb wins instead of losing with the Self KO Clause */ if (b.gen() <= 4) b.selfKoer() = s; else b.selfKoer() = turn(b,s).value("LOTarget").toInt(); } } }
static void m3b(int s, int t, BS &b) { if (!b.attacking()) { return; } /* We never want to activate this berry if this is consumed by Bug Bite */ if (b.gen() >= 4 && !turn(b,s).value("BugBiter").toBool()) { /* Normal moves */ if (!b.hasSubstitute(s) && tmove(b,t).type == 0) { b.sendBerryMessage(4,s,0,t,b.poke(s).item(),move(b,t)); b.eatBerry(s,false); turn(b,t)["Mod3Berry"] = -5; } } }
static void tp(int p, int s, BS &b) { if (!b.isOut(s)) { return; } if (!testpinch(p, s, b, 4, false)) { return; } if (b.gen() <= 4) { poke(b,s)["BerryLock"] = true; } else { poke(b,s)["Stat6BerryModifier"] = true; } b.sendBerryMessage(10,s,0); }
static void tp(int p, int s, BS &b) { if (b.koed(s) || b.poke(s).isFull()) return; if (!testpinch(p, s, b, 2, true)) return; b.sendBerryMessage(3,s,0); int arg = poke(b,p)["ItemArg"].toInt(); if (arg == 10) /* oran berry */ b.healLife(s, 10); else /* Sitrus Berry */ { if (b.gen() >= 4) b.healLife(s, b.poke(s).totalLifePoints()/4); else b.healLife(s, 30); } }
static void as(int s, int, BS &b) { bool used = false; if (poke(b,s).contains("AttractedTo")) { int seducer = poke(b,s)["AttractedTo"].toInt(); if (poke(b,seducer).contains("Attracted") && poke(b,seducer)["Attracted"].toInt() == s) { removeFunction(poke(b,s), "DetermineAttackPossible", "Attract"); poke(b,s).remove("AttractedTo"); used = true; } } if (b.gen() >= 5) { if (poke(b,s).contains("Tormented")) { removeFunction(poke(b,s), "MovesPossible", "Torment"); poke(b,s).remove("Tormented"); used = true; } if (b.counters(s).hasCounter(BC::Taunt)) { removeFunction(poke(b,s), "MovesPossible", "Taunt"); removeFunction(poke(b,s), "MovePossible", "Taunt"); b.removeEndTurnEffect(BS::PokeEffect, s, "Taunt"); used = true; } if (b.counters(s).hasCounter(BC::Encore)) { removeFunction(poke(b,s), "MovesPossible", "Encore"); b.removeEndTurnEffect(BS::PokeEffect, s, "Encore"); used = true; } if (b.counters(s).hasCounter(BC::Disable)) { removeFunction(poke(b,s), "MovesPossible", "Disable"); removeFunction(poke(b,s), "MovePossible", "Disable"); b.removeEndTurnEffect(BS::PokeEffect, s, "Disable"); used = true; } b.counters(s).clear(); } if (used) { b.sendItemMessage(7,s); b.disposeItem(s); } }
static void atl(int s, int, BS &b) { if (b.gen() > 4) return; /* Last move used is here not to take "special occurence" moves */ poke(b,s)["ChoiceMemory"] = poke(b,s)["LastMoveUsed"]; }