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);
    }
Exemple #2
0
    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);
    }
Exemple #3
0
    static void asc(int s, int, BS &b) {
        if (b.koed(s))
            return;

        int status = b.poke(s).status();
        bool conf = b.isConfused(s);
        int arg = poke(b,s)["ItemArg"].toInt();

        /* Confusion berry */
        if (arg == -1) {
            if (conf) {
                b.eatBerry(s);
                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) {
            goto end;
        }    /* Poison Berry */
        else if (arg == Pokemon::Poisoned) {
            if (status == Pokemon::Poisoned || status == Pokemon::DeeplyPoisoned) {
                goto end;
            }
        } else { /* Other Status Berry */
            if (status == arg) {
                goto end;
            }
        }

        return;

        end:
        b.eatBerry(s);
        b.healStatus(s, status);
        b.sendBerryMessage(1, s, arg + 1);
    }
    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);
        }
    }
Exemple #5
0
 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);
     }
 }
Exemple #6
0
    static void to (int s, int, BS &b) {
        if (!testpinch(s, s, b,4))
            return;

        b.sendBerryMessage(11,s,0);
        turn(b,s)["TurnOrder"] = 3;
    }
Exemple #7
0
    static void btl(int s, int, BS &b) {
        if (!testpinch(s, s, b,4))
            return;

        poke(b,s)["BerryLock"] = true;
        b.sendBerryMessage(10,s,0);
    }
Exemple #8
0
    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;
        }
    }
Exemple #9
0
 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);
 }
Exemple #10
0
    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;
        }
    }
Exemple #11
0
    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);
    }
Exemple #12
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);
        }
    }
Exemple #13
0
    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 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;
    }
Exemple #15
0
 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);
 }
Exemple #16
0
    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;
        }
    }
Exemple #17
0
    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 #18
0
    static void ti(int p, int s, BS &b) {
        int attack = turn(b,p).value("ItemAttackSlot").toInt();
        int pp = poke(b,p).value("ItemArg").toInt();

        if (pp == 0) {
            pp = 99;
        }

        b.sendBerryMessage(2,s,0,0,0,b.move(s,attack));

        b.gainPP(s, attack, pp);
    }
Exemple #19
0
    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 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);
    }
Exemple #21
0
 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);
 }
Exemple #22
0
    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);
    }
Exemple #23
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;
 }
Exemple #24
0
 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);
     }
 }
Exemple #25
0
    static void ti(int p, int s, BS &b) {
        int pp = poke(b,p).value("ItemArg").toInt();

        if (pp == 0) {
            pp = 99;
        }

        b.sendBerryMessage(2,s,1);

        for (int i = 0; i < 4; i++) {
            if (b.move(s,i) != Move::NoMove) {
                b.gainPP(s, i, pp);
            }
        }
    }
Exemple #26
0
    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;
            }
        }
    }
Exemple #27
0
    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);
    }
Exemple #28
0
    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);
        }
    }
Exemple #29
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);
        }
    }