示例#1
0
        // ^ Skill check ^

        /// <summary>
        /// Initializes upgrade effect, setting required default values.
        /// You should generally use this constructor!
        /// </summary>
        /// <param name="type"></param>
        public UpgradeEffect(UpgradeType type)
        {
            Type           = type;
            Unk1           = 0;
            Unk2           = 0;
            Stat           = 0;
            ValueType      = 0;
            Value          = 0;
            SkillId        = 0;
            SkillVar       = 0;
            Unk4           = 0x0A;
            Unk5           = 0;
            CheckType      = UpgradeCheckType.None;
            CheckStat      = 0;
            CheckRace      = 0;
            CheckPtj       = 0;
            CheckMonth     = 0;
            CheckBroken    = false;
            CheckTitleId   = 0;
            CheckCondition = 0;
            CheckValueType = 0;
            CheckValue     = 0;
            CheckSkillId   = 0;
            CheckSkillRank = 0;
        }
示例#2
0
		/// <summary>
		/// Creates new track record.
		/// </summary>
		/// <param name="type"></param>
		/// <param name="done"></param>
		/// <param name="success"></param>
		/// <param name="last"></param>
		public PtjTrackRecord(PtjType type, int done, int success, DateTime last)
		{
			this.Type = type;
			this.Done = done;
			this.Success = success;
			this.LastChange = last;
		}
示例#3
0
 /// <summary>
 /// Creates new track record.
 /// </summary>
 /// <param name="type"></param>
 /// <param name="done"></param>
 /// <param name="success"></param>
 /// <param name="last"></param>
 public PtjTrackRecord(PtjType type, int done, int success, DateTime last)
 {
     this.Type       = type;
     this.Done       = done;
     this.Success    = success;
     this.LastChange = last;
 }
示例#4
0
        /// <summary>
        /// Modifies track record, changing success, done, and last change.
        /// </summary>
        /// <param name="type"></param>
        /// <param name="done"></param>
        /// <param name="success"></param>
        public void ModifyPtjTrackRecord(PtjType type, int done, int success)
        {
            var record = this.GetPtjTrackRecord(type);

            record.Done      += done;
            record.Success   += success;
            record.LastChange = DateTime.Now;
        }
示例#5
0
        /// <summary>
        /// Sends QuestUpdatePtj to creature's client, updates the char info window.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="type"></param>
        /// <param name="done"></param>
        /// <param name="success"></param>
        public static void QuestUpdatePtj(Creature creature, PtjType type, int done, int success)
        {
            var packet = new Packet(Op.QuestUpdatePtj, creature.EntityId);

            packet.PutInt((int)type);
            packet.PutInt(done);
            packet.PutInt(success);

            creature.Client.Send(packet);
        }
示例#6
0
        /// <summary>
        /// Sets track record, changing success, done, and last change.
        /// </summary>
        /// <param name="type"></param>
        /// <param name="done"></param>
        /// <param name="success"></param>
        public void SetPtjTrackRecord(PtjType type, int done, int success)
        {
            var record = this.GetPtjTrackRecord(type);

            record.Done       = done;
            record.Success    = success;
            record.LastChange = DateTime.Now;

            this.PtjTrackRecordChanged.Raise(_creature, record);
        }
示例#7
0
 public void OnCreatureStartedPtj(Creature creature, PtjType type)
 {
     // the Diligent
     // Show if creature starts any PTJ.
     // ------------------------------------------------------------------
     if (!creature.KnowsTitle(33))
     {
         creature.ShowTitle(33);
     }
 }
示例#8
0
        /// <summary>
        /// Returns track record for type.
        /// </summary>
        /// <returns></returns>
        public PtjTrackRecord GetPtjTrackRecord(PtjType type)
        {
            PtjTrackRecord record;

            lock (_ptjRecords)
                if (!_ptjRecords.TryGetValue(type, out record))
                {
                    _ptjRecords[type] = (record = new PtjTrackRecord(type, 0, 0, DateTime.MinValue));
                }

            return(record);
        }
示例#9
0
        /// <summary>
        /// Returns a random quest id from the given ones, based on the current
        /// Erinn day and the player's success rate for this PTJ type.
        /// </summary>
        /// <param name="type"></param>
        /// <param name="questIds"></param>
        /// <returns></returns>
        public int GetRandomPtj(Creature creature, PtjType type, params int[] questIds)
        {
            var level           = creature.GetPtjQuestLevel(type);
            var sameLevelQuests = this.GetLevelMatchingQuestIds(level, type, questIds);

            // Return random quest's id
            // Random is seeded with the current Erinn day so we always get
            // the same result for one in-game day.
            var rnd = new Random(ErinnTime.Now.DateTimeStamp);

            return(sameLevelQuests.ElementAt(rnd.Next(sameLevelQuests.Count())));
        }
