public void ProcessPlayerWatchList()
        {
            PlayerList.Clear();
            MyAPIGateway.Players.GetPlayers(PlayerList);

            foreach (var player in PlayerList)
            {
                if (player.IsBot == true || player.Character == null)
                {
                    continue;
                }

                if (playerWatchList.ContainsKey(player) == true)
                {
                    //Regular Timers

                    if (Settings.General.EnableSpaceCargoShips == true)
                    {
                        playerWatchList[player].SpaceCargoShipTimer -= Settings.General.PlayerWatcherTimerTrigger;
                    }

                    if (Settings.General.EnablePlanetaryCargoShips == true)
                    {
                        playerWatchList[player].AtmoCargoShipTimer -= Settings.General.PlayerWatcherTimerTrigger;
                    }

                    if (Settings.General.EnableRandomEncounters == true)
                    {
                        //CoolDown Timers
                        if (playerWatchList[player].RandomEncounterCoolDownTimer > 0)
                        {
                            playerWatchList[player].RandomEncounterCoolDownTimer -= Settings.General.PlayerWatcherTimerTrigger;
                        }
                        else
                        {
                            playerWatchList[player].RandomEncounterCheckTimer -= Settings.General.PlayerWatcherTimerTrigger;
                        }

                        if (playerWatchList[player].RandomEncounterDistanceCoordCheck == Vector3D.Zero)
                        {
                            playerWatchList[player].RandomEncounterDistanceCoordCheck = player.GetPosition();
                        }
                    }

                    if (Settings.General.EnablePlanetaryInstallations == true)
                    {
                        if (playerWatchList[player].PlanetaryInstallationCooldownTimer > 0)
                        {
                            playerWatchList[player].PlanetaryInstallationCooldownTimer -= Settings.General.PlayerWatcherTimerTrigger;
                        }
                        else
                        {
                            playerWatchList[player].PlanetaryInstallationCheckTimer -= Settings.General.PlayerWatcherTimerTrigger;
                        }
                    }

                    if (Settings.General.EnableBossEncounters == true)
                    {
                        if (BossEncounterSpawner.IsPlayerInBossEncounter(player.IdentityId) == false)
                        {
                            if (playerWatchList[player].BossEncounterCooldownTimer > 0)
                            {
                                playerWatchList[player].BossEncounterCooldownTimer -= Settings.General.PlayerWatcherTimerTrigger;
                            }
                            else
                            {
                                playerWatchList[player].BossEncounterCheckTimer -= Settings.General.PlayerWatcherTimerTrigger;
                            }
                        }
                    }

                    //Apply Increment to Timers and Engage Spawners When Appropriate
                    if (playerWatchList[player].SpaceCargoShipTimer <= 0 && NPCWatcher.PendingNPCs.Count == 0)
                    {
                        playerWatchList[player].SpaceCargoShipTimer = rnd.Next(Settings.SpaceCargoShips.MinSpawnTime, Settings.SpaceCargoShips.MaxSpawnTime);
                        Logger.SkipNextMessage = true;
                        Logger.AddMsg("Attempting Space/Lunar Cargo Ship Spawn Near Player: " + player.DisplayName);
                        Logger.SkipNextMessage = true;
                        var spawnResult = SpaceCargoShipSpawner.AttemptSpawn(player.GetPosition());
                        Logger.AddMsg(spawnResult);
                    }

                    if (playerWatchList[player].AtmoCargoShipTimer <= 0 && NPCWatcher.PendingNPCs.Count == 0)
                    {
                        playerWatchList[player].AtmoCargoShipTimer = rnd.Next(Settings.PlanetaryCargoShips.MinSpawnTime, Settings.PlanetaryCargoShips.MaxSpawnTime);
                        Logger.SkipNextMessage = true;
                        Logger.AddMsg("Attempting Planetary Cargo Ship Spawn Near Player: " + player.DisplayName);
                        Logger.SkipNextMessage = true;
                        var spawnResult = PlanetaryCargoShipSpawner.AttemptSpawn(player.GetPosition());
                        Logger.AddMsg(spawnResult);
                    }

                    if (playerWatchList[player].RandomEncounterCheckTimer <= 0 && playerWatchList[player].RandomEncounterCoolDownTimer <= 0 && NPCWatcher.PendingNPCs.Count == 0)
                    {
                        playerWatchList[player].RandomEncounterCheckTimer = Settings.RandomEncounters.SpawnTimerTrigger;

                        if (Vector3D.Distance(player.GetPosition(), playerWatchList[player].RandomEncounterDistanceCoordCheck) >= Settings.RandomEncounters.PlayerTravelDistance)
                        {
                            playerWatchList[player].RandomEncounterDistanceCoordCheck = player.GetPosition();
                            Logger.SkipNextMessage = true;
                            Logger.AddMsg("Attempting Random Encounter Spawn Near Player: " + player.DisplayName);
                            Logger.SkipNextMessage = true;
                            var spawnResult = RandomEncounterSpawner.AttemptSpawn(player.GetPosition());
                            Logger.AddMsg(spawnResult);

                            if (spawnResult.StartsWith("Spawning Group - ") == true)
                            {
                                playerWatchList[player].RandomEncounterCoolDownTimer = Settings.RandomEncounters.PlayerSpawnCooldown;
                            }
                        }
                    }

                    if (playerWatchList[player].PlanetaryInstallationCheckTimer <= 0 && playerWatchList[player].PlanetaryInstallationCooldownTimer <= 0 && NPCWatcher.PendingNPCs.Count == 0)
                    {
                        playerWatchList[player].PlanetaryInstallationCheckTimer = Settings.PlanetaryInstallations.SpawnTimerTrigger;
                        Logger.SkipNextMessage = true;
                        Logger.AddMsg("Attempting Planetary Installation Spawn Near Player: " + player.DisplayName);
                        Logger.SkipNextMessage = true;
                        var spawnResult = PlanetaryInstallationSpawner.AttemptSpawn(player.GetPosition(), player);
                        Logger.AddMsg(spawnResult);

                        if (spawnResult.StartsWith("Spawning Group - ") == true)
                        {
                            playerWatchList[player].PlanetaryInstallationCooldownTimer = Settings.PlanetaryInstallations.PlayerSpawnCooldown;
                        }
                    }

                    if (playerWatchList[player].BossEncounterCheckTimer <= 0 && NPCWatcher.PendingNPCs.Count == 0)
                    {
                        playerWatchList[player].BossEncounterCheckTimer = Settings.BossEncounters.SpawnTimerTrigger;
                        Logger.SkipNextMessage = true;
                        Logger.AddMsg("Attempting Boss Encounter Spawn Near Player: " + player.DisplayName);
                        Logger.SkipNextMessage = true;
                        var spawnResult = BossEncounterSpawner.AttemptSpawn(player.GetPosition());
                        Logger.AddMsg(spawnResult);

                        if (spawnResult.StartsWith("Boss Encounter GPS Created") == true)
                        {
                            playerWatchList[player].BossEncounterCooldownTimer = Settings.BossEncounters.PlayerSpawnCooldown;
                        }
                    }
                }
                else
                {
                    var newPlayerWatcher = new PlayerWatcher();
                    playerWatchList.Add(player, newPlayerWatcher);
                }
            }
        }
        public static string EligibleSpawnGroupsAtPosition(Vector3D coords)
        {
            var sb            = new StringBuilder();
            var validFactions = new Dictionary <string, List <string> >();



            //Space Cargo Ship
            sb.Append("::: Space / Lunar Cargo Ship Eligible Spawns :::").AppendLine();
            var spaceCargoList = SpaceCargoShipSpawner.GetSpaceCargoShips(coords, out validFactions);

            foreach (var sgroup in spaceCargoList.Distinct().ToList())
            {
                sb.Append(" - ").Append(sgroup.SpawnGroupName).AppendLine();
            }

            sb.AppendLine();

            //Random Encounter
            sb.Append("::: Random Encounter Eligible Spawns :::").AppendLine().AppendLine();
            var randEncounterList = RandomEncounterSpawner.GetRandomEncounters(coords, out validFactions);

            foreach (var sgroup in randEncounterList.Distinct().ToList())
            {
                sb.Append(" - ").Append(sgroup.SpawnGroupName).AppendLine();
            }

            sb.AppendLine();

            //Planetary Cargo Ship
            sb.Append("::: Planetary Cargo Ship Eligible Spawns :::").AppendLine().AppendLine();
            var planetCargoList = PlanetaryCargoShipSpawner.GetPlanetaryCargoShips(coords, out validFactions);

            foreach (var sgroup in planetCargoList.Distinct().ToList())
            {
                sb.Append(" - ").Append(sgroup.SpawnGroupName).AppendLine();
            }

            sb.AppendLine();

            //Planetary Installation
            sb.Append("::: Planetary Installation Eligible Spawns :::").AppendLine().AppendLine();
            var smallList         = new List <ImprovedSpawnGroup>();
            var mediumList        = new List <ImprovedSpawnGroup>();
            var largeList         = new List <ImprovedSpawnGroup>();
            var planetStationList = PlanetaryInstallationSpawner.GetPlanetaryInstallations(coords, out smallList, out mediumList, out largeList, out validFactions);

            foreach (var sgroup in planetStationList.Distinct().ToList())
            {
                sb.Append(" - ").Append(sgroup.SpawnGroupName).AppendLine();
            }

            sb.AppendLine();

            //Boss Encounter
            sb.Append("::: Boss Encounter Eligible Spawns :::").AppendLine().AppendLine();

            var spawnCoords = Vector3D.Zero;

            if (BossEncounterSpawner.GetInitialSpawnCoords(coords, out spawnCoords) == true)
            {
                var bossList = BossEncounterSpawner.GetBossEncounters(coords, spawnCoords);

                foreach (var sgroup in bossList.Distinct().ToList())
                {
                    sb.Append(" - ").Append(sgroup.SpawnGroupName).AppendLine();
                }
            }

            return(sb.ToString());
        }
