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); }
static void udi(int s, int t, BS &b) { if (s==t) return; if (!b.canHeal(s) || turn(b,s).value("EncourageBug").toBool()) return; int damage = turn(b,s)["DamageInflicted"].toInt(); if (damage > 0) { b.sendItemMessage(24, s); b.healLife(s, damage/8); } }
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 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 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; } }
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 et(int s, int, BS &b) { if(b.koed(s) || b.hasWorkingAbility(s, Ability::MagicGuard)) { return; } if(b.hasType(s, Pokemon::Poison)) { if (b.canHeal(s)) { b.sendItemMessage(16,s,0); b.healLife(s, b.poke(s).totalLifePoints()/16); } } else { b.sendItemMessage(16,s,1); b.inflictDamage(s, b.poke(s).totalLifePoints()/8,s); } }
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); } } }
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 to (int s, int, BS &b) { if (!testpinch(s, s, b,4)) return; b.sendBerryMessage(11,s,0); turn(b,s)["TurnOrder"] = 3; }
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); }
static void bpm(int s, int, BS &b) { if (tmove(b,s).type == poke(b,s)["ItemArg"]) { if (b.gen() >= 4) turn(b,s)["BasePowerItemModifier"] = 2; else turn(b,s)["BasePowerItemModifier"] = 1; } }
static void aaf(int, int, BS &b) { std::vector<int> speeds = b.sortedBySpeed(); for (unsigned i = 0; i < speeds.size(); i++) { int p = speeds[i]; if (!b.hasWorkingItem(p, Item::EscapeButton)) continue; if (!turn(b,p).contains("EscapeButtonActivated")) continue; if (turn(b,p)["EscapeButtonCount"] != slot(b,p)["SwitchCount"]) continue; b.sendItemMessage(39, p, 0); b.disposeItem(p); b.requestSwitch(p); } }
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 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); } }
void run() { typedef typename Space::execution_space ExecSpace; TestViewMappingSubview< ExecSpace > self; ASSERT_EQ( Aa.extent(0), AN ); ASSERT_EQ( Ab.extent(0), AN - 2 ); ASSERT_EQ( Ac.extent(0), AN - 2 ); ASSERT_EQ( Ba.extent(0), BN0 ); ASSERT_EQ( Ba.extent(1), BN1 ); ASSERT_EQ( Ba.extent(2), BN2 ); ASSERT_EQ( Bb.extent(0), BN0 - 2 ); ASSERT_EQ( Bb.extent(1), BN1 - 2 ); ASSERT_EQ( Bb.extent(2), BN2 - 2 ); ASSERT_EQ( Ca.extent(0), CN0 ); ASSERT_EQ( Ca.extent(1), CN1 ); ASSERT_EQ( Ca.extent(2), CN2 ); ASSERT_EQ( Ca.extent(3), 13 ); ASSERT_EQ( Ca.extent(4), 14 ); ASSERT_EQ( Cb.extent(0), CN0 - 2 ); ASSERT_EQ( Cb.extent(1), CN1 - 2 ); ASSERT_EQ( Cb.extent(2), CN2 - 2 ); ASSERT_EQ( Da.extent(0), DN0 ); ASSERT_EQ( Da.extent(1), DN1 ); ASSERT_EQ( Da.extent(2), DN2 ); ASSERT_EQ( Da.extent(3), DN3 ); ASSERT_EQ( Da.extent(4), DN4 ); ASSERT_EQ( Db.extent(0), DN1 - 2 ); ASSERT_EQ( Db.extent(1), DN2 - 2 ); ASSERT_EQ( Db.extent(2), DN3 - 2 ); ASSERT_EQ( Da.stride_1(), Db.stride_0() ); ASSERT_EQ( Da.stride_2(), Db.stride_1() ); ASSERT_EQ( Da.stride_3(), Db.stride_2() ); long error_count = -1; Kokkos::parallel_reduce( Kokkos::RangePolicy< ExecSpace >( 0, 1 ), *this, error_count ); ASSERT_EQ( error_count, 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; } }
static void bpm(int s, int t, BS &b) { if (s == t) return; /* Doom Desire & Future sight don't have their gem attacking right away, only when it hits, and then b.attacking() is false */ if (tmove(b,s).attack == Move::FutureSight || tmove(b,s).attack == Move::DoomDesire) { if (b.attacking()) return; } if (tmove(b,s).power <= 1) { return; } if (tmove(b,s).type != poke(b,s)["ItemArg"].toInt() || tmove(b,s).attack == Move::FirePledge || tmove(b,s).attack == Move::GrassPledge || tmove(b,s).attack == Move::WaterPledge ) return; b.sendItemMessage(37, s, 0, 0, b.poke(s).item(), move(b,s)); turn(b,s)["GemActivated"] = true; b.disposeItem(s); }
static void bpm(int s, int t, BS &b) { if (s == t) return; /* Doom Desire & Future sight don't have their jewel attacking right away, only when it hits, and then b.attacking() is false */ if (tmove(b,s).attack == Move::FutureSight || tmove(b,s).attack == Move::DoomDesire) { if (b.attacking()) return; } if (tmove(b,s).power <= 1) { return; } if (tmove(b,s).type != poke(b,s)["ItemArg"].toInt()) return; b.sendItemMessage(37, s, 0, 0, b.poke(s).item(), move(b,s)); turn(b,s)["BasePowerItemModifier"] = 5; b.disposeItem(s); }
static void sm(int s,int, BS &b) { int num = b.pokenum(s).pokenum; QStringList args = poke(b,s)["ItemArg"].toString().split('_'); if(!args[0].split('/').contains(QString::number(num))) { return; } int boost = args[1].toInt(); for (int i = 2; i < args.size(); i++) { turn(b,s)["Stat" + args[i] + "ItemModifier"] = boost; } }
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 bpm(int s, int, BS &b) { QStringList args = poke(b,s)["ItemArg"].toString().split('_'); QStringList pokes = args[0].split('/'); if (!pokes.contains(QString::number(b.pokenum(s).pokenum))) return; int type = tmove(b,s).type; for (int i = 1; i < args.size(); i++) { if (type == args[i].toInt()) turn(b,s)["BasePowerItemModifier"] = 2; } }
static void as(int s, int, BS &b) { bool used = false; if (poke(b,s).contains("AttractedTo")) { int seducer = poke(b,s)["AttractedTo"].toInt(); if (poke(b,seducer).contains("Attracted") && poke(b,seducer)["Attracted"].toInt() == s) { removeFunction(poke(b,s), "DetermineAttackPossible", "Attract"); poke(b,s).remove("AttractedTo"); used = true; } } if (b.gen() >= 5) { if (poke(b,s).contains("Tormented")) { removeFunction(poke(b,s), "MovesPossible", "Torment"); poke(b,s).remove("Tormented"); used = true; } if (b.counters(s).hasCounter(BC::Taunt)) { removeFunction(poke(b,s), "MovesPossible", "Taunt"); removeFunction(poke(b,s), "MovePossible", "Taunt"); b.removeEndTurnEffect(BS::PokeEffect, s, "Taunt"); used = true; } if (b.counters(s).hasCounter(BC::Encore)) { removeFunction(poke(b,s), "MovesPossible", "Encore"); b.removeEndTurnEffect(BS::PokeEffect, s, "Encore"); used = true; } if (b.counters(s).hasCounter(BC::Disable)) { removeFunction(poke(b,s), "MovesPossible", "Disable"); removeFunction(poke(b,s), "MovePossible", "Disable"); b.removeEndTurnEffect(BS::PokeEffect, s, "Disable"); used = true; } b.counters(s).clear(); } if (used) { b.sendItemMessage(7,s); b.disposeItem(s); } }
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 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 atl(int s, int, BS &b) { if (turn(b,s).value("ActivateLifeOrb").toBool() && !turn(b,s).value("NoLifeOrbActivation").toBool() && !turn(b,s).value("EncourageBug").toBool() && !b.hasWorkingAbility(s, Ability::MagicGuard)) { if (b.gen() >= 5) b.sendItemMessage(21,s); b.inflictDamage(s,b.poke(s).totalLifePoints()/10,s); turn(b,s)["NoLifeOrbActivation"] = true; /* Self KO Clause */ if (b.koed(s)) { /* In VGC 2011 (gen 5), the user of the Life Orb wins instead of losing with the Self KO Clause */ if (b.gen() <= 4) b.selfKoer() = s; else b.selfKoer() = turn(b,s).value("LOTarget").toInt(); } } }
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); } } } }
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); } } }
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 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); } }