-
Notifications
You must be signed in to change notification settings - Fork 1
Melee Base Template
Vuthakral edited this page Aug 28, 2019
·
1 revision
On this page you can find a template for a working combat knife SWEP. I highly recommend you copy and paste the first code block without comments, and then use the rest of the page here as reference for what each setting does.
Start by making a new lua file in your lua\weapons\ folder and name it what you want. e.g. yourname_weaponname, or in Draconic's case, drc_example_knife
SWEP.Base = "draconic_melee_base"
SWEP.Gun = "drc_example_knife"
SWEP.HoldType = "knife" -- https://wiki.garrysmod.com/page/Hold_Types
SWEP.CrouchHoldType = "knife"
SWEP.IdleSequence = "idle"
SWEP.WalkSequence = "idle"
SWEP.Category = "Draconic Examples"
SWEP.PrintName = "Knife Example"
SWEP.Auhtor = "Vuthakral"
SWEP.Contact = " https://discord.gg/6Y7WXrX // Steam: Vuthakral // Disc: Vuthakral#9761 "
SWEP.Purpose = ""
SWEP.Instructions = ""
SWEP.Spawnable = true
SWEP.AdminSpawnable = false
SWEP.DrawCrosshair = true
SWEP.Slot = 0
SWEP.SlotPos = 1
SWEP.UseHands = true
SWEP.ViewModelFlip = false
SWEP.ViewModel = "models/weapons/cstrike/c_knife_t.mdl"
SWEP.WorldModel = "models/weapons/w_knife_t.mdl"
SWEP.ViewModelFOV = 70
SWEP.VMPos = Vector(0, 0, 0)
SWEP.VMAng = Vector(0, 0, 0)
SWEP.SS = 1
SWEP.BS = 2
SWEP.Primary.SwingSound = Sound( "draconic.BladeSwingSmall" )
SWEP.Primary.HitSoundWorld = Sound( "draconic.BladeSmallHitWorld" )
SWEP.Primary.HitSoundFlesh = Sound( "draconic.BladeSmallHitFlesh" )
SWEP.Primary.HitSoundEnt = Sound( "draconic.BladeSmallHitWorld" )
SWEP.Primary.HoldType = "knife"
SWEP.Primary.HoldTypeCrouch = "knife"
SWEP.Primary.ImpactDecal = "ManhackCut"
SWEP.Primary.Automatic = true
SWEP.Primary.Damage = 7
SWEP.Primary.DamageType = DMG_SLASH
SWEP.Primary.Range = 20
SWEP.Primary.Force = 5
SWEP.Primary.DelayMiss = 0.42
SWEP.Primary.DelayHit = 0.54
SWEP.Primary.CanAttackCrouched = true
SWEP.Primary.HitActivity = ACT_VM_PRIMARYATTACK
SWEP.Primary.CrouchHitActivity = ACT_VM_PRIMARYATTACK
SWEP.Primary.MissActivity = ACT_VM_PRIMARYATTACK
SWEP.Primary.CrouchMissActivity = ACT_VM_PRIMARYATTACK
SWEP.Primary.HitDelay = 0.14
SWEP.Secondary.SwingSound = Sound( "draconic.BladeStabSmall" )
SWEP.Secondary.HitSoundWorld = Sound( "draconic.BladeSmallHitWorld" )
SWEP.Secondary.HitSoundFlesh = Sound( "draconic.BladeSmallStabFlesh" )
SWEP.Secondary.HitSoundEnt = Sound( "draconic.BladeSmallHitWorld" )
SWEP.Secondary.HoldType = "knife"
SWEP.Secondary.HoldTypeCrouch = "knife"
SWEP.Secondary.ImpactDecal = "ManhackCut"
SWEP.Secondary.Automatic = true
SWEP.Secondary.Damage = 65
SWEP.Secondary.DamageType = DMG_SLASH
SWEP.Secondary.Range = 30
SWEP.Secondary.Force = 7
SWEP.Secondary.DelayMiss = 1.5
SWEP.Secondary.DelayHit = 0.78
SWEP.Secondary.CanAttackCrouched = true
SWEP.Secondary.HitActivity = ACT_VM_MISSCENTER
SWEP.Secondary.CrouchHitActivity = ACT_VM_MISSCENTER
SWEP.Secondary.MissActivity = ACT_VM_MISSCENTER
SWEP.Secondary.CrouchMissActivity = ACT_VM_MISSCENTER
SWEP.Secondary.HitDelay = 0.19
SWEP.Secondary.Velocity = Vector(0, 0, 0)
SWEP.Primary.CanLunge = true
SWEP.Primary.LungeAutomatic = false
SWEP.Primary.LungeKeyInput = IN_USE
SWEP.Primary.LungeVelocity = 1000
SWEP.Primary.LungeMaxDist = 250
SWEP.Primary.LungeSwingSound = Sound( "" )
SWEP.Primary.LungeHitSoundWorld = Sound( "" )
SWEP.Primary.LungeHitSoundFlesh = Sound( "" )
SWEP.Primary.LungeHitSoundEnt = Sound( "" )
SWEP.LungeHoldType = "melee"
SWEP.LungeHoldTypeCrouch = "melee"
SWEP.Primary.LungeImpactDecal = ""
SWEP.Primary.LungeHitAct = ACT_VM_PRIMARYATTACK
SWEP.Primary.LungeMissAct = ACT_VM_PRIMARYATTACK
SWEP.Primary.LungeDelayMiss = 1.3
SWEP.Primary.LungeDelayHit = 0.7
SWEP.Primary.LungeHitDelay = 0.26
SWEP.Primary.LungeDamage = 72
SWEP.Primary.LungeDamageType = DMG_CLUB
SWEP.Primary.LungeRange = 25
SWEP.Primary.LungeForce = 20
- SWEP.Base // What defines which base to use for your weapon.
- SWEP.Gun // An identifier for your weapon. Currently unused but will be used in the future. Please identify your guns with the name.
- SWEP.Holdtype // The standing holdtype of your weapon. https://wiki.garrysmod.com/page/Hold_Types
- SWEP.CrouchHoldtype ^^^
- SWEP.IdleSequence // The idle animation of your weapon's viewmodel. This is used for idle/walking animations.
- SWEP.WalkSequence ^^^
- SWEP.Category // The category in the spawnmenu in which your weapon will appear.
- SWEP.PrintName // The name that will appear on the HUD for your weapon.
- SWEP.Author // The name that will appear under the name/icon in the weapon select menu.
- SWEP.Contact // ^^^
- SWEP.Purpose // ^^^
- SWEP.Instructions // ^^^
- SWEP.Spawnable // The setting that must be set to true for your weapon to appear in the spawnmenu.
- SWEP.AdminSpawnable // A setting that, if set to true, will make it so only admins can spawn your weapon.
- SWEP.Slot // The inventory slot which hte weapon will be categories into. It starts from 0. Slot 0 is your "1" key ingame.
- SWEP.SlotPos // How far down in the slot your weapon will be placed. Again, 0 is the start.
- SWEP.UseHands // The setting to tell the weapon whether or not it should use Garry's Mod's c_hands system
- SWEP.ViewModelFlip // The setting which will flip your viewmodel from left -> right or right -> left.
- SWEP.ViewModel // The setting to define what model to use for the first person model of your weapon
- SWEP.WorldModel // The setting to define what model to use for the third person model of your weapon
- SWEP.ViewmodelFOV // The field of view of the viewmodel. Source displays your current weapon on a unique FOV.
- SWEP.VMPos // The offset position of your SWEP.
- SWEP.VMAng // ^ but for angles
- SWEP.SS // The sway scale built into source. Defaulted to 1. Sway is the movement when you move your character's vision around.
- SWEP.BS // The bob scale built into source. Defaulted to 1. Bob is the movement when you move your character around in the world.
- SWEP.Primary.SwingSound // Melee sound
- SWEP.Primary.HitSoundWorld // Sound to play if the melee impacts with the world, on top of the default material impact.
- SWEP.Primary.HitSoundFlesh // Sound to play if the melee impacts a player or NPC
- SWEP.Primary.HitSoundEnt // Sound to play if the melee impacts a prop or entity
- SWEP.Primary.HoldType // Holdtype to use for a primary attack when standing
- SWEP.Primary.HoldTypeCrouch // Holdtype to use for a primary attack when crouching
- SWEP.Primary.ImpactDecal // Decal to apply to the model upon impact. https://wiki.garrysmod.com/page/util/Decal#/#Built_in_Decals
- SWEP.Primary.Automatic // Whether or not the primary attack should repeat automatically if the primary trigger is held.
- SWEP.Primary.Damage // Self explanatory.
- SWEP.Primary.DamageType // The damage type the melee attack is. https://wiki.garrysmod.com/page/Enums/DMG
- SWEP.Primary.Range // The range at which the melee attack can reach.
- SWEP.Primary.Force // The amount of physics force that should be applied to an object hit by the melee attack.
- SWEP.Primary.DelayMiss // If the attack misses, how long of a delay (in seconds) should be applied before the player can primary attack
- SWEP.Primary.DelayHit // If the attack hits, how long of a delay (in seconds) should be applied before the player can primary attack again.
- SWEP.Primary.CanAttackCrouched // Handles if the weapon can do a primary attack while crouched
- SWEP.Primary.HitActivity // The animation to play on the viewmodel if the melee attack hits while standing. https://wiki.garrysmod.com/page/Enums/ACT
- SWEP.Primary.CrouchHitActivity // The animation to play on the viewmodel if the melee attack hits while crouching. https://wiki.garrysmod.com/page/Enums/ACT
- SWEP.Primary.MissActivity // The animation to play on the viewmodel if the melee attack misses while standing. https://wiki.garrysmod.com/page/Enums/ACT
- SWEP.Primary.CrouchMissActivity // The animation to play on the viewmodel if the melee attack misses while crouching. https://wiki.garrysmod.com/page/Enums/ACT
- SWEP.Primary.HitDelay // How long (in seconds) should it take for the melee to actually impact? (Hint: 0 is as soon as the melee starts.)
- SWEP.Primary.CanLunge // Controls if the weapon can lunge attack or not.
- SWEP.Primary.LungeAutomatic // If the lunge happens automatically when you are within range and have your crosshair over your target a la Halo energy sword style.
- SWEP.Primary.LungeKeyInput // If LungeAutomatic == false, the IN_ enumeration to use to detect a lunge attack. To perform a lunge attack this defined key must be held, and then mouse 1 be pressed while your crosshair is over your target. https://wiki.garrysmod.com/page/Enums/IN
- SWEP.Primary.LungeMaxDist // The maximum distance a target can be (in hammer units) from the player attempting to lunge before it just does a normal primary attack instead.
- SWEP.Primary.LungeSwingSound // Sound to play when performing a lunge attack
- SWEP.Primary.LungeHitSoundWorld // Sound to play if the lunge attack hits the world
- SWEP.Primary.LungeHitSoundFlesh // Sound to play if the lunge attack hits an NPC/Player
- SWEP.Primary.LungeHitSoundEnt // Sound to play if the lunge attack hits an entity/prop
- SWEP.LungeHoldType // Holdtype to use for the lunge attack if the player is standing.
- SWEP.LungeHoldTypeCrouch // Holdtype to use for the lunge attack if the player is crouching
- SWEP.Primary.LungeImpactDecal // Decal to apply to the model upon impact. https://wiki.garrysmod.com/page/util/Decal#/#Built_in_Decals
- SWEP.Primary.LungeHitAct // The animation to play on the viewmodel if the lunge attack hits. https://wiki.garrysmod.com/page/Enums/ACT
- SWEP.Primary.LungeMissAct // The animation to play on the viewmodel if the lunge attack missess. https://wiki.garrysmod.com/page/Enums/ACT
- SWEP.Primary.LungeDelayMiss // If the attack misses, how long of a delay (in seconds) should be applied before the player can lunge attack again.
- SWEP.Primary.LungeDelayHit // If the attack hits, how long of a delay (in seconds) should be applied before the player can lunge attack again.
- SWEP.Primary.LungeHitDelay // How long (in seconds) should it take for the lunge to actually impact? (Hint: 0 is as soon as the lunge starts.)
- SWEP.Primary.LungeDamage // Self explanatory
- SWEP.Primary.LungeDamageType // The damage type the melee attack is. https://wiki.garrysmod.com/page/Enums/DMG
- SWEP.Primary.LungeRange // The range at which the lunge attack can reach.
- SWEP.Primary.LungeForce // The amount of physics force that should be applied to an object hit by the lunge attack.