本文整理汇总了C++中player::has_bionic方法的典型用法代码示例。如果您正苦于以下问题:C++ player::has_bionic方法的具体用法?C++ player::has_bionic怎么用?C++ player::has_bionic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类player
的用法示例。
在下文中一共展示了player::has_bionic方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: give_and_activate
void give_and_activate( player &p, bionic_id const &bioid )
{
INFO( "bionic " + bioid.str() + " is valid" );
REQUIRE( bioid.is_valid() );
p.add_bionic( bioid );
INFO( "dummy has gotten " + bioid.str() + " bionic " );
REQUIRE( p.has_bionic( bioid ) );
// get bionic's index - might not be "last added" due to "integrated" ones
int bioindex = -1;
for( size_t i = 0; i < p.my_bionics->size(); i++ ) {
const auto &bio = ( *p.my_bionics )[ i ];
if( bio.id == bioid ) {
bioindex = i;
}
}
REQUIRE( bioindex != -1 );
const bionic &bio = p.bionic_at_index( bioindex );
REQUIRE( bio.id == bioid );
// turn on if possible
if( bio.id->toggled && !bio.powered ) {
p.activate_bionic( bioindex );
INFO( "bionic " + bio.id.str() + " with index " + std::to_string( bioindex ) + " is active " );
REQUIRE( p.has_active_bionic( bioid ) );
}
}
示例2: calculate_range
int calculate_range(player &p, int tarx, int tary)
{
int trange = rl_dist(p.posx, p.posy, tarx, tary);
it_gun* firing = dynamic_cast<it_gun*>(p.weapon.type);
if (trange < int(firing->volume / 3) && firing->ammo != AT_SHOT)
trange = int(firing->volume / 3);
else if (p.has_bionic("bio_targeting")) {
if (trange > LONG_RANGE)
trange = int(trange * .65);
else
trange = int(trange * .8);
}
if (firing->skill_used == Skill::skill("rifle") && trange > LONG_RANGE)
trange = LONG_RANGE + .6 * (trange - LONG_RANGE);
return trange;
}
示例3: fire
void game::fire(player &p, int tarx, int tary, std::vector<point> &trajectory,
bool burst)
{
item ammotmp;
item* gunmod = p.weapon.active_gunmod();
it_ammo *curammo = NULL;
item *weapon = NULL;
if (p.weapon.has_flag(IF_CHARGE)) { // It's a charger gun, so make up a type
// Charges maxes out at 8.
int charges = p.weapon.num_charges();
it_ammo *tmpammo = dynamic_cast<it_ammo*>(itypes["charge_shot"]);
tmpammo->damage = charges * charges;
tmpammo->pierce = (charges >= 4 ? (charges - 3) * 2.5 : 0);
tmpammo->range = 5 + charges * 5;
if (charges <= 4)
tmpammo->accuracy = 14 - charges * 2;
else // 5, 12, 21, 32
tmpammo->accuracy = charges * (charges - 4);
tmpammo->recoil = tmpammo->accuracy * .8;
tmpammo->ammo_effects = 0;
if (charges == 8)
tmpammo->ammo_effects |= mfb(AMMO_EXPLOSIVE_BIG);
else if (charges >= 6)
tmpammo->ammo_effects |= mfb(AMMO_EXPLOSIVE);
if (charges >= 5)
tmpammo->ammo_effects |= mfb(AMMO_FLAME);
else if (charges >= 4)
tmpammo->ammo_effects |= mfb(AMMO_INCENDIARY);
if (gunmod != NULL) {
weapon = gunmod;
} else {
weapon = &p.weapon;
}
curammo = tmpammo;
weapon->curammo = tmpammo;
weapon->active = false;
weapon->charges = 0;
} else if (gunmod != NULL) {
weapon = gunmod;
curammo = weapon->curammo;
} else {// Just a normal gun. If we're here, we know curammo is valid.
curammo = p.weapon.curammo;
weapon = &p.weapon;
}
ammotmp = item(curammo, 0);
ammotmp.charges = 1;
if (!weapon->is_gun() && !weapon->is_gunmod()) {
debugmsg("%s tried to fire a non-gun (%s).", p.name.c_str(),
weapon->tname().c_str());
return;
}
bool is_bolt = false;
unsigned int effects = curammo->ammo_effects;
// Bolts and arrows are silent
if (curammo->type == AT_BOLT || curammo->type == AT_ARROW)
is_bolt = true;
int x = p.posx, y = p.posy;
// Have to use the gun, gunmods don't have a type
it_gun* firing = dynamic_cast<it_gun*>(p.weapon.type);
if (p.has_trait(PF_TRIGGERHAPPY) && one_in(30))
burst = true;
if (burst && weapon->burst_size() < 2)
burst = false; // Can't burst fire a semi-auto
bool u_see_shooter = u_see(p.posx, p.posy);
// Use different amounts of time depending on the type of gun and our skill
p.moves -= time_to_fire(p, firing);
// Decide how many shots to fire
int num_shots = 1;
if (burst)
num_shots = weapon->burst_size();
if (num_shots > weapon->num_charges() && !weapon->has_flag(IF_CHARGE))
num_shots = weapon->num_charges();
if (num_shots == 0)
debugmsg("game::fire() - num_shots = 0!");
// Set up a timespec for use in the nanosleep function below
timespec ts;
ts.tv_sec = 0;
ts.tv_nsec = BULLET_SPEED;
// Use up some ammunition
int trange = trig_dist(p.posx, p.posy, tarx, tary);
if (trange < int(firing->volume / 3) && firing->ammo != AT_SHOT)
trange = int(firing->volume / 3);
else if (p.has_bionic("bio_targeting")) {
if (trange > LONG_RANGE)
trange = int(trange * .65);
else
trange = int(trange * .8);
}
if (firing->skill_used == Skill::skill("rifle") && trange > LONG_RANGE)
//.........这里部分代码省略.........
示例4: fire
void game::fire(player &p, int tarx, int tary, std::vector<point> &trajectory,
bool burst)
{
item ammotmp;
item* gunmod = p.weapon.active_gunmod();
it_ammo *curammo = NULL;
item *weapon = NULL;
if (p.weapon.has_flag("CHARGE")) { // It's a charger gun, so make up a type
// Charges maxes out at 8.
int charges = p.weapon.num_charges();
it_ammo *tmpammo = dynamic_cast<it_ammo*>(itypes["charge_shot"]);
tmpammo->damage = charges * charges;
tmpammo->pierce = (charges >= 4 ? (charges - 3) * 2.5 : 0);
tmpammo->range = 5 + charges * 5;
if (charges <= 4)
tmpammo->dispersion = 14 - charges * 2;
else // 5, 12, 21, 32
tmpammo->dispersion = charges * (charges - 4);
tmpammo->recoil = tmpammo->dispersion * .8;
if (charges == 8) { tmpammo->ammo_effects.insert("EXPLOSIVE_BIG"); }
else if (charges >= 6) { tmpammo->ammo_effects.insert("EXPLOSIVE"); }
if (charges >= 5){ tmpammo->ammo_effects.insert("FLAME"); }
else if (charges >= 4) { tmpammo->ammo_effects.insert("INCENDIARY"); }
if (gunmod != NULL) {
weapon = gunmod;
} else {
weapon = &p.weapon;
}
curammo = tmpammo;
weapon->curammo = tmpammo;
weapon->active = false;
weapon->charges = 0;
} else if (gunmod != NULL) {
weapon = gunmod;
curammo = weapon->curammo;
} else {// Just a normal gun. If we're here, we know curammo is valid.
curammo = p.weapon.curammo;
weapon = &p.weapon;
}
ammotmp = item(curammo, 0);
ammotmp.charges = 1;
if (!weapon->is_gun() && !weapon->is_gunmod()) {
debugmsg("%s tried to fire a non-gun (%s).", p.name.c_str(),
weapon->tname().c_str());
return;
}
bool is_bolt = false;
std::set<std::string> *effects = &curammo->ammo_effects;
// Bolts and arrows are silent
if (curammo->type == "bolt" || curammo->type == "arrow")
is_bolt = true;
int x = p.posx, y = p.posy;
// Have to use the gun, gunmods don't have a type
it_gun* firing = dynamic_cast<it_gun*>(p.weapon.type);
if (p.has_trait(PF_TRIGGERHAPPY) && one_in(30))
burst = true;
if (burst && weapon->burst_size() < 2)
burst = false; // Can't burst fire a semi-auto
// Use different amounts of time depending on the type of gun and our skill
if (!effects->count("BOUNCE")) {
p.moves -= time_to_fire(p, firing);
}
// Decide how many shots to fire
int num_shots = 1;
if (burst)
num_shots = weapon->burst_size();
if (num_shots > weapon->num_charges() && !weapon->has_flag("CHARGE"))
num_shots = weapon->num_charges();
if (num_shots == 0)
debugmsg("game::fire() - num_shots = 0!");
// Set up a timespec for use in the nanosleep function below
timespec ts;
ts.tv_sec = 0;
ts.tv_nsec = BULLET_SPEED;
// Use up some ammunition
int trange = rl_dist(p.posx, p.posy, tarx, tary);
if (trange < int(firing->volume / 3) && firing->ammo != "shot")
trange = int(firing->volume / 3);
else if (p.has_bionic("bio_targeting")) {
if (trange > LONG_RANGE)
trange = int(trange * .65);
else
trange = int(trange * .8);
}
if (firing->skill_used == Skill::skill("rifle") && trange > LONG_RANGE)
trange = LONG_RANGE + .6 * (trange - LONG_RANGE);
std::string message = "";
//.........这里部分代码省略.........