Пример #1
0
        public Player(Client client) : base(client.Character.ObjectType, client.Random)
        {
            try
            {
                if (client.Account.Admin == true)
                {
                    Admin = 1;
                }
                Achievements    = new List <string>();
                ActualTask      = null;
                MonsterCaches   = new List <MonsterCache>();
                Task            = null;
                AccountType     = client.Account.AccountType;
                AccountPerks    = new AccountTypePerks(AccountType);
                AccountLifetime = client.Account.AccountLifetime;
                IsVip           = AccountLifetime != DateTime.MinValue;
                Client          = client;
                StatsManager    = new StatsManager(this, client.Random.CurrentSeed);
                Name            = client.Account.Name;
                AccountId       = client.Account.AccountId;
                FameCounter     = new FameCounter(this);
                Tokens          = client.Account.FortuneTokens;
                HpPotionPrice   = 5;
                MpPotionPrice   = 5;
                Level           = client.Character.Level == 0 ? 1 : client.Character.Level;
                Experience      = client.Character.Experience;
                ExperienceGoal  = GetExperience(Level + 1, ExpType.Level);
                FakeExperience  = client.Character.FakeExperience;
                IsFakeEnabled   = client.Character.IsFakeEnabled;
                AttackLevel     = client.Character.AttackLevel;

                if (AttackLevel < 10)
                {
                    AttackLevel += 10;
                }

                AttackExperience     = client.Character.AttackExperience;
                AttackGoalExperience = GetExperience(AttackLevel + 1 - 10, ExpType.Stat);
                DefenseLevel         = client.Character.DefenseLevel;

                if (DefenseLevel < 10)
                {
                    DefenseLevel += 10;
                }

                DefenseExperience     = client.Character.DefenseExperience;
                DefenseGoalExperience = GetExperience(DefenseLevel + 1 - 10, ExpType.Stat);
                Bless1          = client.Character.Bless1;
                Bless2          = client.Character.Bless2;
                Bless3          = client.Character.Bless3;
                Bless4          = client.Character.Bless4;
                Bless5          = client.Character.Bless5;
                EnablePetAttack = client.Character.EnablePetAttack;
                Stars           = AccountType >= (int)Core.config.AccountType.DEVELOPER ? 70 : GetStars();
                ChatColors      = new ChatColor(this);
                Texture1        = client.Character.Tex1;
                Texture2        = client.Character.Tex2;
                Credits         = client.Account.Credits;
                NameChosen      = client.Account.NameChosen;
                CurrentFame     = client.Account.Fame;
                Fame            = client.Character.Fame;
                PetHealing      = null;
                PetAttack       = null;
                if (client.Character.Pet != 0)
                {
                    PetHealing = new List <List <int> >();
                    PetAttack  = new List <int>();
                    PetID      = client.Character.Pet;
                    var HPData = PetHPHealing.MinMaxBonus(Resolve((ushort)PetID).ObjectDesc.HPTier, Stars);
                    var MPData = PetMPHealing.MinMaxBonus(Resolve((ushort)PetID).ObjectDesc.MPTier, Stars);
                    PetHealing.Add(new List <int> {
                        HPData.Item1, HPData.Item2, (int)((HPData.Item3 - 1) * 100)
                    });
                    PetHealing.Add(new List <int> {
                        MPData.Item1, MPData.Item2, (int)((MPData.Item3 - 1) * 100)
                    });
                    PetAttack.Add(7750 - Stars * 100);
                    PetAttack.Add(30 + Stars);
                    PetAttack.Add(Resolve((ushort)PetID).ObjectDesc.Projectiles[0].MinDamage);
                    PetAttack.Add(Resolve((ushort)PetID).ObjectDesc.Projectiles[0].MaxDamage);
                }
                LootDropBoostTimeLeft  = client.Character.LootDropTimer;
                lootDropBoostFreeTimer = LootDropBoost;
                LootTierBoostTimeLeft  = client.Character.LootTierTimer;
                lootTierBoostFreeTimer = LootTierBoost;
                FameGoal = (AccountType >= (int)Core.config.AccountType.MOD) ? 0d : GetFameGoal(FameCounter.ClassStats[ObjectType].BestFame);
                Glowing  = AccountType == (int)Core.config.AccountType.VIP;
                var guild = GameServer.Manager.Database.GetGuild(client.Account.GuildId);
                if (guild != null)
                {
                    Guild     = GameServer.Manager.Database.GetGuild(client.Account.GuildId).Name;
                    GuildRank = client.Account.GuildRank;
                }
                else
                {
                    Guild     = "";
                    GuildRank = -1;
                }
                HP = client.Character.HP <= 0 ? (int)ObjectDesc.MaxHP : client.Character.HP;
                MP = client.Character.MP;
                ConditionEffects = 0;
                OxygenBar        = 100;
                HasBackpack      = client.Character.HasBackpack == true;
                PlayerSkin       = Client.Account.OwnedSkins.Contains(Client.Character.Skin) ? Client.Character.Skin : 0;
                HealthPotions    = client.Character.HealthPotions < 0 ? 0 : client.Character.HealthPotions;
                MagicPotions     = client.Character.MagicPotions < 0 ? 0 : client.Character.MagicPotions;

                try
                {
                    Locked  = GameServer.Manager.Database.GetLockeds(client.Account);
                    Ignored = GameServer.Manager.Database.GetIgnoreds(client.Account);
                }
                catch (Exception) { }

                if (HasBackpack)
                {
                    Item[] inv =
                        client.Character.Items.Select(
                            _ =>
                            _ == -1
                                    ? null
                                    : (GameServer.Manager.GameData.Items.ContainsKey((ushort)_) ? GameServer.Manager.GameData.Items[(ushort)_] : null))
                        .ToArray();
                    Item[] backpack =
                        client.Character.Backpack.Select(
                            _ =>
                            _ == -1
                                    ? null
                                    : (GameServer.Manager.GameData.Items.ContainsKey((ushort)_) ? GameServer.Manager.GameData.Items[(ushort)_] : null))
                        .ToArray();

                    Inventory = inv.Concat(backpack).ToArray();
                    XElement xElement = GameServer.Manager.GameData.ObjectTypeToElement[ObjectType].Element("SlotTypes");
                    if (xElement != null)
                    {
                        int[] slotTypes =
                            Utils.FromCommaSepString32(
                                xElement.Value);
                        Array.Resize(ref slotTypes, 20);
                        SlotTypes = slotTypes;
                    }
                }
                else
                {
                    Inventory =
                        client.Character.Items.Select(
                            _ =>
                            _ == -1
                                        ? null
                                        : (GameServer.Manager.GameData.Items.ContainsKey((ushort)_) ? GameServer.Manager.GameData.Items[(ushort)_] : null))
                        .ToArray();
                    XElement xElement = GameServer.Manager.GameData.ObjectTypeToElement[ObjectType].Element("SlotTypes");
                    if (xElement != null)
                    {
                        SlotTypes =
                            Utils.FromCommaSepString32(
                                xElement.Value);
                    }
                }

                var(hp, mp) = GetStats[GetClassType[ObjectType]];

                Stats    = (int[])client.Character.Stats.Clone();
                Stats[0] = Level * hp + 100; // hp
                Stats[1] = Level * mp + 100; // mp
                Stats[2] = 0;                // old attack
                Stats[3] = 0;                // old defense
                Stats[4] = Level / 2;        // spd
                Stats[5] = 10;               // default hp
                Stats[6] = 10;               // default wis
                Stats[7] = 25;               // default dex

                for (var i = 0; i < SlotTypes.Length; i++)
                {
                    if (SlotTypes[i] == 0)
                    {
                        SlotTypes[i] = 10;
                    }
                }

                if (Client.Account.AccountType >= (int)Core.config.AccountType.DEVELOPER)
                {
                    return;
                }

                for (var i = 0; i < 4; i++)
                {
                    if (Inventory[i]?.SlotType != SlotTypes[i])
                    {
                        Inventory[i] = null;
                    }
                }
            }
            catch (Exception) { }
        }
