public Npc Create(uint objectId, uint id) { if (!_templates.ContainsKey(id)) { return(null); } var template = _templates[id]; var npc = new Npc(); npc.ObjId = objectId > 0 ? objectId : ObjectIdManager.Instance.GetNextId(); npc.TemplateId = id; npc.Template = template; npc.ModelId = template.ModelId; npc.Faction = FactionManager.Instance.GetFaction(template.FactionId); npc.Level = template.Level; SetEquipItemTemplate(npc, template.Items.Headgear, EquipmentItemSlot.Head); SetEquipItemTemplate(npc, template.Items.Necklace, EquipmentItemSlot.Neck); SetEquipItemTemplate(npc, template.Items.Shirt, EquipmentItemSlot.Chest); SetEquipItemTemplate(npc, template.Items.Belt, EquipmentItemSlot.Waist); SetEquipItemTemplate(npc, template.Items.Pants, EquipmentItemSlot.Legs); SetEquipItemTemplate(npc, template.Items.Gloves, EquipmentItemSlot.Hands); SetEquipItemTemplate(npc, template.Items.Shoes, EquipmentItemSlot.Feet); SetEquipItemTemplate(npc, template.Items.Bracelet, EquipmentItemSlot.Arms); SetEquipItemTemplate(npc, template.Items.Back, EquipmentItemSlot.Back); SetEquipItemTemplate(npc, template.Items.Undershirts, EquipmentItemSlot.Undershirt); SetEquipItemTemplate(npc, template.Items.Underpants, EquipmentItemSlot.Underpants); SetEquipItemTemplate(npc, template.Items.Mainhand, EquipmentItemSlot.Mainhand); SetEquipItemTemplate(npc, template.Items.Offhand, EquipmentItemSlot.Offhand); SetEquipItemTemplate(npc, template.Items.Ranged, EquipmentItemSlot.Ranged); SetEquipItemTemplate(npc, template.Items.Musical, EquipmentItemSlot.Musical); SetEquipItemTemplate(npc, template.Items.Cosplay, EquipmentItemSlot.Cosplay); if (template.ModelParams != null) { SetEquipItemTemplate(npc, template.HairId, EquipmentItemSlot.Hair); for (var i = 0; i < 7; i++) { SetEquipItemTemplate(npc, template.BodyItems[i], (EquipmentItemSlot)(i + 19)); } } else if (template.CharRaceId > 0) { for (var i = 0; i < 7; i++) { SetEquipItemTemplate(npc, template.BodyItems[i], (EquipmentItemSlot)(i + 19)); } } foreach (var bonusTemplate in template.Bonuses) { var bonus = new Bonus(); bonus.Template = bonusTemplate; bonus.Value = bonusTemplate.Value; // TODO using LinearLevelBonus npc.AddBonus(0, bonus); } npc.Hp = npc.MaxHp; npc.Mp = npc.MaxMp; return(npc); }