public void SetEntry(NPCEntry entry) { Entry = entry; if (m_spawnPoint == null || m_spawnPoint.SpawnEntry.DisplayIdOverride == 0) { Model = entry.ModelInfo; } NativeDisplayId = DisplayId; if (m_brain == null) { // new brain m_brain = m_entry.BrainCreator(this); m_brain.IsRunning = true; } if (m_Movement == null) { m_Movement = new Movement(this); } // misc stuff Name = m_entry.DefaultName; NPCFlags = NPCFlags.None; UnitFlags = UnitFlags.None; DynamicFlags = UnitDynamicFlags.None; Class = ClassId.OHS; Race = RaceId.Human; YieldsXpOrHonor = entry.GeneratesXp; SheathType = SheathType.Melee; // decide which faction if (m_spawnPoint != null) { var map = m_spawnPoint.Map; if (map != null) { Faction = DefaultFaction; } } if (Faction == null) { Faction = entry.RandomFaction; } // speeds m_runSpeed = entry.RunSpeed; m_walkSpeed = entry.WalkSpeed; m_walkBackSpeed = entry.WalkSpeed; Array.Copy(entry.Resistances, m_baseResistances, m_baseResistances.Length); MainWeapon = m_entry.CreateMainHandWeapon(); // Set model after Scale Model = m_entry.GetRandomModel(); GossipMenu = (m_spawnPoint != null && m_spawnPoint.SpawnEntry.DefaultGossip != null) ? m_spawnPoint.SpawnEntry.DefaultGossip : entry.DefaultGossip; if (entry.Resistances != null) { IntMods[(int)StatModifierInt.Asda2Defence] += entry.Resistances[0]; IntMods[(int)StatModifierInt.Asda2MagicDefence] += entry.Resistances[1]; FloatMods[(int)StatModifierFloat.FireResist] += entry.Resistances[2]; FloatMods[(int)StatModifierFloat.EarthResit] += entry.Resistances[3]; FloatMods[(int)StatModifierFloat.WaterResist] += entry.Resistances[4]; FloatMods[(int)StatModifierFloat.DarkResit] += entry.Resistances[5]; FloatMods[(int)StatModifierFloat.LightResist] += entry.Resistances[6]; } UpdateAsda2Defence(); UpdateAsda2MagicDefence(); UpdateFireResistence(); UpdateClimateResistence(); UpdateDarkResistence(); UpdateLightResistence(); UpdateWaterResistence(); UpdateEarthResistence(); PowerType = PowerType.Mana; SetBaseStat(StatType.Strength, 1, false); SetBaseStat(StatType.Agility, 1, false); SetBaseStat(StatType.Intellect, 1, false); SetBaseStat(StatType.Stamina, 1, false); SetBaseStat(StatType.Spirit, 1, false); // health + power var health = entry.GetRandomHealth(); SetInt32(UnitFields.MAXHEALTH, health); SetInt32(UnitFields.BASE_HEALTH, health); if (m_entry.IsDead || m_spawnPoint == null || !m_spawnPoint.SpawnEntry.IsDead) { SetInt32(UnitFields.HEALTH, health); } else if (m_entry.Regenerates) { Regenerates = true; HealthRegenPerTickNoCombat = Math.Max(m_entry.MaxHealth / 10, 1); } var mana = entry.GetRandomMana(); if (mana == 0) { SetInt32(UnitFields.MAXPOWER1, 1); SetInt32(UnitFields.BASE_MANA, 1); } else { SetInt32(UnitFields.MAXPOWER1, mana); SetInt32(UnitFields.BASE_MANA, mana); } SetInt32(UnitFields.POWER1, mana); Power = mana; HoverHeight = entry.HoverHeight; PowerCostMultiplier = 1f; if (PowerType == PowerType.Mana) { ManaRegenPerTickInterrupted = 20; } UpdateUnitState(); if (m_entry.InhabitType.HasFlag(InhabitType.Air)) { Flying++; } AddStandardEquipment(); if (m_mainWeapon != GenericWeapon.Peace) { IncMeleePermissionCounter(); } if (IsImmovable) { InitImmovable(); } Level = entry.GetRandomLevel(); AddMessage(UpdateSpellRanks); }
public void SetEntry(NPCEntry entry) { Entry = entry; if (m_spawnPoint == null || m_spawnPoint.SpawnEntry.DisplayIdOverride == 0) { if (entry.ModelInfos.Length > 0) { Model = entry.ModelInfos.GetRandom(); } } NativeDisplayId = DisplayId; if (m_brain == null) { // new brain m_brain = m_entry.BrainCreator(this); m_brain.IsRunning = true; } if (m_Movement == null) { m_Movement = new Movement(this); } // misc stuff Name = m_entry.DefaultName; NPCFlags = entry.NPCFlags; UnitFlags = entry.UnitFlags; DynamicFlags = entry.DynamicFlags; Class = entry.ClassId; Race = entry.RaceId; YieldsXpOrHonor = entry.GeneratesXp; SheathType = SheathType.Melee; // decide which faction if (m_spawnPoint != null) { var map = m_spawnPoint.Map; if (map != null) { Faction = DefaultFaction; } } if (Faction == null) { Faction = entry.RandomFaction; } // speeds m_runSpeed = entry.RunSpeed; m_swimSpeed = entry.RunSpeed; m_swimBackSpeed = entry.RunSpeed; m_walkSpeed = entry.WalkSpeed; m_walkBackSpeed = entry.WalkSpeed; m_flightSpeed = entry.FlySpeed; m_flightBackSpeed = entry.FlySpeed; Array.Copy(entry.Resistances, m_baseResistances, m_baseResistances.Length); MainWeapon = m_entry.CreateMainHandWeapon(); RangedWeapon = m_entry.CreateRangedWeapon(); OffHandWeapon = entry.CreateOffhandWeapon(); // Set model after Scale Model = m_entry.GetRandomModel(); GossipMenu = (m_spawnPoint != null && m_spawnPoint.SpawnEntry.DefaultGossip != null) ? m_spawnPoint.SpawnEntry.DefaultGossip : entry.DefaultGossip; // TODO: Init stats //for (int i = 0; i < 5; i++) //{ // m_baseStats[i] = statVal; //} PowerType = PowerType.Mana; SetBaseStat(StatType.Strength, 1, false); SetBaseStat(StatType.Agility, 1, false); SetBaseStat(StatType.Intellect, 1, false); SetBaseStat(StatType.Stamina, 1, false); SetBaseStat(StatType.Spirit, 1, false); // health + power var health = entry.GetRandomHealth(); SetInt32(UnitFields.MAXHEALTH, health); SetInt32(UnitFields.BASE_HEALTH, health); if (m_entry.IsDead || m_spawnPoint == null || !m_spawnPoint.SpawnEntry.IsDead) { SetInt32(UnitFields.HEALTH, health); } else if (m_entry.Regenerates) { Regenerates = true; HealthRegenPerTickNoCombat = Math.Max(m_entry.MaxHealth / 10, 1); } var mana = entry.GetRandomMana(); if (mana == 0) { SetInt32(UnitFields.MAXPOWER1, 1); SetInt32(UnitFields.BASE_MANA, 1); } else { SetInt32(UnitFields.MAXPOWER1, mana); SetInt32(UnitFields.BASE_MANA, mana); } SetInt32(UnitFields.POWER1, mana); internalPower = mana; HoverHeight = entry.HoverHeight; PowerCostMultiplier = 1f; if (PowerType == PowerType.Mana) { ManaRegenPerTickInterrupted = 20; } UpdateUnitState(); if (m_entry.InhabitType.HasFlag(InhabitType.Air)) { Flying++; } AddStandardEquipment(); if (m_entry.AddonData != null) { // first add general addon data AddAddonData(m_entry.AddonData); } if (m_spawnPoint != null && m_spawnPoint.SpawnEntry.AddonData != null) { // then override with per-spawn addon data AddAddonData(m_spawnPoint.SpawnEntry.AddonData); } if (m_mainWeapon != GenericWeapon.Peace) { IncMeleePermissionCounter(); } if (IsImmovable) { InitImmovable(); } Level = entry.GetRandomLevel(); AddMessage(UpdateSpellRanks); }