Exemple #1
0
        private void ParseBasicData(Internal.CommunicationStream message)
        {
            bool premium = message.ReadBoolean();

            if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GamePremiumExpiration))
            {
                uint premiumExpiration = message.ReadUnsignedInt();
            }

            byte vocation = message.ReadUnsignedByte();

            if (OpenTibiaUnity.GameManager.ClientVersion >= 1100)
            {
                bool hasReachedMain = message.ReadBoolean();
            }

            List <byte> spells      = new List <byte>();
            ushort      spellsCount = message.ReadUnsignedShort();

            for (int i = 0; i < spellsCount; i++)
            {
                spells.Add(message.ReadUnsignedByte());
            }

            if (Player)
            {
                //_player.PremiumStatus = premium;
                //_player.PremiumExpiration = premiumExpiration;
                //_player.Vocation = vocation;
                //_player.ReachedMain = hasReachedMain;
            }
        }
Exemple #2
0
        private void ParseMonsterCyclopediaBonusEffects(Internal.CommunicationStream message)
        {
            int charmPoints = message.ReadInt();

            int count = message.ReadUnsignedByte();

            for (int i = 0; i < count; i++)
            {
                int    charmType        = message.ReadUnsignedByte();
                string charmName        = message.ReadString();
                string charmDescription = message.ReadString();

                byte   unknown2 = message.ReadUnsignedByte(); // valid values: 0, 1, 2 (likely to be agressive/defensive/passive)
                ushort price    = message.ReadUnsignedShort();

                bool unlocked  = message.ReadBoolean();
                bool activated = message.ReadBoolean();
                if (activated)
                {
                    ushort selectedCreature = message.ReadUnsignedShort(); // raceID
                    uint   clearPrice       = message.ReadUnsignedInt();
                }
            }

            byte remainingNumberOfAssignableBonusEffects = message.ReadUnsignedByte();
            bool hasCharmExpansion = remainingNumberOfAssignableBonusEffects == 255;

            // selectable race ids
            count = message.ReadUnsignedShort();
            for (int i = 0; i < count; i++)
            {
                ushort raceID = message.ReadUnsignedShort();
            }
        }
Exemple #3
0
        private void ParseStoreButtonIndicators(Internal.CommunicationStream message)
        {
            message.ReadBoolean(); // sale on items?
            message.ReadBoolean(); // new items on store?

            // TODO
        }
Exemple #4
0
        private void ParseOpenContainer(Internal.CommunicationStream message)
        {
            byte   containerId     = message.ReadUnsignedByte();
            var    objectIcon      = ProtocolGameExtentions.ReadObjectInstance(message);
            string name            = message.ReadString();
            byte   nOfSlotsPerPage = message.ReadUnsignedByte(); // capacity of shown view
            bool   isSubContainer  = message.ReadBoolean();

            bool canUseDepotSearch    = false;
            bool isDragAndDropEnabled = true;
            bool isPaginationEnabled  = false;
            int  nOfTotalObjects;
            int  indexOfFirstObject = 0;
            int  nOfContentObjects; // objects in the current shown view //

            if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GameContainerPagination))
            {
                if (OpenTibiaUnity.GameManager.ClientVersion >= 1220)
                {
                    canUseDepotSearch = message.ReadBoolean();
                }

                isDragAndDropEnabled = message.ReadBoolean();
                isPaginationEnabled  = message.ReadBoolean();
                nOfTotalObjects      = message.ReadUnsignedShort();
                indexOfFirstObject   = message.ReadUnsignedShort();
                nOfContentObjects    = message.ReadUnsignedByte();

                if (nOfContentObjects > nOfSlotsPerPage)
                {
                    throw new System.Exception("ProtocolGame.ParseOpenContainer: Number of content objects " + nOfContentObjects + " exceeds number of slots per page " + nOfSlotsPerPage);
                }

                if (nOfContentObjects > nOfTotalObjects)
                {
                    throw new System.Exception("ProtocolGame.ParseOpenContainer: Number of content objects " + nOfContentObjects + " exceeds number of total objects " + nOfTotalObjects);
                }
            }
            else
            {
                nOfContentObjects = message.ReadUnsignedByte();
                nOfTotalObjects   = nOfContentObjects;

                if (nOfContentObjects > nOfSlotsPerPage)
                {
                    throw new System.Exception("ProtocolGame.ParseOpenContainer: Number of content objects " + nOfContentObjects + " exceeds the capaciy " + nOfSlotsPerPage);
                }
            }

            var containerView = ContainerStorage.CreateContainerView(containerId, objectIcon, name, isSubContainer,
                                                                     isDragAndDropEnabled, isPaginationEnabled, nOfSlotsPerPage,
                                                                     nOfTotalObjects - nOfContentObjects, indexOfFirstObject, nOfContentObjects);

            for (int i = 0; i < nOfContentObjects; i++)
            {
                containerView.AddObject(indexOfFirstObject + i, ProtocolGameExtentions.ReadObjectInstance(message));
            }
        }
