Exemplo n.º 1
0
 public static PacketWriter AcceptOrTurnInQuest(MapEntityIndex questProvider, QuestID questID)
 {
     var pw = GetWriter(ClientPacketID.AcceptOrTurnInQuest);
     pw.Write(questProvider);
     pw.Write(questID);
     return pw;
 }
Exemplo n.º 2
0
        public static PacketWriter NotifyLevel(MapEntityIndex mapEntityIndex)
        {
            var pw = GetWriter(ServerPacketID.NotifyLevel);

            pw.Write(mapEntityIndex);
            return(pw);
        }
Exemplo n.º 3
0
 public static PacketWriter CharDamage(MapEntityIndex mapEntityIndex, int damage)
 {
     var pw = GetWriter(ServerPacketID.CharDamage);
     pw.Write(mapEntityIndex);
     pw.Write(damage);
     return pw;
 }
Exemplo n.º 4
0
        public static PacketWriter RemoveDynamicEntity(MapEntityIndex mei)
        {
            var pw = GetWriter(ServerPacketID.RemoveDynamicEntity);

            pw.Write(mei);
            return(pw);
        }
Exemplo n.º 5
0
        public static PacketWriter UseWorld(MapEntityIndex useItemIndex)
        {
            var pw = GetWriter(ClientPacketID.UseWorld);

            pw.Write(useItemIndex);
            return(pw);
        }
Exemplo n.º 6
0
        public static PacketWriter StartShopping(MapEntityIndex entityIndex)
        {
            var pw = GetWriter(ClientPacketID.StartShopping);

            pw.Write(entityIndex);
            return(pw);
        }
Exemplo n.º 7
0
        public static PacketWriter RequestDynamicEntity(MapEntityIndex index)
        {
            var pw = GetWriter(ClientPacketID.RequestDynamicEntity);

            pw.Write(index);
            return(pw);
        }
Exemplo n.º 8
0
        public static PacketWriter PickupItem(MapEntityIndex mapEntityIndex)
        {
            var pw = GetWriter(ClientPacketID.PickupItem);

            pw.Write(mapEntityIndex);
            return(pw);
        }
Exemplo n.º 9
0
        public ItemEntity(MapEntityIndex mapEntityIndex, Vector2 pos, Vector2 size, GrhIndex graphicIndex, TickCount currentTime)
            : base(pos, size)
        {
            Amount = 0;

            ((IDynamicEntitySetMapEntityIndex)this).SetMapEntityIndex(mapEntityIndex);
            _grh = new Grh(GrhInfo.GetData(graphicIndex), AnimType.Loop, currentTime);
        }
Exemplo n.º 10
0
        public static PacketWriter StartNPCChatDialog(MapEntityIndex npcIndex, bool forceSkipQuestDialog)
        {
            var pw = GetWriter(ClientPacketID.StartNPCChatDialog);

            pw.Write(npcIndex);
            pw.Write(forceSkipQuestDialog);
            return(pw);
        }
Exemplo n.º 11
0
        public static PacketWriter AcceptOrTurnInQuest(MapEntityIndex questProvider, QuestID questID)
        {
            var pw = GetWriter(ClientPacketID.AcceptOrTurnInQuest);

            pw.Write(questProvider);
            pw.Write(questID);
            return(pw);
        }
Exemplo n.º 12
0
        public static PacketWriter UseEntity(MapEntityIndex usedEntity, MapEntityIndex usedBy)
        {
            var pw = GetWriter(ServerPacketID.UseEntity);

            pw.Write(usedEntity);
            pw.Write(usedBy);
            return(pw);
        }
Exemplo n.º 13
0
        public ItemEntity(MapEntityIndex mapEntityIndex, Vector2 pos, Vector2 size, GrhIndex graphicIndex, TickCount currentTime)
            : base(pos, size)
        {
            Amount = 0;

            ((IDynamicEntitySetMapEntityIndex)this).SetMapEntityIndex(mapEntityIndex);
            _grh = new Grh(GrhInfo.GetData(graphicIndex), AnimType.Loop, currentTime);
        }
Exemplo n.º 14
0
        public static PacketWriter Emote(MapEntityIndex mapEntityIndex, Emoticon emoticon)
        {
            var pw = GetWriter(ServerPacketID.Emote);

            pw.Write(mapEntityIndex);
            pw.WriteEnum(emoticon);
            return(pw);
        }
