Esempio n. 1
0
        private void ParsePlayerStats(Internal.CommunicationStream message)
        {
            int ticks = OpenTibiaUnity.TicksMillis;

            int health    = message.ReadUnsignedShort();
            int maxHealth = message.ReadUnsignedShort();

            Player.SetSkill(SkillType.Health, health, maxHealth, 0);

            int freeCapacity;

            if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GameDoubleFreeCapacity))
            {
                freeCapacity = message.ReadInt();
            }
            else
            {
                freeCapacity = message.ReadShort();
            }

            Player.FreeCapacity = freeCapacity;

            int totalCapacity = 0;

            if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GameTotalCapacity))
            {
                totalCapacity = message.ReadInt();
            }


            Player.SetSkill(SkillType.Capacity, freeCapacity, totalCapacity, 0);

            long experience;

            if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GameDoubleExperience))
            {
                experience = message.ReadLong();
            }
            else
            {
                experience = message.ReadInt();
            }

            Player.SetSkill(SkillType.Experience, experience, 1, 0);

            ushort level        = message.ReadUnsignedShort();
            byte   levelPercent = message.ReadUnsignedByte();

            Player.SetSkill(SkillType.Level, level, 1, levelPercent);

            if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GameExperienceGain))
            {
                float baseXpGain    = message.ReadUnsignedShort() / 100f;
                float voucherAddend = 0;
                if (OpenTibiaUnity.GameManager.ClientVersion < 1150)
                {
                    voucherAddend = message.ReadUnsignedShort() / 100f;
                }
                float grindingAddend     = message.ReadUnsignedShort() / 100f;
                float storeBoostAddend   = message.ReadUnsignedShort() / 100f;
                float huntingBoostFactor = message.ReadUnsignedShort() / 100f;

                Player.ExperienceGainInfo.UpdateGainInfo(baseXpGain, voucherAddend, grindingAddend, storeBoostAddend, huntingBoostFactor);
            }
            else if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GameExperienceBonus))
            {
                double experienceBonus = message.ReadDouble();
                Player.ExperienceBonus = experienceBonus;
            }

            int mana    = message.ReadUnsignedShort();
            int maxMana = message.ReadUnsignedShort();

            Player.SetSkill(SkillType.Mana, mana, maxMana, 0);

            if (OpenTibiaUnity.GameManager.ClientVersion < 1200)
            {
                byte magicLevel        = message.ReadUnsignedByte();
                byte baseMagicLevel    = OpenTibiaUnity.GameManager.GetFeature(GameFeature.GameSkillsBase) ? message.ReadUnsignedByte() : magicLevel;
                byte magicLevelPercent = message.ReadUnsignedByte();

                Player.SetSkill(SkillType.MagLevel, magicLevel, baseMagicLevel, magicLevelPercent);
            }

            int soul = message.ReadUnsignedByte();

            Player.SetSkill(SkillType.SoulPoints, soul, 1, 0);

            if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GamePlayerStamina))
            {
                int stamina = ticks + 60000 * message.ReadUnsignedShort();
                Player.SetSkill(SkillType.Stamina, stamina, ticks, 0);
            }

            if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GameSkillsBase))
            {
                ushort baseSpeed = message.ReadUnsignedShort();
                Player.SetSkill(SkillType.Speed, Player.GetSkillValue(SkillType.Speed), baseSpeed, 0);
            }

            if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GamePlayerRegenerationTime))
            {
                int regeneration = ticks + 1000 * message.ReadUnsignedShort();
                Player.SetSkill(SkillType.Food, regeneration, ticks, 0);
            }

            if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GameOfflineTrainingTime))
            {
                int training = ticks + 60000 * message.ReadUnsignedShort();
                Player.SetSkill(SkillType.OfflineTraining, training, ticks, 0);

                if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GameExperienceGain))
                {
                    uint remainingSeconds   = message.ReadUnsignedShort();
                    bool canBuyMoreXpBoosts = message.ReadBoolean();
                    Player.ExperienceGainInfo.UpdateStoreXpBoost(remainingSeconds, canBuyMoreXpBoosts);
                }
            }
        }
Esempio n. 2
0
        private void ParseMonsterCyclopediaRace(Internal.CommunicationStream message)
        {
            ushort raceID         = message.ReadUnsignedShort();
            var    classification = message.ReadString();

            int  unlockState = message.ReadUnsignedByte();
            uint totalKills  = message.ReadUnsignedInt();

            int killsToFirstDetailStage  = message.ReadUnsignedShort();
            int killsToSecondDetailStage = message.ReadUnsignedShort();
            int killsToThirdDetailStage  = message.ReadUnsignedShort();

            if (unlockState >= 1)
            {
                var difficulty = message.ReadEnum <CyclopediaRaceDifficulty>();
                var occurrence = message.ReadEnum <CyclopediaRaceOccurence>();

                int count = message.ReadUnsignedByte();
                for (int i = 0; i < count; i++)
                {
                    ushort objectID         = message.ReadUnsignedShort();
                    var    rarity           = message.ReadEnum <CyclopediaRaceLootRarity>();
                    bool   specialEventLoot = message.ReadBoolean();
                    if (objectID != 0)
                    {
                        var objectName = message.ReadString();
                        var lootType   = message.ReadEnum <CyclopediaRaceLootType>();
                    }
                }
            }

            if (unlockState >= 2)
            {
                ushort charmPoints           = message.ReadUnsignedShort();
                var    attackType            = message.ReadEnum <CyclopediaRaceAttackType>();
                bool   castSpellsOrUseSkills = message.ReadBoolean(); // shows the icon of spells
                uint   health     = message.ReadUnsignedInt();
                uint   experience = message.ReadUnsignedInt();
                ushort speed      = message.ReadUnsignedShort();
                ushort armor      = message.ReadUnsignedShort();
            }

            if (unlockState >= 3)
            {
                int count = message.ReadUnsignedByte();
                for (int i = 0; i < count; i++)
                {
                    var combatType = message.ReadEnum <CyclopediaCombatType>();
                    int value      = message.ReadShort();
                }

                count = message.ReadUnsignedShort();
                for (int i = 0; i < count; i++)
                {
                    string location = message.ReadString();
                }
            }

            if (unlockState >= 4)
            {
                bool hasCharmSelected = message.ReadBoolean();
                if (hasCharmSelected)
                {
                    int selectedCharmID = message.ReadUnsignedByte();
                    int unknown0        = message.ReadUnsignedByte();
                    int unknown1        = message.ReadUnsignedByte();
                    int unknown2        = message.ReadUnsignedByte();
                }

                bool canSelectCharm = message.ReadBoolean();
            }
        }