本文整理汇总了C++中monster::posz方法的典型用法代码示例。如果您正苦于以下问题:C++ monster::posz方法的具体用法?C++ monster::posz怎么用?C++ monster::posz使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类monster
的用法示例。
在下文中一共展示了monster::posz方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: add
bool Creature_tracker::add( monster &critter )
{
if( critter.type->id.is_null() ) { // Don't wanna spawn null monsters o.O
return false;
}
if( critter.type->has_flag( MF_VERMIN ) ) {
// Don't spawn vermin, they aren't implemented yet
return false;
}
const int critter_id = mon_at( critter.pos() );
if( critter_id != -1 ) {
// We can spawn stuff on hallucinations, but we need to kill them first
if( monsters_list[critter_id]->is_hallucination() ) {
monsters_list[critter_id]->die( nullptr );
// But don't remove - that would change the monster order and could segfault
} else if( critter.is_hallucination() ) {
return false;
} else {
debugmsg( "add_zombie: there's already a monster at %d,%d,%d",
critter.posx(), critter.posy(), critter.posz() );
return false;
}
}
if( MonsterGroupManager::monster_is_blacklisted( critter.type->id ) ) {
return false;
}
monsters_by_location[critter.pos()] = monsters_list.size();
monsters_list.push_back( new monster( critter ) );
return true;
}
示例2: focused_beam
void mdeath::focused_beam( monster &z )
{
for( int k = g->m.i_at( z.pos() ).size() - 1; k >= 0; k-- ) {
if( g->m.i_at( z.pos() )[k].typeId() == "processor" ) {
g->m.i_rem( z.pos(), k );
}
}
if( !z.inv.empty() ) {
if( g->u.sees( z ) ) {
add_msg( m_warning, _( "As the final light is destroyed, it erupts in a blinding flare!" ) );
}
item &settings = z.inv[0];
int x = z.posx() + settings.get_var( "SL_SPOT_X", 0 );
int y = z.posy() + settings.get_var( "SL_SPOT_Y", 0 );
tripoint p( x, y, z.posz() );
std::vector <tripoint> traj = line_to( z.pos(), p, 0, 0 );
for( auto &elem : traj ) {
if( !g->m.trans( elem ) ) {
break;
}
g->m.add_field( elem, fd_dazzling, 2 );
}
}
z.inv.clear();
explosion_handler::explosion( z.pos(), 8 );
}
示例3: add
bool Creature_tracker::add( monster &critter )
{
if( critter.type->id.is_null() ) { // Don't want to spawn null monsters o.O
return false;
}
if( critter.type->has_flag( MF_VERMIN ) ) {
// Don't spawn vermin, they aren't implemented yet
return false;
}
if( const std::shared_ptr<monster> existing_mon_ptr = find( critter.pos() ) ) {
// We can spawn stuff on hallucinations, but we need to kill them first
if( existing_mon_ptr->is_hallucination() ) {
existing_mon_ptr->die( nullptr );
// But don't remove - that would change the monster order and could segfault
} else if( critter.is_hallucination() ) {
return false;
} else {
debugmsg( "add_zombie: there's already a monster at %d,%d,%d",
critter.posx(), critter.posy(), critter.posz() );
return false;
}
}
if( MonsterGroupManager::monster_is_blacklisted( critter.type->id ) ) {
return false;
}
monsters_list.emplace_back( std::make_shared<monster>( critter ) );
monsters_by_location[critter.pos()] = monsters_list.back();
return true;
}
示例4: is_adjacent
// Simplified version of the function in monattack.cpp
bool is_adjacent( const monster &z, const Creature &target )
{
if( rl_dist( z.pos(), target.pos() ) != 1 ) {
return false;
}
return z.posz() == target.posz();
}
示例5: add
bool Creature_tracker::add( monster &critter )
{
if( critter.type->id == "mon_null" ) { // Don't wanna spawn null monsters o.O
return false;
}
if( -1 != mon_at( critter.pos3() ) ) {
debugmsg( "add_zombie: there's already a monster at %d,%d,%d",
critter.posx(), critter.posy(), critter.posz() );
return false;
}
if( monster_is_blacklisted(critter.type) ) {
return false;
}
monsters_by_location[critter.pos3()] = monsters_list.size();
monsters_list.push_back(new monster(critter));
return true;
}
示例6: vine_cut
void mdeath::vine_cut( monster &z )
{
std::vector<monster *> vines;
for( const tripoint &tmp : g->m.points_in_radius( z.pos(), 1 ) ) {
if( tmp == z.pos() ) {
continue; // Skip ourselves
}
if( monster *const z = g->critter_at<monster>( tmp ) ) {
if( z->type->id == mon_creeper_vine ) {
vines.push_back( z );
}
}
}
for( auto &vine : vines ) {
bool found_neighbor = false;
tripoint tmp = vine->pos();
int &x = tmp.x;
int &y = tmp.y;
for( x = vine->posx() - 1; x <= vine->posx() + 1 && !found_neighbor; x++ ) {
for( y = vine->posy() - 1; y <= vine->posy() + 1 && !found_neighbor; y++ ) {
if( x != z.posx() || y != z.posy() ) {
// Not the dying vine
if( monster *const v = g->critter_at<monster>( { x, y, z.posz() } ) ) {
if( v->type->id == mon_creeper_hub || v->type->id == mon_creeper_vine ) {
found_neighbor = true;
}
}
}
}
}
if( !found_neighbor ) {
vine->die( &z );
}
}
}