Exemple #5
0
        private void ParseDeath(Internal.CommunicationStream message)
        {
            var deathType = DeathType.DeathTypeRegular;

            if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GameDeathType))
            {
                deathType = (DeathType)message.ReadUnsignedByte();
            }

            int penalty = 100;

            if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GamePenalityOnDeath) && deathType == DeathType.DeathTypeRegular)
            {
                penalty = message.ReadUnsignedByte();
            }

            bool useDeathRedemption = false;

            if (OpenTibiaUnity.GameManager.ClientVersion >= 1120)
            {
                useDeathRedemption = message.ReadBoolean();
            }

            // TODO death actions...
            //LocalPlayer.OnDeath(deathType, penalty);
        }
Exemple #6
0
        private void ParseBuddyAdd(Internal.CommunicationStream message)
        {
            uint   creatureId  = message.ReadUnsignedInt();
            string name        = message.ReadString();
            string desc        = string.Empty;
            uint   icon        = 0;
            bool   notifyLogin = false;

            if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GameAdditionalVipInfo))
            {
                desc        = message.ReadString();
                icon        = message.ReadUnsignedInt();
                notifyLogin = message.ReadBoolean();
            }

            byte        status = message.ReadUnsignedByte();
            List <byte> groups;

            if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GameBuddyGroups))
            {
                int count = message.ReadUnsignedByte();
                groups = new List <byte>(count);
                for (int i = 0; i < count; i++)
                {
                    groups.Add(message.ReadUnsignedByte());
                }
            }
        }
Exemple #7
0
        public StoreOffer ReadExtendedStoreOffer(Internal.CommunicationStream message)
        {
            string name       = message.ReadString();
            var    storeOffer = new StoreOffer(name, null);

            byte quantityCount = message.ReadUnsignedByte();

            for (int i = 0; i < quantityCount; i++)
            {
                storeOffer.AddQuantityConfiguration(ReadStoreOfferQuantityConfiguration(message));
            }

            storeOffer.AddVisualisation(ReadStoreVisualisation(message));

            if (OpenTibiaUnity.GameManager.ClientVersion >= 1212)
            {
                message.ReadUnsignedByte(); // enum (0, 1, 2)
            }

            storeOffer.Filter = message.ReadString();

            storeOffer.TimeAddedToStore      = message.ReadUnsignedInt();
            storeOffer.TimesBought           = message.ReadUnsignedShort();
            storeOffer.RequiresConfiguration = message.ReadBoolean();

            ushort productCount = message.ReadUnsignedShort();

            for (int i = 0; i < productCount; i++)
            {
                storeOffer.AddProduct(ReadStoreProduct(message));
            }
            return(storeOffer);
        }
Exemple #8
0
        private void ParseShowModalDialog(Internal.CommunicationStream message)
        {
            uint   windowId      = message.ReadUnsignedInt();
            string title         = message.ReadString();
            string windowMessage = message.ReadString();

            byte buttonCount = message.ReadUnsignedByte();

            for (int i = 0; i < buttonCount; i++)
            {
                string buttonText = message.ReadString();
                byte   buttonId   = message.ReadUnsignedByte();
            }

            byte choiceCount = message.ReadUnsignedByte();

            for (int i = 0; i < choiceCount; i++)
            {
                string choiceText = message.ReadString();
                byte   choiceId   = message.ReadUnsignedByte();
            }

            byte defaultEscapeButtonId = message.ReadUnsignedByte();
            byte defaultEnterButtonId  = message.ReadUnsignedByte();
            bool priority = message.ReadBoolean();
        }