Exemple #3
0
        //SpawnPlanetaryInstallation
        public static bool SpawnPlanetaryInstallation(Vector3D coords, List <string> spawnGroups)
        {
            var result = PlanetaryInstallationSpawner.AttemptSpawn(coords, null, spawnGroups);

            return(result.StartsWith("Spawning Group - "));
        }
        public static string EligibleSpawnGroupsAtPosition(Vector3D coords)
        {
            var sb            = new StringBuilder();
            var validFactions = new Dictionary <string, List <string> >();

            //Spawn Data Near Player
            var selectedSpawnGroup = new ImprovedSpawnGroup();

            SpawnResources.RefreshEntityLists();
            SpawnResources.LastThreatRefresh = SpawnResources.GameStartTime;
            var threatLevel = SpawnResources.GetThreatLevel(selectedSpawnGroup, coords);
            var pcuLevel    = SpawnResources.GetPCULevel(selectedSpawnGroup, coords);

            sb.Append("::: Spawn Data Near Player :::").AppendLine();
            sb.Append(" - Threat Score: ").Append(threatLevel.ToString()).AppendLine();
            sb.Append(" - PCU Score:    ").Append(pcuLevel.ToString()).AppendLine();

            sb.AppendLine();

            //Environment Data Near Player
            var environment = new EnvironmentEvaluation(coords);

            sb.Append("::: Environment Data Near Player :::").AppendLine();
            sb.Append(" - Distance From World Center:  ").Append(environment.DistanceFromWorldCenter.ToString()).AppendLine();
            sb.Append(" - Direction From World Center: ").Append(environment.DirectionFromWorldCenter.ToString()).AppendLine();
            sb.Append(" - Is On Planet:                ").Append(environment.IsOnPlanet.ToString()).AppendLine();
            sb.Append(" - Planet Name:                 ").Append(environment.IsOnPlanet ? environment.NearestPlanetName : "N/A").AppendLine();
            sb.Append(" - Planet Diameter:             ").Append(environment.IsOnPlanet ? environment.PlanetDiameter.ToString() : "N/A").AppendLine();
            sb.Append(" - Oxygen At Position:          ").Append(environment.IsOnPlanet ? environment.OxygenAtPosition.ToString() : "N/A").AppendLine();
            sb.Append(" - Atmosphere At Position:      ").Append(environment.IsOnPlanet ? environment.AtmosphereAtPosition.ToString() : "N/A").AppendLine();
            sb.Append(" - Gravity At Position:         ").Append(environment.IsOnPlanet ? environment.GravityAtPosition.ToString() : "N/A").AppendLine();
            sb.Append(" - Altitude At Position:        ").Append(environment.IsOnPlanet ? environment.AltitudeAtPosition.ToString() : "N/A").AppendLine();
            sb.Append(" - Is Night At Position:        ").Append(environment.IsOnPlanet ? environment.IsNight.ToString() : "N/A").AppendLine();
            sb.Append(" - Weather At Position:         ").Append(environment.IsOnPlanet && !string.IsNullOrWhiteSpace(environment.WeatherAtPosition) ? environment.WeatherAtPosition.ToString() : "N/A").AppendLine();
            sb.Append(" - Common Terrain At Position:  ").Append(environment.IsOnPlanet ? environment.CommonTerrainAtPosition.ToString() : "N/A").AppendLine();

            sb.AppendLine();

            //Space Cargo Ship
            sb.Append("::: Space / Lunar Cargo Ship Eligible Spawns :::").AppendLine();
            var spaceCargoList = SpaceCargoShipSpawner.GetSpaceCargoShips(coords, null, out validFactions);

            foreach (var sgroup in spaceCargoList.Distinct().ToList())
            {
                sb.Append(" - ").Append(sgroup.SpawnGroupName).AppendLine();
            }

            sb.AppendLine();

            //Random Encounter
            sb.Append("::: Random Encounter Eligible Spawns :::").AppendLine().AppendLine();
            var randEncounterList = RandomEncounterSpawner.GetRandomEncounters(coords, null, out validFactions);

            foreach (var sgroup in randEncounterList.Distinct().ToList())
            {
                sb.Append(" - ").Append(sgroup.SpawnGroupName).AppendLine();
            }

            sb.AppendLine();

            //Planetary Cargo Ship
            sb.Append("::: Planetary Cargo Ship Eligible Spawns :::").AppendLine().AppendLine();
            var planetCargoList = PlanetaryCargoShipSpawner.GetPlanetaryCargoShips(coords, null, out validFactions);

            foreach (var sgroup in planetCargoList.Distinct().ToList())
            {
                sb.Append(" - ").Append(sgroup.SpawnGroupName).AppendLine();
            }

            sb.AppendLine();

            //Planetary Installation
            sb.Append("::: Planetary Installation Eligible Spawns :::").AppendLine().AppendLine();
            var smallList         = new List <ImprovedSpawnGroup>();
            var mediumList        = new List <ImprovedSpawnGroup>();
            var largeList         = new List <ImprovedSpawnGroup>();
            var planetStationList = PlanetaryInstallationSpawner.GetPlanetaryInstallations(coords, null, out smallList, out mediumList, out largeList, out validFactions);

            foreach (var sgroup in planetStationList.Distinct().ToList())
            {
                sb.Append(" - ").Append(sgroup.SpawnGroupName).AppendLine();
            }

            sb.AppendLine();

            //Boss Encounter
            sb.Append("::: Boss Encounter Eligible Spawns :::").AppendLine().AppendLine();

            var spawnCoords = Vector3D.Zero;

            if (BossEncounterSpawner.GetInitialSpawnCoords(coords, out spawnCoords) == true)
            {
                var bossList = BossEncounterSpawner.GetBossEncounters(coords, spawnCoords, null);

                foreach (var sgroup in bossList.Distinct().ToList())
                {
                    sb.Append(" - ").Append(sgroup.SpawnGroupName).AppendLine();
                }
            }

            return(sb.ToString());
        }