public PortalToObjective(PortalToObjective other) : base(other.Spawn) { Name = other.Name; _target = other._target; _targetPos = other._targetPos; }
/// <summary> /// Searches for the portal from warcamp to the managed objective. /// </summary> /// <param name="realm">Realm of warcamp to seach</param> /// <returns>Portal of null if missing info</returns> private BattlefrontObject GetPortalToObjective(Realms realm) { ushort zoneId = _objective.ZoneId; int objectiveId = _objective.ID; BattlefrontObject portalData = BattlefrontService.GetPortalToObjective(zoneId, objectiveId, realm); if (portalData != null) // A portal exists in same zone { return(portalData); } // Obtherwise, search in other zones of same region foreach (Zone_Info zone in _region.ZonesInfo) { if (zone.ZoneId == zoneId) { continue; } portalData = BattlefrontService.GetPortalToObjective(zone.ZoneId, objectiveId, realm); if (portalData != null) { return(portalData); } } return(null); }
/// <summary> /// Creates a game object spawn entity from given battlefront portal object. /// </summary> /// <param name="battlefrontObject">Portal object providing raw data</param> /// <returns>newly created spawn entity</returns> private GameObject_spawn CreateSpawn(BattlefrontObject battlefrontObject) { GameObject_proto proto = GameObjectService.GetGameObjectProto(PORTAL_PROTO_ENTRY); proto = (GameObject_proto)proto.Clone(); GameObject_spawn spawn = new GameObject_spawn(); spawn.BuildFromProto(proto); // boule blanche : 3457 // grosse boule blanche : 1675 proto.Scale = 25; // spawn.DisplayID = 1675; spawn.DisplayID = 1675; spawn.ZoneId = battlefrontObject.ZoneId; Point3D worldPos = GetWorldPosition(battlefrontObject); spawn.WorldX = worldPos.X; spawn.WorldY = worldPos.Y; spawn.WorldZ = worldPos.Z; spawn.WorldO = battlefrontObject.O; return(spawn); }
public PortalToObjective(BattlefrontObject origin, BattlefrontObject target, string name) : base(origin) { Name = NAME_START + name; Spawn.Proto.Name = Name; // For debug purpose only _target = target; _targetPos = GetWorldPosition(target); }
public PortalToWarcamp( BattlefrontObject origin, BattlefrontObject orderTarget, BattlefrontObject destroTarget) : base(origin) { Name = NAME; Spawn.Proto.Name = NAME; // For debug purpose only _orderTarget = orderTarget; _destroTarget = destroTarget; _orderTargetPos = GetWorldPosition(orderTarget); _destroTargetPos = GetWorldPosition(destroTarget); }
public static void Warcamp(Player plr, string realm = "") { ushort zoneId = plr.Zone.ZoneId; if (realm == "") { // Display current entrances locations plr.SendClientMessage("Order spawn (1) : " + BattlefrontService.GetWarcampEntrance(zoneId, Realms.REALMS_REALM_ORDER)); plr.SendClientMessage("Destruction spawn (2) : " + BattlefrontService.GetWarcampEntrance(zoneId, Realms.REALMS_REALM_DESTRUCTION)); return; } Realms newRealm = Realms.REALMS_REALM_NEUTRAL; if (realm == "order" || realm == "1") { newRealm = Realms.REALMS_REALM_ORDER; } else if (realm == "destruction" || realm == "2") { newRealm = Realms.REALMS_REALM_DESTRUCTION; } else { SendCsr(plr, "CAMPAIGN WARCAMP: illegal realm argument, must be order|destruction or 1|2."); return; } BattlefrontObject oldObject = WorldMgr.Database.SelectObject <BattlefrontObject>($"ZoneId = {zoneId} AND Realm = {(int)newRealm}"); if (oldObject != null) { WorldMgr.Database.DeleteObject(oldObject); oldObject.Dirty = true; WorldMgr.Database.ForceSave(); } BattlefrontObject newObject = new BattlefrontObject { Type = (ushort)BattlefrontObjectType.WARCAMP_ENTRANCE, ObjectiveID = 0, Realm = (ushort)newRealm, }; AddObject(plr, newObject); BattlefrontService.LoadBattlefrontObjects(); SendCsr(plr, $"CAMPAIGN WARCAMP: {(newRealm == Realms.REALMS_REALM_ORDER ? "order" : "destruction")} warcamp is set"); }
/// <summary> /// Adds the given object at player location. /// </summary> /// <param name="plr">Player providing the location or created object.</param> /// <param name="newObject">Object to add with battlefront specific properties configured</param> private static void AddObject(Player plr, BattlefrontObject newObject) { int max = (int)WorldMgr.Database.GetMaxColValue <BattlefrontObject>("Entry"); newObject.Entry = max + 1; newObject.RegionId = plr.Region.RegionId; newObject.ZoneId = plr.ZoneId.Value; newObject.X = plr.X; newObject.Y = plr.Y; newObject.Z = plr.Z; newObject.O = plr.Heading; newObject.Dirty = true; newObject.IsValid = true; WorldMgr.Database.AddObject(newObject); WorldMgr.Database.ForceSave(); }
/// <summary> /// Spawns or despawns given portal. /// </summary> /// <param name="portal">Portal to spawn or despawn</param> /// <param name="portalData">Data bound to the portal</param> /// <param name="spawn">True to spawn the portal, false to despawn it</param> private void UpdatePortalSpawn(PortalToObjective portal, BattlefrontObject portalData, bool spawn) { if (portal.IsInWorld() != spawn) { if (spawn) { PortalToObjective clone = new PortalToObjective(portal); if (portalData.Realm == (ushort)Realms.REALMS_REALM_ORDER) { _orderPortal = clone; } else { _destroPortal = clone; } _region.AddObject(clone, portalData.ZoneId); } else { _region.RemoveObject(portal); } } }
/// <summary>(Re)loads portals data.</summary> internal bool Load() { ushort _zoneId = _objective.ZoneId; int objectiveId = _objective.ID; _objectivePortalData = BattlefrontService.GetPortalToWarcamp(_zoneId, objectiveId); _orderPortalData = GetPortalToObjective(Realms.REALMS_REALM_ORDER); _destroPortalData = GetPortalToObjective(Realms.REALMS_REALM_DESTRUCTION); if (_objectivePortalData != null && _orderPortalData != null && _destroPortalData != null) { return(true); } #if DEBUG if (_region.GetTier() < 5) { List <string> missingInfo = new List <string>(); if (_objectivePortalData == null) { missingInfo.Add("objective portal"); } if (_orderPortalData == null) { missingInfo.Add("order portal"); } if (_destroPortalData == null) { missingInfo.Add("destro portal"); } Log.Error("ObjectivePortalsMgr", $"Missing portal data for objective {_objective.Name} ({_objective.ID}) : " + string.Join(", ", missingInfo)); BattlefrontService.LoadBattlefrontObjects(); } #endif return(false); }
public static void Portal(Player plr, string objectiveName = null) { // Current player battlefront IBattlefront battlefront; if (plr.Region.GetTier() == 1) { battlefront = plr.Region.Bttlfront as RoRBattlefront; } else if (plr.Region.GetTier() > 1) { battlefront = plr.Region.Bttlfront as ProximityBattlefront; } else { return; } if (battlefront == null) { SendCsr(plr, "CAMPAIGN PORTAL: Must be in a battlefront."); return; } // Current flag ProximityFlag flag; string notFoundMessage; string successMessage; BattlefrontObjectType type; if (objectiveName == null) { flag = battlefront.GetClosestFlag(plr.WorldPosition) as ProximityFlag; type = BattlefrontObjectType.WARCAMP_PORTAL; notFoundMessage = "CAMPAIGN PORTAL: Must be near a proximity flag in rvr lake if no name is given."; successMessage = $"CAMPAIGN PORTAL: Portal from {(flag != null ? flag.Name : "")} to warcamp has been set."; } else { flag = GetFlag(battlefront, objectiveName); notFoundMessage = "CAMPAIGN PORTAL: Could not find objective of name : " + objectiveName; type = BattlefrontObjectType.OBJECTIVE_PORTAL; successMessage = $"CAMPAIGN PORTAL: Portal from warcamp to {(flag != null ? flag.Name : "")} has been set for "; } if (flag == null) { SendCsr(plr, notFoundMessage); return; } // Database update BattlefrontService.LoadBattlefrontObjects(); BattlefrontObject newObject = new BattlefrontObject() { Type = (byte)type, ObjectiveID = flag.ID, }; BattlefrontObject oldObject; if (type == BattlefrontObjectType.OBJECTIVE_PORTAL) { // Compute realm, depending on its location - quite a hack but will avoid parameter errors Realms realm; int orderDistance = GetWarcampDistance(plr, Realms.REALMS_REALM_ORDER); int destroDistance = GetWarcampDistance(plr, Realms.REALMS_REALM_DESTRUCTION); if (orderDistance < destroDistance) // In order warcamp { realm = Realms.REALMS_REALM_ORDER; successMessage += "Order."; } else // In destro warcamp { realm = Realms.REALMS_REALM_DESTRUCTION; successMessage += "Destruction."; } newObject.Realm = (ushort)realm; oldObject = BattlefrontService.GetPortalToObjective(plr.ZoneId.Value, flag.ID, realm); } else { oldObject = BattlefrontService.GetPortalToWarcamp(plr.ZoneId.Value, flag.ID); } if (oldObject != null) { WorldMgr.Database.DeleteObject(oldObject); oldObject.Dirty = true; WorldMgr.Database.ForceSave(); } AddObject(plr, newObject); SendCsr(plr, successMessage); }
protected void Teleport(Player player, BattlefrontObject target, Point3D targetPos) { Point2D randomPoint = targetPos.GetPointFromHeading((ushort)random.Next(0, 4096), 5); player.Teleport(target.ZoneId, (uint)randomPoint.X, (uint)randomPoint.Y, (ushort)targetPos.Z, (ushort)target.O); }
protected Point3D GetWorldPosition(BattlefrontObject bObject) { Zone_Info zone = ZoneService.GetZone_Info(bObject.ZoneId); return(ZoneService.GetWorldPosition(zone, (ushort)bObject.X, (ushort)bObject.Y, (ushort)bObject.Z)); }
internal PortalBase(BattlefrontObject origin) { Spawn = CreateSpawn(origin); }