diff --git a/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs b/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs index 7604d5f880..17f8a35594 100644 --- a/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs +++ b/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs @@ -8,6 +8,7 @@ using Content.Shared.Weapons.Melee; using Content.Shared.Weapons.Melee.Events; using Content.Shared.Weapons.Ranged.Components; +using Content.Shared.Wieldable.Components; using Robust.Client.GameObjects; using Robust.Client.Graphics; using Robust.Client.Input; @@ -16,6 +17,8 @@ using Robust.Shared.Input; using Robust.Shared.Map; using Robust.Shared.Player; +using Robust.Shared.Prototypes; +using Robust.Shared.Timing; namespace Content.Client.Weapons.Melee; @@ -64,7 +67,7 @@ public override void Update(float frameTime) if (!TryGetWeapon(entity, out var weaponUid, out var weapon)) return; - if (!CombatMode.IsInCombatMode(entity) || !Blocker.CanAttack(entity, weapon: (weaponUid, weapon))) + if (!CombatMode.IsInCombatMode(entity) || !Blocker.CanAttack(entity)) { weapon.Attacking = false; return; @@ -93,10 +96,29 @@ public override void Update(float frameTime) // 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) + + //Frontier: better support melee vs. ranged checks + /*if (TryComp(weaponUid, out var gun) && gun.UseKey) { return; + }*/ + + // Ranged component has priority over melee if both are supported. + bool gunBoundToUse = false; + bool gunBoundToAlt = false; + if (TryComp(weaponUid, out var gun)) { + gunBoundToUse = gun.UseKey; + gunBoundToAlt = !gun.UseKey; //Bound to alt-use when false + + // If ranged mode only works when wielded, do not block melee attacks when unwielded + // (e.g. crusher & crusher glaive) + if (TryComp(weaponUid, out var _) && + TryComp(weaponUid, out var wield)) { + gunBoundToUse &= wield.Wielded; + gunBoundToAlt &= wield.Wielded; + } } + //End Frontier var mousePos = _eyeManager.PixelToMap(_inputManager.MouseScreenPosition); @@ -117,7 +139,7 @@ public override void Update(float frameTime) } // Heavy attack. - if (altDown == BoundKeyState.Down) + if (altDown == BoundKeyState.Down && !gunBoundToAlt) //Frontier: add !gunBoundToAlt condition { // If it's an unarmed attack then do a disarm if (weapon.AltDisarm && weaponUid == entity) @@ -138,9 +160,9 @@ public override void Update(float frameTime) } // Light attack - if (useDown == BoundKeyState.Down) + if (useDown == BoundKeyState.Down && !gunBoundToUse) //Frontier: add !gunBoundToUse condition { - var attackerPos = TransformSystem.GetMapCoordinates(entity); + var attackerPos = Transform(entity).MapPosition; if (mousePos.MapId != attackerPos.MapId || (attackerPos.Position - mousePos.Position).Length() > weapon.Range) @@ -220,7 +242,7 @@ private void ClientHeavyAttack(EntityUid user, EntityCoordinates coordinates, En return; } - var targetMap = TransformSystem.ToMapCoordinates(coordinates); + var targetMap = coordinates.ToMap(EntityManager, TransformSystem); if (targetMap.MapId != userXform.MapID) return; diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Basic/base_wieldable.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Basic/base_wieldable.yml index 690658d0c7..7d183a7e8d 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Basic/base_wieldable.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Basic/base_wieldable.yml @@ -11,3 +11,12 @@ - type: Gun minAngle: 21 maxAngle: 32 + - type: MeleeRequiresWield ## MeleeAttack for Gun + - type: MeleeWeapon + attackRate: .85 + damage: + types: + Blunt: 3 + angle: 0 + - type: StaminaDamageOnHit + damage: 10 diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/HMGs/hmgs.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/HMGs/hmgs.yml index ebcba7d5e4..e06e1c5104 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/HMGs/hmgs.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/HMGs/hmgs.yml @@ -19,6 +19,15 @@ path: /Audio/Weapons/Guns/Empty/lmg_empty.ogg - type: StaticPrice price: 500 + - type: MeleeRequiresWield ## MeleeAttack for Gun + - type: MeleeWeapon + attackRate: .85 + damage: + types: + Blunt: 7 + angle: 0 + - type: StaminaDamageOnHit + damage: 10 # No chamber because HMG may want its own - type: entity diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/LMGs/lmgs.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/LMGs/lmgs.yml index 1a1514f48c..ec8117abc1 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/LMGs/lmgs.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/LMGs/lmgs.yml @@ -61,6 +61,15 @@ price: 500 - type: UseDelay delay: 1 + - type: MeleeRequiresWield ## MeleeAttack for Gun + - type: MeleeWeapon + attackRate: .85 + damage: + types: + Blunt: 3 + angle: 0 + - type: StaminaDamageOnHit + damage: 10 - type: entity name: L6 SAW diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Launchers/launchers.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Launchers/launchers.yml index 4c48ec1f20..99145145bb 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Launchers/launchers.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Launchers/launchers.yml @@ -19,6 +19,15 @@ containers: ballistic-ammo: !type:Container ents: [] + - type: MeleeRequiresWield ## MeleeAttack for Gun + - type: MeleeWeapon + attackRate: .85 + damage: + types: + Blunt: 7 + angle: 0 + - type: StaminaDamageOnHit + damage: 10 - type: entity name: china lake diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Rifles/rifles.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Rifles/rifles.yml index e34433cb56..27f42337e7 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Rifles/rifles.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Rifles/rifles.yml @@ -50,6 +50,15 @@ gun_chamber: !type:ContainerSlot - type: StaticPrice price: 500 + - type: MeleeRequiresWield ## MeleeAttack for Gun + - type: MeleeWeapon + attackRate: .85 + damage: + types: + Blunt: 5 + angle: 0 + - type: StaminaDamageOnHit + damage: 10 - type: entity name: AKMS @@ -221,3 +230,12 @@ path: /Audio/Weapons/Guns/Empty/empty.ogg clumsyProof: true - type: PacifismAllowedGun + - type: MeleeRequiresWield ## MeleeAttack for Gun + - type: MeleeWeapon + attackRate: .85 + damage: + types: + Blunt: 5 + angle: 0 + - type: StaminaDamageOnHit + damage: 10 \ No newline at end of file diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Shotguns/shotguns.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Shotguns/shotguns.yml index 58cf9eaed3..68d52a8d6e 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Shotguns/shotguns.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Shotguns/shotguns.yml @@ -42,6 +42,15 @@ ents: [] - type: StaticPrice price: 500 + - type: MeleeRequiresWield ## MeleeAttack for Gun + - type: MeleeWeapon + attackRate: .85 + damage: + types: + Blunt: 5 + angle: 0 + - type: StaminaDamageOnHit + damage: 10 - type: entity name: Bulldog @@ -100,6 +109,15 @@ - type: Appearance - type: StaticPrice price: 500 + - type: MeleeRequiresWield ## MeleeAttack for Gun + - type: MeleeWeapon + attackRate: .85 + damage: + types: + Blunt: 7 + angle: 0 + - type: StaminaDamageOnHit + damage: 10 - type: entity name: double-barreled shotgun @@ -123,6 +141,13 @@ graph: ShotgunSawn node: start deconstructionTarget: null + - type: MeleeRequiresWield ## MeleeAttack for Gun + - type: MeleeWeapon + attackRate: .85 + damage: + types: + Blunt: 3 + angle: 0 - type: entity name: double-barreled shotgun @@ -133,6 +158,13 @@ components: - type: BallisticAmmoProvider proto: ShellShotgunBeanbag + - type: MeleeRequiresWield ## MeleeAttack for Gun + - type: MeleeWeapon + attackRate: .85 + damage: + types: + Blunt: 1 + angle: 0 - type: entity name: Enforcer @@ -286,6 +318,13 @@ node: shotgun - type: StaticPrice price: 20 + - type: MeleeRequiresWield ## MeleeAttack for Gun + - type: MeleeWeapon + attackRate: .85 + damage: + types: + Blunt: 1 + angle: 0 - type: entity name: improvised shotgun diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Snipers/snipers.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Snipers/snipers.yml index 4ea0061c96..ced509f8a2 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Snipers/snipers.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Snipers/snipers.yml @@ -17,6 +17,7 @@ slots: - Back - suitStorage + - type: MeleeRequiresWield - type: AmmoCounter - type: Gun fireRate: 0.75 @@ -46,6 +47,19 @@ components: - type: Sprite sprite: Objects/Weapons/Guns/Snipers/bolt_gun_wood.rsi + - type: ThrowingAngle + angle: -135 + - type: MeleeRequiresWield ## MeleeAttack for Gun + - type: MeleeWeapon + attackRate: .85 + damage: + types: + Slash: 10 + Piercing: 5 + angle: 0 + animation: WeaponArcThrust + soundHit: + path: /Audio/Weapons/bladeslice.ogg - type: entity name: Hristov @@ -63,6 +77,15 @@ - CartridgeAntiMateriel capacity: 5 proto: CartridgeAntiMateriel + - type: MeleeRequiresWield ## MeleeAttack for Gun + - type: MeleeWeapon + attackRate: .85 + damage: + types: + Blunt: 5 + angle: 0 + - type: StaminaDamageOnHit + damage: 10 - type: entity name: musket