本文整理汇总了C++中monster::mod_moves方法的典型用法代码示例。如果您正苦于以下问题:C++ monster::mod_moves方法的具体用法?C++ monster::mod_moves怎么用?C++ monster::mod_moves使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类monster
的用法示例。
在下文中一共展示了monster::mod_moves方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: call
bool bite_actor::call( monster &z ) const
{
if( !z.can_act() ) {
return false;
}
Creature *target = z.attack_target();
if( target == nullptr || !is_adjacent( z, *target ) ) {
return false;
}
z.mod_moves( -move_cost );
add_msg( m_debug, "%s attempting to bite %s", z.name().c_str(), target->disp_name().c_str() );
int hitspread = target->deal_melee_attack( &z, z.hit_roll() );
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, _( "The %s lunges at you, but you dodge!" ),
_( "The %s lunges at <npcname>, but they dodge!" ),
z.name().c_str() );
return true;
}
damage_instance damage = damage_max_instance;
dealt_damage_instance dealt_damage;
body_part hit;
double multiplier = rng_float( min_mul, max_mul );
damage.mult_damage( multiplier );
target->deal_melee_hit( &z, hitspread, false, damage, dealt_damage );
hit = dealt_damage.bp_hit;
int damage_total = dealt_damage.total_damage();
add_msg( m_debug, "%s's bite did %d damage", z.name().c_str(), damage_total );
if( damage_total > 0 ) {
auto msg_type = target == &g->u ? m_bad : m_info;
//~ 1$s is monster name, 2$s bodypart in accusative
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 ), 0 );
}
target->add_msg_player_or_npc( msg_type,
_( "The %1$s bites your %2$s!" ),
_( "The %1$s bites <npcname>'s %2$s!" ),
z.name().c_str(),
body_part_name_accusative( hit ).c_str() );
if( one_in( no_infection_chance - damage_total ) ) {
if( target->has_effect( effect_bite, hit ) ) {
target->add_effect( effect_bite, 400, hit, true );
} else if( target->has_effect( effect_infected, hit ) ) {
target->add_effect( effect_infected, 250, hit, true );
} else {
target->add_effect( effect_bite, 1, hit, true );
}
}
} 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( _( "The %1$s bites your %2$s, but fails to penetrate armor!" ),
_( "The %1$s bites <npcname>'s %2$s, but fails to penetrate armor!" ),
z.name().c_str(),
body_part_name_accusative( hit ).c_str() );
}
return true;
}