本文整理汇总了C++中player::get_skill_level方法的典型用法代码示例。如果您正苦于以下问题:C++ player::get_skill_level方法的具体用法?C++ player::get_skill_level怎么用?C++ player::get_skill_level使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类player
的用法示例。
在下文中一共展示了player::get_skill_level方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: detect_trap
bool trap::detect_trap( const tripoint &pos, const player &p ) const
{
// Some decisions are based around:
// * Starting, and thus average perception, is 8.
// * Buried landmines, the silent killer, has a visibility of 10.
// * There will always be a distance malus of 1 unless you're on top of the trap.
// * ...and an average character should at least have a minor chance of
// noticing a buried landmine if standing right next to it.
// Effective Perception...
///\EFFECT_PER increases chance of detecting a trap
return ( p.per_cur - ( p.encumb( bp_eyes ) / 10 ) ) +
// ...small bonus from stimulants...
( p.stim > 10 ? rng( 1, 2 ) : 0 ) +
// ...bonus from trap skill...
///\EFFECT_TRAPS increases chance of detecting a trap
( p.get_skill_level( skill_traps ) * 2 ) +
// ...luck, might be good, might be bad...
rng( -4, 4 ) -
// ...malus if we are tired...
( p.has_effect( effect_lack_sleep ) ? rng( 1, 5 ) : 0 ) -
// ...malus farther we are from trap...
rl_dist( p.pos(), pos ) +
// Police are trained to notice Something Wrong.
( p.has_trait( trait_id( "PROF_POLICE" ) ) ? 1 : 0 ) +
( p.has_trait( trait_id( "PROF_PD_DET" ) ) ? 2 : 0 ) >
// ...must all be greater than the trap visibility.
visibility;
}
示例2: is_valid_player
bool ma_requirements::is_valid_player( const player &u ) const
{
for( const 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( bionic_id( "bio_cqb" ) );
// There are 4 different cases of "armedness":
// Truly unarmed, unarmed weapon, style-allowed weapon, generic weapon
bool valid_weapon =
( unarmed_allowed && u.unarmed_attack() &&
( !strictly_unarmed || !u.is_armed() ) ) ||
( is_valid_weapon( u.weapon ) &&
( melee_allowed || u.style_selected.obj().has_weapon( u.weapon.typeId() ) ) );
if( !valid_weapon ) {
return false;
}
for( const auto &pr : min_skill ) {
if( ( cqb ? 5 : (int)u.get_skill_level( pr.first ) ) < pr.second ) {
return false;
}
}
return true;
}
示例3: string_format
read_inventory_preset( const player &p ) : pickup_inventory_preset( p ), p( p ) {
static const std::string unknown( _( "<color_dkgray>?</color>" ) );
static const std::string martial_arts( _( "martial arts" ) );
append_cell( [ this, &p ]( const item_location & loc ) -> std::string {
if( loc->type->can_use( "MA_MANUAL" ) ) {
return martial_arts;
}
if( !is_known( loc ) ) {
return unknown;
}
const auto &book = get_book( loc );
if( book.skill && p.get_skill_level( book.skill ).can_train() ) {
return string_format( _( "%s to %d" ), book.skill->name().c_str(), book.level );
}
return std::string();
}, _( "TRAINS" ), unknown );
append_cell( [ this ]( const item_location & loc ) -> std::string {
if( !is_known( loc ) ) {
return unknown;
}
const auto &book = get_book( loc );
const int unlearned = book.recipes.size() - get_known_recipes( book );
return unlearned > 0 ? to_string( unlearned ) : std::string();
}, _( "RECIPES" ), unknown );
append_cell( [ this ]( const item_location & loc ) -> std::string {
if( !is_known( loc ) ) {
return unknown;
}
const int fun = get_book( loc ).fun;
if( fun > 0 ) {
return string_format( "<good>+%d</good>", fun );
} else if( fun < 0 ) {
return string_format( "<bad>%d</bad>", fun );
}
return std::string();
}, _( "FUN" ), unknown );
append_cell( [ this, &p ]( const item_location & loc ) -> std::string {
if( !is_known( loc ) ) {
return unknown;
}
std::vector<std::string> dummy;
const player *reader = p.get_book_reader( *loc, dummy );
if( reader == nullptr ) {
return std::string(); // Just to make sure
}
// Actual reading time (in turns). Can be penalized.
const int actual_turns = p.time_to_read( *loc, *reader ) / MOVES( 1 );
// Theoretical reading time (in turns) based on the reader speed. Free of penalties.
const int normal_turns = get_book( loc ).time * reader->read_speed() / MOVES( 1 );
const std::string duration = calendar( actual_turns ).textify_period();
if( actual_turns > normal_turns ) { // Longer - complicated stuff.
return string_format( "<color_ltred>%s</color>", duration.c_str() );
}
return duration; // Normal speed.
}, _( "CHAPTER IN" ), unknown );
}