コード例 #1
0
        void RecvCreateActionDisplayAtEntity(IIPSocket conn, BitStream r)
        {
            ActionDisplayID actionDisplayId = r.ReadActionDisplayID();
            MapEntityIndex sourceEntityIndex = r.ReadMapEntityIndex();
            bool hasTarget = r.ReadBool();
            MapEntityIndex? targetEntityIndex = hasTarget ? r.ReadMapEntityIndex() : (MapEntityIndex?)null;

            // Get the entities
            var sourceEntity = _objGrabber.GetDynamicEntity<Character>(sourceEntityIndex);
            if (sourceEntity == null)
                return;

            var targetEntity = targetEntityIndex.HasValue ? _objGrabber.GetDynamicEntity<Character>(targetEntityIndex.Value) : null;

            // Get the action display
            var ad = ActionDisplayScripts.ActionDisplays[actionDisplayId];
            if (ad == null)
                return;

            // Create
            ad.Execute(Map, sourceEntity, targetEntity);
        }
コード例 #2
0
        void RecvSkillUse(IIPSocket conn, BitStream r)
        {
            var casterEntityIndex = r.ReadMapEntityIndex();
            var hasTarget = r.ReadBool();
            MapEntityIndex? targetEntityIndex = null;
            if (hasTarget)
                targetEntityIndex = r.ReadMapEntityIndex();
            var skillType = r.ReadEnum<SkillType>();

            var casterEntity = _objGrabber.GetDynamicEntity<CharacterEntity>(casterEntityIndex);
            CharacterEntity targetEntity = null;
            if (targetEntityIndex.HasValue)
                targetEntity = _objGrabber.GetDynamicEntity<CharacterEntity>(targetEntityIndex.Value);

            if (casterEntity == null)
                return;

            // Get the SkillInfo for the skill being used
            var skillInfo = _objGrabber.GetSkillInfo(skillType);
            if (skillInfo == null)
                return;

            // If an ActionDisplay is available for this skill, display it
            if (skillInfo.CastActionDisplay.HasValue)
            {
                var ad = ActionDisplayScripts.ActionDisplays[skillInfo.CastActionDisplay.Value];
                if (ad != null)
                    ad.Execute(Map, casterEntity, targetEntity);
            }
        }
コード例 #3
0
        void RecvSetInventorySlot(IIPSocket conn, BitStream r)
        {
            var slot = r.ReadInventorySlot();
            var hasGraphic = r.ReadBool();
            var graphic = hasGraphic ? r.ReadGrhIndex() : GrhIndex.Invalid;
            var amount = r.ReadByte();

            UserInfo.Inventory.Update(slot, graphic, amount, GetTime());
        }
コード例 #4
0
        void RecvSkillSetKnown(IIPSocket conn, BitStream r)
        {
            var skillType = r.ReadEnum<SkillType>();
            var isKnown = r.ReadBool();

            if (!EnumHelper<SkillType>.IsDefined(skillType))
            {
                const string errmsg = "Invalid SkillType received: `{0}`";
                if (log.IsWarnEnabled)
                    log.WarnFormat(errmsg, skillType);
                Debug.Fail(string.Format(errmsg, skillType));
                return;
            }

            // Set the skill's known state
            UserInfo.KnownSkills.SetSkill(skillType, isKnown);
        }
コード例 #5
0
ファイル: UserGuildInformation.cs プロジェクト: wtfcolt/game
        /// <summary>
        /// Reads the <see cref="GuildInfoMessages.SetGuild"/> message.
        /// </summary>
        /// <param name="r">The stream to read the message from.</param>
        void ReadSetGuild(BitStream r)
        {
            _members.Clear();
            _onlineMembers.Clear();

            InGuild = r.ReadBool();

            if (InGuild)
            {
                Name = r.ReadString();
                Tag = r.ReadString();

                var numMembers = r.ReadUShort();
                for (var i = 0; i < numMembers; i++)
                {
                    var v = r.ReadGuildMemberNameRank(null);
                    _members.Add(v);
                }

                var onlineMembers = r.ReadUShort();
                for (var i = 0; i < onlineMembers; i++)
                {
                    var name = r.ReadString();
                    SetOnlineValue(name, true);
                }

                _members.Sort();
            }

            OnGuildChanged();

            if (GuildChanged != null)
                GuildChanged.Raise(this, EventArgs.Empty);
        }
