Skip to content

Commit

Permalink
Mechs real, Synth balance, Terragov Preset
Browse files Browse the repository at this point in the history
  • Loading branch information
Eagle-0 committed Apr 27, 2024
1 parent 4c3724d commit e819a63
Show file tree
Hide file tree
Showing 19 changed files with 864 additions and 14 deletions.
6 changes: 6 additions & 0 deletions Content.Client/Weapons/Ranged/Systems/GunSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Content.Client.Weapons.Ranged.Components;
using Content.Shared.Camera;
using Content.Shared.CombatMode;
using Content.Shared.Mech.Components;
using Content.Shared.Weapons.Ranged;
using Content.Shared.Weapons.Ranged.Components;
using Content.Shared.Weapons.Ranged.Events;
Expand Down Expand Up @@ -141,6 +142,11 @@ public override void Update(float frameTime)

var entity = entityNull.Value;

if (TryComp<MechPilotComponent>(entity, out var mechPilot))
{
entity = mechPilot.Mech;
}

if (!TryGetGun(entity, out var gunUid, out var gun))
{
return;
Expand Down
6 changes: 6 additions & 0 deletions Content.Server/Atmos/EntitySystems/FlammableSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Content.Shared.Damage;
using Content.Shared.Database;
using Content.Shared.Interaction;
using Content.Shared.Mech.Components;
using Content.Shared.Physics;
using Content.Shared.Popups;
using Content.Shared.Projectiles;
Expand Down Expand Up @@ -305,6 +306,11 @@ public void Ignite(EntityUid uid, EntityUid ignitionSource, FlammableComponent?
if (!Resolve(uid, ref flammable))
return;

// I would rather there be a cancellable event for this but I really don't wanna fuck with this janky system more than I have too.
// FlammableSystem rework when?
if (TryComp<MechPilotComponent>(uid, out var mechPilot) && TryComp<MechComponent>(mechPilot.Mech, out var mech) && mech.Airtight)
return;

if (flammable.AlwaysCombustible)
{
flammable.FireStacks = Math.Max(flammable.FirestacksOnIgnite, flammable.FireStacks);
Expand Down
75 changes: 75 additions & 0 deletions Content.Server/Mech/Equipment/EntitySystems/MechGunSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using Content.Server.Mech.Systems;
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Shared.Mech.Components;
using Content.Shared.Mech.Equipment.Components;
using Content.Shared.Throwing;
using Content.Shared.Weapons.Ranged.Systems;
using Robust.Shared.Random;

namespace Content.Server.Mech.Equipment.EntitySystems;
public sealed class MechGunSystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly ThrowingSystem _throwing = default!;
[Dependency] private readonly MechSystem _mech = default!;
[Dependency] private readonly BatterySystem _battery = default!;

public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<MechEquipmentComponent, GunShotEvent>(MechGunShot);
}

private void MechGunShot(EntityUid uid, MechEquipmentComponent component, ref GunShotEvent args)
{
if (!component.EquipmentOwner.HasValue)
return;

if (!TryComp<MechComponent>(component.EquipmentOwner.Value, out var mech))
return;

if (TryComp<BatteryComponent>(uid, out var battery))
{
ChargeGunBattery(uid, battery);
return;
}

// In most guns the ammo itself isn't shot but turned into cassings
// and a new projectile is spawned instead, meaning that args.Ammo
// is most likely inside the equipment container (for some odd reason)

// I'm not even sure why this is needed since GunSystem.Shoot() has a
// container check before ejecting, but yet it still puts the spent ammo inside the mech
foreach (var (ent, _) in args.Ammo)
{
if (ent.HasValue && mech.EquipmentContainer.Contains(ent.Value))
{
mech.EquipmentContainer.Remove(ent.Value);
_throwing.TryThrow(ent.Value, _random.NextVector2(), _random.Next(5));
}
}
}

private void ChargeGunBattery(EntityUid uid, BatteryComponent component)
{
if (!TryComp<MechEquipmentComponent>(uid, out var mechEquipment) || !mechEquipment.EquipmentOwner.HasValue)
return;

if (!TryComp<MechComponent>(mechEquipment.EquipmentOwner.Value, out var mech))
return;

var maxCharge = component.MaxCharge;
var currentCharge = component.CurrentCharge;

var chargeDelta = maxCharge - currentCharge;

if (chargeDelta <= 0 || mech.Energy - chargeDelta < 0)
return;

if (!_mech.TryChangeEnergy(mechEquipment.EquipmentOwner.Value, -chargeDelta, mech))
return;

_battery.SetCharge(uid, component.MaxCharge, component);
}
}
1 change: 1 addition & 0 deletions Content.Server/Mech/Systems/MechSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using Content.Server.Atmos.Components;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Mech.Components;
using Content.Server.Power.Components;
Expand Down
5 changes: 5 additions & 0 deletions Content.Server/Weapons/Ranged/Systems/GunSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Content.Server.Administration.Logs;
using Content.Server.Cargo.Systems;
using Content.Server.Interaction;
using Content.Server.Mech.Equipment.Components;
using Content.Server.Power.EntitySystems;
using Content.Server.Stunnable;
using Content.Server.Weapons.Ranged.Components;
Expand All @@ -11,6 +12,7 @@
using Content.Shared.Database;
using Content.Shared.Effects;
using Content.Shared.Interaction.Components;
using Content.Shared.Mech.Equipment.Components;
using Content.Shared.Projectiles;
using Content.Shared.Weapons.Melee;
using Content.Shared.Weapons.Ranged;
Expand Down Expand Up @@ -170,9 +172,12 @@ public override void Shoot(EntityUid gunUid, GunComponent gun, List<(EntityUid?

// Something like ballistic might want to leave it in the container still
if (!cartridge.DeleteOnSpawn && !Containers.IsEntityInContainer(ent!.Value))
{
EjectCartridge(ent.Value, angle);
}

Dirty(ent!.Value, cartridge);

break;
// Ammo shoots itself
case AmmoComponent newAmmo:
Expand Down
3 changes: 3 additions & 0 deletions Content.Shared/Mech/EntitySystems/SharedMechSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Content.Shared.Movement.Systems;
using Content.Shared.Popups;
using Content.Shared.Weapons.Melee;
using Content.Shared.Weapons.Ranged.Events;
using Robust.Shared.Containers;
using Robust.Shared.Network;
using Robust.Shared.Serialization;
Expand Down Expand Up @@ -43,7 +44,9 @@ public override void Initialize()
{
SubscribeLocalEvent<MechComponent, MechToggleEquipmentEvent>(OnToggleEquipmentAction);
SubscribeLocalEvent<MechComponent, MechEjectPilotEvent>(OnEjectPilotEvent);

SubscribeLocalEvent<MechComponent, InteractNoHandEvent>(RelayInteractionEvent);

SubscribeLocalEvent<MechComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<MechComponent, DestructionEventArgs>(OnDestruction);
SubscribeLocalEvent<MechComponent, GetAdditionalAccessEvent>(OnGetAdditionalAccess);
Expand Down
46 changes: 34 additions & 12 deletions Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Content.Shared.Gravity;
using Content.Shared.Hands;
using Content.Shared.Hands.Components;
using Content.Shared.Mech.Components;
using Content.Shared.Item; // Delta-V: Felinids in duffelbags can't shoot.
using Content.Shared.Popups;
using Content.Shared.Projectiles;
Expand Down Expand Up @@ -126,13 +127,15 @@ private void OnShootRequest(RequestShootEvent msg, EntitySessionEventArgs args)
{
var user = args.SenderSession.AttachedEntity;

if (user == null ||
!_combatMode.IsInCombatMode(user) ||
!TryGetGun(user.Value, out var ent, out var gun) ||
HasComp<ItemComponent>(user)) // Delta-V: Felinids in duffelbags can't shoot.
{
if (user == null || !_combatMode.IsInCombatMode(user))
return;
}

if (TryComp<MechPilotComponent>(user.Value, out var mechPilot))
user = mechPilot.Mech;

if (!TryGetGun(user.Value, out var ent, out var gun))
return;


if (ent != GetEntity(msg.Gun))
return;
Expand All @@ -146,14 +149,19 @@ private void OnStopShootRequest(RequestStopShootEvent ev, EntitySessionEventArgs
{
var gunUid = GetEntity(ev.Gun);

if (args.SenderSession.AttachedEntity == null ||
!TryComp<GunComponent>(gunUid, out var gun) ||
!TryGetGun(args.SenderSession.AttachedEntity.Value, out _, out var userGun))
{
var user = args.SenderSession.AttachedEntity;

if (user == null)
return;
}


if (userGun != gun)
if (TryComp<MechPilotComponent>(user.Value, out var mechPilot))
user = mechPilot.Mech;

if (!TryGetGun(user.Value, out var ent, out var gun))
return;

if (ent != gunUid)
return;

StopShooting(gunUid, gun);
Expand All @@ -172,6 +180,15 @@ public bool TryGetGun(EntityUid entity, out EntityUid gunEntity, [NotNullWhen(tr
gunEntity = default;
gunComp = null;

if (TryComp<MechComponent>(entity, out var mech) &&
mech.CurrentSelectedEquipment.HasValue &&
TryComp<GunComponent>(mech.CurrentSelectedEquipment.Value, out var mechGun))
{
gunEntity = mech.CurrentSelectedEquipment.Value;
gunComp = mechGun;
return true;
}

if (EntityManager.TryGetComponent(entity, out HandsComponent? hands) &&
hands.ActiveHandEntity is { } held &&
TryComp(held, out GunComponent? gun))
Expand Down Expand Up @@ -267,8 +284,11 @@ private void AttemptShoot(EntityUid user, EntityUid gunUid, GunComponent gun)
var shots = 0;
var lastFire = gun.NextFire;

Log.Debug($"Nextfire={gun.NextFire} curTime={curTime}");

while (gun.NextFire <= curTime)
{
Log.Debug("Shots++");
gun.NextFire += fireRate;
shots++;
}
Expand All @@ -292,6 +312,8 @@ private void AttemptShoot(EntityUid user, EntityUid gunUid, GunComponent gun)
throw new ArgumentOutOfRangeException($"No implemented shooting behavior for {gun.SelectedMode}!");
}

Log.Debug($"Shots fired: {shots}");

var attemptEv = new AttemptShootEvent(user, null);
RaiseLocalEvent(gunUid, ref attemptEv);

Expand Down
47 changes: 47 additions & 0 deletions Resources/Prototypes/Damage/modifier_sets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -336,3 +336,50 @@
flatReductions:
# can't punch the endoskeleton to death
Blunt: 5

# Synths
- type: damageModifierSet
id: Synth
coefficients:
Blunt: 1.0
Slash: 0.4
Piercing: 1.5
Cold: 0.0
Heat: 2.5
Shock: 3.0
Poison: 0.0
Radiation: 0.0
Asphyxiation: 0.0
Bloodloss: 0.0
Cellular: 0.0
flatReductions:
Blunt: 5

# Vatgrown
- type: damageModifierSet
id: Terra
coefficients:
Blunt: 2.0
Slash: 2.0
Piercing: 2.0
Cold: 1.0
Heat: 1.5
Shock: 10.0
Poison: 5.0
Radiation: 1.0
Asphyxiation: 2.5
Bloodloss: 1.0
Cellular: 1.0

# Mechs
- type: damageModifierSet
id: FireRestMetallic
parent: Metallic
flatReductions:
Heat: 1000

- type: damageModifierSet
id: FireResStrongMetallic
parent: StrongMetallic
flatReductions:
Heat: 1000
53 changes: 53 additions & 0 deletions Resources/Prototypes/Datasets/Names/terragov_first.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
- type: dataset
id: names_terra_first
values:
- Sgt.
- Capt.
- Pvt.
- Maj.
- Lt.
- Cpl.
- Col.
- Pvt.
- Sgt.
- Capt.
- Pvt.
- Lt.
- Cpl.
- Maj.
- Col.
- Sgt.
- Capt.
- Pvt.
- Lt.
- Cpl.
- Maj.
- Col.
- Sgt.
- Capt.
- Pvt.
- Lt.
- Cpl.
- Maj.
- Col.
- Sgt.
- Capt.
- Pvt.
- Lt.
- Cpl.
- Maj.
- Col.
- Sgt.
- Capt.
- Pvt.
- Lt.
- Cpl.
- Maj.
- Col.
- Sgt.
- Capt.
- Pvt.
- Lt.
- Cpl.
- Maj.
- Col.
Loading

0 comments on commit e819a63

Please sign in to comment.