Пример #1
0
        /// <summary>
        /// Share supplied <see cref="Quest"/> with another <see cref="Player"/>.
        /// </summary>
        public void QuestShare(ushort questId)
        {
            QuestInfo info = GlobalQuestManager.Instance.GetQuestInfo(questId);

            if (info == null)
            {
                throw new ArgumentException($"Invalid quest {questId}!");
            }

            Quest.Quest quest = GetQuest(questId);
            if (quest == null)
            {
                throw new QuestException($"Player {player.CharacterId} tried to share quest {questId} which they don't have!");
            }

            if (!quest.CanShare())
            {
                throw new QuestException($"Player {player.CharacterId} tried to share quest {questId} which can't be shared!");
            }

            Player recipient = player.GetVisible <Player>(player.TargetGuid);

            if (recipient == null)
            {
                throw new QuestException($"Player {player.CharacterId} tried to share quest {questId} to an invalid player!");
            }

            // TODO

            log.Trace($"Shared quest {questId} with player {recipient.Name}.");
        }
Пример #2
0
        /// <summary>
        /// Checks to see if the targeted <see cref="Mailbox"/> is in range.
        /// </summary>
        private bool IsTargetMailBoxInRange(uint unitId)
        {
            // native client function MailSystemLib.AtMailbox also uses entry 237 for distance check
            GameFormulaEntry entry = GameTableManager.Instance.GameFormula.GetEntry(237);

            if (entry == null)
            {
                throw new InvalidOperationException();
            }

            var entity = player.GetVisible <WorldEntity>(unitId);

            return(entity is Mailbox && Vector3.Distance(player.Position, entity.Position) < entry.Datafloat0);
        }