Skip to content

Commit

Permalink
Port PR188 changes directly
Browse files Browse the repository at this point in the history
  • Loading branch information
vaketola committed Nov 6, 2023
1 parent 08ea21b commit dab0059
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 33 deletions.
4 changes: 2 additions & 2 deletions Content.Server/Magic/MagicSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -396,12 +396,12 @@ private void SpawnSpellHelper(List<EntitySpawnEntry> entityEntries, EntityCoordi

#endregion

public void Speak(BaseActionEvent args)
public void Speak(BaseActionEvent args, bool showInChat = true)
{
if (args is not ISpeakSpell speak || string.IsNullOrWhiteSpace(speak.Speech))
return;

_chat.TrySendInGameICMessage(args.Performer, Loc.GetString(speak.Speech),
InGameICChatType.Speak, false);
InGameICChatType.Speak, !showInChat);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ public sealed partial class ShadowkinTeleportEvent : WorldTargetActionEvent, ISp


[DataField("powerCost")]
public float PowerCost = 35f;
public float PowerCost = 40f;

[DataField("staminaCost")]
public float StaminaCost = 30f;
public float StaminaCost = 20f;


[DataField("speech")]
Expand Down Expand Up @@ -49,13 +49,13 @@ public sealed partial class ShadowkinDarkSwapEvent : InstantActionEvent, ISpeakS
/// How much stamina to drain when darkening.
/// </summary>
[DataField("powerCostOn")]
public float PowerCostOn = 45f;
public float PowerCostOn = 60f;

/// <summary>
/// How much stamina to drain when lightening.
/// </summary>
[DataField("powerCostOff")]
public float PowerCostOff = 35f;
public float PowerCostOff = 45f;

/// <summary>
/// How much stamina to drain when darkening.
Expand All @@ -71,12 +71,17 @@ public sealed partial class ShadowkinDarkSwapEvent : InstantActionEvent, ISpeakS


[DataField("speech")]
public string? Speech { get; }
public string? Speech { get; set; }
}

public sealed class ShadowkinDarkSwapAttemptEvent : CancellableEntityEventArgs
{
EntityUid Performer;

public ShadowkinDarkSwapAttemptEvent(EntityUid performer)
{
Performer = performer;
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private void Rest(EntityUid uid, ShadowkinRestPowerComponent component, Shadowki
// No waking up normally (it would do nothing)
_actions.RemoveAction(args.Performer, new InstantAction(_prototype.Index<InstantActionPrototype>("Wake")));

_power.TryAddMultiplier(args.Performer, 1f);
_power.TryAddMultiplier(args.Performer, 1.5f);
// No action cooldown
args.Handled = false;
}
Expand All @@ -66,7 +66,7 @@ private void Rest(EntityUid uid, ShadowkinRestPowerComponent component, Shadowki
// Wake up
_entity.RemoveComponent<ForcedSleepingComponent>(args.Performer);
_entity.RemoveComponent<SleepingComponent>(args.Performer);
_power.TryAddMultiplier(args.Performer, -1f);
_power.TryAddMultiplier(args.Performer, -1.5f);
// Action cooldown
args.Handled = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private void Teleport(EntityUid uid, ShadowkinTeleportPowerComponent component,
pulledTransform.AttachToGridOrMap();

// Resume pulling
// TODO: This does nothing?
// TODO: This does nothing? // This does things sometimes, but the client never knows
_pulling.TryStartPull(puller, pullable);
}

Expand All @@ -99,7 +99,7 @@ private void Teleport(EntityUid uid, ShadowkinTeleportPowerComponent component,
_stamina.TakeStaminaDamage(args.Performer, args.StaminaCost);

// Speak
_magic.Speak(args);
_magic.Speak(args, false);

args.Handled = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,32 +179,24 @@ public override void Update(float frameTime)

private void ForceDarkSwap(EntityUid uid, ShadowkinComponent component)
{
// Add/Remove DarkSwapped component, which will handle the rest
// Add/Remove the component, which should handle the rest
if (_entity.HasComponent<ShadowkinDarkSwappedComponent>(uid))
{
RaiseNetworkEvent(new ShadowkinDarkSwappedEvent(uid, false));
_entity.RemoveComponent<ShadowkinDarkSwappedComponent>(uid);
}
else
{
RaiseNetworkEvent(new ShadowkinDarkSwappedEvent(uid, true));
_entity.EnsureComponent<ShadowkinDarkSwappedComponent>(uid);
}
_entity.AddComponent<ShadowkinDarkSwappedComponent>(uid);
}

private void ForceTeleport(EntityUid uid, ShadowkinComponent component)
{
// Create the event we'll later raise, and set it to our Shadowkin.
var args = new ShadowkinTeleportEvent
{
Performer = uid
};
var args = new ShadowkinTeleportEvent { Performer = uid };

// Pick a random location on the map until we find one that can be reached.
var coords = Transform(uid).Coordinates;
EntityCoordinates? target = null;

for (var i = 8; i != 0; i--) // It'll iterate up to 8 times, shrinking in distance each time, and if it doesn't find a valid location, it'll return.
// It'll iterate up to 8 times, shrinking in distance each time, and if it doesn't find a valid location, it'll return.
for (var i = 8; i != 0; i--)
{
var angle = Angle.FromDegrees(_random.Next(360));
var offset = new Vector2((float) (i * Math.Cos(angle)), (float) (i * Math.Sin(angle)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public float PowerLevel
/// How much energy is gained per second.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
public float PowerLevelGain = 2f;
public float PowerLevelGain = 0.75f;

/// <summary>
/// Power gain multiplier
Expand Down
16 changes: 8 additions & 8 deletions Resources/Prototypes/SimpleStation14/Magic/shadowkin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
id: ShadowkinTeleport
name: action-name-shadowkin-teleport
description: action-description-shadowkin-teleport
useDelay: 2
useDelay: 5
range: 32
itemIconStyle: NoItem
checkCanAccess: true
Expand All @@ -12,25 +12,25 @@
sprite: SimpleStation14/Interface/Actions/shadowkin_icons.rsi
state: teleport
serverEvent: !type:ShadowkinTeleportEvent
powerCost: 35
staminaCost: 15
powerCost: 40
staminaCost: 20
speech: action-description-shadowkin-teleport

- type: instantAction
id: ShadowkinDarkSwap
name: action-name-shadowkin-darkswap
description: action-description-shadowkin-darkswap
useDelay: 3
useDelay: 15
itemIconStyle: NoItem
priority: -21
icon:
sprite: SimpleStation14/Interface/Actions/shadowkin_icons.rsi
state: darkswap
serverEvent: !type:ShadowkinDarkSwapEvent
powerCostOn: 55
powerCostOff: 40
staminaCostOn: 0
staminaCostOff: 0
powerCostOn: 60
powerCostOff: 45
staminaCostOn: 25
staminaCostOff: 25
speech: action-description-shadowkin-darkswap

- type: instantAction
Expand Down

0 comments on commit dab0059

Please sign in to comment.