示例#10
0
    public void OnCreatureCompletedPtj(Creature creature, PtjType type)
    {
        // the Diligent
        // Enable if creature completed a PTJ 100 times.
        // ------------------------------------------------------------------
        if (!creature.CanUseTitle(33))
        {
            var trackRecord = creature.Quests.GetPtjTrackRecord(type);
            if (trackRecord.Done >= 100)
            {
                creature.EnableTitle(33);
                creature.ShowTitle(35);
            }
        }

        // the Super Diligent
        // Enable if creature completed a PTJ 10,000 times.
        // ------------------------------------------------------------------
        if (!creature.CanUseTitle(35))
        {
            var trackRecord = creature.Quests.GetPtjTrackRecord(type);
            if (trackRecord.Done >= 10000)
            {
                creature.EnableTitle(35);
            }
        }

        // the Busy
        // Enable if creature completed 3 Part-time Jobs in one Erinn day.
        // ------------------------------------------------------------------
        if (!creature.CanUseTitle(10154))
        {
            var now   = ErinnTime.Now;
            var count = 0;

            var trackRecords = creature.Quests.GetPtjTrackRecords();
            foreach (var record in trackRecords)
            {
                var change = new ErinnTime(record.LastChange);
                if (now.Day == change.Day && now.Month == change.Month && now.Year == change.Year)
                {
                    count++;
                }
            }

            if (count >= 3)
            {
                creature.EnableTitle(10154);
            }
        }
    }
示例#11
0
        /// <summary>
        /// Of the given <paramref name="questIds"/>, returns those matched to
        /// the player's success rate for the given PTJ <paramref name="type"/>.
        /// </summary>
        /// <param name="type"></param>
        /// <param name="questIds"></param>
        /// <returns></returns>
        public IEnumerable <int> GetLevelMatchingQuestIds(QuestLevel level, PtjType type, params int[] questIds)
        {
            // Check ids
            if (questIds.Length == 0)
            {
                throw new ArgumentException("Creature.RandomPtj: questIds may not be empty.");
            }

            // Check quest scripts and get a list of available ones
            var questScripts      = questIds.Select(id => ChannelServer.Instance.ScriptManager.QuestScripts.Get(id)).Where(a => a != null);
            var questScriptsCount = questScripts.Count();

            if (questScriptsCount == 0)
            {
                throw new Exception("Creature.RandomPtj: Unable to find any of the given quests.");
            }
            if (questScriptsCount != questIds.Length)
            {
                var missing = questIds.Where(a => !questScripts.Any(b => b.Id == a));
                Log.Warning("Creature.RandomPtj: Some of the given quest ids are unknown (" + string.Join(", ", missing) + ").");
            }

            // Check same level quests
            var sameLevelQuests      = questScripts.Where(a => a.Level == level);
            var sameLevelQuestsCount = sameLevelQuests.Count();

            if (sameLevelQuestsCount == 0)
            {
                // Try to fall back to Basic
                sameLevelQuests      = questScripts.Where(a => a.Level == QuestLevel.Basic);
                sameLevelQuestsCount = sameLevelQuests.Count();

                if (sameLevelQuestsCount == 0)
                {
                    throw new Exception("Creature.RandomPtj: Missing quest for level '" + level + "'.");
                }

                Log.Warning("Creature.RandomPtj: Missing quest for level '" + level + "', using 'Basic' as fallback.");
            }

            return(sameLevelQuests.Select(qscript => qscript.Id));
        }
示例#12
0
		/// <summary>
		/// Sets type for PTJs.
		/// </summary>
		/// <param name="type"></param>
		protected void SetPtjType(PtjType type)
		{
			this.PtjType = type;
		}
示例#13
0
        /// <summary>
        /// Sends QuestUpdatePtj to creature's client, updates the char info window.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="type"></param>
        /// <param name="done"></param>
        /// <param name="success"></param>
        public static void QuestUpdatePtj(Creature creature, PtjType type, int done, int success)
        {
            var packet = new Packet(Op.QuestUpdatePtj, creature.EntityId);
            packet.PutInt((int)type);
            packet.PutInt(done);
            packet.PutInt(success);

            creature.Client.Send(packet);
        }
示例#14
0
		/// <summary>
		/// Returns number of times the player has successfully done the given PTJ type.
		/// </summary>
		/// <param name="type"></param>
		/// <returns></returns>
		public int GetPtjSuccessCount(PtjType type)
		{
			return this.Player.Quests.GetPtjTrackRecord(type).Success;
		}
