Ejemplo n.º 1
0
 public static void Initialize()
 {
     DefaultFaction = new Faction
     {
         Id = FactionId.None
     };
     DefaultFamily = new CreatureFamily
     {
         Id = CreatureFamilyId.None
     };
     InitDefault();
     LoadNPCDefs(false);
 }
Ejemplo n.º 2
0
        public static void Initialize()
        {
            DefaultFaction = new Faction()
            {
                Id = FactionId.None
            };
            DefaultFamily = new CreatureFamily()
            {
                Id = CreatureFamilyId.None
            };
            InitDefault();

//#if !DEV
            LoadNPCDefs();
//#endif
        }
Ejemplo n.º 3
0
		/// <summary>
		/// Is called to initialize the object; usually after a set of other operations have been performed or if
		/// the right time has come and other required steps have been performed.
		/// </summary>
		public void FinalizeDataHolder()
		{
			if (string.IsNullOrEmpty(DefaultName))
			{
				ContentMgr.OnInvalidDBData("NPCEntry has no name: " + this);
				return;
			}

			if (Titles == null)
			{
				Titles = new string[(int)ClientLocale.End];
			}

			if (DefaultTitle == null)
			{
				DefaultTitle = "";
			}

			if (SpellGroupId != 0 && NPCMgr.PetSpells != null)
			{
				var spells = NPCMgr.PetSpells.Get(SpellGroupId) ?? Spell.EmptyArray;
				foreach (var spell in spells)
				{
					AddSpell(spell);
				}
			}

			if (MinMana > MaxMana)
			{
				MaxMana = MinMana;
			}

			if (MaxDamage > 0)
			{
				if (MinDamage < 1)
				{
					MinDamage = 1;
				}
				if (MaxDamage < MinDamage)
				{
					MaxDamage = MinDamage;
				}
			}

			if (RangedMaxDamage > 0 && RangedMinDamage > 0)
			{
				if (RangedMaxDamage < RangedMinDamage)
				{
					RangedMaxDamage = RangedMinDamage;
				}
				if (RangedAttackTime == 0)
				{
					RangedAttackTime = AttackTime;
				}
			}

			AggroBaseRange = AggroBaseRangeDefault;

			NPCId = (NPCId)Id;

			DefaultDecayDelayMillis = _DefaultDecayDelayMillis;
			Family = NPCMgr.GetFamily(FamilyId);

			if (Type == CreatureType.NotSpecified || VehicleEntry != null)
			{
				IsIdle = true;
			}
			
			if (Type == CreatureType.NotSpecified && UnitFlags.HasFlag((UnitFlags.Passive | UnitFlags.NotSelectable)))
			{
				IsEventTrigger = true;
				IsIdle = false;
			}

			if (Resistances == null)
			{
				Resistances = new int[ItemConstants.MaxResCount];
			}

			SetFlagIndices = Utility.GetSetIndices((uint)NPCFlags);

			// set/fix factions
			HordeFaction = FactionMgr.Get(HordeFactionId);
			AllianceFaction = FactionMgr.Get(AllianceFactionId);
			if (HordeFaction == null)
			{
				HordeFaction = AllianceFaction;
				HordeFactionId = AllianceFactionId;
			}
			else if (AllianceFaction == null)
			{
				AllianceFaction = HordeFaction;
				AllianceFactionId = HordeFactionId;
			}
			if (AllianceFaction == null)
			{
				ContentMgr.OnInvalidDBData("NPCEntry has no valid Faction: " + this);
				HordeFaction = AllianceFaction = NPCMgr.DefaultFaction;
				HordeFactionId = AllianceFactionId = (FactionTemplateId) HordeFaction.Template.Id;
			}

			// speeds
			if (SpeedFactor < 0.01)
			{
				SpeedFactor = 1;
			}

			if (WalkSpeed == 0)
			{
				WalkSpeed = NPCMgr.DefaultNPCWalkSpeed * SpeedFactor;
			}
			if (RunSpeed == 0)
			{
				RunSpeed = NPCMgr.DefaultNPCRunSpeed * SpeedFactor;
			}
			if (FlySpeed == 0)
			{
				FlySpeed = NPCMgr.DefaultNPCFlySpeed * SpeedFactor;
			}

			// Add all default spells
			if (FixedSpells != null)
			{
				foreach (var spell in FixedSpells)
				{
					AddSpell(spell);
				}
			}

			InstanceTypeHandlers = NPCMgr.GetNPCTypeHandlers(this);
			SpawnTypeHandlers = NPCMgr.GetNPCSpawnTypeHandlers(this);

			//ArrayUtil.PruneVals(ref DisplayIds);

			if (EquipmentId != 0)
			{
				Equipment = NPCMgr.GetEquipment(EquipmentId);
			}

			ModelInfos = new UnitModelInfo[DisplayIds.Length];

			GeneratesXp = (Type != CreatureType.Critter && Type != CreatureType.None && !ExtraFlags.HasFlag(UnitExtraFlags.NoXP));

			var x = 0;
			for (var i = 0; i < DisplayIds.Length; i++)
			{
				var did = DisplayIds[i];
				if (did > 0)
				{
					var model = UnitMgr.GetModelInfo(did);
					if (model != null)
					{
						ModelInfos[x++] = model;
					}
				}
			}

			if (x == 0)
			{
				ContentMgr.OnInvalidDBData("NPCEntry has no valid DisplayId: {0} ({1})", this, DisplayIds.ToString(", "));
				return;
			}

            if(TrainerTemplateId != 0)
            {
                if (!NPCMgr.TrainerSpellTemplates.ContainsKey(TrainerTemplateId))
                {
                    ContentMgr.OnInvalidDBData("NPCEntry has invalid TrainerTemplateId: {0} ({1})", this, TrainerTemplateId);
                }
                else
                {
                    if (TrainerEntry == null)
                    {
                        TrainerEntry = new TrainerEntry();
                    }
                    foreach (var trainerSpell in NPCMgr.TrainerSpellTemplates[TrainerTemplateId])
                    {
                        TrainerEntry.AddSpell(trainerSpell);
                    }
                }
            }

			if (AddonData != null)
			{
				AddonData.InitAddonData(this);
			}

			if (x < ModelInfos.Length)
			{
				Array.Resize(ref ModelInfos, x);
			}

			// add to container
			if (Id < NPCMgr.Entries.Length)
			{
				NPCMgr.Entries[Id] = this;
			}
			else
			{
				NPCMgr.CustomEntries[Id] = this;
			}
			++NPCMgr.EntryCount;

			if (BrainCreator == null)
			{
				BrainCreator = DefaultBrainCreator;
			}

			if (NPCCreator == null)
			{
				NPCCreator = DefaultCreator;
			}
		}
