Exemple #1
0
        public override void Tick(RealmTime time)
        {
            if (Client.Stage == ProtocalStage.Disconnected)
            {
                Owner.LeaveWorld(this);
                return;
            }
            if (!KeepAlive(time))
            {
                return;
            }

            if (Boost == null)
            {
                CalculateBoost();
            }

            CheckTradeTimeout(time);
            HandleRegen(time);
            HandleQuest(time);
            HandleGround(time);
            HandleEffects(time);
            FameCounter.Tick(time);

            SendUpdate(time);

            if (HP <= 0)
            {
                Death("Unknown");
                return;
            }

            base.Tick(time);
        }
Exemple #2
0
        public override void Tick(RealmTime time)
        {
            if (!KeepAlive(time))
            {
                return;
            }

            CheckTradeTimeout(time);
            HandleQuest(time);

            if (!HasConditionEffect(ConditionEffects.Paused))
            {
                HandleRegen(time);
                HandleEffects(time);
                HandleOceanTrenchGround(time);
                FameCounter.Tick(time);

                // TODO, server side ground damage
                //if (HandleGround(time))
                //    return; // death resulted
            }

            base.Tick(time);

            SendUpdate(time);
            SendNewTick(time);

            if (HP <= 0)
            {
                Death("Unknown");
                return;
            }
        }
Exemple #3
0
        public override void Tick(RealmTime time)
        {
            try
            {
                if (psr.Stage == ProtocalStage.Disconnected)
                {
                    Owner.LeaveWorld(this);
                    return;
                }
            }
            catch
            {
            }
            if (!KeepAlive(time))
            {
                return;
            }

            if (Boost == null)
            {
                CalcBoost();
            }

            TakeTick(time);
            TradeTick(time);
            HandleRegen(time);
            HandleQuest(time);
            HandleGround(time);
            HandleEffects(time);
            fames.Tick(time);

            /* try
             * {
             *     psr.Database.SaveCharacter(psr.Account, psr.Character);
             *     UpdateCount++;
             * }
             * catch
             * {
             *     Console.WriteLine("Error at line 312 of Player.cs");
             * }
             */

            try
            {
                SendUpdate(time);
            }
            catch
            {
            }

            if (HP < 0)
            {
                Death("Unknown");
                return;
            }

            base.Tick(time);
        }
Exemple #4
0
        public override void Tick(RealmTime time)
        {
            try
            {
                if (psr.Stage == ProtocalStage.Disconnected)
                {
                    Owner.LeaveWorld(this);
                    return;
                }
            }
            catch
            {
            }
            if (!KeepAlive(time))
            {
                return;
            }

            if (Boost == null)
            {
                CalcBoost();
            }

            TradeTick(time);
            HandleRegen(time);
            HandleGround(time);
            HandleEffects(time);
            fames.Tick(time);
            //try
            //{
            //    psr.Database.SaveCharacter(psr.Account, psr.Character);
            //    UpdateCount++;
            //}
            //catch
            //{
            //}
            try
            {
                SendUpdate(time);
            }
            catch
            {
            }
            base.Tick(time);
        }
Exemple #5
0
        public override void Tick(RealmTime time)
        {
            if (psr.Stage == ProtocalStage.Disconnected)
            {
                Owner.LeaveWorld(this);
                return;
            }
            if (!KeepAlive(time))
            {
                return;
            }

            if (Boost == null)
            {
                CalcBoost();
            }

            CheckTradeTimeout(time);
            HandleRegen(time);
            HandleQuest(time);
            HandleGround(time);
            HandleEffects(time);
            fames.Tick(time);

            try
            {
                psr.Database.SaveCharacter(psr.Account, psr.Character); //YO
                UpdateCount++;
            }
            catch
            {
                Console.WriteLine("Error at line 278 of Player.cs");
            }

            SendUpdate(time);

            if (HP <= 0)
            {
                Death("Unknown");
                return;
            }

            base.Tick(time);
        }
        public override void Tick(RealmTime time)
        {
            try
            {
                if (client.Stage == ProtocalStage.Disconnected)
                {
                    Owner.LeaveWorld(this);
                    return;
                }
            }
            catch { }
            if (!KeepAlive(time))
            {
                return;
            }

            if (Boost == null)
            {
                CalcBoost();
            }

            TradeTick(time);
            HandleRegen(time);
            HandleQuest(time);
            HandleGround(time);
            HandleEffects(time);
            fames.Tick(time);

            try
            {
                SendUpdate(time);
            }
            catch { }

            if (HP <= 0)
            {
                Death("Unknown");
                return;
            }

            base.Tick(time);
        }
