diff --git a/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs b/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs index fbb4a6904d..fc8f9b7687 100644 --- a/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs +++ b/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs @@ -82,17 +82,9 @@ public override void Update(float frameTime) return; } - // TODO using targeted actions while combat mode is enabled should NOT trigger attacks. - - // TODO: Need to make alt-fire melee its own component I guess? - // Melee and guns share a lot in the middle but share virtually nothing at the start and end so - // it's kinda tricky. - // I think as long as we make secondaries their own component it's probably fine - // as long as guncomp has an alt-use key then it shouldn't be too much of a PITA to deal with. - if (TryComp(weaponUid, out var gun) && gun.UseKey) - { - return; - } + // TODO using targeted actions while combat mode is enabled should NOT trigger attacks + + // WD EDIT var mousePos = _eyeManager.PixelToMap(_inputManager.MouseScreenPosition); @@ -112,24 +104,37 @@ public override void Update(float frameTime) coordinates = EntityCoordinates.FromMap(MapManager.GetMapEntityId(mousePos.MapId), mousePos, TransformSystem, EntityManager); } - // Heavy attack. + // WD EDIT START + + // Right click + // Unarmed will try to disarm + // Melee weapons will wideswing + // Ranged weapons will do a light attack. if (altDown == BoundKeyState.Down) { + // Get the target that was clicked on + EntityUid? target = null; + + if (_stateManager.CurrentState is GameplayStateBase screen) + { + target = screen.GetClickedEntity(mousePos); + } + // If it's an unarmed attack then do a disarm if (weapon.AltDisarm && weaponUid == entity) { - EntityUid? target = null; - - if (_stateManager.CurrentState is GameplayStateBase screen) - { - target = screen.GetClickedEntity(mousePos); - } - EntityManager.RaisePredictiveEvent(new DisarmAttackEvent(GetNetEntity(target), GetNetCoordinates(coordinates))); return; } // WD EDIT START + // If it's a ranged weapon then do a light attack + if (TryComp(weaponUid, out var gun) && gun.UseKey) + { + RaisePredictiveEvent(new LightAttackEvent(GetNetEntity(target), GetNetEntity(weaponUid), GetNetCoordinates(coordinates))); + return; + } + if (HasComp(weaponUid)) { if (!_xformQuery.TryGetComponent(entity, out var userXform) || !Timing.IsFirstTimePredicted) @@ -154,9 +159,19 @@ public override void Update(float frameTime) return; } - // Light attack + // WD EDIT START + + // Left click if (useDown == BoundKeyState.Down) { + // If it's a gun that shoots with left click do not attack + if (TryComp(weaponUid, out var gun) && gun.UseKey) + { + return; + } + + // WD EDIT END + var attackerPos = Transform(entity).MapPosition; if (mousePos.MapId != attackerPos.MapId || diff --git a/Content.Server/Weapons/Melee/MeleeWeaponSystem.cs b/Content.Server/Weapons/Melee/MeleeWeaponSystem.cs index 7e611d1ded..5bfacdf8de 100644 --- a/Content.Server/Weapons/Melee/MeleeWeaponSystem.cs +++ b/Content.Server/Weapons/Melee/MeleeWeaponSystem.cs @@ -25,6 +25,7 @@ using System.Linq; using System.Numerics; using Content.Shared.Chat; +using Content.Shared.Weapons.Ranged.Components; // WD EDIT namespace Content.Server.Weapons.Melee; @@ -58,7 +59,7 @@ private void OnMeleeExamineDamage(EntityUid uid, MeleeWeaponComponent component, _damageExamine.AddDamageExamine(args.Message, damageSpec, Loc.GetString("damage-melee")); - if (damageSpec * component.HeavyDamageBaseModifier != damageSpec) + if (damageSpec * component.HeavyDamageBaseModifier != damageSpec && !TryComp(uid, out var gun)) // Guns don't have a heavy attack // WD EDIT _damageExamine.AddDamageExamine(args.Message, damageSpec * component.HeavyDamageBaseModifier, Loc.GetString("damage-melee-heavy")); } diff --git a/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs b/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs index a27eab1eed..efcd6d6b55 100644 --- a/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs +++ b/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs @@ -1,6 +1,7 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Numerics; +using Content.Shared._White.Weapons.Melee.Events; // WD EDIT using Content.Shared.ActionBlocker; using Content.Shared.Administration.Logs; using Content.Shared.CombatMode; @@ -62,7 +63,7 @@ public override void Initialize() base.Initialize(); SubscribeLocalEvent(OnMeleeSelected); - SubscribeLocalEvent(OnMeleeShotAttempted); + SubscribeLocalEvent(OnMeleeAttempted); // WD EDIT SubscribeLocalEvent(OnMeleeShot); SubscribeLocalEvent(OnGetBonusMeleeDamage); SubscribeLocalEvent(OnGetBonusHeavyDamageModifier); @@ -86,7 +87,7 @@ private void OnMapInit(EntityUid uid, MeleeWeaponComponent component, MapInitEve #endif } - private void OnMeleeShotAttempted(EntityUid uid, MeleeWeaponComponent comp, ref ShotAttemptedEvent args) + private void OnMeleeAttempted(EntityUid uid, MeleeWeaponComponent comp, ref MeleeAttemptedEvent args) // WD EDIT { if (comp.NextAttack > Timing.CurTime) args.Cancel(); diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs index 3c5e5c7984..0a28576dff 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs @@ -76,7 +76,7 @@ public override void Initialize() { SubscribeAllEvent(OnShootRequest); SubscribeAllEvent(OnStopShootRequest); - SubscribeLocalEvent(OnGunMelee); + //SubscribeLocalEvent(OnGunMelee); // WD EDIT // Ammo providers InitializeBallistic(); @@ -110,7 +110,9 @@ private void OnMapInit(Entity gun, ref MapInitEvent args) RefreshModifiers((gun, gun)); } - private void OnGunMelee(EntityUid uid, GunComponent component, MeleeHitEvent args) + // WD EDIT START + // Sets the gun cooldown to the melee attack cooldown on attack. Removed since it felt very unintuitive. + /*private void OnGunMelee(EntityUid uid, GunComponent component, MeleeHitEvent args) { if (!TryComp(uid, out var melee)) return; @@ -120,7 +122,8 @@ private void OnGunMelee(EntityUid uid, GunComponent component, MeleeHitEvent arg component.NextFire = melee.NextAttack; Dirty(component); } - } + }*/ + // WD EDIT END private void OnShootRequest(RequestShootEvent msg, EntitySessionEventArgs args) { diff --git a/Content.Shared/_White/Weapons/Melee/Events/MeleeAttemptedEvent.cs b/Content.Shared/_White/Weapons/Melee/Events/MeleeAttemptedEvent.cs new file mode 100644 index 0000000000..0c62977913 --- /dev/null +++ b/Content.Shared/_White/Weapons/Melee/Events/MeleeAttemptedEvent.cs @@ -0,0 +1,37 @@ +namespace Content.Shared._White.Weapons.Melee.Events; + +/// +/// Raised on a melee when someone is attempting to attack with it. +/// Cancel this event to prevent it from attacking. +/// +[ByRefEvent] +public record struct MeleeAttemptedEvent +{ + /// + /// The user attempting to attack with the weapon. + /// + public EntityUid User; + + /// + /// The weapon being used. + /// + public EntityUid Used; + + public bool Cancelled { get; private set; } + + /// + /// Prevent the weapon from attacking + /// + public void Cancel() + { + Cancelled = true; + } + + /// + /// Allow the weapon to attack again, only use if you know what you are doing + /// + public void Uncancel() + { + Cancelled = false; + } +} diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Basic/pka.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Basic/pka.yml index 226fa29164..689a6a3b69 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Basic/pka.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Basic/pka.yml @@ -11,5 +11,16 @@ - state: animation-icon visible: false map: [ "empty-icon" ] + - type: MeleeWeapon # WD EDIT + attackRate: 0.7 + damage: + types: + Blunt: 7 + soundHit: + collection: GenericHit + - type: IncreaseDamageOnWield # WD EDIT + damage: + types: + Blunt: 3 # todo: add itemcomponent with inhandVisuals states using unused texture and animation assets in kinetic_accelerator.rsi # todo: add clothingcomponent with clothingVisuals states using unused texture and animations assets in kinetic_accelerator.rsi diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml index ec0a0a148b..36b483db3a 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml @@ -32,6 +32,13 @@ - type: Appearance - type: StaticPrice price: 500 + - type: MeleeWeapon # WD EDIT + attackRate: 0.7 + damage: + types: + Blunt: 10 + soundHit: + collection: GenericHit - type: entity id: BaseWeaponPowerCell @@ -68,6 +75,13 @@ - type: ContainerContainer containers: gun_magazine: !type:ContainerSlot + - type: MeleeWeapon # WD EDIT + attackRate: 0.7 + damage: + types: + Blunt: 10 + soundHit: + collection: GenericHit - type: entity id: BaseWeaponBatterySmall @@ -88,6 +102,11 @@ slots: - Belt - suitStorage + - type: MeleeWeapon # WD EDIT + attackRate: 1 + damage: + types: + Blunt: 7 - type: entity id: BaseWeaponPowerCellSmall diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/LMGs/lmgs.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/LMGs/lmgs.yml index 49b2eeaada..8487a592e8 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/LMGs/lmgs.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/LMGs/lmgs.yml @@ -60,6 +60,13 @@ price: 500 - type: UseDelay delay: 1 + - type: MeleeWeapon # WD EDIT + attackRate: 0.5 + damage: + types: + Blunt: 8 + soundHit: + collection: GenericHit - type: entity name: L6 SAW diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Pistols/pistols.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Pistols/pistols.yml index 410664e46e..0aa737049c 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Pistols/pistols.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Pistols/pistols.yml @@ -65,6 +65,12 @@ - type: Appearance - type: StaticPrice price: 500 + - type: MeleeWeapon # WD EDIT + damage: + types: + Blunt: 7 + soundHit: + collection: GenericHit - type: entity name: viper diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Revolvers/revolvers.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Revolvers/revolvers.yml index c5237cdad9..08661aa301 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Revolvers/revolvers.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Revolvers/revolvers.yml @@ -50,6 +50,12 @@ path: /Audio/Weapons/Guns/MagIn/revolver_magin.ogg - type: StaticPrice price: 500 + - type: MeleeWeapon # WD EDIT + damage: + types: + Blunt: 7 + soundHit: + collection: GenericHit - type: entity name: Deckard diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Rifles/rifles.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Rifles/rifles.yml index c55b2b6b09..a17d98dcb0 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Rifles/rifles.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Rifles/rifles.yml @@ -49,6 +49,13 @@ gun_chamber: !type:ContainerSlot - type: StaticPrice price: 500 + - type: MeleeWeapon # WD EDIT + attackRate: 0.7 + damage: + types: + Blunt: 10 + soundHit: + collection: GenericHit - type: entity name: AKMS @@ -98,6 +105,10 @@ steps: 1 zeroVisible: true - type: Appearance + - type: MeleeWeapon # WD EDIT + damage: + types: + Blunt: 10 - type: entity name: M-90gl diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/SMGs/smgs.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/SMGs/smgs.yml index 3962f6e1f5..a70809b8b1 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/SMGs/smgs.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/SMGs/smgs.yml @@ -20,7 +20,7 @@ maxAngle: 16 fireRate: 8 angleIncrease: 3 - angleDecay: 16 + angleDecay: 16 selectedMode: FullAuto availableModes: - SemiAuto @@ -54,6 +54,13 @@ gun_chamber: !type:ContainerSlot - type: StaticPrice price: 500 + - type: MeleeWeapon # WD EDIT + attackRate: 0.8 + damage: + types: + Blunt: 8 + soundHit: + collection: GenericHit - type: entity name: Atreides @@ -234,7 +241,7 @@ minAngle: 1 maxAngle: 6 angleIncrease: 1.5 - angleDecay: 6 + angleDecay: 6 selectedMode: FullAuto shotsPerBurst: 5 availableModes: diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Shotguns/shotguns.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Shotguns/shotguns.yml index 52b05b6d60..63f554e448 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Shotguns/shotguns.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Shotguns/shotguns.yml @@ -43,6 +43,13 @@ ents: [] - type: StaticPrice price: 500 + - type: MeleeWeapon # WD EDIT + attackRate: 0.7 + damage: + types: + Blunt: 10 + soundHit: + collection: GenericHit - type: entity name: Bulldog diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Snipers/snipers.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Snipers/snipers.yml index bd6dfdf10f..488c4f8ce6 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Snipers/snipers.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Snipers/snipers.yml @@ -37,6 +37,13 @@ ents: [] - type: StaticPrice price: 500 + - type: MeleeWeapon # WD EDIT + attackRate: 0.5 + damage: + types: + Blunt: 8 + soundHit: + collection: GenericHit - type: entity name: Kardashev-Mosin @@ -54,6 +61,13 @@ soundGunshot: path: /Audio/Weapons/Guns/Gunshots/sniper.ogg fireOnDropChance: 1 + - type: MeleeWeapon # WD EDIT + damage: + types: + Piercing: 10 + Slash: 5 + soundHit: + path: /Audio/Weapons/bladeslice.ogg - type: entity name: Hristov