Autoattacking weapons (#23765)

auto attacks
This commit is contained in:
Nemanja
2024-01-09 02:25:07 -05:00
committed by GitHub
parent e97fd47a87
commit 5db615af54
5 changed files with 18 additions and 6 deletions

View File

@@ -69,7 +69,7 @@ public sealed partial class MeleeWeaponSystem : SharedMeleeWeaponSystem
var useDown = _inputSystem.CmdStates.GetState(EngineKeyFunctions.Use); var useDown = _inputSystem.CmdStates.GetState(EngineKeyFunctions.Use);
var altDown = _inputSystem.CmdStates.GetState(EngineKeyFunctions.UseSecondary); var altDown = _inputSystem.CmdStates.GetState(EngineKeyFunctions.UseSecondary);
if (useDown != BoundKeyState.Down && altDown != BoundKeyState.Down) if (weapon.AutoAttack || useDown != BoundKeyState.Down && altDown != BoundKeyState.Down)
{ {
if (weapon.Attacking) if (weapon.Attacking)
{ {

View File

@@ -60,6 +60,12 @@ public sealed partial class MeleeWeaponComponent : Component
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] [ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
public bool Attacking = false; public bool Attacking = false;
/// <summary>
/// If true, attacks will be repeated automatically without requiring the mouse button to be lifted.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
public bool AutoAttack;
/// <summary> /// <summary>
/// Base damage for this weapon. Can be modified via heavy damage or other means. /// Base damage for this weapon. Can be modified via heavy damage or other means.
/// </summary> /// </summary>

View File

@@ -353,6 +353,7 @@
- type: Clothing - type: Clothing
sprite: Clothing/Hands/Gloves/northstar.rsi sprite: Clothing/Hands/Gloves/northstar.rsi
- type: MeleeWeapon - type: MeleeWeapon
autoAttack: true
attackRate: 4 attackRate: 4
damage: damage:
types: types:

View File

@@ -14,12 +14,15 @@
sprite: Objects/Weapons/Melee/chainsaw.rsi sprite: Objects/Weapons/Melee/chainsaw.rsi
state: icon state: icon
- type: MeleeWeapon - type: MeleeWeapon
autoAttack: true
angle: 0
wideAnimationRotation: -135 wideAnimationRotation: -135
attackRate: 4
damage: damage:
types: types:
Slash: 5 Slash: 2
Blunt: 5 Blunt: 2
Structural: 10 Structural: 4
soundHit: soundHit:
path: /Audio/Weapons/chainsaw.ogg path: /Audio/Weapons/chainsaw.ogg
params: params:
@@ -27,8 +30,8 @@
- type: IncreaseDamageOnWield - type: IncreaseDamageOnWield
damage: damage:
types: types:
Slash: 10 Slash: 4
Structural: 10 Structural: 4
- type: Item - type: Item
size: Normal size: Normal
sprite: Objects/Weapons/Melee/chainsaw.rsi sprite: Objects/Weapons/Melee/chainsaw.rsi

View File

@@ -49,6 +49,8 @@
sprite: Objects/Tools/handdrill.rsi sprite: Objects/Tools/handdrill.rsi
state: handdrill state: handdrill
- type: MeleeWeapon - type: MeleeWeapon
autoAttack: true
angle: 0
wideAnimationRotation: -90 wideAnimationRotation: -90
soundHit: soundHit:
path: "/Audio/Items/drill_hit.ogg" path: "/Audio/Items/drill_hit.ogg"