本文整理汇总了C++中player::i_add方法的典型用法代码示例。如果您正苦于以下问题:C++ player::i_add方法的具体用法?C++ player::i_add怎么用?C++ player::i_add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类player
的用法示例。
在下文中一共展示了player::i_add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: add_item
void add_item( player &p, item &it, inventory_location loc )
{
switch( loc ) {
case GROUND:
g->m.add_item( p.pos(), it );
break;
case INVENTORY:
p.i_add( it );
break;
case WORN:
p.wear_item( it );
break;
case WIELDED_OR_WORN:
if( p.weapon.is_null() ) {
p.wield( it );
} else {
// since we can only wield one item, wear the item instead
p.wear_item( it );
}
break;
default:
FAIL( "unimplemented" );
break;
}
}
示例2: move_item
void move_item( player &p, int pos, inventory_location from, inventory_location to )
{
switch( from ) {
case GROUND:
switch( to ) {
case GROUND:
default:
FAIL( "unimplemented" );
break;
case INVENTORY:
pick_up_from_feet( p, pos );
break;
case WORN:
wear_from_feet( p, pos );
break;
case WIELDED_OR_WORN:
if( p.weapon.is_null() ) {
wield_from_feet( p, pos );
} else {
// since we can only wield one item, wear the item instead
wear_from_feet( p, pos );
}
break;
}
break;
case INVENTORY:
switch( to ) {
case GROUND:
drop_at_feet( p, pos );
break;
case INVENTORY:
default:
FAIL( "unimplemented" );
break;
case WORN:
p.wear( pos, false );
break;
case WIELDED_OR_WORN:
if( p.weapon.is_null() ) {
p.wield( p.i_at( pos ) );
} else {
// since we can only wield one item, wear the item instead
p.wear( pos, false );
}
break;
}
break;
case WORN:
switch( to ) {
case GROUND:
drop_at_feet( p, -2 - pos );
break;
case INVENTORY:
p.takeoff( -2 - pos );
break;
case WORN:
case WIELDED_OR_WORN:
default:
FAIL( "unimplemented" );
break;
}
break;
case WIELDED_OR_WORN:
switch( to ) {
case GROUND:
drop_at_feet( p, -1 - pos );
if( pos == 0 && !p.worn.empty() ) {
// wield the first worn item
p.wield( p.i_at( -2 ) );
}
break;
case INVENTORY:
if( pos == 0 ) {
p.i_add( p.i_rem( -1 ) );
} else {
p.takeoff( -1 - pos );
}
if( pos == 0 && !p.worn.empty() ) {
// wield the first worn item
p.wield( p.i_at( -2 ) );
}
break;
case WORN:
case WIELDED_OR_WORN:
default:
FAIL( "unimplemented" );
break;
}
break;
default:
FAIL( "unimplemented" );
break;
}
}
示例3: fire
//.........这里部分代码省略.........
}
} else if (debug_retarget) {
mvprintz(curshot,5,c_red,"[%d] %s: target == mon_at(%d,%d)[%d] %s hp %d",curshot, p.name.c_str(), tarx ,tary,
mon_at(tarx, tary),
z[mon_at(tarx, tary)].name().c_str(),
z[mon_at(tarx, tary)].hp);
}
// Drop a shell casing if appropriate.
itype_id casing_type = "null";
if( curammo->type == "shot" ) casing_type = "shot_hull";
else if( curammo->type == "9mm" ) casing_type = "9mm_casing";
else if( curammo->type == "22" ) casing_type = "22_casing";
else if( curammo->type == "38" ) casing_type = "38_casing";
else if( curammo->type == "40" ) casing_type = "40_casing";
else if( curammo->type == "44" ) casing_type = "44_casing";
else if( curammo->type == "45" ) casing_type = "45_casing";
else if( curammo->type == "454" ) casing_type = "454_casing";
else if( curammo->type == "500" ) casing_type = "500_casing";
else if( curammo->type == "57" ) casing_type = "57mm_casing";
else if( curammo->type == "46" ) casing_type = "46mm_casing";
else if( curammo->type == "762" ) casing_type = "762_casing";
else if( curammo->type == "223" ) casing_type = "223_casing";
else if( curammo->type == "3006" ) casing_type = "3006_casing";
else if( curammo->type == "308" ) casing_type = "308_casing";
else if( curammo->type == "40mm" ) casing_type = "40mm_casing";
if (casing_type != "null") {
item casing;
casing.make(itypes[casing_type]);
// Casing needs a charges of 1 to stack properly with other casings.
casing.charges = 1;
if( weapon->has_gunmod("brass_catcher") != -1 ) {
p.i_add( casing );
} else {
int x = p.posx - 1 + rng(0, 2);
int y = p.posy - 1 + rng(0, 2);
m.add_item_or_charges(x, y, casing);
}
}
// Use up a round (or 100)
if (weapon->has_flag("FIRE_100"))
weapon->charges -= 100;
else
weapon->charges--;
if (firing->skill_used != Skill::skill("archery") &&
firing->skill_used != Skill::skill("throw"))
{
// Current guns have a durability between 5 and 9.
// Misfire chance is between 1/64 and 1/1024.
if (one_in(2 << firing->durability)) {
add_msg_player_or_npc( &p, _("Your weapon misfires!"),
_("<npcname>'s weapon misfires!") );
return;
}
}
make_gun_sound_effect(this, p, burst, weapon);
int trange = calculate_range(p, tarx, tary);
double missed_by = calculate_missed_by(p, trange, weapon);
// Calculate a penalty based on the monster's speed
double monster_speed_penalty = 1.;
int target_index = mon_at(tarx, tary);
if (target_index != -1) {