/// <summary> /// Create a new inventory artifact from an item template. /// </summary> /// <param name="template"></param> public InventoryArtifact(ItemTemplate template) : base(template) { ArtifactID = ArtifactMgr.GetArtifactIDFromItemID(template.Id_nb); ArtifactLevel = 0; m_levelRequirements = ArtifactMgr.GetLevelRequirements(ArtifactID); for (ArtifactBonus.ID bonusID = ArtifactBonus.ID.Min; bonusID <= ArtifactBonus.ID.Max; ++bonusID) { // Clear all bonuses except the base (L0) bonuses. if (m_levelRequirements[(int)bonusID] > 0) { Template.SetBonusType(bonusID, 0); Template.SetBonusAmount(bonusID, 0); } } }
/// <summary> /// Create a new inventory artifact from an existing inventory item. /// </summary> /// <param name="item"></param> public InventoryArtifact(InventoryItem item) : base(item) { if (item != null) { // We want a new copy from the DB to avoid everyone sharing the same template var template = item.Template != null?item.Template.Clone() as ItemTemplate : item.Template; if (template == null) { log.ErrorFormat("Artifact: Error loading artifact for owner {0} holding item {1} with an id_nb of {2}", item.OwnerID, item.Name, item.Id_nb); return; } Template = template; ObjectId = item.ObjectId; // This is the key for the 'inventoryitem' table OwnerID = item.OwnerID; CanUseEvery = ArtifactMgr.GetReuseTimer(this); ArtifactID = ArtifactMgr.GetArtifactIDFromItemID(Id_nb); ArtifactLevel = ArtifactMgr.GetCurrentLevel(this); m_levelRequirements = ArtifactMgr.GetLevelRequirements(ArtifactID); UpdateAbilities(template); } }