コード例 #1
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);
        }
コード例 #2
0
        /// <summary>
        /// Sets up the Battlefront status list with default values.
        /// </summary>
        /// <param name="battleFrontProgressions"></param>
        private void BuildApocBattleFrontStatusList(List <RVRProgression> battleFrontProgressions)
        {
            lock (LockObject)
            {
                BattleFrontStatuses.Clear();
                foreach (var battleFrontProgression in battleFrontProgressions)
                {
                    // Keeps for this region.
                    var keeps = BattleFrontService.GetZoneKeeps(battleFrontProgression.RegionId, battleFrontProgression.ZoneId);
                    // BattleFront Objectives for this region.
                    var battlefieldObjectives = BattleFrontService.GetZoneBattlefrontObjectives(battleFrontProgression.RegionId, battleFrontProgression.ZoneId);

                    BattleFrontStatuses.Add(new BattleFrontStatus(ImpactMatrixManagerInstance, battleFrontProgression.BattleFrontId)
                    {
                        LockingRealm          = (Realms)BattleFrontProgressions.Single(x => x.BattleFrontId == battleFrontProgression.BattleFrontId).LastOwningRealm,
                        FinalVictoryPoint     = new VictoryPointProgress(battleFrontProgression.OrderVP, battleFrontProgression.DestroVP),
                        OpenTimeStamp         = 0,
                        LockTimeStamp         = 0,
                        Locked                = true,
                        RegionId              = battleFrontProgression.RegionId,
                        Description           = battleFrontProgression.Description,
                        ZoneId                = battleFrontProgression.ZoneId,
                        KeepList              = keeps,
                        BattlefieldObjectives = battlefieldObjectives
                    });
                }
            }
        }
コード例 #3
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");
        }
コード例 #4
0
        /// <summary>
        /// Reload creatures in your region
        /// </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 ReloadCreatures(Player plr, ref List <string> values)
        {
            CreatureService.LoadCreatureItems();
            plr.SendClientMessage("RELOADCREATURES: NPC Items Loaded : " + CreatureService._CreatureItems.Count);

            CreatureService.LoadCreatureProto();
            plr.SendClientMessage("RELOADCREATURES: NPCs Loaded : " + CreatureService.CreatureProtos.Count);

            CreatureService.LoadCreatureStats();
            plr.SendClientMessage("RELOADCREATURES: Stats Loaded : " + CreatureService._CreatureStats.Count);

            BattleFrontService.LoadKeepCreatures();
            plr.SendClientMessage("RELOADCREATURES: Keep Creatures Loaded : " + BattleFrontService._KeepCreatures.Count);

            CreatureService.LoadBossSpawns();
            plr.SendClientMessage("RELOADCREATURES: Bosses Loaded : " + CreatureService.BossSpawns.Count);

            List <Object> allCells = new List <Object>();

            allCells.AddRange(plr._Cell.Objects);
            foreach (Object obj in allCells)
            {
                if (obj.IsCreature())
                {
                    Creature crea = obj.GetCreature();
                    try
                    {
                        var proto = CreatureService.CreatureProtos[crea.Entry];
                        crea.Spawn.Proto = proto;
                    }
                    catch
                    {
                        plr.SendClientMessage("RELOADCREATURES: NPC with Entry " + crea.Entry + " not found in CreatureProtos, removing NPC");
                        crea.Spawn.Proto = null;
                    }
                    crea.Region.CreateCreature(crea.Spawn);
                    crea.Dispose();
                }
            }
            plr.SendClientMessage("RELOADCREATURES: NPC spawn's Loaded : " + CreatureService.CreatureSpawns.Count);
            return(true);
        }
コード例 #5
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}");
        }