Exemple #1
0
 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);
     }
 }
Exemple #2
0
    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;
            }
        }
    }
Exemple #3
0
 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);
     }
 }
Exemple #4
0
    static void uodr(int s, int t, BS &b) {
	if (b.koed(s))
	    return;
        if (turn(b,s).contains("CannotBeKoedBy") && turn(b,s)["CannotBeKoedBy"].toInt() == t && b.poke(s).lifePoints() == 1) {
	    b.sendItemMessage(4, s);
	}
    }
    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 #6
0
    static void uodr(int s, int, BS &b) {
        if (b.koed(s))
            return;

        b.sendItemMessage(4, s);
        turn(b,s)["SurviveReason"] = true;
    }
    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 #8
0
    static void ubh(int s, int t, BS &b) {
        if (b.koed(s) || b.hasSubstitute(s) || turn(b,t).value("EncourageBug").toBool())
            return;
        turn(b,s)["EscapeButtonActivated"] = true;
        turn(b,s)["EscapeButtonCount"] = slot(b,s)["SwitchCount"];

        addFunction(turn(b,t), "AfterAttackFinished", "EscapeButton", &aaf);
    }
Exemple #9
0
    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);
    }
Exemple #10
0
 static void uodr(int s, int t, BS &b) {
     if (fturn(b,t).typeMod > 0 && !b.koed(s)) {
         b.sendItemMessage(43, s);
         b.disposeItem(s);
         b.inflictStatMod(s, Attack, 2, s);
         b.inflictStatMod(s, SpAttack, 2, s);
     }
 }
Exemple #11
0
    static void uss(int s, int, BS &b) {
        if (b.koed(s))
            return;

        b.sendItemMessage(5, s);
        b.disposeItem(s);

        turn(b,s)["SurviveReason"] = true;
    }
Exemple #12
0
    static void udi(int s, int t, BS &b) {
	if (s==t)
	    return;
	if (b.koed(s))
	    return;

	b.sendItemMessage(24, s);
	b.healLife(s, turn(b,s)["DamageInflicted"].toInt()/8);
    }
Exemple #13
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 #14
0
    static void udi(int s, int t, BS &b) {
	if (s == t)
	    return; /* life orb doesn't recoil with self damage */
	if (b.koed(s))
	    return;

	if (turn(b,t).contains("DamageTakenBy") && turn(b,t)["DamageTakenBy"].toInt() == s) {
            turn(b,s)["ActivateLifeOrb"] = true;
	}
    }
Exemple #15
0
    static void uodr(int s, int t, BS &b) {
        if (forbidden_moves.contains(move(b,t)))
            return;

        if (fturn(b,t).typeMod > 0 && !b.koed(s)) {
            b.sendItemMessage(43, s);
            b.disposeItem(s);
            b.inflictStatMod(s, Attack, 2, s);
            b.inflictStatMod(s, SpAttack, 2, s);
        }
    }
Exemple #16
0
    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;
    }
Exemple #17
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 #18
0
    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;
    }
Exemple #19
0
 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);
     }
 }
Exemple #20
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 #21
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");
    }
Exemple #22
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 #23
0
    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);
	}
    }
Exemple #24
0
    static void udi(int s, int t, BS &b) {
        if (s == t)
            return; /* life orb doesn't recoil with self damage */
        if (b.koed(s))
            return;

        /* In gen 4, it does not damage the user if the foe has a substitute. In gen 5, it does */
        if (b.gen() <= 4 && turn(b,t).contains("DamageTakenBy") && turn(b,t)["DamageTakenBy"].toInt() == s) {
            turn(b,s)["ActivateLifeOrb"] = true;
        } else if (b.gen() >= 5 && turn(b,s).contains("DamageInflicted")) {
            turn(b,s)["ActivateLifeOrb"] = true;
            turn(b,s)["LOTarget"] = t;
        }
    }
Exemple #25
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);
    }
Exemple #26
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 #27
0
    static void ti(int, int p, BS &b) {
        for (int i = 0; i < 6; i++) {
            int s = b.slot(p, i);

            b.changeHp(s, b.poke(s).totalLifePoints());
            if (b.koed(s)) {
                b.sendItemMessage(1999, s);
            }
            b.changeStatus(p, i, Pokemon::Fine);
            for (int j = 0; j < 4; j++) {
                if (b.move(s, j) != Move::NoMove) {
                    b.gainPP(s, j, 99);
                }
            }
        }
    }
Exemple #28
0
    static void ti(int p, int s, BS &b) {
        if (!b.koed(s)) {
            return;
        }

        int percent = poke(b,p).value("ItemArg").toInt();

        if (percent == 0) {
            percent = 100;
        }

        b.changeHp(s, b.poke(s).totalLifePoints()*percent/100);
        b.changeStatus(b.player(s), b.slotNum(s), Pokemon::Fine);

        b.sendItemMessage(1007, s);
    }
Exemple #29
0
 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);
     }
 }
Exemple #30
0
    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);
        }
    }