Esempio n. 1
0
        private void ParseGraphicalEffect(Internal.CommunicationStream message)
        {
            var  position = message.ReadPosition();
            byte effectId = message.ReadUnsignedByte();

            var effect = AppearanceStorage.CreateEffectInstance(effectId);

            if (!effect)
            {
                throw new System.Exception("ProtocolGame.ParseGraphicalEffect: Unknown effect id: " + effectId);
            }

            WorldMapStorage.AppendEffect(position, effect);
        }
Esempio n. 2
0
        private void ParseTrackedQuestFlags(Internal.CommunicationStream message)
        {
            bool full = message.ReadUnsignedByte() == 1;

            if (full)
            {
                int unknown2 = message.ReadUnsignedByte();
                int size     = message.ReadUnsignedByte();
                for (int i = 0; i < size; i++)
                {
                    int    missionId          = message.ReadUnsignedShort();
                    string questName          = message.ReadString();
                    string missionName        = message.ReadString();
                    string missionDescription = message.ReadString();
                }
            }
            else
            {
                int    missionId   = message.ReadUnsignedShort();
                string questName   = message.ReadString();
                string missionName = message.ReadString();
            }
        }
Esempio n. 3
0
        private void ParseChannels(Internal.CommunicationStream message)
        {
            int count = message.ReadUnsignedByte();
            List <Chat.Channel> channels = new List <Chat.Channel>(count);

            for (int i = 0; i < count; i++)
            {
                int    id   = message.ReadUnsignedShort();
                string name = message.ReadString();
                channels.Add(new Chat.Channel(id, name, MessageModeType.None));
            }

            OpenTibiaUnity.GameManager.onReceiveChannels.Invoke(channels);
        }
Esempio n. 4
0
        private void ReadCyclopediaCharacterInfoCombatStats(Internal.CommunicationStream message)
        {
            SkillType[] specialSkills = new SkillType[] {
                SkillType.CriticalHitChance,
                SkillType.CriticalHitDamage,
                SkillType.LifeLeechChance,
                SkillType.LifeLeechAmount,
                SkillType.ManaLeechChance,
                SkillType.ManaLeechAmount
            };

            foreach (var skill in specialSkills)
            {
                var skillStruct = ReadSkill(message, true);
            }

            int playerBlessings = message.ReadUnsignedByte();
            int totalBlessings  = message.ReadUnsignedByte();

            ushort attackValue = message.ReadUnsignedShort();
            var    combatType  = message.ReadEnum <CyclopediaCombatType>();

            int convertedDamage = message.ReadUnsignedByte();

            combatType = message.ReadEnum <CyclopediaCombatType>();

            int armorValue   = message.ReadUnsignedShort();
            int defenseValue = message.ReadUnsignedShort();

            int combats = message.ReadUnsignedByte();

            for (int i = 0; i < combats; i++)
            {
                combatType = message.ReadEnum <CyclopediaCombatType>();
                int combatValue = message.ReadUnsignedByte();
            }
        }
Esempio n. 5
0
        public StoreVisualisation ReadStoreVisualisation(Internal.CommunicationStream message)
        {
            var appearanceType = message.ReadEnum <StoreOfferAppearanceType>();

            switch (appearanceType)
            {
            case StoreOfferAppearanceType.Icon:
            {
                string icon = message.ReadString();
                return(new Store.Visualisations.StoreIconVisualisation(icon));
            }

            case StoreOfferAppearanceType.Mount:
            {
                ushort outfitId = message.ReadUnsignedShort();
                return(new Store.Visualisations.StoreMountVisualisation(outfitId));
            }

            case StoreOfferAppearanceType.Outfit:
            {
                ushort outfitId = message.ReadUnsignedShort();
                byte   head     = message.ReadUnsignedByte();
                byte   body     = message.ReadUnsignedByte();
                byte   legs     = message.ReadUnsignedByte();
                byte   feet     = message.ReadUnsignedByte();
                return(new Store.Visualisations.StoreOutfitVisualisation(outfitId, head, body, legs, feet));
            }

            case StoreOfferAppearanceType.Object:
            {
                ushort objectId = message.ReadUnsignedShort();
                return(new Store.Visualisations.StoreObjectVisualisation(objectId));
            }
            }

            return(null);
        }
