-
Notifications
You must be signed in to change notification settings - Fork 1
Adding a Melee Attack To Your Guns.
Vuthakral edited this page Sep 6, 2020
·
5 revisions
Pretty much the easiest thing to do, to be honest. All the code is already in the base, but is not enabled by default. Just paste this code into your swep, and follow the settings described below it:
SWEP.Primary.CanMelee = true
SWEP.Primary.MeleeSwingSound = Sound( "" )
SWEP.Primary.MeleeHitSoundWorld = Sound( "" )
SWEP.Primary.MeleeHitSoundFlesh = Sound( "" )
SWEP.Primary.MeleeHitSoundEnt = Sound( "" )
SWEP.Primary.MeleeImpactDecal = ""
SWEP.Primary.MeleeDamage = 12
SWEP.Primary.MeleeDamageType = DMG_CLUB
SWEP.Primary.MeleeRange = 16.5
SWEP.Primary.MeleeForce = 5
SWEP.Primary.MeleeDelayMiss = 0.42
SWEP.Primary.MeleeDelayHit = 0.54
SWEP.Primary.CanAttackCrouched = false
SWEP.Primary.MeleeHitActivity = nil
SWEP.Primary.MeleeMissActivity = ACT_VM_PRIMARYATTACK
SWEP.Primary.MeleeHitDelay = 0.1
SWEP.Primary.MeleeStartX = 25
SWEP.Primary.MeleeEndX = -25
SWEP.Primary.MeleeStartY = -5
SWEP.Primary.MeleeEndY = 5
SWEP.Primary.MeleeShakeMul = 1
- SWEP.Primary.CanMelee // Enables melee ability if set to true
- SWEP.Primary.MeleeSwingSound // Melee sound (optional)
- SWEP.Primary.MeleeHitSoundWorld // Sound to play if the melee impacts with the world, on top of the default material impact. (optional)
- SWEP.Primary.MeleeHitSoundFlesh // Sound to play if the melee impacts a player or NPC (optional)
- SWEP.Primary.MeleeHitSoundEnt // Sound to play if the melee impacts a prop or entity (optional)
- SWEP.Primary.MeleeImpactDecal // Decal to apply to the model upon impact. https://wiki.garrysmod.com/page/util/Decal#/#Built_in_Decals (optional)
- SWEP.Primary.MeleeDamage // How much damage the melee attack will do.
- SWEP.Primary.MeleeDamageType // The damage type the melee attack is. https://wiki.garrysmod.com/page/Enums/DMG
- SWEP.Primary.MeleeRange // The range at which the melee attack can reach.
- SWEP.Primary.MeleeForce // The amount of physics force that should be applied to an object hit by the melee attaack.
- SWEP.Primary.MeleeDelayMiss // If the attack misses, how long of a delay (in seconds) should be applied before the weapon can melee attack again.
- SWEP.Primary.MeleeDelayHit // If the attack hits, how long of a delay (in seconds) should be applied before the weapon can melee attack again.
- SWEP.Primary.CanAttackCrouched // If the weapon can perform a melee attack while the player is crouched.
- SWEP.Primary.MeleeHitActivity // The animation to play on the viewmodel when the melee attack hits. (optional) https://wiki.garrysmod.com/page/Enums/ACT
- SWEP.Primary.MeleeMissActivity // The animation to play on the viewmodel when the melee attack is started https://wiki.garrysmod.com/page/Enums/ACT
- SWEP.Primary.MeleeHitDelay // How long (in seconds) it should take for the melee's arc registration to start (Hint: 0 is as soon as the melee starts.)
- SWEP.Primary.MeleeStartX // enable debug mode to see this visualized. The start direction of the swing, on the horizontal axis
- SWEP.Primary.MeleeEndX // enable debug mode to see this visualized. The end direction of the swing, on the horizontal axis
- SWEP.Primary.MeleeStartY // enable debug mode to see this visualized. The start direction of the swing, on the vertical axis
- SWEP.Primary.MeleeEndY // enable debug mode to see this visualized. The end direction of the swing, on the vertical axis