Files
wwdpublic/Content.Shared/_Goobstation/Religion/WeakToHolySystem.cs
Kai5 ae1c1c39dd Port Devil (#2454)
<!--
This is a semi-strict format, you can add/remove sections as needed but
the order/format should be kept the same
Remove these comments before submitting
-->

<!--
Explain this PR in as much detail as applicable

Some example prompts to consider:
How might this affect the game? The codebase?
What might be some alternatives to this?
How/Who does this benefit/hurt [the game/codebase]?
-->

This PR ports
https://github.com/Goob-Station/Goob-Station/pull/2409
https://github.com/Goob-Station/Goob-Station/pull/2591
https://github.com/Goob-Station/Goob-Station/pull/2599

This PR was initially intended to be merged into White Dream repo, so my
changes are marked as WD edit.

<!--
A list of everything you have to do before this PR is "complete"
You probably won't have to complete everything before merging but it's
good to leave future references
-->

- [ ] Port pain numbness
- [ ] Port nullrods
- [ ] Port tile movement

---

<!--
This is default collapsed, readers click to expand it and see all your
media
The PR media section can get very large at times, so this is a good way
to keep it clean
The title is written using HTML tags
The title must be within the <summary> tags or you won't see it
-->

<details><summary><h1>Media</h1></summary>
<p>

![image](https://github.com/user-attachments/assets/ee4679d1-fc07-4dc3-8063-e0220bc0d728)

![image](https://github.com/user-attachments/assets/25f590b9-6bf3-43bd-aca3-80452f27b0dd)

![image](https://github.com/user-attachments/assets/1ffb5bb3-e0c7-4827-8193-83bd8480e555)

![image](https://github.com/user-attachments/assets/4ed8c762-1e51-4bd8-9800-6495c12ac68f)

</p>
</details>

---

<!--
You can add an author after the `🆑` to change the name that appears
in the changelog (ex: `🆑 Death`)
Leaving it blank will default to your GitHub display name
This includes all available types for the changelog
-->

🆑
- add: Ported Devil antag from Goobstation

---------

Signed-off-by: Kai5 <68296202+Kai518@users.noreply.github.com>
Signed-off-by: VMSolidus <evilexecutive@gmail.com>
Co-authored-by: Solstice <solsticeofthewinter@gmail.com>
Co-authored-by: VMSolidus <evilexecutive@gmail.com>
2025-07-20 13:37:35 +10:00

135 lines
4.5 KiB
C#

// SPDX-FileCopyrightText: 2025 GoobBot <uristmchands@proton.me>
// SPDX-FileCopyrightText: 2025 Solstice <solsticeofthewinter@gmail.com>
// SPDX-FileCopyrightText: 2025 SolsticeOfTheWinter <solsticeofthewinter@gmail.com>
// SPDX-FileCopyrightText: 2025 TheBorzoiMustConsume <197824988+TheBorzoiMustConsume@users.noreply.github.com>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
using Content.Shared._Goobstation.Bible;
using Content.Shared._Goobstation.Religion.Nullrod;
using Content.Server.Bible.Components;
using Content.Shared.Damage;
using Content.Shared.Interaction;
using Content.Shared.Inventory;
using Content.Shared.Timing;
using Robust.Shared.Physics.Events;
using Robust.Shared.Timing;
namespace Content.Shared._Goobstation.Religion;
public sealed class WeakToHolySystem : EntitySystem
{
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly InventorySystem _inventorySystem = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly GoobBibleSystem _goobBible = default!;
[Dependency] private readonly UseDelaySystem _useDelay = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<WeakToHolyComponent, DamageUnholyEvent>(OnUnholyItemDamage);
SubscribeLocalEvent<WeakToHolyComponent, AfterInteractUsingEvent>(AfterBibleUse);
// SubscribeLocalEvent<HereticRitualRuneComponent, StartCollideEvent>(OnCollide);
// SubscribeLocalEvent<HereticRitualRuneComponent, EndCollideEvent>(OnCollideEnd);
SubscribeLocalEvent<DamageableComponent, DamageModifyEvent>(OnDamageModify);
}
private void AfterBibleUse(Entity<WeakToHolyComponent> ent, ref AfterInteractUsingEvent args)
{
if (!TryComp<BibleComponent>(args.Used, out var bibleComp)
|| !TryComp(args.Used, out UseDelayComponent? useDelay)
|| _useDelay.IsDelayed((args.Used, useDelay))
|| !HasComp<BibleUserComponent>(args.User)
|| args.Target is not { } target)
return;
_goobBible.TryDoSmite(target, bibleComp, args, useDelay);
}
#region Holy Damage Dealing
private void OnDamageModify(EntityUid uid, DamageableComponent component, DamageModifyEvent args)
{
var unholyEvent = new DamageUnholyEvent(uid, args.Origin);
RaiseLocalEvent(uid, ref unholyEvent);
var holyCoefficient = 0f; // Default resistance
if (unholyEvent.ShouldTakeHoly)
holyCoefficient = 1f; //Allow holy damage
DamageModifierSet modifierSet = new()
{
Coefficients = new Dictionary<string, float>
{
{ "Holy", holyCoefficient },
},
};
args.Damage = DamageSpecifier.ApplyModifierSet(args.Damage, modifierSet);
}
private void OnUnholyItemDamage(Entity<WeakToHolyComponent> uid, ref DamageUnholyEvent args)
{
if (uid.Comp.AlwaysTakeHoly)
{
args.ShouldTakeHoly = true;
return;
}
foreach (var item in _inventorySystem.GetHandOrInventoryEntities(args.Target, SlotFlags.WITHOUT_POCKET))
{
if (!HasComp<UnholyItemComponent>(item))
continue;
args.ShouldTakeHoly = true;
return;
}
}
#endregion
// #region Heretic Rune Healing
//
// // Passively heal on runes
// private void OnCollide(Entity<HereticRitualRuneComponent> ent, ref StartCollideEvent args)
// {
// if (!TryComp<WeakToHolyComponent>(args.OtherEntity, out var weak))
// return;
//
// weak.IsColliding = true;
// }
//
// private void OnCollideEnd(Entity<HereticRitualRuneComponent> ent, ref EndCollideEvent args)
// {
// if (!TryComp<WeakToHolyComponent>(args.OtherEntity, out var weak))
// return;
//
// weak.IsColliding = false;
// }
//
// public override void Update(float frameTime)
// {
// base.Update(frameTime);
//
// var query = EntityQueryEnumerator<WeakToHolyComponent>();
// while (query.MoveNext(out var uid, out var comp))
// {
// if (comp.NextHealTick > _timing.CurTime || !comp.IsColliding)
// continue;
//
// _damageableSystem.TryChangeDamage(uid, comp.HealAmount);
//
// comp.NextHealTick = _timing.CurTime + comp.HealTickDelay;
// }
// }
//
// #endregion
}