static bool testpinch(int p, int s, BS &b, int ratio, bool activate) { //HP Pinches activate, nothing else does if sending back if (turn(b,s).value("SendingBack").toBool() && !activate) { return false; } if (turn(b,p).value("BugBiter").toBool()) { b.eatBerry(s); return true; } //Gluttony if (b.hasWorkingAbility(s, Ability::Gluttony)) ratio = 2; if (!b.koed(s)) { int lp = b.poke(s).lifePoints(); int tp = b.poke(s).totalLifePoints(); if (lp*ratio <= tp) { //Reusing 'bool activate' in order to only affect HP berries if (poke(b, s).value("HealBlockCount").toInt() > 0 && activate) { b.sendMoveMessage(59,BS::HealByItem,s,Type::Psychic,s,b.poke(s).item()); return false; } b.eatBerry(s,s==p); return true; } } return false; }
static void tp(int p, int s, BS &b) { if (!b.isOut(s)) { return; } int berry = b.poke(s).item(); QVector<int> stats; for (int i = Attack; i <= Evasion; i++) { if (fpoke(b,s).boosts[i] < 6) { stats.push_back(i); } } if (stats.empty()) return; if (!testpinch(p, s, b, 4, false)) return; int stat = stats[b.randint(stats.size())]; if (b.hasWorkingAbility(s, Ability::Contrary)) { b.sendBerryMessage(9,s,1,s, berry, stat); } else { b.sendBerryMessage(9,s,0,s, berry, stat); } b.inflictStatMod(s, stat, 2, s, false); }
static void et(int s, int, BS &b) { if (b.hasWorkingAbility(s, Ability::MagicGuard)) return; b.sendItemMessage(29,s,0); b.inflictDamage(s, b.poke(s).totalLifePoints()/8,s); }
static void ubh(int s, int t, BS &b) { if (b.koed(s) || b.hasSubstitute(s) || b.hasWorkingAbility(s, Ability::Encourage)) return; turn(b,s)["EscapeButtonActivated"] = true; turn(b,s)["EscapeButtonCount"] = slot(b,s)["SwitchCount"]; addFunction(turn(b,t), "AfterAttackFinished", "EscapeButton", &aaf); }
static void upa(int s, int t, BS &b) { if (b.koed(s) && !b.koed(t)) { if (!b.hasWorkingAbility(t,Ability::Damp)){ b.sendAbMessage(2,0,s,t); b.inflictPercentDamage(t,25,s,false); } else b.sendAbMessage(2,1,s,t); } }
static void ubh(int s, int t, BS &b) { if (b.koed(s) || (b.hasWorkingAbility(t, Ability::Encourage) && turn(b,t).contains("EncourageBug")) || b.hasSubstitute(s)) return; addFunction(turn(b,t), "AfterAttackFinished", "RedCard", &aaf); turn(b,t)["RedCardUser"] = s; turn(b,t)["RedCardCount"] = slot(b,t)["SwitchCount"]; turn(b,t)["RedCardGiverCount"] = slot(b,s)["SwitchCount"]; return; }
static void ubh(int s, int t, BS &b) { //Red Card does not trigger if the Pokemon is phazed with Dragon Tail/Circle Throw if (b.koed(s) || (b.hasWorkingAbility(t, Ability::SheerForce) && turn(b,t).contains("EncourageBug")) || tmove(b,t).attack == Move::DragonTail || tmove(b,t).attack == Move::CircleThrow || (b.hasSubstitute(s) && !b.canBypassSub(t))) return; addFunction(turn(b,t), "AfterAttackFinished", "RedCard", &aaf); turn(b,t)["RedCardUser"] = s; turn(b,t)["RedCardCount"] = slot(b,t)["SwitchCount"]; turn(b,t)["RedCardGiverCount"] = slot(b,s)["SwitchCount"]; return; }
static void upa( int s, int t, BS &b) { if (!b.koed(t) && !b.hasWorkingAbility(t, Ability::MagicGuard)) { b.sendItemMessage(34,s,0,t); b.inflictDamage(t,b.poke(t).totalLifePoints()/6,s,false); /* In VGC 2011, the one with the rugged helmet wins */ if (b.koed(t)) { b.selfKoer() = t; } } }
static void uodr(int s, int t, BS &b) { if (!b.attacking()) { return; } //Magic Guard if (tmove(b,t).category != poke(b,s)["ItemArg"].toInt() || b.koed(t) || b.hasWorkingAbility(t, Ability::MagicGuard)) { return; } b.eatBerry(s); b.sendBerryMessage(12,s,0,t); b.inflictDamage(t, b.poke(t).totalLife()/8,s,false); }
static void et(int s, int, BS &b) { if(b.koed(s) || b.hasWorkingAbility(s, Ability::MagicGuard)) { return; } if(b.hasType(s, Pokemon::Poison)) { if (!b.poke(s).isFull()) { b.sendItemMessage(16,s,0); b.healLife(s, b.poke(s).totalLifePoints()/16); } } else if (!b.hasType(s, Pokemon::Steel)) { b.sendItemMessage(16,s,1); b.inflictDamage(s, b.poke(s).totalLifePoints()/8,s); } }
static bool testpinch(int s, int , BS &b, int ratio) { if (turn(b,s).value("BugBiter").toBool()) { b.eatBerry(s); return true; } //Gluttony if (b.hasWorkingAbility(s, 30)) ratio = 2; bool ret = b.poke(s).lifePoints()*ratio <= b.poke(s).totalLifePoints() && !b.koed(s); if (ret) b.eatBerry(s); return ret; }
static void udi(int s, int t, BS &b) { if (s==t) return; if (b.koed(s) || b.hasWorkingAbility(s, Ability::Encourage)) return; if (b.poke(s).lifePoints() == b.poke(s).totalLifePoints()) { // Don't heal if at full health already return; } int damage = turn(b,s)["DamageInflicted"].toInt(); if (damage > 0) { b.sendItemMessage(24, s); b.healLife(s, damage/8); } }
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 tp(int p, int s, BS &b) { /* The berry may change after the call to test pinch (eaten), so saved before. */ int berry = b.poke(s).item(); if (!testpinch(p, s, b, 4, false)) return; int arg = poke(b,p)["ItemArg"].toInt(); if (b.isOut(s)) { if (b.hasWorkingAbility(s, Ability::Contrary)) { b.sendBerryMessage(7,s,1,s, berry, arg); } else { b.sendBerryMessage(7,s,0,s, berry, arg); } b.inflictStatMod(s, arg, 1, s, false); } }
static void uodr(int s, int t, BS &b) { if (!b.attacking() || b.koed(s)) { return; } int arg = poke(b,s)["ItemArg"].toInt(); int berry = b.poke(s).item(); if (turn(b,t).value("BugBiter").toBool() || tmove(b,t).category == Move::Special) { b.eatBerry(s, s==t); if (b.isOut(s)) { if (b.hasWorkingAbility(s, Ability::Contrary)) { b.sendBerryMessage(7,s,1,s, berry, arg); } else { b.sendBerryMessage(7,s,0,s, berry, arg); } b.inflictStatMod(s,arg,1,s,false); } } }
static void aaf(int t, int, BS &b) { if (turn(b,t)["RedCardCount"] != slot(b,t)["SwitchCount"]) return; int s = turn(b,t)["RedCardUser"].toInt(); if (b.koed(s) || b.koed(t) || turn(b,t)["RedCardGiverCount"] != slot(b,s)["SwitchCount"]) return; if (!b.hasWorkingItem(s, Item::RedCard)) return; int target = b.player(t); if (b.countBackUp(target) == 0) { return; } b.sendItemMessage(38, s, 0, t); b.disposeItem(s); /* ingrain & suction cups */ if (poke(b,t).value("Rooted").toBool()) { b.sendMoveMessage(107, 1, s, Pokemon::Grass,t); return; } else if (b.hasWorkingAbility(t,Ability::SuctionCups)) { b.sendMoveMessage(107, 0, s, 0,t); return; } QList<int> switches; for (int i = 0; i < 6; i++) { if (!b.isOut(target, i) && !b.poke(target,i).ko()) { switches.push_back(i); } } b.sendBack(t, true); b.sendPoke(t, switches[b.randint(switches.size())], true); b.sendMoveMessage(107,2,s,0,t); b.callEntryEffects(t); turn(b,t).remove("RedCardUser"); }
static void atl(int s, int, BS &b) { if (turn(b,s).value("ActivateLifeOrb").toBool() && !b.hasWorkingAbility(s, Ability::MagicGuard)) { //b.sendItemMessage(21,s); b.inflictDamage(s,b.poke(s).totalLifePoints()/10,s); } }
static void uodr(int s, int t, BS &b) { //Magic Guard if (turn(b,t)["Category"].toInt() != poke(b,s)["ItemArg"].toInt() || b.koed(t) || b.hasWorkingAbility(t, Ability::MagicGuard)) { return; } b.eatBerry(s); b.sendBerryMessage(12,s,0,t); b.inflictDamage(t, b.poke(t).lifePoints()/8,s,false); }