wServer.realm.entities.player.Player.Death C# (CSharp) Method

Death() public method

public Death ( string killer ) : void
killer string
return void
        public void Death(string killer)
        {
            if (psr.Stage == ProtocalStage.Disconnected || resurrecting)
                return;
            switch (Owner.Name)
            {
                case "Free Battle Arena":
                case "Battle Arena":
                case "Arena":
                    Owner.BroadcastPacket(new TextPacket
                    {
                        BubbleTime = 0,
                        Stars = -1,
                        Name = "",
                        Text = Name + " was eliminated by " + killer //removed XP as max packet length reached!
                    }, null);
                    psr.Reconnect(new ReconnectPacket
                    {
                        Host = "",
                        Port = 2050,
                        GameId = World.NEXUS_ID,
                        Name = "Nexus",
                        Key = Empty<byte>.Array,
                    });
                    return;
                case "Zombies":
                    Owner.BroadcastPacket(new TextPacket
                    {
                        BubbleTime = 0,
                        Stars = -1,
                        Name = "",
                        Text = Name + " has become one with the infected" //cinematic!
                    }, null);
                    psr.Reconnect(new ReconnectPacket
                    {
                        Host = "",
                        Port = 2050,
                        GameId = World.NEXUS_ID,
                        Name = "Nexus",
                        Key = Empty<byte>.Array,
                    });
                    return;
                case "Nexus":
                    Owner.BroadcastPacket(new TextPacket
                    {
                        BubbleTime = 0,
                        Stars = -1,
                        Name = "",
                        Text = Name + " was saved by the holy powers of the Nexus."
                    }, null);
                    HP = psr.Character.MaxHitPoints;
                    psr.Disconnect();
                    return;
            }
            if (Client.Account.Rank > 2)
            {
                HP = psr.Character.MaxHitPoints;
                psr.Disconnect();
                return;
            }
            if (CheckResurrection())
                return;

            if (psr.Character.Dead)
            {
                psr.Disconnect();
                return;
            }
            GenerateGravestone();
            switch (killer)
            {
                case "":
                case "Unknown":
                    break;
                default:
                    Owner.BroadcastPacket(new TextPacket
                    {
                        BubbleTime = 0,
                        Stars = -1,
                        Name = "",
                        Text = Name + " died at Level " + Level + ", with " + Fame + " Fame" + ", killed by " + killer
                    }, null);
                    break;
            }

            try
            {
                var maxed = (from i in XmlDatas.TypeToElement[ObjectType].Elements("LevelIncrease") let limit = int.Parse(XmlDatas.TypeToElement[ObjectType].Element(i.Value).Attribute("max").Value) let idx = StatsManager.StatsNameToIndex(i.Value) where Stats[idx] >= limit select StatsManager.StatsIndexToPotName(idx)).ToList();

                psr.Character.Dead = true;
                SaveToCharacter();
                psr.Database.SaveCharacter(psr.Account, psr.Character);
                if (Owner.Id != -6)
                {
                    psr.Database.Death(psr.Account, psr.Character, killer);
                    psr.SendPacket(new DeathPacket
                    {
                        AccountId = AccountId,
                        CharId = psr.Character.CharacterId,
                        Killer = killer
                    });
                    Owner.Timers.Add(new WorldTimer(1000, (w, t) => psr.Disconnect()));
                    Owner.LeaveWorld(this);

                    var mcount = maxed.Count;
                    if (mcount >= 2)
                    {
                        MaxPotionOnDeath(maxed);
                        if (mcount >= 6)
                        {
                            MaxPotionOnDeath(maxed);
                            if (mcount == 8)
                            {
                                MaxPotionOnDeath(maxed);
                            }
                        }
                    }
                }
                else
                    psr.Disconnect();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }