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; } } }
public void FinalizeAfterLoad() { FemaleModel = UnitMgr.GetModelInfo(FemaleDisplayId); if (FemaleModel == null) { return; } MaleModel = UnitMgr.GetModelInfo(MaleDisplayId); if (MaleModel == null) { return; } 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; }
public void FinalizeAfterLoad() { this.FemaleModel = UnitMgr.GetModelInfo(this.FemaleDisplayId); if (this.FemaleModel == null) { return; } this.MaleModel = UnitMgr.GetModelInfo(this.MaleDisplayId); if (this.MaleModel == null) { return; } if ((double)this.FemaleModel.BoundingRadius < 0.1) { this.FemaleModel.BoundingRadius = this.MaleModel.BoundingRadius; } else if ((double)this.MaleModel.BoundingRadius < 0.1) { this.MaleModel.BoundingRadius = this.FemaleModel.BoundingRadius; } if ((double)this.FemaleModel.CombatReach < 0.1) { this.FemaleModel.CombatReach = this.MaleModel.CombatReach; } else if ((double)this.MaleModel.CombatReach < 0.1) { this.MaleModel.CombatReach = this.FemaleModel.CombatReach; } ArchetypeMgr.BaseRaces[(uint)this.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 (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; } }