Skip to content

Commit

Permalink
Merge branch 'master' into existingitems
Browse files Browse the repository at this point in the history
  • Loading branch information
Aidenkrz authored Dec 23, 2024
2 parents a01b11f + 9dd7491 commit ad30fb3
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 1 deletion.
14 changes: 14 additions & 0 deletions Content.Server/Damage/Components/DamageOtherOnHitComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,19 @@ public sealed partial class DamageOtherOnHitComponent : Component
[ViewVariables(VVAccess.ReadWrite)]
public DamageSpecifier Damage = default!;

[DataField("damageMultiplierOverTime")]
[ViewVariables(VVAccess.ReadWrite)]
public float DamageMultiplierOverTime = 1f;

[DataField("timeTillMaxDamage")]
[ViewVariables(VVAccess.ReadWrite)]
public float TimeTillMaxDamage = 0f;

[ViewVariables(VVAccess.ReadOnly)]
public TimeSpan TimeThrown = TimeSpan.Zero;

[ViewVariables(VVAccess.ReadOnly)]
public TimeSpan TimeToMaxDamage = TimeSpan.Zero;

}
}
20 changes: 19 additions & 1 deletion Content.Server/Damage/Systems/DamageOtherOnHitSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Content.Shared.Wires;
using Robust.Shared.Physics.Components;
using Robust.Shared.Player;
using Robust.Shared.Timing;

namespace Content.Server.Damage.Systems
{
Expand All @@ -24,20 +25,30 @@ public sealed class DamageOtherOnHitSystem : EntitySystem
[Dependency] private readonly DamageExamineSystem _damageExamine = default!;
[Dependency] private readonly SharedCameraRecoilSystem _sharedCameraRecoil = default!;
[Dependency] private readonly SharedColorFlashEffectSystem _color = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;

public override void Initialize()
{
SubscribeLocalEvent<DamageOtherOnHitComponent, ThrowDoHitEvent>(OnDoHit);
SubscribeLocalEvent<DamageOtherOnHitComponent, DamageExamineEvent>(OnDamageExamine);
SubscribeLocalEvent<DamageOtherOnHitComponent, AttemptPacifiedThrowEvent>(OnAttemptPacifiedThrow);
SubscribeLocalEvent<DamageOtherOnHitComponent, ThrownEvent>(OnThrow);
}

private void OnDoHit(EntityUid uid, DamageOtherOnHitComponent component, ThrowDoHitEvent args)
{
if (TerminatingOrDeleted(args.Target))
return;

var dmg = _damageable.TryChangeDamage(args.Target, component.Damage, component.IgnoreResistances, origin: args.Component.Thrower);
var currentTime = _gameTiming.CurTime;
var timeSinceThrown = (currentTime - component.TimeThrown).TotalSeconds;
float scaleFactor = MathHelper.Clamp((float)(timeSinceThrown / component.TimeTillMaxDamage), 0f, 1f);

var scaledDamage = new DamageSpecifier();
foreach (var (damageType, baseDamage) in component.Damage.DamageDict)
scaledDamage.DamageDict[damageType] = baseDamage * (1f - scaleFactor) + baseDamage * component.DamageMultiplierOverTime * scaleFactor;

var dmg = _damageable.TryChangeDamage(args.Target, scaledDamage, component.IgnoreResistances, origin: args.Component.Thrower);

// Log damage only for mobs. Useful for when people throw spears at each other, but also avoids log-spam when explosions send glass shards flying.
if (dmg != null && HasComp<MobStateComponent>(args.Target))
Expand Down Expand Up @@ -68,5 +79,12 @@ private void OnAttemptPacifiedThrow(Entity<DamageOtherOnHitComponent> ent, ref A
{
args.Cancel("pacified-cannot-throw");
}

private void OnThrow(EntityUid uid, DamageOtherOnHitComponent component, ref ThrownEvent args)
{
component.TimeThrown = _gameTiming.CurTime;
component.TimeToMaxDamage = component.TimeThrown + TimeSpan.FromSeconds(component.TimeTillMaxDamage);
}

}
}
15 changes: 15 additions & 0 deletions Resources/Changelog/Suspicion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,18 @@
id: 25
time: '2024-12-17T20:12:54.0000000+00:00'
url: https://github.com/Goob-Station/Suspicion-on-Space-Station/pull/42
- author: Aidenkrz
changes:
- message: Jester role! New role whose goal is to get killed by innocents and detectives.
type: Add
id: 26
time: '2024-12-22T07:33:55.0000000+00:00'
url: https://github.com/Goob-Station/Suspicion-on-Space-Station/pull/49
- author: Aidenkrz
changes:
- message: Added new traitor item, (Throwing) Combat Knife. Costs 2 tc, looks like
a normal combat knife but can one shot if thrown from ~8 tiles away.
type: Add
id: 27
time: '2024-12-23T01:41:25.0000000+00:00'
url: https://github.com/Goob-Station/Suspicion-on-Space-Station/pull/50
3 changes: 3 additions & 0 deletions Resources/Locale/en-US/_SSS/store_items.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ uplink-homerun-bat-desc = Send your enemies flying! Breaks after four hits.
uplink-defibrillator-name = Defibrillator
uplink-defibrillator-desc = Revive your friends! One time use.
uplink-one-shot-knife-name = Throwing Knife
uplink-one-shot-knife-desc = A combat knife that appears to be normal, but its damage scales with how long its been in the air, dealing up to 100 damage. Destroyed after use, so use it wisely!
10 changes: 10 additions & 0 deletions Resources/Prototypes/_SSS/Catalog/sss_uplink.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@
cost:
Telecrystal: 3

- type: listing
id: UplinkOneShotKnifeSSS
name: uplink-one-shot-knife-name
description: uplink-one-shot-knife-desc
icon: { sprite: /Textures/Objects/Weapons/Melee/combat_knife.rsi, state: icon }
productEntity: CombatKnifeOneShotThrowing
categories:
- SSSTraitorWeapons
cost:
Telecrystal: 2

- type: listing
id: UplinkExplosiveGrenadeSSS
Expand Down
17 changes: 17 additions & 0 deletions Resources/Prototypes/_SSS/Entities/Objects/Weapons/Melee/knife.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
- type: entity
name: combat knife
suffix: 1-Hit Throw
parent: CombatKnife
id: CombatKnifeOneShotThrowing
description: A deadly knife intended for melee confrontations.
components:
- type: DamageOtherOnHit
damage:
types:
Slash: 5
damageMultiplierOverTime: 20
timeTillMaxDamage: 0.475
- type: EmbeddableProjectile
sound: /Audio/Weapons/star_hit.ogg
offset: -0.15,0.0
deleteOnRemove: true

0 comments on commit ad30fb3

Please sign in to comment.