Make nukies usable (#8257)

* Make nukies usable

- Spawn points that work
- Radar default range bumped up
- Used the infiltrator instead
- Spawning works
I playtested it and it was working so anything new pops up then I'm gonna screm.

* a
This commit is contained in:
metalgearsloth
2022-05-19 07:48:00 +10:00
committed by GitHub
parent ab179e171e
commit d9bcc7f6dd
7 changed files with 780 additions and 202 deletions

View File

@@ -2,6 +2,7 @@
using Content.Server.Chat.Managers;
using Content.Server.Nuke;
using Content.Server.RoundEnd;
using Content.Server.Spawners.Components;
using Content.Server.Station.Components;
using Content.Server.Station.Systems;
using Content.Shared.CCVar;
@@ -49,7 +50,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
private void OnNukeExploded(NukeExplodedEvent ev)
{
if (!Enabled) return;
_opsWon = true;
_roundEndSystem.EndRound();
}
@@ -78,6 +79,8 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
private void OnPlayersSpawning(RulePlayerSpawningEvent ev)
{
if (!Enabled) return;
_aliveNukeops.Clear();
var numOps = (int)Math.Min(Math.Floor((double)ev.PlayerPool.Count / _cfg.GetCVar(CCVars.NukeopsPlayersPerOp)),
@@ -88,22 +91,22 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
ops[i] = _random.PickAndTake(ev.PlayerPool);
}
var map = "/Maps/syndiepuddle.yml";
var map = "/Maps/infiltrator.yml";
var aabbs = _stationSystem.Stations.SelectMany(x =>
Comp<StationDataComponent>(x).Grids.Select(x => _mapManager.GetGridComp(x).Grid.WorldBounds.CalcBoundingBox())).ToArray();
Comp<StationDataComponent>(x).Grids.Select(x => _mapManager.GetGridComp(x).Grid.WorldAABB)).ToArray();
var aabb = aabbs[0];
for (int i = 1; i < aabbs.Length; i++)
{
aabb.Union(aabbs[i]);
}
var (_, grid) = _mapLoader.LoadBlueprint(GameTicker.DefaultMap, map, new MapLoadOptions
var (_, gridId) = _mapLoader.LoadBlueprint(GameTicker.DefaultMap, map, new MapLoadOptions
{
Offset = aabb.Center + MathF.Max(aabb.Height, aabb.Width)*2.5f
Offset = aabb.Center + MathF.Max(aabb.Height / 2f, aabb.Width / 2f) * 2.5f
});
if (!grid.HasValue)
if (!gridId.HasValue)
{
Logger.ErrorS("NUKEOPS", $"Gridid was null when loading \"{map}\", aborting.");
foreach (var session in ops)
@@ -113,19 +116,52 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
return;
}
var gear = _prototypeManager.Index<StartingGearPrototype>("SyndicateOperativeGearFull");
var spawnpos = new EntityCoordinates(_mapManager.GetGridEuid(grid.Value), new Vector2(1.5f, -4.5f));
var gridUid = _mapManager.GetGridEuid(gridId.Value);
// TODO: Loot table or something
var commanderGear = _prototypeManager.Index<StartingGearPrototype>("SyndicateCommanderGearFull");
var starterGear = _prototypeManager.Index<StartingGearPrototype>("SyndicateOperativeGearFull");
var spawns = new List<EntityCoordinates>();
// Forgive me for hardcoding prototypes
foreach (var (_, meta, xform) in EntityManager.EntityQuery<SpawnPointComponent, MetaDataComponent, TransformComponent>(true))
{
if (meta.EntityPrototype?.ID != "SpawnPointNukies" || xform.ParentUid != gridUid) continue;
spawns.Add(xform.Coordinates);
}
if (spawns.Count == 0)
{
spawns.Add(EntityManager.GetComponent<TransformComponent>(gridUid).Coordinates);
Logger.WarningS("nukies", $"Fell back to default spawn for nukies!");
}
// TODO: This should spawn the nukies in regardless and transfer if possible; rest should go to shot roles.
for (var i = 0; i < ops.Length; i++)
{
string name;
StartingGearPrototype gear;
if (i == 0)
{
name = $"Commander";
gear = commanderGear;
}
else
{
name = $"Operator #{i}";
gear = starterGear;
}
var session = ops[i];
var name = $"Operator #{i}";
var newMind = new Mind.Mind(session.UserId)
{
CharacterName = name
};
newMind.ChangeOwningPlayer(session.UserId);
var mob = EntityManager.SpawnEntity("MobHuman", spawnpos);
var mob = EntityManager.SpawnEntity("MobHuman", _random.Pick(spawns));
EntityManager.GetComponent<MetaDataComponent>(mob).EntityName = name;
newMind.TransferTo(mob);