示例#1
0
        /// <summary>
        /// Reward GP to player if the quest awards it.
        /// </summary>
        /// <param name="player">The player who completed the quest.</param>
        /// <param name="questID">The ID of the quest</param>
        private static void OnQuestCompleted(NWPlayer player, int questID)
        {
            var quest     = QuestService.GetQuestByID(questID);
            var gpRewards = quest.GetRewards().Where(x => x.GetType() == typeof(QuestGPReward)).Cast <QuestGPReward>().ToList();

            // GP rewards not specified. Bail out early.
            if (gpRewards.Count <= 0)
            {
                return;
            }

            foreach (var reward in gpRewards)
            {
                int gp = CalculateGPReward(player, reward.Guild, reward.Amount);
                GiveGuildPoints(player, reward.Guild, gp);
            }
        }
示例#2
0
        public static void OnChestOpen(NWPlaceable oChest)
        {
            NWPlayer oPC = (_.GetLastOpenedBy());

            if (!oPC.IsPlayer)
            {
                return;
            }

            if (_.GetActionMode(oPC.Object, _.ACTION_MODE_STEALTH) == _.TRUE)
            {
                _.SetActionMode(oPC.Object, _.ACTION_MODE_STEALTH, _.FALSE);
            }

            string       resref           = oChest.Resref;
            int          chestID          = oChest.GetLocalInt(SearchSiteIDVariableName);
            int          skillRank        = _.GetSkillRank(_.SKILL_SEARCH, oPC.Object);
            int          numberOfSearches = (skillRank / ExtraSearchPerNumberLevels) + 1;
            PCSearchSite searchEntity     = DataService.SingleOrDefault <PCSearchSite>(x => x.PlayerID == oPC.GlobalID && x.SearchSiteID == chestID);
            DateTime     timeLock         = DateTime.UtcNow;

            if (numberOfSearches <= 0)
            {
                numberOfSearches = 1;
            }

            if (searchEntity != null)
            {
                timeLock = searchEntity.UnlockDateTime;
            }

            if (resref == SearchSiteCopyResref)
            {
                oChest.IsUseable = false;
            }

            QuestService.SpawnQuestItems(oChest, oPC);

            if (timeLock < DateTime.UtcNow || searchEntity == null)
            {
                int dc = oChest.GetLocalInt(SearchSiteDCVariableName);

                for (int search = 1; search <= numberOfSearches; search++)
                {
                    RunSearchCycle(oPC, oChest, dc);
                    dc += RandomService.Random(3) + 1;
                }

                SaveChestInventory(oPC, oChest, false);
            }
            else
            {
                var searchItems = DataService.Where <PCSearchSiteItem>(x => x.PlayerID == oPC.GlobalID && x.SearchSiteID == searchEntity.SearchSiteID).ToList();
                foreach (PCSearchSiteItem item in searchItems)
                {
                    NWItem oItem = SerializationService.DeserializeItem(item.SearchItem, oChest);

                    // Prevent item duplication in containers
                    if (oItem.HasInventory)
                    {
                        foreach (NWItem containerItem in oItem.InventoryItems)
                        {
                            containerItem.Destroy();
                        }
                    }
                }
            }
        }