Exemplo n.º 1
0
 protected override void TickCore(Entity host, RealmTime time, ref object state)
 {
     if (MathsUtils.GenerateProb(50))
     {
         host.Owner.LeaveWorld(host);
     }
 }
Exemplo n.º 2
0
        public void Death(string killer, ObjectDesc desc = null)
        {
            try
            {
                if (_dying)
                {
                    return;
                }
                _dying = true;

                switch (Owner.Name)
                {
                case "Arena":
                {
                    HP = Client.Character.MaxHitPoints;
                    Client.Reconnect(new ReconnectPacket
                        {
                            Host   = "",
                            Port   = Program.Settings.GetValue <int>("port"),
                            GameId = World.NEXUS_ID,
                            Name   = "Nexus",
                            Key    = Empty <byte> .Array
                        });
                    return;
                }
                }

                if (CheckBrokenAmulet(MathsUtils.GenerateProb(100)) || CheckNotBrokenAmulet())
                {
                    return;
                }

                if (Client.Stage == ProtocalStage.Disconnected || _resurrecting)
                {
                    return;
                }
                if (CheckResurrection())
                {
                    return;
                }

                if (Client.Character.Dead)
                {
                    Client.Disconnect(Client.DisconnectReason.REGISTRATION_NEEDED);
                    return;
                }

                GenerateGravestone();

                if (desc != null)
                {
                    killer = desc.DisplayId;
                }
                switch (killer)
                {
                case "":
                case "Unknown":
                    Client.Disconnect(Client.DisconnectReason.REGISTRATION_NEEDED);
                    return;

                default:
                    if (desc != null)
                    {
                        announceDeath(desc.ObjectId);
                    }
                    else
                    {
                        announceDeath(killer);
                    }
                    break;
                }
                if (Client.Account.Rank > 1)
                {
                    Client.Disconnect(Client.DisconnectReason.REGISTRATION_NEEDED);
                    return;
                }
                Manager.Database.DoActionAsync(db =>
                {
                    Client.Character.Dead = true;
                    SaveToCharacter();
                    db.SaveCharacter(Client.Account, Client.Character);
                    db.Death(Manager.GameData, Client.Account, Client.Character, killer);
                });
                if (Owner.Id != World.TEST_ID)
                {
                    Client.SendPacket(new DeathPacket
                    {
                        AccountId = AccountId,
                        CharId    = Client.Character.CharacterId,
                        Killer    = killer,
                        Obf0      = -1,
                        Obf1      = -1
                    });
                    Owner.Timers.Add(new WorldTimer(1000, (w, t) => Client.Disconnect(Client.DisconnectReason.REGISTRATION_NEEDED)));
                    Owner.LeaveWorld(this);
                }
                else
                {
                    Client.Disconnect(Client.DisconnectReason.REGISTRATION_NEEDED);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemplo n.º 3
0
        public void Death(string killer, ObjectDesc desc = null)
        {
            if (CheckBrokenAmulet(MathsUtils.GenerateProb(100)))
            {
                return;
            }
            if (CheckNotBrokenAmulet())
            {
                return;
            }
            if (_dying)
            {
                return;
            }
            _dying = true;
            var killPlayer = true;

            switch (Owner.Name)
            {
            case "Arena":
            {
                Client.SendPacket(new ArenaDeathPacket
                    {
                        RestartPrice = 100
                    });
                HP = Client.Character.MaxHitPoints;
                ApplyConditionEffect(new ConditionEffect
                    {
                        Effect     = ConditionEffectIndex.Invulnerable,
                        DurationMS = -1
                    });
                return;
            }
            }


            if (Client.Stage == ProtocalStage.Disconnected || _resurrecting)
            {
                return;
            }
            if (CheckResurrection())
            {
                return;
            }

            if (Client.Character.Dead)
            {
                Client.Disconnect();
                return;
            }

            GenerateGravestone();

            if (desc != null)
            {
                killer = desc.DisplayId;
            }
            switch (killer)
            {
            case "":
            case "Unknown":
                killPlayer = false;
                break;

            default:
                announceDeath(killer, desc);
                break;
            }

            if (killPlayer)
            {
                try
                {
                    Manager.Database.DoActionAsync(db =>
                    {
                        Client.Character.Dead = true;
                        SaveToCharacter();
                        db.SaveCharacter(Client.Account, Client.Character);
                        db.Death(Manager.GameData, Client.Account, Client.Character, killer);
                    });
                    if (Owner.Id != World.TEST_ID)
                    {
                        Client.SendPacket(new DeathPacket
                        {
                            AccountId = AccountId,
                            CharId    = Client.Character.CharacterId,
                            Killer    = killer,
                            Obf0      = -1,
                            Obf1      = -1
                        });
                        Owner.Timers.Add(new WorldTimer(1000, (w, t) => Client.Disconnect()));
                        Owner.LeaveWorld(this);
                    }
                    else
                    {
                        Client.Disconnect();
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
            else
            {
                Client.Disconnect();
            }
        }