Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Лютый нёрф фантома #286

Merged
merged 3 commits into from
Aug 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ public bool StartEpidemicHallucinations(EntityUid target, string proto)
return false;

var hallucinations = EnsureComp<HallucinationsDiseaseComponent>(target);
hallucinations.EndTime = _timing.CurTime + TimeSpan.FromSeconds(15);

hallucinations.Proto = prototype;
hallucinations.Spawns = prototype.Entities;
hallucinations.Range = prototype.Range;
Expand Down Expand Up @@ -224,6 +226,12 @@ public override void Update(float frameTime)
var diseaseQuery = EntityQueryEnumerator<HallucinationsDiseaseComponent, TransformComponent>();
while (diseaseQuery.MoveNext(out var uid, out var stat, out var xform))
{
if (_timing.CurTime >= stat.EndTime)
{
RemCompDeferred<HallucinationsDiseaseComponent>(uid);
continue;
}

if (_timing.CurTime < stat.NextSecond)
continue;
var rate = stat.SpawnRate;
Expand Down
169 changes: 100 additions & 69 deletions Content.Server/ADT/Phantom/EntitySystems/PhantomSystem.cs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Content.Server/ADT/Phantom/EntitySystems/VesselSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private void OnShutdown(EntityUid uid, VesselComponent component, ComponentShutd

phantom.Vessels.Remove(uid);
var ev = new RefreshPhantomLevelEvent();
RaiseLocalEvent(component.Phantom, ev);
RaiseLocalEvent(component.Phantom, ref ev);
_phantom.PopulateVesselMenu(component.Phantom);

if (phantom.Holder == uid)
Expand Down Expand Up @@ -104,7 +104,7 @@ private void OnDeleted(EntityUid uid, VesselComponent component, EntityTerminati

phantom.Vessels.Remove(uid);
var ev = new RefreshPhantomLevelEvent();
RaiseLocalEvent(component.Phantom, ev);
RaiseLocalEvent(component.Phantom, ref ev);

if (phantom.Holder == uid)
_phantom.StopHaunt(component.Phantom, uid, phantom);
Expand Down
3 changes: 2 additions & 1 deletion Content.Server/ADT/Phantom/Role/PhantomRuleComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Content.Shared.Random;
using Robust.Shared.Audio;
using Content.Shared.Dataset;
using Content.Shared.Mind;

namespace Content.Server.GameTicking.Rules.Components;

Expand Down Expand Up @@ -63,7 +64,7 @@ public sealed partial class PhantomRuleComponent : Component
[DataField]
public Dictionary<EntityUid, string> OperativeMindPendingData = new();

public EntityUid PhantomMind = new();
public Entity<MindComponent> PhantomMind = new();

[DataField]
public ProtoId<WeightedRandomPrototype> ObjectiveGroup = "PhantomObjectiveGroups";
Expand Down
54 changes: 48 additions & 6 deletions Content.Server/ADT/Phantom/Role/PhantomRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
using Content.Server.Revolutionary.Components;
using Content.Shared.Mind;
using Content.Shared.GameTicking.Components;
using Content.Shared.Stunnable;
using Content.Shared.Damage;

namespace Content.Server.GameTicking.Rules;

Expand All @@ -33,6 +35,8 @@ public sealed class PhantomRuleSystem : GameRuleSystem<PhantomRuleComponent>
[Dependency] private readonly StationSystem _stationSystem = default!;
[Dependency] private readonly EmergencyShuttleSystem _emergencyShuttle = default!;
[Dependency] private readonly ObjectivesSystem _objectives = default!;
[Dependency] private readonly SharedStunSystem _sharedStun = default!;
[Dependency] private readonly DamageableSystem _damage = default!;

private ISawmill _sawmill = default!;

Expand All @@ -46,6 +50,8 @@ public override void Initialize()

SubscribeLocalEvent<PhantomComponent, PhantomDiedEvent>(OnMobStateChanged);
SubscribeLocalEvent<PhantomComponent, MindAddedMessage>(OnMindAdded);
SubscribeLocalEvent<PhantomComponent, PhantomLevelReachedEvent>(OnNewLevelReached);

SubscribeLocalEvent<PhantomTyranyTargetComponent, MobStateChangedEvent>(OnCommandMobStateChanged);

SubscribeLocalEvent<PhantomComponent, PhantomTyranyEvent>(OnTyranyAttempt);
Expand Down Expand Up @@ -101,8 +107,25 @@ protected override void AppendRoundEndText(EntityUid uid, PhantomRuleComponent c
}
}

private void OnMobStateChanged(EntityUid uid, PhantomComponent component, PhantomDiedEvent args)
private void OnMobStateChanged(EntityUid uid, PhantomComponent component, ref PhantomDiedEvent args)
{
foreach (var vessel in component.Vessels)
{
var stunTime = TimeSpan.FromSeconds(4);
RemComp<VesselComponent>(uid);
_sharedStun.TryParalyze(vessel, stunTime, true);
}
foreach (var cursed in component.CursedVessels)
{
var damage = new DamageSpecifier();
damage.DamageDict.Add("Blunt", 200);
damage.DamageDict.Add("Cellular", 200);
_damage.TryChangeDamage(cursed, damage, true);
RemComp<PhantomPuppetComponent>(uid);
}
if (HasComp<PhantomHolderComponent>(component.Holder))
RemCompDeferred<PhantomHolderComponent>(component.Holder);

var ruleQuery = QueryActiveRules();
while (ruleQuery.MoveNext(out _, out _, out var phantom, out _))
{
Expand All @@ -113,7 +136,7 @@ private void OnMobStateChanged(EntityUid uid, PhantomComponent component, Phanto
}
}

private void OnTyranyAttempt(EntityUid uid, PhantomComponent component, PhantomTyranyEvent args)
private void OnTyranyAttempt(EntityUid uid, PhantomComponent component, ref PhantomTyranyEvent args)
{
var ruleQuery = QueryActiveRules();
while (ruleQuery.MoveNext(out _, out _, out var phantom, out _))
Expand All @@ -123,7 +146,7 @@ private void OnTyranyAttempt(EntityUid uid, PhantomComponent component, PhantomT
}
}

private void OnNightmareAttempt(EntityUid uid, PhantomComponent component, PhantomNightmareEvent args)
private void OnNightmareAttempt(EntityUid uid, PhantomComponent component, ref PhantomNightmareEvent args)
{
var ruleQuery = QueryActiveRules();
while (ruleQuery.MoveNext(out _, out _, out var phantom, out _))
Expand All @@ -133,7 +156,7 @@ private void OnNightmareAttempt(EntityUid uid, PhantomComponent component, Phant
}
}

private void OnReincarnation(EntityUid uid, PhantomComponent component, PhantomReincarnatedEvent args)
private void OnReincarnation(EntityUid uid, PhantomComponent component, ref PhantomReincarnatedEvent args)
{
var ruleQuery = QueryActiveRules();
while (ruleQuery.MoveNext(out _, out _, out var phantom, out _))
Expand All @@ -155,9 +178,13 @@ private void OnMindAdded(EntityUid uid, PhantomComponent component, MindAddedMes
while (query.MoveNext(out _, out _, out var nukeops, out _))
{
_roles.MindAddRole(mindId, new PhantomRoleComponent { PrototypeId = "Phantom" });
AddObjectives(mindId, mind, nukeops);
var finObjective = _objectives.GetRandomObjective(mindId, mind, nukeops.FinalObjectiveGroup, 10f);
if (finObjective == null)
return;

_mind.AddObjective(mindId, mind, finObjective.Value);
nukeops.OperativeMindPendingData.Remove(uid);
nukeops.PhantomMind = mindId;
nukeops.PhantomMind = (mindId, mind);
_antagSelection.SendBriefing(mind.Session, Loc.GetString("phantom-welcome"), Color.BlueViolet, component.GreetSoundNotification);

if (mind.Session is not { } playerSession)
Expand All @@ -168,6 +195,21 @@ private void OnMindAdded(EntityUid uid, PhantomComponent component, MindAddedMes
}
}

private void OnNewLevelReached(EntityUid uid, PhantomComponent component, ref PhantomLevelReachedEvent args)
{
var ruleQuery = QueryActiveRules();
while (ruleQuery.MoveNext(out _, out _, out var phantom, out _))
{
var objective = _objectives.GetRandomObjective(phantom.PhantomMind.Owner, phantom.PhantomMind.Comp, phantom.ObjectiveGroup, _cfg.GetCVar(CCVars.PhantomMaxDifficulty));
if (objective == null)
continue;

_mind.AddObjective(phantom.PhantomMind.Owner, phantom.PhantomMind.Comp, objective.Value);
var adding = Comp<ObjectiveComponent>(objective.Value).Difficulty;
Log.Debug($"Added objective {ToPrettyString(objective):objective} with {adding} difficulty");
}
}

private void SetWinType(EntityUid uid, PhantomWinType type, PhantomRuleComponent? component = null, bool endRound = true)
{
if (!Resolve(uid, ref component))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using Robust.Shared.Random;
using Content.Shared.ADT.Phantom.Components;

namespace Content.Server.Objectives.Systems;
namespace Content.Server.Objectives.Systems; // ADT file

/// <summary>
/// Handles kill person condition logic and picking random kill targets.
Expand Down Expand Up @@ -59,9 +59,19 @@ private void OnPersonAssigned(EntityUid uid, PickPhantomImmunePersonComponent co
args.Cancelled = true;
return;
}
var resultList = new List<EntityUid>();

foreach (var item in allHumans) // Don't pick heads because they may be tyrany targets
{
if (_job.MindTryGetJob(item, out _, out var prototype) && prototype.RequireAdminNotify) // Why is it named RequireAdminNotify? Anyway, this checks if this mind is a command staff
continue;
resultList.Add(item);
}
var pickedTarget = _random.Pick(resultList);

if (TryComp<MindComponent>(pickedTarget, out var mind) && mind.OwnedEntity != null)
EnsureComp<PhantomImmuneComponent>(mind.OwnedEntity.Value);

var pickedTarget = _random.Pick(allHumans);
EnsureComp<PhantomImmuneComponent>(pickedTarget);
_target.SetTarget(uid, pickedTarget, target);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
using Robust.Shared.Random;
using Content.Shared.ADT.Phantom.Components;

namespace Content.Server.Objectives.Systems;
namespace Content.Server.Objectives.Systems; // ADT filt

/// <summary>
/// Handles kill person condition logic and picking random kill targets.
/// Handles turning person into a vessel
/// </summary>
public sealed class MakeTargetVesselConditionSystem : EntitySystem
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
using Robust.Shared.Random;
using Content.Shared.ADT.Phantom.Components;

namespace Content.Server.Objectives.Systems;
namespace Content.Server.Objectives.Systems; // ADT file

/// <summary>
/// Handles kill person condition logic and picking random kill targets.
/// Final phantom objective
/// </summary>
public sealed class PhantomNightmareStartedConditionSystem : EntitySystem
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
using Robust.Shared.Random;
using Content.Shared.ADT.Phantom.Components;

namespace Content.Server.Objectives.Systems;
namespace Content.Server.Objectives.Systems; // ADT file

/// <summary>
/// Handles kill person condition logic and picking random kill targets.
/// Final phantom objective
/// </summary>
public sealed class PhantomReincarnateConditionSystem : EntitySystem
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
using Content.Shared.Mobs.Components;
using Content.Server.Revolutionary.Components;

namespace Content.Server.Objectives.Systems;
namespace Content.Server.Objectives.Systems; // ADT file

/// <summary>
/// Handles kill person condition logic and picking random kill targets.
/// Final phantom objective
/// </summary>
public sealed class PhantomTyranyConditionSystem : EntitySystem
{
Expand Down Expand Up @@ -76,6 +76,6 @@ private float GetProgress(EntityUid? uid)
}
}

return Math.Clamp(dead / commandList.Count, 0f, 1f);
return Math.Clamp(dead / commandList.Count, 0f, component.TyranyStarted ? 1f : 0.8f);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public sealed partial class HallucinationsDiseaseComponent : Component
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float CurChance = 0.1f;

[DataField, ViewVariables(VVAccess.ReadWrite)]
public TimeSpan? EndTime;

public List<EntProtoId> Spawns = new();

[DataField]
Expand Down
6 changes: 3 additions & 3 deletions Content.Shared/ADT/Phantom/Components/PhantomComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,6 @@ public sealed partial class PhantomComponent : Component
[ViewVariables(VVAccess.ReadWrite)]
public Container HelpingHand = default!;

[ViewVariables(VVAccess.ReadWrite)]
public bool EpidemicActive = false;

[DataField]
public int HelpingHandDuration = 10;
public int HelpingHandTimer = 0;
Expand All @@ -330,6 +327,9 @@ public sealed partial class PhantomComponent : Component

[DataField]
public bool IgnoreLevels = false;

[DataField]
public int MaxReachedLevel = 0;
#region Finale
[DataField]
public bool FinalAbilityUsed = false;
Expand Down
43 changes: 13 additions & 30 deletions Content.Shared/ADT/Phantom/SharedPhantom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,40 +145,23 @@ public sealed partial class PuppeterDoAfterEvent : SimpleDoAfterEvent
#endregion

#region Events
public sealed class RefreshPhantomLevelEvent : EntityEventArgs
{
public RefreshPhantomLevelEvent()
{
}
}
[ByRefEvent]
public record struct RefreshPhantomLevelEvent();

public sealed class PhantomReincarnatedEvent : EntityEventArgs
{
public PhantomReincarnatedEvent()
{
}
}
[ByRefEvent]
public record struct PhantomReincarnatedEvent();

public sealed class PhantomDiedEvent : EntityEventArgs
{
public PhantomDiedEvent()
{
}
}
[ByRefEvent]
public record struct PhantomDiedEvent();

public sealed class PhantomTyranyEvent : EntityEventArgs
{
public PhantomTyranyEvent()
{
}
}
[ByRefEvent]
public record struct PhantomTyranyEvent();

public sealed class PhantomNightmareEvent : EntityEventArgs
{
public PhantomNightmareEvent()
{
}
}
[ByRefEvent]
public record struct PhantomNightmareEvent();

[ByRefEvent]
public record struct PhantomLevelReachedEvent(int Level);

[DataDefinition]
public sealed partial class EctoplasmHitscanHitEvent : EntityEventArgs
Expand Down
7 changes: 7 additions & 0 deletions Content.Shared/ADT/Phantom/Systems/SharedPhantomSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ public void SelectStyle(EntityUid uid, PhantomComponent component, string style,
if (level > 9 && curseds > 1)
AddFromList(uid, component, proto.Lvl5Actions);
component.CurrentStyle = style;

if (component.MaxReachedLevel < level)
{
var ev = new PhantomLevelReachedEvent(level);
component.MaxReachedLevel = level;
RaiseLocalEvent(uid, ref ev);
}
}

/// <summary>
Expand Down
15 changes: 15 additions & 0 deletions Content.Shared/Revolutionary/SharedRevolutionarySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Robust.Shared.GameStates;
using Robust.Shared.Player;
using Content.Shared.Antag;
using Content.Shared.ADT.Phantom.Components;

namespace Content.Shared.Revolutionary;

Expand Down Expand Up @@ -45,6 +46,20 @@ private void MindShieldImplanted(EntityUid uid, MindShieldComponent comp, MapIni
_sharedStun.TryParalyze(uid, stunTime, true);
_popupSystem.PopupEntity(Loc.GetString("rev-break-control", ("name", name)), uid);
}
// who and why have done it THIS way
// ADT phantom start
if (HasComp<VesselComponent>(uid))
{
if (HasComp<PhantomPuppetComponent>(uid))
RemCompDeferred<MindShieldComponent>(uid);
else
{
var stunTime = TimeSpan.FromSeconds(4);
RemComp<VesselComponent>(uid);
_sharedStun.TryParalyze(uid, stunTime, true);
}
}
// ADT phantom end
}

/// <summary>
Expand Down
Loading
Loading