public void FinalizeAfterLoad() { //Faction = FactionMgr.Get(FactionTemplateId); FemaleModel = UnitMgr.GetModelInfo(FemaleDisplayId); if (FemaleModel != null) { MaleModel = UnitMgr.GetModelInfo(MaleDisplayId); if (MaleModel != null) { // fix broken values if (FemaleModel.BoundingRadius < 0.1) { FemaleModel.BoundingRadius = MaleModel.BoundingRadius; } else if (MaleModel.BoundingRadius < 0.1) { MaleModel.BoundingRadius = FemaleModel.BoundingRadius; } if (FemaleModel.CombatReach < 0.1) { FemaleModel.CombatReach = MaleModel.CombatReach; } else if (MaleModel.CombatReach < 0.1) { MaleModel.CombatReach = FemaleModel.CombatReach; } ArchetypeMgr.BaseRaces[(uint) Id] = this; } } }
/// <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 }
/// <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)); } }