Skip to content

Commit

Permalink
Shadowkin fixes (real) (#189)
Browse files Browse the repository at this point in the history
# Media (woah!)

### Critical/Dead Shadowkin are returned from The Dark.


https://github.com/Simple-Station/Parkstation/assets/77995199/20a078ae-efeb-4718-9375-6d44cffca92e

### Critical Shadowkin will not gain power or activate any powers
randomly.


https://github.com/Simple-Station/Parkstation/assets/77995199/809aa5fa-9952-437d-909a-5ab78be089d2

### Cuffed Shadowkin will not be able to use powers, random or
otherwise.


https://github.com/Simple-Station/Parkstation/assets/77995199/9e829ca9-afa6-4b59-9f1c-723f1d970457

### Being a super tired Shadowkin won't make you sleep so hard that you
wake up.


https://github.com/Simple-Station/Parkstation/assets/77995199/e428ea3b-9351-47cc-9e6e-73a8188f781f


# Changelog

:cl:
- fix: Critical/Dead Shadowkin are returned from The Dark.
- tweak: Critical Shadowkin will not gain power or activate any powers
randomly.
- tweak: Cuffed Shadowkin will not be able to use powers, random or
otherwise.
- tweak: More lights are affected by Shadowkin Darkening.
- fix: Shadowkin should no longer randomly lose the ability to use their
powers.
- fix: Being a super tired Shadowkin won't make you sleep so hard that
you wake up.
  • Loading branch information
DEATHB4DEFEAT authored Jul 29, 2023
1 parent 8b0cffd commit 93633b1
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Content.Shared.Actions;
using Content.Shared.Actions.ActionTypes;
using Content.Shared.CombatMode.Pacification;
using Content.Shared.Cuffs.Components;
using Content.Shared.Damage.Systems;
using Content.Shared.SimpleStation14.Species.Shadowkin.Components;
using Content.Shared.SimpleStation14.Species.Shadowkin.Events;
Expand All @@ -30,14 +31,10 @@ public sealed class ShadowkinDarkSwapSystem : EntitySystem
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly MagicSystem _magic = default!;

private InstantAction _action = default!;

public override void Initialize()
{
base.Initialize();

_action = new InstantAction(_prototype.Index<InstantActionPrototype>("ShadowkinDarkSwap"));

SubscribeLocalEvent<ShadowkinDarkSwapPowerComponent, ComponentStartup>(Startup);
SubscribeLocalEvent<ShadowkinDarkSwapPowerComponent, ComponentShutdown>(Shutdown);

Expand All @@ -50,17 +47,27 @@ public override void Initialize()

private void Startup(EntityUid uid, ShadowkinDarkSwapPowerComponent component, ComponentStartup args)
{
_actions.AddAction(uid, _action, uid);
_actions.AddAction(uid, new InstantAction(_prototype.Index<InstantActionPrototype>("ShadowkinDarkSwap")), null);
}

private void Shutdown(EntityUid uid, ShadowkinDarkSwapPowerComponent component, ComponentShutdown args)
{
_actions.RemoveAction(uid, _action);
_actions.RemoveAction(uid, new InstantAction(_prototype.Index<InstantActionPrototype>("ShadowkinDarkSwap")));
}


private void DarkSwap(EntityUid uid, ShadowkinDarkSwapPowerComponent component, ShadowkinDarkSwapEvent args)
{
// Need power to drain power
if (!_entity.HasComponent<ShadowkinComponent>(args.Performer))
return;

// Don't activate abilities if handcuffed
// TODO: Something like the Psionic Headcage to disable powers for Shadowkin
if (_entity.HasComponent<HandcuffComponent>(args.Performer))
return;


var hasComp = _entity.HasComponent<ShadowkinDarkSwappedComponent>(args.Performer);

SetDarkened(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public override void Update(float frameTime)
if (!_entity.TryGetComponent(light, out ShadowkinLightComponent? shadowkinLight))
continue;
// Not powered, undo changes
if (!_entity.TryGetComponent(light, out PoweredLightComponent? powered) || !powered.On)
if (_entity.TryGetComponent(light, out PoweredLightComponent? powered) && !powered.On)
{
ResetLight(pointLight, shadowkinLight);
continue;
Expand All @@ -98,10 +98,10 @@ public override void Update(float frameTime)
shadowkin.DarkenedLights.Remove(light);
continue;
}
// 10% chance to remove the attached entity so it can become another Shadowkin's light
// 3% chance to remove the attached entity so it can become another Shadowkin's light
if (shadowkinLight.AttachedEntity == uid)
{
if (_random.Prob(0.1f))
if (_random.Prob(0.03f))
shadowkinLight.AttachedEntity = EntityUid.Invalid;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Content.Shared.Actions;
using Content.Shared.Actions.ActionTypes;
using Content.Shared.Bed.Sleep;
using Content.Shared.Cuffs.Components;
using Content.Shared.SimpleStation14.Species.Shadowkin.Components;
using Robust.Shared.Prototypes;

Expand All @@ -15,14 +16,10 @@ public sealed class ShadowkinRestSystem : EntitySystem
[Dependency] private readonly SharedActionsSystem _actions = default!;
[Dependency] private readonly ShadowkinPowerSystem _power = default!;

private InstantAction _action = default!;

public override void Initialize()
{
base.Initialize();

_action = new InstantAction(_prototype.Index<InstantActionPrototype>("ShadowkinRest"));

SubscribeLocalEvent<ShadowkinRestPowerComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<ShadowkinRestPowerComponent, ComponentShutdown>(OnShutdown);

Expand All @@ -32,19 +29,26 @@ public override void Initialize()

private void OnStartup(EntityUid uid, ShadowkinRestPowerComponent component, ComponentStartup args)
{
_actions.AddAction(uid, _action, uid);
_actions.AddAction(uid, new InstantAction(_prototype.Index<InstantActionPrototype>("ShadowkinRest")), null);
}

private void OnShutdown(EntityUid uid, ShadowkinRestPowerComponent component, ComponentShutdown args)
{
_actions.RemoveAction(uid, _action);
_actions.RemoveAction(uid, new InstantAction(_prototype.Index<InstantActionPrototype>("ShadowkinRest")));
}

private void Rest(EntityUid uid, ShadowkinRestPowerComponent component, ShadowkinRestEvent args)
{
// Need power to modify power
if (!_entity.HasComponent<ShadowkinComponent>(args.Performer))
return;

// Rest is a funny ability, keep it :)
// // Don't activate abilities if handcuffed
// if (_entity.HasComponent<HandcuffComponent>(args.Performer))
// return;


// Now doing what you weren't before
component.IsResting = !component.IsResting;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Content.Server.SimpleStation14.Species.Shadowkin.Events;
using Content.Shared.Actions;
using Content.Shared.Actions.ActionTypes;
using Content.Shared.Cuffs.Components;
using Content.Shared.Damage.Systems;
using Content.Shared.Pulling.Components;
using Content.Shared.SimpleStation14.Species.Shadowkin.Components;
Expand All @@ -24,14 +25,10 @@ public sealed class ShadowkinTeleportSystem : EntitySystem
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly MagicSystem _magic = default!;

private WorldTargetAction _action = default!;

public override void Initialize()
{
base.Initialize();

_action = new WorldTargetAction(_prototype.Index<WorldTargetActionPrototype>("ShadowkinTeleport"));

SubscribeLocalEvent<ShadowkinTeleportPowerComponent, ComponentStartup>(Startup);
SubscribeLocalEvent<ShadowkinTeleportPowerComponent, ComponentShutdown>(Shutdown);

Expand All @@ -41,19 +38,24 @@ public override void Initialize()

private void Startup(EntityUid uid, ShadowkinTeleportPowerComponent component, ComponentStartup args)
{
_actions.AddAction(uid, _action, uid);
_actions.AddAction(uid, new WorldTargetAction(_prototype.Index<WorldTargetActionPrototype>("ShadowkinTeleport")), null);
}

private void Shutdown(EntityUid uid, ShadowkinTeleportPowerComponent component, ComponentShutdown args)
{
_actions.RemoveAction(uid, _action);
_actions.RemoveAction(uid, new WorldTargetAction(_prototype.Index<WorldTargetActionPrototype>("ShadowkinTeleport")));
}


private void Teleport(EntityUid uid, ShadowkinTeleportPowerComponent component, ShadowkinTeleportEvent args)
{
if (args.Handled ||
!_entity.TryGetComponent<ShadowkinComponent>(args.Performer, out var comp))
// Need power to drain power
if (!_entity.TryGetComponent<ShadowkinComponent>(args.Performer, out var comp))
return;

// Don't activate abilities if handcuffed
// TODO: Something like the Psionic Headcage to disable powers for Shadowkin
if (_entity.HasComponent<HandcuffComponent>(args.Performer))
return;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using Content.Server.Mind;
using Content.Server.Mind.Components;
using Content.Server.SimpleStation14.Species.Shadowkin.Events;
using Content.Shared.Bed.Sleep;
using Content.Shared.Cuffs.Components;
using Content.Shared.Examine;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
Expand Down Expand Up @@ -89,14 +91,21 @@ public override void Update(float frameTime)
// Update power level for all shadowkin
while (query.MoveNext(out var uid, out var shadowkin))
{
// Skip if the shadowkin is dead or catatonic
// Ensure dead or critical shadowkin aren't swapped, skip them
if (_mobState.IsDead(uid) ||
!_entity.System<MindSystem>().TryGetMind(uid, out var mind) ||
_mobState.IsCritical(uid))
{
_entity.RemoveComponent<ShadowkinDarkSwappedComponent>(uid);
continue;
}

// Don't update things for ssd shadowkin
if (!_entity.System<MindSystem>().TryGetMind(uid, out var mind) ||
mind.Session == null)
continue;

var oldPowerLevel = _power.GetLevelName(shadowkin.PowerLevel);

var oldPowerLevel = _power.GetLevelName(shadowkin.PowerLevel);
_power.TryUpdatePowerLevel(uid, frameTime);

if (oldPowerLevel != _power.GetLevelName(shadowkin.PowerLevel))
Expand All @@ -107,6 +116,12 @@ public override void Update(float frameTime)
// I can't figure out how to get this to go to the 100% filled state in the above if statement 😢
_power.UpdateAlert(uid, true, shadowkin.PowerLevel);


// Don't randomly activate abilities if handcuffed
// TODO: Something like the Psionic Headcage to disable powers for Shadowkin
if (_entity.HasComponent<HandcuffComponent>(uid))
continue;

#region MaxPower
// Check if they're at max power
if (shadowkin.PowerLevel >= ShadowkinComponent.PowerThresholds[ShadowkinPowerThreshold.Max])
Expand Down Expand Up @@ -149,7 +164,9 @@ public override void Update(float frameTime)
(
ShadowkinComponent.PowerThresholds[ShadowkinPowerThreshold.Tired] +
ShadowkinComponent.PowerThresholds[ShadowkinPowerThreshold.Okay]
) / 2f
) / 2f &&
// Don't sleep if asleep
!_entity.HasComponent<SleepingComponent>(uid)
)
{
// If so, start the timer
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Objects/Devices/pda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
icon: { sprite: Objects/Tools/flashlight.rsi, state: flashlight }
iconOn: Objects/Tools/flashlight.rsi/flashlight-on.png
event: !type:ToggleActionEvent
- type: ShadowkinLight
- type: PointLight
enabled: false
radius: 1.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
sprite: Objects/Misc/Lights/lights.rsi
size: 20
heldPrefix: off
- type: ShadowkinLight
- type: PointLight
enabled: false
radius: 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
map: [ "light" ]
- type: Item
sprite: Objects/Tools/flashlight.rsi
- type: ShadowkinLight
- type: PointLight
enabled: false
mask: /Textures/Effects/LightMasks/cone.png
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- state: on
map: ["enum.PoweredLightLayers.Base"]
state: on
- type: ShadowkinLight
- type: PointLight
radius: 10
energy: 0.8
Expand Down Expand Up @@ -107,7 +108,6 @@
components:
- type: Sprite
state: off
- type: ShadowkinLight
- type: PointLight
enabled: true
- type: PoweredLight
Expand Down

0 comments on commit 93633b1

Please sign in to comment.