Ejemplo n.º 4
0
        /// <summary>
        /// Is called to initialize the object; usually after a set of other operations have been performed or if
        /// the right time has come and other required steps have been performed.
        /// </summary>
        public void FinalizeDataHolder()
        {
            if (string.IsNullOrEmpty(DefaultName))
            {
                ContentMgr.OnInvalidDBData("NPCEntry has no name: " + this);
                return;
            }

            if (SpellGroupId != 0 && NPCMgr.PetSpells != null)
            {
                var spells = NPCMgr.PetSpells.Get(SpellGroupId) ?? Spell.EmptyArray;
                foreach (var spell in spells)
                {
                    AddSpell(spell);
                }
            }

            if (MinMana > MaxMana)
            {
                MaxMana = MinMana;
            }

            if (MaxDamage > 0)
            {
                if (MinDamage < 1)
                {
                    MinDamage = 1;
                }
                if (MaxDamage < MinDamage)
                {
                    MaxDamage = MinDamage;
                }
            }
            if (Rank == CreatureRank.WorldBoss || Rank == CreatureRank.Boss)
            {
                IsBoss = true;
            }

            NPCId = (NPCId)Id;

            DefaultDecayDelayMillis = _DefaultDecayDelayMillis;
            Family = NPCMgr.GetFamily(CreatureFamilyId.Wolf);

            if (Type == CreatureType.NotSpecified || VehicleEntry != null)
            {
                IsIdle = true;
            }

            if (Type == CreatureType.NotSpecified && UnitFlags.HasFlag((UnitFlags.Passive | UnitFlags.NotSelectable)))
            {
                IsEventTrigger = true;
                IsIdle         = false;
            }

            if (Resistances == null)
            {
                Resistances = new int[ItemConstants.MaxResCount];
            }

            SetFlagIndices = Utility.GetSetIndices((uint)NPCFlags);

            // set/fix factions
            HordeFaction    = FactionMgr.Get(HordeFactionId);
            AllianceFaction = FactionMgr.Get(AllianceFactionId);
            if (HordeFaction == null)
            {
                HordeFaction   = AllianceFaction;
                HordeFactionId = AllianceFactionId;
            }
            else if (AllianceFaction == null)
            {
                AllianceFaction   = HordeFaction;
                AllianceFactionId = HordeFactionId;
            }
            if (AllianceFaction == null)
            {
                ContentMgr.OnInvalidDBData("NPCEntry has no valid Faction: " + this);
                HordeFaction   = AllianceFaction = NPCMgr.DefaultFaction;
                HordeFactionId = AllianceFactionId = (FactionTemplateId)HordeFaction.Template.Id;
            }

            // Add all default spells
            if (FixedSpells != null)
            {
                foreach (var spell in FixedSpells)
                {
                    AddSpell(spell);
                }
            }

            InstanceTypeHandlers = NPCMgr.GetNPCTypeHandlers(this);
            SpawnTypeHandlers    = NPCMgr.GetNPCSpawnTypeHandlers(this);


            GeneratesXp = (Type != CreatureType.Critter && Type != CreatureType.None &&
                           !ExtraFlags.HasFlag(UnitExtraFlags.NoXP));

            AtackRange = CombatReach + 0.2f;
            ModelInfo  = new UnitModelInfo {
                BoundingRadius = BoundingRadius, CombatReach = CombatReach
            };

            // add to container
            if (Id < NPCMgr.Entries.Length)
            {
                NPCMgr.Entries[Id] = this;
            }
            else
            {
                NPCMgr.CustomEntries[Id] = this;
            }
            ++NPCMgr.EntryCount;

            if (BrainCreator == null)
            {
                BrainCreator = DefaultBrainCreator;
            }

            if (NPCCreator == null)
            {
                NPCCreator = DefaultCreator;
            }

            #region calc expirience
            Expirience =
                (int)
                (((MinHealth + MaxHealth) * 2.2f + (MaxDamage + MinDamage) * 100 + Resistances.Aggregate((a, r) => a + r * 100)) /
                 2000 * Math.Pow(MinLevel, 0.3325f));
            #endregion
        }