Esempio n. 6
0
        private void ParseCreatureSkull(Internal.CommunicationStream message)
        {
            uint creatureId = message.ReadUnsignedInt();
            byte pkFlag     = message.ReadUnsignedByte();

            var creature = CreatureStorage.GetCreature(creatureId);

            if (!!creature)
            {
                creature.SetPKFlag((PKFlag)pkFlag);
                CreatureStorage.InvalidateOpponents();
            }/*else {
              * throw new System.Exception("ProtocolGame.ParseCreatureSkull: Unknown creature id: " + creatureId);
              * }*/
        }
Esempio n. 7
0
 private void ParsePlayerStates(Internal.CommunicationStream message)
 {
     if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GamePlayerStateU32))
     {
         Player.StateFlags = message.ReadUnsignedInt();
     }
     else if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GamePlayerStateU16))
     {
         Player.StateFlags = message.ReadUnsignedShort();
     }
     else
     {
         Player.StateFlags = message.ReadUnsignedByte();
     }
 }
Esempio n. 8
0
        private void ParseCreatureHealth(Internal.CommunicationStream message)
        {
            uint creatureId    = message.ReadUnsignedInt();
            byte healthPercent = message.ReadUnsignedByte();

            var creature = CreatureStorage.GetCreature(creatureId);

            if (!!creature)
            {
                creature.SetSkill(SkillType.HealthPercent, healthPercent);
                CreatureStorage.InvalidateOpponents();
            }/*else {
              * throw new System.Exception("ProtocolGame.ParseCreatureHealth: Unknown creature id: " + creatureId);
              * }*/
        }
Esempio n. 9
0
        private void ParseCreatureMark(Internal.CommunicationStream message)
        {
            uint creatureId = message.ReadUnsignedInt();
            byte mark       = message.ReadUnsignedByte();

            var creature = CreatureStorage.GetCreature(creatureId);

            if (!!creature)
            {
                creature.Marks.SetMark(MarkType.OneSecondTemp, mark);
                CreatureStorage.InvalidateOpponents();
            }/*else {
              * throw new System.Exception("ProtocolGame.ParseCreatureMark: Unknown creature id: " + creatureId);
              * }*/
        }
Esempio n. 10
0
        private void ParseMissleEffect(Internal.CommunicationStream message)
        {
            var  fromPosition = message.ReadPosition();
            var  toPosition   = message.ReadPosition();
            byte missleId     = message.ReadUnsignedByte();

            var missle = AppearanceStorage.CreateMissileInstance(missleId, fromPosition, toPosition);

            if (!missle)
            {
                throw new System.Exception("ProtocolGame.ParseMissleEffect: Unknown missle id: " + missleId);
            }

            WorldMapStorage.AppendEffect(fromPosition, missle);
        }
Esempio n. 11
0
        private void ParseTrappers(Internal.CommunicationStream message)
        {
            int n = message.ReadUnsignedByte();
            List <Creatures.Creature> trappers = new List <Creatures.Creature>();

            for (int i = 0; i < n; i++)
            {
                var creatureId = message.ReadUnsignedInt();
                var creature   = CreatureStorage.GetCreature(creatureId);
                if (creature)
                {
                    trappers.Add(creature);
                }
            }

            CreatureStorage.SetTrappers(trappers);
        }
Esempio n. 12
0
        private void ParseCreateInContainer(Internal.CommunicationStream message)
        {
            byte   containerId = message.ReadUnsignedByte();
            ushort slot        = 0;

            if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GameContainerPagination))
            {
                slot = message.ReadUnsignedShort();
            }
            var @object = ProtocolGameExtentions.ReadObjectInstance(message);

            var containerView = ContainerStorage.GetContainerView(containerId);

            if (!!containerView)
            {
                containerView.AddObject(slot, @object);
            }
        }
