protected override void Apply() { Unit owner = this.m_aura.Auras.Owner; owner.Dismount(); this.displayId = owner.DisplayId; if (this.m_spellEffect.MiscValue > 0) { if (!NPCMgr.EntriesLoaded) { return; } NPCEntry entry = NPCMgr.GetEntry((uint)this.m_spellEffect.MiscValue); if (entry == null) { TransformHandler.log.Warn("Transform spell {0} has invalid creature-id {1}", (object)this.m_aura.Spell, (object)this.m_spellEffect.MiscValue); } else { owner.Model = entry.GetRandomModel(); } } else { TransformHandler.log.Warn("Transform spell {0} has no creature-id set", (object)this.m_aura.Spell); } }
protected Figurine(NPCEntry entry) { m_entry = entry; GenerateId(m_entry.Id); UnitFlags = UnitFlags.SelectableNotAttackable | UnitFlags.Possessed; DynamicFlags = UnitDynamicFlags.TrackUnit; EmoteState = EmoteType.StateDead; NPCFlags |= NPCFlags.Gossip; Model = m_entry.GetRandomModel(); EntryId = m_entry.Id; var speed = 10f; m_runSpeed = speed; m_swimSpeed = speed; m_swimBackSpeed = speed; m_walkSpeed = speed; m_walkBackSpeed = speed; m_flightSpeed = speed; m_flightBackSpeed = speed; SetInt32(UnitFields.MAXHEALTH, int.MaxValue); SetInt32(UnitFields.BASE_HEALTH, int.MaxValue); SetInt32(UnitFields.HEALTH, int.MaxValue); // just make a smaller version of the creature to be spawned SetFloat(ObjectFields.SCALE_X, entry.Scale * DefaultScale); IsEvading = true; }
protected FigurineBase(NPCId id) { if (_sharedAuras == null) { _sharedAuras = new AuraCollection(this); } m_auras = _sharedAuras; GenerateId((uint)id); NPCEntry entry = NPCMgr.GetEntry(id); UnitFlags = UnitFlags.SelectableNotAttackable | UnitFlags.Possessed; DynamicFlags = UnitDynamicFlags.TrackUnit; EmoteState = EmoteType.StateDead; NPCFlags |= NPCFlags.Gossip; Model = entry.GetRandomModel(); EntryId = entry.Id; m_runSpeed = 1f; m_swimSpeed = 1f; m_swimBackSpeed = 1f; m_walkSpeed = 1f; m_walkBackSpeed = 1f; m_flightSpeed = 1f; m_flightBackSpeed = 1f; SetInt32(UnitFields.MAXHEALTH, int.MaxValue); SetInt32(UnitFields.BASE_HEALTH, int.MaxValue); SetInt32(UnitFields.HEALTH, int.MaxValue); SetFloat(ObjectFields.SCALE_X, entry.Scale * DefaultScale); m_evades = true; }
public static void FlyUnit(Unit unit, bool startFlight, LinkedListNode <PathVertex> startNode) { if (unit.TaxiPaths.Count < 1) { throw new InvalidOperationException("Tried to fly Unit without Path given."); } TaxiPath taxiPath = unit.TaxiPaths.Peek(); unit.IsInCombat = false; unit.Stealthed = 0; if (startFlight) { NPCEntry entry = NPCMgr.GetEntry(unit.Faction.IsAlliance ? taxiPath.From.AllianceMountId : taxiPath.From.HordeMountId); if (entry != null) { uint displayId = entry.GetRandomModel().DisplayId; unit.Mount(displayId); if (unit is Character) { unit.PushFieldUpdateToPlayer((Character)unit, UnitFields.MOUNTDISPLAYID, displayId); } } unit.OnTaxiStart(); } unit.LatestTaxiPathNode = startNode ?? taxiPath.Nodes.First; if (unit.LatestTaxiPathNode == taxiPath.Nodes.First) { unit.taxiTime = 0; MovementHandler.SendMoveToPacket(unit, taxiPath.PathTime, MonsterMoveFlags.Flag_0x2000_FullPoints_1, taxiPath.Nodes); } else { unit.taxiTime = startNode.Previous.Value.TimeFromStart + (int)(1000.0 * startNode.Value.Pos.GetDistance(unit.Position) / AirSpeed); MovementHandler.SendMoveToPacket(unit, AirSpeed, MonsterMoveFlags.Flag_0x2000_FullPoints_1, startNode); } }
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); }