Exemple #9
0
        public StoreOpenParameters ReadStoreOpenParameters(Internal.CommunicationStream message)
        {
            var openAction = message.ReadEnum <StoreOpenParameterAction>();

            Store.OpenParameters.IStoreOpenParamater openParam = null;
            switch (openAction)
            {
            case StoreOpenParameterAction.Invalid:
            {
                break;
            }

            case StoreOpenParameterAction.CategoryType:
            {
                var categoryType = message.ReadEnum <StoreCategoryType>();
                openParam = new Store.OpenParameters.StoreCategoryTypeOpenParamater(categoryType);
                break;
            }

            case StoreOpenParameterAction.CategoryAndFilter:
            {
                var categoryAndFilter = ReadStoreCategoryAndFilter(message);
                openParam = new Store.OpenParameters.StoreCategoryAndFilterOpenParamater(categoryAndFilter);
                break;
            }

            case StoreOpenParameterAction.OfferType:
            {
                var offerType = message.ReadEnum <StoreOfferType>();
                openParam = new Store.OpenParameters.StoreOfferTypeOpenParamater(offerType);
                break;
            }

            case StoreOpenParameterAction.OfferId:
            {
                var offerId = message.ReadUnsignedInt();
                openParam = new Store.OpenParameters.StoreOfferIdOpenParamater(offerId);
                break;
            }

            case StoreOpenParameterAction.CategoryName:
            {
                var categoryName = message.ReadString();
                openParam = new Store.OpenParameters.StoreCategoryNameOpenParamater(categoryName);
                break;
            }
            }

            // enum too, 0, 1, 2, 3
            message.ReadUnsignedByte();

            /**
             * 0: default
             * 1: home
             * // 2, 3?
             */
            message.ReadBoolean(); // 0, 1, 2, 3 (enum)
            return(new StoreOpenParameters(openAction, openParam));
        }
Exemple #10
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();
            }
        }
Exemple #11
0
        private ObjectInstance ReadObjectInstance(Internal.CommunicationStream message, int id = -1)
        {
            if (id == -1)
            {
                id = message.ReadUnsignedShort();
            }

            if (id == 0)
            {
                return(null);
            }
            else if (id <= AppearanceInstance.Creature)
            {
                throw new System.Exception("ProtocolGameUtility.ReadObjectInstance: Invalid type (id = " + id + ")");
            }

            var @object = AppearanceStorage.CreateObjectInstance((uint)id, 0);

            if (!@object)
            {
                throw new System.Exception("ProtocolGameUtility.ReadObjectInstance: Invalid instance with id " + id);
            }

            if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GameObjectMarks))
            {
                @object.Marks.SetMark(MarkType.Permenant, message.ReadUnsignedByte());
            }

            if (@object.Type.IsStackable || @object.Type.IsFluidContainer || @object.Type.IsSplash)
            {
                @object.Data = message.ReadUnsignedByte();
            }

            if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GameItemAnimationPhase))
            {
                if (@object.Type.FrameGroups[(int)Protobuf.Shared.FrameGroupType.Idle].SpriteInfo.IsAnimation)
                {
                    int phase = message.ReadUnsignedByte();
                    @object.Phase = phase == 0 ? Constants.PhaseAutomatic : phase;
                }
            }

            if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GameQuickLoot) && @object.Type.IsContainer)
            {
                bool assignedToQuickLoot = message.ReadBoolean();
                if (assignedToQuickLoot)
                {
                    uint lootContainers = message.ReadUnsignedInt(); // 1 << ObjectCategory | ....
                }
            }

            return(@object);
        }
