Skip to content

Commit

Permalink
DungGine.h:
Browse files Browse the repository at this point in the history
* Better splashing effect when some NPC that flies over the water falls down (e.g. a dragon). See #55.
  • Loading branch information
razterizer committed Oct 5, 2024
1 parent 2f26855 commit 61cf750
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions DungGine.h
Original file line number Diff line number Diff line change
Expand Up @@ -1385,7 +1385,7 @@ namespace dung
{
bool swimming = is_wet(npc.on_terrain) && npc.can_swim && !npc.can_fly;
bool dead_on_liquid = npc.health <= 0 && swimming;
if (!dead_on_liquid || sim_time_s - npc.death_time_s < 1.5f)
if (!dead_on_liquid || sim_time_s - npc.death_time_s < 1.5f + (npc.can_fly ? 0.5f : 0.f))
f_render_item(npc);

if (npc.visible && is_wet(npc.on_terrain))
Expand All @@ -1398,11 +1398,38 @@ namespace dung
}
else if (npc.health <= 0)
{
if (math::in_range<float>(sim_time_s - npc.death_time_s, 0.5f, 1.f, Range::Closed))
float time_delay = 0.f;
if (npc.can_fly)
{
if (math::in_range<float>(sim_time_s - npc.death_time_s, 1.f, 1.5f, Range::Closed))
{
// ***
// * *
// ***
for (int r_offs = -1; r_offs <= +1; ++r_offs)
for (int c_offs = -2; c_offs <= +2; ++c_offs)
{
if (r_offs != 0 && std::abs(c_offs) == 2)
continue;
if (r_offs == 0 && std::abs(c_offs) < 2)
continue;
if (r_offs == 0 && c_offs == 0)
continue;
RC offs_pos { r_offs, c_offs };
RC npc_scr_offs_pos = npc_scr_pos + offs_pos;
RC npc_world_offs_pos = npc.pos + offs_pos;
if (m_environment->is_inside_any_room(npc_world_offs_pos))
sh.write_buffer("*", npc_scr_offs_pos.r, npc_scr_offs_pos.c, Color::White, Color::Transparent2);
}
}
}
if (math::in_range<float>(sim_time_s - npc.death_time_s - time_delay, 0.5f, 1.f, Range::Closed))
{
for (int r_offs = -1; r_offs <= +1; ++r_offs)
for (int c_offs = -1; c_offs <= +1; ++c_offs)
{
if (r_offs == 0 && c_offs == 0)
continue;
RC offs_pos { r_offs, c_offs };
RC npc_scr_offs_pos = npc_scr_pos + offs_pos;
RC npc_world_offs_pos = npc.pos + offs_pos;
Expand Down

0 comments on commit 61cf750

Please sign in to comment.