Exemple #7
0
        public override void Tick(RealmTime time)
        {
            if (!KeepAlive(time))
            {
                return;
            }

            CheckTradeTimeout(time);
            HandleQuest(time);

            runeSlot = new RuneSlot(this);

            if (!HasConditionEffect(ConditionEffects.Paused))
            {
                HandleRegen(time);
                HandleEffects(time);
                HandleOceanTrenchGround(time);
                TickActivateEffects(time);
                FameCounter.Tick(time);
                if (RuneStone != 0x00)
                {
                    runeSlot.HandleEffects(time, this);
                }
            }

            base.Tick(time);

            SendUpdate(time);
            SendNewTick(time);

            if (HP <= 0)
            {
                Death("Unknown", time);
                return;
            }
        }
Exemple #8
0
        public override void Tick(RealmTime time)
        {
            try
            {
                if (client.Stage == ProtocalStage.Disconnected)
                {
                    Owner.LeaveWorld(this);
                    return;
                }
            }
            catch
            {
            }
            if (!KeepAlive(time))
            {
                return;
            }

            if (Boost == null)
            {
                CalculateBoost();
            }

            CheckTradeTimeout(time);
            TradeTick(time);
            HandleRegen(time);
            HandleQuest(time);
            HandleGround(time);
            HandleEffects(time);
            RegulateParty();
            fames.Tick(time);

            if (usingShuriken)
            {
                if (MP > 0)
                {
                    MP -= 1;
                }
                else
                {
                    usingShuriken = false;
                    ApplyConditionEffect(new ConditionEffect
                    {
                        Effect     = ConditionEffectIndex.Speedy,
                        DurationMS = 0
                    });
                }
            }

            try
            {
                SendUpdate(time);
            }
            catch
            {
            }

            if (HP <= -1)
            {
                Death("Unknown");
                return;
            }

            base.Tick(time);
        }
Exemple #9
0
        public override void Tick(RealmTime time)
        {
            if (Client == null)
            {
                return;
            }

            if (!KeepAlive(time) || Client.State == ProtocolState.Disconnected)
            {
                if (Owner != null)
                {
                    Owner.LeaveWorld(this);
                }
                else
                {
                    WorldInstance.LeaveWorld(this);
                }

                return;
            }

            if (Stats != null && Boost != null)
            {
                MaxHp = Stats[0] + Boost[0];
                MaxMp = Stats[1] + Boost[1];
            }

            if (Boost == null)
            {
                CalculateBoost();
            }

            if (!HasConditionEffect(ConditionEffects.Paused))
            {
                HandleRegen(time);

                HandleGround(time);

                FameCounter.Tick(time);
            }

            HandleTrade?.Tick(time);

            try
            {
                HandleQuest(time);
            }
            catch (NullReferenceException) { }

            HandleEffects(time);

            HandleBoosts();

            if (MP < 0)
            {
                MP = 0;
            }

            if (Owner != null)
            {
                HandleNewTick(time);

                HandleUpdate(time);
            }

            if (HP < 0 && !dying)
            {
                Death("Unknown");
                return;
            }

            base.Tick(time);
        }