Exemple #12
0
        public StoreOfferQuantityConfiguration ReadStoreOfferQuantityConfiguration(Internal.CommunicationStream message)
        {
            uint   offerId = message.ReadUnsignedInt();
            ushort amount  = message.ReadUnsignedShort();
            uint   price   = message.ReadUnsignedInt();
            bool   useTransferableCoins = message.ReadBoolean();

            bool disabled        = message.ReadBoolean();
            var  disabledReasons = new List <string>();

            if (disabled)
            {
                int errorCount = message.ReadUnsignedByte();
                for (int i = 0; i < errorCount; i++)
                {
                    disabledReasons.Add(message.ReadString());
                }
            }

            var highlightState = message.ReadEnum <StoreHighlightState>();

            if (highlightState == StoreHighlightState.Sale)
            {
                uint saleValidUntilTimestamp = message.ReadUnsignedInt();
                uint basePrice = message.ReadUnsignedInt();
            }

            var quantityConfiguration = new StoreOfferQuantityConfiguration(offerId, price, amount, highlightState, useTransferableCoins);

            quantityConfiguration.DisabledReasons.AddRange(disabledReasons);

            if (disabled)
            {
                quantityConfiguration.DisabledState = StoreOfferDisableState.Disabled;
            }

            return(quantityConfiguration);
        }
Exemple #13
0
        private void ParseCreatureUnpass(Internal.CommunicationStream message)
        {
            uint creatureId = message.ReadUnsignedInt();
            bool unpass     = message.ReadBoolean();

            var creature = CreatureStorage.GetCreature(creatureId);

            if (!!creature)
            {
                creature.Unpassable = unpass;
            }/*else {
              * throw new System.Exception("ProtocolGame.ParseCreatureUnpass: Unknown creature id: " + creatureId);
              * }*/
        }
Exemple #14
0
        private void ParseOpenRewardWall(Internal.CommunicationStream message)
        {
            message.ReadBoolean();                                            // openedFromShrine
            message.ReadUnsignedInt();                                        // timestamp for the player to be able to take the reward (0 = able)
            message.ReadUnsignedByte();                                       // currentRewardIndex
            bool showWarningWhenCollecting = message.ReadUnsignedByte() != 0; // showWarningWhenCollecting

            if (showWarningWhenCollecting)
            {
                message.ReadString(); // warningMessage
            }

            message.ReadUnsignedInt();   // timestamp for the streak to expire (0 = won't expire until server save)
            message.ReadUnsignedShort(); // current streak
            message.ReadUnsignedShort(); // unknown
        }
Exemple #15
0
        private void ParseCreditBalance(Internal.CommunicationStream message)
        {
            bool updating = message.ReadBoolean();

            if (updating)
            {
                uint coins             = message.ReadUnsignedInt();
                uint transferableCoins = message.ReadUnsignedInt();
                uint tournamentCoins   = 0;

                if (OpenTibiaUnity.GameManager.ClientVersion >= 1215)
                {
                    tournamentCoins = message.ReadUnsignedInt();
                }
            }
        }
Exemple #16
0
        private void ParseShowModalDialog(Internal.CommunicationStream message)
        {
            var modalDialog = new ProtocolModalDialog();

            modalDialog.Id      = message.ReadUnsignedInt();
            modalDialog.Title   = message.ReadString();
            modalDialog.Message = message.ReadString();

            byte buttonCount = message.ReadUnsignedByte();

            modalDialog.Buttons = new ProtocolModalDialogEntity[buttonCount];
            for (int i = 0; i < buttonCount; i++)
            {
                string text = message.ReadString();
                byte   id   = message.ReadUnsignedByte();
                modalDialog.Buttons[i] = new ProtocolModalDialogEntity()
                {
                    Id   = id,
                    Text = text
                };
            }

            byte choiceCount = message.ReadUnsignedByte();

            modalDialog.Choices = new ProtocolModalDialogEntity[choiceCount];
            for (int i = 0; i < choiceCount; i++)
            {
                string text = message.ReadString();
                byte   id   = message.ReadUnsignedByte();
                modalDialog.Choices[i] = new ProtocolModalDialogEntity()
                {
                    Id   = id,
                    Text = text
                };
            }

            modalDialog.DefaultEnterButton  = message.ReadUnsignedByte();
            modalDialog.DefaultEscapeButton = message.ReadUnsignedByte();
            modalDialog.Priority            = message.ReadBoolean();

            OpenTibiaUnity.GameManager.onRequestModalDialog.Invoke(modalDialog);
        }