Exemplo n.º 15
0
 public static PacketWriter ChatSay(string name, MapEntityIndex mapEntityIndex, string text)
 {
     var pw = GetWriter(ServerPacketID.ChatSay);
     pw.Write(name, GameData.MaxServerSayNameLength);
     pw.Write(mapEntityIndex);
     pw.Write(text, GameData.MaxServerSayLength);
     return pw;
 }
Exemplo n.º 16
0
        public static PacketWriter SkillStartCasting_ToMap(MapEntityIndex entityIndex, SkillType skillType)
        {
            var pw = GetWriter(ServerPacketID.SkillStartCasting_ToMap);

            pw.Write(entityIndex);
            pw.WriteEnum(skillType);
            return(pw);
        }
Exemplo n.º 17
0
        public static PacketWriter PlaySoundAtEntity(SoundID sound, MapEntityIndex mapEntityIndex)
        {
            var pw = GetWriter(ServerPacketID.PlaySoundAtEntity);

            pw.Write(sound);
            pw.Write(mapEntityIndex);
            return(pw);
        }
Exemplo n.º 18
0
        public static PacketWriter CharDamage(MapEntityIndex mapEntityIndex, int damage)
        {
            var pw = GetWriter(ServerPacketID.CharDamage);

            pw.Write(mapEntityIndex);
            pw.Write(damage);
            return(pw);
        }
Exemplo n.º 19
0
 public static PacketWriter Attack(MapEntityIndex? target)
 {
     var pw = GetWriter(ClientPacketID.Attack);
     pw.Write(target.HasValue);
     if (target.HasValue)
         pw.Write(target.Value);
     return pw;
 }
Exemplo n.º 20
0
        public static PacketWriter StartChatDialog(MapEntityIndex npcIndex, NPCChatDialogID dialogID)
        {
            var pw = GetWriter(ServerPacketID.StartChatDialog);

            pw.Write(npcIndex);
            pw.Write(dialogID);
            return(pw);
        }
Exemplo n.º 21
0
 public static PacketWriter StartShopping(MapEntityIndex shopOwnerIndex, IShop<ShopItem> shop)
 {
     var pw = GetWriter(ServerPacketID.StartShopping);
     pw.Write(shopOwnerIndex);
     pw.Write(shop.CanBuy);
     pw.Write(shop.Name);
     shop.WriteShopItems(pw);
     return pw;
 }
Exemplo n.º 22
0
 public static void SetProvidedQuests(PacketWriter pw, MapEntityIndex mapEntityIndex, IEnumerable <QuestID> quests)
 {
     pw.WriteEnum(ServerPacketID.SetProvidedQuests);
     pw.Write(mapEntityIndex);
     pw.Write((byte)quests.Count());
     foreach (var q in quests)
     {
         pw.Write(q);
     }
 }
Exemplo n.º 23
0
        public static PacketWriter SetCharacterPaperDoll(MapEntityIndex mapEntityIndex, IEnumerable<string> layers)
        {
            var pw = GetWriter(ServerPacketID.SetCharacterPaperDoll);
            pw.Write(mapEntityIndex);

            pw.Write((byte)layers.Count());
            foreach (var layer in layers)
            {
                pw.Write(layer);
            }

            return pw;
        }
Exemplo n.º 24
0
        public static PacketWriter CharAttack(MapEntityIndex attacker, MapEntityIndex? attacked = null, ActionDisplayID? actionDisplay = null)
        {
            var pw = GetWriter(ServerPacketID.CharAttack);
            pw.Write(attacker);

            pw.Write(attacked.HasValue);
            if (attacked.HasValue)
                pw.Write(attacked.Value);

            pw.Write(actionDisplay.HasValue);
            if (actionDisplay.HasValue)
                pw.Write(actionDisplay.Value);

            return pw;
        }
Exemplo n.º 25
0
        public static PacketWriter SkillUse(MapEntityIndex user, MapEntityIndex? target, SkillType skillType)
        {
            var pw = GetWriter(ServerPacketID.SkillUse);
            pw.Write(user);

            if (target.HasValue)
            {
                pw.Write(true);
                pw.Write(target.Value);
            }
            else
                pw.Write(false);

            pw.WriteEnum(skillType);

            return pw;
        }
