-
Notifications
You must be signed in to change notification settings - Fork 1
Adding a Melee Attack To Your Guns.
Vuthakral edited this page Aug 28, 2019
·
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.MeleeKeyInput = IN_USE
SWEP.Primary.MeleeSwingSound = Sound( "" )
SWEP.Primary.MeleeHitSoundWorld = Sound( "" )
SWEP.Primary.MeleeHitSoundFlesh = Sound( "" )
SWEP.Primary.MeleeHitSoundEnt = Sound( "" )
SWEP.Primary.MeleeImpactDecal = ""
SWEP.Primary.MeleeDamage = 32
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 = ACT_VM_HITCENTER
SWEP.Primary.MeleeMissActivity = ACT_VM_HITCENTER
SWEP.Primary.MeleeHitDelay = 0.22
- SWEP.Primary.CanMelee // Enables melee ability if set to true
- SWEP.Primary.MeleeKeyInput // The IN_ enumeration to use to detect a melee attack. To perform a melee attack this defined key must be held, and then mouse 1 be pressed. https://wiki.garrysmod.com/page/Enums/IN
- SWEP.Primary.MeleeSwingSound // Melee sound
- SWEP.Primary.MeleeHitSoundWorld // Sound to play if the melee impacts with the world, on top of the default material impact.
- SWEP.Primary.MeleeHitSoundFlesh // Sound to play if the melee impacts a player or NPC
- SWEP.Primary.MeleeHitSoundEnt // Sound to play if the melee impacts a prop or entity
- SWEP.Primary.MeleeImpactDecal // Decal to apply to the model upon impact. https://wiki.garrysmod.com/page/util/Decal#/#Built_in_Decals
- 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 if the melee attack hits. https://wiki.garrysmod.com/page/Enums/ACT
- SWEP.Primary.MeleeMissActivity // The animation to play on the viewmodel if the melee attack misses. https://wiki.garrysmod.com/page/Enums/ACT
- SWEP.Primary.MeleeHitDelay // How long (in seconds) should it take for the melee to actually impact? (Hint: 0 is as soon as the melee starts.)