Esempio n. 13
0
        private AppearanceInstance ReadCreatureOutfit(Internal.CommunicationStream message, AppearanceInstance instance = null)
        {
            int outfitId;

            if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GameOutfitIdU16))
            {
                outfitId = message.ReadUnsignedShort();
            }
            else
            {
                outfitId = message.ReadUnsignedByte();
            }

            if (outfitId != 0)
            {
                int headColor   = message.ReadUnsignedByte();
                int torsoColor  = message.ReadUnsignedByte();
                int legsColor   = message.ReadUnsignedByte();
                int detailColor = message.ReadUnsignedByte();

                int addonsFlags = 0;
                if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GamePlayerAddons))
                {
                    addonsFlags = message.ReadUnsignedByte();
                }

                OutfitInstance outfitInstance = instance as OutfitInstance;
                if (!!outfitInstance)
                {
                    outfitInstance.UpdateProperties(headColor, torsoColor, legsColor, detailColor, addonsFlags);
                    return(instance);
                }

                return(AppearanceStorage.CreateOutfitInstance((uint)outfitId, headColor, torsoColor, legsColor, detailColor, addonsFlags));
            }

            uint           objectId       = message.ReadUnsignedShort();
            ObjectInstance objectInstance = instance as ObjectInstance;

            if (!!objectInstance && objectInstance.Id == objectId)
            {
                return(objectInstance);
            }

            if (objectId == 0)
            {
                return(AppearanceStorage.CreateOutfitInstance(OutfitInstance.InvisibleOutfitId, 0, 0, 0, 0, 0));
            }

            return(AppearanceStorage.CreateObjectInstance(objectId, 0));
        }
Esempio n. 14
0
        private void ParseBlessings(Internal.CommunicationStream message)
        {
            var    protocolVersion = OpenTibiaUnity.GameManager.ProtocolVersion;
            ushort blessings       = message.ReadUnsignedShort();

            if (protocolVersion < 1120)
            {
                Player.HasFullBlessings = blessings == 1;
            }
            else
            {
                Player.Blessings = blessings;
            }

            if (protocolVersion >= 1120)
            {
                message.ReadUnsignedByte(); // buttonStatus
            }
        }
Esempio n. 15
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();
                }
            }
        }
Esempio n. 16
0
        private Market.Offer ReadMarketOffer(Internal.CommunicationStream message, MarketOfferType offerType, ushort var)
        {
            uint   timestamp = message.ReadUnsignedInt();
            ushort counter   = message.ReadUnsignedShort();

            ushort objectId;

            switch (var)
            {
            case Constants.MarketRequestOwnOffers:
            case Constants.MarketRequestOwnHistory:
                objectId = message.ReadUnsignedShort();
                break;

            default:
                objectId = var;
                break;
            }

            ushort amount     = message.ReadUnsignedShort();
            uint   piecePrice = message.ReadUnsignedInt();

            MarketOfferState state     = MarketOfferState.Active;
            string           character = null;

            switch (var)
            {
            case Constants.MarketRequestOwnOffers:
                break;

            case Constants.MarketRequestOwnHistory:
                state = (MarketOfferState)message.ReadUnsignedByte();
                break;

            default:
                character = message.ReadString();
                break;
            }

            return(new Market.Offer(new Market.OfferId(counter, timestamp), offerType, objectId, amount, piecePrice, character, state));
        }
Esempio n. 17
0
        private void ParseCreatureType(Internal.CommunicationStream message)
        {
            uint creatureId = message.ReadUnsignedInt();
            byte type       = message.ReadUnsignedByte();
            uint master     = 0;

            if (OpenTibiaUnity.GameManager.ClientVersion >= 1120 && type == (int)CreatureType.Summon)
            {
                master = message.ReadUnsignedInt();
            }

            var creature = CreatureStorage.GetCreature(creatureId);

            if (!!creature)
            {
                creature.Type = (CreatureType)type;
                creature.SetSummonerId(master);
            }/*else {
              * throw new System.Exception("ProtocolGame.ParseCreatureType: Unknown creature id: " + creatureId);
              * }*/
        }
