本文整理汇总了C++中player类的典型用法代码示例。如果您正苦于以下问题:C++ player类的具体用法?C++ player怎么用?C++ player使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了player类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: debug
void monster::debug(player &u)
{
debugmsg("monster::debug %s has %d steps planned.", name().c_str(), plans.size());
debugmsg("monster::debug %s Moves %d Speed %d HP %d",name().c_str(), moves, get_speed(), hp);
for (size_t i = 0; i < plans.size(); i++) {
const int digit = '0' + (i % 10);
mvaddch(plans[i].y - SEEY + u.posy(), plans[i].x - SEEX + u.posx(), digit);
}
getch();
}
开发者ID:reverieAlice,项目名称:Cataclysm-DDA,代码行数:10,代码来源:monster.cpp
示例2: is_valid_player
bool ma_requirements::is_valid_player(player &u)
{
for( auto buff_id : req_buffs ) {
if (!u.has_mabuff(buff_id)) {
return false;
}
}
//A technique is valid if it applies to unarmed strikes, if it applies generally
//to all weapons (such as Ninjutsu sneak attacks or innate weapon techniques like RAPID)
//or if the weapon is flagged as being compatible with the style. Some techniques have
//further restrictions on required weapon properties (is_valid_weapon).
bool cqb = u.has_active_bionic("bio_cqb");
bool valid = ((unarmed_allowed && u.unarmed_attack()) ||
(melee_allowed && !u.unarmed_attack() && is_valid_weapon(u.weapon)) ||
(u.has_weapon() && martialarts[u.style_selected].has_weapon(u.weapon.type->id) &&
is_valid_weapon(u.weapon))) &&
((u.skillLevel("melee") >= min_melee &&
u.skillLevel("unarmed") >= min_unarmed &&
u.skillLevel("bashing") >= min_bashing &&
u.skillLevel("cutting") >= min_cutting &&
u.skillLevel("stabbing") >= min_stabbing) || cqb);
return valid;
}
开发者ID:gienkov,项目名称:Cataclysm-DDA,代码行数:26,代码来源:martialarts.cpp
示例3: put_into_vehicle
void put_into_vehicle( player &p, const std::list<item> &items, vehicle &veh, int part )
{
if( items.empty() ) {
return;
}
const tripoint where = veh.global_part_pos3( part );
const std::string ter_name = g->m.name( where );
int fallen_count = 0;
for( auto it : items ) { // cant use constant reference here because of the spill_contents()
if( it.is_bucket_nonempty() && !it.spill_contents( p ) ) {
p.add_msg_player_or_npc(
_( "To avoid spilling its contents, you set your %1$s on the %2$s." ),
_( "To avoid spilling its contents, <npcname> sets their %1$s on the %2$s." ),
it.display_name().c_str(), ter_name.c_str()
);
g->m.add_item_or_charges( where, it );
continue;
}
if( !veh.add_item( part, it ) ) {
if( it.count_by_charges() ) {
// Maybe we can add a few charges in the trunk and the rest on the ground.
it.mod_charges( -veh.add_charges( part, it ) );
}
g->m.add_item_or_charges( where, it );
++fallen_count;
}
}
const std::string part_name = veh.part_info( part ).name();
if( same_type( items ) ) {
const item &it = items.front();
const int dropcount = items.size() * ( it.count_by_charges() ? it.charges : 1 );
p.add_msg_player_or_npc(
ngettext( "You put your %1$s in the %2$s's %3$s.",
"You put your %1$s in the %2$s's %3$s.", dropcount ),
ngettext( "<npcname> puts their %1$s in the %2$s's %3$s.",
"<npcname> puts their %1$s in the %2$s's %3$s.", dropcount ),
it.tname( dropcount ).c_str(), veh.name.c_str(), part_name.c_str()
);
} else {
p.add_msg_player_or_npc(
_( "You put several items in the %1$s's %2$s." ),
_( "<npcname> puts several items in the %1$s's %2$s." ),
veh.name.c_str(), part_name.c_str()
);
}
if( fallen_count > 0 ) {
add_msg( m_warning, _( "The trunk is full, so some items fell to the %s." ), ter_name.c_str() );
}
}
开发者ID:ProfoundDarkness,项目名称:Cataclysm-DDA,代码行数:55,代码来源:activity_item_handling.cpp
示例4: hit
int monster::hit(game *g, player &p, body_part &bp_hit)
{
int numdice = type->melee_skill;
if (dice(numdice, 10) <= dice(p.dodge(g), 10) && !one_in(20)) {
if (numdice > p.sklevel[sk_dodge])
p.practice(sk_dodge, 10);
return 0; // We missed!
}
p.practice(sk_dodge, 5);
int ret = 0;
int highest_hit;
switch (type->size) {
case MS_TINY:
highest_hit = 3;
break;
case MS_SMALL:
highest_hit = 12;
break;
case MS_MEDIUM:
highest_hit = 20;
break;
case MS_LARGE:
highest_hit = 28;
break;
case MS_HUGE:
highest_hit = 35;
break;
}
if (has_flag(MF_DIGS))
highest_hit -= 8;
if (has_flag(MF_FLIES))
highest_hit += 20;
if (highest_hit <= 1)
highest_hit = 2;
if (highest_hit > 20)
highest_hit = 20;
int bp_rand = rng(0, highest_hit - 1);
if (bp_rand <= 2)
bp_hit = bp_legs;
else if (bp_rand <= 10)
bp_hit = bp_torso;
else if (bp_rand <= 14)
bp_hit = bp_arms;
else if (bp_rand <= 16)
bp_hit = bp_mouth;
else if (bp_rand == 17)
bp_hit = bp_eyes;
else
bp_hit = bp_head;
ret += dice(type->melee_dice, type->melee_sides);
return ret;
}
开发者ID:pistacchio,项目名称:Cataclysm,代码行数:54,代码来源:monster.cpp
示例5: get_item_from_inventory
item_location game::get_item_from_inventory( player &p, const std::string &title )
{
const std::string msg = p.is_npc() ? string_format( _( "%s's inventory is empty." ),
p.name.c_str() ) :
std::string( _( "Your inventory is empty." ) );
return inv_internal( p,
inventory_filter_preset( convert_filter( [ &p ]( const item & it ) {
return !p.is_worn( it ) && &p.weapon != ⁢
} ) ), title, -1, msg );
}
开发者ID:EpicOrange,项目名称:Cataclysm-DDA,代码行数:11,代码来源:game_inventory.cpp
示例6: test_consumable_ammo
void test_consumable_ammo( player &p, std::string &itemname, bool when_empty, bool when_full )
{
item it = item( itemname, 0, 0 ) ;
it.ammo_unset();
INFO( "consume \'" + it.tname() + "\' with " + std::to_string( it.ammo_remaining() ) + " charges" );
REQUIRE( p.can_consume( it ) == when_empty );
it.ammo_set( it.ammo_type()->default_ammotype(), -1 ); // -1 -> full
INFO( "consume \'" + it.tname() + "\' with " + std::to_string( it.ammo_remaining() ) + " charges" );
REQUIRE( p.can_consume( it ) == when_full );
}
开发者ID:Barhandar,项目名称:Cataclysm-DDA,代码行数:12,代码来源:bionics_test.cpp
示例7: pick_up_from_feet
void pick_up_from_feet( player &p, int pos ) {
auto size_before = g->m.i_at( p.pos() ).size();
REQUIRE( size_before > pos );
p.moves = 100;
p.assign_activity( activity_id( "ACT_PICKUP" ) );
p.activity.placement = tripoint(0, 0, 0);
p.activity.values.push_back( false ); // not from vehicle
p.activity.values.push_back( pos ); // index of item to pick up
p.activity.values.push_back( 0 );
p.activity.do_turn( p );
REQUIRE( g->m.i_at( p.pos() ).size() == size_before - 1 );
}
开发者ID:alapazam,项目名称:Cataclysm-DDA,代码行数:12,代码来源:invlet_test.cpp
示例8: fs2netd_get_pilot_info
int fs2netd_get_pilot_info(const char *callsign, player *out_plr, bool first_call)
{
if ( !Logged_in ) {
return -2;
}
if ( (out_plr == NULL) || (callsign == NULL) || !(strlen(callsign)) ) {
return -2;
}
static player new_plr;
if (first_call) {
new_plr.reset();
strncpy( new_plr.callsign, callsign, CALLSIGN_LEN );
// initialize the stats to default values
init_scoring_element( &new_plr.stats );
out_plr->reset();
Local_timeout = timer_get_seconds() + 30;
In_process = true;
ml_printf("FS2NetD MSG: Requesting pilot stats for '%s' ...", callsign);
}
int rc = FS2NetD_GetPlayerData(callsign, &new_plr, false, first_call);
// some sort of failure
if (rc > 0) {
In_process = false;
Local_timeout = -1;
return -2;
}
// if timeout passes then bail on failure
if ( timer_get_seconds() > Local_timeout ) {
In_process = false;
Local_timeout = -1;
return -2;
}
if (rc == 0) {
memcpy( out_plr, &new_plr, sizeof(player) );
In_process = false;
Local_timeout = -1;
}
// we should only be returning -1 (processing) or 0 (got data successfully)
return rc;
}
开发者ID:n-kawamt,项目名称:fs2open_snapshot,代码行数:53,代码来源:fs2netd_client.cpp
示例9: setPlayerSprites
//initialize player - more to come, for now just animations
void setPlayerSprites()
{
if (mainPlayer.getCharName().compare("Flu") == 0)
{
mainPlayer.loadPlayerSprites(6);
mainPlayer.getSprites()[0] = SOIL_load_OGL_texture("Textures/Flu.png", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_INVERT_Y);
mainPlayer.getSprites()[1] = SOIL_load_OGL_texture("Textures/Fluattack1.png", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_INVERT_Y);
mainPlayer.getSprites()[2] = SOIL_load_OGL_texture("Textures/Fluattack2.png", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_INVERT_Y);
mainPlayer.getSprites()[3] = SOIL_load_OGL_texture("Textures/Fluattack3.png", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_INVERT_Y);
mainPlayer.getSprites()[4] = SOIL_load_OGL_texture("Textures/Fluattack4.png", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_INVERT_Y);
mainPlayer.getSprites()[5] = SOIL_load_OGL_texture("Textures/Fluattack5.png", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_INVERT_Y);
}
}
开发者ID:rellena,项目名称:GERMS2.01,代码行数:14,代码来源:playermovefuncs.cpp
示例10: comestible_inventory_preset
comestible_inventory_preset( const player &p ) : inventory_selector_preset(), p( p ) {
append_cell( [ p, this ]( const item_location & loc ) {
return good_bad_none( p.nutrition_for( get_comestible_item( loc ) ) );
}, _( "NUTRITION" ) );
append_cell( [ this ]( const item_location & loc ) {
return good_bad_none( get_edible_comestible( loc ).quench );
}, _( "QUENCH" ) );
append_cell( [ p, this ]( const item_location & loc ) {
return good_bad_none( p.fun_for( get_comestible_item( loc ) ).first );
}, _( "JOY" ) );
append_cell( [ this ]( const item_location & loc ) {
const int spoils = get_edible_comestible( loc ).spoils;
if( spoils > 0 ) {
return to_string_clipped( time_duration::from_turns( spoils ) );
}
return std::string();
}, _( "SPOILS IN" ) );
append_cell( [ this, &p ]( const item_location & loc ) {
std::string cbm_name;
switch( p.get_cbm_rechargeable_with( get_comestible_item( loc ) ) ) {
case rechargeable_cbm::none:
break;
case rechargeable_cbm::battery:
cbm_name = _( "Battery" );
break;
case rechargeable_cbm::reactor:
cbm_name = _( "Reactor" );
break;
case rechargeable_cbm::furnace:
cbm_name = _( "Furnace" );
break;
}
if( !cbm_name.empty() ) {
return string_format( "<color_cyan>%s</color>", cbm_name.c_str() );
}
return std::string();
}, _( "CBM" ) );
append_cell( [ this, &p ]( const item_location & loc ) {
return good_bad_none( p.get_acquirable_energy( get_comestible_item( loc ) ) );
}, _( "ENERGY" ) );
}
开发者ID:RyanMcManaman,项目名称:Cataclysm-DDA,代码行数:50,代码来源:game_inventory.cpp
示例11: crafting_allowed
static bool crafting_allowed( const player &p, const recipe &rec )
{
if( !p.has_morale_to_craft() ) {
add_msg( m_info, _( "Your morale is too low to craft..." ) );
return false;
}
if( p.lighting_craft_speed_multiplier( rec ) <= 0.0f ) {
add_msg( m_info, _( "You can't see to craft!" ) );
return false;
}
return true;
}
开发者ID:AlecWhite,项目名称:Cataclysm-DDA,代码行数:14,代码来源:crafting.cpp
示例12: calculate_missed_by
double calculate_missed_by(player &p, int trange, item* weapon)
{
// No type for gunmods,so use player weapon.
it_gun* firing = dynamic_cast<it_gun*>(p.weapon.type);
// Calculate deviation from intended target (assuming we shoot for the head)
double deviation = 0.; // Measured in quarter-degrees.
// Up to 0.75 degrees for each skill point < 8.
if (p.skillLevel(firing->skill_used) < 8) {
deviation += rng(0, 3 * (8 - p.skillLevel(firing->skill_used)));
}
// Up to 0.25 deg per each skill point < 9.
if (p.skillLevel("gun") < 9) { deviation += rng(0, 9 - p.skillLevel("gun")); }
deviation += rng(0, p.ranged_dex_mod());
deviation += rng(0, p.ranged_per_mod());
deviation += rng(0, 2 * p.encumb(bp_arms)) + rng(0, 4 * p.encumb(bp_eyes));
deviation += rng(0, weapon->curammo->dispersion);
// item::dispersion() doesn't support gunmods.
deviation += rng(0, p.weapon.dispersion());
int adj_recoil = p.recoil + p.driving_recoil;
deviation += rng(int(adj_recoil / 4), adj_recoil);
if (deviation < 0) { return 0; }
// .013 * trange is a computationally cheap version of finding the tangent.
// (note that .00325 * 4 = .013; .00325 is used because deviation is a number
// of quarter-degrees)
// It's also generous; missed_by will be rather short.
return (.00325 * deviation * trange);
}
开发者ID:CinghialeCdda,项目名称:Cataclysm-DDA,代码行数:32,代码来源:ranged.cpp
示例13: drop_on_map
void drop_on_map( const player &p, const std::list<item> &items, const tripoint &where )
{
if( items.empty() ) {
return;
}
const std::string ter_name = g->m.name( where );
const bool can_move_there = g->m.passable( where );
if( same_type( items ) ) {
const item &it = items.front();
const int dropcount = items.size() * ( it.count_by_charges() ? it.charges : 1 );
const std::string it_name = it.tname( dropcount );
if( can_move_there ) {
p.add_msg_player_or_npc(
ngettext( "You drop your %1$s on the %2$s.",
"You drop your %1$s on the %2$s.", dropcount ),
ngettext( "<npcname> drops their %1$s on the %2$s.",
"<npcname> drops their %1$s on the %2$s.", dropcount ),
it_name.c_str(), ter_name.c_str()
);
} else {
p.add_msg_player_or_npc(
ngettext( "You put your %1$s in the %2$s.",
"You put your %1$s in the %2$s.", dropcount ),
ngettext( "<npcname> puts their %1$s in the %2$s.",
"<npcname> puts their %1$s in the %2$s.", dropcount ),
it_name.c_str(), ter_name.c_str()
);
}
} else {
if( can_move_there ) {
p.add_msg_player_or_npc(
_( "You drop several items on the %s." ),
_( "<npcname> drops several items on the %s." ),
ter_name.c_str()
);
} else {
p.add_msg_player_or_npc(
_( "You put several items in the %s." ),
_( "<npcname> puts several items in the %s." ),
ter_name.c_str()
);
}
}
for( const auto &it : items ) {
g->m.add_item_or_charges( where, it );
}
}
开发者ID:ProfoundDarkness,项目名称:Cataclysm-DDA,代码行数:49,代码来源:activity_item_handling.cpp
示例14: attack_speed
int attack_speed(player &u, bool missed)
{
int move_cost = u.weapon.attack_time() + 20 * u.encumb(bp_torso);
if (u.has_trait(PF_LIGHT_BONES))
move_cost *= .9;
if (u.has_trait(PF_HOLLOW_BONES))
move_cost *= .8;
move_cost -= u.disease_intensity(DI_SPEED_BOOST);
if (move_cost < 25)
return 25;
return move_cost;
}
开发者ID:StoicDwarf,项目名称:Cataclysm-DDA,代码行数:15,代码来源:melee.cpp
示例15: absorb_water
void stomach_contents::absorb_water( player &p, units::volume amount )
{
if( water < amount ) {
amount = water;
water = 0_ml;
} else {
water -= amount;
}
if( p.get_thirst() < -100 ) {
return;
} else if( p.get_thirst() - units::to_milliliter( amount / 5 ) < -100 ) {
p.set_thirst( -100 );
}
p.mod_thirst( -units::to_milliliter( amount ) / 5 );
}
开发者ID:Robik81,项目名称:Cataclysm-DDA,代码行数:15,代码来源:stomach.cpp
示例16: turn
/*
* Determines whose turn it will be, and returns that player
*@ param player &a , player &b the players to be compared, using references
*
*/
player turn(player &a, player &b)
{
if(a.turn == 1)
{
a.setTurn(0);
b.setTurn(1);
return a;
}
else if(b.turn ==1)
{
a.setTurn(1);
b.setTurn(0);
return b;
}
}
开发者ID:rilethunder,项目名称:HW03,代码行数:20,代码来源:Game.cpp
示例17: test_consumable_charges
void test_consumable_charges( player &p, std::string &itemname, bool when_none, bool when_max )
{
item it = item( itemname, 0, 0 ) ;
INFO( "\'" + it.tname() + "\' is count-by-charges" );
CHECK( it.count_by_charges() );
it.charges = 0;
INFO( "consume \'" + it.tname() + "\' with " + std::to_string( it.charges ) + " charges" );
REQUIRE( p.can_consume( it ) == when_none );
it.charges = LONG_MAX;
INFO( "consume \'" + it.tname() + "\' with " + std::to_string( it.charges ) + " charges" );
REQUIRE( p.can_consume( it ) == when_max );
}
开发者ID:Barhandar,项目名称:Cataclysm-DDA,代码行数:15,代码来源:bionics_test.cpp
示例18: get_gate_id
void gates::open_gate( const tripoint &pos, player &p )
{
const gate_id gid = get_gate_id( pos );
if( !gates_data.is_valid( gid ) ) {
p.add_msg_if_player( _( "Nothing happens." ) );
return;
}
const gate_data &gate = gates_data.obj( gid );
p.add_msg_if_player( gate.pull_message.c_str() );
p.assign_activity( ACT_OPEN_GATE, gate.moves );
p.activity.placement = pos;
}
开发者ID:1942rob,项目名称:Cataclysm-DDA,代码行数:15,代码来源:gates.cpp
示例19: stack_invlet_test
void stack_invlet_test( player &dummy, inventory_location from, inventory_location to )
{
// invlet to assign
constexpr char invlet = '|';
// duplication will most likely only happen if the stack is in the inventory
// and is subsequently wielded or worn
if( from != INVENTORY || ( to != WORN && to != WIELDED_OR_WORN ) ) {
FAIL( "unimplemented" );
}
// remove all items
dummy.inv.clear();
dummy.worn.clear();
dummy.remove_weapon();
g->m.i_clear( dummy.pos() );
// some stackable item that can be wielded and worn
item tshirt( "tshirt" );
// add two such items to the starting position
add_item( dummy, tshirt, from );
add_item( dummy, tshirt, from );
// assign the stack with invlet
assign_invlet( dummy, item_at( dummy, 0, from ), invlet, CACHED );
// wield or wear one of the items
move_item( dummy, 0, from, to );
std::stringstream ss;
ss << "1. add a stack of two same items to " << location_desc( from ) << std::endl;
ss << "2. assign the stack with an invlet" << std::endl;
ss << "3. " << move_action_desc( 0, from, to ) << std::endl;
ss << "expect the two items to have different invlets" << std::endl;
ss << "actually the two items have " <<
( item_at( dummy, 0, to ).invlet != item_at( dummy, 0, from ).invlet ? "different" : "the same" ) <<
" invlets" << std::endl;
INFO( ss.str() );
REQUIRE( item_at( dummy, 0, from ).typeId() == tshirt.typeId() );
REQUIRE( item_at( dummy, 0, to ).typeId() == tshirt.typeId() );
// the wielded/worn item should have different invlet from the remaining item
CHECK( item_at( dummy, 0, to ).invlet != item_at( dummy, 0, from ).invlet );
// clear invlets
assign_invlet( dummy, item_at( dummy, 0, from ), invlet, NONE );
assign_invlet( dummy, item_at( dummy, 0, to ), invlet, NONE );
}
开发者ID:BevapDin,项目名称:Cataclysm-DDA,代码行数:48,代码来源:invlet_test.cpp
示例20: try_refuel_fire
void player_activity::do_turn( player &p )
{
// Should happen before activity or it may fail du to 0 moves
if( *this && type->will_refuel_fires() ) {
try_refuel_fire( p );
}
if( type->based_on() == based_on_type::TIME ) {
moves_left -= 100;
} else if( type->based_on() == based_on_type::SPEED ) {
if( p.moves <= moves_left ) {
moves_left -= p.moves;
p.moves = 0;
} else {
p.moves -= moves_left;
moves_left = 0;
}
}
// This might finish the activity (set it to null)
type->call_do_turn( this, &p );
if( *this && type->rooted() ) {
p.rooted();
p.pause();
}
if( *this && moves_left <= 0 ) {
// Note: For some activities "finish" is a misnomer; that's why we explicitly check if the
// type is ACT_NULL below.
if( !( type->call_finish( this, &p ) ) ) {
// "Finish" is never a misnomer for any activity without a finish function
set_to_null();
}
}
if( !*this ) {
// Make sure data of previous activity is cleared
p.activity = player_activity();
if( !p.backlog.empty() && p.backlog.front().auto_resume ) {
p.activity = p.backlog.front();
p.backlog.pop_front();
}
// If whatever activity we were doing forced us to pick something up to
// handle it, drop any overflow that may have caused
p.drop_invalid_inventory();
}
}
开发者ID:BevapDin,项目名称:Cataclysm-DDA,代码行数:48,代码来源:player_activity.cpp
注:本文中的player类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论