Revenant stuff (#110)
* - add: Chaplain cult shield immune. * - add: Revenant stuff.
This commit is contained in:
97
Content.Server/Revenant/EntitySystems/BlightSystem.cs
Normal file
97
Content.Server/Revenant/EntitySystems/BlightSystem.cs
Normal file
@@ -0,0 +1,97 @@
|
||||
using Content.Server.Bed.Sleep;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Revenant.Components;
|
||||
using Content.Shared.Bed.Sleep;
|
||||
using Content.Shared.Mobs;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.Revenant.EntitySystems;
|
||||
|
||||
public sealed class BlightSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SleepingSystem _sleeping = default!;
|
||||
[Dependency] private readonly PopupSystem _popup = default!;
|
||||
[Dependency] private readonly MobStateSystem _mobState = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<BlightComponent, MobStateChangedEvent>(OnMobStateChanged);
|
||||
SubscribeLocalEvent<BlightComponent, ComponentStartup>(OnStartup);
|
||||
SubscribeLocalEvent<BlightComponent, ComponentShutdown>(OnShutdown);
|
||||
}
|
||||
|
||||
private void OnShutdown(Entity<BlightComponent> ent, ref ComponentShutdown args)
|
||||
{
|
||||
if (!Deleted(ent) && !EntityManager.IsQueuedForDeletion(ent) && _mobState.IsAlive(ent))
|
||||
_popup.PopupEntity("Вы вновь чувствуете себя здоровым.", ent, ent);
|
||||
}
|
||||
|
||||
private void OnStartup(Entity<BlightComponent> ent, ref ComponentStartup args)
|
||||
{
|
||||
SetDelay(ent.Comp);
|
||||
SetDuration(ent.Comp);
|
||||
}
|
||||
|
||||
private void OnMobStateChanged(Entity<BlightComponent> ent, ref MobStateChangedEvent args)
|
||||
{
|
||||
RemCompDeferred<BlightComponent>(ent);
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
|
||||
var query = EntityQueryEnumerator<BlightComponent>();
|
||||
var sleepingQuery = GetEntityQuery<SleepingComponent>();
|
||||
|
||||
while (query.MoveNext(out var ent, out var blight))
|
||||
{
|
||||
blight.Duration += frameTime;
|
||||
|
||||
if (blight.Duration >= blight.MaxDuration.TotalSeconds)
|
||||
{
|
||||
RemCompDeferred<BlightComponent>(ent);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sleepingQuery.HasComponent(ent))
|
||||
{
|
||||
if (blight.BedSleep)
|
||||
{
|
||||
blight.SleepDelay += frameTime;
|
||||
if (blight.SleepDelay >= blight.SleepingCureTime.TotalSeconds)
|
||||
RemCompDeferred<BlightComponent>(ent);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
blight.BedSleep = false;
|
||||
blight.SleepDelay = 0f;
|
||||
|
||||
blight.Delay += frameTime;
|
||||
|
||||
if (blight.Delay < blight.MaxDelay.TotalSeconds)
|
||||
continue;
|
||||
|
||||
_sleeping.TrySleeping(ent);
|
||||
|
||||
blight.Delay = 0f;
|
||||
SetDelay(blight);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetDuration(BlightComponent comp)
|
||||
{
|
||||
comp.MaxDuration = TimeSpan.FromSeconds(_random.Next(300, 420));
|
||||
}
|
||||
|
||||
private void SetDelay(BlightComponent comp)
|
||||
{
|
||||
comp.MaxDelay = TimeSpan.FromSeconds(_random.Next(10, 30));
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ using Content.Shared.Item;
|
||||
using Content.Shared.Bed.Sleep;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Content.Server.Bible.Components;
|
||||
using Content.Server.Maps;
|
||||
using Content.Server.Revenant.Components;
|
||||
using Content.Shared.DoAfter;
|
||||
@@ -25,6 +26,7 @@ using Content.Shared.Maps;
|
||||
using Content.Shared.Mobs;
|
||||
using Content.Shared.Mobs.Components;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using Content.Shared.Physics;
|
||||
using Content.Shared.Revenant.Components;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Utility;
|
||||
@@ -52,8 +54,19 @@ public sealed partial class RevenantSystem
|
||||
SubscribeLocalEvent<RevenantComponent, RevenantOverloadLightsActionEvent>(OnOverloadLightsAction);
|
||||
SubscribeLocalEvent<RevenantComponent, RevenantBlightActionEvent>(OnBlightAction);
|
||||
SubscribeLocalEvent<RevenantComponent, RevenantMalfunctionActionEvent>(OnMalfunctionAction);
|
||||
|
||||
SubscribeLocalEvent<RevenantComponent, DoAfterAttemptEvent<HarvestEvent>>(OnHarvestAttempt); // WD
|
||||
}
|
||||
|
||||
// WD START
|
||||
private void OnHarvestAttempt(Entity<RevenantComponent> ent, ref DoAfterAttemptEvent<HarvestEvent> args)
|
||||
{
|
||||
var target = args.DoAfter.Args.Target;
|
||||
if (target != null && _mobState.IsAlive(target.Value) && !HasComp<SleepingComponent>(target.Value))
|
||||
args.Cancel();
|
||||
}
|
||||
// WD END
|
||||
|
||||
private void OnInteract(EntityUid uid, RevenantComponent component, InteractNoHandEvent args)
|
||||
{
|
||||
if (args.Target == args.User || args.Target == null)
|
||||
@@ -137,12 +150,25 @@ public sealed partial class RevenantSystem
|
||||
return;
|
||||
}
|
||||
|
||||
// WD START
|
||||
var tileref = Transform(uid).Coordinates.GetTileRef();
|
||||
if (tileref != null)
|
||||
{
|
||||
if(_physics.GetEntitiesIntersectingBody(uid, (int) CollisionGroup.Impassable).Count > 0)
|
||||
{
|
||||
_popup.PopupEntity(Loc.GetString("revenant-in-solid"), uid, uid);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// WD END
|
||||
|
||||
var doAfter = new DoAfterArgs(EntityManager, uid, revenant.HarvestDebuffs.X, new HarvestEvent(), uid, target: target)
|
||||
{
|
||||
DistanceThreshold = 2,
|
||||
BreakOnUserMove = true,
|
||||
BreakOnDamage = true,
|
||||
RequireCanInteract = false, // stuns itself
|
||||
AttemptFrequency = AttemptFrequency.EveryTick // WD EDIT
|
||||
};
|
||||
|
||||
if (!_doAfter.TryStartDoAfter(doAfter))
|
||||
@@ -306,6 +332,19 @@ public sealed partial class RevenantSystem
|
||||
return;
|
||||
|
||||
args.Handled = true;
|
||||
|
||||
// WD START
|
||||
var query = GetEntityQuery<BibleUserComponent>();
|
||||
foreach (var e in _lookup.GetEntitiesInRange(uid, component.BlightRadius))
|
||||
{
|
||||
if (!_mobState.IsAlive(e) || query.HasComponent(e))
|
||||
continue;
|
||||
|
||||
var blight = EnsureComp<BlightComponent>(e);
|
||||
blight.Duration = 0f;
|
||||
}
|
||||
// WD END
|
||||
|
||||
// TODO: When disease refactor is in.
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using Content.Server.Actions;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.Store.Components;
|
||||
using Content.Server.Store.Systems;
|
||||
using Content.Shared._White.Chaplain;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.DoAfter;
|
||||
@@ -19,6 +20,8 @@ using Content.Shared.Revenant.Components;
|
||||
using Content.Shared.StatusEffect;
|
||||
using Content.Shared.Stunnable;
|
||||
using Content.Shared.Tag;
|
||||
using Content.Shared.Weapons.Melee;
|
||||
using Content.Shared.Weapons.Melee.Events;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
@@ -62,9 +65,21 @@ public sealed partial class RevenantSystem : EntitySystem
|
||||
SubscribeLocalEvent<RevenantComponent, StatusEffectEndedEvent>(OnStatusEnded);
|
||||
SubscribeLocalEvent<RoundEndTextAppendEvent>(_ => MakeVisible(true));
|
||||
|
||||
SubscribeLocalEvent<RevenantComponent, AttackedEvent>(OnAttacked); // WD EDIT
|
||||
|
||||
InitializeAbilities();
|
||||
}
|
||||
|
||||
// WD START
|
||||
private void OnAttacked(Entity<RevenantComponent> ent, ref AttackedEvent args)
|
||||
{
|
||||
if (!HasComp<HolyWeaponComponent>(args.Used) || !TryComp(args.Used, out MeleeWeaponComponent? weapon))
|
||||
return;
|
||||
|
||||
args.BonusDamage = weapon.Damage;
|
||||
}
|
||||
// WD END
|
||||
|
||||
private void OnStartup(EntityUid uid, RevenantComponent component, ComponentStartup args)
|
||||
{
|
||||
//update the icon
|
||||
|
||||
Reference in New Issue
Block a user