Example #1
0
		protected internal override void Apply()
		{
			if (m_aura.Auras.Owner is Character) {
				skill = ((Character)m_aura.Auras.Owner).Skills[(SkillId)m_spellEffect.MiscValue];
				if (skill != null) {
					skill.Modifier += (short)EffectValue;
				}
			}
		}
Example #2
0
		/// <summary>
		/// Skill gains up chance formula
		/// </summary>
		/// <param name="targetLevel"></param>
		/// <param name="skill"></param>
		/// <returns></returns>
		private int GetSkillGainChance(int targetLevel, Skill skill)
		{
			int grayLevel = XpGenerator.GetGrayLevel(m_owner.Level);

			// no gain for gray skill levels
			if (targetLevel < grayLevel) return 0;

			var lvlDiff = targetLevel - grayLevel;
			var skillDiff = skill.MaxValue - skill.CurrentValue;

			if (skillDiff <= 0) return 0;

			var chance = 3 * lvlDiff * skillDiff;

			if (chance > 100) chance = 100;

			return chance;
		}
Example #3
0
		public override void Initialize(ref SpellFailedReason failReason)
		{
			if (m_cast.Selected != null)
			{
				lockable = m_cast.Selected as GameObject;
			}
			else
			{
				lockable = m_cast.TargetItem;
			}

			if (lockable == null)
			{
				failReason = SpellFailedReason.BadTargets;
			}
			else
			{
				var lck = lockable.Lock;
				var chr = m_cast.CasterChar;

				if (lck == null)
				{
					log.Warn("Using OpenLock on object without Lock: " + lockable);
					failReason = SpellFailedReason.Error;
					return;
				}
				if (chr == null)
				{
					log.Warn("Using OpenLock without Character: " + chr);
					failReason = SpellFailedReason.Error;
					return;
				}

				if (!lck.IsUnlocked)
				{
					var type = (LockInteractionType)Effect.MiscValue;
					if (lck.Keys.Length > 0 && m_cast.CasterItem != null)
					{
						if (!lck.Keys.Contains(key => key.KeyId == m_cast.CasterItem.Template.ItemId))
						{
							failReason = SpellFailedReason.ItemNotFound;
							return;
						}
					}
					else if (!lck.Supports(type))
					{
						failReason = SpellFailedReason.BadTargets;
						return;
					}

					if (type != LockInteractionType.None)
					{
						foreach (var openingMethod in lck.OpeningMethods)
						{
							if (openingMethod.InteractionType == type)
							{
								if (openingMethod.RequiredSkill != SkillId.None)
								{
									skill = chr.Skills[openingMethod.RequiredSkill];
									if (skill == null || skill.ActualValue < openingMethod.RequiredSkillValue)
									{
										failReason = SpellFailedReason.MinSkill;
									}
								}
								method = openingMethod;
								break;
							}
						}

						if (method == null)
						{
							// we are using the wrong kind of spell on the target
							failReason = SpellFailedReason.BadTargets;
						}
					}
				}

				if (failReason != SpellFailedReason.Ok)
				{
					// spell failed
					if (lockable is GameObject && ((GameObject)lockable).Entry.IsConsumable)
					{
						// re-enable GO
						((GameObject)lockable).State = GameObjectState.Enabled;
					}
				}
			}
		}
Example #4
0
		public void Load()
		{
			uint professions = 0;
			foreach (var record in m_owner.Record.LoadSkills())
			{
				var skillLine = SkillHandler.ById[(ushort)record.SkillId];
				if (skillLine == null)
				{
					log.Warn("Invalid Skill Id '{0}' in SkillRecord '{1}'", record.SkillId, record.Guid);
					// m_owner.Record.RemoveSkill(record);
				}
				else
				{
					if (skillLine.Category == SkillCategory.Profession)
					{
						professions++;
					}

					if (m_skills.ContainsKey(skillLine.Id))
					{
						log.Warn("Character {0} had Skill {1} more than once", m_owner, skillLine);
					}
					else
					{
						var skill = new Skill(this, FindFreeField(), record, skillLine);
						Add(skill, false);
					}
				}
			}
			FreeProfessions = Math.Max(SkillHandler.MaxProfessionsPerChar - professions, 0);
		}
Example #5
0
		internal void OnRemove(Skill skill)
		{
			ByField.Remove(skill.PlayerField);

			if (skill.SkillLine.Category == SkillCategory.Profession && FreeProfessions < SkillHandler.MaxProfessionsPerChar)
			{
				FreeProfessions++;
			}

			// reset the skill field
			m_owner.SetUInt32(skill.PlayerField, 0);
			m_owner.SetUInt32(skill.PlayerField + 1, 0);
			m_owner.SetUInt32(skill.PlayerField + 2, 0);

			// remove all skill-related spells
			if (SkillHandler.RemoveAbilitiesWithSkill)
			{
				skill.RemoveAllAbilities();
			}
			skill.Record.DeleteAndFlush();
		}
Example #6
0
		public void Remove(Skill skill)
		{
			m_skills.Remove(skill.SkillLine.Id);
			OnRemove(skill);
		}
Example #7
0
		/// <summary>
		/// Adds the skill without any checks
		/// </summary>
		protected void Add(Skill skill, bool isNew)
		{
			m_skills.Add(skill.SkillLine.Id, skill);
			ByField.Add(skill.PlayerField, skill);

			if (skill.SkillLine.Category == SkillCategory.Language)
			{
				m_owner.KnownLanguages.Add(skill.SkillLine.Language);
			}
			else if (skill.SkillLine.Category == SkillCategory.ArmorProficiency)
			{
				CharacterHandler.SendProfiency(m_owner, ItemClass.Armor, ArmorProficiency);
			}
			else if (skill.SkillLine.Category == SkillCategory.WeaponProficiency)
			{
				CharacterHandler.SendProfiency(m_owner, ItemClass.Weapon, WeaponProficiency);
			}

			if (isNew)
			{
				skill.Push();
				//for (var i = 0; i < skill.SkillLine.InitialAbilities.Count; i++)
				//{
				//    var ability = skill.SkillLine.InitialAbilities[i];
				//    if (!m_owner.Spells.Contains(ability.Spell.Id))
				//    {
				//        m_owner.Spells.Add(ability.Spell);
				//    }
				//}
			}
		}
Example #8
0
		/// <summary>
		/// Adds the skill without any checks
		/// </summary>
		protected void Add(Skill skill, bool isNew)
		{
			m_skills.Add(skill.SkillLine.Id, skill);
			ByField.Add(skill.PlayerField, skill);

			if (skill.SkillLine.Category == SkillCategory.Language)
			{
				m_owner.KnownLanguages.Add(skill.SkillLine.Language);
			}
			
			if (isNew)
			{
				skill.Push();
				//for (var i = 0; i < skill.SkillLine.InitialAbilities.Count; i++)
				//{
				//    var ability = skill.SkillLine.InitialAbilities[i];
				//    if (!m_owner.Spells.Contains(ability.Spell.Id))
				//    {
				//        m_owner.Spells.Add(ability.Spell);
				//    }
				//}
			}
		}