/// <summary> /// Invoked when the objective is locked, spawning the portal to warcamp. /// </summary> internal void ObjectiveLocked() { if (_objectivePortal != null) { return; } if (!Load()) // Useful when database has been updated at runtime { return; } if (_objectivePortal == null && _region.GetTier() < 2) { _objectivePortal = new PortalToWarcamp(_objectivePortalData, _orderPortalData, _destroPortalData); _region.AddObject(_objectivePortal, _objectivePortalData.ZoneId); } if (_orderPortal != null) { _orderPortal.Dispose(); _destroPortal.Dispose(); _orderPortal = null; _destroPortal = null; } }
public void Spawn(bool attackable) { GameObject?.Destroy(); GameObject_proto proto = GameObjectService.GetGameObjectProto(Info.GameObjectId); if (proto == null) { Log.Error("KeepDoor", "No Door Proto"); return; } _logger.Debug($"Spawning Keep Door = {Info.DoorId} Number = {Info.Number} for Keep = {Keep.Info.Name}"); GameObject_spawn spawn = new GameObject_spawn { Guid = (uint)GameObjectService.GenerateGameObjectSpawnGUID(), WorldO = Info.O, WorldY = Info.Y, WorldZ = Info.Z, WorldX = Info.X, ZoneId = Info.ZoneId, DoorId = Info.DoorId, }; spawn.BuildFromProto(proto); GameObject = new KeepGameObject(spawn, this, Keep); Region.AddObject(GameObject, spawn.ZoneId); GameObject.SetAttackable(attackable); Occlusion.SetFixtureVisible(Info.DoorId, true); }
public void SpawnGuard(int team) { if (Creature != null) { Creature.Destroy(); } this.team = team; Creature_proto Proto = CreatureService.GetCreatureProto(team == 1 ? OrderId : DestroId); if (Proto == null) { Log.Error("FlagGuard", "No FlagGuard Proto"); return; } Creature_spawn Spawn = new Creature_spawn(); Spawn.BuildFromProto(Proto); Spawn.WorldO = o; Spawn.WorldY = y; Spawn.WorldZ = z; Spawn.WorldX = x; Spawn.ZoneId = ZoneId; Spawn.RespawnMinutes = 3; Creature = new GuardCreature(Spawn, this); Region.AddObject(Creature, Spawn.ZoneId); }
/// <summary> /// Changes the current faction of selected Unit (byte Faction) /// </summary> /// <param name="plr">Player that initiated the command</param> /// <param name="values">List of command arguments (after command name)</param> /// <returns>True if command was correctly handled, false if operation was canceled</returns> public static bool ModifyFaction(Player plr, ref List <string> values) { byte faction = (byte)GetInt(ref values); byte save = (byte)(values.Count > 0 ? GetInt(ref values) : 0); Object obj = GetObjectTarget(plr); RegionMgr region = obj.Region; ushort zoneId = obj.Zone.ZoneId; obj.RemoveFromWorld(); obj.GetUnit().SetFaction(faction); region.AddObject(obj.GetUnit(), zoneId, true); if (save > 0) { if (obj.IsCreature()) { Creature crea = obj.GetCreature(); crea.Spawn.Faction = faction; WorldMgr.Database.SaveObject(crea.Spawn); } } return(true); }
public void Spawn() { GameObject?.Destroy(); GameObject_proto proto = GameObjectService.GetGameObjectProto(Info.GameObjectId); if (proto == null) { Log.Error("KeepDoor", "No Door Proto"); return; } // Log.Info("KeepDoor", "Spawning Keep Door = " + Info.DoorId + " Number = " + Info.Number); GameObject_spawn spawn = new GameObject_spawn { Guid = (uint)GameObjectService.GenerateGameObjectSpawnGUID(), WorldO = Info.O, WorldY = Info.Y, WorldZ = Info.Z, WorldX = Info.X, ZoneId = Info.ZoneId, DoorId = Info.DoorId, }; spawn.BuildFromProto(proto); GameObject = new KeepGameObject(spawn, this, Keep); Region.AddObject(GameObject, spawn.ZoneId); GameObject.SetAttackable(Keep.KeepStatus != KeepStatus.KEEPSTATUS_LOCKED); WarZoneLib.RegionData.HideDoor(false, Info.ZoneId, Info.DoorId); }
private void LoadObjects() { foreach (var obj in Info.Objects) { InstanceObject o = null; if (obj.DoorID != 0) { o = new InstanceDoor(this, obj); } else { o = new InstanceObject(this, obj); } Region.AddObject(o, Info.ZoneID, true); o.SetZone(Region.GetZoneMgr(Info.ZoneID)); Region.CheckZone(o); _Objects.Add(o); } }
/// <summary> /// Loads battlefront objectives. /// </summary> private void LoadObjectives() { List <Battlefront_Objective> objectives = BattlefrontService.GetBattlefrontObjectives(Region.RegionId); _logger.Warn($"Calling LoadObjectives from RoRBattleFront"); if (objectives == null) { return; // t1 or database lack } float orderDistanceSum = 0f; float destroDistanceSum = 0f; foreach (Battlefront_Objective obj in objectives) { ProximityFlag flag = new ProximityFlag(obj, this, Region, Tier); _Objectives.Add(flag); Region.AddObject(flag, obj.ZoneId); orderDistanceSum += flag.GetWarcampDistance(Realms.REALMS_REALM_ORDER); destroDistanceSum += flag.GetWarcampDistance(Realms.REALMS_REALM_DESTRUCTION); _logger.Debug($"...Obj Entry:{obj.Entry} Name:{obj.Name} ZoneId:{obj.ZoneId} Region:{obj.RegionId}"); _logger.Debug($"...Flag State:{flag.FlagState} State:{flag.State}"); } // Sets the scaler to compute securization rewards #if DEBUG if (Tier != 1) { _logger.Error("Tier != 1, Distance scaler in t2, t3, t4 - should consider keeps"); //throw new NotImplementedException("Distance scaler in t2, t3, t4 - should consider keeps"); } #endif foreach (ProximityFlag flag in _Objectives) { flag.SetWarcampDistanceScaler(orderDistanceSum / objectives.Count, destroDistanceSum / objectives.Count); } }
public void SpawnGuard(Realms realm) { if (Creature != null) { Creature.Destroy(); Creature = null; } if (realm != Realms.REALMS_REALM_NEUTRAL) { if (Info.DestroId == 0 && realm == Realms.REALMS_REALM_DESTRUCTION) { _logger.Trace($"Creature Id = 0, no spawning"); } else { Creature_proto proto = CreatureService.GetCreatureProto(realm == Realms.REALMS_REALM_ORDER ? Info.OrderId : Info.DestroId); if (proto == null) { Log.Error("KeepNPC", "No FlagGuard Proto"); return; } _logger.Trace($"Spawning Guard {proto.Name} ({proto.Entry})"); Creature_spawn spawn = new Creature_spawn(); spawn.BuildFromProto(proto); spawn.WorldO = Info.O; spawn.WorldX = Info.X; spawn.WorldY = Info.Y; spawn.WorldZ = Info.Z; spawn.ZoneId = Info.ZoneId; Creature = new KeepCreature(spawn, this, Keep); Creature.WaypointGUID = Convert.ToUInt32(Info.WaypointGUID); if (Info.WaypointGUID > 0) { Creature.AiInterface.Waypoints = WaypointService.GetKeepNpcWaypoints(Info.WaypointGUID); } Region.AddObject(Creature, spawn.ZoneId); } } }
public Instance(ushort zoneid, ushort id, byte realm, Instance_Lockouts lockouts) { Lockout = lockouts; ID = id; ZoneID = zoneid; Realm = realm; Region = new RegionMgr(zoneid, ZoneService.GetZoneRegion(zoneid), "", new ApocCommunications()); InstanceService._InstanceInfo.TryGetValue(zoneid, out Info); LoadBossSpawns(); LoadSpawns(); // todo get the saved progress from group _running = true; _evtInterface = new EventInterface(); closetime = (TCPManager.GetTimeStamp() + 7200); // instancing stuff InstanceService.SaveLockoutInstanceID(ZoneID + ":" + ID, Lockout); new Thread(Update).Start(); Log.Success("Opening Instance", "Instance ID " + ID + " Map: " + Info.Name); // TOVL if (zoneid == 179) { foreach (var p in GameObjectService.GameObjectSpawns.Where(e => e.Value.ZoneId == 179)) { if (p.Value.Entry == 98908) { GameObject go = new GameObject(p.Value); _Objects.Add(go); Region.AddObject(go, zoneid, true); } } if (Info != null && Info.Objects.Count > 0) { LoadObjects(); } _evtInterface.AddEvent(UpdatePendulums, 7000, 0); } }
public static void Create(RegionMgr region, PQuest_Info info, ref Dictionary <uint, ContributionInfo> players, float bagCountMod) { if (region == null) { Log.Error("GoldChest", "Attempt to create for NULL region"); return; } if (info == null) { Log.Error("GoldChest", "NULL PQuest in Region " + region); return; } if (bagCountMod == 0.0f) { return; } GameObject_proto proto = GameObjectService.GetGameObjectProto(188); GameObject_spawn spawn = new GameObject_spawn { Guid = (uint)GameObjectService.GenerateGameObjectSpawnGUID(), WorldO = 0, WorldY = info.GoldChestWorldY, WorldZ = info.GoldChestWorldZ, WorldX = info.GoldChestWorldX, ZoneId = info.ZoneId }; spawn.BuildFromProto(proto); GoldChest chest = new GoldChest(spawn, info, ref players, bagCountMod, region); region.AddObject(chest, info.ZoneId); }
public static void F_INIT_PLAYER(BaseClient client, PacketIn packet) { GameClient cclient = (GameClient)client; Player Plr = cclient.Plr; if (Plr == null) { return; } // clear all lockouts if they are expired InstanceService.ClearLockouts(Plr); if (!Plr.IsInWorld()) // If the player is not on a map, then we add it to the map { ushort zoneId = Plr.Info.Value.ZoneId; ushort regionId = (ushort)Plr.Info.Value.RegionId; Zone_Info info = ZoneService.GetZone_Info(zoneId); if (info?.Type == 0) { RegionMgr region = WorldMgr.GetRegion(regionId, true); if (region.AddObject(Plr, zoneId, true)) { return; } } else if (info?.Type == 4 || info?.Type == 5 || info?.Type == 6) // login into a instance results in teleport outside { if (InstanceService._InstanceInfo.TryGetValue(zoneId, out Instance_Info II)) { Zone_jump ExitJump = null; if (Plr.Realm == Realms.REALMS_REALM_ORDER) { ExitJump = ZoneService.GetZoneJump(II.OrderExitZoneJumpID); } else if (Plr.Realm == Realms.REALMS_REALM_DESTRUCTION) { ExitJump = ZoneService.GetZoneJump(II.DestrExitZoneJumpID); } if (ExitJump == null) { Log.Error("Exit Jump in Instance", " " + zoneId + " missing!"); } else { Plr.Teleport(ExitJump.ZoneID, ExitJump.WorldX, ExitJump.WorldY, ExitJump.WorldZ, ExitJump.WorldO); } } return; } // Warp a player to their bind point if they attempt to load into a scenario map. RallyPoint rallyPoint = RallyPointService.GetRallyPoint(Plr.Info.Value.RallyPoint); if (rallyPoint != null) { Plr.Teleport(rallyPoint.ZoneID, rallyPoint.WorldX, rallyPoint.WorldY, rallyPoint.WorldZ, rallyPoint.WorldO); } else { CharacterInfo cInfo = CharMgr.GetCharacterInfo(Plr.Info.Career); Plr.Teleport(cInfo.ZoneId, (uint)cInfo.WorldX, (uint)cInfo.WorldY, (ushort)cInfo.WorldZ, (ushort)cInfo.WorldO); } } else { Plr.Loaded = false; Plr.StartInit(); } }