Nuke agent is separete role (#15385)

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
lzk228
2023-05-01 17:20:56 +03:00
committed by GitHub
parent 3ee8ab0d9c
commit 7ecafb45e8
4 changed files with 65 additions and 25 deletions

View File

@@ -53,6 +53,9 @@ public sealed class NukeopsRuleComponent : Component
[DataField("operativeRoleProto", customTypeSerializer: typeof(PrototypeIdSerializer<StartingGearPrototype>))]
public string OperativeRoleProto = "Nukeops";
[DataField("medicRoleProto", customTypeSerializer: typeof(PrototypeIdSerializer<StartingGearPrototype>))]
public string MedicRoleProto = "NukeopsMedic";
[DataField("commanderStartingGearProto", customTypeSerializer: typeof(PrototypeIdSerializer<StartingGearPrototype>))]
public string CommanderStartGearPrototype = "SyndicateCommanderGearFull";

View File

@@ -408,8 +408,10 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
var playersPerOperative = nukeops.PlayersPerOperative;
var maxOperatives = nukeops.MaxOperatives;
// Dear lord what is happening HERE.
var everyone = new List<IPlayerSession>(ev.PlayerPool);
var prefList = new List<IPlayerSession>();
var medPrefList = new List<IPlayerSession>();
var cmdrPrefList = new List<IPlayerSession>();
var operatives = new List<IPlayerSession>();
@@ -427,7 +429,10 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
{
prefList.Add(player);
}
if (profile.AntagPreferences.Contains(nukeops.MedicRoleProto))
{
medPrefList.Add(player);
}
if (profile.AntagPreferences.Contains(nukeops.CommanderRolePrototype))
{
cmdrPrefList.Add(player);
@@ -438,31 +443,38 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
for (var i = 0; i < numNukies; i++)
{
// TODO: Please fix this if you touch it.
IPlayerSession nukeOp;
// Only one commander, so we do it at the start
if (i == 0)
{
if (cmdrPrefList.Count == 0)
{
if (medPrefList.Count == 0)
{
if (prefList.Count == 0)
{
if (everyone.Count == 0)
{
Logger.InfoS("preset",
"Insufficient ready players to fill up with nukeops, stopping the selection");
Logger.InfoS("preset", "Insufficient ready players to fill up with nukeops, stopping the selection");
break;
}
nukeOp = _random.PickAndTake(everyone);
Logger.InfoS("preset",
"Insufficient preferred nukeop commanders or nukies, picking at random.");
Logger.InfoS("preset", "Insufficient preferred nukeop commanders, agents or nukies, picking at random.");
}
else
{
nukeOp = _random.PickAndTake(prefList);
everyone.Remove(nukeOp);
Logger.InfoS("preset",
"Insufficient preferred nukeop commanders, picking at random from regular op list.");
Logger.InfoS("preset", "Insufficient preferred nukeop commander or agents, picking at random from regular op list.");
}
}
else
{
nukeOp = _random.PickAndTake(medPrefList);
everyone.Remove(nukeOp);
prefList.Remove(nukeOp);
Logger.InfoS("preset", "Insufficient preferred nukeop commanders, picking an agent");
}
}
else
@@ -470,30 +482,45 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
nukeOp = _random.PickAndTake(cmdrPrefList);
everyone.Remove(nukeOp);
prefList.Remove(nukeOp);
medPrefList.Remove(nukeOp);
Logger.InfoS("preset", "Selected a preferred nukeop commander.");
}
}
else
else if (i == 1)
{
if (medPrefList.Count == 0)
{
if (prefList.Count == 0)
{
if (everyone.Count == 0)
{
Logger.InfoS("preset",
"Insufficient ready players to fill up with nukeops, stopping the selection");
Logger.InfoS("preset", "Insufficient ready players to fill up with nukeops, stopping the selection");
break;
}
nukeOp = _random.PickAndTake(everyone);
Logger.InfoS("preset", "Insufficient preferred nukeops, picking at random.");
Logger.InfoS("preset", "Insufficient preferred nukeop commanders, agents or nukies, picking at random.");
}
else
{
nukeOp = _random.PickAndTake(prefList);
everyone.Remove(nukeOp);
Logger.InfoS("preset", "Selected a preferred nukeop.");
Logger.InfoS("preset", "Insufficient preferred nukeop commander or agents, picking at random from regular op list.");
}
}
else
{
nukeOp = _random.PickAndTake(medPrefList);
everyone.Remove(nukeOp);
Logger.InfoS("preset", "Insufficient preferred nukeop commanders, picking an agent");
}
}
else
{
nukeOp = _random.PickAndTake(prefList);
everyone.Remove(nukeOp);
Logger.InfoS("preset", "Selected a preferred nukeop commander.");
}
operatives.Add(nukeOp);
}
@@ -641,7 +668,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
break;
case 1:
name = Loc.GetString("nukeops-role-agent") + " " + _random.PickAndTake(component.OperativeNames[component.NormalNames]);
role = component.OperativeRoleProto;
role = component.MedicRoleProto;
gear = component.MedicStartGearPrototype;
break;
default:

View File

@@ -16,5 +16,8 @@ roles-antag-suspicion-suspect-objective = Kill the innocents.
roles-antag-nuclear-operative-commander-name = Nuclear operative commander
roles-antag-nuclear-operative-commander-objective = Lead your team to the destruction of the station.
roles-antag-nuclear-operative-agent-name = Nuclear operative agent
roles-antag-nuclear-operative-agent-objective = Like default operative, the team's treatment will have priority.
roles-antag-nuclear-operative-name = Nuclear operative
roles-antag-nuclear-operative-objective = Find the nuke disk and blow up the station.

View File

@@ -5,6 +5,13 @@
setPreference: true
objective: roles-antag-nuclear-operative-objective
- type: antag
id: NukeopsMedic
name: roles-antag-nuclear-operative-agent-name
antagonist: true
setPreference: true
objective: roles-antag-nuclear-operative-agent-objective
- type: antag
id: NukeopsCommander
name: roles-antag-nuclear-operative-commander-name