public void FinalizeDataHolder() { SpawnEntry = NPCMgr.GetSpawnEntry(SpawnId); if (SpawnEntry == null) { ContentMgr.OnInvalidDBData("{0} had an invalid SpawnId.", this); } else { var added = false; var cur = SpawnEntry.Waypoints.First; while (cur != null) { if (cur.Value.Id > Id) { Node = cur.List.AddBefore(cur, this); added = true; break; } if (cur.Value.Id == Id) { ContentMgr.OnInvalidDBData("Found multiple Waypoints with the same Id {0} for SpawnEntry {1}", Id, SpawnEntry); return; } cur = cur.Next; } if (!added) { SpawnEntry.HasDefaultWaypoints = false; Node = SpawnEntry.Waypoints.AddLast(this); } } }
public override void Process(CmdTrigger <RealmServerCmdArgs> trigger) { string str = trigger.Text.NextModifiers(); Map map; NPCSpawnEntry npcSpawnEntry = GetNPCSpawnEntry(trigger, str == "c", out map); if (npcSpawnEntry == null) { return; } uint num = trigger.Text.NextUInt(1U); if (num < 1U) { trigger.Reply("Invalid amount: " + num); } else { map.AddNPCSpawnPool(npcSpawnEntry.PoolTemplate); if (trigger.Args.Target != null) { trigger.Args.Target.TeleportTo(map, npcSpawnEntry.Position); } trigger.Reply("Created spawn: {0}", (object)npcSpawnEntry); } }
public void FinalizeDataHolder() { NPCSpawnEntry spawnEntry = NPCMgr.GetSpawnEntry(NPCSpawnId); IGossipEntry entry1 = GossipMgr.GetEntry(GossipId); if (spawnEntry == null) { ContentMgr.OnInvalidDBData("{0} refers to invalid spawn id: {1}", (object)GetType(), (object)this); } else if (entry1 == null) { ContentMgr.OnInvalidDBData("{0} has invalid GossipId: {1}", (object)GetType(), (object)this); } else { NPCEntry entry2 = spawnEntry.Entry; if (spawnEntry.DefaultGossip == null) { spawnEntry.DefaultGossip = new GossipMenu(entry1); } else { spawnEntry.DefaultGossip.GossipEntry = entry1; } } }
public MapTemplate GetMapTemplate() { NPCSpawnEntry npcSpawnEntry = this.SpawnEntries.FirstOrDefault <NPCSpawnEntry>(); if (npcSpawnEntry != null) { return(World.GetMapTemplate(npcSpawnEntry.MapId)); } return((MapTemplate)null); }
public static void CreateTeleportNPC(NPCId id, Vector3 location, MapId mapId, uint phase = WorldObject.DefaultPhase) { var spawn = new NPCSpawnEntry(id, mapId, location); spawn.FinalizeDataHolder(); spawn.Spawned += npc => { npc.Invulnerable++; npc.GossipMenu = WorldLocationMgr.CreateTeleMenu(); }; }
private static void ApplyEventNPCData(WorldEvent worldEvent) { foreach (WorldEventNpcData modelEquip in worldEvent.ModelEquips) { NPCSpawnEntry spawnEntry = NPCMgr.GetSpawnEntry(modelEquip.Guid); if (spawnEntry == null) { WorldEventMgr.Log.Warn("Invalid Spawn Entry in World Event NPC Data, Entry: {0}", modelEquip.Guid); } else { if (modelEquip.EntryId != (NPCId)0) { modelEquip.OriginalEntryId = spawnEntry.EntryId; spawnEntry.EntryId = modelEquip.EntryId; spawnEntry.Entry = NPCMgr.GetEntry(spawnEntry.EntryId); if (spawnEntry.Entry == null) { WorldEventMgr.Log.Warn("{0} had an invalid World Event EntryId.", (object)spawnEntry); spawnEntry.EntryId = modelEquip.OriginalEntryId; spawnEntry.Entry = NPCMgr.GetEntry(spawnEntry.EntryId); } } if (modelEquip.ModelId != 0U) { spawnEntry.DisplayIdOverride = modelEquip.ModelId; } if (modelEquip.EquipmentId != 0U) { modelEquip.OriginalEquipmentId = spawnEntry.EquipmentId; spawnEntry.EquipmentId = modelEquip.EquipmentId; spawnEntry.Equipment = NPCMgr.GetEquipment(spawnEntry.EquipmentId); } foreach (NPCSpawnPoint npcSpawnPoint in ((IEnumerable <NPCSpawnPoint>)spawnEntry.SpawnPoints.ToArray()).Where <NPCSpawnPoint>( (Func <NPCSpawnPoint, bool>)(point => point.IsActive))) { npcSpawnPoint.Respawn(); if (modelEquip.SpellIdToCastAtStart != SpellId.None) { Spell spell = SpellHandler.Get(modelEquip.SpellIdToCastAtStart); if (spell != null) { int num = (int)npcSpawnPoint.ActiveSpawnling.SpellCast.Start(spell); } } } } } }
/// <summary> /// Spawns the pool to which the NPCSpawnEntry belongs which is closest to the given location /// </summary> public static NPCSpawnPoint SpawnClosestSpawnEntry(IWorldLocation pos) { NPCSpawnEntry closestSpawnEntry = NPCMgr.GetClosestSpawnEntry(pos); if (closestSpawnEntry != null) { NPCSpawnPool npcSpawnPool = pos.Map.AddNPCSpawnPoolNow(closestSpawnEntry.PoolTemplate); if (npcSpawnPool != null) { return(npcSpawnPool.GetSpawnPoint(closestSpawnEntry)); } } return((NPCSpawnPoint)null); }
public override void Process(CmdTrigger <RealmServerCmdArgs> trigger) { string str = trigger.Text.NextModifiers(); Map map; NPCSpawnEntry npcSpawnEntry = GetNPCSpawnEntry(trigger, str == "c", out map); if (npcSpawnEntry == null) { return; } if (trigger.Args.Target != null) { trigger.Args.Target.TeleportTo(map, npcSpawnEntry.Position); } trigger.Reply("Created spawn: {0}", (object)npcSpawnEntry); }
public TestBrain(NPC owner) : base((Unit)owner) { NPCSpawnPoint spawnPoint = owner.SpawnPoint; if (spawnPoint == null) { return; } NPCSpawnEntry spawnEntry = spawnPoint.SpawnEntry; if (spawnEntry == null) { return; } this.m_waypoints = spawnEntry.Waypoints; }
private static void DeSpawnEvent(WorldEvent worldEvent) { foreach (WorldEventNPC npcSpawn in worldEvent.NPCSpawns) { NPCSpawnEntry spawnEntry = NPCMgr.GetSpawnEntry(npcSpawn.Guid); Map map = spawnEntry.Map; if (map != null) { if (npcSpawn.Spawn) { map.RemoveNPCSpawnPool(spawnEntry.PoolTemplate); } else { foreach (SpawnPoint <NPCSpawnPoolTemplate, NPCSpawnEntry, NPC, NPCSpawnPoint, NPCSpawnPool> spawnPoint in spawnEntry.SpawnPoints.ToArray()) { spawnPoint.Respawn(); } } } } foreach (WorldEventGameObject goSpawn in worldEvent.GOSpawns) { GOSpawnEntry spawnEntry = GOMgr.GetSpawnEntry(goSpawn.Guid); Map map = spawnEntry.Map; if (map != null) { if (goSpawn.Spawn) { map.RemoveGOSpawnPool(spawnEntry.PoolTemplate); } else { foreach (SpawnPoint <GOSpawnPoolTemplate, GOSpawnEntry, GameObject, GOSpawnPoint, GOSpawnPool> spawnPoint in spawnEntry.SpawnPoints.ToArray()) { spawnPoint.Respawn(); } } } } }
private static void ResetEventNPCData(WorldEvent worldEvent) { foreach (WorldEventNpcData modelEquip in worldEvent.ModelEquips) { NPCSpawnEntry spawnEntry = NPCMgr.GetSpawnEntry(modelEquip.Guid); if (spawnEntry == null) { Log.Warn("Invalid Spawn Entry in World Event NPC Data, Entry: {0}", modelEquip.Guid); } else { if (modelEquip.EntryId != 0) { spawnEntry.EntryId = modelEquip.OriginalEntryId; spawnEntry.Entry = NPCMgr.GetEntry(spawnEntry.EntryId); } if (modelEquip.ModelId != 0U) { spawnEntry.DisplayIdOverride = 0U; } if (modelEquip.EquipmentId != 0U) { spawnEntry.EquipmentId = modelEquip.OriginalEquipmentId; spawnEntry.Equipment = NPCMgr.GetEquipment(spawnEntry.EquipmentId); } foreach (NPCSpawnPoint npcSpawnPoint in spawnEntry.SpawnPoints.ToArray().Where( point => point.IsActive)) { npcSpawnPoint.Respawn(); if (modelEquip.SpellIdToCastAtEnd != SpellId.None) { Spell spell = SpellHandler.Get(modelEquip.SpellIdToCastAtEnd); if (spell != null) { int num = (int)npcSpawnPoint.ActiveSpawnling.SpellCast.Start(spell); } } } } } }
public static NPCSpawnEntry GetClosestSpawnEntry(this IEnumerable <NPCSpawnEntry> entries, IWorldLocation pos) { NPCSpawnEntry npcSpawnEntry = (NPCSpawnEntry)null; float num1 = float.MaxValue; foreach (NPCSpawnEntry entry in entries) { if ((int)entry.Phase == (int)pos.Phase) { float num2 = pos.Position.DistanceSquared(entry.Position); if ((double)num2 < (double)num1) { num1 = num2; npcSpawnEntry = entry; } } } return(npcSpawnEntry); }
public static NPCSpawnEntry GetClosestSpawnEntry(this IEnumerable <NPCSpawnEntry> entries, IWorldLocation pos) { NPCSpawnEntry closest = null; var distanceSq = Single.MaxValue; foreach (var entry in entries) { if (entry.Phase != pos.Phase) { continue; } var distSq = pos.Position.DistanceSquared(entry.Position); if (distSq < distanceSq) { distanceSq = distSq; closest = entry; } } return(closest); }
public void FinalizeDataHolder() { SpawnEntry = NPCMgr.GetSpawnEntry(SpawnId); if (SpawnEntry == null) { ContentMgr.OnInvalidDBData("{0} had an invalid SpawnId.", (object)this); } else { bool flag = false; for (LinkedListNode <WaypointEntry> node = SpawnEntry.Waypoints.First; node != null; node = node.Next) { if (node.Value.Id > Id) { Node = node.List.AddBefore(node, this); flag = true; break; } if ((int)node.Value.Id == (int)Id) { ContentMgr.OnInvalidDBData("Found multiple Waypoints with the same Id {0} for SpawnEntry {1}", (object)Id, (object)SpawnEntry); return; } } if (flag) { return; } SpawnEntry.HasDefaultWaypoints = false; Node = SpawnEntry.Waypoints.AddLast(this); } }
public static NPCSpawnEntry GetClosestSpawnEntry(IWorldLocation pos) { NPCSpawnEntry npcSpawnEntry = (NPCSpawnEntry)null; float num1 = float.MaxValue; foreach (SpawnPoolTemplate <NPCSpawnPoolTemplate, NPCSpawnEntry, NPC, NPCSpawnPoint, NPCSpawnPool> spawnPoolTemplate in NPCMgr.SpawnPoolsByMap[(int)pos.MapId]) { foreach (NPCSpawnEntry entry in spawnPoolTemplate.Entries) { if ((int)entry.Phase == (int)pos.Phase) { float num2 = pos.Position.DistanceSquared(entry.Position); if ((double)num2 < (double)num1) { num1 = num2; npcSpawnEntry = entry; } } } } return(npcSpawnEntry); }
public static NPCSpawnEntry GetClosestSpawnEntry(IWorldLocation pos) { NPCSpawnEntry closest = null; var distanceSq = Single.MaxValue; foreach (var pool in SpawnPoolsByMap[(int)pos.MapId]) { foreach (var entry in pool.Entries) { if (entry.Phase != pos.Phase) { continue; } var distSq = pos.Position.DistanceSquared(entry.Position); if (distSq < distanceSq) { distanceSq = distSq; closest = entry; } } } return(closest); }
private static void SetupPrinceKeleseth() { princeKelesethEntry = NPCMgr.GetEntry(NPCId.PrinceKeleseth); princeKelesethEntry.BrainCreator = princeKeleseth => new PrinceKelesethBrain(princeKeleseth); PrinceSkeletonEntry = NPCMgr.GetEntry(NPCId.VrykulSkeleton); // add spell to prince PrinceSkeletonEntry.AddSpell(SpellId.Decrepify); SpellHandler.Apply(spell => { spell.CooldownTime = 5000; }, SpellId.Decrepify); var princeSpawnEntry = princeKelesethEntry.SpawnEntries[0]; var poolTemplate = princeSpawnEntry.PoolTemplate; // do not let Skeletons decay PrinceSkeletonEntry.DefaultDecayDelayMillis = 0; // add skeleton spawn entries to pool for (var i = 0; i < PrinceSkeletonCount; i++) { var skelSpawnEntry = new NPCSpawnEntry(PrinceSkeletonEntry.NPCId, MapId.UtgardeKeep, PrinceSkeletonPositions[i]) { AutoSpawns = false, // must not respawn automatically when dead IsDead = true, // spawn dead PoolId = poolTemplate.PoolId // share Prince' pool }; skelSpawnEntry.FinalizeDataHolder(); // adds to PoolTemplate automatically PrinceSkeletonSpawnEntries[i] = skelSpawnEntry; } // give the prince his AttackAction princeKelesethEntry.Activated += prince => { var instance = prince.Map as UtgardeKeep; if (instance == null || prince.SpawnPoint == null) return; ((BaseBrain)prince.Brain).DefaultCombatAction.Strategy = new PrinceKelesethAttackAction(prince); instance.SpawnDeadPrinceSkeletons(prince); }; // prince deleted princeKelesethEntry.Deleted += prince => { var instance = prince.Map as UtgardeKeep; if (instance == null) return; // add this "if", in case a GM spawns more than one prince if (instance.PrinceKeleseth == prince) { // unset PrinceKeleseth object instance.PrinceKeleseth = null; } }; // prince dies princeKelesethEntry.Died += prince => { var instance = prince.Map as UtgardeKeep; if (instance == null) return; // kill all skeletons instance.KillPrinceSkeletons(); }; // update Skeleton if it dies/lives or gets deleted PrinceSkeletonEntry.Activated += UpdateSkeleton; PrinceSkeletonEntry.Died += UpdateSkeleton; PrinceSkeletonEntry.Deleted += UpdateSkeleton; princeKelesethEntry.AddSpell(SpellId.ShadowBolt_73); SpellHandler.Apply(spell => { spell.CooldownTime = 10000; }, SpellId.ShadowBolt_73); //Heroic //princeKelesethEntry.AddSpell(SpellId.ShadowBolt_99); //SpellHandler.Apply(spell => { spell.CooldownTime = 5000; }, // SpellId.ShadowBolt_73); //princeKelesethEntry.AddSpell(SpellId.FrostTomb_3); //princeKelesethEntry.AddSpell(SpellId.FrostTomb_3); //princeKelesethEntry.AddSpell(SpellId.FrostTombSummon); //princeKelesethEntry.AddSpell(SpellId.Decrepify); //princeKelesethEntry.AddSpell(SpellId.ScourgeResurrection); }
private static void SetupPrinceKeleseth() { princeKelesethEntry = NPCMgr.GetEntry(NPCId.PrinceKeleseth); princeKelesethEntry.BrainCreator = princeKeleseth => new PrinceKelesethBrain(princeKeleseth); PrinceSkeletonEntry = NPCMgr.GetEntry(NPCId.VrykulSkeleton); // add spell to prince PrinceSkeletonEntry.AddSpell(SpellId.Decrepify); SpellHandler.Apply(spell => { spell.CooldownTime = 5000; }, SpellId.Decrepify); var princeSpawnEntry = princeKelesethEntry.SpawnEntries[0]; var poolTemplate = princeSpawnEntry.PoolTemplate; // do not let Skeletons decay PrinceSkeletonEntry.DefaultDecayDelayMillis = 0; // add skeleton spawn entries to pool for (var i = 0; i < PrinceSkeletonCount; i++) { var skelSpawnEntry = new NPCSpawnEntry(PrinceSkeletonEntry.NPCId, MapId.UtgardeKeep, PrinceSkeletonPositions[i]) { AutoSpawns = false, // must not respawn automatically when dead IsDead = true, // spawn dead PoolId = poolTemplate.PoolId // share Prince' pool }; skelSpawnEntry.FinalizeDataHolder(); // adds to PoolTemplate automatically PrinceSkeletonSpawnEntries[i] = skelSpawnEntry; } // give the prince his AttackAction princeKelesethEntry.Activated += prince => { var instance = prince.Map as UtgardeKeep; if (instance == null || prince.SpawnPoint == null) { return; } ((BaseBrain)prince.Brain).DefaultCombatAction.Strategy = new PrinceKelesethAttackAction(prince); instance.SpawnDeadPrinceSkeletons(prince); }; // prince deleted princeKelesethEntry.Deleted += prince => { var instance = prince.Map as UtgardeKeep; if (instance == null) { return; } // add this "if", in case a GM spawns more than one prince if (instance.PrinceKeleseth == prince) { // unset PrinceKeleseth object instance.PrinceKeleseth = null; } }; // prince dies princeKelesethEntry.Died += prince => { var instance = prince.Map as UtgardeKeep; if (instance == null) { return; } // kill all skeletons instance.KillPrinceSkeletons(); }; // update Skeleton if it dies/lives or gets deleted PrinceSkeletonEntry.Activated += UpdateSkeleton; PrinceSkeletonEntry.Died += UpdateSkeleton; PrinceSkeletonEntry.Deleted += UpdateSkeleton; princeKelesethEntry.AddSpell(SpellId.ShadowBolt_73); SpellHandler.Apply(spell => { spell.CooldownTime = 10000; }, SpellId.ShadowBolt_73); //Heroic //princeKelesethEntry.AddSpell(SpellId.ShadowBolt_99); //SpellHandler.Apply(spell => { spell.CooldownTime = 5000; }, // SpellId.ShadowBolt_73); //princeKelesethEntry.AddSpell(SpellId.FrostTomb_3); //princeKelesethEntry.AddSpell(SpellId.FrostTomb_3); //princeKelesethEntry.AddSpell(SpellId.FrostTombSummon); //princeKelesethEntry.AddSpell(SpellId.Decrepify); //princeKelesethEntry.AddSpell(SpellId.ScourgeResurrection); }
public override void Process(CmdTrigger <RealmServerCmdArgs> trigger) { string str1 = trigger.Text.NextModifiers(); string name = null; if (str1.Contains("d")) { name = trigger.Text.NextWord(); } if (str1.Contains("r")) { NPC target = trigger.Args.Target as NPC; if (target == null) { trigger.Reply("Wrong target."); } else { EntityId entityId = target.EntityId; NPCSpawnEntry spawnEntry = target.SpawnEntry; spawnEntry.CommitDeleteAndFlush(); trigger.Reply("Monstr {0} deleted from spawn.", (object)spawnEntry); } } else { NPCId id = trigger.Text.NextEnum(NPCId.End); if (id == NPCId.End) { trigger.Reply("Invalid NPC."); } else { uint num1 = trigger.Text.NextUInt(1U); if (num1 < 1U) { trigger.Reply("Invalid amount: " + num1); } else { string str2 = null; NPCEntry entry = NPCMgr.GetEntry(id); if (entry == null) { trigger.Reply("Invalid NPCId: " + id); } else { IWorldLocation target; if (!string.IsNullOrEmpty(name)) { target = WorldLocationMgr.Get(name); if (target == null) { trigger.Reply("Invalid destination: " + name); return; } } else { if (trigger.Args.Target == null) { trigger.Reply("No destination given."); return; } target = trigger.Args.Target; } int num2 = 1; int x1 = -num2; int y1 = -num2; int num3 = 8; long num4 = num1 + num3; int num5 = 0; while (true) { while (y1 > num2 || num5++ >= num4) { int y2 = num2; int x2 = x1 + 1; if (num5 < num4) { for (; x2 <= num2 && (long)num5++ < num4; ++x2) { if (num3 < num5) { SpawnMob(x2, y2, entry, target); } } int x3 = num2; int y3 = y2 - 1; if (num5 < num4) { for (; y3 >= -num2 && (long)num5++ < num4; --y3) { if (num3 < num5) { SpawnMob(x3, y3, entry, target); } } y1 = -num2; x1 = x3 - 1; if (num5 < num4) { for (; x1 >= -num2; --x1) { if (x1 == -num2) { ++num2; x1 = -num2; y1 = -num2; break; } if (num5++ < num4) { if (num3 < num5) { SpawnMob(x1, y1, entry, target); } } else { break; } } if (num5 < num4) { continue; } } } } trigger.Reply("Created {0}.", (object)str2); return; } if (num3 < num5) { SpawnMob(x1, y1, entry, target); } ++y1; } } } } } }