2023-12-24 12:58:28 +03:00
|
|
|
using Content.Server.Antag;
|
2023-04-25 20:23:14 -04:00
|
|
|
using Content.Server.GameTicking.Rules.Components;
|
2023-06-18 11:33:19 -07:00
|
|
|
using Content.Server.Mind;
|
2023-08-28 16:53:24 -07:00
|
|
|
using Content.Server.NPC.Systems;
|
|
|
|
|
using Content.Server.Objectives;
|
2023-04-23 21:00:42 +00:00
|
|
|
using Content.Server.PDA.Ringer;
|
2021-12-21 21:23:29 +01:00
|
|
|
using Content.Server.Roles;
|
|
|
|
|
using Content.Server.Traitor.Uplink;
|
|
|
|
|
using Content.Shared.CCVar;
|
|
|
|
|
using Content.Shared.Dataset;
|
2023-08-30 21:46:11 -07:00
|
|
|
using Content.Shared.Mind;
|
2023-01-13 16:57:10 -08:00
|
|
|
using Content.Shared.Mobs.Systems;
|
2023-09-16 07:18:10 +01:00
|
|
|
using Content.Shared.Objectives.Components;
|
2023-06-07 10:15:22 +03:00
|
|
|
using Content.Shared.PDA;
|
2021-12-26 06:13:37 +03:00
|
|
|
using Content.Shared.Roles;
|
2023-08-30 21:46:11 -07:00
|
|
|
using Content.Shared.Roles.Jobs;
|
2023-11-27 22:12:34 +11:00
|
|
|
using Robust.Server.Player;
|
2021-12-21 21:23:29 +01:00
|
|
|
using Robust.Shared.Configuration;
|
|
|
|
|
using Robust.Shared.Prototypes;
|
|
|
|
|
using Robust.Shared.Random;
|
2023-01-20 11:18:47 -05:00
|
|
|
using Robust.Shared.Timing;
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
2021-12-21 21:23:29 +01:00
|
|
|
|
|
|
|
|
namespace Content.Server.GameTicking.Rules;
|
|
|
|
|
|
2023-04-25 20:23:14 -04:00
|
|
|
public sealed class TraitorRuleSystem : GameRuleSystem<TraitorRuleComponent>
|
2021-12-21 21:23:29 +01:00
|
|
|
{
|
2023-12-24 12:58:28 +03:00
|
|
|
[Dependency] private readonly AntagSelectionSystem _antagSelection = default!;
|
2021-12-21 21:23:29 +01:00
|
|
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
|
|
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
|
|
|
|
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
2023-07-17 15:51:52 +12:00
|
|
|
[Dependency] private readonly NpcFactionSystem _npcFaction = default!;
|
2022-11-03 22:58:19 -04:00
|
|
|
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
|
2022-08-17 00:34:25 -04:00
|
|
|
[Dependency] private readonly UplinkSystem _uplink = default!;
|
2023-06-18 11:33:19 -07:00
|
|
|
[Dependency] private readonly MindSystem _mindSystem = default!;
|
2023-08-30 21:46:11 -07:00
|
|
|
[Dependency] private readonly SharedRoleSystem _roleSystem = default!;
|
|
|
|
|
[Dependency] private readonly SharedJobSystem _jobs = default!;
|
2023-08-28 16:53:24 -07:00
|
|
|
[Dependency] private readonly ObjectivesSystem _objectives = default!;
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
[Dependency] private readonly IGameTiming _timing = default!;
|
2022-11-03 22:58:19 -04:00
|
|
|
|
2023-04-25 20:23:14 -04:00
|
|
|
private int PlayersPerTraitor => _cfg.GetCVar(CCVars.TraitorPlayersPerTraitor);
|
|
|
|
|
private int MaxTraitors => _cfg.GetCVar(CCVars.TraitorMaxTraitors);
|
2023-01-20 11:18:47 -05:00
|
|
|
|
2021-12-21 21:23:29 +01:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<RoundStartAttemptEvent>(OnStartAttempt);
|
|
|
|
|
SubscribeLocalEvent<RulePlayerJobsAssignedEvent>(OnPlayersSpawned);
|
2022-07-28 20:59:45 -04:00
|
|
|
SubscribeLocalEvent<PlayerSpawnCompleteEvent>(HandleLatejoin);
|
2023-09-04 05:55:34 +01:00
|
|
|
|
|
|
|
|
SubscribeLocalEvent<TraitorRuleComponent, ObjectivesTextGetInfoEvent>(OnObjectivesTextGetInfo);
|
|
|
|
|
SubscribeLocalEvent<TraitorRuleComponent, ObjectivesTextPrependEvent>(OnObjectivesTextPrepend);
|
2021-12-21 21:23:29 +01:00
|
|
|
}
|
|
|
|
|
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
//Set min players on game rule
|
|
|
|
|
protected override void Added(EntityUid uid, TraitorRuleComponent component, GameRuleComponent gameRule, GameRuleAddedEvent args)
|
|
|
|
|
{
|
|
|
|
|
base.Added(uid, component, gameRule, args);
|
|
|
|
|
|
|
|
|
|
gameRule.MinPlayers = _cfg.GetCVar(CCVars.TraitorMinPlayers);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Started(EntityUid uid, TraitorRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args)
|
|
|
|
|
{
|
|
|
|
|
base.Started(uid, component, gameRule, args);
|
|
|
|
|
MakeCodewords(component);
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-25 20:23:14 -04:00
|
|
|
protected override void ActiveTick(EntityUid uid, TraitorRuleComponent component, GameRuleComponent gameRule, float frameTime)
|
2023-01-20 11:18:47 -05:00
|
|
|
{
|
2023-04-25 20:23:14 -04:00
|
|
|
base.ActiveTick(uid, component, gameRule, frameTime);
|
2021-12-21 21:23:29 +01:00
|
|
|
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
if (component.SelectionStatus < TraitorRuleComponent.SelectionState.Started && component.AnnounceAt < _timing.CurTime)
|
|
|
|
|
{
|
2023-04-25 20:23:14 -04:00
|
|
|
DoTraitorStart(component);
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
component.SelectionStatus = TraitorRuleComponent.SelectionState.Started;
|
|
|
|
|
}
|
2023-04-24 16:21:05 +10:00
|
|
|
}
|
2021-12-21 21:23:29 +01:00
|
|
|
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
/// <summary>
|
|
|
|
|
/// Check for enough players
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ev"></param>
|
2023-04-24 16:21:05 +10:00
|
|
|
private void OnStartAttempt(RoundStartAttemptEvent ev)
|
|
|
|
|
{
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
TryRoundStartAttempt(ev, Loc.GetString("traitor-title"));
|
2021-12-21 21:23:29 +01:00
|
|
|
}
|
|
|
|
|
|
2023-04-25 20:23:14 -04:00
|
|
|
private void MakeCodewords(TraitorRuleComponent component)
|
2022-07-20 05:46:23 -04:00
|
|
|
{
|
|
|
|
|
var codewordCount = _cfg.GetCVar(CCVars.TraitorCodewordCount);
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
var adjectives = _prototypeManager.Index<DatasetPrototype>(component.CodewordAdjectives).Values;
|
|
|
|
|
var verbs = _prototypeManager.Index<DatasetPrototype>(component.CodewordVerbs).Values;
|
2022-07-20 05:46:23 -04:00
|
|
|
var codewordPool = adjectives.Concat(verbs).ToList();
|
|
|
|
|
var finalCodewordCount = Math.Min(codewordCount, codewordPool.Count);
|
2023-04-25 20:23:14 -04:00
|
|
|
component.Codewords = new string[finalCodewordCount];
|
2022-07-20 05:46:23 -04:00
|
|
|
for (var i = 0; i < finalCodewordCount; i++)
|
|
|
|
|
{
|
2023-04-25 20:23:14 -04:00
|
|
|
component.Codewords[i] = _random.PickAndTake(codewordPool);
|
2022-07-20 05:46:23 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-25 20:23:14 -04:00
|
|
|
private void DoTraitorStart(TraitorRuleComponent component)
|
2021-12-21 21:23:29 +01:00
|
|
|
{
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
var eligiblePlayers = _antagSelection.GetEligiblePlayers(_playerManager.Sessions, component.TraitorPrototypeId);
|
|
|
|
|
|
|
|
|
|
if (eligiblePlayers.Count == 0)
|
2021-12-21 21:23:29 +01:00
|
|
|
return;
|
|
|
|
|
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
var traitorsToSelect = _antagSelection.CalculateAntagCount(_playerManager.PlayerCount, PlayersPerTraitor, MaxTraitors);
|
2022-07-20 05:46:23 -04:00
|
|
|
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
var selectedTraitors = _antagSelection.ChooseAntags(traitorsToSelect, eligiblePlayers);
|
2023-01-20 11:18:47 -05:00
|
|
|
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
MakeTraitor(selectedTraitors, component);
|
2023-01-20 11:18:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnPlayersSpawned(RulePlayerJobsAssignedEvent ev)
|
|
|
|
|
{
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
//Start the timer
|
|
|
|
|
var query = QueryActiveRules();
|
|
|
|
|
while (query.MoveNext(out _, out var comp, out var gameRuleComponent))
|
2023-01-20 11:18:47 -05:00
|
|
|
{
|
2023-04-25 20:23:14 -04:00
|
|
|
var delay = TimeSpan.FromSeconds(
|
|
|
|
|
_cfg.GetCVar(CCVars.TraitorStartDelay) +
|
|
|
|
|
_random.NextFloat(0f, _cfg.GetCVar(CCVars.TraitorStartDelayVariance)));
|
2023-01-20 11:18:47 -05:00
|
|
|
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
//Set the delay for choosing traitors
|
|
|
|
|
comp.AnnounceAt = _timing.CurTime + delay;
|
2023-01-20 11:18:47 -05:00
|
|
|
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
comp.SelectionStatus = TraitorRuleComponent.SelectionState.ReadyToStart;
|
2023-04-25 20:23:14 -04:00
|
|
|
}
|
2022-07-20 05:46:23 -04:00
|
|
|
}
|
2021-12-21 21:23:29 +01:00
|
|
|
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
public bool MakeTraitor(List<EntityUid> traitors, TraitorRuleComponent component, bool giveUplink = true, bool giveObjectives = true)
|
2022-07-20 05:46:23 -04:00
|
|
|
{
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
foreach (var traitor in traitors)
|
2023-04-25 20:23:14 -04:00
|
|
|
{
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
MakeTraitor(traitor, component, giveUplink, giveObjectives);
|
2023-04-25 20:23:14 -04:00
|
|
|
}
|
|
|
|
|
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool MakeTraitor(EntityUid traitor, TraitorRuleComponent component, bool giveUplink = true, bool giveObjectives = true)
|
|
|
|
|
{
|
|
|
|
|
//Grab the mind if it wasnt provided
|
2023-08-28 16:53:24 -07:00
|
|
|
if (!_mindSystem.TryGetMind(traitor, out var mindId, out var mind))
|
2022-07-20 05:46:23 -04:00
|
|
|
return false;
|
2023-08-28 16:53:24 -07:00
|
|
|
|
|
|
|
|
if (HasComp<TraitorRoleComponent>(mindId))
|
|
|
|
|
{
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
Log.Error($"Player {mind.CharacterName} is already a traitor.");
|
2023-01-01 20:18:47 -05:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
var briefing = Loc.GetString("traitor-role-codewords-short", ("codewords", string.Join(", ", component.Codewords)));
|
2022-09-15 15:37:54 -04:00
|
|
|
|
2023-09-10 03:51:51 +01:00
|
|
|
Note[]? code = null;
|
|
|
|
|
if (giveUplink)
|
|
|
|
|
{
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
// Calculate the amount of currency on the uplink.
|
|
|
|
|
var startingBalance = _cfg.GetCVar(CCVars.TraitorStartingBalance);
|
|
|
|
|
if (_jobs.MindTryGetJob(mindId, out _, out var prototype))
|
|
|
|
|
startingBalance = Math.Max(startingBalance - prototype.AntagAdvantage, 0);
|
|
|
|
|
|
2023-09-10 03:51:51 +01:00
|
|
|
// creadth: we need to create uplink for the antag.
|
|
|
|
|
// PDA should be in place already
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
var pda = _uplink.FindUplinkTarget(traitor);
|
|
|
|
|
if (pda == null || !_uplink.AddUplink(traitor, startingBalance))
|
2023-09-10 03:51:51 +01:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// Give traitors their codewords and uplink code to keep in their character info menu
|
|
|
|
|
code = EnsureComp<RingerUplinkComponent>(pda.Value).Code;
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
|
2023-09-10 03:51:51 +01:00
|
|
|
// If giveUplink is false the uplink code part is omitted
|
|
|
|
|
briefing = string.Format("{0}\n{1}", briefing,
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
Loc.GetString("traitor-role-uplink-code-short", ("code", string.Join("-", code).Replace("sharp", "#"))));
|
2023-09-10 03:51:51 +01:00
|
|
|
}
|
2023-04-25 20:23:14 -04:00
|
|
|
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
_antagSelection.SendBriefing(traitor, GenerateBriefing(component.Codewords, code), null, component.GreetSoundNotification);
|
|
|
|
|
|
|
|
|
|
component.TraitorMinds.Add(mindId);
|
2023-06-07 10:15:22 +03:00
|
|
|
|
|
|
|
|
// Assign traitor roles
|
2023-08-31 22:29:45 +01:00
|
|
|
_roleSystem.MindAddRole(mindId, new TraitorRoleComponent
|
|
|
|
|
{
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
PrototypeId = component.TraitorPrototypeId
|
|
|
|
|
}, mind, true);
|
|
|
|
|
// Assign briefing
|
2023-08-31 22:29:45 +01:00
|
|
|
_roleSystem.MindAddRole(mindId, new RoleBriefingComponent
|
|
|
|
|
{
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
Briefing = briefing.ToString()
|
|
|
|
|
}, mind, true);
|
2021-12-21 21:23:29 +01:00
|
|
|
|
2023-06-07 10:15:22 +03:00
|
|
|
// Change the faction
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
_npcFaction.RemoveFaction(traitor, component.NanoTrasenFaction, false);
|
|
|
|
|
_npcFaction.AddFaction(traitor, component.SyndicateFaction);
|
2023-01-01 20:18:47 -05:00
|
|
|
|
2023-06-07 10:15:22 +03:00
|
|
|
// Give traitors their objectives
|
2023-09-10 03:51:51 +01:00
|
|
|
if (giveObjectives)
|
2021-12-21 21:23:29 +01:00
|
|
|
{
|
2023-09-10 03:51:51 +01:00
|
|
|
var maxDifficulty = _cfg.GetCVar(CCVars.TraitorMaxDifficulty);
|
|
|
|
|
var maxPicks = _cfg.GetCVar(CCVars.TraitorMaxPicks);
|
|
|
|
|
var difficulty = 0f;
|
2024-01-15 23:09:14 +00:00
|
|
|
Log.Debug($"Attempting {maxPicks} objective picks with {maxDifficulty} difficulty");
|
2023-09-10 03:51:51 +01:00
|
|
|
for (var pick = 0; pick < maxPicks && maxDifficulty > difficulty; pick++)
|
|
|
|
|
{
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
var objective = _objectives.GetRandomObjective(mindId, mind, component.ObjectiveGroup);
|
2023-09-10 03:51:51 +01:00
|
|
|
if (objective == null)
|
|
|
|
|
continue;
|
2023-06-18 11:33:19 -07:00
|
|
|
|
2023-09-16 07:18:10 +01:00
|
|
|
_mindSystem.AddObjective(mindId, mind, objective.Value);
|
2024-01-15 23:09:14 +00:00
|
|
|
var adding = Comp<ObjectiveComponent>(objective.Value).Difficulty;
|
|
|
|
|
difficulty += adding;
|
|
|
|
|
Log.Debug($"Added objective {ToPrettyString(objective):objective} with {adding} difficulty");
|
2023-09-10 03:51:51 +01:00
|
|
|
}
|
2021-12-21 21:23:29 +01:00
|
|
|
}
|
|
|
|
|
|
2022-07-20 05:46:23 -04:00
|
|
|
return true;
|
2021-12-21 21:23:29 +01:00
|
|
|
}
|
|
|
|
|
|
2022-07-28 20:59:45 -04:00
|
|
|
private void HandleLatejoin(PlayerSpawnCompleteEvent ev)
|
|
|
|
|
{
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
var query = QueryActiveRules();
|
|
|
|
|
while (query.MoveNext(out _, out var comp, out _))
|
2023-04-25 20:23:14 -04:00
|
|
|
{
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
if (comp.TotalTraitors >= MaxTraitors)
|
2023-04-25 20:23:14 -04:00
|
|
|
continue;
|
2022-07-28 20:59:45 -04:00
|
|
|
|
2023-04-25 20:23:14 -04:00
|
|
|
if (!ev.LateJoin)
|
|
|
|
|
continue;
|
2022-07-28 20:59:45 -04:00
|
|
|
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
if (!_antagSelection.IsPlayerEligible(ev.Player, comp.TraitorPrototypeId))
|
2023-04-25 20:23:14 -04:00
|
|
|
continue;
|
2023-01-20 11:18:47 -05:00
|
|
|
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
//If its before we have selected traitors, continue
|
|
|
|
|
if (comp.SelectionStatus < TraitorRuleComponent.SelectionState.Started)
|
2023-04-25 20:23:14 -04:00
|
|
|
continue;
|
2022-07-28 20:59:45 -04:00
|
|
|
|
2023-04-25 20:23:14 -04:00
|
|
|
// the nth player we adjust our probabilities around
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
var target = PlayersPerTraitor * comp.TotalTraitors + 1;
|
2023-04-25 20:23:14 -04:00
|
|
|
var chance = 1f / PlayersPerTraitor;
|
2022-07-28 20:59:45 -04:00
|
|
|
|
2023-04-25 20:23:14 -04:00
|
|
|
// If we have too many traitors, divide by how many players below target for next traitor we are.
|
|
|
|
|
if (ev.JoinOrder < target)
|
|
|
|
|
{
|
|
|
|
|
chance /= (target - ev.JoinOrder);
|
|
|
|
|
}
|
|
|
|
|
else // Tick up towards 100% chance.
|
|
|
|
|
{
|
|
|
|
|
chance *= ((ev.JoinOrder + 1) - target);
|
|
|
|
|
}
|
2023-04-24 01:20:51 -04:00
|
|
|
|
2023-04-25 20:23:14 -04:00
|
|
|
if (chance > 1)
|
|
|
|
|
chance = 1;
|
|
|
|
|
|
|
|
|
|
// Now that we've calculated our chance, roll and make them a traitor if we roll under.
|
|
|
|
|
// You get one shot.
|
|
|
|
|
if (_random.Prob(chance))
|
|
|
|
|
{
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
MakeTraitor(ev.Mob, comp);
|
2023-04-25 20:23:14 -04:00
|
|
|
}
|
2022-07-28 20:59:45 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-04 05:55:34 +01:00
|
|
|
private void OnObjectivesTextGetInfo(EntityUid uid, TraitorRuleComponent comp, ref ObjectivesTextGetInfoEvent args)
|
2021-12-21 21:23:29 +01:00
|
|
|
{
|
2023-09-04 05:55:34 +01:00
|
|
|
args.Minds = comp.TraitorMinds;
|
|
|
|
|
args.AgentName = Loc.GetString("traitor-round-end-agent-name");
|
|
|
|
|
}
|
2023-04-25 20:23:14 -04:00
|
|
|
|
2023-09-04 05:55:34 +01:00
|
|
|
private void OnObjectivesTextPrepend(EntityUid uid, TraitorRuleComponent comp, ref ObjectivesTextPrependEvent args)
|
|
|
|
|
{
|
|
|
|
|
args.Text += "\n" + Loc.GetString("traitor-round-end-codewords", ("codewords", string.Join(", ", comp.Codewords)));
|
2021-12-21 21:23:29 +01:00
|
|
|
}
|
2022-11-03 22:58:19 -04:00
|
|
|
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
/// <summary>
|
|
|
|
|
/// Start this game rule manually
|
|
|
|
|
/// </summary>
|
|
|
|
|
public TraitorRuleComponent StartGameRule()
|
|
|
|
|
{
|
|
|
|
|
var comp = EntityQuery<TraitorRuleComponent>().FirstOrDefault();
|
|
|
|
|
if (comp == null)
|
|
|
|
|
{
|
|
|
|
|
GameTicker.StartGameRule("Traitor", out var ruleEntity);
|
|
|
|
|
comp = Comp<TraitorRuleComponent>(ruleEntity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return comp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void MakeTraitorAdmin(EntityUid entity, bool giveUplink, bool giveObjectives)
|
|
|
|
|
{
|
|
|
|
|
var traitorRule = StartGameRule();
|
|
|
|
|
MakeTraitor(entity, traitorRule, giveUplink, giveObjectives);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string GenerateBriefing(string[] codewords, Note[]? uplinkCode)
|
|
|
|
|
{
|
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
sb.AppendLine(Loc.GetString("traitor-role-greeting"));
|
|
|
|
|
sb.AppendLine(Loc.GetString("traitor-role-codewords-short", ("codewords", string.Join(", ", codewords))));
|
|
|
|
|
if (uplinkCode != null)
|
|
|
|
|
sb.AppendLine(Loc.GetString("traitor-role-uplink-code-short", ("code", string.Join("-", uplinkCode).Replace("sharp", "#"))));
|
|
|
|
|
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-28 16:53:24 -07:00
|
|
|
public List<(EntityUid Id, MindComponent Mind)> GetOtherTraitorMindsAliveAndConnected(MindComponent ourMind)
|
2022-11-03 22:58:19 -04:00
|
|
|
{
|
2023-08-28 16:53:24 -07:00
|
|
|
List<(EntityUid Id, MindComponent Mind)> allTraitors = new();
|
2023-04-25 20:23:14 -04:00
|
|
|
foreach (var traitor in EntityQuery<TraitorRuleComponent>())
|
|
|
|
|
{
|
2023-08-28 16:53:24 -07:00
|
|
|
foreach (var role in GetOtherTraitorMindsAliveAndConnected(ourMind, traitor))
|
2023-04-25 20:23:14 -04:00
|
|
|
{
|
|
|
|
|
if (!allTraitors.Contains(role))
|
|
|
|
|
allTraitors.Add(role);
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-11-03 22:58:19 -04:00
|
|
|
|
2023-04-25 20:23:14 -04:00
|
|
|
return allTraitors;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-28 16:53:24 -07:00
|
|
|
private List<(EntityUid Id, MindComponent Mind)> GetOtherTraitorMindsAliveAndConnected(MindComponent ourMind, TraitorRuleComponent component)
|
2023-04-25 20:23:14 -04:00
|
|
|
{
|
2023-08-28 16:53:24 -07:00
|
|
|
var traitors = new List<(EntityUid Id, MindComponent Mind)>();
|
|
|
|
|
foreach (var traitor in component.TraitorMinds)
|
|
|
|
|
{
|
|
|
|
|
if (TryComp(traitor, out MindComponent? mind) &&
|
|
|
|
|
mind.OwnedEntity != null &&
|
|
|
|
|
mind.Session != null &&
|
|
|
|
|
mind != ourMind &&
|
|
|
|
|
_mobStateSystem.IsAlive(mind.OwnedEntity.Value) &&
|
|
|
|
|
mind.CurrentEntity == mind.OwnedEntity)
|
|
|
|
|
{
|
|
|
|
|
traitors.Add((traitor, mind));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return traitors;
|
2022-11-03 22:58:19 -04:00
|
|
|
}
|
2021-12-21 21:23:29 +01:00
|
|
|
}
|