Ejemplo n.º 1
0
        private void ParseLoginSuccess(Internal.CommunicationStream message)
        {
            Player.Id = message.ReadUnsignedInt();

#if !UNITY_EDITOR && UNITY_STANDALONE_WIN
            string title = string.Format("{0} - {1}", Application.productName, CharacterName);
            OpenTibiaUnity.GameManager.SetApplicationTitle(title);
#endif

            BeatDuration = message.ReadUnsignedShort();
            if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GameNewSpeedLaw))
            {
                Creatures.Creature.SpeedA = message.ReadDouble();
                Creatures.Creature.SpeedB = message.ReadDouble();
                Creatures.Creature.SpeedC = message.ReadDouble();
            }

            BugReportsAllowed = message.ReadBoolean();
            if (OpenTibiaUnity.GameManager.ClientVersion >= 1054)
            {
                bool canChangePvPFrameRate = message.ReadBoolean();
            }

            if (OpenTibiaUnity.GameManager.ClientVersion >= 1058)
            {
                bool exportPvPEnabled = message.ReadBoolean();
            }

            if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GameIngameStore))
            {
                string storeLink        = message.ReadString();
                ushort storePackageSize = message.ReadUnsignedShort();
            }

            if (OpenTibiaUnity.GameManager.ClientVersion >= 1149 && OpenTibiaUnity.GameManager.BuildVersion >= 6018)
            {
                bool exivaRestrictions = message.ReadBoolean();
            }

            if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GameTournament))
            {
                bool tournamentActivated = message.ReadBoolean();
            }
        }
Ejemplo n.º 2
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);
                }
            }
        }