コード例 #6
0
 void RecvSetClickWarpMode(IIPSocket conn, BitStream r)
 {
     bool enabled = r.ReadBool();
     GameplayScreen.AppendToChatOutput("Click warp mode: " + (enabled ? "Enabled" : "Disabled"), Color.Green);
     GameplayScreen.ClickWarpMode = enabled;
 }
コード例 #7
0
        void RecvCreateAccount(IIPSocket conn, BitStream r)
        {
            var successful = r.ReadBool();
            var errorMessage = string.Empty;

            if (!successful)
            {
                var failureGameMessage = r.ReadEnum<GameMessage>();
                errorMessage = GameMessageCollection.CurrentLanguage.GetMessage(failureGameMessage);
            }

            if (ReceivedCreateAccount != null)
                ReceivedCreateAccount.Raise(conn, new CreateAccountEventArgs(successful, errorMessage));
        }
コード例 #8
0
        void RecvStartNPCChatDialog(IIPSocket conn, BitStream r)
        {
            var npcIndex = r.ReadMapEntityIndex();
            var forceSkipQuestDialog = r.ReadBool();

            User user;
            Map map;
            if (!TryGetMap(conn, out user, out map))
                return;

            if (user.IsPeerTrading)
                return;

            var npc = map.GetDynamicEntity<NPC>(npcIndex);
            if (npc == null)
                return;

            // Check the distance and state
            if (user.Map != npc.Map || user.Map == null || !npc.IsAlive || npc.IsDisposed || user.GetDistance(npc) > GameData.MaxNPCChatDistance)
                return;

            // If the NPC provides any quests that this user can do or turn in, show that instead
            if (!forceSkipQuestDialog && !npc.Quests.IsEmpty())
            {
                IQuest<User>[] availableQuests;
                IQuest<User>[] turnInQuests;
                QuestHelper.GetAvailableQuests(user, npc, out availableQuests, out turnInQuests);

                if (availableQuests.Length > 0 || turnInQuests.Length > 0)
                {
                    using (var pw = ServerPacket.StartQuestChatDialog(npcIndex, availableQuests.Select(x => x.QuestID), turnInQuests.Select(x => x.QuestID)))
                    {
                        user.Send(pw, ServerMessageType.GUI);
                    }
                    return;
                }
            }

            // Force-skipped the quest dialog, or there was no available quests, so start the chat dialog
            user.ChatState.StartChat(npc);
        }
コード例 #9
0
        void RecvAcceptOrTurnInQuestReply(IIPSocket conn, BitStream r)
        {
            var questID = r.ReadQuestID();
            var successful = r.ReadBool();
#pragma warning disable 168
            var accepted = r.ReadBool();
#pragma warning restore 168

            if (successful)
            {
                // Remove the quest from the available quests list
                var aqf = GameplayScreen.AvailableQuestsForm;
                if (aqf.IsVisible)
                {
                    aqf.AvailableQuests = aqf.AvailableQuests.Where(x => x.QuestID != questID).ToArray();
                }
            }
        }
コード例 #10
0
        void RecvCharAttack(IIPSocket conn, BitStream r)
        {
            // Read the values
            var attackerID = r.ReadMapEntityIndex();

            MapEntityIndex? attackedID;
            if (r.ReadBool())
                attackedID = r.ReadMapEntityIndex();
            else
                attackedID = null;

            ActionDisplayID? actionDisplayIDNullable;
            if (r.ReadBool())
                actionDisplayIDNullable = r.ReadActionDisplayID();
            else
                actionDisplayIDNullable = null;

            // Get the object references using the IDs provided
            var attacker = _objGrabber.GetDynamicEntity<Character>(attackerID);
            if (attacker == null)
                return;

            DynamicEntity attacked = attackedID.HasValue ? Map.GetDynamicEntity(attackedID.Value) : null;

            // Use the default ActionDisplayID if we were provided with a null value
            ActionDisplayID actionDisplayID = !actionDisplayIDNullable.HasValue ? GameData.DefaultActionDisplayID : actionDisplayIDNullable.Value;

            // Get the ActionDisplay to use and, if valid, execute it
            var actionDisplay = ActionDisplayScripts.ActionDisplays[actionDisplayID];
            if (actionDisplay != null)
                actionDisplay.Execute(Map, attacker, attacked);
        }
コード例 #11
0
        void RecvUpdateStat(IIPSocket conn, BitStream r)
        {
            var isBaseStat = r.ReadBool();
            var stat = r.ReadStat<StatType>();

            var coll = isBaseStat ? UserInfo.BaseStats : UserInfo.ModStats;
            coll[stat.StatType] = stat.Value;
        }
