本文整理汇总了C++中monster::get_weight方法的典型用法代码示例。如果您正苦于以下问题:C++ monster::get_weight方法的具体用法?C++ monster::get_weight怎么用?C++ monster::get_weight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类monster
的用法示例。
在下文中一共展示了monster::get_weight方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: splatter
void mdeath::splatter( monster &z )
{
const bool gibbable = !z.type->has_flag( MF_NOGIB );
const int max_hp = std::max( z.get_hp_max(), 1 );
const float overflow_damage = std::max( -z.get_hp(), 0 );
const float corpse_damage = 2.5 * overflow_damage / max_hp;
bool pulverized = corpse_damage > 5 && overflow_damage > z.get_hp_max();
// make sure that full splatter happens when this is a set death function, not part of normal
for( const auto &deathfunction : z.type->dies ) {
if( deathfunction == mdeath::splatter ) {
pulverized = true;
}
}
const field_id type_blood = z.bloodType();
const field_id type_gib = z.gibType();
if( gibbable ) {
const auto area = g->m.points_in_radius( z.pos(), 1 );
int number_of_gibs = std::min( std::floor( corpse_damage ) - 1, 1 + max_hp / 5.0f );
if( pulverized && z.type->size >= MS_MEDIUM ) {
number_of_gibs += rng( 1, 6 );
sfx::play_variant_sound( "mon_death", "zombie_gibbed", sfx::get_heard_volume( z.pos() ) );
}
for( int i = 0; i < number_of_gibs; ++i ) {
g->m.add_splatter( type_gib, random_entry( area ), rng( 1, i + 1 ) );
g->m.add_splatter( type_blood, random_entry( area ) );
}
}
// 1% of the weight of the monster is the base, with overflow damage as a multiplier
int gibbed_weight = rng( 0, round( to_gram( z.get_weight() ) / 100 *
( overflow_damage / max_hp + 1 ) ) );
// limit gibbing to 15%
gibbed_weight = std::min( gibbed_weight, to_gram( z.get_weight() ) * 15 / 100 );
if( pulverized && gibbable ) {
float overflow_ratio = overflow_damage / max_hp + 1;
int gib_distance = round( rng( 2, 4 ) );
for( const auto &entry : *z.type->harvest ) {
// only flesh and bones survive.
if( entry.type == "flesh" || entry.type == "bone" ) {
// the larger the overflow damage, the less you get
const int chunk_amt = entry.mass_ratio / overflow_ratio / 10 * to_gram(
z.get_weight() ) / to_gram( ( item::find_type( entry.drop ) )->weight );
scatter_chunks( entry.drop, chunk_amt, z, gib_distance, chunk_amt / ( gib_distance - 1 ) );
gibbed_weight -= entry.mass_ratio / overflow_ratio / 20 * to_gram( z.get_weight() );
}
}
if( gibbed_weight > 0 ) {
scatter_chunks( "ruined_chunks",
gibbed_weight / to_gram( ( item::find_type( "ruined_chunks" ) ) ->weight ), z, gib_distance,
gibbed_weight / to_gram( ( item::find_type( "ruined_chunks" ) )->weight ) / ( gib_distance + 1 ) );
}
// add corpse with gib flag
item corpse = item::make_corpse( z.type->id, calendar::turn, z.unique_name );
// Set corpse to damage that aligns with being pulped
corpse.set_damage( 4000 );
corpse.set_flag( "GIBBED" );
if( z.has_effect( effect_no_ammo ) ) {
corpse.set_var( "no_ammo", "no_ammo" );
}
g->m.add_item_or_charges( z.pos(), corpse );
}
}