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;
    }
Exemple #2
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 #4
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 #5
0
    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;
    }
Exemple #6
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 #7
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 #8
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;
        }
    }
    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 #10
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 #11
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 #12
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 #13
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 #14
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 #15
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);
            }
        }
    }