コード例 #12
0
        void RecvUpdateEquipmentSlot(IIPSocket conn, BitStream r)
        {
            var slot = r.ReadEnum<EquipmentSlot>();
            var hasValue = r.ReadBool();

            if (hasValue)
            {
                var graphic = r.ReadGrhIndex();
                UserInfo.Equipped.SetSlot(slot, graphic);
            }
            else
                UserInfo.Equipped.ClearSlot(slot);
        }
コード例 #13
0
        void RecvStartShopping(IIPSocket conn, BitStream r)
        {
            var shopOwnerIndex = r.ReadMapEntityIndex();
            var canBuy = r.ReadBool();
            var name = r.ReadString();
            var itemCount = r.ReadByte();

            var items = new IItemTemplateTable[itemCount];
            for (var i = 0; i < itemCount; i++)
            {
                var value = new ItemTemplateTable();
                value.ReadState(r);
                items[i] = value;
            }

            var shopOwner = Map.GetDynamicEntity(shopOwnerIndex);
            var shopInfo = new ShopInfo<IItemTemplateTable>(shopOwner, name, canBuy, items);

            GameplayScreen.ShopForm.DisplayShop(shopInfo);
        }
コード例 #14
0
 /// <summary>
 /// Reads a boolean.
 /// </summary>
 /// <param name="name">Unused by the <see cref="BinaryValueReader"/>.</param>
 /// <returns>Value read from the reader.</returns>
 public bool ReadBool(string name)
 {
     return(_reader.ReadBool());
 }
コード例 #15
0
        void RecvCreateAccountCharacter(IIPSocket conn, BitStream r)
        {
            var successful = r.ReadBool();
            var errorMessage = successful ? string.Empty : r.ReadString();

            if (ReceivedCreateAccountCharacter != null)
                ReceivedCreateAccountCharacter.Raise(conn, new CreateAccountEventArgs(successful, errorMessage));
        }
コード例 #16
0
        void RecvAttack(IIPSocket conn, BitStream r)
        {
            User user;
            MapEntityIndex? targetIndex = null;

            var hasTarget = r.ReadBool();
            if (hasTarget)
                targetIndex = r.ReadMapEntityIndex();

            if ((user = TryGetUser(conn)) != null)
            {
                if (user.IsPeerTrading)
                    return;

                user.Attack(GetTargetCharacter(user, targetIndex));
            }
        }
コード例 #17
0
        void RecvHasQuestStartRequirementsReply(IIPSocket conn, BitStream r)
        {
            var questID = r.ReadQuestID();
            var hasRequirements = r.ReadBool();

            UserInfo.HasStartQuestRequirements.SetRequirementsStatus(questID, hasRequirements);
        }
コード例 #18
0
        void RecvUseSkill(IIPSocket conn, BitStream r)
        {
            SkillType skillType;
            MapEntityIndex? targetIndex = null;

            // Get the SkillType to use
            try
            {
                skillType = r.ReadEnum<SkillType>();
            }
            catch (InvalidCastException)
            {
                const string errmsg = "Failed to read SkillType from stream.";
                if (log.IsWarnEnabled)
                    log.Warn(errmsg);
                Debug.Fail(errmsg);
                r.ReadBool();
                return;
            }

            // Check for a target
            var hasTarget = r.ReadBool();
            if (hasTarget)
                targetIndex = r.ReadMapEntityIndex();

            // Get the user
            User user;
            if ((user = TryGetUser(conn)) != null)
            {
                // Check that they know the skill
                if (!user.KnownSkills.Knows(skillType))
                    user.Send(GameMessage.SkillNotKnown, ServerMessageType.GUIChat);
                else
                {
                    // Use the skill
                    user.UseSkill(skillType, GetTargetCharacter(user, targetIndex));
                }
            }
        }
コード例 #19
0
ファイル: UserGroupInformation.cs プロジェクト: wtfcolt/game
        /// <summary>
        /// Handles <see cref="GroupInfoMessages.SetGroup"/>.
        /// </summary>
        /// <param name="bs">The <see cref="BitStream"/> to read from.</param>
        void ReadSetGroup(BitStream bs)
        {
            _members.Clear();
            _founder = null;

            var isInGroup = bs.ReadBool();

            if (isInGroup)
            {
                // Read the group members
                var numMembers = bs.ReadByte();
                var members = bs.ReadStrings(numMembers);
                _members.AddRange(members);

                // Read the founder's name
                _founder = bs.ReadString();
            }

            // Raise events
            OnGroupChanged();

            if (GroupChanged != null)
                GroupChanged.Raise(this, EventArgs.Empty);
        }