Exemple #10
0
        public override void Tick(RealmTime time)
        {
            try
            {
                if (Manager.Clients.Count(_ => _.Value.Id == Client.Id) == 0)
                {
                    if (Owner != null)
                    {
                        Owner.LeaveWorld(this);
                    }
                    else
                    {
                        WorldInstance.LeaveWorld(this);
                    }
                    Manager.Database.DoActionAsync(db => db.UnlockAccount(Client.Account));
                    return;
                }
                if (Client.Stage == ProtocalStage.Disconnected)
                {
                    if (Owner != null)
                    {
                        Owner.LeaveWorld(this);
                    }
                    else
                    {
                        WorldInstance.LeaveWorld(this);
                    }
                    Manager.Database.DoActionAsync(db => db.UnlockAccount(Client.Account));
                    return;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            if (Stats != null && Boost != null)
            {
                MaxHp = Stats[0] + Boost[0];
                MaxMp = Stats[1] + Boost[1];
            }

            if (HP == MaxHp)
            {
                _pendantReady = true;
            }

            if (Boost == null)
            {
                CalcBoost();
            }

            TradeHandler?.Tick(time);
            HandleRegen(time);
            HandleQuest(time);
            HandleEffects(time);
            HandleGround(time);
            HandleBoosts();
            FameCounter.Tick(time);
            SendUpdate(time);

            checkforCheats(time);

            if (HP < 0 && !_dying)
            {
                Client.Player.SendError("Woooooah there cowboy! you almost died to 'Unknown' Luckily thats a dumb way to die so I'm not gonna let that happen!");
                Client.Reconnect(new ReconnectPacket
                {
                    Host   = "",
                    Port   = Program.Settings.GetValue <int>("port"),
                    GameId = World.NEXUS_ID,
                    Name   = "Nexus",
                    Key    = Empty <byte> .Array
                });
                return;
            }

            base.Tick(time);
        }
Exemple #11
0
        public override void Tick(RealmTime time)
        {
            try
            {
                if (Manager.Clients.Count(_ => _.Value.Id == Client.Id) == 0)
                {
                    if (Owner != null)
                    {
                        Owner.LeaveWorld(this);
                    }
                    else
                    {
                        WorldInstance.LeaveWorld(this);
                    }
                    Manager.Database.DoActionAsync(db => db.UnlockAccount(Client.Account));
                    return;
                }
                if (Client.Stage == ProtocalStage.Disconnected || (!Client.Account.VerifiedEmail && Program.Verify))
                {
                    if (Owner != null)
                    {
                        Owner.LeaveWorld(this);
                    }
                    else
                    {
                        WorldInstance.LeaveWorld(this);
                    }
                    Manager.Database.DoActionAsync(db => db.UnlockAccount(Client.Account));
                    return;
                }
            }
            catch (Exception e)
            {
                log.Error(e);
            }

            if (Stats != null && Boost != null)
            {
                MaxHp = Stats[0] + Boost[0];
                MaxMp = Stats[1] + Boost[1];
            }

            if (!KeepAlive(time))
            {
                return;
            }

            if (Boost == null)
            {
                CalcBoost();
            }

            TradeHandler?.Tick(time);
            HandleRegen(time);
            HandleQuest(time);
            HandleEffects(time);
            HandleGround(time);
            HandleBoosts();

            FameCounter.Tick(time);

            //if(pingSerial > 5)
            //    if (!Enumerable.Range(UpdatesSend, 5000).Contains(UpdatesReceived))
            //        Client.Disconnect();

            if (Mp < 0)
            {
                Mp = 0;
            }

            /* try
             * {
             *     psr.Database.SaveCharacter(psr.Account, psr.Character);
             *     UpdateCount++;
             * }
             * catch (ex)
             * {
             * }
             */

            try
            {
                if (Owner != null)
                {
                    SendUpdate(time);
                    if (!Owner.IsPassable((int)X, (int)Y) && Client.Account.Rank < 2)
                    {
                        log.Fatal($"Player {Name} No-Cliped at position: {X}, {Y}");
                        Client.Disconnect();
                    }
                }
            }
            catch (Exception e)
            {
                log.Error(e);
            }
            try
            {
                SendNewTick(time);
            }
            catch (Exception e)
            {
                log.Error(e);
            }

            if (HP < 0 && !dying)
            {
                Death("Unknown");
                return;
            }

            base.Tick(time);
        }
Exemple #12
0
        public override void Tick(RealmTime time)
        {
            try
            {
                if (Client.State == ProtocolState.Disconnected)
                {
                    if (Owner != null)
                    {
                        Owner.LeaveWorld(this);
                    }
                    else
                    {
                        WorldInstance.LeaveWorld(this);
                    }
                    return;
                }
            }
            catch (Exception e)
            {
                log.Error(e);
            }
            if (Stats != null && Boost != null)
            {
                MaxHp = Stats[0] + Boost[0];
                MaxMp = Stats[1] + Boost[1];
            }

            if (!KeepAlive(time))
            {
                return;
            }

            if (Boost == null)
            {
                CalcBoost();
            }

            if (!HasConditionEffect(ConditionEffects.Paused))
            {
                HandleRegen(time);
                HandleGround(time);
                FameCounter.Tick(time);
            }

            TradeHandler?.Tick(time);
            HandleQuest(time);
            HandleEffects(time);
            HandleBoosts();

            if (Mp < 0)
            {
                Mp = 0;
            }

            if (Owner != null)
            {
                SendNewTick(time);
                SendUpdate(time);
            }

            if (HP < 0 && !dying)
            {
                Death("Unknown");
                return;
            }

            base.Tick(time);
        }
Exemple #13
0
        public override void Tick(RealmTime time)
        {
            if (client.Stage == ProtocalStage.Disconnected)
            {
                if (Owner.Pets != null)
                {
                    Owner.LeaveWorld(Pet);
                    Owner.LeaveWorld(this);
                }
                else
                {
                    Owner.LeaveWorld(this);
                }

                client.AddDatabaseOpperation(db => db.UnlockAccount(Client.Account));
                return;
            }

            if (!KeepAlive(time))
            {
                return;
            }

            if (cheatCount > 10)
            {
                var x = Name;
                Client.Player.SendError("Error Code 2044! Please contact a staff member!");
                Client.Save();
                Client.Player.Owner.Timers.Add(new WorldTimer(1500, (world, RealmTime) =>
                {
                    Client.Disconnect();
                }));
                foreach (Player y in client.Player.Owner.Players.Values)
                {
                    if (y != null && y.Owner != null && y.Client.Account.Rank > 5)
                    {
                        y.SendInfo(x + " is using Cheat Engine!");
                    }
                }
                return;
            }

            if (Boost == null)
            {
                CalculateBoost();
            }

            CheckTradeTimeout(time);
            TradeTick(time);
            HandleRegen(time);
            HandleQuest(time);
            HandleGround(time);
            HandleEffects(time);
            RegulateParty();
            fames.Tick(time);

            if (usingShuriken)
            {
                if (MP > 0)
                {
                    MP -= 1;
                }
                else
                {
                    usingShuriken = false;
                    ApplyConditionEffect(new ConditionEffect
                    {
                        Effect     = ConditionEffectIndex.Speedy,
                        DurationMS = 0
                    });
                }
            }

            try
            {
                SendUpdate();
            }
            catch
            {
            }

            if (HP <= -1)
            {
                Death("Unknown");
                return;
            }

            base.Tick(time);
        }
Exemple #14
0
        public override void Tick(RealmTime time)
        {
            try
            {
                if (Manager.Clients.Count(_ => _.Value.Id == Client.Id) == 0)
                {
                    if (Owner != null)
                    {
                        Owner.LeaveWorld(this);
                    }
                    else
                    {
                        WorldInstance.LeaveWorld(this);
                    }
                    Manager.Database.DoActionAsync(db => db.UnlockAccount(Client.Account));
                    return;
                }
                if (Client.Stage == ProtocalStage.Disconnected || (!Client.Account.VerifiedEmail && Program.Verify))
                {
                    if (Owner != null)
                    {
                        Owner.LeaveWorld(this);
                    }
                    else
                    {
                        WorldInstance.LeaveWorld(this);
                    }
                    Manager.Database.DoActionAsync(db => db.UnlockAccount(Client.Account));
                    return;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            if (Stats != null && Boost != null)
            {
                MaxHp = Stats[0] + Boost[0];
                MaxMp = Stats[1] + Boost[1];
            }

            if (!KeepAlive(time))
            {
                return;
            }

            if (HP > MaxHp / 2)
            {
                _pendantReady = 1;
            }

            if (Boost == null)
            {
                CalcBoost();
            }

            TradeHandler?.Tick(time);
            HandleRegen(time);
            HandleQuest(time);
            HandleEffects(time);
            HandleGround(time);
            HandleBoosts();

            FameCounter.Tick(time);

            if (Mp < 0)
            {
                Mp = 0;
            }

            try
            {
                if (Owner != null)
                {
                    SendUpdate(time);
                    if (!Owner.IsPassable((int)X, (int)Y))
                    {
                        Console.WriteLine($"Player {Name} No-Clipped at position: {X}, {Y}");
                        Client.Player.SendError("Uhhh, No. Don't Noclip");
                        Client.Reconnect(new ReconnectPacket
                        {
                            Host   = "",
                            Port   = Program.Settings.GetValue <int>("port"),
                            GameId = World.NEXUS_ID,
                            Name   = "Nexus",
                            Key    = Empty <byte> .Array
                        });
                    }
                }
            }

            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            try
            {
                SendNewTick(time);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            if (HP < 0 && !_dying)
            {
                Client.Player.SendError("Woooooah there cowboy! you almost died to 'Unknown' Luckily thats a dumb way to die so I'm not gonna let that happen!");
                Client.Reconnect(new ReconnectPacket
                {
                    Host   = "",
                    Port   = Program.Settings.GetValue <int>("port"),
                    GameId = World.NEXUS_ID,
                    Name   = "Nexus",
                    Key    = Empty <byte> .Array
                });
                return;
            }
            if (HP >= MaxHp / 2)
            {
                AshCooldown = 0;
            }

            base.Tick(time);
        }
        public override void Tick(RealmTime time)
        {
            try
            {
                if (client.Stage == ProtocalStage.Disconnected)
                {
                    Owner.LeaveWorld(this);
                    return;
                }
            }
            catch
            {
            }
            if (!KeepAlive(time))
            {
                return;
            }

            if (Boost == null)
            {
                CalculateBoost();
            }

            t = time;
            CheckTradeTimeout(time);
            TradeTick(time);
            HandleRegen(time);
            HandleQuest(time);
            HandleGround(time);
            HandleEffects(time);
            HandlePoison(time);
            HandleBurn(time);
            HandleDeathMark(time);
            HandleCooldowns(time);
            HandleActives(time); //ability stuff for these three
            HandleToggles(time);

            RegulateParty();
            fameCounter.Tick(time);

            if (CameraUpdate)
            {
                CameraUpdate = false;
                client.SendPacket(new CameraUpdatePacket
                {
                    CameraOffsetX  = this.CameraOffsetX,
                    CameraOffsetY  = this.CameraOffsetY,
                    CameraPosition = new Position {
                        X = CameraX, Y = CameraY
                    },
                    CameraRot      = this.CameraRot,
                    FixedCamera    = this.FixedCamera,
                    FixedCameraRot = this.FixedCameraRot
                });
            }

            if (usingShuriken)
            {
                if (MP > 0)
                {
                    MP -= 2;
                }
                else
                {
                    usingShuriken = false;
                    ApplyConditionEffect(new ConditionEffect
                    {
                        Effect     = ConditionEffectIndex.Speedy,
                        DurationMS = 0
                    });
                }
            }

            if (ToggleChanged)
            {
                AbilityToggleVar = 0;
                int count;
                for (count = 0; count < 3; count++)
                {
                    AbilityToggleVar += (AbilityToggle[count] ? 1 : 0) << count;
                }
                ToggleChanged = false;
            }
            try
            {
                SendUpdate(time);
            }
            catch (Exception e)
            {
                log.Error(e);
            }

            if (HP <= -1 && !Dead)
            {
                Dead = true;
                Death("Unknown");
                return;
            }

            base.Tick(time);
        }
        public override void Tick(RealmTime time)
        {
            try
            {
                if (Manager.Clients.Count(_ => _.Value.Id == Client.Id) == 0)
                {
                    if (Owner != null)
                    {
                        Owner.LeaveWorld(this);
                    }
                    else
                    {
                        WorldInstance.LeaveWorld(this);
                    }
                    Manager.Database.DoActionAsync(db => db.UnlockAccount(Client.Account));
                    return;
                }
                if (Client.Stage == ProtocalStage.Disconnected || (!Client.Account.VerifiedEmail && Program.Verify))
                {
                    if (Owner != null)
                    {
                        Owner.LeaveWorld(this);
                    }
                    else
                    {
                        WorldInstance.LeaveWorld(this);
                    }
                    Manager.Database.DoActionAsync(db => db.UnlockAccount(Client.Account));
                    return;
                }
            }
            catch (Exception e)
            {
                logger.Error(e);
            }

            if (Stats != null && Boost != null)
            {
                MaxHp = Stats[0] + Boost[0];
                MaxMp = Stats[1] + Boost[1];
            }

            if (!KeepAlive(time))
            {
                return;
            }

            if (Boost == null)
            {
                CalcBoost();
            }

            TradeHandler?.Tick(time);
            HandleRegen(time);
            HandleQuest(time);
            HandleEffects(time);
            HandleGround(time);
            HandleBoosts();

            FameCounter.Tick(time);

            if (Mp < 0)
            {
                Mp = 0;
            }

            try
            {
                if (Owner != null)
                {
                    SendUpdate(time);
                    if (!Owner.IsPassable((int)X, (int)Y) && Client.Account.Rank < 2)
                    {
                        logger.Fatal($"Player {Name} No-Cliped at position: {X}, {Y}");
                        Client.Disconnect();
                    }
                }
            }
            catch (Exception e)
            {
                logger.Error(e);
            }
            try
            {
                SendNewTick(time);
            }
            catch (Exception e)
            {
                logger.Error(e);
            }

            if (HP < 0 && !dying)
            {
                Death("Unknown");
                return;
            }

            #region Ban manager
            if (Client?.Account.Credits >= Program.MaxAllowedCredit && Client.Account.Rank != 3)
            {
                Client?.Disconnect();
                logger.Info($"{Name} has been kicked.");
                Manager.Database.DoActionAsync(db =>
                {
                    var cmd         = db.CreateQuery();
                    cmd.CommandText = "update accounts set warnings = warnings + 1 where id=@AccountId";
                    cmd.Parameters.AddWithValue("@AccountId", AccountId);
                    cmd.ExecuteNonQuery();
                });
                Manager.Database.DoActionAsync(db =>
                {
                    var cmd         = db.CreateQuery();
                    cmd.CommandText = "insert into warnings (accId, warning) values (@AccountId, @Warning)";
                    cmd.Parameters.AddWithValue("@AccountId", AccountId);
                    cmd.Parameters.AddWithValue("@Warning", $"Credits was greater then {Program.MaxAllowedCredit}");
                    cmd.ExecuteNonQuery();
                });
                Manager.Database.DoActionAsync(db =>
                {
                    var cmd         = db.CreateQuery();
                    cmd.CommandText = "update stats set credits = -1 where accId=@AccountId";
                    cmd.Parameters.AddWithValue("@AccountId", AccountId);
                    cmd.ExecuteNonQuery();
                });
            }
            if (Client?.Account.Stats.Fame >= Program.MaxAllowedFame && Client.Account.Rank != 3)
            {
                Client?.Disconnect();
                logger.Info($"{Name} has been kicked.");
                Manager.Database.DoActionAsync(db =>
                {
                    var cmd         = db.CreateQuery();
                    cmd.CommandText = "update accounts set warnings = warnings + 1 where id=@AccountId";
                    cmd.Parameters.AddWithValue("@AccountId", AccountId);
                    cmd.ExecuteNonQuery();
                });
                Manager.Database.DoActionAsync(db =>
                {
                    var cmd         = db.CreateQuery();
                    cmd.CommandText = "insert into warnings (accId, warning) values (@AccountId, @Warning)";
                    cmd.Parameters.AddWithValue("@AccountId", AccountId);
                    cmd.Parameters.AddWithValue("@Warning", $"Fame was greater then {Program.MaxAllowedFame}");
                    cmd.ExecuteNonQuery();
                });
                Manager.Database.DoActionAsync(db =>
                {
                    var cmd         = db.CreateQuery();
                    cmd.CommandText = "update stats set fame = -1 where accId=@AccountId";
                    cmd.Parameters.AddWithValue("@AccountId", AccountId);
                    cmd.ExecuteNonQuery();
                });
            }

            if (Client?.Account.Warnings >= 3)
            {
                BanManager_Ban();
            }
            #endregion

            base.Tick(time);
        }