Example #1
0
        /// <summary>
        /// Tries to learn the given tier for the given skill (if allowed)
        /// </summary>
        /// <returns>Whether it succeeded</returns>
        public bool TryLearn(SkillId id, SkillTierId tier)
        {
            Skill skill;

            if (!m_skills.TryGetValue(id, out skill))
            {
                SkillRaceClassInfo skillRaceClassInfo;
                if (!AvailableSkills.TryGetValue(id, out skillRaceClassInfo) ||
                    m_owner.Level < skillRaceClassInfo.MinimumLevel)
                {
                    return(false);
                }
                skill = Add(skillRaceClassInfo.SkillLine, false);
            }

            if (skill.CanLearnTier(tier))
            {
                skill.MaxValue = (ushort)skill.SkillLine.Tiers.GetMaxValue(tier);
                if (id == SkillId.Riding)
                {
                    skill.CurrentValue = skill.MaxValue;
                }
            }

            return(true);
        }
Example #2
0
 public bool HasTier(SkillTierId tier)
 {
     if (Tiers.MaxValues != null)
     {
         return((int)tier < Tiers.MaxValues.Length);
     }
     return(false);
 }
Example #3
0
        public Skill GetOrCreate(SkillId id, SkillTierId tier, bool ignoreRestrictions)
        {
            Skill skill = GetOrCreate(id, ignoreRestrictions);

            if (skill != null && skill.SkillLine.HasTier(tier))
            {
                skill.MaxValue = (ushort)skill.SkillLine.Tiers.GetMaxValue(tier);
            }
            return(skill);
        }
        protected override void Apply(WorldObject target, ref DamageAction[] actions)
        {
            SkillId     miscValue  = (SkillId)Effect.MiscValue;
            SkillTierId basePoints = (SkillTierId)Effect.BasePoints;

            if (((Character)target).Skills.TryLearn(miscValue, basePoints))
            {
                return;
            }
            m_cast.Cancel(SpellFailedReason.MinSkill);
        }
Example #5
0
 /// <summary>
 /// Checks whether the given tier can be learned
 /// </summary>
 public bool CanLearnTier(SkillTierId tier)
 {
     if (SkillLine.HasTier(tier))
     {
         uint tierLimit = SkillLine.Tiers.GetMaxValue(tier);
         if (CurrentValue >= (int)tierLimit - 100)
         {
             // cannot be learnt if we have less than max - 100 in that skill
             return(true);
         }
     }
     return(false);
 }
Example #6
0
        /// <summary>
        /// If this char is allowed to learn this skill (matching Race, Class and Level) on the given tier,
        /// the correspdonding SkillLine will be returned. Returns null if skill cannot be learnt.
        /// </summary>
        public SkillLine GetLineIfLearnable(SkillId id, SkillTierId tier)
        {
            SkillRaceClassInfo skillRaceClassInfo;

            if (!AvailableSkills.TryGetValue(id, out skillRaceClassInfo) ||
                m_owner.Level < skillRaceClassInfo.MinimumLevel)
            {
                return(null);
            }
            Skill skill;

            if ((tier == SkillTierId.Apprentice ||
                 skillRaceClassInfo.SkillLine.Tiers.MaxValues.Length >= (long)tier) &&
                (m_skills.TryGetValue(id, out skill) && skill.CanLearnTier(tier)))
            {
                return(null);
            }
            return(skillRaceClassInfo.SkillLine);
        }
Example #7
0
        /// <summary>
        /// If this char is allowed to learn this skill (matching Race, Class and Level) on the given tier,
        /// the correspdonding SkillLine will be returned. Returns null if skill cannot be learnt.
        /// </summary>
        public SkillLine GetLineIfLearnable(SkillId id, SkillTierId tier)
        {
            SkillRaceClassInfo info;

            if (!AvailableSkills.TryGetValue(id, out info) || m_owner.Level < info.MinimumLevel)
            {
                return(null);
            }

            if (tier == 0 || (info.SkillLine.Tiers.MaxValues.Length >= (uint)tier))
            {
                Skill skill;
                if (m_skills.TryGetValue(id, out skill))
                {
                    if (skill.CanLearnTier(tier))
                    {
                        return(null);
                    }
                }
            }
            return(info.SkillLine);
        }
Example #8
0
            public override void Process(CmdTrigger <RealmServerCmdArgs> trigger)
            {
                SkillId id = trigger.Text.NextEnum <SkillId>(SkillId.None);

                if (trigger.Text.HasNext)
                {
                    SkillTierId tier = trigger.Text.NextEnum <SkillTierId>(SkillTierId.GrandMaster);
                    if (SkillHandler.Get(id) != null)
                    {
                        Skill skill = ((Character)trigger.Args.Target).Skills.GetOrCreate(id, tier, true);
                        trigger.Reply(RealmLangKey.CmdSkillTierResponse, (object)skill, (object)skill.CurrentValue,
                                      (object)skill.MaxValue);
                    }
                    else
                    {
                        trigger.Reply(RealmLangKey.CmdSkillTierError1, (object)id);
                    }
                }
                else
                {
                    trigger.Reply(RealmLangKey.CmdSkillTierError2);
                }
            }