Пример #2
0
        public Player(Client client) : base(client.Character.ObjectType, client.Random)
        {
            try
            {
                if (client.Account.Admin == true)
                {
                    Admin = 1;
                }
                Achievements    = new List <string>();
                ActualTask      = null;
                MonsterCaches   = new List <MonsterCache>();
                Task            = null;
                AccountType     = client.Account.AccountType;
                AccountPerks    = new AccountTypePerks(AccountType);
                AccountLifetime = client.Account.AccountLifetime;
                IsVip           = AccountLifetime != DateTime.MinValue;
                Client          = client;
                StatsManager    = new StatsManager(this, client.Random.CurrentSeed);
                Name            = client.Account.Name;
                AccountId       = client.Account.AccountId;
                FameCounter     = new FameCounter(this);
                Tokens          = client.Account.FortuneTokens;
                HpPotionPrice   = 5;
                MpPotionPrice   = 5;
                Level           = client.Character.Level == 0 ? 1 : client.Character.Level;
                Experience      = client.Character.Experience;
                ExperienceGoal  = GetExpGoal(Level);
                Stars           = AccountType >= (int)Core.config.AccountType.LEGENDS_OF_LOE_ACCOUNT ? 70 : GetStars();
                Texture1        = client.Character.Tex1;
                Texture2        = client.Character.Tex2;
                Credits         = client.Account.Credits;
                NameChosen      = client.Account.NameChosen;
                CurrentFame     = client.Account.Fame;
                Fame            = client.Character.Fame;
                PetHealing      = null;
                PetAttack       = null;
                if (client.Character.Pet != 0)
                {
                    PetHealing = new List <List <int> >();
                    PetAttack  = new List <int>();
                    PetID      = client.Character.Pet;
                    Tuple <int, int, double> HPData = PetHPHealing.MinMaxBonus(Resolve((ushort)PetID).ObjectDesc.HPTier, Stars);
                    Tuple <int, int, double> MPData = PetMPHealing.MinMaxBonus(Resolve((ushort)PetID).ObjectDesc.MPTier, Stars);
                    PetHealing.Add(new List <int> {
                        HPData.Item1, HPData.Item2, (int)((HPData.Item3 - 1) * 100)
                    });
                    PetHealing.Add(new List <int> {
                        MPData.Item1, MPData.Item2, (int)((MPData.Item3 - 1) * 100)
                    });
                    PetAttack.Add(7750 - Stars * 100);
                    PetAttack.Add(30 + Stars);
                    PetAttack.Add(Resolve((ushort)PetID).ObjectDesc.Projectiles[0].MinDamage);
                    PetAttack.Add(Resolve((ushort)PetID).ObjectDesc.Projectiles[0].MaxDamage);
                }
                LootDropBoostTimeLeft  = client.Character.LootDropTimer;
                lootDropBoostFreeTimer = LootDropBoost;
                LootTierBoostTimeLeft  = client.Character.LootTierTimer;
                lootTierBoostFreeTimer = LootTierBoost;
                FameGoal = (AccountType >= (int)Core.config.AccountType.LEGENDS_OF_LOE_ACCOUNT) ? 0 : GetFameGoal(FameCounter.ClassStats[ObjectType].BestFame);
                Glowing  = false;
                DbGuild guild = GameServer.Manager.Database.GetGuild(client.Account.GuildId);
                if (guild != null)
                {
                    Guild     = GameServer.Manager.Database.GetGuild(client.Account.GuildId).Name;
                    GuildRank = client.Account.GuildRank;
                }
                else
                {
                    Guild     = "";
                    GuildRank = -1;
                }
                HP = client.Character.HP <= 0 ? (int)ObjectDesc.MaxHP : client.Character.HP;
                MP = client.Character.MP;
                ConditionEffects = 0;
                OxygenBar        = 100;
                HasBackpack      = client.Character.HasBackpack == true;
                PlayerSkin       = Client.Account.OwnedSkins.Contains(Client.Character.Skin) ? Client.Character.Skin : 0;
                HealthPotions    = client.Character.HealthPotions < 0 ? 0 : client.Character.HealthPotions;
                MagicPotions     = client.Character.MagicPotions < 0 ? 0 : client.Character.MagicPotions;

                try
                {
                    Locked  = client.Account.Database.GetLockeds(client.Account);
                    Ignored = client.Account.Database.GetIgnoreds(client.Account);
                    Muted   = client.Account.Muted;
                }
                catch (Exception) { }

                if (HasBackpack)
                {
                    Item[] inv =
                        client.Character.Items.Select(
                            _ =>
                            _ == -1
                                    ? null
                                    : (GameServer.Manager.GameData.Items.ContainsKey((ushort)_) ? GameServer.Manager.GameData.Items[(ushort)_] : null))
                        .ToArray();
                    Item[] backpack =
                        client.Character.Backpack.Select(
                            _ =>
                            _ == -1
                                    ? null
                                    : (GameServer.Manager.GameData.Items.ContainsKey((ushort)_) ? GameServer.Manager.GameData.Items[(ushort)_] : null))
                        .ToArray();

                    Inventory = inv.Concat(backpack).ToArray();
                    XElement xElement = GameServer.Manager.GameData.ObjectTypeToElement[ObjectType].Element("SlotTypes");
                    if (xElement != null)
                    {
                        int[] slotTypes =
                            Utils.FromCommaSepString32(
                                xElement.Value);
                        Array.Resize(ref slotTypes, 20);
                        SlotTypes = slotTypes;
                    }
                }
                else
                {
                    Inventory =
                        client.Character.Items.Select(
                            _ =>
                            _ == -1
                                        ? null
                                        : (GameServer.Manager.GameData.Items.ContainsKey((ushort)_) ? GameServer.Manager.GameData.Items[(ushort)_] : null))
                        .ToArray();
                    XElement xElement = GameServer.Manager.GameData.ObjectTypeToElement[ObjectType].Element("SlotTypes");
                    if (xElement != null)
                    {
                        SlotTypes =
                            Utils.FromCommaSepString32(
                                xElement.Value);
                    }
                }
                Stats = (int[])client.Character.Stats.Clone();

                for (var i = 0; i < SlotTypes.Length; i++)
                {
                    if (SlotTypes[i] == 0)
                    {
                        SlotTypes[i] = 10;
                    }
                }

                if (Client.Account.AccountType >= (int)Core.config.AccountType.TUTOR_ACCOUNT)
                {
                    return;
                }

                for (var i = 0; i < 4; i++)
                {
                    if (Inventory[i]?.SlotType != SlotTypes[i])
                    {
                        Inventory[i] = null;
                    }
                }
            }
            catch (Exception) { }
        }