Exemplo n.º 26
0
        static Character GetTargetCharacter(Character user, MapEntityIndex? index)
        {
            if (!index.HasValue)
                return null;

            // Check for a valid user
            if (user == null || user.Map == null)
                return null;

            // Check for a valid target index
            var target = user.Map.GetDynamicEntity<Character>(index.Value);
            if (target == null || target.Map != user.Map)
                return null;

            // Check for a valid distance
            if (user.GetDistance(target) > GameData.MaxTargetDistance)
                return null;

            return target;
        }
Exemplo n.º 27
0
        public static PacketWriter StartQuestChatDialog(MapEntityIndex npcIndex, IEnumerable <QuestID> availableQuests,
                                                        IEnumerable <QuestID> turnInQuests)
        {
            var pw = GetWriter(ServerPacketID.StartQuestChatDialog);

            pw.Write(npcIndex);

            // Write the list of available quests
            if (availableQuests != null)
            {
                var values = availableQuests.ToImmutable();
                Debug.Assert(values.Count() <= byte.MaxValue);
                pw.Write((byte)values.Count());
                foreach (var q in values)
                {
                    pw.Write(q);
                }
            }
            else
            {
                pw.Write((byte)0);
            }

            // Write the list of quests that can be turned in
            if (turnInQuests != null)
            {
                var values = turnInQuests.ToImmutable();
                Debug.Assert(values.Count() <= byte.MaxValue);
                pw.Write((byte)values.Count());
                foreach (var q in values)
                {
                    pw.Write(q);
                }
            }
            else
            {
                pw.Write((byte)0);
            }

            return(pw);
        }
Exemplo n.º 28
0
 public static PacketWriter PlaySoundAtEntity(SoundID sound, MapEntityIndex mapEntityIndex)
 {
     var pw = GetWriter(ServerPacketID.PlaySoundAtEntity);
     pw.Write(sound);
     pw.Write(mapEntityIndex);
     return pw;
 }
Exemplo n.º 29
0
 public static PacketWriter RemoveDynamicEntity(MapEntityIndex mei)
 {
     var pw = GetWriter(ServerPacketID.RemoveDynamicEntity);
     pw.Write(mei);
     return pw;
 }
Exemplo n.º 30
0
 public static PacketWriter UseEntity(MapEntityIndex usedEntity, MapEntityIndex usedBy)
 {
     var pw = GetWriter(ServerPacketID.UseEntity);
     pw.Write(usedEntity);
     pw.Write(usedBy);
     return pw;
 }
Exemplo n.º 31
0
 public static PacketWriter UseSkill(SkillType skillType, MapEntityIndex? target)
 {
     var pw = GetWriter(ClientPacketID.UseSkill);
     pw.WriteEnum(skillType);
     pw.Write(target.HasValue);
     if (target.HasValue)
         pw.Write(target.Value);
     return pw;
 }
Exemplo n.º 32
0
 public static PacketWriter UseWorld(MapEntityIndex useItemIndex)
 {
     var pw = GetWriter(ClientPacketID.UseWorld);
     pw.Write(useItemIndex);
     return pw;
 }
Exemplo n.º 33
0
 public static PacketWriter Emote(MapEntityIndex mapEntityIndex, Emoticon emoticon)
 {
     var pw = GetWriter(ServerPacketID.Emote);
     pw.Write(mapEntityIndex);
     pw.WriteEnum(emoticon);
     return pw;
 }
