# Conflicts: # Content.Client/Administration/UI/Logs/AdminLogsControl.xaml.cs # Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTab.xaml.cs # Content.Server/Administration/Systems/AdminVerbSystem.Smites.cs # Content.Server/Mindshield/MindShieldSystem.cs # Content.Shared/Gravity/SharedGravitySystem.cs # Content.Shared/Implants/SharedSubdermalImplantSystem.cs # Resources/Locale/en-US/_strings/traits/traits.ftl # Resources/Prototypes/Entities/Clothing/Shoes/misc.yml # Resources/Prototypes/Entities/Objects/Devices/Electronics/door_access.yml # Resources/Prototypes/Entities/Objects/Misc/implanters.yml # Resources/Prototypes/Entities/Objects/Misc/subdermal_implants.yml # Resources/Prototypes/Entities/Objects/Specific/Mech/mechs.yml # Resources/Prototypes/Entities/Objects/Weapons/Throwable/grenades.yml # Resources/Prototypes/Entities/Structures/Doors/Airlocks/airlocks.yml # Resources/Prototypes/Entities/Structures/Machines/surveillance_camera_routers.yml # Resources/Textures/Interface/Misc/job_icons.rsi/meta.json
422 lines
15 KiB
C#
422 lines
15 KiB
C#
using Content.Shared.Popups;
|
|
using Content.Shared.Damage;
|
|
using Content.Shared.Revenant;
|
|
using Robust.Shared.Random;
|
|
using Content.Shared.Tag;
|
|
using Content.Shared.Storage.Components;
|
|
using Content.Server.Light.Components;
|
|
using Content.Server.Ghost;
|
|
using Robust.Shared.Physics;
|
|
using Content.Shared.Doors.Components; // Sunrise-Edit
|
|
using Content.Shared.Throwing;
|
|
using Content.Server.Storage.EntitySystems;
|
|
using Content.Shared.Interaction;
|
|
using Content.Shared.Item;
|
|
using Content.Shared.Bed.Sleep;
|
|
using System.Linq;
|
|
using System.Numerics;
|
|
using Content.Server.Revenant.Components;
|
|
using Content.Shared.Physics;
|
|
using Content.Shared.DoAfter;
|
|
using Content.Shared.Emag.Systems;
|
|
using Content.Shared.FixedPoint;
|
|
using Content.Shared.Humanoid;
|
|
using Content.Shared.Light.Components;
|
|
using Content.Shared.Maps;
|
|
using Content.Shared.Mobs;
|
|
using Content.Shared.Mobs.Components;
|
|
using Content.Shared.Mobs.Systems;
|
|
using Content.Shared.Revenant.Components;
|
|
using Robust.Shared.Physics.Components;
|
|
using Robust.Shared.Utility;
|
|
using Robust.Shared.Map.Components;
|
|
using Content.Shared.Whitelist;
|
|
using Robust.Shared.Prototypes;
|
|
using Content.Server.Doors.Systems; // Sunrise-Edit
|
|
|
|
namespace Content.Server.Revenant.EntitySystems;
|
|
|
|
public sealed partial class RevenantSystem
|
|
{
|
|
[Dependency] private readonly EmagSystem _emagSystem = default!;
|
|
[Dependency] private readonly ThrowingSystem _throwing = default!;
|
|
[Dependency] private readonly EntityStorageSystem _entityStorage = default!;
|
|
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
|
[Dependency] private readonly MobThresholdSystem _mobThresholdSystem = default!;
|
|
[Dependency] private readonly GhostSystem _ghost = default!;
|
|
[Dependency] private readonly TileSystem _tile = default!;
|
|
[Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
|
|
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
|
|
[Dependency] private readonly SharedMapSystem _mapSystem = default!;
|
|
[Dependency] private readonly DoorSystem _doorSystem = default!; // Sunrise-Edit
|
|
|
|
private static readonly ProtoId<TagPrototype> WindowTag = "Window";
|
|
|
|
private void InitializeAbilities()
|
|
{
|
|
SubscribeLocalEvent<RevenantComponent, UserActivateInWorldEvent>(OnInteract);
|
|
SubscribeLocalEvent<RevenantComponent, SoulEvent>(OnSoulSearch);
|
|
SubscribeLocalEvent<RevenantComponent, HarvestEvent>(OnHarvest);
|
|
|
|
SubscribeLocalEvent<RevenantComponent, RevenantDefileActionEvent>(OnDefileAction);
|
|
SubscribeLocalEvent<RevenantComponent, RevenantOverloadLightsActionEvent>(OnOverloadLightsAction);
|
|
SubscribeLocalEvent<RevenantComponent, RevenantBlightActionEvent>(OnBlightAction);
|
|
SubscribeLocalEvent<RevenantComponent, RevenantMalfunctionActionEvent>(OnMalfunctionAction);
|
|
SubscribeLocalEvent<RevenantComponent, RevenantLockActionEvent>(OnLockAction); // Sunrise-Edit
|
|
SubscribeLocalEvent<RevenantComponent, RevenantDrainActionEvent>(OnDrainAction); // Sunrise-Edit
|
|
}
|
|
|
|
private void OnInteract(EntityUid uid, RevenantComponent component, UserActivateInWorldEvent args)
|
|
{
|
|
if (args.Handled)
|
|
return;
|
|
|
|
if (args.Target == args.User)
|
|
return;
|
|
var target = args.Target;
|
|
|
|
if (HasComp<PoweredLightComponent>(target))
|
|
{
|
|
args.Handled = _ghost.DoGhostBooEvent(target);
|
|
return;
|
|
}
|
|
|
|
if (!HasComp<MobStateComponent>(target) || !HasComp<HumanoidAppearanceComponent>(target) || HasComp<RevenantComponent>(target))
|
|
return;
|
|
|
|
args.Handled = true;
|
|
if (!TryComp<EssenceComponent>(target, out var essence) || !essence.SearchComplete)
|
|
{
|
|
EnsureComp<EssenceComponent>(target);
|
|
BeginSoulSearchDoAfter(uid, target, component);
|
|
}
|
|
else
|
|
{
|
|
BeginHarvestDoAfter(uid, target, component, essence);
|
|
}
|
|
|
|
args.Handled = true;
|
|
}
|
|
|
|
private void BeginSoulSearchDoAfter(EntityUid uid, EntityUid target, RevenantComponent revenant)
|
|
{
|
|
var searchDoAfter = new DoAfterArgs(EntityManager, uid, revenant.SoulSearchDuration, new SoulEvent(), uid, target: target)
|
|
{
|
|
BreakOnMove = true,
|
|
BreakOnDamage = true,
|
|
DistanceThreshold = 2
|
|
};
|
|
|
|
if (!_doAfter.TryStartDoAfter(searchDoAfter))
|
|
return;
|
|
|
|
_popup.PopupEntity(Loc.GetString("revenant-soul-searching", ("target", target)), uid, uid, PopupType.Medium);
|
|
}
|
|
|
|
private void OnSoulSearch(EntityUid uid, RevenantComponent component, SoulEvent args)
|
|
{
|
|
if (args.Handled || args.Cancelled)
|
|
return;
|
|
|
|
if (!TryComp<EssenceComponent>(args.Args.Target, out var essence))
|
|
return;
|
|
essence.SearchComplete = true;
|
|
|
|
string message;
|
|
switch (essence.EssenceAmount)
|
|
{
|
|
case <= 45:
|
|
message = "revenant-soul-yield-low";
|
|
break;
|
|
case >= 90:
|
|
message = "revenant-soul-yield-high";
|
|
break;
|
|
default:
|
|
message = "revenant-soul-yield-average";
|
|
break;
|
|
}
|
|
_popup.PopupEntity(Loc.GetString(message, ("target", args.Args.Target)), args.Args.Target.Value, uid, PopupType.Medium);
|
|
|
|
args.Handled = true;
|
|
}
|
|
|
|
private void BeginHarvestDoAfter(EntityUid uid, EntityUid target, RevenantComponent revenant, EssenceComponent essence)
|
|
{
|
|
if (essence.Harvested)
|
|
{
|
|
_popup.PopupEntity(Loc.GetString("revenant-soul-harvested"), target, uid, PopupType.SmallCaution);
|
|
return;
|
|
}
|
|
|
|
if (TryComp<MobStateComponent>(target, out var mobstate) && mobstate.CurrentState == MobState.Alive && !HasComp<SleepingComponent>(target))
|
|
{
|
|
_popup.PopupEntity(Loc.GetString("revenant-soul-too-powerful"), target, uid);
|
|
return;
|
|
}
|
|
|
|
if(_physics.GetEntitiesIntersectingBody(uid, (int) CollisionGroup.Impassable).Count > 0)
|
|
{
|
|
_popup.PopupEntity(Loc.GetString("revenant-in-solid"), uid, uid);
|
|
return;
|
|
}
|
|
|
|
var doAfter = new DoAfterArgs(EntityManager, uid, revenant.HarvestDebuffs.X, new HarvestEvent(), uid, target: target)
|
|
{
|
|
DistanceThreshold = 2,
|
|
BreakOnMove = true,
|
|
BreakOnDamage = true,
|
|
RequireCanInteract = false, // stuns itself
|
|
};
|
|
|
|
if (!_doAfter.TryStartDoAfter(doAfter))
|
|
return;
|
|
|
|
_appearance.SetData(uid, RevenantVisuals.Harvesting, true);
|
|
|
|
_popup.PopupEntity(Loc.GetString("revenant-soul-begin-harvest", ("target", target)),
|
|
target, PopupType.Large);
|
|
|
|
TryUseAbility(uid, revenant, 0, revenant.HarvestDebuffs);
|
|
}
|
|
|
|
private void OnHarvest(EntityUid uid, RevenantComponent component, HarvestEvent args)
|
|
{
|
|
if (args.Cancelled)
|
|
{
|
|
_appearance.SetData(uid, RevenantVisuals.Harvesting, false);
|
|
return;
|
|
}
|
|
|
|
if (args.Handled || args.Args.Target == null)
|
|
return;
|
|
|
|
_appearance.SetData(uid, RevenantVisuals.Harvesting, false);
|
|
|
|
if (!TryComp<EssenceComponent>(args.Args.Target, out var essence))
|
|
return;
|
|
|
|
_popup.PopupEntity(Loc.GetString("revenant-soul-finish-harvest", ("target", args.Args.Target)),
|
|
args.Args.Target.Value, PopupType.LargeCaution);
|
|
|
|
essence.Harvested = true;
|
|
ChangeEssenceAmount(uid, essence.EssenceAmount, component);
|
|
_store.TryAddCurrency(new Dictionary<string, FixedPoint2>
|
|
{ {component.StolenEssenceCurrencyPrototype, essence.EssenceAmount} }, uid);
|
|
|
|
if (!HasComp<MobStateComponent>(args.Args.Target))
|
|
return;
|
|
|
|
if (_mobState.IsAlive(args.Args.Target.Value) || _mobState.IsCritical(args.Args.Target.Value))
|
|
{
|
|
_popup.PopupEntity(Loc.GetString("revenant-max-essence-increased"), uid, uid);
|
|
component.EssenceRegenCap += component.MaxEssenceUpgradeAmount;
|
|
}
|
|
|
|
//KILL THEMMMM
|
|
|
|
if (!_mobThresholdSystem.TryGetThresholdForState(args.Args.Target.Value, MobState.Dead, out var damage))
|
|
return;
|
|
DamageSpecifier dspec = new();
|
|
dspec.DamageDict.Add("Cold", damage.Value);
|
|
_damage.TryChangeDamage(args.Args.Target, dspec, true, origin: uid);
|
|
|
|
args.Handled = true;
|
|
}
|
|
|
|
private void OnDefileAction(EntityUid uid, RevenantComponent component, RevenantDefileActionEvent args)
|
|
{
|
|
if (args.Handled)
|
|
return;
|
|
|
|
if (!TryUseAbility(uid, component, component.DefileCost, component.DefileDebuffs))
|
|
return;
|
|
|
|
args.Handled = true;
|
|
|
|
var xform = Transform(uid);
|
|
if (!TryComp<MapGridComponent>(xform.GridUid, out var map))
|
|
return;
|
|
var tiles = _mapSystem.GetTilesIntersecting(
|
|
xform.GridUid.Value,
|
|
map,
|
|
Box2.CenteredAround(_transformSystem.GetWorldPosition(xform),
|
|
new Vector2(component.DefileRadius * 2, component.DefileRadius)))
|
|
.ToArray();
|
|
|
|
_random.Shuffle(tiles);
|
|
|
|
for (var i = 0; i < component.DefileTilePryAmount; i++)
|
|
{
|
|
if (!tiles.TryGetValue(i, out var value))
|
|
continue;
|
|
_tile.PryTile(value);
|
|
}
|
|
|
|
var lookup = _lookup.GetEntitiesInRange(uid, component.DefileRadius, LookupFlags.Approximate | LookupFlags.Static);
|
|
var tags = GetEntityQuery<TagComponent>();
|
|
var entityStorage = GetEntityQuery<EntityStorageComponent>();
|
|
var items = GetEntityQuery<ItemComponent>();
|
|
var lights = GetEntityQuery<PoweredLightComponent>();
|
|
|
|
foreach (var ent in lookup)
|
|
{
|
|
//break windows
|
|
if (tags.HasComponent(ent) && _tag.HasTag(ent, WindowTag))
|
|
{
|
|
//hardcoded damage specifiers til i die.
|
|
var dspec = new DamageSpecifier();
|
|
dspec.DamageDict.Add("Structural", 60);
|
|
_damage.TryChangeDamage(ent, dspec, origin: uid);
|
|
}
|
|
|
|
if (!_random.Prob(component.DefileEffectChance))
|
|
continue;
|
|
|
|
//randomly opens some lockers and such.
|
|
if (entityStorage.TryGetComponent(ent, out var entstorecomp))
|
|
_entityStorage.OpenStorage(ent, entstorecomp);
|
|
|
|
//chucks shit
|
|
if (items.HasComponent(ent) &&
|
|
TryComp<PhysicsComponent>(ent, out var phys) && phys.BodyType != BodyType.Static)
|
|
_throwing.TryThrow(ent, _random.NextAngle().ToWorldVec());
|
|
|
|
//flicker lights
|
|
if (lights.HasComponent(ent))
|
|
_ghost.DoGhostBooEvent(ent);
|
|
}
|
|
}
|
|
|
|
private void OnOverloadLightsAction(EntityUid uid, RevenantComponent component, RevenantOverloadLightsActionEvent args)
|
|
{
|
|
if (args.Handled)
|
|
return;
|
|
|
|
if (!TryUseAbility(uid, component, component.OverloadCost, component.OverloadDebuffs))
|
|
return;
|
|
|
|
args.Handled = true;
|
|
|
|
var xform = Transform(uid);
|
|
var poweredLights = GetEntityQuery<PoweredLightComponent>();
|
|
var mobState = GetEntityQuery<MobStateComponent>();
|
|
var lookup = _lookup.GetEntitiesInRange(uid, component.OverloadRadius);
|
|
//TODO: feels like this might be a sin and a half
|
|
foreach (var ent in lookup)
|
|
{
|
|
if (!mobState.HasComponent(ent) || !_mobState.IsAlive(ent))
|
|
continue;
|
|
|
|
var nearbyLights = _lookup.GetEntitiesInRange(ent, component.OverloadZapRadius)
|
|
.Where(e => poweredLights.HasComponent(e) && !HasComp<RevenantOverloadedLightsComponent>(e) &&
|
|
_interact.InRangeUnobstructed(e, uid, -1)).ToArray();
|
|
|
|
if (!nearbyLights.Any())
|
|
continue;
|
|
|
|
//get the closest light
|
|
var allLight = nearbyLights.OrderBy(e =>
|
|
Transform(e).Coordinates.TryDistance(EntityManager, xform.Coordinates, out var dist) ? component.OverloadZapRadius : dist);
|
|
var comp = EnsureComp<RevenantOverloadedLightsComponent>(allLight.First());
|
|
comp.Target = ent; //who they gon fire at?
|
|
}
|
|
}
|
|
|
|
private void OnBlightAction(EntityUid uid, RevenantComponent component, RevenantBlightActionEvent args)
|
|
{
|
|
if (args.Handled)
|
|
return;
|
|
|
|
if (!TryUseAbility(uid, component, component.BlightCost, component.BlightDebuffs))
|
|
return;
|
|
|
|
args.Handled = true;
|
|
// TODO: When disease refactor is in.
|
|
}
|
|
|
|
// Sunrise-Start
|
|
private void OnLockAction(EntityUid uid, RevenantComponent component, RevenantLockActionEvent args)
|
|
{
|
|
if (args.Handled)
|
|
return;
|
|
|
|
if (!TryUseAbility(uid, component, component.MalfunctionCost, component.LockDebuffs))
|
|
return;
|
|
|
|
args.Handled = true;
|
|
|
|
foreach (var ent in _lookup.GetEntitiesInRange(uid, component.MalfunctionRadius))
|
|
{
|
|
if (TryComp<DoorComponent>(ent, out var doorComp) && TryComp<DoorBoltComponent>(ent, out var boltsComp))
|
|
{
|
|
if (!boltsComp.BoltWireCut)
|
|
_doorSystem.SetBoltsDown((ent, boltsComp), true, uid);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void OnDrainAction(EntityUid uid, RevenantComponent component, RevenantDrainActionEvent args)
|
|
{
|
|
if (args.Handled)
|
|
return;
|
|
|
|
if (!TryUseAbility(uid, component, 0, component.DrainDebuffs))
|
|
return;
|
|
|
|
args.Handled = true;
|
|
|
|
var lookup = _lookup.GetEntitiesInRange(uid, component.DrainRadius);
|
|
|
|
float totalEssence = 0;
|
|
|
|
var min = Math.Min(component.DrainDamageMin, component.DrainDamageMax);
|
|
var max = Math.Max(component.DrainDamageMin, component.DrainDamageMax);
|
|
|
|
foreach (var target in lookup)
|
|
{
|
|
if (target == uid || !_mobState.IsAlive(target))
|
|
continue;
|
|
|
|
var amount = _random.Next(min, max + 1);
|
|
|
|
var damage = new DamageSpecifier();
|
|
damage.DamageDict.Add(component.DrainDamageType, amount);
|
|
|
|
if (_damage.TryChangeDamage(target, damage, origin: uid) != null)
|
|
totalEssence += amount;
|
|
}
|
|
|
|
if (totalEssence > 0)
|
|
{
|
|
_store.TryAddCurrency(new()
|
|
{
|
|
{ component.StolenEssenceCurrencyPrototype, (FixedPoint2)(totalEssence * component.StolenEssenceCurrencyRate) }
|
|
}, uid);
|
|
|
|
component.Essence += (FixedPoint2)(totalEssence * component.EssenceGainRate);
|
|
if (component.Essence > component.EssenceRegenCap)
|
|
component.Essence = component.EssenceRegenCap;
|
|
}
|
|
}
|
|
// Sunrise-End
|
|
|
|
private void OnMalfunctionAction(EntityUid uid, RevenantComponent component, RevenantMalfunctionActionEvent args)
|
|
{
|
|
if (args.Handled)
|
|
return;
|
|
|
|
if (!TryUseAbility(uid, component, component.MalfunctionCost, component.MalfunctionDebuffs))
|
|
return;
|
|
|
|
args.Handled = true;
|
|
|
|
foreach (var ent in _lookup.GetEntitiesInRange(uid, component.MalfunctionRadius))
|
|
{
|
|
if (_whitelistSystem.IsWhitelistFail(component.MalfunctionWhitelist, ent) ||
|
|
_whitelistSystem.IsBlacklistPass(component.MalfunctionBlacklist, ent))
|
|
continue;
|
|
|
|
_emagSystem.TryEmagEffect(uid, uid, ent);
|
|
}
|
|
}
|
|
}
|