public void Load() { uint num = 0; foreach (SkillRecord loadSkill in m_owner.Record.LoadSkills()) { SkillLine skillLine = SkillHandler.ById[(ushort)loadSkill.SkillId]; if (skillLine == null) { log.Warn("Invalid Skill Id '{0}' in SkillRecord '{1}'", loadSkill.SkillId, loadSkill.Guid); } else { if (skillLine.Category == SkillCategory.Profession) { ++num; } if (m_skills.ContainsKey(skillLine.Id)) { log.Warn("Character {0} had Skill {1} more than once", m_owner, skillLine); } else { Add(new Skill(this, FindFreeField(), loadSkill, skillLine), false); } } } FreeProfessions = Math.Max(SkillHandler.MaxProfessionsPerChar - num, 0U); }
/// <summary> /// Add a new Skill with initial values to this SkillCollection if it can be added /// </summary> /// <param name="ignoreRestrictions">Whether to ignore the race, class and level requirements of this skill</param> public Skill Add(SkillId id, bool ignoreRestrictions) { SkillLine line = ignoreRestrictions ? SkillHandler.ById.Get((uint)id) : GetLineIfLearnable(id, 0); if (line != null) { return(Add(line, ignoreRestrictions)); } return(null); }
public Skill(SkillCollection skills, PlayerFields field, SkillRecord record, SkillLine skillLine) { PlayerField = field; m_skills = skills; m_record = record; SkillLine = skillLine; m_skills.Owner.SetUInt16Low(field, (ushort)skillLine.Id); m_skills.Owner.SetUInt16High(field, skillLine.Abandonable); SetCurrentValueSilently(record.CurrentValue); MaxValue = record.MaxValue; }
public Skill(SkillCollection skills, PlayerFields field, SkillRecord record, SkillLine skillLine) { this.PlayerField = field; this.m_skills = skills; this.m_record = record; this.SkillLine = skillLine; this.m_skills.Owner.SetUInt16Low((UpdateFieldId)field, (ushort)skillLine.Id); this.m_skills.Owner.SetUInt16High((UpdateFieldId)field, skillLine.Abandonable); this.SetCurrentValueSilently(record.CurrentValue); this.MaxValue = record.MaxValue; }
/// <summary> /// Add a new Skill with initial values to this SkillCollection if it can be added /// </summary> /// <param name="ignoreRestrictions">Whether to ignore the race, class and level requirements of this skill</param> public Skill Add(SkillId id, bool ignoreRestrictions) { SkillLine line = ignoreRestrictions ? SkillHandler.ById.Get <SkillLine>((uint)id) : this.GetLineIfLearnable(id, SkillTierId.Apprentice); if (line != null) { return(this.Add(line, ignoreRestrictions)); } return((Skill)null); }
/// <summary> /// Add a new Skill to this SkillCollection if its not a profession or the character still has professions left (or ignoreRestrictions is true) /// </summary> public Skill Add(SkillLine skillLine, uint value, uint max, bool ignoreRestrictions) { if (!ignoreRestrictions && skillLine.Category == SkillCategory.Profession && FreeProfessions <= 0U) { return(null); } Skill skill = CreateNew(skillLine, value, max); Add(skill, true); if (skillLine.Category == SkillCategory.Profession) { --FreeProfessions; } return(skill); }
public Skill(SkillCollection skills, PlayerFields field, SkillLine skill, uint value, uint max) { this.m_record = new SkillRecord() { SkillId = skill.Id, OwnerId = skills.Owner.Record.Guid }; this.m_skills = skills; this.PlayerField = field; this.SkillLine = skill; this.m_skills.Owner.SetUInt16Low((UpdateFieldId)field, (ushort)skill.Id); this.m_skills.Owner.SetUInt16High((UpdateFieldId)field, skill.Abandonable); this.CurrentValue = (ushort)value; this.MaxValue = (ushort)max; this.m_record.CreateLater(); }
public Skill(SkillCollection skills, PlayerFields field, SkillLine skill, uint value, uint max) { m_record = new SkillRecord { SkillId = skill.Id, OwnerId = skills.Owner.Record.Guid }; m_skills = skills; PlayerField = field; SkillLine = skill; m_skills.Owner.SetUInt16Low(field, (ushort)skill.Id); m_skills.Owner.SetUInt16High(field, skill.Abandonable); CurrentValue = (ushort)value; MaxValue = (ushort)max; m_record.CreateLater(); }
/// <summary> /// Add a new Skill to this SkillCollection if its not a profession or the character still has professions left (or ignoreRestrictions is true) /// </summary> public Skill Add(SkillLine skillLine, uint value, uint max, bool ignoreRestrictions) { if (ignoreRestrictions || skillLine.Category != SkillCategory.Profession || FreeProfessions > 0) { var skill = CreateNew(skillLine, value, max); Add(skill, true); if (skillLine.Category == SkillCategory.Profession) { FreeProfessions--; } return(skill); } return(null); }
public Skill(SkillCollection skills, PlayerFields field, SkillLine skill, uint value, uint max) { m_record = new SkillRecord { SkillId = skill.Id, OwnerId = skills.Owner.Record.Guid }; m_skills = skills; PlayerField = field; SkillLine = skill; m_skills.Owner.SetUInt16Low(field, (ushort)skill.Id); m_skills.Owner.SetUInt16High(field, skill.Abandonable); CurrentValue = (ushort)value; MaxValue = (ushort)max; RealmWorldDBMgr.DatabaseProvider.SaveOrUpdate(m_record); }
internal void InitializeTemplate() { if (Names == null) { Names = new string[(int)ClientLocale.End]; } if (Descriptions == null) { Descriptions = new string[(int)ClientLocale.End]; } if (DefaultDescription == null) { DefaultDescription = ""; } if (string.IsNullOrEmpty(DefaultName) || Id == 0) { // something's off with these entries return; } ItemId = (ItemId)Id; //Faction = (FactionId)Faction; // faction, 3.2.2 RequiredSkill = SkillHandler.Get(RequiredSkillId); Set = ItemMgr.GetSet(SetId); Lock = LockEntry.Entries.Get(LockId); RequiredFaction = FactionMgr.Get(RequiredFactionId); RequiredProfession = SpellHandler.Get(RequiredProfessionId); SubClassMask = (ItemSubClassMask)(1 << (int)SubClass); EquipmentSlots = ItemMgr.EquipmentSlotsByInvSlot.Get((uint)InventorySlotType); InventorySlotMask = (InventorySlotTypeMask)(1 << (int)InventorySlotType); IsAmmo = InventorySlotType == InventorySlotType.Ammo; IsKey = Class == ItemClass.Key; IsBag = InventorySlotType == InventorySlotType.Bag; IsContainer = Class == ItemClass.Container || Class == ItemClass.Quiver; // enchantables can't be stacked IsStackable = MaxAmount > 1 && RandomSuffixId == 0 && RandomPropertiesId == 0; IsTwoHandWeapon = InventorySlotType == InventorySlotType.TwoHandWeapon; SetIsWeapon(); if (ToolCategory != 0)// && TotemCategory != TotemCategory.SkinningKnife) { ItemMgr.FirstTotemsPerCat[(uint)ToolCategory] = this; } if (GemPropertiesId != 0) { GemProperties = EnchantMgr.GetGemproperties(GemPropertiesId); if (GemProperties != null) { GemProperties.Enchantment.GemTemplate = this; } } if (Sockets == null) { Sockets = new SocketInfo[ItemConstants.MaxSocketCount]; } else if (Sockets.Contains(sock => sock.Color != 0)) { HasSockets = true; } if (Damages == null) { Damages = DamageInfo.EmptyArray; } if (Resistances == null) { Resistances = new int[(int)DamageSchool.Count]; } if (SocketBonusEnchantId != 0) { SocketBonusEnchant = EnchantMgr.GetEnchantmentEntry(SocketBonusEnchantId); } switch (Class) { case ItemClass.Weapon: ItemProfession = ItemProfessions.WeaponSubClassProfessions.Get((uint)SubClass); break; case ItemClass.Armor: ItemProfession = ItemProfessions.ArmorSubClassProfessions.Get((uint)SubClass); break; } if (SheathType == SheathType.Undetermined) { // TODO: Read sheath-id from Item.dbc } // spells if (Spells != null) { ArrayUtil.Prune(ref Spells); for (int i = 0; i < 5; i++) { Spells[i].Index = (uint)i; Spells[i].FinalizeAfterLoad(); } } else { Spells = ItemSpell.EmptyArray; } UseSpell = Spells.Where(itemSpell => itemSpell.Trigger == ItemSpellTrigger.Use && itemSpell.Spell != null).FirstOrDefault(); if (UseSpell != null) { UseSpell.Spell.RequiredTargetType = RequiredTargetType; UseSpell.Spell.RequiredTargetId = RequiredTargetId; } EquipSpells = Spells.Where(spell => spell.Trigger == ItemSpellTrigger.Equip && spell.Spell != null).Select(itemSpell => itemSpell.Spell).ToArray(); SoulstoneSpell = Spells.Where(spell => spell.Trigger == ItemSpellTrigger.Soulstone && spell.Spell != null).Select(itemSpell => itemSpell.Spell).FirstOrDefault(); HitSpells = Spells.Where(spell => spell.Trigger == ItemSpellTrigger.ChanceOnHit && spell.Spell != null).Select(itemSpell => itemSpell.Spell).ToArray(); if (UseSpell != null && (UseSpell.Id == SpellId.Learning || UseSpell.Id == SpellId.Learning_2)) { // Teaching TeachSpell = Spells.Where(spell => spell.Trigger == ItemSpellTrigger.Consume).FirstOrDefault(); } ConsumesAmount = (Class == ItemClass.Consumable || Spells.Contains(spell => spell.Trigger == ItemSpellTrigger.Consume)) && (UseSpell == null || !UseSpell.HasCharges); IsHearthStone = UseSpell != null && UseSpell.Spell.IsHearthStoneSpell; IsInventory = InventorySlotType != InventorySlotType.None && InventorySlotType != InventorySlotType.Bag && InventorySlotType != InventorySlotType.Quiver && InventorySlotType != InventorySlotType.Relic; // find set if (SetId != 0) { var set = ItemMgr.Sets.Get((uint)SetId); if (set != null) { ArrayUtil.Add(ref set.Templates, this); } } // truncate arrays if (Mods != null) { ArrayUtil.TruncVals(ref Mods); } else { Mods = StatModifier.EmptyArray; } IsCharter = Flags.HasFlag(ItemFlags.Charter); RandomSuffixFactor = EnchantMgr.GetRandomSuffixFactor(this); if (IsCharter) { Creator = () => new PetitionCharter(); } else if (IsContainer) { Creator = () => new Container(); } else { Creator = () => new Item(); } }
/// <summary> /// Returns a new Skill object /// </summary> protected Skill CreateNew(SkillLine skillLine, uint value, uint max) { return new Skill(this, FindFreeField(), skillLine, value, max); }
/// <summary> /// Add a new Skill to this SkillCollection if its not a profession or the character still has professions left (or ignoreRestrictions is true) /// </summary> public Skill Add(SkillLine skillLine, uint value, uint max, bool ignoreRestrictions) { if (ignoreRestrictions || skillLine.Category != SkillCategory.Profession || FreeProfessions > 0) { var skill = CreateNew(skillLine, value, max); Add(skill, true); if (skillLine.Category == SkillCategory.Profession) { FreeProfessions--; } return skill; } return null; }
/// <summary> /// Adds and returns the given Skill with initial values /// </summary> /// <param name="line"></param> public Skill Add(SkillLine line, bool ignoreRestrictions) { return(Add(line, line.InitialValue, line.InitialLimit, ignoreRestrictions)); }
public void LearnMax(SkillLine skillLine) { GetOrCreate(skillLine.Id, (uint)skillLine.Tier.Values.Length - 1, skillLine.MaxValue); //Add(skill, 375, 375, instant); }
public void LearnMax(SkillLine skillLine) { GetOrCreate(skillLine.Id, skillLine.MaxValue, skillLine.MaxValue); }
public void LearnMax(SkillLine skillLine) { GetOrCreate(skillLine.Id, skillLine.MaxValue, skillLine.MaxValue); //Add(skill, 375, 375, instant); }
/// <summary> /// Adds and returns the given Skill with initial values /// </summary> /// <param name="line"></param> public Skill Add(SkillLine line, bool ignoreRestrictions) { return Add(line, line.InitialValue, line.InitialLimit, ignoreRestrictions); }
/// <summary> /// Returns a new Skill object /// </summary> protected Skill CreateNew(SkillLine skillLine, uint value, uint max) { return(new Skill(this, FindFreeField(), skillLine, value, max)); }