diff --git a/Game/Dungeon/DungeonHandler.Dungeons.cs b/Game/Dungeon/DungeonHandler.Dungeons.cs index f8e0b22..9e9def8 100644 --- a/Game/Dungeon/DungeonHandler.Dungeons.cs +++ b/Game/Dungeon/DungeonHandler.Dungeons.cs @@ -412,7 +412,7 @@ public sealed partial class DungeonHandler x = p.X, y = p.Y }), - mobs = instance.Simulation.Mobs.Values.Where(m => m.IsAlive).Select(m => new + mobs = instance.Simulation.Mobs.Values.Select(m => new { id = m.Id, definitionId = m.DefinitionId, @@ -422,8 +422,10 @@ public sealed partial class DungeonHandler rotation = m.Rotation, health = m.Health, maxHealth = m.MaxHealth, + hasLoot = m.HasDeathLoot, isAlive = m.IsAlive, state = m.State.ToString().ToLower(), + currentAnimation = m.CurrentAnimation, spriteConfig = DeserializeSpriteConfigSafe(m.SpriteConfigJson), tintColor = m.TintColor, scale = m.Scale @@ -547,6 +549,7 @@ public sealed partial class DungeonHandler killedBoss.IsAlive = false; killedBoss.Health = 0; killedBoss.State = MobState.Dead; + killedBoss.CurrentAnimation = killedBoss.GetDirectionalAnimation("death"); } else { @@ -574,6 +577,7 @@ public sealed partial class DungeonHandler boss.IsAlive = false; boss.Health = 0; boss.State = MobState.Dead; + boss.CurrentAnimation = boss.GetDirectionalAnimation("death"); } } } @@ -640,6 +644,7 @@ public sealed partial class DungeonHandler mob.Value.IsAlive = false; mob.Value.Health = 0; mob.Value.State = MobState.Dead; + mob.Value.CurrentAnimation = mob.Value.GetDirectionalAnimation("death"); } instance.Simulation.Mobs.TryAdd(mob.Key, mob.Value); diff --git a/Game/Dungeon/DungeonHandler.MobLoot.cs b/Game/Dungeon/DungeonHandler.MobLoot.cs index bdd706c..6ad5510 100644 --- a/Game/Dungeon/DungeonHandler.MobLoot.cs +++ b/Game/Dungeon/DungeonHandler.MobLoot.cs @@ -37,6 +37,13 @@ public sealed partial class DungeonHandler return; } + // No interaction once corpse loot is exhausted + if (!mob.HasDeathLoot) + { + await SendErrorAsync(connection, "Mob has no loot", ct); + return; + } + // Check distance if (session.PlayerInstance != null) { diff --git a/Game/Dungeon/DungeonHandler.cs b/Game/Dungeon/DungeonHandler.cs index 91d3b72..5e926ae 100644 --- a/Game/Dungeon/DungeonHandler.cs +++ b/Game/Dungeon/DungeonHandler.cs @@ -846,7 +846,9 @@ public sealed partial class DungeonHandler : IClientMessageHandler rotation = m.Rotation, health = m.Health, maxHealth = m.MaxHealth, + hasLoot = m.HasDeathLoot, state = m.State.ToString().ToLower(), + currentAnimation = m.CurrentAnimation, isAlive = m.IsAlive, spriteConfig = DeserializeSpriteConfigSafe(m.SpriteConfigJson), tintColor = m.TintColor, @@ -2819,11 +2821,13 @@ public sealed partial class DungeonHandler : IClientMessageHandler var visiblePlayerIds = visiblePlayers.Select(p => p.CharacterId).ToHashSet(); var nearbyOrRelevantMobs = sim.Mobs.Values - .Where(m => m.IsAlive && (!spatialFiltering || IsNearby(m.X, m.Y) || m.TargetId == session.CharacterId)) + .Where(m => !spatialFiltering || + IsNearby(m.X, m.Y) || + (m.IsAlive && m.TargetId == session.CharacterId)) .ToList(); var visibleMobs = sendSpatialThisTick ? nearbyOrRelevantMobs - : nearbyOrRelevantMobs.Where(m => m.TargetId == session.CharacterId).ToList(); + : nearbyOrRelevantMobs.Where(m => !m.IsAlive || m.TargetId == session.CharacterId).ToList(); var visibleMobIds = visibleMobs.Select(m => m.Id).ToHashSet(); bool sendMobCatalog = session.CurrentDungeonId.HasValue && session.InitialMobCatalogDungeonId != session.CurrentDungeonId; @@ -2877,8 +2881,10 @@ public sealed partial class DungeonHandler : IClientMessageHandler rotation = m.Rotation, health = m.Health, maxHealth = m.MaxHealth, + hasLoot = m.HasDeathLoot, isAlive = m.IsAlive, state = m.State.ToString().ToLower(), + currentAnimation = m.CurrentAnimation, spriteConfig = DeserializeSpriteConfigSafe(m.SpriteConfigJson), tintColor = m.TintColor, scale = m.Scale diff --git a/Game/Dungeon/DungeonSimulation.cs b/Game/Dungeon/DungeonSimulation.cs index ad8c7d9..0a78db2 100644 --- a/Game/Dungeon/DungeonSimulation.cs +++ b/Game/Dungeon/DungeonSimulation.cs @@ -374,33 +374,16 @@ public partial class DungeonSimulation UpdatePlayer(player); } - // Handle corpse cleanup (remove corpses 30 seconds after loot is empty AND dungeon is cleared) - var corpsesToRemove = new List(); - if (Phase == DungeonPhase.Cleared) + // Keep corpses in the world after death (even after loot is emptied). + // We still stamp when loot becomes empty so UI/inspection logic can reference it. + foreach (var mob in Mobs.Values.Where(m => !m.IsAlive)) { - foreach (var mob in Mobs.Values.Where(m => !m.IsAlive)) + if (!mob.HasDeathLoot && !mob.LootEmptiedAtTick.HasValue) { - // Check if loot just became empty - if (!mob.HasDeathLoot && !mob.LootEmptiedAtTick.HasValue) - { - mob.LootEmptiedAtTick = CurrentTick; - } - - // Remove corpse 30 seconds after loot emptied (10 ticks per second) - if (mob.LootEmptiedAtTick.HasValue && - CurrentTick - mob.LootEmptiedAtTick.Value >= 30 * TicksPerSecond) - { - corpsesToRemove.Add(mob.Id); - } + mob.LootEmptiedAtTick = CurrentTick; } } - // Remove corpses - foreach (var mobId in corpsesToRemove) - { - Mobs.Remove(mobId, out _); - } - // Check dungeon completion (only once when phase is still Active) if (Phase == DungeonPhase.Active && Mobs.Values.All(m => !m.IsAlive)) { @@ -786,7 +769,13 @@ public partial class DungeonSimulation // Check if mob died if (mob.Health <= 0 && mob.IsAlive) { + mob.Health = 0; mob.IsAlive = false; + mob.State = MobState.Dead; + mob.TargetId = null; + mob.CastingAbility = null; + mob.CastTimeRemaining = 0; + mob.CurrentAnimation = mob.GetDirectionalAnimation("death"); _pendingDeathEvents.Add(new DeathEvent { EntityType = EntityType.Mob, @@ -1302,6 +1291,10 @@ public partial class DungeonSimulation mob.Health = 0; mob.IsAlive = false; mob.State = MobState.Dead; + mob.TargetId = null; + mob.CastingAbility = null; + mob.CastTimeRemaining = 0; + mob.CurrentAnimation = mob.GetDirectionalAnimation("death"); player.XpGained += mob.Stats.XpReward; player.MobsKilled++; diff --git a/Game/Dungeon/MobAI.cs b/Game/Dungeon/MobAI.cs index b062b0b..b636536 100644 --- a/Game/Dungeon/MobAI.cs +++ b/Game/Dungeon/MobAI.cs @@ -861,6 +861,10 @@ public static class MobAI mob.Health = 0; mob.IsAlive = false; mob.State = MobState.Dead; + mob.TargetId = null; + mob.CastingAbility = null; + mob.CastTimeRemaining = 0; + mob.CurrentAnimation = mob.GetDirectionalAnimation("death"); } } }