Example #9
0
            public override void Process(CmdTrigger <RealmServerCmdArgs> trigger)
            {
                SkillId   id        = trigger.Text.NextEnum <SkillId>(SkillId.None);
                SkillLine skillLine = SkillHandler.Get(id);

                if (skillLine != null)
                {
                    Character   target       = (Character)trigger.Args.Target;
                    int         num          = trigger.Text.NextInt(1);
                    SkillTierId tierForLevel = skillLine.GetTierForLevel(num);
                    target.Skills.GetOrCreate(id, true).CurrentValue = (ushort)num;
                    Spell spellForTier = skillLine.GetSpellForTier(tierForLevel);
                    if (spellForTier != null)
                    {
                        target.Spells.AddSpell(spellForTier);
                    }
                    trigger.Reply(RealmLangKey.CmdSkillSetResponse, (object)skillLine, (object)num,
                                  (object)tierForLevel);
                }
                else
                {
                    trigger.Reply(RealmLangKey.CmdSkillSetError, (object)id);
                }
            }
Example #10
0
 /// <summary>Checks whether the given tier can be learned</summary>
 public bool CanLearnTier(SkillTierId tier)
 {
     return(this.SkillLine.HasTier(tier) &&
            (int)this.CurrentValue >= (int)this.SkillLine.Tiers.GetMaxValue(tier) - 100);
 }
Example #11
0
 /// <summary>
 /// Checks whether the given tier can be learned
 /// </summary>
 public bool CanLearnTier(SkillTierId tier)
 {
     if (SkillLine.HasTier(tier))
     {
         uint tierLimit = SkillLine.Tiers.GetMaxValue(tier);
         if (CurrentValue >= (int)tierLimit - 100)
         {
             // cannot be learnt if we have less than max - 100 in that skill
             return true;
         }
     }
     return false;
 }
Example #12
0
		public Spell GetSpellForTier(SkillTierId tier)
		{
			return TeachingSpells.FirstOrDefault(spell => spell.GetEffect(SpellEffectType.Skill).BasePoints == (int)tier);
		}
Example #13
0
		public bool HasTier(SkillTierId tier)
		{
			return Tiers.MaxValues != null && (int)tier < Tiers.MaxValues.Length;
		}
Example #14
0
		public Skill GetOrCreate(SkillId id, SkillTierId tier, bool ignoreRestrictions)
		{
			Skill skill = GetOrCreate(id, ignoreRestrictions);
			if (skill != null)
			{
				if (skill.SkillLine.HasTier(tier))
				{
					skill.MaxValue = (ushort)skill.SkillLine.Tiers.GetMaxValue(tier);
				}
			}
			return skill;
		}
Example #15
0
		/// <summary>
		/// Tries to learn the given tier for the given skill (if allowed)
		/// </summary>
		/// <returns>Whether it succeeded</returns>
		public bool TryLearn(SkillId id, SkillTierId tier)
		{
			Skill skill;
			if (!m_skills.TryGetValue(id, out skill))
			{
				SkillRaceClassInfo info;
				if (!AvailableSkills.TryGetValue(id, out info) || m_owner.Level < info.MinimumLevel)
				{
					return false;
				}
				skill = Add(info.SkillLine, false);
			}

			if (skill.CanLearnTier(tier))
			{
				skill.MaxValue = (ushort)skill.SkillLine.Tiers.GetMaxValue(tier);
				if (id == SkillId.Riding)
				{
					skill.CurrentValue = skill.MaxValue;
				}
			}
			return true;
		}
Example #16
0
		/// <summary>
		/// If this char is allowed to learn this skill (matching Race, Class and Level) on the given tier, 
		/// the correspdonding SkillLine will be returned. Returns null if skill cannot be learnt.
		/// </summary>
		public SkillLine GetLineIfLearnable(SkillId id, SkillTierId tier)
		{
			SkillRaceClassInfo info;
			if (!AvailableSkills.TryGetValue(id, out info) || m_owner.Level < info.MinimumLevel)
			{
				return null;
			}

			if (tier == 0 || (info.SkillLine.Tiers.MaxValues.Length >= (uint)tier))
			{
				Skill skill;
				if (m_skills.TryGetValue(id, out skill))
				{
					if (skill.CanLearnTier(tier))
					{
						return null;
					}
				}
			}
			return info.SkillLine;
		}
Example #17
0
		public uint GetMaxValue(SkillTierId id)
		{
			return MaxValues[(uint)id];
		}
Example #18
0
		public uint GetCost(SkillTierId id)
		{
			return Costs[(uint)id];
		}
Example #19
0
 public uint GetCost(SkillTierId id)
 {
     return(Costs[(uint)id]);
 }
Example #20
0
 public bool HasTier(SkillTierId tier)
 {
     return(Tiers.MaxValues != null && (int)tier < Tiers.MaxValues.Length);
 }
Example #21
0
 public Spell GetSpellForTier(SkillTierId tier)
 {
     return(TeachingSpells.FirstOrDefault(spell =>
                                          (SkillTierId)spell.GetEffect(SpellEffectType.Skill).BasePoints == tier));
 }
Example #22
0
 public uint GetMaxValue(SkillTierId id)
 {
     return(MaxValues[(uint)id]);
 }
Example #23
0
 public Spell GetSpellForTier(SkillTierId tier)
 {
     return(this.TeachingSpells.FirstOrDefault <Spell>((Func <Spell, bool>)(spell =>
                                                                            (SkillTierId)spell.GetEffect(SpellEffectType.Skill).BasePoints == tier)));
 }