/// <summary>
        /// Periodically checks player positions around flags to debuff
        /// them when they approach warcamp entrances.
        /// </summary>
        private void CheckSpawnFarm()
        {
            foreach (Player player in _syncPlayersList)
            {
                BattlefrontFlag flag = (BattlefrontFlag)GetClosestFlag(player.WorldPosition, true);

                if (flag != null && flag.FlagState != ObjectiveFlags.ZoneLocked)
                {
                    flag.AddPlayerInQuadrant(player);
                }

                // Check warcamp farm
                if (player.Zone != null)
                {
                    Realms  opposite   = player.Realm == Realms.REALMS_REALM_DESTRUCTION ? Realms.REALMS_REALM_ORDER : Realms.REALMS_REALM_DESTRUCTION;
                    Point3D warcampLoc = BattlefrontService.GetWarcampEntrance(player.Zone.ZoneId, opposite);

                    if (warcampLoc != null)
                    {
                        float range = (float)player.GetDistanceTo(warcampLoc);
                        if (range < WARCAMP_FARM_RANGE)
                        {
                            player.WarcampFarmScaler = range / WARCAMP_FARM_RANGE;
                        }
                        else
                        {
                            player.WarcampFarmScaler = 1f;
                        }
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// Computes distance of player to warcamp of given realm.
        /// </summary>
        /// <param name="plr">Player to compute distance from</param>
        /// <param name="realm">Realm of the warcamp to compute distance to</param>
        /// <returns>Distance or int.MaxValue if not found in current zone</returns>
        private static int GetWarcampDistance(Player plr, Realms realm)
        {
            ushort  zoneId     = plr.ZoneId.Value;
            Point3D warcampLoc = BattlefrontService.GetWarcampEntrance(zoneId, realm);

            return(warcampLoc != null?plr.GetDistanceTo(warcampLoc) : int.MaxValue);
        }
        /// <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>
        /// Loads keeps, keep units and doors.
        /// </summary>
        private void LoadKeeps()
        {
            List <Keep_Info> keeps = BattlefrontService.GetKeepInfos(Region.RegionId);

            if (keeps == null)
            {
                return; // t1 or database lack
            }
            foreach (Keep_Info info in keeps)
            {
                Keep keep = new Keep(info, Tier, Region);
                keep.Realm = (Realms)keep.Info.Realm;
                _Keeps.Add(keep);
                Region.AddObject(keep, info.ZoneId);

                if (info.Creatures != null)
                {
                    foreach (Keep_Creature crea in info.Creatures)
                    {
                        keep.Creatures.Add(new KeepNpcCreature(Region, crea, keep));
                    }
                }

                if (info.Doors != null)
                {
                    foreach (Keep_Door door in info.Doors)
                    {
                        keep.Doors.Add(new KeepDoor(Region, door, keep));
                    }
                }
            }
        }
示例#5
0
        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>
        /// 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);
            }
        }
        /// <summary>
        /// Loads battlefront objectives.
        /// </summary>

        private void LoadObjectives()
        {
            List <Battlefront_Objective> objectives = BattlefrontService.GetBattlefrontObjectives(Region.RegionId);

            if (objectives == null)
            {
                return; // t1 or database lack
            }
            float orderDistanceSum  = 0f;
            float destroDistanceSum = 0f;

            foreach (Battlefront_Objective obj in objectives)
            {
                NewDawnBattlefieldObjective flag = new NewDawnBattlefieldObjective(obj, Region.GetTier());
                Objectives.Add(flag);
                Region.AddObject(flag, obj.ZoneId);
                flag.Battlefront = this;

                //orderDistanceSum += flag.GetWarcampDistance(Realms.REALMS_REALM_ORDER);
                //destroDistanceSum += flag.GetWarcampDistance(Realms.REALMS_REALM_DESTRUCTION);
            }
        }
        /// <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);
        }
示例#9
0
        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);
        }
