// BaseAnimal.Die() public static void NPCDied(BaseAnimal animal, HitInfo info) { if (info.Initiator != null) { Player p = new Player(info.Initiator as BasePlayer); PlayerStats stats = new PlayerStats(p.SteamID); stats.AddKill(false, true); p.Stats = stats; } var npc = new NPC(animal); OnNPCDied.OnNext(new Events.NPCDeathEvent(npc, info)); }
// BasePlayer.Die() public static void PlayerDied(BasePlayer player, HitInfo info) { // works if (info == null) { info = new HitInfo(); info.damageType = player.metabolism.lastDamage; info.Initiator = player as BaseEntity; } Player victim = new Player(player); if (info.Initiator != null) { PlayerStats statsV = new PlayerStats(victim.SteamID); if (info.Initiator is BasePlayer) { Player p = new Player(info.Initiator as BasePlayer); PlayerStats stats = new PlayerStats(p.SteamID); stats.AddKill(true, false); p.Stats = stats; statsV.AddDeath(true, false); } else if (info.Initiator is BaseAnimal) { statsV.AddDeath(false, true); } victim.Stats = statsV; } Events.PlayerDeathEvent pde = new Events.PlayerDeathEvent(victim, info); OnPlayerDied.OnNext(pde); if (!pde.dropLoot) { player.inventory.Strip(); } }