示例#15
0
	public void OnCreatureCompletedPtj(Creature creature, PtjType type)
	{
		// the Diligent
		// Enable if creature completed a PTJ 100 times.
		// ------------------------------------------------------------------
		if (!creature.Titles.IsUsable(33))
		{
			var trackRecord = creature.Quests.GetPtjTrackRecord(type);
			if (trackRecord.Done >= 100)
			{
				creature.Titles.Enable(33);
				creature.Titles.Show(35);
			}
		}

		// the Super Diligent 
		// Enable if creature completed a PTJ 10,000 times.
		// ------------------------------------------------------------------
		if (!creature.Titles.IsUsable(35))
		{
			var trackRecord = creature.Quests.GetPtjTrackRecord(type);
			if (trackRecord.Done >= 10000)
				creature.Titles.Enable(35);
		}

		// the Busy 
		// Enable if creature completed 3 Part-time Jobs in one Erinn day.
		// ------------------------------------------------------------------
		if (!creature.Titles.IsUsable(10154))
		{
			var now = ErinnTime.Now;
			var count = 0;

			var trackRecords = creature.Quests.GetPtjTrackRecords();
			foreach (var record in trackRecords)
			{
				var change = new ErinnTime(record.LastChange);
				if (now.Day == change.Day && now.Month == change.Month && now.Year == change.Year)
					count++;
			}

			if (count >= 3)
				creature.Titles.Enable(10154);
		}
	}
示例#16
0
 /// <summary>
 /// Changes effect to check if the given PTJ has been done x times.
 /// </summary>
 /// <param name="ptjType"></param>
 /// <param name="count"></param>
 public void SetPtjCheck(PtjType ptjType, int count)
 {
     CheckType  = UpgradeCheckType.IfPtjCompletedMoreThan;
     CheckPtj   = ptjType;
     CheckValue = (short)count;
 }
示例#17
0
 /// <summary>
 /// Sets type for PTJs.
 /// </summary>
 /// <param name="type"></param>
 protected void SetPtjType(PtjType type)
 {
     this.PtjType = type;
 }
示例#18
0
		/// <summary>
		/// Returns true if a PTJ quest is active and its type matches
		/// the given one.
		/// </summary>
		public bool DoingPtj(PtjType type)
		{
			var quest = this.Player.Quests.GetPtjQuest();
			return (quest != null && quest.Data.PtjType == type);
		}
示例#19
0
		/// <summary>
		/// Returns track record for type.
		/// </summary>
		/// <returns></returns>
		public PtjTrackRecord GetPtjTrackRecord(PtjType type)
		{
			PtjTrackRecord record;
			lock (_ptjRecords)
				if (!_ptjRecords.TryGetValue(type, out record))
					_ptjRecords[type] = (record = new PtjTrackRecord(type, 0, 0, DateTime.MinValue));

			return record;
		}
示例#20
0
		/// <summary>
		/// Modifies track record, changing success, done, and last change.
		/// </summary>
		/// <param name="type"></param>
		/// <param name="done"></param>
		/// <param name="success"></param>
		public void ModifyPtjTrackRecord(PtjType type, int done, int success)
		{
			var record = this.GetPtjTrackRecord(type);

			record.Done += done;
			record.Success += success;
			record.LastChange = DateTime.Now;

			this.PtjTrackRecordChanged.Raise(_creature, record);
		}
示例#21
0
文件: Items.cs 项目: tkiapril/aura
		// ^ Skill check ^

		/// <summary>
		/// Initializes upgrade effect, setting required default values.
		/// You should generally use this constructor!
		/// </summary>
		/// <param name="type"></param>
		public UpgradeEffect(UpgradeType type)
		{
			Type = type;
			Unk1 = 0;
			Unk2 = 0;
			Stat = 0;
			ValueType = 0;
			Value = 0;
			SkillId = 0;
			SkillVar = 0;
			Unk4 = 0x0A;
			Unk5 = 0;
			CheckType = UpgradeCheckType.None;
			CheckStat = 0;
			CheckRace = 0;
			CheckPtj = 0;
			CheckMonth = 0;
			CheckBroken = false;
			CheckTitleId = 0;
			CheckCondition = 0;
			CheckValueType = 0;
			CheckValue = 0;
			CheckSkillId = 0;
			CheckSkillRank = 0;
		}
