public GameObject Spawn(IWorldLocation where, Unit owner) { GameObject gameObject = GameObject.Create(this, where, FirstSpawnEntry, null); gameObject.Owner = owner; return(gameObject); }
/// <summary> /// Creates a new GameObject with the given parameters /// </summary> public static GameObject Create(GOEntry entry, IWorldLocation where, GOSpawnEntry spawnEntry = null, GOSpawnPoint spawnPoint = null) { var go = entry.GOCreator(); var handlerCreator = entry.HandlerCreator; go.Init(entry, spawnEntry, spawnPoint); if (handlerCreator != null) { go.Handler = handlerCreator(); } else { log.Warn("GOEntry {0} did not have a HandlerCreator set - Type: {1}", entry, entry.Type); go.Delete(); return(null); } go.Phase = where.Phase; var pos = where.Position; if (spawnPoint == null) { pos.Z = where.Map.Terrain.GetGroundHeightUnderneath(pos); } where.Map.AddObject(go, ref pos); go.MarkUpdate(GameObjectFields.DYNAMIC); return(go); }
public GameObject Spawn(IWorldLocation where, Unit owner) { var go = GameObject.Create(this, where, FirstSpawnEntry); go.Owner = owner; return(go); }
void CreatePortal(WorldObject at, IWorldLocation target) { // create portal var portal = Portal.Create(at, target); at.PlaceInFront(portal); }
/// <summary> /// Creates a new GameObject with the given parameters /// </summary> public static GameObject Create(GOEntry entry, IWorldLocation where, GOSpawnEntry spawnEntry = null, GOSpawnPoint spawnPoint = null) { var go = entry.GOCreator(); var handlerCreator = entry.HandlerCreator; go.Init(entry, spawnEntry, spawnPoint); if (handlerCreator != null) { go.Handler = handlerCreator(); } else { log.Warn("GOEntry {0} did not have a HandlerCreator set - Type: {1}", entry, entry.Type); go.Delete(); return null; } go.Phase = where.Phase; var pos = where.Position; if (spawnPoint == null) { pos.Z = where.Map.Terrain.GetGroundHeightUnderneath(pos); } where.Map.AddObject(go, ref pos); go.MarkUpdate(GameObjectFields.DYNAMIC); return go; }
/// <summary>Creates a new GameObject with the given parameters</summary> public static GameObject Create(GOEntry entry, IWorldLocation where, GOSpawnEntry spawnEntry = null, GOSpawnPoint spawnPoint = null) { GameObject gameObject = entry.GOCreator(); gameObject.GoId = entry.GOId; Func <GameObjectHandler> handlerCreator = entry.HandlerCreator; gameObject.Init(entry, spawnEntry, spawnPoint); if (handlerCreator != null) { gameObject.Handler = handlerCreator(); gameObject.Phase = where.Phase; Vector3 position = where.Position; if (spawnPoint == null) { position.Z = where.Map.Terrain.GetGroundHeightUnderneath(position); } where.Map.AddObject(gameObject, ref position); gameObject.MarkUpdate(GameObjectFields.DYNAMIC); return(gameObject); } log.Warn("GOEntry {0} did not have a HandlerCreator set - Type: {1}", entry, entry.Type); gameObject.Delete(); return(null); }
private void SpawnMob(int x, int y, NPCEntry entry, IWorldLocation dest) { Vector3 pos = new Vector3(dest.Position.X + x, dest.Position.Y + y); WorldLocation worldLocation = new WorldLocation(dest.Map, pos, 1U); entry.SpawnAt(worldLocation, false).Brain.State = BrainState.GmMove; }
private void SpawnMob(int x, int y, uint npcId, IWorldLocation dest) { Vector3 pos = new Vector3(dest.Position.X + x, dest.Position.Y + y); WorldLocation worldLocation = new WorldLocation(dest.Map, pos, 1U); NPCMgr.GetEntry(npcId).SpawnAt(worldLocation, false).Brain.State = BrainState.Roam; }
private void SpawnMob(int x, int y, uint npcId, IWorldLocation dest) { var pos = new Vector3(dest.Position.X + x, dest.Position.Y + y); var wl = new WorldLocation(dest.Map, pos); var newNpc = NPCMgr.GetEntry(npcId).SpawnAt(wl); newNpc.Brain.State = BrainState.Roam; }
public static bool IsValid(this IWorldLocation location) { if ((double)location.Position.X != 0.0 && location.Map != null) { return(location.Phase != 0U); } return(false); }
private void SpawnMob(int x, int y, NPCEntry entry, IWorldLocation dest) { var pos = new Vector3(dest.Position.X + x, dest.Position.Y + y); var wl = new WorldLocation(dest.Map, pos); var newNpc = entry.SpawnAt(wl); newNpc.Brain.State = BrainState.GmMove; }
/// <summary> /// Creates the given kind of GameObject with the default Template /// </summary> public static GameObject Create(GOEntryId id, IWorldLocation location, GOSpawnEntry spawnEntry = null, GOSpawnPoint spawnPoint = null) { var entry = GOMgr.GetEntry(id); if (entry == null) { return null; } return Create(entry, location, spawnEntry, spawnPoint); }
/// <summary> /// Creates the given kind of GameObject with the default Template /// </summary> public static GameObject Create(GOEntryId id, IWorldLocation location, GOSpawnEntry spawnEntry = null, GOSpawnPoint spawnPoint = null) { var entry = GOMgr.GetEntry(id); if (entry == null) { return(null); } return(Create(entry, location, spawnEntry, spawnPoint)); }
public static Portal Create(IWorldLocation where, IWorldLocation target) { var entry = GOMgr.GetEntry(GOPortalEntry.PortalId); if (entry == null) { return null; } var portal = (Portal)Create(entry, where); portal.Target = target; return portal; }
public static bool IsValid(this IWorldLocation location, Unit user) { if (location.Position.Equals(new Vector3())) { return(false); } if (location.Map == null) { return(user.Map.Id == location.MapId); } return(true); }
private void IbrakoSummon(NPC npc, IWorldLocation dest) { if (npc.HealthPct < 40 && !npc.HelperBossSummoned) { npc.HelperBossSummoned = true; SpawnMob(2, 2, 752, dest); } else if (npc.HealthPct >= 40) { SpawnMob(-2, -2, 751, npc); SpawnMob(0, -2, 747, dest); } }
/// <summary> /// Iterates over all objects of the given Type within the given radius around this object. /// </summary> /// <param name="radius"></param> /// <param name="predicate">Returns whether to continue iteration.</param> /// <returns>True, if iteration should continue (usually indicating that we did not find what we were looking for).</returns> public static bool IterateEnvironment <O>(this IWorldLocation location, float radius, Func <O, bool> predicate) where O : WorldObject { return(location.Map.IterateObjects(location.Position, radius, location.Phase, (Func <WorldObject, bool>)(obj => { if (obj is O) { return predicate((O)obj); } return true; }))); }
public NPC SpawnAt(IWorldLocation loc, bool hugGround = false) { NPC npc = this.Create(loc.Map.DifficultyIndex); Vector3 position = loc.Position; if (hugGround && this.InhabitType == InhabitType.Ground) { position.Z = loc.Map.Terrain.GetGroundHeightUnderneath(position); } loc.Map.AddObject((WorldObject)npc, loc.Position); npc.Phase = loc.Phase; return(npc); }
public static Portal Create(IWorldLocation where, IWorldLocation target) { GOEntry entry = GOMgr.GetEntry(GOEntryId.Portal, true); if (entry == null) { return(null); } Portal portal = (Portal)GameObject.Create(entry, where, null, null); portal.Target = target; return(portal); }
public NPC SpawnAt(IWorldLocation loc, bool hugGround = false) { var npc = Create(loc.Map.DifficultyIndex); var pos = loc.Position; if (hugGround && InhabitType == InhabitType.Ground) { pos.Z = loc.Map.Terrain.GetGroundHeightUnderneath(pos); } loc.Map.AddObject(npc, loc.Position); npc.Phase = loc.Phase; return(npc); }
public static Portal Create(IWorldLocation where, IWorldLocation target) { var entry = GOMgr.GetEntry(GOPortalEntry.PortalId); if (entry == null) { return(null); } var portal = (Portal)Create(entry, where); portal.Target = target; return(portal); }
/// <summary> /// Spawns the pool to which the NPCSpawnEntry belongs which is closest to the given location /// </summary> public static NPCSpawnPoint SpawnClosestSpawnEntry(IWorldLocation pos) { var entry = GetClosestSpawnEntry(pos); if (entry != null) { var pool = pos.Map.AddNPCSpawnPoolNow(entry.PoolTemplate); if (pool != null) { return(pool.GetSpawnPoint(entry)); } } return(null); }
/// <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); }
private void KaiyaSummon(NPC npc, IWorldLocation dest) { if (npc.HealthPct < 40 && !npc.HelperBossSummoned) { npc.HelperBossSummoned = true; SpawnMob(2, 2, 511, dest); //hysteric kaiya } else if (npc.HealthPct >= 40) { SpawnMob(-2, -2, 324, dest); SpawnMob(-1, -2, 325, dest); SpawnMob(0, -2, 326, dest); SpawnMob(1, -2, 327, dest); } }
private void IbrakoSummon(NPC npc, IWorldLocation dest) { if (npc.HealthPct < 40 && !npc.HelperBossSummoned) { npc.HelperBossSummoned = true; SpawnMob(2, 2, 752U, dest); } else { if (npc.HealthPct < 40) { return; } SpawnMob(-2, -2, 751U, npc); SpawnMob(0, -2, 747U, dest); } }
private void BlackEagleSummon(NPC npc, IWorldLocation dest) { if (npc.HealthPct < 40 && !npc.HelperBossSummoned) { npc.HelperBossSummoned = true; SpawnMob(2, 2, 512, dest); } else if (npc.HealthPct >= 40) { SpawnMob(-2, -2, 392, npc); SpawnMob(-3, -2, 392, npc); SpawnMob(0, -2, 392, npc); SpawnMob(-1, -2, 392, npc); SpawnMob(0, -2, 377, dest); SpawnMob(1, -2, 377, dest); } }
/// <summary> /// Returns the Unit that is closest within the given Radius around this Object /// TODO: Should add visibility test? /// </summary> public static Unit GetNearestUnit(this IWorldLocation wObj, float radius) { Unit unit = null; var sqDist = float.MaxValue; wObj.IterateEnvironment <Unit>(radius, obj => { var curSqDist = obj.GetDistanceSq(wObj); if (curSqDist < sqDist) { sqDist = curSqDist; unit = obj; } return(true); } ); return(unit); }
/// <summary> /// Returns the Unit that is closest within the given Radius around this Object /// TODO: Should add visibility test? /// </summary> public static Unit GetNearestUnit(this IWorldLocation wObj, float radius) { Unit unit = (Unit)null; float sqDist = float.MaxValue; wObj.IterateEnvironment <Unit>(radius, (Func <Unit, bool>)(obj => { float distanceSq = obj.GetDistanceSq((IHasPosition)wObj); if ((double)distanceSq < (double)sqDist) { sqDist = distanceSq; unit = obj; } return(true); })); return(unit); }
private void KaiyaSummon(NPC npc, IWorldLocation dest) { if (npc.HealthPct < 40 && !npc.HelperBossSummoned) { npc.HelperBossSummoned = true; SpawnMob(2, 2, 511U, dest); } else { if (npc.HealthPct < 40) { return; } SpawnMob(-2, -2, 324U, dest); SpawnMob(-1, -2, 325U, dest); SpawnMob(0, -2, 326U, dest); SpawnMob(1, -2, 327U, dest); } }
/// <summary> /// Returns the Unit that is closest within the given Radius around this Object and passes the filter /// </summary> public static Unit GetNearestUnit(this IWorldLocation wObj, float radius, Func <Unit, bool> filter) { Unit target = (Unit)null; float sqDist = float.MaxValue; wObj.IterateEnvironment <Unit>(radius, (Func <Unit, bool>)(unit => { if (filter(unit)) { float distanceSq = unit.GetDistanceSq((IHasPosition)wObj); if ((double)distanceSq < (double)sqDist) { sqDist = distanceSq; target = unit; } } return(true); })); return(target); }
/// <summary> /// Returns the Unit that is closest within the given Radius around this Object and passes the filter /// </summary> public static Unit GetNearestUnit(this IWorldLocation wObj, float radius, Func <Unit, bool> filter) { Unit target = null; var sqDist = float.MaxValue; wObj.IterateEnvironment <Unit>(radius, unit => { if (filter(unit)) { var curSqDist = unit.GetDistanceSq(wObj); if (curSqDist < sqDist) { sqDist = curSqDist; target = unit; } } return(true); } ); return(target); }
private void BlackEagleSummon(NPC npc, IWorldLocation dest) { if (npc.HealthPct < 40 && !npc.HelperBossSummoned) { npc.HelperBossSummoned = true; this.SpawnMob(2, 2, 512U, dest); } else { if (npc.HealthPct < 40) { return; } this.SpawnMob(-2, -2, 392U, (IWorldLocation)npc); this.SpawnMob(-3, -2, 392U, (IWorldLocation)npc); this.SpawnMob(0, -2, 392U, (IWorldLocation)npc); this.SpawnMob(-1, -2, 392U, (IWorldLocation)npc); this.SpawnMob(0, -2, 377U, dest); this.SpawnMob(1, -2, 377U, dest); } }
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 GameObject Spawn(IWorldLocation location, Unit owner) { var go = Create(owner); go.Position = location.Position; location.Region.AddObject(go); return go; }
/// <summary> /// Teleports the owner to the given WorldObject. /// </summary> /// <param name="location"></param> /// <returns></returns> public bool TeleportTo(IWorldLocation location) { var pos = location.Position; var rgn = location.Region; if (rgn == null) { if (Region.Id != location.RegionId) { return false; } rgn = Region; } TeleportTo(rgn, ref pos, m_orientation); if (location is WorldObject) { Zone = ((WorldObject)location).Zone; } return true; }
/// <summary> /// Returns the GOTemplate of this entry that is closest to the given location /// </summary> public GOTemplate GetClosestTemplate(IWorldLocation pos) { return Templates.GetClosestTemplate(pos); }
/// <summary> /// Spawns and returns a new GameObject from this template into the given region /// </summary> /// <returns>The newly spawned GameObject or null, if the Template has no Entry associated with it.</returns> public GameObject Spawn(IWorldLocation pos) { var go = GameObject.Create(Entry, this); go.Position = pos.Position; pos.Region.AddObject(go); return go; }
public NPC Create(IWorldLocation loc) { var npc = NPCCreator(this); npc.SetupNPC(this, null); loc.Region.AddObject(npc, loc.Position); return npc; }
/// <summary> /// Teleports the owner to the given WorldObject. /// </summary> /// <param name="location"></param> /// <returns></returns> public bool TeleportTo(IWorldLocation location) { var pos = location.Position; var map = location.Map; if (map == null) { if (Map.Id != location.MapId) { return false; } map = Map; } TeleportTo(map, ref pos, m_orientation); Phase = location.Phase; if (location is WorldObject) { Zone = ((WorldObject)location).Zone; } return true; }
public static GOSpawnEntry GetClosestEntry(this ICollection<GOSpawnEntry> entries, IWorldLocation pos) { if (pos == null) { return entries.First(); } var closestDistSq = float.MaxValue; GOSpawnEntry closest = null; foreach (var entry in entries) { if (entry.MapId != pos.MapId || entry.Phase != pos.Phase) { continue; } var distSq = pos.Position.DistanceSquared(entry.Position); if (distSq < closestDistSq) { closestDistSq = distSq; closest = entry; } } return closest; }
public static void CreateTeleportNPC(NPCId id, IWorldLocation loc) { CreateTeleportNPC(id, loc.Position, loc.MapId, loc.Phase); }
void CreatePortal(WorldObject at, IWorldLocation target) { // create portal var portal = Portal.Create(target); at.PlaceInFront(portal); }
public GameObject Spawn(IWorldLocation where, Unit owner) { var go = GameObject.Create(this, where, FirstSpawnEntry); go.Owner = owner; return go; }
/// <summary> /// Creates a new GameObject with the given parameters /// </summary> public static GameObject Create(GOEntry entry, IWorldLocation where, GOSpawnEntry spawnEntry = null, GOSpawnPoint spawnPoint = null) { var go = entry.GOCreator(); var handlerCreator = entry.HandlerCreator; go.Init(entry, spawnEntry, spawnPoint); if (handlerCreator != null) { go.Handler = handlerCreator(); } else { log.Warn("GOEntry {0} did not have a HandlerCreator set - Type: {1}", entry, entry.Type); go.Delete(); return null; } go.Phase = where.Phase; var pos = where.Position; where.Map.AddObject(go, ref pos); return go; }
protected Portal(IWorldLocation target) { Target = target; }
public static void CreateTeleportNPC(NPCId id, IWorldLocation loc) { CreateTeleportNPC(id, loc.Position, loc.RegionId); }
public NPC SpawnAt(IWorldLocation loc, bool hugGround = false) { var npc = Create(loc.Map.DifficultyIndex); var pos = loc.Position; if (hugGround && InhabitType == InhabitType.Ground) { pos.Z = loc.Map.Terrain.GetGroundHeightUnderneath(pos); } loc.Map.AddObject(npc, loc.Position); npc.Phase = loc.Phase; return npc; }
public NPC SpawnAt(IWorldLocation loc) { var npc = Create(loc.Map.DifficultyIndex); loc.Map.AddObject(npc, loc.Position); npc.Phase = loc.Phase; return npc; }
public GameObject Spawn(IWorldLocation location) { return Spawn(location, location as Unit); }
/// <summary> /// Summons the dropped flag. /// </summary> /// <param name="location">The target location (can [and should] be a unit)</param> public void SummonDroppedFlag(IWorldLocation location) { _flag = DroppedFlagEntry.Spawn(location, null); // Flags never have an owner. }
/// <summary> /// Returns the GOTemplate of this entry that is closest to the given location /// </summary> public GOSpawnEntry GetClosestTemplate(IWorldLocation pos) { return SpawnEntries.GetClosestEntry(pos); }
public static GOSpawn GetClosestTemplate(this ICollection<GOSpawn> templates, IWorldLocation pos) { var closestDistSq = float.MaxValue; GOSpawn closest = null; if (pos == null) { return templates.First(); } foreach (var template in templates) { if (template == null || template.RegionId != pos.RegionId) { continue; } var distSq = pos.Position.DistanceSquared(template.Pos); if (distSq < closestDistSq) { closestDistSq = distSq; closest = template; } } return closest; }
public static GOSpawnEntry GetClosestEntry(this ICollection<GOSpawnPoolTemplate> templates, IWorldLocation pos) { if (pos == null) { return templates.First().Entries.FirstOrDefault(); } var closestDistSq = float.MaxValue; GOSpawnEntry closest = null; foreach (var template in templates) { if (template == null || template.MapId != pos.MapId) { continue; } foreach (var entry in template.Entries) { if (entry.Phase != pos.Phase) continue; var distSq = pos.Position.DistanceSquared(entry.Position); if (distSq < closestDistSq) { closestDistSq = distSq; closest = entry; } } } return closest; }
public NPC SpawnAt(IWorldLocation loc) { var npc = Create(loc.Region.DifficultyIndex); npc.SetupNPC(this, null); loc.Region.AddObject(npc, loc.Position); return npc; }