本文整理汇总了C++中player::get_str方法的典型用法代码示例。如果您正苦于以下问题:C++ player::get_str方法的具体用法?C++ player::get_str怎么用?C++ player::get_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类player
的用法示例。
在下文中一共展示了player::get_str方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wield_check_internal
void wield_check_internal( player &dummy, item &the_item, const char *section_text,
const std::string &var_name, int expected_cost )
{
dummy.weapon = dummy.ret_null;
dummy.set_moves( 1000 );
int old_moves = dummy.moves;
dummy.wield( the_item );
int move_cost = old_moves - dummy.moves;
if( expected_cost < 0 ) {
printf( " wield_check( %s, dummy, %s, %d );\n", section_text, var_name.c_str(), move_cost );
} else {
INFO( "Strength:" << dummy.get_str() );
int max_cost = expected_cost * 1.1f;
int min_cost = expected_cost * 0.9f;
CHECK( move_cost <= max_cost );
CHECK( move_cost >= min_cost );
}
}
示例2: place_player
void start_location::place_player( player &u ) const
{
// Need the "real" map with it's inside/outside cache and the like.
map &m = g->m;
// Start us off somewhere in the center of the map
u.setx( SEEX * int( MAPSIZE / 2 ) + 5 );
u.sety( SEEY * int( MAPSIZE / 2 ) + 6 );
u.setz( g->get_levz() );
m.build_map_cache( m.get_abs_sub().z );
const bool must_be_inside = flags().count( "ALLOW_OUTSIDE" ) == 0;
///\EFFECT_STR allows player to start behind less-bashable furniture and terrain
const int bash = u.get_str(); // TODO: Allow using items here
// Remember biggest found location
// Sometimes it may be impossible to automatically found an ideal location
// but the player may be more creative than this algorithm and do away with just "good"
int best_rate = 0;
// In which attempt did this area get checked?
// We can overwrite earlier attempts, but not start in them
int checked[SEEX * MAPSIZE][SEEY * MAPSIZE];
std::fill_n( &checked[0][0], SEEX * MAPSIZE * SEEY * MAPSIZE, 0 );
bool found_good_spot = false;
// Try some random points at start
int tries = 0;
const auto check_spot = [&]( const tripoint & pt ) {
tries++;
const int rate = rate_location( m, pt, must_be_inside, bash, tries, checked );
if( best_rate < rate ) {
best_rate = rate;
u.setpos( pt );
if( rate == INT_MAX ) {
found_good_spot = true;
}
}
};
while( !found_good_spot && tries < 100 ) {
tripoint rand_point( ( SEEX * int( MAPSIZE / 2 ) ) + rng( 0, SEEX * 2 ),
( SEEY * int( MAPSIZE / 2 ) ) + rng( 0, SEEY * 2 ),
u.posz() );
check_spot( rand_point );
}
// If we haven't got a good location by now, screw it and brute force it
// This only happens in exotic locations (deep of a science lab), but it does happen
if( !found_good_spot ) {
tripoint tmp = u.pos();
int &x = tmp.x;
int &y = tmp.y;
for( x = 0; x < SEEX * MAPSIZE; x++ ) {
for( y = 0; y < SEEY * MAPSIZE; y++ ) {
check_spot( tmp );
}
}
}
if( !found_good_spot ) {
debugmsg( "Could not find a good starting place for character" );
}
}