static void appl(int s, int, BS &b) { 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.poke(s).move(i).PP() == 0) { zeroPP = true; init = true; minmove = i; minPP = 0; break; } if (b.poke(s).move(i).PP() < minPP && b.poke(s).move(i).PP() < b.poke(s).move(i).totalPP()) { minmove = i; init = true; minPP = b.poke(s).move(i).PP(); } } if (init && (zeroPP || turn(b,s).value("BugBiter").toBool())) { b.eatBerry(s); b.sendBerryMessage(2,s,0,0,0,b.move(s,minmove)); b.gainPP(s,minmove,10); } }
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 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 uodr(int s, int t, BS &b) { if (b.koed(s)) return; if (turn(b,t)["TypeMod"].toInt() <= 4) return; if (b.poke(s).isFull()) return; b.eatBerry(s); b.sendBerryMessage(6,s,0); b.healLife(s, b.poke(s).totalLifePoints()/5); }
static void ti(int p, int s, BS &b) { if (b.poke(s).isFull()) { return; } b.sendBerryMessage(3,s,0); int arg = poke(b,p).value("ItemArg").toInt(); if (arg == 0) { arg = b.poke(s).totalLifePoints(); } b.healLife(s, arg); }
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 void uodr(int s, int, BS &b) { if (!b.attacking()) { return; } if (b.attacker() == s) return; if (fturn(b,b.attacker()).typeMod <= 0) return; if (b.canHeal(s,BS::HealByItem,b.poke(s).item())) { b.eatBerry(s); b.sendBerryMessage(6,s,0); b.healLife(s, b.poke(s).totalLifePoints()/5); } }
static void ahpc(int s, int, BS &b) { if (!b.koed(s) && b.poke(s).lifePercent() <= 50) { b.disposeItem(s); b.sendItemMessage(18,s,0); b.healLife(s, 20); } }
static void et(int s, int, BS &b) { if (!b.canHeal(s)) return; b.sendItemMessage(12,s); b.healLife(s, b.poke(s).totalLifePoints()/16); }
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 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 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 m3b(int s, int t, BS &b) { if (!b.hasSubstitute(s) && turn(b,t)["TypeMod"].toInt() > 4 && turn(b,t)["Type"].toInt() == poke(b,s)["ItemArg"].toInt()) { b.sendBerryMessage(4,s,0,t,b.poke(s).item(),move(b,t)); b.eatBerry(s,false); turn(b,t)["Mod3Berry"] = -5; } }
static void ubh(int s, int t, BS &b) { if (!b.koed(s) && type(b,t) == poke(b,s)["ItemArg"].toInt()) { int stat; if (b.poke(s).item() == Item::RechargeableBattery) { if (b.hasMaximalStatMod(s, Attack)) return; stat = Attack; } else { if (b.hasMaximalStatMod(s, SpAttack)) return; stat = SpAttack; } b.sendItemMessage(36, s, 0, t, b.poke(s).item(), stat); b.disposeItem(s); b.inflictStatMod(s, stat, 1, s, false); } }
static void m3b(int s, int t, BS &b) { /* Normal moves */ if (!b.hasSubstitute(s) && turn(b,t)["Type"].toInt() == 0) { b.sendBerryMessage(4,s,0,t,b.poke(s).item(),turn(b,t)["Move"].toInt()); b.eatBerry(s,false); turn(b,t)["Mod3Berry"] = -5; } }
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); }
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 tp(int s, int, BS &b) { int berry = b.poke(s).item(); if (!testpinch(s, s, b, 4)) return; int stat = (b.true_rand()%5) +1; b.gainStatMod(s, stat, 2,false); b.sendBerryMessage(9,s,0,s,berry, stat); }
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 tp (int p, int s, BS &b) { if (b.koed(s)) return; if (!testpinch(p, s, b, 4, true)) return; b.sendBerryMessage(6,s,0); b.healLife(s, b.poke(s).totalLifePoints()/8); //Berries inflict confusion based on the hindering stat of a non-neutral Nature int plus = NatureInfo::StatBoosted(b.poke(s).nature()); int minus = NatureInfo::StatHindered(b.poke(s).nature()); if (plus != minus) { int arg = poke(b,s)["ItemArg"].toInt(); if (arg == minus) b.inflictConfused(s,s); } }
static void ahpc(int s, int, BS &b) { if (!b.canHeal(s)) return; if (b.poke(s).lifePercent() <= 50) { b.disposeItem(s); b.sendItemMessage(18,s,0); b.healLife(s, 20); } }
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 ubh(int s, int t, BS &b) { int tp = poke(b,s)["ItemArg"].toString().section('_', 0, 0).toInt(); if (!b.koed(s) && type(b,t) == tp) { int stat = poke(b,s)["ItemArg"].toString().section('_', 1).toInt(); if (b.hasMaximalStatMod(s, stat)) return; b.sendItemMessage(36, s, 0, t, b.poke(s).item(), stat); b.disposeItem(s); b.inflictStatMod(s, stat, 1, s, false); } }
static void m3b(int s, int t, BS &b) { if (!b.attacking()) { return; } if (!b.hasSubstitute(s) && fturn(b,t).typeMod > 0 && tmove(b,t).type == poke(b,s)["ItemArg"].toInt()) { 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 s, int, BS &b) { if (!testpinch(s, s, b,2)) return; b.sendBerryMessage(3,s,0); int arg = poke(b,s)["ItemArg"].toInt(); if (arg == 10) /* oran berry */ b.healLife(s, 10); else /* Sitrus Berry */ b.healLife(s, b.poke(s).totalLifePoints()/4); }
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 tp(int s, int, BS &b) { /* The berry may change after the call to test pinch (eaten), so saved before. */ int berry = b.poke(s).item(); if (!testpinch(s, s, b,4)) return; int arg = poke(b,s)["ItemArg"].toInt(); b.sendBerryMessage(7,s,0,s,berry, arg); b.gainStatMod(s, arg, 1,false); }
static void ti(int p, int s, BS &b) { QString sarg = poke(b,p).value("ItemArg").toString(); int arg = sarg.section("_", 0, 0).toInt(); bool permanent = sarg.section("_", 1) == "1"; if (permanent) { turn(b,p)["PermanentItem"] = true; } if (b.koed(s)) return; int status = b.poke(s).status(); bool conf = b.isConfused(s); /* Confusion berry */ if (arg == -1) { if (conf) { b.healConfused(s); b.sendBerryMessage(1, s, 0); } return; } /* Lum berry */ if (conf && arg == 0) { b.healConfused(s); goto end; } if (status == Pokemon::Fine) { return; } /* LumBerry */ if (arg == 0) { if (status == Pokemon::Fine) return; goto end; } else { /* Other Status Berry */ if (status == arg) { goto end; } } return; end: b.healStatus(s, status); b.sendBerryMessage(1, s, arg + 1); }
static void et(int s, int, BS &b) { if (b.poke(s).status() != Pokemon::Fine) { return; } int status = poke(b,s)["ItemArg"].toInt(); if (!b.canGetStatus(s, status)) return; if (status == Pokemon::Burnt) { b.sendItemMessage(19,s,0); } else { b.sendItemMessage(19,s,1); } b.inflictStatus(s, status, s, status == Pokemon::Poisoned ? 15: 0, status == Pokemon::Poisoned ? 15: 0); }