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 to (int p, int s, BS &b) {
        if (!b.isOut(p)) {
            return;
        }
        if (!testpinch(p, s, b, 4, false)) {
            return;
        }

        b.sendBerryMessage(11,s,0);
        turn(b,s)["TurnOrder"] = 3;
    }
    static void tp(int p, int s, BS &b) {
        if (!b.isOut(s)) {
            return;
        }

        if (!testpinch(p, s, b, 4, false)) {
            return;
        }

        poke(b,s)["BerryLock"] = true;
        b.sendBerryMessage(10,s,0);
    }
 static void to (int p, int s, BS &b) {
     if (!b.isOut(p)) {
         return;
     }
     if (turn(b,p).value("BugBiter").toBool()) {
         b.eatBerry(s);
         return;
     }
     if (!testpinch(p, s, b, 4, false)) {
         return;
     }
     b.sendBerryMessage(11,s,0);
     turn(b,s)["TurnOrder"] = 3;
 }
    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) {
        /* 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);
            }
        }
    }
Exemple #8
0
    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");
    }
 /* ripped off from focus energy */
 static void uas(int, int s, BS &b) {
     if (b.isOut(s)) {
         addFunction(poke(b,s), "TurnSettings", "FocusEnergy", &ts);
         b.sendMoveMessage(46,0,s);
     }
 }