Revenant stuff (#110)

* - add: Chaplain cult shield immune.

* - add: Revenant stuff.
This commit is contained in:
Aviu00
2024-02-24 01:06:24 +09:00
committed by GitHub
parent 6d26bf8e5d
commit a411d14461
10 changed files with 225 additions and 29 deletions

View File

@@ -1,4 +1,5 @@
using Content.Server.Popups;
using Content.Server.Revenant.Components;
using Content.Server.Sound.Components;
using Content.Shared.Actions;
using Content.Shared.Audio;
@@ -93,12 +94,14 @@ namespace Content.Server.Bed.Sleep
private void OnSleepAction(EntityUid uid, MobStateComponent component, SleepActionEvent args)
{
TrySleeping(uid);
if (TrySleeping(uid) && TryComp(uid, out BlightComponent? blight)) // WD EDIT
blight.BedSleep = true;
}
private void OnBedSleepAction(EntityUid uid, ActionsContainerComponent component, SleepActionEvent args)
{
TrySleeping(args.Performer);
if (TrySleeping(args.Performer) && TryComp(args.Performer, out BlightComponent? blight)) // WD EDIT
blight.BedSleep = true;
}
private void OnWakeAction(EntityUid uid, MobStateComponent component, WakeActionEvent args)

View File

@@ -3,6 +3,7 @@ using Content.Server.Ghost.Roles.Components;
using Content.Server.Ghost.Roles.Events;
using Content.Server.Popups;
using Content.Server._White.Other.CustomFluffSystems.merkka;
using Content.Server.Revenant.Components;
using Content.Shared.ActionBlocker;
using Content.Shared.Actions;
using Content.Shared.Bible;
@@ -117,6 +118,21 @@ namespace Content.Server.Bible
return;
}
// WD START
if (HasComp<BlightComponent>(args.Target.Value))
{
var othersMessage = Loc.GetString(component.LocPrefix + "-blight-success-others", ("user", Identity.Entity(args.User, EntityManager)), ("target", Identity.Entity(args.Target.Value, EntityManager)), ("bible", uid));
_popupSystem.PopupEntity(othersMessage, args.User, Filter.PvsExcept(args.User), true, PopupType.Medium);
var selfMessage = Loc.GetString(component.LocPrefix + "-blight-success-self", ("target", Identity.Entity(args.Target.Value, EntityManager)), ("bible", uid));
_popupSystem.PopupEntity(selfMessage, args.User, args.User, PopupType.Large);
_audio.PlayPvs(component.HealSoundPath, args.User);
_delay.TryResetDelay((uid, useDelay));
RemCompDeferred<BlightComponent>(args.Target.Value);
return;
}
// WD END
// This only has a chance to fail if the target is not wearing anything on their head and is not a familiar.
if (!_invSystem.TryGetSlotEntity(args.Target.Value, "head", out var _) && !HasComp<FamiliarComponent>(args.Target.Value))
{

View File

@@ -0,0 +1,26 @@
namespace Content.Server.Revenant.Components;
[RegisterComponent]
public sealed partial class BlightComponent : Component
{
[ViewVariables(VVAccess.ReadWrite)]
public TimeSpan MaxDuration;
[ViewVariables(VVAccess.ReadWrite)]
public float Duration;
[ViewVariables(VVAccess.ReadWrite)]
public TimeSpan MaxDelay;
[ViewVariables(VVAccess.ReadWrite)]
public float Delay;
[ViewVariables(VVAccess.ReadWrite)]
public TimeSpan SleepingCureTime = TimeSpan.FromSeconds(25);
[ViewVariables(VVAccess.ReadWrite)]
public float SleepDelay;
[ViewVariables]
public bool BedSleep;
}

View 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));
}
}

View File

@@ -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.
}

View File

@@ -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

View File

@@ -1,6 +1,7 @@
using Content.Server.Hands.Systems;
using Content.Server.Stunnable;
using Content.Server._White.Cult.Items.Components;
using Content.Shared._White.Chaplain;
using Content.Shared.Mobs.Components;
using Content.Shared.Throwing;
using Content.Shared._White.Cult;
@@ -30,12 +31,9 @@ public sealed class ReturnItemOnThrowSystem : EntitySystem
if (!HasComp<MobStateComponent>(args.Target))
return;
if (!_stun.IsParalyzed(args.Target))
if (!_stun.IsParalyzed(args.Target) && !isCultist && !HasComp<HolyComponent>(args.Target))
{
if (!isCultist)
{
_stun.TryParalyze(args.Target, TimeSpan.FromSeconds(component.StunTime), true);
}
_stun.TryParalyze(args.Target, TimeSpan.FromSeconds(component.StunTime), true);
}
_hands.PickupOrDrop(thrower, uid);

View File

@@ -0,0 +1,2 @@
bible-blight-success-self = Вы ударяете { $target } с помощью { $bible }, и его недуг рассеивается во вспышке святого света!
bible-blight-success-others = { CAPITALIZE($user) } ударяет { $target } с помощью { $bible }, и его недуг рассеивается во вспышке святого света!

View File

@@ -30,16 +30,16 @@
event: !type:RevenantOverloadLightsActionEvent
useDelay: 20
#- type: entity
# id: ActionRevenantBlight
# name: Blight
# description: Costs 50 Essence.
# noSpawn: true
# components:
# - type: InstantAction
# icon: Interface/Actions/blight.png
# event: !type:RevenantBlightActionEvent
# useDelay: 20
- type: entity
id: ActionRevenantBlight
name: Blight
description: Costs 50 Essence.
noSpawn: true
components:
- type: InstantAction
icon: Interface/Actions/blight.png
event: !type:RevenantBlightActionEvent
useDelay: 20
- type: entity
id: ActionRevenantMalfunction

View File

@@ -24,18 +24,18 @@
- !type:ListingLimitedStockCondition
stock: 1
#- type: listing
# id: RevenantBlight
# name: Blight
# description: Infects all nearby organisms with an infectious disease that causes toxic buildup and tiredness. Using it leaves you vulnerable to attacks for a medium period of time.
# productAction: ActionRevenantBlight
# cost:
# StolenEssence: 75
# categories:
# - RevenantAbilities
# conditions:
# - !type:ListingLimitedStockCondition
# stock: 1
- type: listing
id: RevenantBlight
name: Blight
description: Infects all nearby organisms with an infectious disease that causes toxic buildup and tiredness. Using it leaves you vulnerable to attacks for a medium period of time.
productAction: ActionRevenantBlight
cost:
StolenEssence: 75
categories:
- RevenantAbilities
conditions:
- !type:ListingLimitedStockCondition
stock: 1
- type: listing
id: RevenantMalfunction