本文整理汇总了C++中monster::name方法的典型用法代码示例。如果您正苦于以下问题:C++ monster::name方法的具体用法?C++ monster::name怎么用?C++ monster::name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类monster
的用法示例。
在下文中一共展示了monster::name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: worm
void mdeath::worm( monster &z )
{
if( g->u.sees( z ) ) {
if( z.type->dies.size() == 1 ) {
add_msg( m_good, _( "The %s splits in two!" ), z.name() );
} else {
add_msg( m_warning, _( "Two worms crawl out of the %s's corpse." ), z.name() );
}
}
std::vector <tripoint> wormspots;
for( auto &&wormp : g->m.points_in_radius( z.pos(), 1 ) ) { // *NOPAD*
if( g->m.has_flag( "DIGGABLE", wormp ) && g->is_empty( wormp ) ) {
wormspots.push_back( wormp );
}
}
int worms = 0;
while( worms < 2 && !wormspots.empty() ) {
const tripoint target = random_entry_removed( wormspots );
if( !g->critter_at( target ) ) {
g->summon_mon( mon_halfworm, target );
worms++;
}
}
}
示例2: blobsplit
void mdeath::blobsplit( monster &z )
{
int speed = z.get_speed() - rng( 30, 50 );
g->m.spawn_item( z.pos(), "slime_scrap", 1, 0, calendar::turn );
if( z.get_speed() <= 0 ) {
if( g->u.sees( z ) ) {
// TODO: Add vermin-tagged tiny versions of the splattered blob :)
add_msg( m_good, _( "The %s splatters apart." ), z.name() );
}
return;
}
if( g->u.sees( z ) ) {
if( z.type->dies.size() == 1 ) {
add_msg( m_good, _( "The %s splits in two!" ), z.name() );
} else {
add_msg( m_bad, _( "Two small blobs slither out of the corpse." ) );
}
}
std::vector <tripoint> valid;
for( auto &&dest : g->m.points_in_radius( z.pos(), 1 ) ) { // *NOPAD*
if( g->is_empty( dest ) && z.can_move_to( dest ) ) {
valid.push_back( dest );
}
}
for( int s = 0; s < 2 && !valid.empty(); s++ ) {
const tripoint target = random_entry_removed( valid );
if( monster *const blob = g->summon_mon( speed < 50 ? mon_blob_small : mon_blob, target ) ) {
blob->make_ally( z );
blob->set_speed_base( speed );
blob->set_hp( speed );
}
}
}
示例3: acid
void mdeath::acid( monster &z )
{
if( g->u.sees( z ) ) {
if( z.type->dies.size() ==
1 ) { //If this death function is the only function. The corpse gets dissolved.
add_msg( m_mixed, _( "The %s's body dissolves into acid." ), z.name() );
} else {
add_msg( m_warning, _( "The %s's body leaks acid." ), z.name() );
}
}
g->m.add_field( z.pos(), fd_acid, 3 );
}
示例4: call
bool melee_actor::call( monster &z ) const
{
Creature *target = find_target( z );
if( target == nullptr ) {
return false;
}
z.mod_moves( -move_cost );
add_msg( m_debug, "%s attempting to melee_attack %s", z.name().c_str(),
target->disp_name().c_str() );
const int acc = accuracy >= 0 ? accuracy : z.type->melee_skill;
int hitspread = target->deal_melee_attack( &z, dice( acc, 10 ) );
if( hitspread < 0 ) {
auto msg_type = target == &g->u ? m_warning : m_info;
sfx::play_variant_sound( "mon_bite", "bite_miss", sfx::get_heard_volume( z.pos() ),
sfx::get_heard_angle( z.pos() ) );
target->add_msg_player_or_npc( msg_type, miss_msg_u.c_str(), miss_msg_npc.c_str(),
z.name().c_str() );
return true;
}
damage_instance damage = damage_max_instance;
double multiplier = rng_float( min_mul, max_mul );
damage.mult_damage( multiplier );
body_part bp_hit = body_parts.empty() ?
target->select_body_part( &z, hitspread ) :
*body_parts.pick();
target->on_hit( &z, bp_hit );
dealt_damage_instance dealt_damage = target->deal_damage( &z, bp_hit, damage );
dealt_damage.bp_hit = bp_hit;
int damage_total = dealt_damage.total_damage();
add_msg( m_debug, "%s's melee_attack did %d damage", z.name().c_str(), damage_total );
if( damage_total > 0 ) {
on_damage( z, *target, dealt_damage );
} else {
sfx::play_variant_sound( "mon_bite", "bite_miss", sfx::get_heard_volume( z.pos() ),
sfx::get_heard_angle( z.pos() ) );
target->add_msg_player_or_npc( no_dmg_msg_u.c_str(), no_dmg_msg_npc.c_str(), z.name().c_str(),
body_part_name_accusative( bp_hit ).c_str() );
}
return true;
}
示例5: 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;
}
示例6: boomer_glow
void mdeath::boomer_glow( monster &z )
{
std::string explode = string_format( _( "a %s explode!" ), z.name() );
sounds::sound( z.pos(), 24, sounds::sound_t::combat, explode, false, "explosion", "small" );
for( auto &&dest : g->m.points_in_radius( z.pos(), 1 ) ) { // *NOPAD*
g->m.bash( dest, 10 );
if( monster *const z = g->critter_at<monster>( dest ) ) {
z->stumble();
z->moves -= 250;
}
if( Creature *const critter = g->critter_at( dest ) ) {
critter->add_env_effect( effect_boomered, bp_eyes, 5, 25_turns );
for( int i = 0; i < rng( 2, 4 ); i++ ) {
body_part bp = random_body_part();
critter->add_env_effect( effect_glowing, bp, 4, 4_minutes );
if( critter != nullptr && critter->has_effect( effect_glowing ) ) {
break;
}
}
}
}
g->m.propagate_field( z.pos(), fd_bile, 30, 2 );
}
示例7: zapback
void mdefense::zapback( monster &m, Creature *const source,
dealt_projectile_attack const *const proj )
{
// Not a melee attack, attacker lucked out or out of range
if( source == nullptr || proj != nullptr ||
rng( 0, 100 ) > m.def_chance || rl_dist( m.pos(), source->pos() ) > 1 ) {
return;
}
if( source->is_elec_immune() ) {
return;
}
// Players/NPCs can avoid the shock by using non-conductive weapons
player const *const foe = dynamic_cast<player *>( source );
if( foe != nullptr && !foe->weapon.conductive() && !foe->unarmed_attack() ) {
return;
}
damage_instance const shock {
DT_ELECTRIC, static_cast<float>( rng( 1, 5 ) )
};
source->deal_damage( &m, bp_arm_l, shock );
source->deal_damage( &m, bp_arm_r, shock );
if( g->u.sees( source->pos() ) ) {
auto const msg_type = ( source == &g->u ) ? m_bad : m_info;
add_msg( msg_type, _( "Striking the %1$s shocks %2$s!" ),
m.name().c_str(), source->disp_name().c_str() );
}
source->check_dead_state();
}
示例8: darkman
void mdeath::darkman( monster &z )
{
g->u.remove_effect( effect_darkness );
if( g->u.sees( z ) ) {
add_msg( m_good, _( "The %s melts away." ), z.name() );
}
}
示例9: broken_ammo
void mdeath::broken_ammo( monster &z )
{
if( g->u.sees( z.pos() ) ) {
//~ %s is the possessive form of the monster's name
add_msg( m_info, _( "The %s's interior compartment sizzles with destructive energy." ),
z.name() );
}
mdeath::broken( z );
}
示例10: conflagration
void mdeath::conflagration( monster &z )
{
for( const auto &dest : g->m.points_in_radius( z.pos(), 1 ) ) {
g->m.propagate_field( dest, fd_fire, 18, 3 );
}
const std::string explode = string_format( _( "a %s explode!" ), z.name() );
sounds::sound( z.pos(), 24, sounds::sound_t::combat, explode, false, "explosion", "small" );
}
示例11: fireball
void mdeath::fireball( monster &z )
{
if( one_in( 10 ) ) {
g->m.propagate_field( z.pos(), fd_fire, 15, 3 );
std::string explode = string_format( _( "an explosion of tank of the %s's flamethrower!" ),
z.name() );
sounds::sound( z.pos(), 24, sounds::sound_t::combat, explode, false, "explosion", "default" );
add_msg( m_good, _( "I love the smell of burning zed in the morning." ) );
} else {
normal( z );
}
}
示例12: remove
void Creature_tracker::remove( const monster &critter )
{
const auto iter = std::find_if( monsters_list.begin(), monsters_list.end(),
[&]( const std::shared_ptr<monster> &ptr ) {
return ptr.get() == &critter;
} );
if( iter == monsters_list.end() ) {
debugmsg( "Tried to remove invalid monster %s", critter.name() );
return;
}
remove_from_location_map( critter );
monsters_list.erase( iter );
}
示例13: broken
void mdeath::broken( monster &z ) {
// Bail out if flagged (simulates eyebot flying away)
if( z.no_corpse_quiet ) {
return;
}
std::string item_id = z.type->id.str();
if (item_id.compare(0, 4, "mon_") == 0) {
item_id.erase(0, 4);
}
// make "broken_manhack", or "broken_eyebot", ...
item_id.insert(0, "broken_");
g->m.spawn_item( z.pos(), item_id, 1, 0, calendar::turn );
if( g->u.sees( z.pos() ) ) {
add_msg( m_good, _( "The %s collapses!" ), z.name().c_str() );
}
}
示例14: boomer
void mdeath::boomer( monster &z )
{
std::string explode = string_format( _( "a %s explode!" ), z.name() );
sounds::sound( z.pos(), 24, sounds::sound_t::combat, explode, false, "explosion", "small" );
for( auto &&dest : g->m.points_in_radius( z.pos(), 1 ) ) { // *NOPAD*
g->m.bash( dest, 10 );
if( monster *const z = g->critter_at<monster>( dest ) ) {
z->stumble();
z->moves -= 250;
}
}
if( rl_dist( z.pos(), g->u.pos() ) == 1 ) {
g->u.add_env_effect( effect_boomered, bp_eyes, 2, 24_turns );
}
g->m.propagate_field( z.pos(), fd_bile, 15, 1 );
}
示例15: on_damage
void melee_actor::on_damage( monster &z, Creature &target, dealt_damage_instance &dealt ) const
{
if( target.is_player() ) {
sfx::play_variant_sound( "mon_bite", "bite_hit", sfx::get_heard_volume( z.pos() ),
sfx::get_heard_angle( z.pos() ) );
sfx::do_player_death_hurt( dynamic_cast<player &>( target ), false );
}
auto msg_type = target.attitude_to( g->u ) == Creature::A_FRIENDLY ? m_bad : m_neutral;
const body_part bp = dealt.bp_hit;
target.add_msg_player_or_npc( msg_type, hit_dmg_u, hit_dmg_npc, z.name(),
body_part_name_accusative( bp ) );
for( const auto &eff : effects ) {
if( x_in_y( eff.chance, 100 ) ) {
const body_part affected_bp = eff.affect_hit_bp ? bp : eff.bp;
target.add_effect( eff.id, time_duration::from_turns( eff.duration ), affected_bp, eff.permanent );
}
}
}