Exemplo n.º 34
0
            /// <summary>
            /// Gets a dynamic entity.
            /// </summary>
            /// <typeparam name="T">The type of <see cref="DynamicEntity"/> to get.</typeparam>
            /// <param name="index">The <see cref="MapEntityIndex"/>.</param>
            /// <returns>The <see cref="DynamicEntity"/> for the given <paramref name="index"/>, or null if no <see cref="DynamicEntity"/>
            /// exists at that index or it was an invalid type.</returns>
            public T GetDynamicEntity <T>(MapEntityIndex index) where T : class
            {
                var de     = _parent.Map.GetDynamicEntity(index);
                var casted = de as T;

                if (casted != null)
                {
                    // Successfully got the DynamicEntity
                    Debug.Assert(de.MapEntityIndex == index);
                    _getDynamicEntityFailTimers.Remove(index);
                    return(casted);
                }

                // Failed to get the DynamicEntity in the right type (or at all)

                // Log
                if (de == null)
                {
                    // No DynamicEntity found
                    const string errmsg = "No DynamicEntity found at index `{0}`.";
                    if (log.IsInfoEnabled)
                    {
                        log.InfoFormat(errmsg, index);
                    }
                }
                else
                {
                    // DynamicEntity found, but of the wrong type
                    const string errmsg = "DynamicEntity `{0}` found at index `{1}`, but it was of type `{2}` and not `{3}`.";
                    if (log.IsErrorEnabled)
                    {
                        log.ErrorFormat(errmsg, de, index, de.GetType(), typeof(T));
                    }
                }

                var now = TickCount.Now;

                // Check if we have failed with this index before, and if it is time to send a request to the server. Or, if we haven't
                // had a failure yet, add it.
                TickCount firstFailTime;

                if (!_getDynamicEntityFailTimers.TryGetValue(index, out firstFailTime))
                {
                    _getDynamicEntityFailTimers.Add(index, now);
                }
                else
                {
                    var deltaTime = now - firstFailTime;
                    if (deltaTime > _maxGetDynamicEntityFailTimeout)
                    {
                        const string msg = "Sending request for DynamicEntity with index `{0}`.";
                        if (log.IsInfoEnabled)
                        {
                            log.InfoFormat(msg, index);
                        }

                        // Enough time has elapsed to send the request
                        using (var pw = ClientPacket.RequestDynamicEntity(index))
                        {
                            _parent.NetworkSender.Send(pw, ClientMessageType.System);
                        }

                        _getDynamicEntityFailTimers.Remove(index);
                    }
                }

                return(null);
            }
Exemplo n.º 35
0
 public static PacketWriter StartShopping(MapEntityIndex entityIndex)
 {
     var pw = GetWriter(ClientPacketID.StartShopping);
     pw.Write(entityIndex);
     return pw;
 }
Exemplo n.º 36
0
 public static PacketWriter SkillStartCasting_ToMap(MapEntityIndex entityIndex, SkillType skillType)
 {
     var pw = GetWriter(ServerPacketID.SkillStartCasting_ToMap);
     pw.Write(entityIndex);
     pw.WriteEnum(skillType);
     return pw;
 }
Exemplo n.º 37
0
 /// <summary>
 /// Sets which map character is the one controlled by the user
 /// </summary>
 /// <param name="mapEntityIndex">Map character index controlled by the user</param>
 public static PacketWriter SetUserChar(MapEntityIndex mapEntityIndex)
 {
     var pw = GetWriter();
     SetUserChar(pw, mapEntityIndex);
     return pw;
 }
Exemplo n.º 38
0
 public static void SetUserChar(PacketWriter pw, MapEntityIndex mapEntityIndex)
 {
     pw.Write(ServerPacketID.SetUserChar);
     pw.Write(mapEntityIndex);
 }
Exemplo n.º 39
0
 public static PacketWriter RequestDynamicEntity(MapEntityIndex index)
 {
     var pw = GetWriter(ClientPacketID.RequestDynamicEntity);
     pw.Write(index);
     return pw;
 }
Exemplo n.º 40
0
 public static PacketWriter NotifyLevel(MapEntityIndex mapEntityIndex)
 {
     var pw = GetWriter(ServerPacketID.NotifyLevel);
     pw.Write(mapEntityIndex);
     return pw;
 }
Exemplo n.º 41
0
 public static void SetCharacterMPPercent(PacketWriter pw, MapEntityIndex mapEntityIndex, byte mpPercent)
 {
     pw.Write(ServerPacketID.SetCharacterMPPercent);
     pw.Write(mapEntityIndex);
     pw.Write(mpPercent);
 }
Exemplo n.º 42
0
 public static PacketWriter StartChatDialog(MapEntityIndex npcIndex, NPCChatDialogID dialogID)
 {
     var pw = GetWriter(ServerPacketID.StartChatDialog);
     pw.Write(npcIndex);
     pw.Write(dialogID);
     return pw;
 }
