Files
wwdpublic/Content.Server/_Goobstation/Devil/DevilSystem.Actions.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

118 lines
4.2 KiB
C#

// SPDX-FileCopyrightText: 2025 GoobBot <uristmchands@proton.me>
// SPDX-FileCopyrightText: 2025 Solstice <solsticeofthewinter@gmail.com>
// SPDX-FileCopyrightText: 2025 SolsticeOfTheWinter <solsticeofthewinter@gmail.com>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
using Content.Server._Goobstation.Devil.Contract;
using Content.Server._Goobstation.Devil.Contract.Revival;
using Content.Server._Goobstation.Devil.Grip;
using Content.Shared._Goobstation.Devil;
using Content.Shared._Goobstation.Devil.Actions;
using Content.Shared._Goobstation.Devil.Condemned;
using Content.Shared._Goobstation.Devil.Contract;
using Content.Shared.IdentityManagement;
namespace Content.Server._Goobstation.Devil;
public sealed partial class DevilSystem
{
private void SubscribeAbilities()
{
SubscribeLocalEvent<DevilComponent, CreateContractEvent>(OnContractCreated);
SubscribeLocalEvent<DevilComponent, CreateRevivalContractEvent>(OnRevivalContractCreated);
SubscribeLocalEvent<DevilComponent, ShadowJauntEvent>(OnShadowJaunt);
SubscribeLocalEvent<DevilComponent, DevilGripEvent>(OnDevilGrip);
SubscribeLocalEvent<DevilComponent, DevilPossessionEvent>(OnPossess);
}
private void OnContractCreated(Entity<DevilComponent> devil, ref CreateContractEvent args)
{
if (!TryUseAbility(args))
return;
var contract = Spawn(devil.Comp.ContractPrototype, Transform(devil).Coordinates);
_hands.TryPickupAnyHand(devil, contract);
if (!TryComp<DevilContractComponent>(contract, out var contractComponent))
return;
contractComponent.ContractOwner = args.Performer;
PlayFwooshSound(devil);
DoContractFlavor(devil, Identity.Name(devil, EntityManager));
}
private void OnRevivalContractCreated(Entity<DevilComponent> devil, ref CreateRevivalContractEvent args)
{
if (!TryUseAbility(args))
return;
var contract = Spawn(devil.Comp.RevivalContractPrototype, Transform(devil).Coordinates);
_hands.TryPickupAnyHand(devil, contract);
if (!TryComp<RevivalContractComponent>(contract, out var contractComponent))
return;
contractComponent.ContractOwner = args.Performer;
PlayFwooshSound(devil);
DoContractFlavor(devil, Identity.Name(devil, EntityManager));
}
private void OnShadowJaunt(Entity<DevilComponent> devil, ref ShadowJauntEvent args)
{
if (!TryUseAbility(args))
return;
Spawn(devil.Comp.JauntAnimationProto, Transform(devil).Coordinates);
Spawn(devil.Comp.PentagramEffectProto, Transform(devil).Coordinates);
_poly.PolymorphEntity(devil, devil.Comp.JauntEntityProto);
}
private void OnDevilGrip(Entity<DevilComponent> devil, ref DevilGripEvent args)
{
if (!TryUseAbility(args))
return;
if (devil.Comp.DevilGrip != null)
{
foreach (var item in _hands.EnumerateHeld(devil))
{
if (HasComp<DevilGripComponent>(item))
QueueDel(item);
}
}
var grasp = Spawn(devil.Comp.GripPrototype, Transform(devil).Coordinates);
if (!_hands.TryPickupAnyHand(devil, grasp))
QueueDel(grasp);
devil.Comp.DevilGrip = args.Action.Owner;
}
private void OnPossess(Entity<DevilComponent> devil, ref DevilPossessionEvent args)
{
if (!TryComp<CondemnedComponent>(args.Target, out var condemned) || condemned.SoulOwnedNotDevil)
{
var message = Loc.GetString("invalid-possession-target");
_popup.PopupEntity(message, devil, devil);
return;
}
if (!TryUseAbility(args))
return;
if (devil.Comp.PowerLevel != DevilPowerLevel.None)
devil.Comp.PossessionDuration *= (int)devil.Comp.PowerLevel;
if (_possession.TryPossessTarget(args.Target, args.Performer, devil.Comp.PossessionDuration, true, polymorphPossessor: true))
{
Spawn(devil.Comp.JauntAnimationProto, Transform(args.Target).Coordinates);
Spawn(devil.Comp.PentagramEffectProto, Transform(args.Target).Coordinates);
}
}
}