Exemple #17
0
        private void ReadCyclopediaCharacterInfoAchievements(Internal.CommunicationStream message)
        {
            ushort totalPoints             = message.ReadUnsignedShort();
            ushort totalSecretAchievements = message.ReadUnsignedShort();

            ushort obtainedAchievements = message.ReadUnsignedShort();

            for (int i = 0; i < obtainedAchievements; i++)
            {
                ushort achievementID = message.ReadUnsignedShort();
                uint   time          = message.ReadUnsignedInt();
                bool   secret        = message.ReadBoolean();
                if (secret)
                {
                    string name        = message.ReadString();
                    string description = message.ReadString();
                    int    grade       = message.ReadUnsignedByte();
                }
            }
        }
Exemple #18
0
        private void ParseInspectionList(Internal.CommunicationStream message)
        {
            bool isPlayer = message.ReadBoolean();

            int size = message.ReadUnsignedByte();

            for (int i = 0; i < size; i++)
            {
                var @object = ReadObjectInstance(message);
                if (isPlayer)
                {
                    var slot = message.ReadEnum <ClothSlots>();
                }

                int imbuementSlots = message.ReadUnsignedByte();
                for (int j = 0; j < imbuementSlots; j++)
                {
                    int imbuementId = message.ReadUnsignedByte();
                }

                int details = message.ReadUnsignedByte();
                for (int j = 0; j < details; j++)
                {
                    string name        = message.ReadString();
                    string description = message.ReadString();
                }
            }

            if (isPlayer)
            {
                string playerName = message.ReadString();
                var    outfit     = ReadCreatureOutfit(message);

                int details = message.ReadUnsignedByte();
                for (int j = 0; j < details; j++)
                {
                    string name        = message.ReadString();
                    string description = message.ReadString();
                }
            }
        }
Exemple #19
0
        private void ReadCyclopediaCharacterInfoGeneralStats(Internal.CommunicationStream message)
        {
            ulong  experience   = message.ReadUnsignedLong();
            ushort level        = message.ReadUnsignedShort();
            int    levelPercent = message.ReadUnsignedByte();

            float baseXpGain         = message.ReadUnsignedShort() / 100f;
            float grindingAddend     = message.ReadUnsignedShort() / 100f;
            float storeBoostAddend   = message.ReadUnsignedShort() / 100f;
            float huntingBoostFactor = message.ReadUnsignedShort() / 100f;

            message.ReadUnsignedShort(); // yet unknown
            bool canBuyXpBoost = message.ReadBoolean();

            int health    = message.ReadUnsignedShort();
            int maxHealth = message.ReadUnsignedShort();
            int mana      = message.ReadUnsignedShort();
            int maxMana   = message.ReadUnsignedShort();
            int soul      = message.ReadUnsignedByte();

            int ticks        = OpenTibiaUnity.TicksMillis;
            int stamina      = ticks + 60000 * message.ReadUnsignedShort();
            int regeneration = ticks + 1000 * message.ReadUnsignedShort();
            int training     = ticks + 60000 * message.ReadUnsignedShort();

            int speed     = message.ReadUnsignedShort();
            int baseSpeed = message.ReadUnsignedShort();

            uint totalCapacity = message.ReadUnsignedInt();
            uint baseCapacity  = message.ReadUnsignedInt();
            uint freeCapacity  = message.ReadUnsignedInt();

            int skillCount = message.ReadUnsignedByte();

            for (int i = 0; i < skillCount; i++)
            {
                var skillType = message.ReadEnum <SkillType>();
                var skill     = ReadSkill(message);
            }
        }
Exemple #20
0
        private ProtocolOutfit ReadNewProtocolOutfit(Internal.CommunicationStream message)
        {
            ushort outfitId   = message.ReadUnsignedShort();
            var    outfitName = message.ReadString();
            int    addOns     = message.ReadUnsignedByte();

            OutfitLockType lockType = OutfitLockType.Unlocked;
            uint           offerId  = 0;

            var clientVersion = OpenTibiaUnity.GameManager.ClientVersion;

            if (clientVersion >= 1185)
            {
                if (clientVersion >= 1220)
                {
                    lockType = message.ReadEnum <OutfitLockType>();
                }
                else if (message.ReadBoolean())
                {
                    lockType = OutfitLockType.Store;
                }

                if (lockType == OutfitLockType.Store)
                {
                    offerId = message.ReadUnsignedInt();
                }
            }

            return(new ProtocolOutfit()
            {
                _id = outfitId,
                Name = outfitName,
                AddOns = addOns,
                LockType = lockType,
                StoreOfferId = offerId,
            });
        }