Exemplo n.º 43
0
 public static void SetUserChar(PacketWriter pw, MapEntityIndex mapEntityIndex)
 {
     pw.Write(ServerPacketID.SetUserChar);
     pw.Write(mapEntityIndex);
 }
Exemplo n.º 44
0
        public static PacketWriter StartQuestChatDialog(MapEntityIndex npcIndex, IEnumerable<QuestID> availableQuests,
                                                        IEnumerable<QuestID> turnInQuests)
        {
            var pw = GetWriter(ServerPacketID.StartQuestChatDialog);

            pw.Write(npcIndex);

            // Write the list of available quests
            if (availableQuests != null)
            {
                var values = availableQuests.ToImmutable();
                Debug.Assert(values.Count() <= byte.MaxValue);
                pw.Write((byte)values.Count());
                foreach (var q in values)
                {
                    pw.Write(q);
                }
            }
            else
                pw.Write((byte)0);

            // Write the list of quests that can be turned in
            if (turnInQuests != null)
            {
                var values = turnInQuests.ToImmutable();
                Debug.Assert(values.Count() <= byte.MaxValue);
                pw.Write((byte)values.Count());
                foreach (var q in values)
                {
                    pw.Write(q);
                }
            }
            else
                pw.Write((byte)0);

            return pw;
        }
Exemplo n.º 45
0
        public static PacketWriter CreateActionDisplayAtEntity(ActionDisplayID actionDisplayId, MapEntityIndex sourceEntityIndex, MapEntityIndex?targetEntityIndex = null)
        {
            var pw = GetWriter(ServerPacketID.CreateActionDisplayAtEntity);

            pw.Write(actionDisplayId);
            pw.Write(sourceEntityIndex);

            pw.Write(targetEntityIndex.HasValue);
            if (targetEntityIndex.HasValue)
            {
                pw.Write(targetEntityIndex.Value);
            }

            return(pw);
        }
Exemplo n.º 46
0
 public static void SetCharacterMPPercent(PacketWriter pw, MapEntityIndex mapEntityIndex, byte mpPercent)
 {
     pw.Write(ServerPacketID.SetCharacterMPPercent);
     pw.Write(mapEntityIndex);
     pw.Write(mpPercent);
 }
Exemplo n.º 47
0
        public static PacketWriter CreateActionDisplayAtEntity(ActionDisplayID actionDisplayId, MapEntityIndex sourceEntityIndex, MapEntityIndex? targetEntityIndex = null)
        {
            var pw = GetWriter(ServerPacketID.CreateActionDisplayAtEntity);
            pw.Write(actionDisplayId);
            pw.Write(sourceEntityIndex);

            pw.Write(targetEntityIndex.HasValue);
            if (targetEntityIndex.HasValue)
                pw.Write(targetEntityIndex.Value);

            return pw;
        }
Exemplo n.º 48
0
 public static PacketWriter SetCharacterMPPercent(MapEntityIndex mapEntityIndex, byte mpPercent)
 {
     var pw = GetWriter();
     SetCharacterMPPercent(pw, mapEntityIndex, mpPercent);
     return pw;
 }
Exemplo n.º 49
0
 public static PacketWriter SkillStopCasting_ToMap(MapEntityIndex entityIndex)
 {
     var pw = GetWriter(ServerPacketID.SkillStopCasting_ToMap);
     pw.Write(entityIndex);
     return pw;
 }
Exemplo n.º 50
0
 public static PacketWriter StartNPCChatDialog(MapEntityIndex npcIndex, bool forceSkipQuestDialog)
 {
     var pw = GetWriter(ClientPacketID.StartNPCChatDialog);
     pw.Write(npcIndex);
     pw.Write(forceSkipQuestDialog);
     return pw;
 }
Exemplo n.º 51
0
 public static void SetProvidedQuests(PacketWriter pw, MapEntityIndex mapEntityIndex, IEnumerable<QuestID> quests)
 {
     pw.WriteEnum(ServerPacketID.SetProvidedQuests);
     pw.Write(mapEntityIndex);
     pw.Write((byte)quests.Count());
     foreach (var q in quests)
     {
         pw.Write(q);
     }
 }
Exemplo n.º 52
0
 public static void Write(this BitStream bitStream, MapEntityIndex mapEntityIndex)
 {
     bitStream.Write(null, mapEntityIndex);
 }