Новая цель на убийство других антагонистов

This commit is contained in:
Vigers Ray 2025-01-04 02:11:42 +03:00
parent 8c8561c348
commit cb17bfcefe
8 changed files with 100 additions and 11 deletions

View file

@ -0,0 +1,8 @@
using Content.Server.Objectives.Systems;
namespace Content.Server.Objectives.Components;
[RegisterComponent, Access(typeof(KillPersonConditionSystem))]
public sealed partial class PickRandomAntagComponent : Component
{
}

View file

@ -8,6 +8,8 @@ using Content.Shared.Mind;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Objectives.Components;
using Content.Shared.Random.Helpers;
using Content.Shared.Roles;
using Robust.Shared.Configuration;
using Robust.Shared.Random;
@ -24,6 +26,7 @@ public sealed class KillPersonConditionSystem : EntitySystem
[Dependency] private readonly SharedMindSystem _mind = default!;
[Dependency] private readonly TargetObjectiveSystem _target = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly SharedRoleSystem _roleSystem = default!;
public override void Initialize()
{
@ -34,6 +37,8 @@ public sealed class KillPersonConditionSystem : EntitySystem
SubscribeLocalEvent<PickRandomPersonComponent, ObjectiveAssignedEvent>(OnPersonAssigned);
SubscribeLocalEvent<PickRandomHeadComponent, ObjectiveAssignedEvent>(OnHeadAssigned);
SubscribeLocalEvent<PickRandomAntagComponent, ObjectiveAssignedEvent>(OnAntagAssigned);
}
private void OnGetProgress(EntityUid uid, KillPersonConditionComponent comp, ref ObjectiveGetProgressEvent args)
@ -75,7 +80,7 @@ public sealed class KillPersonConditionSystem : EntitySystem
return;
}
_target.SetTarget(uid, _random.Pick(allHumans), target);
_target.SetTarget(uid, args.MindId, _random.Pick(allHumans), target);
}
private void OnHeadAssigned(EntityUid uid, PickRandomHeadComponent comp, ref ObjectiveAssignedEvent args)
@ -109,7 +114,41 @@ public sealed class KillPersonConditionSystem : EntitySystem
if (allHeads.Count == 0)
allHeads = allHumans; // fallback to non-head target
_target.SetTarget(uid, _random.Pick(allHeads), target);
_target.SetTarget(uid, args.MindId, _random.Pick(allHeads), target);
}
private void OnAntagAssigned(EntityUid uid, PickRandomAntagComponent comp, ref ObjectiveAssignedEvent args)
{
if (!TryComp<TargetObjectiveComponent>(uid, out var target))
{
args.Cancelled = true;
return;
}
if (target.Target != null)
return;
var allHumans = GetAliveTargetsExcept(args.MindId);
if (allHumans.Count == 0)
{
args.Cancelled = true;
return;
}
var allAntags = new HashSet<Entity<MindComponent>>();
foreach (var person in allHumans)
{
if (_roleSystem.MindIsAntagonist(person))
allAntags.Add(person);
}
if (allAntags.Count == 0)
{
args.Cancelled = true;
return;
}
_target.SetTarget(uid, args.MindId, _random.Pick(allAntags), target);
}
private float GetProgress(EntityUid target, bool requireDead)
@ -148,9 +187,11 @@ public sealed class KillPersonConditionSystem : EntitySystem
var allTargets = new HashSet<Entity<MindComponent>>();
var query = EntityQueryEnumerator<MobStateComponent, AntagTargetComponent, HumanoidAppearanceComponent>();
while (query.MoveNext(out var uid, out var mobState, out _, out _))
while (query.MoveNext(out var uid, out var mobState, out var antagTarget, out _))
{
if (!_mind.TryGetMind(uid, out var mind, out var mindComp) || mind == exclude || !_mobState.IsAlive(uid, mobState))
if (!_mind.TryGetMind(uid, out var mind, out var mindComp) ||
mind == exclude || !_mobState.IsAlive(uid, mobState) ||
antagTarget.KillerMind != null)
continue;
allTargets.Add(new Entity<MindComponent>(mind, mindComp));

View file

@ -4,6 +4,7 @@ using Content.Shared.Objectives.Components;
using Content.Shared.Roles.Jobs;
using Robust.Shared.GameObjects;
using System.Diagnostics.CodeAnalysis;
using Content.Server._Sunrise.TraitorTarget;
namespace Content.Server.Objectives.Systems;
@ -33,11 +34,16 @@ public sealed class TargetObjectiveSystem : EntitySystem
/// <summary>
/// Sets the Target field for the title and other components to use.
/// </summary>
public void SetTarget(EntityUid uid, EntityUid target, TargetObjectiveComponent? comp = null)
public void SetTarget(EntityUid uid, EntityUid mindId, EntityUid target, TargetObjectiveComponent? comp = null)
{
if (!Resolve(uid, ref comp))
return;
if (TryComp<AntagTargetComponent>(target, out var antagTargetCom))
{
antagTargetCom.KillerMind = mindId;
}
comp.Target = target;
}

View file

@ -3,5 +3,6 @@ namespace Content.Server._Sunrise.TraitorTarget
[RegisterComponent]
public sealed partial class AntagTargetComponent : Component
{
public EntityUid? KillerMind;
}
}

