public override void Started() { base.Started(); // TODO: "safe random" for chems. Right now this includes admin chemicals. var allReagents = PrototypeManager.EnumeratePrototypes <ReagentPrototype>() .Where(x => !x.Abstract) .Select(x => x.ID).ToList(); // This is gross, but not much can be done until event refactor, which needs Dynamic. var sound = new SoundPathSpecifier("/Audio/Effects/extinguish.ogg"); foreach (var(_, transform) in EntityManager.EntityQuery <GasVentPumpComponent, TransformComponent>()) { var solution = new Solution(); if (!RobustRandom.Prob(0.33f)) { continue; } if (RobustRandom.Prob(0.05f)) { solution.AddReagent(RobustRandom.Pick(allReagents), 100); } else { solution.AddReagent(RobustRandom.Pick(SafeishVentChemicals), 100); } FoamAreaReactionEffect.SpawnFoam("Foam", transform.Coordinates, solution, RobustRandom.Next(2, 6), 20, 1, 1, sound, EntityManager); } }
/// <summary> /// Finds 2-5 random, alive entities that can host diseases /// and gives them a randomly selected disease. /// They all get the same disease. /// </summary> public override void Started() { base.Started(); HashSet <EntityUid> stationsToNotify = new(); List <DiseaseCarrierComponent> aliveList = new(); foreach (var(carrier, mobState) in EntityManager.EntityQuery <DiseaseCarrierComponent, MobStateComponent>()) { if (!mobState.IsDead()) { aliveList.Add(carrier); } } RobustRandom.Shuffle(aliveList); // We're going to filter the above out to only alive mobs. Might change after future mobstate rework var toInfect = RobustRandom.Next(2, 5); var diseaseName = RobustRandom.Pick(NotTooSeriousDiseases); if (!PrototypeManager.TryIndex(diseaseName, out DiseasePrototype? disease)) { return; } // Now we give it to people in the list of living disease carriers earlier foreach (var target in aliveList) { if (toInfect-- == 0) { break; } _diseaseSystem.TryAddDisease(target.Owner, disease, target); var station = StationSystem.GetOwningStation(target.Owner); if (station == null) { continue; } stationsToNotify.Add((EntityUid)station); } }
public override void Started() { base.Started(); if (StationSystem.Stations.Count == 0) { return; // No stations } var chosenStation = RobustRandom.Pick(StationSystem.Stations.ToList()); var jobList = _stationJobs.GetJobs(chosenStation).Keys.ToList(); // Low chance to completely change up the late-join landscape by closing all positions except infinite slots. // Lower chance than the /tg/ equivalent of this event. if (RobustRandom.Prob(0.25f)) { var chosenJob = RobustRandom.PickAndTake(jobList); _stationJobs.MakeJobUnlimited(chosenStation, chosenJob); // INFINITE chaos. foreach (var job in jobList) { if (_stationJobs.IsJobUnlimited(chosenStation, job)) { continue; } _stationJobs.TrySetJobSlot(chosenStation, job, 0); } } else { // Changing every role is maybe a bit too chaotic so instead change 20-30% of them. for (var i = 0; i < RobustRandom.Next((int)(jobList.Count * 0.20), (int)(jobList.Count * 0.30)); i++) { var chosenJob = RobustRandom.PickAndTake(jobList); if (_stationJobs.IsJobUnlimited(chosenStation, chosenJob)) { continue; } _stationJobs.TryAdjustJobSlot(chosenStation, chosenJob, RobustRandom.Next(-3, 6)); } } }
public override void Started() { base.Started(); // Essentially we'll pick out a target amount of gas to leak, then a rate to leak it at, then work out the duration from there. if (TryFindRandomTile(out _targetTile, out _targetStation, out _targetGrid, out _targetCoords)) { _foundTile = true; _leakGas = RobustRandom.Pick(LeakableGases); // Was 50-50 on using normal distribution. var totalGas = (float)RobustRandom.Next(MinimumGas, MaximumGas); var startAfter = ((StationEventRuleConfiguration)Configuration).StartAfter; _molesPerSecond = RobustRandom.Next(MinimumMolesPerSecond, MaximumMolesPerSecond); _endAfter = totalGas / _molesPerSecond + startAfter; Sawmill.Info($"Leaking {totalGas} of {_leakGas} over {_endAfter - startAfter} seconds at {_targetTile}"); } // Look technically if you wanted to guarantee a leak you'd do this in announcement but having the announcement // there just to f**k with people even if there is no valid tile is funny. }
public override void Started() { base.Started(); var spawnLocations = EntityManager.EntityQuery <VentCritterSpawnLocationComponent, TransformComponent>().ToList(); RobustRandom.Shuffle(spawnLocations); var spawnAmount = RobustRandom.Next(7, 15); // A small colony of critters. for (int i = 0; i < spawnAmount && i < spawnLocations.Count - 1; i++) { var spawnChoice = RobustRandom.Pick(SpawnedPrototypeChoices); if (RobustRandom.Prob(0.01f) || i == 0) //small chance for multiple, but always at least 1 { spawnChoice = "SpawnPointGhostRatKing"; } var coords = spawnLocations[i].Item2.Coordinates; Sawmill.Info($"Spawning mouse {spawnChoice} at {coords}"); EntityManager.SpawnEntity(spawnChoice, coords); } }
public override void Started() { base.Started(); var spawnChoice = RobustRandom.Pick(SpawnedPrototypeChoices); var spawnLocations = EntityManager.EntityQuery <VentCritterSpawnLocationComponent>().ToList(); RobustRandom.Shuffle(spawnLocations); var spawnAmount = RobustRandom.Next(4, 12); // A small colony of critters. Sawmill.Info($"Spawning {spawnAmount} of {spawnChoice}"); foreach (var location in spawnLocations) { if (spawnAmount-- == 0) { break; } var coords = EntityManager.GetComponent <TransformComponent>(location.Owner); EntityManager.SpawnEntity(spawnChoice, coords.Coordinates); } }