Exemple #21
0
        private ProtocolMount ReadProtocolMount(Internal.CommunicationStream message)
        {
            ushort mountId   = message.ReadUnsignedShort();
            var    mountName = message.ReadString();
            bool   locked    = true;
            uint   offerId   = 0;

            if (OpenTibiaUnity.GameManager.ClientVersion >= 1185)
            {
                locked = message.ReadBoolean();
                if (locked)
                {
                    offerId = message.ReadUnsignedInt();
                }
            }

            return(new ProtocolMount()
            {
                _id = mountId,
                Name = mountName,
                Locked = locked,
                StoreOfferId = offerId,
            });
        }
Exemple #22
0
        private void ParseUpdateExivaOptions(Internal.CommunicationStream message)
        {
            message.ReadBoolean();
            message.ReadBoolean();
            message.ReadBoolean();
            message.ReadBoolean();
            message.ReadBoolean();
            message.ReadBoolean();

            List <string> list1 = new List <string>();
            List <string> list2 = new List <string>();
            List <string> list3 = new List <string>();
            List <string> list4 = new List <string>();

            int count = message.ReadUnsignedShort();

            for (int i = 0; i < count; i++)
            {
                list1.Add(message.ReadString());
            }

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

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

            count = message.ReadUnsignedShort();
            for (int i = 0; i < count; i++)
            {
                list4.Add(message.ReadString());
            }
        }
Exemple #23
0
 private void ParseRestingAreaState(Internal.CommunicationStream message)
 {
     bool   inRestingArea      = message.ReadBoolean();
     bool   restingBonusActive = message.ReadBoolean();
     string description        = message.ReadString();
 }
Exemple #24
0
        private void ParseCyclopediaMapData(Internal.CommunicationStream message)
        {
            int dataType = message.ReadUnsignedByte();

            // unfinished packet, more information needed....
            switch (dataType)
            {
            case 0:
            {         // StaticMarker (sure)
                var    position        = message.ReadPosition();
                int    markType        = message.ReadUnsignedByte();
                string markDescription = message.ReadString();
                break;
            }

            case 1:
            {         // idk?
                int count = message.ReadUnsignedShort();
                for (int i = 0; i < count; i++)
                {
                    // UnlockedArea (struct)
                    int unknown1 = message.ReadUnsignedByte();         // unknown
                    int unknown2 = message.ReadUnsignedByte();         // unknown
                    int unknown3 = message.ReadUnsignedByte();         // (enum) maximum value: 3
                    int unknown4 = message.ReadUnsignedByte();         // unknown
                }

                count = message.ReadUnsignedShort();
                for (int i = 0; i < count; i++)
                {
                    ushort unknown = message.ReadUnsignedShort();         // unknown
                }

                count = message.ReadUnsignedShort();
                for (int i = 0; i < count; i++)
                {
                    ushort unknown = message.ReadUnsignedShort();         // unknown
                }

                break;
            }

            case 2:
            {         // Raid (sure)
                var  position = message.ReadPosition();
                bool inactive = message.ReadBoolean();
                break;
            }

            case 3:
            {                               // ImminentRaid (not sure)
                message.ReadUnsignedByte(); // unknown
                message.ReadUnsignedByte(); // unknown
                message.ReadUnsignedByte(); // unknown
                break;
            }

            case 4:
            {                               // ViewPoints (not sure)
                message.ReadUnsignedByte(); // unknown
                message.ReadUnsignedByte(); // unknown
                message.ReadUnsignedByte(); // unknown
                break;
            }


            case 5:
            {                                                   // idk? (but it unlocks areas)
                ushort areaId    = message.ReadUnsignedShort(); // this is likely to be areaId
                byte   totalPois = message.ReadUnsignedByte();  // unknown

                // points of interest unlocked!
                int poiCount = message.ReadUnsignedByte();
                for (int i = 0; i < poiCount; i++)
                {
                    // point of interest
                    var position = message.ReadPosition();
                    int unknown6 = message.ReadUnsignedByte();
                }

                break;
            }

            case 6:
            {
                break;
            }

            case 7:
            {
                break;
            }

            case 8:
            {
                break;
            }

            case 9:
            {
                //
                uint maximumGold = message.ReadUnsignedInt();      // maximum gold? (used for progress)
                uint unknown2    = message.ReadUnsignedInt();      // unknown

                // these are area donations,
                byte listCount = message.ReadUnsignedByte();
                for (int i = 0; i < listCount; i++)
                {
                    // ushort areaId, uint gold contributed
                    //
                    uint unknown5 = message.ReadUnsignedShort();
                    uint unknown3 = message.ReadUnsignedInt();
                    uint unknown4 = message.ReadUnsignedInt();
                    uint unknown6 = message.ReadUnsignedByte();
                }
                break;
            }

            case 10:
            {
                ushort unknown = message.ReadUnsignedShort();
                break;
            }

            case 11:
            {
                break;
            }
            }
        }