View file

@ -9407,3 +9407,20 @@
type: Fix
id: 654
time: '2025-01-03T09:01:31.287837+00:00'
- author: VigersRay
changes:
- message: "\u0412\u0435\u0440\u043D\u0443\u043B \u0446\u0435\u043B\u0438 \u043D\
\u0430 \u0445\u0430\u0439\u0434\u0436\u0435\u043A \u0438 \u0441\u043B\u0430\u0432\
\u043D\u0443\u044E \u0441\u043C\u0435\u0440\u0442\u044C \u0430\u0433\u0435\u043D\
\u0442\u0430\u043C."
type: Tweak
- message: "\u0414\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u0430 \u043D\u043E\u0432\
\u0430\u044F \u0446\u0435\u043B\u044C \u043D\u0430 \u0443\u0431\u0438\u0439\u0441\
\u0442\u0432\u043E \u0430\u0433\u0435\u043D\u0442\u0430\u043C."
type: Add
- message: "\u0412\u0435\u0440\u043D\u0443\u043B \u0446\u0435\u043B\u044C \u043D\
\u0430 \u0434\u0438\u0441\u043A \u044F\u0434\u0435\u0440\u043A\u0438 \u0430\u0433\
\u0435\u043D\u0442\u0430\u043C."
type: Tweak
id: 655
time: '2025-01-03T23:11:33.964746+00:00'

View file

@ -0,0 +1 @@
objective-condition-kill-antag-title = Убить { $targetName }, должность: { CAPITALIZE($job) }.

View file

@ -3,7 +3,7 @@
id: TraitorObjectiveGroups
weights:
TraitorObjectiveGroupSteal: 1
TraitorObjectiveGroupKill: 0.5 # Sunrise-Edit: Меньше убийств - меньше гостов.
TraitorObjectiveGroupKill: 1
TraitorObjectiveGroupState: 1 #As in, something about your character. Alive, dead, arrested, gained an ability...
TraitorObjectiveGroupSocial: 1 #Involves helping/harming others without killing them or stealing their stuff
@ -14,11 +14,11 @@
CMOHyposprayStealObjective: 1
#CMOCrewMonitorStealObjective: 1 # Sunrise-Edit: Больше не хайриск
RDHardsuitStealObjective: 1
#NukeDiskStealObjective: 1 # Sunrise-Edit: Цель требует убить слишком много людей.
NukeDiskStealObjective: 1
MagbootsStealObjective: 1
CorgiMeatStealObjective: 1
ClipboardStealObjective: 1
CaptainGunStealObjective: 0.2 # Sunrise-Edit: Чтобы его украсть капитана прийдется убить.
CaptainGunStealObjective: 0.5
CaptainJetpackStealObjective: 0.5
HandTeleporterStealObjective: 0.5
EnergyShotgunStealObjective: 0.5
@ -32,15 +32,16 @@
- type: weightedRandom
id: TraitorObjectiveGroupKill
weights:
KillRandomPersonObjective: 1
KillRandomAntagObjective: 1
KillRandomPersonObjective: 0.5
KillRandomHeadObjective: 0.25
- type: weightedRandom
id: TraitorObjectiveGroupState
weights:
EscapeShuttleObjective: 1
#DieObjective: 0.02 # Почему-то трейторы думают что умереть = убить как можно больше.
#HijackShuttleObjective: 0.02 # Нам незачем разрешать рдм в не рдм режиме.
DieObjective: 0.05
HijackShuttleObjective: 0.03
- type: weightedRandom
id: TraitorObjectiveGroupSocial

View file

@ -98,6 +98,20 @@
# if ce flies a shittle to centcom you better find a way onto it
requireDead: true
- type: entity
parent: [BaseTraitorObjective, BaseKillObjective]
id: KillRandomAntagObjective
description:
components:
- type: Objective
difficulty: 1.0
unique: true
- type: TargetObjective
title: objective-condition-kill-antag-title
- type: PickRandomAntag
- type: KillPersonCondition
requireDead: true
# social
- type: entity