mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 05:27:38 +03:00
Added Right Click Melee Attack to Guns (#24)
* meleeweaponsystem * gun prototype changes * stop breaking the game !!!!!!!! * okey lets go (#WD EDIT TIME) (GOIDA!!!!) * antigoida (file removed because moved) ILOVEGITILOVEGITILOVEGITILOVEGITILOVEGIT * WD EDIT START Co-authored-by: Spatison <137375981+Spatison@users.noreply.github.com> * summary typo fix --------- Co-authored-by: vanx <#vanxxxx> Co-authored-by: Spatison <137375981+Spatison@users.noreply.github.com>
This commit is contained in:
@@ -82,17 +82,9 @@ public sealed partial class MeleeWeaponSystem : SharedMeleeWeaponSystem
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO using targeted actions while combat mode is enabled should NOT trigger attacks.
|
||||
// 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<GunComponent>(weaponUid, out var gun) && gun.UseKey)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// WD EDIT
|
||||
|
||||
var mousePos = _eyeManager.PixelToMap(_inputManager.MouseScreenPosition);
|
||||
|
||||
@@ -112,24 +104,37 @@ public sealed partial class MeleeWeaponSystem : SharedMeleeWeaponSystem
|
||||
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<GunComponent>(weaponUid, out var gun) && gun.UseKey)
|
||||
{
|
||||
RaisePredictiveEvent(new LightAttackEvent(GetNetEntity(target), GetNetEntity(weaponUid), GetNetCoordinates(coordinates)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (HasComp<BlinkComponent>(weaponUid))
|
||||
{
|
||||
if (!_xformQuery.TryGetComponent(entity, out var userXform) || !Timing.IsFirstTimePredicted)
|
||||
@@ -154,9 +159,19 @@ public sealed partial class MeleeWeaponSystem : SharedMeleeWeaponSystem
|
||||
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<GunComponent>(weaponUid, out var gun) && gun.UseKey)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// WD EDIT END
|
||||
|
||||
var attackerPos = Transform(entity).MapPosition;
|
||||
|
||||
if (mousePos.MapId != attackerPos.MapId ||
|
||||
|
||||
@@ -25,6 +25,7 @@ using Robust.Shared.Random;
|
||||
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 @@ public sealed class MeleeWeaponSystem : SharedMeleeWeaponSystem
|
||||
|
||||
_damageExamine.AddDamageExamine(args.Message, damageSpec, Loc.GetString("damage-melee"));
|
||||
|
||||
if (damageSpec * component.HeavyDamageBaseModifier != damageSpec)
|
||||
if (damageSpec * component.HeavyDamageBaseModifier != damageSpec && !TryComp<GunComponent>(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"));
|
||||
}
|
||||
|
||||
|
||||
@@ -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 abstract class SharedMeleeWeaponSystem : EntitySystem
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<MeleeWeaponComponent, HandSelectedEvent>(OnMeleeSelected);
|
||||
SubscribeLocalEvent<MeleeWeaponComponent, ShotAttemptedEvent>(OnMeleeShotAttempted);
|
||||
SubscribeLocalEvent<MeleeWeaponComponent, MeleeAttemptedEvent>(OnMeleeAttempted); // WD EDIT
|
||||
SubscribeLocalEvent<MeleeWeaponComponent, GunShotEvent>(OnMeleeShot);
|
||||
SubscribeLocalEvent<BonusMeleeDamageComponent, GetMeleeDamageEvent>(OnGetBonusMeleeDamage);
|
||||
SubscribeLocalEvent<BonusMeleeDamageComponent, GetHeavyDamageModifierEvent>(OnGetBonusHeavyDamageModifier);
|
||||
@@ -86,7 +87,7 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
|
||||
#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();
|
||||
|
||||
@@ -76,7 +76,7 @@ public abstract partial class SharedGunSystem : EntitySystem
|
||||
{
|
||||
SubscribeAllEvent<RequestShootEvent>(OnShootRequest);
|
||||
SubscribeAllEvent<RequestStopShootEvent>(OnStopShootRequest);
|
||||
SubscribeLocalEvent<GunComponent, MeleeHitEvent>(OnGunMelee);
|
||||
//SubscribeLocalEvent<GunComponent, MeleeHitEvent>(OnGunMelee); // WD EDIT
|
||||
|
||||
// Ammo providers
|
||||
InitializeBallistic();
|
||||
@@ -110,7 +110,9 @@ public abstract partial class SharedGunSystem : EntitySystem
|
||||
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<MeleeWeaponComponent>(uid, out var melee))
|
||||
return;
|
||||
@@ -120,7 +122,8 @@ public abstract partial class SharedGunSystem : EntitySystem
|
||||
component.NextFire = melee.NextAttack;
|
||||
Dirty(component);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
// WD EDIT END
|
||||
|
||||
private void OnShootRequest(RequestShootEvent msg, EntitySessionEventArgs args)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
namespace Content.Shared._White.Weapons.Melee.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Raised on a melee when someone is attempting to attack with it.
|
||||
/// Cancel this event to prevent it from attacking.
|
||||
/// </summary>
|
||||
[ByRefEvent]
|
||||
public record struct MeleeAttemptedEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// The user attempting to attack with the weapon.
|
||||
/// </summary>
|
||||
public EntityUid User;
|
||||
|
||||
/// <summary>
|
||||
/// The weapon being used.
|
||||
/// </summary>
|
||||
public EntityUid Used;
|
||||
|
||||
public bool Cancelled { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Prevent the weapon from attacking
|
||||
/// </summary>
|
||||
public void Cancel()
|
||||
{
|
||||
Cancelled = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allow the weapon to attack again, only use if you know what you are doing
|
||||
/// </summary>
|
||||
public void Uncancel()
|
||||
{
|
||||
Cancelled = false;
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user