Exemple #25
0
 private void ParseImpactTracking(Internal.CommunicationStream message)
 {
     bool healing = message.ReadBoolean();
     uint damage  = message.ReadUnsignedInt();
 }
Exemple #26
0
 private void ParseUpdatingStoreBalance(Internal.CommunicationStream message)
 {
     bool updating = message.ReadBoolean();
 }
Exemple #27
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();
            }
        }
Exemple #28
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);
                }
            }
        }
Exemple #29
0
        private void ParseOutfitDialog(Internal.CommunicationStream message)
        {
            var outfit = ProtocolGameExtentions.ReadCreatureOutfit(message);

            Appearances.AppearanceInstance mountOutfit = null;
            if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GamePlayerMounts))
            {
                mountOutfit = ProtocolGameExtentions.ReadMountOutfit(message);
            }

            var outfitList = new List <ProtocolOutfit>();

            if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GameNewOutfitProtocol))
            {
                int count;
                if (OpenTibiaUnity.GameManager.ClientVersion >= 1185)
                {
                    count = message.ReadUnsignedShort();
                }
                else
                {
                    count = message.ReadUnsignedByte();
                }

                for (int i = 0; i < count; i++)
                {
                    outfitList.Add(ReadNewProtocolOutfit(message));
                }
            }
            else
            {
                ushort outfitStart, outfitEnd;
                if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GameOutfitIdU16))
                {
                    outfitStart = message.ReadUnsignedShort();
                    outfitEnd   = message.ReadUnsignedShort();
                }
                else
                {
                    outfitStart = message.ReadUnsignedByte();
                    outfitEnd   = message.ReadUnsignedByte();
                }

                for (ushort i = outfitStart; i <= outfitEnd; i++)
                {
                    outfitList.Add(new ProtocolOutfit()
                    {
                        _id = i
                    });
                }
            }

            List <ProtocolMount> mountList = null;

            if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GamePlayerMounts))
            {
                mountList = new List <ProtocolMount>();
                int count;
                if (OpenTibiaUnity.GameManager.ClientVersion >= 1185)
                {
                    count = message.ReadUnsignedShort();
                }
                else
                {
                    count = message.ReadUnsignedByte();
                }

                for (int i = 0; i < count; i++)
                {
                    mountList.Add(ReadProtocolMount(message));
                }
            }

            OutfitDialogType type = 0;

            if (OpenTibiaUnity.GameManager.ClientVersion >= 1185)
            {
                type = message.ReadEnum <OutfitDialogType>();
                bool mounted = message.ReadBoolean();
            }

            OpenTibiaUnity.GameManager.onRequestOutfitDialog.Invoke(outfit, mountOutfit, outfitList, mountList);
        }
Exemple #30
0
 private void ParseDepotTileState(Internal.CommunicationStream message)
 {
     Player.IsInDepot = message.ReadBoolean();
 }