Thief hotfix (#22976)

* fixes!

* reduced collection amount

* omeeeeega

* pipup

* popup
This commit is contained in:
Ed
2023-12-27 23:42:15 +03:00
committed by GitHub
parent 7d19a323b5
commit 166296b2c5
10 changed files with 77 additions and 57 deletions

View File

@@ -2,11 +2,9 @@ using Content.Server.Chat.Managers;
using Content.Server.GameTicking.Rules.Components;
using Content.Server.Mind;
using Content.Server.Objectives;
using Content.Server.Shuttles.Components;
using Content.Server.Roles;
using Content.Shared.Mind;
using Content.Shared.Objectives.Components;
using Content.Shared.Preferences;
using Content.Shared.Roles;
using Content.Shared.Roles.Jobs;
using Robust.Shared.Player;
@@ -17,24 +15,26 @@ using Content.Shared.Humanoid;
using Content.Server.Antag;
using Robust.Server.Audio;
using Content.Shared.CombatMode.Pacification;
using Content.Shared.Random;
namespace Content.Server.GameTicking.Rules;
public sealed class ThiefRuleSystem : GameRuleSystem<ThiefRuleComponent>
{
[Dependency] private readonly IChatManager _chatManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly AntagSelectionSystem _antagSelection = default!;
[Dependency] private readonly AudioSystem _audio = default!;
[Dependency] private readonly MindSystem _mindSystem = default!;
[Dependency] private readonly SharedRoleSystem _roleSystem = default!;
[Dependency] private readonly SharedJobSystem _jobs = default!;
[Dependency] private readonly ObjectivesSystem _objectives = default!;
const string bigObjectiveGroup = "ThiefBigObjectiveGroups";
const string smallObjectiveGroup = "ThiefObjectiveGroups";
const string escapeObjectiveGroup = "ThiefEscapeObjectiveGroups";
[ValidatePrototypeId<WeightedRandomPrototype>]
const string BigObjectiveGroup = "ThiefBigObjectiveGroups";
[ValidatePrototypeId<WeightedRandomPrototype>]
const string SmallObjectiveGroup = "ThiefObjectiveGroups";
[ValidatePrototypeId<WeightedRandomPrototype>]
const string EscapeObjectiveGroup = "ThiefEscapeObjectiveGroups";
private const float BigObjectiveChance = 0.7f;
public override void Initialize()
@@ -52,24 +52,21 @@ public sealed class ThiefRuleSystem : GameRuleSystem<ThiefRuleComponent>
var query = EntityQueryEnumerator<ThiefRuleComponent, GameRuleComponent>();
while (query.MoveNext(out var uid, out var thief, out var gameRule))
{
//Chance to not lauch gamerule
if (!_random.Prob(thief.RuleChance))
//Chance to not lauch gamerule
if (_random.Prob(thief.RuleChance))
{
RemComp<ThiefRuleComponent>(uid);
continue;
}
if (!GameTicker.IsGameRuleAdded(uid, gameRule))
continue;
foreach (var player in ev.Players)
{
if (!ev.Profiles.ContainsKey(player.UserId))
if (!GameTicker.IsGameRuleAdded(uid, gameRule))
continue;
thief.StartCandidates[player] = ev.Profiles[player.UserId];
foreach (var player in ev.Players)
{
if (!ev.Profiles.TryGetValue(player.UserId, out var profile))
continue;
thief.StartCandidates[player] = profile;
}
DoThiefStart(thief);
}
DoThiefStart(thief);
}
}
@@ -88,19 +85,12 @@ public sealed class ThiefRuleSystem : GameRuleSystem<ThiefRuleComponent>
foreach(var thief in selectedThieves)
{
MakeThief(thief, component.PacifistThieves);
MakeThief(component, thief, component.PacifistThieves);
}
}
public bool MakeThief(ICommonSession thief, bool AddPacified)
public bool MakeThief(ThiefRuleComponent thiefRule, ICommonSession thief, bool addPacified)
{
var thiefRule = EntityQuery<ThiefRuleComponent>().FirstOrDefault();
if (thiefRule == null)
{
GameTicker.StartGameRule("Thief", out var ruleEntity);
thiefRule = Comp<ThiefRuleComponent>(ruleEntity);
}
//checks
if (!_mindSystem.TryGetMind(thief, out var mindId, out var mind))
{
@@ -124,9 +114,12 @@ public sealed class ThiefRuleSystem : GameRuleSystem<ThiefRuleComponent>
PrototypeId = thiefRule.ThiefPrototypeId
});
//Add Pacified
if (AddPacified)
//Add Pacified
//To Do: Long-term this should just be using the antag code to add components.
if (addPacified) //This check is important because some servers may want to disable the thief's pacifism. Do not remove.
{
EnsureComp<PacifiedComponent>(mind.OwnedEntity.Value);
}
// Notificate player about new role assignment
if (_mindSystem.TryGetSession(mindId, out var session))
@@ -140,7 +133,7 @@ public sealed class ThiefRuleSystem : GameRuleSystem<ThiefRuleComponent>
if (_random.Prob(BigObjectiveChance)) // 70% chance to 1 big objective (structure or animal)
{
var objective = _objectives.GetRandomObjective(mindId, mind, bigObjectiveGroup);
var objective = _objectives.GetRandomObjective(mindId, mind, BigObjectiveGroup);
if (objective != null)
{
_mindSystem.AddObjective(mindId, mind, objective.Value);
@@ -150,7 +143,7 @@ public sealed class ThiefRuleSystem : GameRuleSystem<ThiefRuleComponent>
for (var i = 0; i < thiefRule.MaxStealObjectives && thiefRule.MaxObjectiveDifficulty > difficulty; i++) // Many small objectives
{
var objective = _objectives.GetRandomObjective(mindId, mind, smallObjectiveGroup);
var objective = _objectives.GetRandomObjective(mindId, mind, SmallObjectiveGroup);
if (objective == null)
continue;
@@ -159,17 +152,29 @@ public sealed class ThiefRuleSystem : GameRuleSystem<ThiefRuleComponent>
}
//Escape target
var escapeObjective = _objectives.GetRandomObjective(mindId, mind, escapeObjectiveGroup);
var escapeObjective = _objectives.GetRandomObjective(mindId, mind, EscapeObjectiveGroup);
if (escapeObjective != null)
_mindSystem.AddObjective(mindId, mind, escapeObjective.Value);
// Give starting items
_antagSelection.GiveAntagBagGear(mind.OwnedEntity.Value, thiefRule.StarterItems);
thiefRule.ThiefMinds.Add(mindId);
thiefRule.ThievesMinds.Add(mindId);
return true;
}
public void AdminMakeThief(ICommonSession thief, bool addPacified)
{
var thiefRule = EntityQuery<ThiefRuleComponent>().FirstOrDefault();
if (thiefRule == null)
{
GameTicker.StartGameRule("Thief", out var ruleEntity);
thiefRule = Comp<ThiefRuleComponent>(ruleEntity);
}
MakeThief(thiefRule, thief, addPacified);
}
//Add mind briefing
private void OnGetBriefing(Entity<ThiefRoleComponent> thief, ref GetBriefingEvent args)
{
@@ -193,7 +198,7 @@ public sealed class ThiefRuleSystem : GameRuleSystem<ThiefRuleComponent>
private void OnObjectivesTextGetInfo(Entity<ThiefRuleComponent> thiefs, ref ObjectivesTextGetInfoEvent args)
{
args.Minds = thiefs.Comp.ThiefMinds;
args.Minds = thiefs.Comp.ThievesMinds;
args.AgentName = Loc.GetString("thief-round-end-agent-name");
}
}