Ejemplo n.º 5
0
		/// <summary>
		/// Is called to initialize the object; usually after a set of other operations have been performed or if
		/// the right time has come and other required steps have been performed.
		/// </summary>
		public void FinalizeDataHolder()
		{
			if (string.IsNullOrEmpty(DefaultName))
			{
				ContentHandler.OnInvalidDBData("NPCEntry has no name: " + this);
				return;
			}

			if (Titles == null)
			{
				Titles = new string[(int)ClientLocale.End];
			}

			if (DefaultTitle == null)
			{
				DefaultTitle = "";
			}

			if (SpellGroupId != 0 && NPCMgr.PetSpells != null)
			{
				var spells = NPCMgr.PetSpells.Get(SpellGroupId) ?? Spell.EmptyArray;
				foreach (var spell in spells)
				{
					AddSpell(spell);
				}
			}

			if (MinMana > MaxMana)
			{
				MaxMana = MinMana;
			}

			if (MaxDamage > 0)
			{
				if (MinDamage < 1)
				{
					MinDamage = 1;
				}
				if (MaxDamage < MinDamage)
				{
					MaxDamage = MinDamage;
				}
			}

			if (RangedMaxDamage > 0 && RangedMinDamage > 0)
			{
				if (RangedMaxDamage < RangedMinDamage)
				{
					RangedMaxDamage = RangedMinDamage;
				}
				if (RangedAttackTime == 0)
				{
					RangedAttackTime = AttackTime;
				}
			}

			MovesRandomly = NPCFlags == NPCFlags.None;

			NPCId = (NPCId)Id;

			DefaultDecayDelay = _DefaultDecayDelay;
			Family = NPCMgr.GetFamily(FamilyId);

			if (Type == NPCType.NotSpecified)
			{
				IsIdle = true;
			}

			const uint gossipStartId = 200231u; // random fixed Id
			NameGossipId = gossipStartId + Id;
			new GossipEntry(NameGossipId, DefaultName + " (" + Id + ")");		// entry adds itself to GossipMgr

			if (Resistances == null)
			{
				Resistances = new int[ItemConstants.MaxResCount];
			}

			SetFlagIndices = Utility.GetSetIndices((uint)NPCFlags);
			HordeFaction = FactionMgr.Get(HordeFactionId);
			AllianceFaction = FactionMgr.Get(AllianceFactionId);

			if (HordeFaction == null)
			{
				HordeFaction = AllianceFaction;
			}
			else if (AllianceFaction == null)
			{
				AllianceFaction = HordeFaction;
			}

			if (AllianceFaction == null)
			{
				ContentHandler.OnInvalidDBData("NPCEntry has no valid Faction: " + this);
				AllianceFaction = NPCMgr.DefaultFaction;
				HordeFaction = AllianceFaction;
			}

			if (SpeedFactor < 0.01)
			{
				SpeedFactor = 1;
			}

			if (WalkSpeed == 0)
			{
				WalkSpeed = NPCMgr.DefaultNPCWalkSpeed * SpeedFactor;
			}
			if (RunSpeed == 0)
			{
				RunSpeed = NPCMgr.DefaultNPCRunSpeed * SpeedFactor;
			}
			if (FlySpeed == 0)
			{
				FlySpeed = NPCMgr.DefaultNPCFlySpeed * SpeedFactor;
			}

			// Add all default spells
			if (FixedSpells != null)
			{
				foreach (var spell in FixedSpells)
				{
					AddSpell(spell);
				}
			}

			InstanceTypeHandlers = NPCMgr.GetNPCTypeHandlers(this);
			SpawnTypeHandlers = NPCMgr.GetNPCSpawnTypeHandlers(this);

			//ArrayUtil.PruneVals(ref DisplayIds);

			if (EquipmentId != 0)
			{
				Equipment = NPCMgr.GetEquipment(EquipmentId);
			}

			ModelInfos = new UnitModelInfo[DisplayIds.Length];

			GeneratesXp = Type != NPCType.Critter && Type != NPCType.None;

			var x = 0;
			for (var i = 0; i < DisplayIds.Length; i++)
			{
				var did = DisplayIds[i];
				if (did > 0)
				{
					var model = UnitMgr.GetModelInfo(did);
					if (model != null)
					{
						ModelInfos[x++] = model;
					}
				}
			}

			if (x == 0)
			{
				ContentHandler.OnInvalidDBData("NPCEntry has no valid DisplayId: {0} ({1})", this, DisplayIds.ToString(", "));
				return;
			}

			if (x < ModelInfos.Length)
			{
				Array.Resize(ref ModelInfos, x);
			}

			// add to container
			if (Id < NPCMgr.Entries.Length)
			{
				NPCMgr.Entries[Id] = this;
			}
			else
			{
				NPCMgr.CustomEntries[Id] = this;
			}
			++NPCMgr.EntryCount;

			if (BrainCreator == null)
			{
				BrainCreator = DefaultBrainCreator;
			}

			if (NPCCreator == null)
			{
				NPCCreator = DefaultCreator;
			}
		}
