Skip to content
This repository has been archived by the owner on Apr 6, 2024. It is now read-only.

Combat #9

Draft
wants to merge 25 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
925ecd5
almayer window yay
CharcoalGungan Mar 3, 2023
335d750
DOORS + CATWALK + MAP PURGE
CharcoalGungan Mar 12, 2023
a5f891a
Squashed commit of the following:
Pspritechologist Mar 24, 2023
d0ec0ea
Part of the TDM map done between myself and Pengu.
Pspritechologist Mar 13, 2023
a9b8723
Map Progress
CharcoalGungan Mar 14, 2023
101ad75
Added fences, fixed admin testing map, and more progress on TDM map
Pspritechologist Mar 14, 2023
6eabb84
Changed temp map name, and edited some lights
Pspritechologist Mar 15, 2023
3f67ea8
Tweaked lights more
Pspritechologist Mar 15, 2023
412c1ed
M41A added as proof of concept and testing platform for attachments
CharcoalGungan Mar 17, 2023
964601a
New gun vars : )
CharcoalGungan Mar 27, 2023
310e8bd
Testing wield slowdown.
Pspritechologist Apr 2, 2023
a2e1a6a
New Guns
CharcoalGungan Apr 7, 2023
e69b81b
Wielded weapons are now capable of slowing down the wielder.
Pspritechologist Apr 7, 2023
b2ddba1
Added slowdowns to wielded weapons.
Pspritechologist Apr 7, 2023
c09c662
we be funny we add sniper and meta copyright so we do not get sued
CharcoalGungan Apr 10, 2023
7ce3e28
Update README.md
CharcoalGungan Apr 10, 2023
60699a6
Update README.md
CharcoalGungan Apr 22, 2023
1692dc1
10x24mm STD, AP, IC added as proof of concept
CharcoalGungan Apr 23, 2023
258d7dc
cbt
CharcoalGungan May 7, 2023
f47e12b
Working on armour, doesn't seem functional yet.
Pspritechologist May 20, 2023
8f18b0a
Fixes post rebase
Pspritechologist May 26, 2023
0775a32
Merge branch 'master' of https://github.com/Park-Station/CM-SS14 into…
Pspritechologist Jun 19, 2023
7d5eaa2
Removes GunWieldBonusComponent.cs
Pspritechologist Jun 19, 2023
8be765a
Merge branch 'master' of github.com:Park-Station/CM-SS14 into Combat
CharcoalGungan Jun 24, 2023
0d61527
Fixed some borked sprites.
Pspritechologist Jul 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"request": "launch",
"program": "${workspaceFolder}/bin/Content.Server/Content.Server.dll",
"args": [],
"console": "integratedTerminal",
"console": "internalConsole",
"stopAtEntry": false
},
{
Expand All @@ -43,4 +43,4 @@
"preLaunchTask": "build"
}
]
}
}
10 changes: 6 additions & 4 deletions Content.Client/Weapons/Ranged/Systems/GunSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,13 @@ public override void Shoot(EntityUid gunUid, GunComponent gun, List<(EntityUid?
// This also means any ammo specific stuff can be grabbed as necessary.
var direction = fromCoordinates.ToMapPos(EntityManager, TransformSystem) - toCoordinates.ToMapPos(EntityManager, TransformSystem);

var recoilStrength = (float) (((gun.CurrentAngle + 90) / 90f) * gun.CameraRecoilScalar);

foreach (var (ent, shootable) in ammo)
{
if (throwItems)
{
Recoil(user, direction, gun.CameraRecoilScalar);
Recoil(user, direction, recoilStrength);
if (ent!.Value.IsClientSide())
Del(ent.Value);
else
Expand All @@ -202,7 +204,7 @@ public override void Shoot(EntityUid gunUid, GunComponent gun, List<(EntityUid?
SetCartridgeSpent(ent!.Value, cartridge, true);
MuzzleFlash(gunUid, cartridge, user);
Audio.PlayPredicted(gun.SoundGunshot, gunUid, user);
Recoil(user, direction, gun.CameraRecoilScalar);
Recoil(user, direction, recoilStrength);
// TODO: Can't predict entity deletions.
//if (cartridge.DeleteOnSpawn)
// Del(cartridge.Owner);
Expand All @@ -220,15 +222,15 @@ public override void Shoot(EntityUid gunUid, GunComponent gun, List<(EntityUid?
case AmmoComponent newAmmo:
MuzzleFlash(gunUid, newAmmo, user);
Audio.PlayPredicted(gun.SoundGunshot, gunUid, user);
Recoil(user, direction, gun.CameraRecoilScalar);
Recoil(user, direction, recoilStrength);
if (ent!.Value.IsClientSide())
Del(ent.Value);
else
RemComp<AmmoComponent>(ent.Value);
break;
case HitscanPrototype:
Audio.PlayPredicted(gun.SoundGunshot, gunUid, user);
Recoil(user, direction, gun.CameraRecoilScalar);
Recoil(user, direction, recoilStrength);
break;
}
}
Expand Down
12 changes: 11 additions & 1 deletion Content.Server/Armor/ArmorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public override void Initialize()
base.Initialize();

SubscribeLocalEvent<ArmorComponent, InventoryRelayedEvent<DamageModifyEvent>>(OnDamageModify);
SubscribeLocalEvent<ArmorComponent, DamageModifyEvent>(OnDamageModifyDirect);
SubscribeLocalEvent<ArmorComponent, GetVerbsEvent<ExamineVerb>>(OnArmorVerbExamine);
SubscribeLocalEvent<ArmorComponent, PriceCalculationEvent>(GetArmorPrice);
}
Expand Down Expand Up @@ -64,7 +65,16 @@ private void GetArmorPrice(EntityUid uid, ArmorComponent component, ref PriceCal

private void OnDamageModify(EntityUid uid, ArmorComponent component, InventoryRelayedEvent<DamageModifyEvent> args)
{
args.Args.Damage = DamageSpecifier.ApplyModifierSet(args.Args.Damage, component.Modifiers);
OnDamageModifyDirect(uid, component, args.Args);
}

private void OnDamageModifyDirect(EntityUid uid, ArmorComponent component, DamageModifyEvent args)
{
Logger.DebugS("armor", $"Armor modifying damage: {args.Damage}");

args.Damage = DamageSpecifier.ApplyModifierSet(args.Damage, component.Modifiers);

Logger.DebugS("armor", $"Armor modified damage: {args.Damage}");
}

private void OnArmorVerbExamine(EntityUid uid, ArmorComponent component, GetVerbsEvent<ExamineVerb> args)
Expand Down
15 changes: 14 additions & 1 deletion Content.Server/Weapons/Ranged/Systems/GunSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Content.Server.Power.EntitySystems;
using Content.Server.Stunnable;
using Content.Server.Weapons.Ranged.Components;
using Content.Shared.Wieldable.Components;
using Content.Shared.Damage;
using Content.Shared.Damage.Systems;
using Content.Shared.Database;
Expand Down Expand Up @@ -329,7 +330,19 @@ private Angle[] LinearSpread(Angle start, Angle end, int intervals)
private Angle GetRecoilAngle(TimeSpan curTime, GunComponent component, Angle direction)
{
var timeSinceLastFire = (curTime - component.LastFire).TotalSeconds;
var newTheta = MathHelper.Clamp(component.CurrentAngle.Theta + component.AngleIncrease.Theta - component.AngleDecay.Theta * timeSinceLastFire, component.MinAngle.Theta, component.MaxAngle.Theta);

var minAngleMod = component.MinAngle;
var angleIncreaseMod = component.AngleIncrease;

if (EntityManager.TryGetComponent<WieldableComponent>(component.Owner, out var wieldable) && wieldable.Wielded)
{
minAngleMod *= component.MinAngleWeildedMultiplier;
angleIncreaseMod *= component.AngleIncreaseWeildedMultiplier;
}

var newTheta = MathHelper.Clamp(component.CurrentAngle.Theta + angleIncreaseMod.Theta - component.AngleDecay.Theta *
timeSinceLastFire, minAngleMod.Theta, component.MaxAngle.Theta);

component.CurrentAngle = new Angle(newTheta);
component.LastFire = component.NextFire;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Content.Shared.Wieldable;
using Content.Shared.Wieldable.Components;

namespace Content.Shared.CMSS14.Wieldable.Components;

[RegisterComponent]
public sealed class CurrentlyWieldingComponent : Component
{
public float WalkMod;
public float SprintMod;
}
4 changes: 2 additions & 2 deletions Content.Shared/Camera/SharedCameraRecoilSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public abstract class SharedCameraRecoilSystem : EntitySystem
/// <summary>
/// Minimum rate of magnitude restore towards 0 kick.
/// </summary>
private const float RestoreRateMin = 0.1f;
private const float RestoreRateMin = 0.5f;

/// <summary>
/// Time in seconds since the last kick that lerps RestoreRateMin and RestoreRateMax
Expand All @@ -25,7 +25,7 @@ public abstract class SharedCameraRecoilSystem : EntitySystem
/// <summary>
/// The maximum magnitude of the kick applied to the camera at any point.
/// </summary>
protected const float KickMagnitudeMax = 1f;
protected const float KickMagnitudeMax = 5f;

private ISawmill _log = default!;

Expand Down
21 changes: 19 additions & 2 deletions Content.Shared/Damage/DamageSpecifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,28 @@ public static DamageSpecifier ApplyModifierSet(DamageSpecifier damageSpec, Damag
// more cause they're just bloody stumps.
DamageSpecifier newDamage = new(damageSpec);

float ap = (float) (damageSpec.DamageDict.TryGetValue("AP", out var apValue) ? apValue : 0f);

if (modifierSet.FlatReduction.TryGetValue("AP", out var apReduct))
ap = Math.Max(ap - apReduct, 0);

foreach (var entry in newDamage.DamageDict)
{
if (entry.Value <= 0) continue;

if (entry.Key == "AP") continue; // Don't want to reduce armor penetration with armor :P

float newValue = entry.Value.Float();

if (modifierSet.FlatReduction.TryGetValue(entry.Key, out var reduction))
{
Logger.DebugS("damage", $"Flat reduction of {reduction} for {entry.Key}.");
// armor penetration reduces flat reductions
reduction = Math.Max(reduction - ap, 0);
// Logger.DebugS("damage", $"Armor penetration is {newDamage.DamageDict["AP"]}.");
Logger.DebugS("damage", $"Reducing by {reduction}.");
newValue -= reduction;
Logger.DebugS("damage", $"New value is {newValue}.");
if (newValue <= 0)
{
// flat reductions cannot heal you
Expand Down Expand Up @@ -190,7 +203,7 @@ public void ClampMin(FixedPoint2 minValue)
{
foreach (var (key, value) in DamageDict)
{
if (value < minValue)
if (value < minValue && key != "AP")
{
DamageDict[key] = minValue;
}
Expand All @@ -205,7 +218,7 @@ public void ClampMax(FixedPoint2 maxValue)
{
foreach (var (key, value) in DamageDict)
{
if (value > maxValue)
if (value > maxValue && key != "AP")
{
DamageDict[key] = maxValue;
}
Expand All @@ -228,6 +241,10 @@ public void ExclusiveAdd(DamageSpecifier other)
{
DamageDict[type] += value;
}
else if (type == "AP")
{
DamageDict.Add(type, value);
}
}
}

Expand Down
15 changes: 14 additions & 1 deletion Content.Shared/Weapons/Ranged/Components/GunComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,25 @@ public partial class GunComponent : Component
[ViewVariables(VVAccess.ReadWrite), DataField("angleIncrease")]
public Angle AngleIncrease = Angle.FromDegrees(0.5);

/// <summary>
/// How much the multiplier reduces AngleIncrease when weilded.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("angleIncreaseWeildedMultiplier")]
public float AngleIncreaseWeildedMultiplier = 1f;


/// <summary>
/// How much the <see cref="CurrentAngle"/> decreases per second.
/// </summary>
[DataField("angleDecay")]
public Angle AngleDecay = Angle.FromDegrees(4);

/// <summary>
/// The amount that weilding the gun decreases spread.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("minAngleWeildedMultiplier")]
public float MinAngleWeildedMultiplier = 1f;

/// <summary>
/// The maximum angle allowed for <see cref="CurrentAngle"/>
/// </summary>
Expand Down Expand Up @@ -109,7 +122,7 @@ public partial class GunComponent : Component
/// How fast the projectile moves.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("projectileSpeed")]
public float ProjectileSpeed = 25f;
public float ProjectileSpeed = 30f;

/// <summary>
/// When the gun is next available to be shot.
Expand Down
20 changes: 0 additions & 20 deletions Content.Shared/Weapons/Ranged/Components/GunWieldBonusComponent.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected virtual void InitializeBallistic()
SubscribeLocalEvent<BallisticAmmoProviderComponent, GetVerbsEvent<Verb>>(OnBallisticVerb);
SubscribeLocalEvent<BallisticAmmoProviderComponent, InteractUsingEvent>(OnBallisticInteractUsing);
SubscribeLocalEvent<BallisticAmmoProviderComponent, AfterInteractEvent>(OnBallisticAfterInteract);
SubscribeLocalEvent<BallisticAmmoProviderComponent, UseInHandEvent>(OnBallisticUse);
// SubscribeLocalEvent<BallisticAmmoProviderComponent, UseInHandEvent>(OnBallisticUse);
}

private void OnBallisticUse(EntityUid uid, BallisticAmmoProviderComponent component, UseInHandEvent args)
Expand Down
6 changes: 6 additions & 0 deletions Content.Shared/Wieldable/Components/WieldableComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,10 @@ public sealed partial class WieldableComponent : Component

[DataField("wieldTime")]
public float WieldTime = 1.5f;

[DataField("walkMod"), ViewVariables(VVAccess.ReadWrite)]
public float WalkMod = 1f;

[DataField("sprintMod"), ViewVariables(VVAccess.ReadWrite)]
public float SprintMod = 1f;
}
Loading