Ejemplo n.º 1
0
        public bool Run(params object[] args)
        {
            NWPlayer player = _.GetLastUsedBy();

            if (!player.IsPlayer)
            {
                return(false);
            }

            NWPlaceable placeable = Object.OBJECT_SELF;
            int         keyItemID = placeable.GetLocalInt("KEY_ITEM_ID");

            if (keyItemID <= 0)
            {
                return(false);
            }

            if (_keyItem.PlayerHasKeyItem(player, keyItemID))
            {
                player.SendMessage("You already have this key item.");
                return(false);
            }

            _keyItem.GivePlayerKeyItem(player, keyItemID);

            string visibilityGUID = placeable.GetLocalString("VISIBILITY_OBJECT_ID");

            if (!string.IsNullOrWhiteSpace(visibilityGUID))
            {
                _ovs.AdjustVisibility(player, placeable, false);
            }

            return(true);
        }
Ejemplo n.º 2
0
        private void DoSlice()
        {
            NWPlaceable self      = Object.OBJECT_SELF;
            int         keyItemID = self.GetLocalInt("KEY_ITEM_ID");

            if (keyItemID <= 0)
            {
                GetPC().SendMessage("ERROR: Improperly configured key item. ID is not set. Notify an admin.");
                return;
            }

            _keyItem.GivePlayerKeyItem(GetPC(), keyItemID);

            string visibilityObjectID = self.GetLocalString("VISIBILITY_OBJECT_ID");

            if (!string.IsNullOrWhiteSpace(visibilityObjectID))
            {
                _ovs.AdjustVisibility(GetPC(), self, false);
            }

            EndConversation();
        }
Ejemplo n.º 3
0
        public void CompleteQuest(NWPlayer player, NWObject questOwner, int questID, ItemVO selectedItem)
        {
            if (!player.IsPlayer)
            {
                return;
            }

            Quest         quest   = _data.Single <Quest>(x => x.ID == questID);
            PCQuestStatus pcState = _data.Single <PCQuestStatus>(x => x.PlayerID == player.GlobalID && x.QuestID == questID);

            QuestState finalState = _data.GetAll <QuestState>().Where(x => x.QuestID == questID).OrderBy(o => o.Sequence).Last();

            if (finalState == null)
            {
                player.SendMessage("Could not find final state of quest. Please notify an admin this quest is bugged. (QuestID: " + questID + ")");
                return;
            }

            pcState.CurrentQuestStateID = finalState.ID;
            pcState.CompletionDate      = DateTime.UtcNow;

            if (selectedItem == null)
            {
                var rewardItems = _data.Where <QuestRewardItem>(x => x.QuestID == questID);
                foreach (QuestRewardItem reward in rewardItems)
                {
                    _.CreateItemOnObject(reward.Resref, player.Object, reward.Quantity);
                }
            }
            else
            {
                _.CreateItemOnObject(selectedItem.Resref, player.Object, selectedItem.Quantity);
            }

            if (quest.RewardGold > 0)
            {
                _.GiveGoldToCreature(player.Object, quest.RewardGold);
            }

            if (quest.RewardKeyItemID != null)
            {
                _keyItem.GivePlayerKeyItem(player, (int)quest.RewardKeyItemID);
            }

            if (quest.RemoveStartKeyItemAfterCompletion && quest.StartKeyItemID != null)
            {
                _keyItem.RemovePlayerKeyItem(player, (int)quest.StartKeyItemID);
            }

            if (!string.IsNullOrWhiteSpace(quest.MapNoteTag))
            {
                _mapPin.DeleteMapPin(player, "QST_MAP_NOTE_" + questID);
            }

            if (quest.RewardFame > 0)
            {
                PCRegionalFame     fame   = _data.SingleOrDefault <PCRegionalFame>(x => x.PlayerID == player.GlobalID && x.FameRegionID == quest.FameRegionID);
                DatabaseActionType action = DatabaseActionType.Update;

                if (fame == null)
                {
                    fame = new PCRegionalFame
                    {
                        PlayerID     = player.GlobalID,
                        FameRegionID = quest.FameRegionID,
                        Amount       = 0
                    };

                    action = DatabaseActionType.Insert;
                }

                fame.Amount += quest.RewardFame;
                _data.SubmitDataChange(fame, action);
            }

            player.SendMessage("Quest '" + quest.Name + "' complete!");
            _data.SubmitDataChange(pcState, DatabaseActionType.Update);
            _.RemoveJournalQuestEntry(quest.JournalTag, player, FALSE);

            if (!string.IsNullOrWhiteSpace(quest.OnCompleteRule) && questOwner != null)
            {
                App.ResolveByInterface <IQuestRule>("QuestRule." + quest.OnCompleteRule, rule =>
                {
                    string[] args = null;
                    if (!string.IsNullOrWhiteSpace(quest.OnCompleteArgs))
                    {
                        args = quest.OnCompleteArgs.Split(',');
                    }
                    rule.Run(player, questOwner, questID, args);
                });
            }
        }
Ejemplo n.º 4
0
        public void CompleteQuest(NWPlayer player, int questID, ItemVO selectedItem)
        {
            if (!player.IsPlayer)
            {
                return;
            }

            Quest         quest   = _db.Quests.Single(x => x.QuestID == questID);
            PCQuestStatus pcState = _db.PCQuestStatus.Single(x => x.PlayerID == player.GlobalID && x.QuestID == questID);

            QuestState finalState = null;

            foreach (QuestState questState in quest.QuestStates)
            {
                if (questState.IsFinalState)
                {
                    finalState = questState;
                    break;
                }
            }

            if (finalState == null)
            {
                player.SendMessage("Could not find final state of quest. Please notify an admin this quest is bugged. (QuestID: " + questID + ")");
                return;
            }

            pcState.CurrentQuestStateID = finalState.QuestStateID;
            pcState.CompletionDate      = DateTime.UtcNow;

            if (selectedItem == null)
            {
                foreach (QuestRewardItem reward in quest.QuestRewardItems)
                {
                    _.CreateItemOnObject(reward.Resref, player.Object, reward.Quantity);
                }
            }
            else
            {
                _.CreateItemOnObject(selectedItem.Resref, player.Object, selectedItem.Quantity, "");
            }

            if (quest.RewardGold > 0)
            {
                _.GiveGoldToCreature(player.Object, quest.RewardGold);
            }

            if (quest.RewardXP > 0)
            {
                // TODO: Skill-related exp rewards??
            }

            if (quest.RewardKeyItemID != null)
            {
                _keyItem.GivePlayerKeyItem(player, (int)quest.RewardKeyItemID);
            }

            if (quest.RemoveStartKeyItemAfterCompletion && quest.StartKeyItemID != null)
            {
                _keyItem.RemovePlayerKeyItem(player, (int)quest.StartKeyItemID);
            }

            if (!string.IsNullOrWhiteSpace(quest.MapNoteTag))
            {
                _mapPin.DeleteMapPin(player, "QST_MAP_NOTE_" + questID);
            }

            if (quest.RewardFame > 0)
            {
                PCRegionalFame fame = _db.PCRegionalFames.Single(x => x.PlayerID == player.GlobalID && x.FameRegionID == quest.FameRegionID);
                fame.Amount += quest.RewardFame;
            }

            player.SendMessage("Quest '" + quest.Name + "' complete!");
            _db.SaveChanges();
        }