Ejemplo n.º 6
0
        /// <summary>
        /// Is called to initialize the object; usually after a set of other operations have been performed or if
        /// the right time has come and other required steps have been performed.
        /// </summary>
        public void FinalizeDataHolder()
        {
            if (string.IsNullOrEmpty(DefaultName))
            {
                ContentMgr.OnInvalidDBData("NPCEntry has no name: " + this);
                return;
            }

            if (Titles == null)
            {
                Titles = new string[(int)ClientLocale.End];
            }

            if (DefaultTitle == null)
            {
                DefaultTitle = "";
            }

            if (SpellGroupId != 0 && NPCMgr.PetSpells != null)
            {
                var spells = NPCMgr.PetSpells.Get(SpellGroupId) ?? Spell.EmptyArray;
                foreach (var spell in spells)
                {
                    AddSpell(spell);
                }
            }

            if (MinMana > MaxMana)
            {
                MaxMana = MinMana;
            }

            if (MaxDamage > 0)
            {
                if (MinDamage < 1)
                {
                    MinDamage = 1;
                }
                if (MaxDamage < MinDamage)
                {
                    MaxDamage = MinDamage;
                }
            }

            if (RangedMaxDamage > 0 && RangedMinDamage > 0)
            {
                if (RangedMaxDamage < RangedMinDamage)
                {
                    RangedMaxDamage = RangedMinDamage;
                }
                if (RangedAttackTime == 0)
                {
                    RangedAttackTime = AttackTime;
                }
            }

            AggroBaseRange = AggroBaseRangeDefault;

            NPCId = (NPCId)Id;

            DefaultDecayDelayMillis = _DefaultDecayDelayMillis;
            Family = NPCMgr.GetFamily(FamilyId);

            if (Type == CreatureType.NotSpecified || VehicleEntry != null)
            {
                IsIdle = true;
            }

            if (Type == CreatureType.NotSpecified && UnitFlags.HasFlag((UnitFlags.Passive | UnitFlags.NotSelectable)))
            {
                IsEventTrigger = true;
                IsIdle         = false;
            }

            if (Resistances == null)
            {
                Resistances = new int[ItemConstants.MaxResCount];
            }

            SetFlagIndices = Utility.GetSetIndices((uint)NPCFlags);

            // set/fix factions
            HordeFaction    = FactionMgr.Get(HordeFactionId);
            AllianceFaction = FactionMgr.Get(AllianceFactionId);
            if (HordeFaction == null)
            {
                HordeFaction   = AllianceFaction;
                HordeFactionId = AllianceFactionId;
            }
            else if (AllianceFaction == null)
            {
                AllianceFaction   = HordeFaction;
                AllianceFactionId = HordeFactionId;
            }
            if (AllianceFaction == null)
            {
                ContentMgr.OnInvalidDBData("NPCEntry has no valid Faction: " + this);
                HordeFaction   = AllianceFaction = NPCMgr.DefaultFaction;
                HordeFactionId = AllianceFactionId = (FactionTemplateId)HordeFaction.Template.Id;
            }

            // speeds
            if (SpeedFactor < 0.01)
            {
                SpeedFactor = 1;
            }

            if (WalkSpeed == 0)
            {
                WalkSpeed = NPCMgr.DefaultNPCWalkSpeed * SpeedFactor;
            }
            if (RunSpeed == 0)
            {
                RunSpeed = NPCMgr.DefaultNPCRunSpeed * SpeedFactor;
            }
            if (FlySpeed == 0)
            {
                FlySpeed = NPCMgr.DefaultNPCFlySpeed * SpeedFactor;
            }

            // Add all default spells
            if (FixedSpells != null)
            {
                foreach (var spell in FixedSpells)
                {
                    AddSpell(spell);
                }
            }

            InstanceTypeHandlers = NPCMgr.GetNPCTypeHandlers(this);
            SpawnTypeHandlers    = NPCMgr.GetNPCSpawnTypeHandlers(this);

            //ArrayUtil.PruneVals(ref DisplayIds);

            if (EquipmentId != 0)
            {
                Equipment = NPCMgr.GetEquipment(EquipmentId);
            }

            ModelInfos = new UnitModelInfo[DisplayIds.Length];

            GeneratesXp = (Type != CreatureType.Critter && Type != CreatureType.None && !ExtraFlags.HasFlag(UnitExtraFlags.NoXP));

            var x = 0;

            for (var i = 0; i < DisplayIds.Length; i++)
            {
                var did = DisplayIds[i];
                if (did > 0)
                {
                    var model = UnitMgr.GetModelInfo(did);
                    if (model != null)
                    {
                        ModelInfos[x++] = model;
                    }
                }
            }

            if (x == 0)
            {
                ContentMgr.OnInvalidDBData("NPCEntry has no valid DisplayId: {0} ({1})", this, DisplayIds.ToString(", "));
                return;
            }

            if (TrainerTemplateId != 0)
            {
                if (!NPCMgr.TrainerSpellTemplates.ContainsKey(TrainerTemplateId))
                {
                    ContentMgr.OnInvalidDBData("NPCEntry has invalid TrainerTemplateId: {0} ({1})", this, TrainerTemplateId);
                }
                else
                {
                    if (TrainerEntry == null)
                    {
                        TrainerEntry = new TrainerEntry();
                    }
                    foreach (var trainerSpell in NPCMgr.TrainerSpellTemplates[TrainerTemplateId])
                    {
                        TrainerEntry.AddSpell(trainerSpell);
                    }
                }
            }

            if (AddonData != null)
            {
                AddonData.InitAddonData(this);
            }

            if (x < ModelInfos.Length)
            {
                Array.Resize(ref ModelInfos, x);
            }

            // add to container
            if (Id < NPCMgr.Entries.Length)
            {
                NPCMgr.Entries[Id] = this;
            }
            else
            {
                NPCMgr.CustomEntries[Id] = this;
            }
            ++NPCMgr.EntryCount;

            if (BrainCreator == null)
            {
                BrainCreator = DefaultBrainCreator;
            }

            if (NPCCreator == null)
            {
                NPCCreator = DefaultCreator;
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Is called to initialize the object; usually after a set of other operations have been performed or if
        /// the right time has come and other required steps have been performed.
        /// </summary>
        public void FinalizeDataHolder()
        {
            if (string.IsNullOrEmpty(this.DefaultName))
            {
                ContentMgr.OnInvalidDBData("NPCEntry has no name: " + (object)this);
            }
            else
            {
                if (this.SpellGroupId != 0U && NPCMgr.PetSpells != null)
                {
                    foreach (Spell spell in NPCMgr.PetSpells.Get <Spell[]>(this.SpellGroupId) ?? Spell.EmptyArray)
                    {
                        this.AddSpell(spell);
                    }
                }

                if (this.MinMana > this.MaxMana)
                {
                    this.MaxMana = this.MinMana;
                }
                if ((double)this.MaxDamage > 0.0)
                {
                    if ((double)this.MinDamage < 1.0)
                    {
                        this.MinDamage = 1f;
                    }
                    if ((double)this.MaxDamage < (double)this.MinDamage)
                    {
                        this.MaxDamage = this.MinDamage;
                    }
                }

                if (this.Rank == CreatureRank.WorldBoss || this.Rank == CreatureRank.Boss)
                {
                    this.IsBoss = true;
                }
                this.NPCId = (NPCId)this.Id;
                this.DefaultDecayDelayMillis = this._DefaultDecayDelayMillis;
                this.Family = NPCMgr.GetFamily(CreatureFamilyId.Wolf);
                if (this.Type == CreatureType.NotSpecified || this.VehicleEntry != null)
                {
                    this.IsIdle = true;
                }
                if (this.Type == CreatureType.NotSpecified &&
                    this.UnitFlags.HasFlag((Enum)(UnitFlags.Passive | UnitFlags.NotSelectable)))
                {
                    this.IsEventTrigger = true;
                    this.IsIdle         = false;
                }

                if (this.Resistances == null)
                {
                    this.Resistances = new int[7];
                }
                this.SetFlagIndices  = Utility.GetSetIndices((uint)this.NPCFlags);
                this.HordeFaction    = FactionMgr.Get(this.HordeFactionId);
                this.AllianceFaction = FactionMgr.Get(this.AllianceFactionId);
                if (this.HordeFaction == null)
                {
                    this.HordeFaction   = this.AllianceFaction;
                    this.HordeFactionId = this.AllianceFactionId;
                }
                else if (this.AllianceFaction == null)
                {
                    this.AllianceFaction   = this.HordeFaction;
                    this.AllianceFactionId = this.HordeFactionId;
                }

                if (this.AllianceFaction == null)
                {
                    ContentMgr.OnInvalidDBData("NPCEntry has no valid Faction: " + (object)this);
                    this.HordeFaction   = this.AllianceFaction = NPCMgr.DefaultFaction;
                    this.HordeFactionId = this.AllianceFactionId = (FactionTemplateId)this.HordeFaction.Template.Id;
                }

                if (this.FixedSpells != null)
                {
                    foreach (SpellId fixedSpell in this.FixedSpells)
                    {
                        this.AddSpell(fixedSpell);
                    }
                }

                this.InstanceTypeHandlers = NPCMgr.GetNPCTypeHandlers(this);
                this.SpawnTypeHandlers    = NPCMgr.GetNPCSpawnTypeHandlers(this);
                this.GeneratesXp          = this.Type != CreatureType.Critter && this.Type != CreatureType.None &&
                                            !this.ExtraFlags.HasFlag((Enum)UnitExtraFlags.NoXP);
                this.AtackRange = this.CombatReach + 0.2f;
                this.ModelInfo  = new UnitModelInfo()
                {
                    BoundingRadius = this.BoundingRadius,
                    CombatReach    = this.CombatReach
                };
                if ((long)this.Id < (long)NPCMgr.Entries.Length)
                {
                    NPCMgr.Entries[this.Id] = this;
                }
                else
                {
                    NPCMgr.CustomEntries[this.Id] = this;
                }
                ++NPCMgr.EntryCount;
                if (this.BrainCreator == null)
                {
                    this.BrainCreator = new Func <NPC, IBrain>(this.DefaultBrainCreator);
                }
                if (this.NPCCreator == null)
                {
                    this.NPCCreator = NPCEntry.DefaultCreator;
                }
                this.Expirience = (int)(((double)(this.MinHealth + this.MaxHealth) * 2.20000004768372 +
                                         ((double)this.MaxDamage + (double)this.MinDamage) * 100.0 +
                                         (double)((IEnumerable <int>) this.Resistances).Aggregate <int>(
                                             (Func <int, int, int>)((a, r) => a + r * 100))) / 2000.0 *
                                        Math.Pow((double)this.MinLevel, 0.332500010728836));
            }
        }