public override void Process(CmdTrigger <RealmServerCmdArgs> trigger) { var id = trigger.Text.NextEnum(SkillId.None); var skillLine = SkillHandler.Get(id); if (skillLine != null) { var chr = ((Character)trigger.Args.Target); var amount = trigger.Text.NextInt(1); //var max = Math.Max(trigger.Text.NextInt(1), amount); var tier = skillLine.GetTierForLevel(amount); var skill = chr.Skills.GetOrCreate(id, true); skill.CurrentValue = (ushort)amount; //skill.MaxValue = (ushort)skillLine.Tiers.GetMaxValue(tier); var spell = skillLine.GetSpellForTier(tier); if (spell != null) { chr.Spells.AddSpell(spell); } trigger.Reply(RealmLangKey.CmdSkillSetResponse, skillLine, amount, tier); } else { trigger.Reply(RealmLangKey.CmdSkillSetError, id); } }
public void FinalizeDataHolder() { if ((Spell = SpellHandler.Get(SpellId)) == null) { ContentMgr.OnInvalidDBData("SpellId is invalid in " + this); } else if (RequiredSpellId != SpellId.None && SpellHandler.Get(RequiredSpellId) == null) { ContentMgr.OnInvalidDBData("RequiredSpellId is invalid in " + this); } else if (RequiredSkillId != SkillId.None && SkillHandler.Get(RequiredSkillId) == null) { ContentMgr.OnInvalidDBData("RequiredSkillId is invalid in " + this); } else { NPCEntry entry = NPCMgr.GetEntry(TrainerId); if (entry == null) { ContentMgr.OnInvalidDBData("TrainerId is invalid in " + this); } else { if (RequiredLevel == 0) { RequiredLevel = Spell.Level; } if (entry.TrainerEntry == null) { entry.TrainerEntry = new TrainerEntry(); } entry.TrainerEntry.AddSpell(this); } } }
public new void FinalizeDataHolder() { if ((Spell = SpellHandler.Get(SpellId)) == null) { ContentMgr.OnInvalidDBData("SpellId is invalid in " + this); } else if (RequiredSpellId != SpellId.None && SpellHandler.Get(RequiredSpellId) == null) { ContentMgr.OnInvalidDBData("RequiredSpellId is invalid in " + this); } else if (RequiredSkillId != SkillId.None && SkillHandler.Get(RequiredSkillId) == null) { ContentMgr.OnInvalidDBData("RequiredSkillId is invalid in " + this); } else { if (RequiredLevel == 0) { RequiredLevel = Spell.Level; } if (!NPCMgr.TrainerSpellTemplates.ContainsKey(TrainerTemplateId)) { NPCMgr.TrainerSpellTemplates.Add(TrainerTemplateId, new List <TrainerSpellEntry>()); } NPCMgr.TrainerSpellTemplates[TrainerTemplateId].Add(this); } }
public override void Process(CmdTrigger <RealmServerCmdArgs> trigger) { var mod = trigger.Text.NextModifiers(); var id = trigger.Text.NextEnum(SkillId.None); var amount = trigger.Text.NextUInt(0); var chr = (Character)trigger.Args.Target; var inv = chr.Inventory; var skillLine = SkillHandler.Get(id); if (skillLine != null) { var skill = ((Character)trigger.Args.Target).Skills.GetOrCreate(id, true); skill.CurrentValue = amount > 0 ? (ushort)amount : (ushort)skillLine.MaxValue; skill.MaxValue = (ushort)skillLine.MaxValue; trigger.Reply(RealmLangKey.CmdSkillLearnResponse, skillLine, amount > 0 ? amount : skillLine.MaxValue); if (mod == "r") { // add bags for (var i = InventorySlot.Bag1; i <= InventorySlot.BagLast; i++) { if (inv[i] == null) { inv.AddUnchecked((int)i, ItemId.FororsCrateOfEndlessResistGearStorage, 1, true); } } } var count = 0; foreach (var ability in SkillHandler.GetAbilities(id)) { if (ability.GreyValue < 1) { continue; } count++; if (count > amount) { break; } chr.Spells.AddSpell(ability.Spell); if (mod == "r") { chr.PlayerSpells.AddSpellRequirements(ability.Spell); } } } else { trigger.Reply(RealmLangKey.CmdSkillLearnError, id); } }
public override CreatureFamily ConvertTo(byte[] rawData, ref int id) { var family = new CreatureFamily { Id = ((CreatureFamilyId)(id = (int)GetUInt32(rawData, 0))), MinScale = GetFloat(rawData, 1), MaxScale = GetFloat(rawData, 3), MaxScaleLevel = GetInt32(rawData, 4), SkillLine = SkillHandler.Get(GetUInt32(rawData, 5)), PetFoodMask = (PetFoodMask)GetUInt32(rawData, 7), PetTalentType = (PetTalentType)GetUInt32(rawData, 8), Name = GetString(rawData, 10) }; family.ScaleStep = (family.MaxScale - family.MinScale) / family.MaxScaleLevel; return(family); }
public override CreatureFamily ConvertTo(byte[] rawData, ref int id) { CreatureFamily creatureFamily = new CreatureFamily() { Id = (CreatureFamilyId)(id = (int)DBCRecordConverter.GetUInt32(rawData, 0)), MinScale = DBCRecordConverter.GetFloat(rawData, 1), MaxScale = DBCRecordConverter.GetFloat(rawData, 3), MaxScaleLevel = DBCRecordConverter.GetInt32(rawData, 4), SkillLine = SkillHandler.Get(DBCRecordConverter.GetUInt32(rawData, 5)), PetFoodMask = (PetFoodMask)DBCRecordConverter.GetUInt32(rawData, 7), PetTalentType = (PetTalentType)DBCRecordConverter.GetUInt32(rawData, 8), Name = this.GetString(rawData, 10) }; creatureFamily.ScaleStep = (creatureFamily.MaxScale - creatureFamily.MinScale) / (float)creatureFamily.MaxScaleLevel; return(creatureFamily); }
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); } }
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); } }
public override ItemSet ConvertTo(byte[] rawData, ref int id) { ItemSet set = new ItemSet(); id = (int)(set.Id = rawData.GetUInt32(0)); set.Name = GetString(rawData, 1); set.Templates = new ItemTemplate[10]; // 17 (or less) items //for (uint i = ItemsOffset; i <= ItemsEnd; i++) //{ // var itemId = rawData.GetUInt32(i); // if (itemId != 0) // { // var templ = ItemMgr.GetTemplate(itemId); // if (templ != null) // { // items.Add(templ); // } // } //} var boni = new Spell[MaxBonusCount]; for (uint i = BoniOffset; i < BoniOffset + MaxBonusCount; i++) { var spellId = rawData.GetUInt32(i); if (spellId != 0) { Spell spell; if ((spell = SpellHandler.Get(spellId)) != null) { var index = i - BoniOffset; boni[index] = spell; } } } var orderedBoni = new List <Spell> [MaxBonusCount]; uint highestIndex = 0; for (uint i = BoniOrderOffset; i < BoniOrderOffset + MaxBonusCount; i++) { var amount = rawData.GetUInt32(i); if (amount > 0) { var orderedIndex = amount - 1; if (highestIndex < orderedIndex) { highestIndex = orderedIndex; } var spells = orderedBoni[orderedIndex]; if (spells == null) { orderedBoni[orderedIndex] = spells = new List <Spell>(3); } var bonusSlot = i - BoniOrderOffset; var spell = boni[bonusSlot]; if (spell != null) { spells.Add(spell); } } } set.Boni = new Spell[highestIndex + 1][]; for (int i = 0; i <= highestIndex; i++) { if (orderedBoni[i] != null) { set.Boni[i] = orderedBoni[i].ToArray(); } } var skillId = (SkillId)rawData.GetUInt32(51); if (skillId > 0) { SkillLine skill = SkillHandler.Get(skillId); if (skill != null) { set.RequiredSkill = skill; set.RequiredSkillValue = rawData.GetUInt32(52); } } return(set); }
public IEnumerable <SkillContract> Get() { return(_skillHandler.Get()); }
internal void InitializeTemplate() { if (this.Names == null) { this.Names = new string[8]; } if (this.Descriptions == null) { this.Descriptions = new string[8]; } if (this.DefaultDescription == null) { this.DefaultDescription = ""; } if (string.IsNullOrEmpty(this.DefaultName) || this.Id == 0U) { return; } this.ItemId = (Asda2ItemId)this.Id; this.RequiredSkill = SkillHandler.Get(this.RequiredSkillId); this.Set = ItemMgr.GetSet(this.SetId); this.Lock = LockEntry.Entries.Get <LockEntry>(this.LockId); this.RequiredFaction = FactionMgr.Get(this.RequiredFactionId); this.RequiredProfession = SpellHandler.Get(this.RequiredProfessionId); this.SubClassMask = (ItemSubClassMask)(1 << (int)(this.SubClass & (ItemSubClass.WeaponDagger | ItemSubClass.WeaponThrown)) ); this.EquipmentSlots = ItemMgr.EquipmentSlotsByInvSlot.Get <EquipmentSlot[]>((uint)this.InventorySlotType); this.InventorySlotMask = (InventorySlotTypeMask)(1 << (int)(this.InventorySlotType & (InventorySlotType.WeaponRanged | InventorySlotType.Cloak))); this.IsAmmo = this.InventorySlotType == InventorySlotType.Ammo; this.IsKey = this.Class == ItemClass.Key; this.IsBag = this.InventorySlotType == InventorySlotType.Bag; this.IsContainer = this.Class == ItemClass.Container || this.Class == ItemClass.Quiver; this.IsStackable = this.MaxAmount > 1 && this.RandomSuffixId == 0U && this.RandomPropertiesId == 0U; this.IsTwoHandWeapon = this.InventorySlotType == InventorySlotType.TwoHandWeapon; this.SetIsWeapon(); if (this.ToolCategory != ToolCategory.None) { ItemMgr.FirstTotemsPerCat[(uint)this.ToolCategory] = this; } if (this.GemPropertiesId != 0U) { this.GemProperties = EnchantMgr.GetGemproperties(this.GemPropertiesId); if (this.GemProperties != null) { this.GemProperties.Enchantment.GemTemplate = this; } } if (this.Sockets == null) { this.Sockets = new SocketInfo[3]; } else if (((IEnumerable <SocketInfo>) this.Sockets).Contains <SocketInfo>( (Func <SocketInfo, bool>)(sock => sock.Color != SocketColor.None))) { this.HasSockets = true; } if (this.Damages == null) { this.Damages = DamageInfo.EmptyArray; } if (this.Resistances == null) { this.Resistances = new int[7]; } if (this.SocketBonusEnchantId != 0U) { this.SocketBonusEnchant = EnchantMgr.GetEnchantmentEntry(this.SocketBonusEnchantId); } switch (this.Class) { case ItemClass.Weapon: this.ItemProfession = ItemProfessions.WeaponSubClassProfessions.Get <SkillId>((uint)this.SubClass); break; case ItemClass.Armor: this.ItemProfession = ItemProfessions.ArmorSubClassProfessions.Get <SkillId>((uint)this.SubClass); break; } int sheathType = (int)this.SheathType; if (this.Spells != null) { ArrayUtil.Prune <ItemSpell>(ref this.Spells); for (int index = 0; index < 5; ++index) { this.Spells[index].Index = (uint)index; this.Spells[index].FinalizeAfterLoad(); } } else { this.Spells = ItemSpell.EmptyArray; } this.UseSpell = ((IEnumerable <ItemSpell>) this.Spells).Where <ItemSpell>( (Func <ItemSpell, bool>)(itemSpell => { if (itemSpell.Trigger == ItemSpellTrigger.Use) { return(itemSpell.Spell != null); } return(false); })).FirstOrDefault <ItemSpell>(); if (this.UseSpell != null) { this.UseSpell.Spell.RequiredTargetType = this.RequiredTargetType; this.UseSpell.Spell.RequiredTargetId = this.RequiredTargetId; } this.EquipSpells = ((IEnumerable <ItemSpell>) this.Spells).Where <ItemSpell>((Func <ItemSpell, bool>)(spell => { if (spell.Trigger == ItemSpellTrigger.Equip) { return(spell.Spell != null); } return(false); })).Select <ItemSpell, Spell>((Func <ItemSpell, Spell>)(itemSpell => itemSpell.Spell)).ToArray <Spell>(); this.SoulstoneSpell = ((IEnumerable <ItemSpell>) this.Spells).Where <ItemSpell>( (Func <ItemSpell, bool>)(spell => { if (spell.Trigger == ItemSpellTrigger.Soulstone) { return(spell.Spell != null); } return(false); })).Select <ItemSpell, Spell>((Func <ItemSpell, Spell>)(itemSpell => itemSpell.Spell)) .FirstOrDefault <Spell>(); this.HitSpells = ((IEnumerable <ItemSpell>) this.Spells).Where <ItemSpell>((Func <ItemSpell, bool>)(spell => { if (spell.Trigger == ItemSpellTrigger.ChanceOnHit) { return(spell.Spell != null); } return(false); })).Select <ItemSpell, Spell>((Func <ItemSpell, Spell>)(itemSpell => itemSpell.Spell)).ToArray <Spell>(); this.ConsumesAmount = (this.Class == ItemClass.Consumable || ((IEnumerable <ItemSpell>) this.Spells).Contains <ItemSpell>( (Func <ItemSpell, bool>)(spell => spell.Trigger == ItemSpellTrigger.Consume))) && (this.UseSpell == null || !this.UseSpell.HasCharges); this.IsHearthStone = this.UseSpell != null && this.UseSpell.Spell.IsHearthStoneSpell; this.IsInventory = this.InventorySlotType != InventorySlotType.None && this.InventorySlotType != InventorySlotType.Bag && this.InventorySlotType != InventorySlotType.Quiver && this.InventorySlotType != InventorySlotType.Relic; if (this.SetId != ItemSetId.None) { ItemSet itemSet = ItemMgr.Sets.Get <ItemSet>((uint)this.SetId); if (itemSet != null) { int num = (int)ArrayUtil.Add <ItemTemplate>(ref itemSet.Templates, this); } } if (this.Mods != null) { ArrayUtil.TruncVals <StatModifier>(ref this.Mods); } else { this.Mods = StatModifier.EmptyArray; } this.IsCharter = this.Flags.HasFlag((Enum)ItemFlags.Charter); this.RandomSuffixFactor = EnchantMgr.GetRandomSuffixFactor(this); if (this.IsCharter) { this.Creator = (Func <Item>)(() => (Item) new PetitionCharter()); } else if (this.IsContainer) { this.Creator = (Func <Item>)(() => (Item) new Container()); } else { this.Creator = (Func <Item>)(() => new Item()); } }
public override ItemSet ConvertTo(byte[] rawData, ref int id) { ItemSet itemSet = new ItemSet(); id = (int)(itemSet.Id = rawData.GetUInt32(0U)); itemSet.Name = this.GetString(rawData, 1); itemSet.Templates = new ItemTemplate[10]; Spell[] spellArray = new Spell[8]; for (uint field = 35; field < 43U; ++field) { uint uint32 = rawData.GetUInt32(field); Spell spell; if (uint32 != 0U && (spell = SpellHandler.Get(uint32)) != null) { uint num = field - 35U; spellArray[num] = spell; } } List <Spell>[] spellListArray = new List <Spell> [8]; uint num1 = 0; for (uint field = 43; field < 51U; ++field) { uint uint32 = rawData.GetUInt32(field); if (uint32 > 0U) { uint num2 = uint32 - 1U; if (num1 < num2) { num1 = num2; } List <Spell> spellList = spellListArray[num2]; if (spellList == null) { spellListArray[num2] = spellList = new List <Spell>(3); } uint num3 = field - 43U; Spell spell = spellArray[num3]; if (spell != null) { spellList.Add(spell); } } } itemSet.Boni = new Spell[num1 + 1U][]; for (int index = 0; (long)index <= (long)num1; ++index) { if (spellListArray[index] != null) { itemSet.Boni[index] = spellListArray[index].ToArray(); } } SkillId uint32_1 = (SkillId)rawData.GetUInt32(51U); if (uint32_1 > SkillId.None) { SkillLine skillLine = SkillHandler.Get(uint32_1); if (skillLine != null) { itemSet.RequiredSkill = skillLine; itemSet.RequiredSkillValue = rawData.GetUInt32(52U); } } return(itemSet); }
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(); } }
internal void InitializeTemplate() { if (Names == null) { Names = new string[8]; } if (Descriptions == null) { Descriptions = new string[8]; } if (DefaultDescription == null) { DefaultDescription = ""; } if (string.IsNullOrEmpty(DefaultName) || Id == 0U) { return; } ItemId = (Asda2ItemId)Id; 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 & (ItemSubClass.WeaponDagger | ItemSubClass.WeaponThrown)) ); EquipmentSlots = ItemMgr.EquipmentSlotsByInvSlot.Get((uint)InventorySlotType); InventorySlotMask = (InventorySlotTypeMask)(1 << (int)(InventorySlotType & (InventorySlotType.WeaponRanged | InventorySlotType.Cloak))); IsAmmo = InventorySlotType == InventorySlotType.Ammo; IsKey = Class == ItemClass.Key; IsBag = InventorySlotType == InventorySlotType.Bag; IsContainer = Class == ItemClass.Container || Class == ItemClass.Quiver; IsStackable = MaxAmount > 1 && RandomSuffixId == 0U && RandomPropertiesId == 0U; IsTwoHandWeapon = InventorySlotType == InventorySlotType.TwoHandWeapon; SetIsWeapon(); if (ToolCategory != ToolCategory.None) { ItemMgr.FirstTotemsPerCat[(uint)ToolCategory] = this; } if (GemPropertiesId != 0U) { GemProperties = EnchantMgr.GetGemproperties(GemPropertiesId); if (GemProperties != null) { GemProperties.Enchantment.GemTemplate = this; } } if (Sockets == null) { Sockets = new SocketInfo[3]; } else if (Sockets.Contains( sock => sock.Color != SocketColor.None)) { HasSockets = true; } if (Damages == null) { Damages = DamageInfo.EmptyArray; } if (Resistances == null) { Resistances = new int[7]; } if (SocketBonusEnchantId != 0U) { 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; } int sheathType = (int)SheathType; if (Spells != null) { ArrayUtil.Prune(ref Spells); for (int index = 0; index < 5; ++index) { Spells[index].Index = (uint)index; Spells[index].FinalizeAfterLoad(); } } else { Spells = ItemSpell.EmptyArray; } UseSpell = Spells.Where( itemSpell => { if (itemSpell.Trigger == ItemSpellTrigger.Use) { return(itemSpell.Spell != null); } return(false); }).FirstOrDefault(); if (UseSpell != null) { UseSpell.Spell.RequiredTargetType = RequiredTargetType; UseSpell.Spell.RequiredTargetId = RequiredTargetId; } EquipSpells = Spells.Where(spell => { if (spell.Trigger == ItemSpellTrigger.Equip) { return(spell.Spell != null); } return(false); }).Select(itemSpell => itemSpell.Spell).ToArray(); SoulstoneSpell = Spells.Where( spell => { if (spell.Trigger == ItemSpellTrigger.Soulstone) { return(spell.Spell != null); } return(false); }).Select(itemSpell => itemSpell.Spell) .FirstOrDefault(); HitSpells = Spells.Where(spell => { if (spell.Trigger == ItemSpellTrigger.ChanceOnHit) { return(spell.Spell != null); } return(false); }).Select(itemSpell => itemSpell.Spell).ToArray(); 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; if (SetId != ItemSetId.None) { ItemSet itemSet = ItemMgr.Sets.Get((uint)SetId); if (itemSet != null) { int num = (int)ArrayUtil.Add(ref itemSet.Templates, this); } } if (Mods != null) { ArrayUtil.TruncVals(ref Mods); } else { Mods = StatModifier.EmptyArray; } IsCharter = Flags.HasFlag(ItemFlags.Charter); RandomSuffixFactor = EnchantMgr.GetRandomSuffixFactor(this); if (IsCharter) { Creator = () => (Item) new PetitionCharter(); } else if (IsContainer) { Creator = () => (Item) new Container(); } else { Creator = () => new Item(); } }