本文整理汇总了C++中monster::sees方法的典型用法代码示例。如果您正苦于以下问题:C++ monster::sees方法的具体用法?C++ monster::sees怎么用?C++ monster::sees使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类monster
的用法示例。
在下文中一共展示了monster::sees方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: call
bool gun_actor::call( monster &z ) const
{
Creature *target;
if( z.friendly != 0 ) {
// Attacking monsters, not the player!
int boo_hoo;
target = z.auto_find_hostile_target( range, boo_hoo );
if( target == nullptr ) {
// Couldn't find any targets!
if( boo_hoo > 0 && g->u.sees( z ) ) {
// because that stupid oaf was in the way!
add_msg( m_warning, ngettext( "Pointed in your direction, the %s emits an IFF warning beep.",
"Pointed in your direction, the %s emits %d annoyed sounding beeps.",
boo_hoo ),
z.name().c_str(), boo_hoo );
}
return false;
}
shoot( z, *target );
return true;
}
// Not friendly; hence, firing at the player too
target = z.attack_target();
if( target == nullptr || rl_dist( z.pos(), target->pos() ) > range ||
!z.sees( *target ) ) {
return false;
}
shoot( z, *target );
return true;
}
示例2: call
bool gun_actor::call( monster &z ) const
{
Creature *target;
if( z.friendly ) {
int max_range = 0;
for( const auto &e : ranges ) {
max_range = std::max( std::max( max_range, e.first.first ), e.first.second );
}
int hostiles; // hostiles which cannot be engaged without risking friendly fire
target = z.auto_find_hostile_target( max_range, hostiles );
if( !target ) {
if( hostiles > 0 && g->u.sees( z ) ) {
add_msg( m_warning, ngettext( "Pointed in your direction, the %s emits an IFF warning beep.",
"Pointed in your direction, the %s emits %d annoyed sounding beeps.",
hostiles ),
z.name(), hostiles );
}
return false;
}
} else {
target = z.attack_target();
if( !target || !z.sees( *target ) ) {
return false;
}
}
int dist = rl_dist( z.pos(), target->pos() );
for( const auto &e : ranges ) {
if( dist >= e.first.first && dist <= e.first.second ) {
shoot( z, *target, e.second );
return true;
}
}
return false;
}