Crossbow (#327)
* Add powered crossbow * Add spear embedding (#18578) * Add spear embedding * fuck this copy-paste * Juicier * the river * Add crossbow embedding * Fix crossbow construction * Finish crossbow * Remove unused --------- Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
21
Content.Client/White/Crossbow/DrawableVisualizerSystem.cs
Normal file
21
Content.Client/White/Crossbow/DrawableVisualizerSystem.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Content.Shared.Weapons.Ranged.Systems;
|
||||
using Content.Shared.White.Crossbow;
|
||||
using Robust.Client.GameObjects;
|
||||
|
||||
namespace Content.Client.White.Crossbow;
|
||||
|
||||
public sealed class DrawableSystem : VisualizerSystem<DrawableComponent>
|
||||
{
|
||||
protected override void OnAppearanceChange(EntityUid uid, DrawableComponent component, ref AppearanceChangeEvent args)
|
||||
{
|
||||
if (args.Sprite == null)
|
||||
return;
|
||||
|
||||
var drawn = args.AppearanceData.TryGetValue(DrawableVisuals.Drawn, out var drawnObj) && drawnObj is true;
|
||||
|
||||
var hasAmmo = args.AppearanceData.TryGetValue(AmmoVisuals.AmmoCount, out var ammoCount) && (int) ammoCount > 0;
|
||||
|
||||
var state = drawn ? "drawn" : hasAmmo ? "loaded" : "base";
|
||||
args.Sprite.LayerSetState(0, state);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ using Content.Server.Administration.Logs;
|
||||
using Content.Server.Damage.Components;
|
||||
using Content.Server.Weapons.Ranged.Systems;
|
||||
using Content.Shared.Camera;
|
||||
using Content.Server.White.Crossbow;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Events;
|
||||
using Content.Shared.Damage.Systems;
|
||||
@@ -32,7 +33,17 @@ namespace Content.Server.Damage.Systems
|
||||
|
||||
private void OnDoHit(EntityUid uid, DamageOtherOnHitComponent component, ThrowDoHitEvent args)
|
||||
{
|
||||
var dmg = _damageable.TryChangeDamage(args.Target, component.Damage, component.IgnoreResistances, origin: args.Component.Thrower);
|
||||
// WD EDIT START
|
||||
if (args.Handled)
|
||||
return;
|
||||
|
||||
var damage = component.Damage;
|
||||
|
||||
if (TryComp(uid, out ThrowDamageModifierComponent? modifier))
|
||||
damage += modifier.Damage;
|
||||
|
||||
var dmg = _damageable.TryChangeDamage(args.Target, damage, component.IgnoreResistances, origin: args.Component.Thrower);
|
||||
// WD EDIT END
|
||||
|
||||
// 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))
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using Content.Server.Stack;
|
||||
using Content.Shared.Stacks;
|
||||
using Content.Shared.Weapons.Ranged.Components;
|
||||
using Content.Shared.Weapons.Ranged.Events;
|
||||
using Robust.Shared.Map;
|
||||
@@ -6,6 +8,8 @@ namespace Content.Server.Weapons.Ranged.Systems;
|
||||
|
||||
public sealed partial class GunSystem
|
||||
{
|
||||
[Dependency] private readonly StackSystem _stack = default!;
|
||||
|
||||
protected override void Cycle(EntityUid uid, BallisticAmmoProviderComponent component, MapCoordinates coordinates)
|
||||
{
|
||||
EntityUid? ent = null;
|
||||
@@ -32,4 +36,9 @@ public sealed partial class GunSystem
|
||||
var cycledEvent = new GunCycledEvent();
|
||||
RaiseLocalEvent(uid, ref cycledEvent);
|
||||
}
|
||||
|
||||
protected override EntityUid GetStackEntity(EntityUid uid, StackComponent stack) // WD
|
||||
{
|
||||
return _stack.Split(uid, 1, Transform(uid).Coordinates, stack) ?? uid;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using Content.Server.Interaction;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Server.Stunnable;
|
||||
using Content.Server.Weapons.Ranged.Components;
|
||||
using Content.Server.White.Crossbow;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Systems;
|
||||
using Content.Shared.Database;
|
||||
@@ -13,6 +14,7 @@ using Content.Shared.Effects;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Interaction.Components;
|
||||
using Content.Shared.Projectiles;
|
||||
using Content.Shared.Throwing;
|
||||
using Content.Shared.Weapons.Melee;
|
||||
using Content.Shared.Weapons.Ranged;
|
||||
using Content.Shared.Weapons.Ranged.Components;
|
||||
@@ -42,6 +44,7 @@ public sealed partial class GunSystem : SharedGunSystem
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
[Dependency] private readonly StaminaSystem _stamina = default!;
|
||||
[Dependency] private readonly StunSystem _stun = default!;
|
||||
[Dependency] private readonly PoweredSystem _powered = default!; // WD
|
||||
|
||||
public const float DamagePitchVariation = SharedMeleeWeaponSystem.DamagePitchVariation;
|
||||
public const float GunClumsyChance = 0.5f;
|
||||
@@ -306,7 +309,17 @@ public sealed partial class GunSystem : SharedGunSystem
|
||||
{
|
||||
RemoveShootable(uid);
|
||||
// TODO: Someone can probably yeet this a billion miles so need to pre-validate input somewhere up the call stack.
|
||||
ThrowingSystem.TryThrow(uid, mapDirection, gun.ProjectileSpeed, user);
|
||||
// WD EDIT START
|
||||
var coefficient = _powered.GetPowerCoefficient(gunUid);
|
||||
if (gun.ForceThrowingAngle)
|
||||
{
|
||||
var angle = EnsureComp<ThrowingAngleComponent>(uid);
|
||||
angle.Angle = gun.Angle;
|
||||
}
|
||||
ThrowingSystem.TryThrow(uid, mapDirection.Normalized() * 7f * coefficient, gun.ProjectileSpeed, user);
|
||||
if (gun.ForceThrowingAngle)
|
||||
RemComp<ThrowingAngleComponent>(uid);
|
||||
// WD EDIT END
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.Damage;
|
||||
|
||||
namespace Content.Server.White.Crossbow;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class ModifyDamageOnShootComponent : Component
|
||||
{
|
||||
[DataField("damage", required: true)]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public DamageSpecifier Damage = new();
|
||||
|
||||
[DataField("addEmbedding")]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool AddEmbedding;
|
||||
|
||||
[DataField("offset")]
|
||||
public Vector2 Offset = Vector2.Zero;
|
||||
}
|
||||
33
Content.Server/White/Crossbow/ModifyDamageOnShootSystem.cs
Normal file
33
Content.Server/White/Crossbow/ModifyDamageOnShootSystem.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Content.Shared.Projectiles;
|
||||
using Content.Shared.Throwing;
|
||||
using Content.Shared.Weapons.Ranged.Events;
|
||||
|
||||
namespace Content.Server.White.Crossbow;
|
||||
|
||||
public sealed class ModifyDamageOnShootSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<ModifyDamageOnShootComponent, AmmoShotEvent>(OnShoot);
|
||||
}
|
||||
|
||||
private void OnShoot(EntityUid uid, ModifyDamageOnShootComponent component, AmmoShotEvent args)
|
||||
{
|
||||
foreach (var proj in args.FiredProjectiles)
|
||||
{
|
||||
var comp = EnsureComp<ThrowDamageModifierComponent>(proj);
|
||||
comp.Damage += component.Damage;
|
||||
|
||||
if (!component.AddEmbedding)
|
||||
continue;
|
||||
|
||||
comp.AddEmbedding = true;
|
||||
var embed = EnsureComp<EmbeddableProjectileComponent>(proj);
|
||||
embed.Offset = component.Offset;
|
||||
embed.PreventEmbedding = false;
|
||||
Dirty(proj, embed);
|
||||
}
|
||||
}
|
||||
}
|
||||
15
Content.Server/White/Crossbow/PoweredComponent.cs
Normal file
15
Content.Server/White/Crossbow/PoweredComponent.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using Content.Shared.Damage;
|
||||
|
||||
namespace Content.Server.White.Crossbow;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class PoweredComponent : Component
|
||||
{
|
||||
[DataField("charge", required: true)]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float Charge;
|
||||
|
||||
[DataField("damage", required: true)]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public DamageSpecifier Damage = new();
|
||||
}
|
||||
91
Content.Server/White/Crossbow/PoweredSystem.cs
Normal file
91
Content.Server/White/Crossbow/PoweredSystem.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Shared.Projectiles;
|
||||
using Content.Shared.Weapons.Ranged.Events;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.White.Crossbow;
|
||||
|
||||
public sealed class PoweredSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SharedContainerSystem _containers = default!;
|
||||
[Dependency] private readonly BatterySystem _battery = default!;
|
||||
|
||||
private const string CellSlot = "cell_slot";
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<PoweredComponent, AmmoShotEvent>(OnShoot);
|
||||
}
|
||||
|
||||
private void OnShoot(EntityUid uid, PoweredComponent component, AmmoShotEvent args)
|
||||
{
|
||||
if (!TryGetBatteryComponent(uid, out var battery, out var batteryUid))
|
||||
return;
|
||||
|
||||
var (factor, charge) = GetFactor(component, battery, batteryUid.Value);
|
||||
|
||||
// Чтобы затриггерить взрыв на полную мощь, если есть плазма в батарейке
|
||||
_battery.SetCharge(batteryUid.Value, battery.CurrentCharge, battery);
|
||||
|
||||
_battery.SetCharge(batteryUid.Value, battery.CurrentCharge - charge, battery);
|
||||
var damage = component.Damage * factor;
|
||||
|
||||
foreach (var proj in args.FiredProjectiles)
|
||||
{
|
||||
EnsureComp<ThrowDamageModifierComponent>(proj).Damage += damage;
|
||||
|
||||
if (factor == 0)
|
||||
continue;
|
||||
|
||||
var embed = EnsureComp<EmbeddableProjectileComponent>(proj);
|
||||
embed.Penetrate = true;
|
||||
Dirty(proj, embed);
|
||||
}
|
||||
}
|
||||
|
||||
public float GetPowerCoefficient(EntityUid uid)
|
||||
{
|
||||
if (!TryComp(uid, out PoweredComponent? component) ||
|
||||
!TryGetBatteryComponent(uid, out var battery, out var batteryUid))
|
||||
return 1f;
|
||||
|
||||
return 1f + GetFactor(component, battery, batteryUid.Value).Item1;
|
||||
}
|
||||
|
||||
private (float, float) GetFactor(PoweredComponent component, BatteryComponent battery, EntityUid batteryUid)
|
||||
{
|
||||
DebugTools.Assert(component.Charge != 0f);
|
||||
var charge = MathF.Min(battery.CurrentCharge, component.Charge);
|
||||
var factor = charge / component.Charge;
|
||||
|
||||
if (TryComp(batteryUid, out RiggableComponent? rig) && rig.IsRigged)
|
||||
factor *= 2f;
|
||||
|
||||
return (factor, charge);
|
||||
}
|
||||
|
||||
private bool TryGetBatteryComponent(EntityUid uid, [NotNullWhen(true)] out BatteryComponent? battery,
|
||||
[NotNullWhen(true)] out EntityUid? batteryUid)
|
||||
{
|
||||
if (!_containers.TryGetContainer(uid, CellSlot, out var container) ||
|
||||
container is not ContainerSlot slot)
|
||||
{
|
||||
battery = null;
|
||||
batteryUid = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
batteryUid = slot.ContainedEntity;
|
||||
|
||||
if (batteryUid != null)
|
||||
return TryComp(batteryUid, out battery);
|
||||
|
||||
battery = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using Content.Shared.Damage;
|
||||
|
||||
namespace Content.Server.White.Crossbow;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class ThrowDamageModifierComponent : Component
|
||||
{
|
||||
public DamageSpecifier Damage = new();
|
||||
|
||||
public bool AddEmbedding;
|
||||
|
||||
public bool ClearDamageOnRemove;
|
||||
}
|
||||
43
Content.Server/White/Crossbow/ThrowDamageModifierSystem.cs
Normal file
43
Content.Server/White/Crossbow/ThrowDamageModifierSystem.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using Content.Shared.Projectiles;
|
||||
using Content.Shared.Throwing;
|
||||
using Content.Shared.White.Crossbow;
|
||||
|
||||
namespace Content.Server.White.Crossbow;
|
||||
|
||||
public sealed class ThrowDamageModifierSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<ThrowDamageModifierComponent, StopThrowEvent>(OnStopped);
|
||||
SubscribeLocalEvent<ThrowDamageModifierComponent, EmbedStartEvent>(OnEmbedStart);
|
||||
SubscribeLocalEvent<ThrowDamageModifierComponent, EmbedRemovedEvent>(OnEmbedRemoved);
|
||||
}
|
||||
|
||||
private void OnEmbedStart(EntityUid uid, ThrowDamageModifierComponent component, ref EmbedStartEvent args)
|
||||
{
|
||||
component.ClearDamageOnRemove = true;
|
||||
|
||||
if (component.AddEmbedding)
|
||||
args.Embed.PreventEmbedding = true;
|
||||
}
|
||||
|
||||
private void OnEmbedRemoved(EntityUid uid, ThrowDamageModifierComponent component, EmbedRemovedEvent args)
|
||||
{
|
||||
if (!component.ClearDamageOnRemove)
|
||||
return;
|
||||
|
||||
component.ClearDamageOnRemove = false;
|
||||
component.Damage.DamageDict.Clear();
|
||||
|
||||
if (component.AddEmbedding)
|
||||
RemComp<EmbeddableProjectileComponent>(uid);
|
||||
}
|
||||
|
||||
private void OnStopped(EntityUid uid, ThrowDamageModifierComponent component, StopThrowEvent args)
|
||||
{
|
||||
if (!component.ClearDamageOnRemove)
|
||||
component.Damage.DamageDict.Clear();
|
||||
}
|
||||
}
|
||||
@@ -46,4 +46,15 @@ public sealed partial class EmbeddableProjectileComponent : Component
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
|
||||
public SoundSpecifier? Sound;
|
||||
|
||||
// WD START
|
||||
[AutoNetworkedField]
|
||||
public bool PreventEmbedding;
|
||||
|
||||
[AutoNetworkedField]
|
||||
public bool Penetrate;
|
||||
|
||||
[AutoNetworkedField]
|
||||
public EntityUid? PenetratedUid;
|
||||
// WD END
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using Content.Shared.DoAfter;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Throwing;
|
||||
using Content.Shared.White.Crossbow;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Network;
|
||||
@@ -26,6 +27,7 @@ public abstract partial class SharedProjectileSystem : EntitySystem
|
||||
[Dependency] private readonly SharedHandsSystem _hands = default!;
|
||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
[Dependency] private readonly PenetratedSystem _penetratedSystem = default!; // WD
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -37,24 +39,19 @@ public abstract partial class SharedProjectileSystem : EntitySystem
|
||||
SubscribeLocalEvent<EmbeddableProjectileComponent, ActivateInWorldEvent>(OnEmbedActivate);
|
||||
SubscribeLocalEvent<EmbeddableProjectileComponent, RemoveEmbeddedProjectileEvent>(OnEmbedRemove);
|
||||
SubscribeLocalEvent<EmbeddableProjectileComponent, AttemptPacifiedThrowEvent>(OnAttemptPacifiedThrow);
|
||||
SubscribeLocalEvent<EmbeddableProjectileComponent, LandEvent>(OnLand); // WD
|
||||
}
|
||||
|
||||
private void OnEmbedActivate(EntityUid uid, EmbeddableProjectileComponent component, ActivateInWorldEvent args)
|
||||
{
|
||||
// Nuh uh
|
||||
if (component.RemovalTime == null)
|
||||
return;
|
||||
|
||||
// WD EDIT START
|
||||
if (args.Handled || !TryComp<PhysicsComponent>(uid, out var physics) || physics.BodyType != BodyType.Static)
|
||||
return;
|
||||
|
||||
args.Handled = true;
|
||||
|
||||
_doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, component.RemovalTime.Value,
|
||||
new RemoveEmbeddedProjectileEvent(), eventTarget: uid, target: uid)
|
||||
{
|
||||
DistanceThreshold = SharedInteractionSystem.InteractionRange,
|
||||
});
|
||||
AttemptEmbedRemove(uid, args.User, component);
|
||||
// WD EDIT END
|
||||
}
|
||||
|
||||
private void OnEmbedRemove(EntityUid uid, EmbeddableProjectileComponent component, RemoveEmbeddedProjectileEvent args)
|
||||
@@ -82,6 +79,16 @@ public abstract partial class SharedProjectileSystem : EntitySystem
|
||||
projectile.DamagedEntity = false;
|
||||
}
|
||||
|
||||
// WD START
|
||||
if (component.PenetratedUid != null)
|
||||
{
|
||||
_penetratedSystem.FreePenetrated(component.PenetratedUid.Value);
|
||||
component.PenetratedUid = null;
|
||||
}
|
||||
|
||||
RaiseLocalEvent(uid, new EmbedRemovedEvent());
|
||||
// WD END
|
||||
|
||||
// Land it just coz uhhh yeah
|
||||
var landEv = new LandEvent(args.User, true);
|
||||
RaiseLocalEvent(uid, ref landEv);
|
||||
@@ -96,6 +103,28 @@ public abstract partial class SharedProjectileSystem : EntitySystem
|
||||
if (!component.EmbedOnThrow)
|
||||
return;
|
||||
|
||||
// WD START
|
||||
if (component is {Penetrate: true, PenetratedUid: null} &&
|
||||
TryComp(args.Target, out PenetratedComponent? penetrated) &&
|
||||
penetrated is {ProjectileUid: null, IsPinned: false} &&
|
||||
TryComp(args.Target, out PhysicsComponent? physics))
|
||||
{
|
||||
component.PenetratedUid = args.Target;
|
||||
penetrated.ProjectileUid = uid;
|
||||
_physics.SetLinearVelocity(args.Target, Vector2.Zero, body: physics);
|
||||
_physics.SetBodyType(args.Target, BodyType.Static, body: physics);
|
||||
var xform = Transform(args.Target);
|
||||
_transform.SetParent(args.Target, xform, uid);
|
||||
_transform.SetLocalPosition(args.Target,
|
||||
xform.LocalPosition + Transform(uid).LocalRotation.RotateVec(new Vector2(0.5f, 0.5f)), xform);
|
||||
Dirty(uid, component);
|
||||
return;
|
||||
}
|
||||
|
||||
if (component.PenetratedUid == args.Target)
|
||||
args.Handled = true;
|
||||
// WD END
|
||||
|
||||
Embed(uid, args.Target, component);
|
||||
}
|
||||
|
||||
@@ -113,6 +142,16 @@ public abstract partial class SharedProjectileSystem : EntitySystem
|
||||
|
||||
private void Embed(EntityUid uid, EntityUid target, EmbeddableProjectileComponent component)
|
||||
{
|
||||
if (component.PreventEmbedding || component.PenetratedUid == target) // WD START
|
||||
return;
|
||||
|
||||
var ev = new EmbedStartEvent(component);
|
||||
RaiseLocalEvent(uid, ref ev);
|
||||
|
||||
if (TryComp(component.PenetratedUid, out PenetratedComponent? penetrated))
|
||||
penetrated.IsPinned = true;
|
||||
// WD END
|
||||
|
||||
TryComp<PhysicsComponent>(uid, out var physics);
|
||||
_physics.SetLinearVelocity(uid, Vector2.Zero, body: physics);
|
||||
_physics.SetBodyType(uid, BodyType.Static, body: physics);
|
||||
@@ -160,6 +199,37 @@ public abstract partial class SharedProjectileSystem : EntitySystem
|
||||
{
|
||||
args.Cancel("pacified-cannot-throw-embed");
|
||||
}
|
||||
|
||||
// WD EDIT START
|
||||
private void OnLand(EntityUid uid, EmbeddableProjectileComponent component, ref LandEvent args)
|
||||
{
|
||||
if (component.PenetratedUid == null)
|
||||
return;
|
||||
|
||||
var penetratedUid = component.PenetratedUid.Value;
|
||||
component.PenetratedUid = null;
|
||||
|
||||
_penetratedSystem.FreePenetrated(penetratedUid);
|
||||
|
||||
Embed(uid, penetratedUid, component);
|
||||
}
|
||||
|
||||
public void AttemptEmbedRemove(EntityUid uid, EntityUid user, EmbeddableProjectileComponent? component = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component, false))
|
||||
return;
|
||||
|
||||
// Nuh uh
|
||||
if (component.RemovalTime == null)
|
||||
return;
|
||||
|
||||
_doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, user, component.RemovalTime.Value,
|
||||
new RemoveEmbeddedProjectileEvent(), eventTarget: uid, target: uid)
|
||||
{
|
||||
DistanceThreshold = SharedInteractionSystem.InteractionRange,
|
||||
});
|
||||
}
|
||||
// WD EDIT END
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
|
||||
@@ -167,6 +167,16 @@ public partial class GunComponent : Component
|
||||
/// </summary>
|
||||
[DataField("clumsyProof"), ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool ClumsyProof = false;
|
||||
|
||||
// WD START
|
||||
[DataField("forceThrowingAngle")]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool ForceThrowingAngle;
|
||||
|
||||
[DataField("angle")]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public Angle Angle;
|
||||
// WD END
|
||||
}
|
||||
|
||||
[Flags]
|
||||
|
||||
@@ -2,6 +2,7 @@ using Content.Shared.DoAfter;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Stacks;
|
||||
using Content.Shared.Verbs;
|
||||
using Content.Shared.Weapons.Ranged.Components;
|
||||
using Content.Shared.Weapons.Ranged.Events;
|
||||
@@ -47,8 +48,17 @@ public abstract partial class SharedGunSystem
|
||||
if (GetBallisticShots(component) >= component.Capacity)
|
||||
return;
|
||||
|
||||
component.Entities.Add(args.Used);
|
||||
Containers.Insert(args.Used, component.Container);
|
||||
var entity = args.Used; // WD EDIT START
|
||||
var doInsert = true;
|
||||
if (TryComp(args.Used, out StackComponent? stack) && stack.Count > 1)
|
||||
{
|
||||
entity = GetStackEntity(args.Used, stack);
|
||||
doInsert = false;
|
||||
}
|
||||
|
||||
component.Entities.Add(entity);
|
||||
if (_netManager.IsServer || doInsert)
|
||||
Containers.Insert(entity, component.Container); // WD EDIT END
|
||||
// Not predicted so
|
||||
Audio.PlayPredicted(component.SoundInsert, uid, args.User);
|
||||
args.Handled = true;
|
||||
@@ -56,6 +66,8 @@ public abstract partial class SharedGunSystem
|
||||
Dirty(uid, component);
|
||||
}
|
||||
|
||||
protected virtual EntityUid GetStackEntity(EntityUid uid, StackComponent stack) { return uid; }
|
||||
|
||||
private void OnBallisticAfterInteract(EntityUid uid, BallisticAmmoProviderComponent component, AfterInteractEvent args)
|
||||
{
|
||||
if (args.Handled ||
|
||||
|
||||
16
Content.Shared/White/Crossbow/DrawableComponent.cs
Normal file
16
Content.Shared/White/Crossbow/DrawableComponent.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Content.Shared.Weapons.Ranged.Components;
|
||||
using Robust.Shared.Audio;
|
||||
|
||||
namespace Content.Shared.White.Crossbow;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class DrawableComponent : Component
|
||||
{
|
||||
[ViewVariables]
|
||||
public bool Drawn;
|
||||
|
||||
public BallisticAmmoProviderComponent Provider = default!;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("soundInsert")]
|
||||
public SoundSpecifier? SoundDraw = new SoundPathSpecifier("/Audio/Weapons/drawbow2.ogg");
|
||||
}
|
||||
71
Content.Shared/White/Crossbow/DrawableSystem.cs
Normal file
71
Content.Shared/White/Crossbow/DrawableSystem.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Weapons.Ranged.Components;
|
||||
using Content.Shared.Weapons.Ranged.Systems;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.White.Crossbow;
|
||||
|
||||
public sealed class DrawableSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<DrawableComponent, ComponentStartup>(OnStartup);
|
||||
SubscribeLocalEvent<DrawableComponent, EntRemovedFromContainerMessage>(OnItemRemove);
|
||||
SubscribeLocalEvent<DrawableComponent, AttemptShootEvent>(OnAttemptShoot);
|
||||
SubscribeLocalEvent<DrawableComponent, UseInHandEvent>(OnUse);
|
||||
}
|
||||
|
||||
private void OnUse(EntityUid uid, DrawableComponent component, UseInHandEvent args)
|
||||
{
|
||||
if (component.Drawn || component.Provider.Count == 0)
|
||||
return;
|
||||
|
||||
args.Handled = true;
|
||||
|
||||
_audio.PlayPredicted(component.SoundDraw, uid, args.User);
|
||||
component.Drawn = true;
|
||||
|
||||
UpdateDrawableAppearance(uid, component);
|
||||
}
|
||||
|
||||
private void OnItemRemove(EntityUid uid, DrawableComponent component, EntRemovedFromContainerMessage args)
|
||||
{
|
||||
if (!component.Drawn || args.Container.ID != component.Provider.Container.ID)
|
||||
return;
|
||||
|
||||
component.Drawn = false;
|
||||
UpdateDrawableAppearance(uid, component);
|
||||
}
|
||||
|
||||
private void OnStartup(EntityUid uid, DrawableComponent component, ComponentStartup args)
|
||||
{
|
||||
component.Provider = EnsureComp<BallisticAmmoProviderComponent>(uid);
|
||||
}
|
||||
|
||||
private void OnAttemptShoot(EntityUid uid, DrawableComponent component, ref AttemptShootEvent args)
|
||||
{
|
||||
if (!component.Drawn)
|
||||
args.Cancelled = true;
|
||||
}
|
||||
|
||||
private void UpdateDrawableAppearance(EntityUid uid, DrawableComponent component)
|
||||
{
|
||||
if (!TryComp<AppearanceComponent>(uid, out var appearance))
|
||||
return;
|
||||
|
||||
_appearance.SetData(uid, DrawableVisuals.Drawn, component.Drawn, appearance);
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum DrawableVisuals : byte
|
||||
{
|
||||
Drawn
|
||||
}
|
||||
10
Content.Shared/White/Crossbow/EmbedEvents.cs
Normal file
10
Content.Shared/White/Crossbow/EmbedEvents.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Content.Shared.Projectiles;
|
||||
|
||||
namespace Content.Shared.White.Crossbow;
|
||||
|
||||
[ByRefEvent]
|
||||
public readonly record struct EmbedStartEvent(EmbeddableProjectileComponent Embed);
|
||||
|
||||
public sealed class EmbedRemovedEvent : EntityEventArgs
|
||||
{
|
||||
}
|
||||
9
Content.Shared/White/Crossbow/PenetratedComponent.cs
Normal file
9
Content.Shared/White/Crossbow/PenetratedComponent.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Content.Shared.White.Crossbow;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class PenetratedComponent : Component
|
||||
{
|
||||
public EntityUid? ProjectileUid;
|
||||
|
||||
public bool IsPinned;
|
||||
}
|
||||
41
Content.Shared/White/Crossbow/PenetratedSystem.cs
Normal file
41
Content.Shared/White/Crossbow/PenetratedSystem.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Content.Shared.Movement.Events;
|
||||
using Content.Shared.Projectiles;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
|
||||
namespace Content.Shared.White.Crossbow;
|
||||
|
||||
public sealed class PenetratedSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
[Dependency] private readonly SharedProjectileSystem _projectile = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<PenetratedComponent, MoveInputEvent>(OnMoveInput);
|
||||
}
|
||||
|
||||
private void OnMoveInput(EntityUid uid, PenetratedComponent component, ref MoveInputEvent args)
|
||||
{
|
||||
if (component is {ProjectileUid: not null, IsPinned: true})
|
||||
_projectile.AttemptEmbedRemove(component.ProjectileUid.Value, uid);
|
||||
}
|
||||
|
||||
public void FreePenetrated(EntityUid uid, PenetratedComponent? penetrated = null)
|
||||
{
|
||||
if (!Resolve(uid, ref penetrated, false))
|
||||
return;
|
||||
|
||||
var xform = Transform(uid);
|
||||
TryComp<PhysicsComponent>(uid, out var physics);
|
||||
_physics.SetBodyType(uid, BodyType.Dynamic, body: physics, xform: xform);
|
||||
_transform.AttachToGridOrMap(uid, xform);
|
||||
penetrated.ProjectileUid = null;
|
||||
penetrated.IsPinned = false;
|
||||
_physics.WakeBody(uid, body: physics);
|
||||
}
|
||||
}
|
||||
@@ -233,6 +233,7 @@
|
||||
- type: DeathGasps
|
||||
- type: ExaminableClothes
|
||||
- type: CharacterInformation
|
||||
- type: Penetrated
|
||||
|
||||
- type: entity
|
||||
save: false
|
||||
|
||||
@@ -32,6 +32,10 @@
|
||||
- type: PhysicalComposition
|
||||
materialComposition:
|
||||
Steel: 50 #Half of a regular steel sheet to reflect the crafting recipe
|
||||
- type: Tag
|
||||
tags:
|
||||
- DroneUsable
|
||||
- CrossbowBolt
|
||||
- type: Stack
|
||||
stackType: MetalRod
|
||||
baseLayer: base
|
||||
@@ -82,6 +86,7 @@
|
||||
tags:
|
||||
- RodMetal1
|
||||
- DroneUsable
|
||||
- CrossbowBolt
|
||||
- type: Sprite
|
||||
state: rods
|
||||
- type: Stack
|
||||
@@ -97,10 +102,31 @@
|
||||
tags:
|
||||
- RodMetal1
|
||||
- DroneUsable
|
||||
- CrossbowBolt
|
||||
- type: Ammo
|
||||
muzzleFlash: null
|
||||
- type: DamageOtherOnHit
|
||||
damage:
|
||||
types:
|
||||
Blunt: 0
|
||||
- type: Sprite
|
||||
state: rods
|
||||
- type: Stack
|
||||
count: 1
|
||||
- type: Fixtures
|
||||
fixtures:
|
||||
fix1:
|
||||
shape: !type:PolygonShape
|
||||
vertices:
|
||||
- -0.20,-0.10
|
||||
- -0.10,-0.20
|
||||
- 0.40,0.30
|
||||
- 0.30,0.40
|
||||
density: 20
|
||||
mask:
|
||||
- ItemMask
|
||||
restitution: 0.3
|
||||
friction: 0.2
|
||||
|
||||
- type: entity
|
||||
parent: PartRodMetal
|
||||
|
||||
@@ -28,8 +28,9 @@
|
||||
sprite: Objects/Misc/rifle_stock.rsi
|
||||
state: icon
|
||||
- type: Construction
|
||||
graph: RifleStockGraph
|
||||
node: riflestock
|
||||
deconstructionTarget: null
|
||||
graph: WeaponPoweredCrossbowGraph
|
||||
node: stock
|
||||
- type: Tag
|
||||
tags:
|
||||
- RifleStock
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
- type: entity
|
||||
name: арбалет
|
||||
parent: BaseItem
|
||||
id: WeaponPoweredCrossbow
|
||||
description: Опасная штука, страшная вещь.
|
||||
components:
|
||||
- type: Sprite
|
||||
sprite: White/Objects/Weapons/crossbow.rsi
|
||||
state: base
|
||||
- type: Clothing
|
||||
quickEquip: false
|
||||
slots:
|
||||
- Back
|
||||
- type: Item
|
||||
size: 80
|
||||
sprite: White/Objects/Weapons/crossbow.rsi
|
||||
- type: Gun
|
||||
forceThrowingAngle: true
|
||||
angle: 225
|
||||
projectileSpeed: 35
|
||||
fireRate: 0.5
|
||||
soundGunshot:
|
||||
path: /Audio/Weapons/click.ogg
|
||||
- type: BallisticAmmoProvider
|
||||
whitelist:
|
||||
tags:
|
||||
- CrossbowBolt
|
||||
capacity: 1
|
||||
soundInsert:
|
||||
path: /Audio/Weapons/Guns/MagIn/revolver_magin.ogg
|
||||
- type: ContainerContainer
|
||||
containers:
|
||||
ballistic-ammo: !type:Container
|
||||
ents: []
|
||||
cell_slot: !type:ContainerSlot
|
||||
- type: PowerCellSlot
|
||||
cellSlotId: cell_slot
|
||||
- type: ItemSlots
|
||||
slots:
|
||||
cell_slot:
|
||||
name: power-cell-slot-component-slot-name-default
|
||||
- type: Drawable
|
||||
- type: Appearance
|
||||
- type: ModifyDamageOnShoot
|
||||
addEmbedding: true
|
||||
offset: 0.2,0.2
|
||||
damage:
|
||||
types:
|
||||
Blunt: 15
|
||||
- type: Powered
|
||||
charge: 360
|
||||
damage:
|
||||
types:
|
||||
Blunt: 30
|
||||
- type: Construction
|
||||
deconstructionTarget: null
|
||||
graph: WeaponPoweredCrossbowGraph
|
||||
node: crossbow
|
||||
|
||||
- type: entity
|
||||
name: часть арбалета
|
||||
parent: BaseItem
|
||||
id: WeaponPoweredCrossbowUnfinished
|
||||
description: Недоделанный арбалет.
|
||||
components:
|
||||
- type: Sprite
|
||||
sprite: White/Objects/Weapons/crossbow.rsi
|
||||
state: base
|
||||
- type: Item
|
||||
size: 80
|
||||
sprite: White/Objects/Weapons/crossbow.rsi
|
||||
- type: Clothing
|
||||
quickEquip: false
|
||||
slots:
|
||||
- Back
|
||||
- type: Construction
|
||||
deconstructionTarget: null
|
||||
graph: WeaponPoweredCrossbowGraph
|
||||
node: unfinished
|
||||
@@ -43,3 +43,55 @@
|
||||
doAfter: 1
|
||||
- node: flamethrower
|
||||
entity: WeaponFlamethrower
|
||||
|
||||
- type: constructionGraph
|
||||
id: WeaponPoweredCrossbowGraph
|
||||
start: stock
|
||||
graph:
|
||||
- node: stock
|
||||
entity: RifleStock
|
||||
edges:
|
||||
- to: unfinished
|
||||
steps:
|
||||
- material: MetalRod
|
||||
amount: 3
|
||||
doAfter: 3
|
||||
- node: unfinished
|
||||
edges:
|
||||
- to: rods
|
||||
- node: unfinished
|
||||
entity: WeaponPoweredCrossbowUnfinished
|
||||
edges:
|
||||
- to: welded
|
||||
steps:
|
||||
- tool: Welding
|
||||
doAfter: 5
|
||||
- node: welded
|
||||
edges:
|
||||
- to: cables
|
||||
steps:
|
||||
- material: Cable
|
||||
amount: 5
|
||||
doAfter: 0.5
|
||||
- node: cables
|
||||
edges:
|
||||
- to: plastic
|
||||
steps:
|
||||
- material: Plastic
|
||||
amount: 3
|
||||
doAfter: 0.5
|
||||
- node: plastic
|
||||
edges:
|
||||
- to: unscrewed
|
||||
steps:
|
||||
- material: Cable
|
||||
amount: 5
|
||||
doAfter: 0.5
|
||||
- node: unscrewed
|
||||
edges:
|
||||
- to: crossbow
|
||||
steps:
|
||||
- tool: Screwing
|
||||
doAfter: 1
|
||||
- node: crossbow
|
||||
entity: WeaponPoweredCrossbow
|
||||
|
||||
@@ -3,3 +3,6 @@
|
||||
|
||||
- type: Tag
|
||||
id: EnergySword
|
||||
|
||||
- type: Tag
|
||||
id: CrossbowBolt
|
||||
|
||||
BIN
Resources/Textures/White/Objects/Weapons/crossbow.rsi/base.png
Normal file
BIN
Resources/Textures/White/Objects/Weapons/crossbow.rsi/base.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 845 B |
BIN
Resources/Textures/White/Objects/Weapons/crossbow.rsi/drawn.png
Normal file
BIN
Resources/Textures/White/Objects/Weapons/crossbow.rsi/drawn.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 919 B |
Binary file not shown.
|
After Width: | Height: | Size: 291 B |
Binary file not shown.
|
After Width: | Height: | Size: 547 B |
BIN
Resources/Textures/White/Objects/Weapons/crossbow.rsi/loaded.png
Normal file
BIN
Resources/Textures/White/Objects/Weapons/crossbow.rsi/loaded.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 973 B |
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"version": 1,
|
||||
"license": "CC-BY-SA-3.0",
|
||||
"copyright": "Taken from paradise at https://github.com/ParadiseSS13/Paradise at 76d0428022d17f3249585d96ac9b69076206efd4",
|
||||
"size": {
|
||||
"x": 32,
|
||||
"y": 32
|
||||
},
|
||||
"states": [
|
||||
{
|
||||
"name": "base"
|
||||
},
|
||||
{
|
||||
"name": "loaded"
|
||||
},
|
||||
{
|
||||
"name": "drawn"
|
||||
},
|
||||
{
|
||||
"name": "inhand-left",
|
||||
"directions": 4
|
||||
},
|
||||
{
|
||||
"name": "inhand-right",
|
||||
"directions": 4
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user