示例#22
0
文件: Items.cs 项目: tkiapril/aura
		/// <summary>
		/// Changes effect to check if the given PTJ has been done x times.
		/// </summary>
		/// <param name="ptjType"></param>
		/// <param name="count"></param>
		public void SetPtjCheck(PtjType ptjType, int count)
		{
			CheckType = UpgradeCheckType.IfPtjCompletedMoreThan;
			CheckPtj = ptjType;
			CheckValue = (short)count;
		}
示例#23
0
 public void OnCreatureCompletedPtj(Creature creature, PtjType type)
 {
     CreatureCompletedPtj.Raise(creature, type);
 }
示例#24
0
 public void OnCreatureStartedPtj(Creature creature, PtjType type)
 {
     CreatureStartedPtj.Raise(creature, type);
 }
示例#25
0
		/// <summary>
		/// Returns the player's level (basic, int, adv) for the given PTJ type.
		/// </summary>
		/// <param name="type"></param>
		/// <returns></returns>
		public QuestLevel GetPtjQuestLevel(PtjType type)
		{
			var record = this.Player.Quests.GetPtjTrackRecord(type);
			return record.GetQuestLevel();
		}
示例#26
0
		/// <summary>
		/// Returns a random quest id from the given ones, based on the current
		/// Erinn day and the player's success rate for this PTJ type.
		/// </summary>
		/// <param name="type"></param>
		/// <param name="questIds"></param>
		/// <returns></returns>
		public int RandomPtj(PtjType type, params int[] questIds)
		{
			var level = this.GetPtjQuestLevel(type);

			// Check ids
			if (questIds.Length == 0)
				throw new ArgumentException("NpcScript.RandomPtj: questIds may not be empty.");

			// Check quest scripts and get a list of available ones
			var questScripts = questIds.Select(id => ChannelServer.Instance.ScriptManager.QuestScripts.Get(id)).Where(a => a != null);
			var questScriptsCount = questScripts.Count();
			if (questScriptsCount == 0)
				throw new Exception("NpcScript.RandomPtj: Unable to find any of the given quests.");
			if (questScriptsCount != questIds.Length)
			{
				var missing = questIds.Where(a => !questScripts.Any(b => b.Id == a));
				Log.Warning("NpcScript.RandomPtj: Some of the given quest ids are unknown (" + string.Join(", ", missing) + ").");
			}

			// Check same level quests
			var sameLevelQuests = questScripts.Where(a => a.Level == level);
			var sameLevelQuestsCount = sameLevelQuests.Count();

			if (sameLevelQuestsCount == 0)
			{
				// Try to fall back to Basic
				sameLevelQuests = questScripts.Where(a => a.Level == QuestLevel.Basic);
				sameLevelQuestsCount = sameLevelQuests.Count();

				if (sameLevelQuestsCount == 0)
					throw new Exception("NpcScript.RandomPtj: Missing quest for level '" + level + "'.");

				Log.Warning("NpcScript.RandomPtj: Missing quest for level '" + level + "', using 'Basic' as fallback.");
			}

			// Return random quest's id
			// Random is seeded with the current Erinn day so we always get
			// the same result for one in-game day.
			var rnd = new Random(ErinnTime.Now.DateTimeStamp);
			var randomQuest = sameLevelQuests.ElementAt(rnd.Next(sameLevelQuestsCount));

			return randomQuest.Id;
		}
示例#27
0
		/// <summary>
		/// Returns number of times the player has done the given PTJ type.
		/// </summary>
		/// <param name="type"></param>
		/// <returns></returns>
		public int GetPtjDoneCount(PtjType type)
		{
			return this.Player.Quests.GetPtjTrackRecord(type).Done;
		}
示例#28
0
		/// <summary>
		/// Returns true if the player can do a PTJ of type, because he hasn't
		/// done one of the same type today.
		/// </summary>
		/// <param name="type"></param>
		/// <returns></returns>
		public bool CanDoPtj(PtjType type, int remaining = 99)
		{
			// Always allow devCATs
			//if (this.Title == TitleId.devCAT)
			//	return true;

			// Check remaining
			if (remaining <= 0)
				return false;

			// Check if PTJ has already been done this Erinn day
			var ptj = this.Player.Quests.GetPtjTrackRecord(type);
			var change = new ErinnTime(ptj.LastChange);
			var now = ErinnTime.Now;

			return (now.Day != change.Day || now.Month != change.Month || now.Year != change.Year);
		}
示例#29
0
	public void OnCreatureStartedPtj(Creature creature, PtjType type)
	{
		// the Diligent
		// Show if creature starts any PTJ.
		// ------------------------------------------------------------------
		if (!creature.Titles.Knows(33))
			creature.Titles.Show(33);
	}