Esempio n. 18
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);
        }
Esempio n. 19
0
        public StoreProduct ReadStoreProduct(Internal.CommunicationStream message)
        {
            string name        = message.ReadString();
            string description = null;
            List <StoreVisualisation> visualisations = new List <StoreVisualisation>();

            if (OpenTibiaUnity.GameManager.ClientVersion < 1180)
            {
                description = message.ReadString();

                int iconCount = message.ReadUnsignedByte();
                for (int i = 0; i < iconCount; i++)
                {
                    visualisations.Add(new Store.Visualisations.StoreIconVisualisation(message.ReadString()));
                }
            }
            else
            {
                visualisations.Add(ReadStoreVisualisation(message));
            }

            return(new StoreProduct(name, description, visualisations));
        }
Esempio n. 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,
            });
        }
Esempio n. 21
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);
        }
Esempio n. 22
0
 private void ParseStoreError(Internal.CommunicationStream message)
 {
     int    type  = message.ReadUnsignedByte();
     string error = message.ReadString();
 }
Esempio n. 23
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();
            }
        }
Esempio n. 24
0
 private void ParseInspectionState(Internal.CommunicationStream message)
 {
     uint creatureId = message.ReadUnsignedInt();
     byte state      = message.ReadUnsignedByte();
 }
Esempio n. 25
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. 26
0
 private void ParsePvpSituations(Internal.CommunicationStream message)
 {
     message.ReadUnsignedByte(); // situations
 }
Esempio n. 27
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);
        }
Esempio n. 28
0
 private void ParseDailyRewardCollectionState(Internal.CommunicationStream message)
 {
     message.ReadUnsignedByte(); // collection tokens
 }
Esempio n. 29
0
        private DailyReward.DailyReward ReadDailyReward(Internal.CommunicationStream message)
        {
            var rewardType = message.ReadEnum <DailyRewardType>();
            var reward     = new DailyReward.DailyReward(rewardType);

            switch (rewardType)
            {
            case DailyRewardType.PickedItems: {
                reward.AllowedMaximumItems = message.ReadUnsignedByte();
                int objectCount = message.ReadUnsignedByte();

                for (int i = 0; i < objectCount; i++)
                {
                    ushort objectId     = message.ReadUnsignedShort();
                    string objectName   = message.ReadString();
                    uint   objectWeight = message.ReadUnsignedInt();

                    reward.AddItem(new DailyReward.Types.Object(objectId, objectName, objectWeight, -1));
                }

                break;
            }

            case DailyRewardType.FixedItems: {
                int itemsCount = message.ReadUnsignedByte();
                for (int i = 0; i < itemsCount; i++)
                {
                    var subType = message.ReadEnum <DailyRewardSubType>();
                    switch (subType)
                    {
                    case DailyRewardSubType.Object: {
                        ushort objectId     = message.ReadUnsignedShort();
                        string objectName   = message.ReadString();
                        int    objectAmount = message.ReadUnsignedByte();

                        reward.AddItem(new DailyReward.Types.Object(objectId, objectName, 0, objectAmount));
                        break;
                    }

                    case DailyRewardSubType.PreyBonusRerolls: {
                        int amount = message.ReadUnsignedByte();
                        reward.AddItem(new DailyReward.Types.PreyBonusRerolls(amount));
                        break;
                    }

                    case DailyRewardSubType.FiftyPercentXpBoost: {
                        ushort minutes = message.ReadUnsignedShort();
                        reward.AddItem(new DailyReward.Types.XpBoost(minutes));
                        break;
                    }

                    default:
                        throw new System.Exception("ProtocolGame.ReadDailyReward: Invalid reward sub-type " + (int)subType + ".");
                    }
                }

                break;
            }
            }

            return(reward);
        }
Esempio n. 30
0
        private void ParseCloseContainer(Internal.CommunicationStream message)
        {
            byte containerId = message.ReadUnsignedByte();

            ContainerStorage.CloseContainerView(containerId);
        }