Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix debugmsgs on dying critters #1387

Merged
merged 1 commit into from
Mar 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ void Creature::reset()

void Creature::bleed() const
{
g->m.add_splatter( bloodType(), pos() );
const field_type_id &blood_type = bloodType();
if( blood_type ) {
get_map().add_splatter( blood_type, pos() );
}
}

void Creature::reset_bonuses()
Expand Down
13 changes: 9 additions & 4 deletions src/mondeath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ static void scatter_chunks( const itype_id &chunk_name, int chunk_amt, monster &

void mdeath::splatter( monster &z )
{
map &here = get_map();
const bool gibbable = !z.type->has_flag( MF_NOGIB );

const int max_hp = std::max( z.get_hp_max(), 1 );
Expand All @@ -183,7 +184,7 @@ void mdeath::splatter( monster &z )
const field_type_id type_gib = z.gibType();

if( gibbable ) {
const auto area = g->m.points_in_radius( z.pos(), 1 );
const auto area = here.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 ) {
Expand All @@ -192,8 +193,12 @@ void mdeath::splatter( monster &z )
}

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 ) );
if( type_blood ) {
here.add_splatter( type_gib, random_entry( area ), rng( 1, i + 1 ) );
}
if( type_gib ) {
here.add_splatter( type_blood, random_entry( area ) );
}
}
}
// 1% of the weight of the monster is the base, with overflow damage as a multiplier
Expand Down Expand Up @@ -226,7 +231,7 @@ void mdeath::splatter( monster &z )
if( z.has_effect( effect_no_ammo ) ) {
corpse.set_var( "no_ammo", "no_ammo" );
}
g->m.add_item_or_charges( z.pos(), corpse );
here.add_item_or_charges( z.pos(), corpse );
}
}

Expand Down