示例#10
0
        public ProximityProgressingBattlefront(RegionMgr region, bool oRvRFront) : base(region, oRvRFront)
        {
            _battlefrontStatus = BattlefrontService.GetStatusFor(region.RegionId);

            // RB   4/24/2016   A lot of non-RvR zones are included in the T4 regions, so those need to be discarded. And we need to do this manually.

            switch (Region.RegionId)
            {
            case 2:     // T4 Dwarf vs Greenskin
                Zones = new List <Zone_Info>
                {
                    Region.ZonesInfo.Find(z => z.ZoneId == 3),
                    Region.ZonesInfo.Find(z => z.ZoneId == 5),
                    Region.ZonesInfo.Find(z => z.ZoneId == 9)
                };
                break;

            case 11:     // T4 Empire vs Chaos
                Zones = new List <Zone_Info>
                {
                    Region.ZonesInfo.Find(z => z.ZoneId == 103),
                    Region.ZonesInfo.Find(z => z.ZoneId == 105),
                    Region.ZonesInfo.Find(z => z.ZoneId == 109)
                };
                break;

            case 4:     // T4 High Elf vs Dark Elf
                Zones = new List <Zone_Info>
                {
                    Region.ZonesInfo.Find(z => z.ZoneId == 203),
                    Region.ZonesInfo.Find(z => z.ZoneId == 205),
                    Region.ZonesInfo.Find(z => z.ZoneId == 209)
                };
                break;

            // Here we start to implement the DoomsDay Event pairings - that is, T2 T3 T4 merge - not used :(
            case 6:     // T3 Empire vs Chaos
                Zones = new List <Zone_Info>
                {
                    Region.ZonesInfo.Find(z => z.ZoneId == 102),     // High Pass
                    Region.ZonesInfo.Find(z => z.ZoneId == 108)      // Talabecland
                };
                break;

            case 10:     // T3 Dwarf vs Greenskin
                Zones = new List <Zone_Info>
                {
                    Region.ZonesInfo.Find(z => z.ZoneId == 2),     // The Badlands
                    Region.ZonesInfo.Find(z => z.ZoneId == 8)      // Black Fire Pass
                };
                break;

            case 12:     // T2 Dwarf vs Greenskin
                Zones = new List <Zone_Info>
                {
                    Region.ZonesInfo.Find(z => z.ZoneId == 1),     // Marshes of Madness
                    Region.ZonesInfo.Find(z => z.ZoneId == 7)      // Barak V
                };
                break;

            case 14:     // T2 Empire vs Chaos
                Zones = new List <Zone_Info>
                {
                    Region.ZonesInfo.Find(z => z.ZoneId == 101),     // Troll Country
                    Region.ZonesInfo.Find(z => z.ZoneId == 107)      // Ostland
                };
                break;

            case 15:     // T2 High Elf vs Dark Elf
                Zones = new List <Zone_Info>
                {
                    Region.ZonesInfo.Find(z => z.ZoneId == 201),     // The Shadowlands
                    Region.ZonesInfo.Find(z => z.ZoneId == 207)      // Ellyrion
                };
                break;

            case 16:     // T3 High Elf vs Dark Elf
                Zones = new List <Zone_Info>
                {
                    Region.ZonesInfo.Find(z => z.ZoneId == 202),     // Avelorn
                    Region.ZonesInfo.Find(z => z.ZoneId == 208)      // Saphery
                };
                break;
            }

            // RB   4/29/2016   If this is a T4 Campaign region and we are building this Battlefront for the first time, load it after setting BOs.
            LoadPairing();
        }
示例#11
0
        public static void CreateNew(Player plr, int entry)
        {
            Point3D destPos;
            ushort  destHeading;

            RvRStructure curStruct = plr.CbtInterface.GetCurrentTarget() as RvRStructure;

            RvRObjectInfo info = BattlefrontService.GetRvRObjectInfo(entry);

            _logger.Debug($"RVRStructure BattlefrontService.GetRvRObjectInfo Entry={entry} info={info.Name} {info.ModelId} {info.ObjectId}");

            if (curStruct != null)
            {
                ushort shiftHeading = (ushort)((curStruct.Heading + 1024) & 0xFFF);
                destPos     = new Point3D(curStruct.WorldPosition);
                destHeading = curStruct.Heading;

                Point2D offsetPoint = GetOffsetFromHeading(shiftHeading, (ushort)(info.ExclusionRadius + curStruct._info.ExclusionRadius + 1));

                Vector2 offsetVector = new Vector2(offsetPoint.X, offsetPoint.Y);
                offsetVector.Normalize();

                Vector2 toPlayer = new Vector2(plr.WorldPosition.X - curStruct.WorldPosition.X, plr.WorldPosition.Y - curStruct.WorldPosition.Y);
                toPlayer.Normalize();

                float dotP = Vector2.DotProduct2D(offsetVector, toPlayer);

                if (dotP >= 0)
                {
                    destPos.X += offsetPoint.X;
                    destPos.Y += offsetPoint.Y;
                }

                else
                {
                    destPos.X -= offsetPoint.X;
                    destPos.Y -= offsetPoint.Y;
                }
            }

            else
            {
                Point2D offset = GetOffsetFromHeading(plr.Heading, 10);
                destHeading = plr.Heading;
                destPos     = new Point3D(plr.WorldPosition.X + offset.X, plr.WorldPosition.Y + offset.Y, plr.WorldPosition.Z);
            }

            foreach (Object obj in plr.ObjectsInRange)
            {
                RvRStructure structure = obj as RvRStructure;

                if (structure == null)
                {
                    continue;
                }

                if (structure.WorldPosition.GetDistanceTo(destPos) < info.ExclusionRadius + structure._info.ExclusionRadius)
                {
                    plr.SendClientMessage("Too close to existing structure", ChatLogFilters.CHATLOGFILTERS_C_ABILITY_ERROR);
                    plr.SendClientMessage("Too close to an existing structure (one exists within " + structure.WorldPosition.GetDistanceTo(destPos) + "ft and " + (info.ExclusionRadius + structure._info.ExclusionRadius) + "ft clearance is required)", ChatLogFilters.CHATLOGFILTERS_USER_ERROR);
                    return;
                }
            }

            RvRStructure newStruct = new RvRStructure(info, destPos, destHeading, plr);

            plr.Region.AddObject(newStruct, plr.Zone.ZoneId, true);

            _logger.Debug($"RVRStructure CreateNew Entry={entry} {curStruct.Name} {curStruct.Oid} Zone={plr.Zone.ZoneId}");
        }