Skip to content

Instantly share code, notes, and snippets.

@YuRaNnNzZZ
Last active January 24, 2023 07:29
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save YuRaNnNzZZ/b6c9decb7e6f977645e143410875ba63 to your computer and use it in GitHub Desktop.
Save YuRaNnNzZZ/b6c9decb7e6f977645e143410875ba63 to your computer and use it in GitHub Desktop.
TFA Base Documentation (obsolete)

All base documentation has moved to it's own GitHub repo: https://github.com/YuRaNnNzZZ/TFA-SWEP-Base-Documentation

This Gist will not be updated anymore.

This is the official TFA SWEP Base documentation.

Before going through anything from here, make sure you have read through Lua basics guide for GMod here first!

List of contents:

Paths that are loaded by the base automatically (in load order):

  • lua/tfa/enums/ - Early enums initialization (only recommended for early global variables declaration)
  • lua/tfa/modules/ - Base modules (official modules are loaded first; custom modules loading is only kept for backwards compatibility and is unsupported!)
  • lua/tfa/external/ - External modules (code loaded in there is guaranteed to have TFA global variable initalized)
  • lua/tfa/att/ - Attachments (files with base in their name are loaded first)

All paths (except attachments) support client and server-side separation by prepending cl_ or sv_ to the file name.

For any questions regarding this documentation or any problems with developing addons for TFA Base, post in #development-help channel of the official support Discord server.

If you want to translate the base to your language, take a look at the localization reference!

-- TFA Base Animations reference
-- Example of animation table:
SWEP.Animations = {
["shoot1"] = {
-- Еype of the animation entry, either TFA.Enum.ANIMATION_ACT or TFA.Enum.ANIMATION_SEQ
-- ALL ENTRIES OF THE ANIMATION MUST BE OF THE SAME TYPE!!!
-- for ANIMATION_ACT, "value" must be one of the enums from https://wiki.facepunch.com/gmod/Enums/ACT
-- for ANIMATION_SEQ "value" is the sequence name
["type"] = TFA.Enum.ANIMATION_ACT,
-- Basic
["value"] = ACT_VM_PRIMARYATTACK,
["value_empty"] = ACT_VM_DRYFIRE,
["value_last"] = ACT_VM_PRIMARYATTACK_EMPTY,
-- Silenced
["value_sil"] = ACT_VM_PRIMARYATTACK_SILENCED,
["value_sil_empty"] = ACT_VM_DRYFIRE_SILENCED,
-- Ironsights/ADS
["value_is"] = ACT_VM_PRIMARYATTACK_1,
["value_is_empty"] = ACT_VM_PRIMARYATTACK_2,
["value_is_last"] = ACT_VM_PRIMARYATTACK_3,
-- ADS + Silenced
["value_is_sil"] = ACT_VM_PRIMARYATTACK_DEPLOYED_1,
["value_is_sil_empty"] = ACT_VM_PRIMARYATTACK_DEPLOYED_2,
["value_is_sil_last"] = ACT_VM_PRIMARYATTACK_DEPLOYED_3,
-- Force enable animation (when it's not autodetected)
["enabled"] = true
},
}
-- Uncomment entry and add to SWEP.Animations table of your SWEP. DO NOT COPY THE WHOLE BLOCK!
-- SWEP.Animations = {
--[[ Gun Base ]]--
-- ["draw_first"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_DRAW_DEPLOYED,
-- ["enabled"] = nil
-- },
-- ["draw"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_DRAW
-- },
-- ["draw_empty"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_DRAW_EMPTY
-- },
-- ["draw_silenced"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_DRAW_SILENCED
-- },
-- ["shoot1"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_PRIMARYATTACK
-- },
-- ["shoot1_last"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_PRIMARYATTACK_EMPTY
-- },
-- ["shoot1_empty"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_DRYFIRE
-- },
-- ["shoot1_silenced"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_PRIMARYATTACK_SILENCED
-- },
-- ["shoot1_silenced_empty"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_DRYFIRE_SILENCED or 0
-- },
-- ["shoot1_is"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_PRIMARYATTACK_1
-- },
-- ["shoot2"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_SECONDARYATTACK
-- },
-- ["shoot2_last"] = {
-- ["type"] = TFA.Enum.ANIMATION_SEQ,
-- ["value"] = "shoot2_last"
-- },
-- ["shoot2_empty"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_DRYFIRE
-- },
-- ["shoot2_silenced"] = {
-- ["type"] = TFA.Enum.ANIMATION_SEQ,
-- ["value"] = "shoot2_silenced"
-- },
-- ["shoot2_is"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_ISHOOT_M203
-- },
-- ["idle"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_IDLE
-- },
-- ["idle_empty"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_IDLE_EMPTY
-- },
-- ["idle_silenced"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_IDLE_SILENCED
-- },
-- ["reload"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_RELOAD
-- },
-- ["reload_empty"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_RELOAD_EMPTY
-- },
-- ["reload_silenced"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_RELOAD_SILENCED
-- },
-- ["reload_shotgun_start"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_SHOTGUN_RELOAD_START
-- },
-- ["reload_shotgun_finish"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_SHOTGUN_RELOAD_FINISH
-- },
-- ["reload_is"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_RELOAD_ADS
-- },
-- ["reload_empty_is"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_RELOAD_EMPTY_ADS
-- },
-- ["reload_silenced_is"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_RELOAD_SILENCED_ADS
-- },
-- ["reload_shotgun_start_is"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_SHOTGUN_RELOAD_START_ADS
-- },
-- ["reload_shotgun_finish_is"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_SHOTGUN_RELOAD_FINISH_ADS
-- },
-- ["holster"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_HOLSTER
-- },
-- ["holster_empty"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_HOLSTER_EMPTY
-- },
-- ["holster_silenced"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_HOLSTER_SILENCED
-- },
-- ["silencer_attach"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_ATTACH_SILENCER
-- },
-- ["silencer_detach"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_DETACH_SILENCER
-- },
-- ["rof"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_FIREMODE
-- },
-- ["rof_is"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_IFIREMODE
-- },
-- ["inspect"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_FIDGET
-- },
-- ["inspect_empty"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_FIDGET_EMPTY
-- },
-- ["inspect_silenced"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_FIDGET_SILENCED
-- },
--[[ Bash Base ]]--
-- ["bash"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_HITCENTER
-- },
-- ["bash_silenced"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_HITCENTER2
-- },
-- ["bash_empty"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_MISSCENTER
-- },
-- ["bash_empty_silenced"] = {
-- ["type"] = TFA.Enum.ANIMATION_ACT,
-- ["value"] = ACT_VM_MISSCENTER2
-- },
-- }
-- Fake ACT enum entries added by the base
-- These values do not exist in the engine, so for those names use the replacement value in the $sequence definition:
-- ACT_VM_FIDGET_EMPTY - ACT_CROSSBOW_FIDGET_UNLOADED
-- ACT_VM_FIDGET_SILENCED - ACT_RPG_FIDGET_UNLOADED
-- ACT_VM_HOLSTER_SILENCED - ACT_CROSSBOW_HOLSTER_UNLOADED
-- ACT_VM_RELOAD_ADS - ACT_IDLE_AIM_RIFLE_STIMULATED
-- ACT_VM_RELOAD_EMPTY_ADS - ACT_WALK_AIM_RIFLE_STIMULATED
-- ACT_VM_RELOAD_SILENCED_ADS - ACT_RUN_AIM_RIFLE_STIMULATED
-- ACT_SHOTGUN_RELOAD_START_ADS - ACT_IDLE_SHOTGUN_RELAXED
-- ACT_SHOTGUN_RELOAD_FINISH_ADS - ACT_IDLE_SHOTGUN_STIMULATED
--[[ Bow Base ]]--
-- SWEP.BowAnimations = {
-- ["shake"] = {
-- ["type"] = TFA.Enum.ANIMATION_SEQ,
-- ["value"] = "tiredloop",
-- ["enabled"] = true
-- },
-- ["shoot"] = {
-- ["type"] = TFA.Enum.ANIMATION_SEQ,
-- ["value"] = "fire_1",
-- ["enabled"] = true
-- },
-- ["cancel"] = {
-- ["type"] = TFA.Enum.ANIMATION_SEQ,
-- ["value"] = "cancelarrow",
-- ["enabled"] = true
-- },
-- ["draw"] = {
-- ["type"] = TFA.Enum.ANIMATION_SEQ,
-- ["value"] = "drawarrow",
-- ["enabled"] = true
-- }
-- }
-- TFA Base Attachment Template by TFA Base Devs
-- To the extent possible under law, the person who associated CC0 with
-- TFA Base Template has waived all copyright and related or neighboring rights
-- to TFA Base Template.
-- You should have received a copy of the CC0 legalcode along with this
-- work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
if not ATTACHMENT then
ATTACHMENT = {}
end
ATTACHMENT.TFADataVersion = 1 -- If it is undefined, it fallbacks to 0 and WeaponTable gets migrated like SWEPs do
-- ATTACHMENT.Base = "base" -- Attachment baseclass, defaults to "base" attachment
ATTACHMENT.Name = "Example Attachment"
ATTACHMENT.ShortName = nil -- Abbreviation shown on the bottom left of the icon, generated from name if not defined
ATTACHMENT.Description = {
TFA.Attachments.Colors["+"], "Does something good",
TFA.Attachments.Colors["-"], "Does something bad",
-- Color(255, 255, 255), "bottom text",
} -- all colors are defined in lua/tfa/modules/tfa_attachments.lua
ATTACHMENT.Icon = nil -- "entities/tfa_ammo_match.png" -- Full path to the icon, reverts to '?' by default
ATTACHMENT.WeaponTable = { -- The place where you change the stats (CACHED STATS ONLY!)
["Primary"] = {
["Damage"] = 60, -- For example, you want to change SWEP.Primary.Damage value to 60
["ClipSize"] = function(wep, stat)
return wep.Primary_TFA.ClipSize_Override or stat * 1.5
end -- Stat functions support changing value dynamically (which is cached afterwards), SWEP.Primary_TFA contains original unchanged values
}
}
-- ATTACHMENT.DInv2_GridSizeX = nil -- DInventory/2 Specific. Determines attachment's width in grid.
-- ATTACHMENT.DInv2_GridSizeY = nil -- DInventory/2 Specific. Determines attachment's height in grid.
-- ATTACHMENT.DInv2_Volume = nil -- DInventory/2 Specific. Determines attachment's volume in liters.
-- ATTACHMENT.DInv2_Mass = nil -- DInventory/2 Specific. Determines attachment's mass in kilograms.
-- ATTACHMENT.DInv2_StackSize = nil -- DInventory/2 Specific. Determines attachment's maximal stack size.
--[[
-- Default behavior is always allow, override to change
function ATTACHMENT:CanAttach(wep)
return true
end
]]--
--[[
-- These functions are called BEFORE stat cache is rebuilt
function ATTACHMENT:Attach(wep)
end
function ATTACHMENT:Detach(wep)
end
]]--
-- Attachment functions called from base
--[[
-- Called from render target code if SWEP.RTDrawEnabled is true
function ATTACHMENT:RTCode(wep, rt_texture, w, h)
end
]]--
--[[
-- Called from FireBullets for each bullet trace hit; arguments are passed from bullet callback
function ATTACHMENT:CustomBulletCallback(wep, attacker, trace, dmginfo)
end
]]--
if not TFA_ATTACHMENT_ISUPDATING then
TFAUpdateAttachments()
end
-- TFA Base Template by TFA Base Devs
-- To the extent possible under law, the person who associated CC0 with
-- TFA Base Template has waived all copyright and related or neighboring rights
-- to TFA Base Template.
-- You should have received a copy of the CC0 legalcode along with this
-- work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
-- M9K compatible version is dated as 0 (and 0 is also fallback if TFADataVersion not present)
-- as well as everything made for TFA Base before 4.7
SWEP.TFADataVersion = 1
----------------- Basic Garry's Mod SWEP structure stats / TFA Base properties
SWEP.Base = "tfa_gun_base"
SWEP.Category = "TFA Template" -- The category.
-- Please, just choose something generic or something I've already done if you plan on only doing like one (or two or three) swep(s).
SWEP.Manufacturer = nil -- Gun Manufactrer (e.g. Hoeckler and Koch)
SWEP.Author = "" -- Author Tooltip
SWEP.Contact = "" -- Contact Info Tooltip
SWEP.Purpose = "" -- Purpose Tooltip
SWEP.Instructions = "" -- Instructions Tooltip
SWEP.Spawnable = false -- Can you, as a normal user, spawn this?
SWEP.AdminSpawnable = false -- Can an adminstrator spawn this? Does not tie into your admin mod necessarily, unless its coded to allow for GMod's default ranks somewhere in its code. Evolve and ULX should work, but try to use weapon restriction rather than these.
SWEP.DrawCrosshair = true -- Draw the crosshair?
-- AKA DrawCrosshairIS
SWEP.DrawCrosshairIronSights = false -- Draw the crosshair in ironsights?
SWEP.PrintName = "TFA Base Template" -- Weapon name (Shown on HUD)
SWEP.Slot = 2 -- Slot in the weapon selection menu. Subtract 1, as this starts at 0.
SWEP.SlotPos = 73 -- Position in the slot
SWEP.AutoSwitchTo = true -- Auto switch to if we pick it up
SWEP.AutoSwitchFrom = true -- Auto switch from if you pick up a better weapon
SWEP.Weight = 30 -- This controls how "good" the weapon is for autopickup.
SWEP.Type = nil -- Weapon type. Autodetected, but in some cases needs to be set manually. PLEASE MAKE SURE THE TYPE IS SET PROPERLY so that autodetection code won't make funky stuff.
-- Recognized generic types: "Pistol", "Machine Pistol", "Revolver", "Sub-Machine Gun", "Rifle", "Carbine", "Light Machine Gun", "Shotgun", "Designated Marksman Rifle", "Sniper Rifle", "Grenade", "Launcher"; "Dual Pistols", "Dual Revolvers", "Dual Sub-Machine Guns" and "Dual Guns".
SWEP.Type_Displayed = nil -- Weapon type override for displaying in the inspection menu. If you want to add wacky text below the gun name, DO IT HERE AND NOT IN THE ACTUAL TYPE FIELD!
----------------- The Most basic weapon stats
SWEP.Primary.RPM = 600 -- This is in Rounds Per Minute / RPM
SWEP.Primary.NumShots = 1 -- The number of shots the weapon fires
SWEP.Primary.HullSize = 0 -- Big bullets, increase this value. They increase the hull size of the hitscan bullet.
SWEP.Primary.Automatic = true -- Automatic/Semi Auto
-- If your gun is bullet based
SWEP.Primary.Damage = 0.01 -- Damage, in standard damage points.
SWEP.Primary.Force = nil -- Force value, leave nil to autocalc
-- elseif Your gun is projectile based
-- If your gun is projectile based, ignore Primary.Damage and Primary.Force
SWEP.Primary.Projectile = nil -- Entity to shoot
SWEP.Primary.ProjectileVelocity = 0 -- Entity to shoot's velocity
SWEP.Primary.ProjectileModel = nil -- Entity to shoot's model
----------------- TFA Base basic stats
SWEP.Primary.Knockback = nil -- Autodetected if nil; this is the velocity kickback
SWEP.Primary.DryFireDelay = nil -- How long you have to wait after firing your last shot before a dryfire animation can play. Leave nil for full empty attack length. Can also use SWEP.StatusLength[ ACT_VM_BLABLA ]
SWEP.Primary.BurstDelay = nil -- Delay between bursts, leave nil to autocalculate
-- AKA FiresUnderwater
SWEP.Primary.FiresUnderwater = false -- Whenever this weapon can fire underwater
----------------- TFA Base extended basic stats
SWEP.Primary.RPM_Semi = nil -- RPM for semi-automatic or burst fire. This is in Rounds Per Minute / RPM
SWEP.Primary.RPM_Burst = nil -- RPM for burst fire, overrides semi. This is in Rounds Per Minute / RPM
SWEP.Primary.DamageTypeHandled = true -- true will handle damagetype in base
SWEP.Primary.DamageType = nil -- See DMG enum. This might be DMG_SHOCK, DMG_BURN, DMG_BULLET, etc. Leave nil to autodetect. DMG_AIRBOAT opens doors.
----------------- TFA Base Basic sound handling
SWEP.Primary.Sound = Sound("") -- This is the sound of the weapon, when you shoot.
SWEP.Primary.SilencedSound = nil -- This is the sound of the weapon, when silenced.
-- AKA IronInSound
SWEP.Secondary.IronSightsInSound = nil -- Sound to play when iron sighting in? nil for default
-- AKA IronOutSound
SWEP.Secondary.IronSightsOutSound = nil -- Sound to play when iron sighting out? nil for default
----------------- TFA Base Advanced sound handling
-- Requires looped .wav files prepared beforehand - https://wiki.facepunch.com/gmod/Creating_Looping_Sounds
SWEP.Primary.LoopSound = nil -- Looped fire sound, unsilenced
SWEP.Primary.LoopSoundSilenced = nil -- Looped fire sound, silenced
SWEP.Primary.LoopSoundTail = nil -- Loop end/tail sound, unsilenced
SWEP.Primary.LoopSoundTailSilenced = nil -- Loop end/tail sound, silenced
SWEP.Primary.LoopSoundAutoOnly = false -- Play loop sound for full-auto only? Fallbacks to Primary.Sound for semi/burst if true
-- WORLD/THIRDPERSON/NPC FIRING SOUNDS! Fallbacks to first person sound if not defined.
SWEP.Primary.Sound_World = nil -- This is the sound of the weapon, when you shoot.
SWEP.Primary.SilencedSound_World = nil -- This is the sound of the weapon, when silenced.
SWEP.Primary.LoopSound_World = nil -- Looped fire sound, unsilenced
SWEP.Primary.LoopSoundSilenced_World = nil -- Looped fire sound, silenced
SWEP.Primary.LoopSoundTail_World = nil -- Loop end/tail sound, unsilenced
SWEP.Primary.LoopSoundTailSilenced_World = nil -- Loop end/tail sound, silenced
-- LOW AMMO
SWEP.FireSoundAffectedByClipSize = true -- Play low ammo and last shot sounds? Controlled by "Enable nearly-empty sounds" server option.
SWEP.LowAmmoSoundThreshold = nil -- Clip fill percentage below which low ammo sound will start playing; default is 0.33
SWEP.LowAmmoSound = nil -- Low ammo sound
SWEP.LastAmmoSound = nil -- Last shot sound
-- Both are autodetected based on weapon type
-- Low ammo sounds that are supplied by the base: "TFA.LowAmmo.Handgun", "TFA.LowAmmo.Shotgun", "TFA.LowAmmo.AutoShotgun", "TFA.LowAmmo.MachineGun", "TFA.LowAmmo.AssaultRifle", "TFA.LowAmmo.DMR", "TFA.LowAmmo.Revolver", "TFA.LowAmmo.Sniper", "TFA.LowAmmo.SMG", "TFA.LowAmmo.SciFi", "TFA.LowAmmo.GL"
-- For last ammo sound just add _Dry at the end (for example "TFA.LowAmmo.Handgun_Dry")
----------------- Jamming mechanics
SWEP.CanJam = true -- whenever weapon cam jam
SWEP.JamChance = 0.04 -- the (maximal) chance the weapon will jam. Newly spawned weapon will never jam on first shot for example.
-- Default value is 0.04 (4%)
-- Maxmial value is 1, means weapon will always jam when factor become 100
-- Also remember that there is a minimal factor before weapon can jam
-- This number is not treated "as-is" but as basic value that needs to be concluded as chance
-- You don't really need to cry over it and trying to balance it, TFA Base will do the job for you
-- (TFA Base will calculate the best value between 0 and JamChance based on current JamFactor of the weapon)
SWEP.JamFactor = 0.06 -- How to increase jam factor after each shot.
-- When factor reach 100 it will mean that on each shot there will be SWEP.Primary.JamChance chance to jam
-- When factor reach 50 it will mean that on each shot there will be SWEP.Primary.JamChance / 2 chance to jam
-- and so on
-- Default value is 0.06, means weapon will jam with SWEP.Primary.JamChance chance right after 1666 shots
-- These settings are good for Assault Rifles, however, not good for anything else.
-- Suggested stats:
--[[
-- Pistols
SWEP.JamChance = 0.20
SWEP.JamFactor = 0.14
]]
--[[
-- Revolvers
SWEP.JamChance = 0.17
SWEP.JamFactor = 0.50
]]
--[[
-- Miniguns
SWEP.JamChance = 0.03
SWEP.JamFactor = 0.01
]]
--[[
-- Submachine gun
SWEP.JamChance = 0.04
SWEP.JamFactor = 0.09
]]
--[[
-- Auto shotguns
SWEP.JamChance = 0.15
SWEP.JamFactor = 0.2
]]
--[[
-- Pump-action shotguns
SWEP.JamChance = 0.25
SWEP.JamFactor = 0.3
]]
--[[
-- Sniper rifle
SWEP.JamChance = 0.17
SWEP.JamFactor = 0.35
]]
----------------- Silencing
SWEP.CanBeSilenced = false -- Can we silence? Requires animations.
SWEP.Silenced = false -- Silenced by default?
----------------- Selective Fire Stuff
SWEP.SelectiveFire = false -- Allow selecting your firemode?
SWEP.DisableBurstFire = false -- Only auto/single?
SWEP.OnlyBurstFire = false -- No auto, only burst/single?
SWEP.BurstFireCount = nil -- Burst fire count override (autocalculated by the clip size if nil)
SWEP.DefaultFireMode = "" -- Default to auto or whatev
SWEP.FireModeName = nil -- Change to a text value to override it
----------------- Ammo Related
SWEP.Primary.ClipSize = 0 -- This is the size of a clip
SWEP.Primary.DefaultClip = 0 -- This is the number of bullets the gun gives you, counting a clip as defined directly above.
SWEP.Primary.Ammo = "none" -- What kind of ammo. Options, besides custom, include pistol, 357, smg1, ar2, buckshot, slam, SniperPenetratedRound, and AirboatGun.
-- Pistol, buckshot, and slam like to ricochet. Use AirboatGun for a light metal peircing shotgun pellets
SWEP.Primary.AmmoConsumption = 1 -- Ammo consumed per shot
-- AKA DisableChambering
SWEP.Primary.DisableChambering = false -- Disable round-in-the-chamber
-- Recoil Related
SWEP.Primary.KickUp = 0 -- This is the maximum upwards recoil (rise)
SWEP.Primary.KickDown = 0 -- This is the maximum downwards recoil (skeet)
SWEP.Primary.KickHorizontal = 0 -- This is the maximum sideways recoil (no real term)
SWEP.Primary.StaticRecoilFactor = 0.5 -- Amount of recoil to directly apply to EyeAngles. Enter what fraction or percentage (in decimal form) you want. This is also affected by a convar that defaults to 0.5.
-- Firing Cone Related
SWEP.Primary.Spread = .01 -- This is hip-fire acuracy. Less is more (1 is horribly awful, .0001 is close to perfect)
SWEP.Primary.IronAccuracy = .005 -- Ironsight accuracy, should be the same for shotguns
SWEP.Primary.DisplaySpread = nil -- Defaults to true. Display spread on customization screen?
SWEP.Primary.DisplayIronSpread = nil -- Defaults to Primary.DisplaySpread. Display spread on customization screen for iron sights? This is always false if Secondary.IronSightsEnabled is false
-- Unless you can do this manually, autodetect it. If you decide to manually do these, uncomment this block and remove this line.
SWEP.Primary.SpreadMultiplierMax = nil -- How far the spread can expand when you shoot. Example val: 2.5
SWEP.Primary.SpreadIncrement = nil -- What percentage of the modifier is added on, per shot. Example val: 1/3.5
SWEP.Primary.SpreadRecovery = nil -- How much the spread recovers, per second. Example val: 3
SWEP.Primary.SpreadRecoveryDelay = nil -- Delay in seconds before spread starts to recover
----------------- Range stats
SWEP.Primary.DisplayFalloff = nil -- Defaults to true (false for melees)
-- Use these if you don't want/understand how to use LUT below.
-- These values are automatically converted to RangeFalloffLUT table
SWEP.Primary.FalloffMetricBased = false -- Set to true if you set up values below
SWEP.Primary.FalloffByMeter = nil -- How much damage points will bullet loose when travel
SWEP.Primary.MinRangeStartFalloff = nil -- How long will bullet travel in Meters before starting to lose damage?
SWEP.Primary.MaxFalloff = nil -- Maximal amount of damage to be lost
-- Use this for full control over damage dropoff.
--[[
SWEP.Primary.RangeFalloffLUT = {
bezier = true, -- Whenever to use Bezier or not to interpolate points?
-- you probably always want it to be set to true
range_func = "quintic", -- function to spline range
-- "linear" for linear splining.
-- Possible values are "quintic", "cubic", "cosine", "sinusine", "linear" or your own function
units = "meters", -- possible values are "inches", "inch", "hammer", "hu" (are all equal)
-- everything else is considered to be meters
lut = { -- providing zero point is not required
-- without zero point it is considered to be as {range = 0, damage = 1}
{range = 5, damage = 0.9},
{range = 12, damage = 0.8},
{range = 18, damage = 0.5},
{range = 24, damage = 0.2},
{range = 30, damage = 0.55},
{range = 38, damage = 0.76},
{range = 50, damage = 1},
{range = 52, damage = 0.96},
{range = 60, damage = 0.3},
{range = 70, damage = 0.1},
}
}
]]
----------------- Spread stats
-- Bullet pattern to utilize
-- to be used to utilize built-in patterns
SWEP.Primary.SpreadPattern = nil -- Defaults to ""
-- Spread bias
-- The bigger is the number, the stronger is spread
-- along specified axis (Yaw for X, Pitch for Y). Note that this is not clamped and it is possible
-- to make spread along X or Y or both bigger than current aimcone
SWEP.Primary.SpreadBiasYaw = nil -- Defaults to 1
SWEP.Primary.SpreadBiasPitch = nil -- Defaults to 1
-- Check common/bullet.lua for more information on how to implement custom
-- functions if you REALLY need them
-- Less is more. Accuracy * 0.5 = Twice as accurate, Accuracy * 0.1 = Ten times as accurate
SWEP.CrouchAccuracyMultiplier = 0.5
----------------- Recoil related things
SWEP.ViewModelPunchPitchMultiplier = nil -- Default value is 0.5
SWEP.ViewModelPunchPitchMultiplier_IronSights = nil -- Default value is 0.09
SWEP.ViewModelPunch_MaxVertialOffset = nil -- Default value is 3
SWEP.ViewModelPunch_MaxVertialOffset_IronSights = nil -- Default value is 1.95
SWEP.ViewModelPunch_VertialMultiplier = nil -- Default value is 1
SWEP.ViewModelPunch_VertialMultiplier_IronSights = nil -- Default value is 0.25
SWEP.ViewModelPunchYawMultiplier = nil -- Default value is 0.6
SWEP.ViewModelPunchYawMultiplier_IronSights = nil -- Default value is 0.25
-- AKA IronRecoilMultiplier
SWEP.Primary.IronRecoilMultiplier = 0.5 -- Multiply recoil by this factor when we're in ironsights. This is proportional, not inversely.
-- Stats below have no effect if RecoilLUT is not defined
SWEP.Primary.RecoilLUT_IronSightsMult = nil -- Defaults to 0.5
-- controls how much effective LUT is when iron sighting
SWEP.Primary.RecoilLUT_AnglePunchMult = nil -- Defaults to 0.25
-- controls how much effective LUT at pushing EyeAngles of shooter
SWEP.Primary.RecoilLUT_ViewPunchMult = nil -- Defaults to 1
-- controls how much effective LUT at viewpunch
--[[
SWEP.Primary.RecoilLUT = {
["in"] = {
bezier = true,
func = "quintic", -- function to inerpolate progress when sampling points from table
-- Possible values are "quintic", "cubic", "cosine", "sinusine", "linear" or your own function
cooldown_speed = 1, -- how much to loose progress when we are at this stage
-- 1 means we lose entire progress in a second
increase = 0.1, -- how much to increase progress after shot
-- 0.1 means that this stage would be full after 10 shots
wait = 0.1, -- how much time do we wait in seconds after we stopped shooting
-- after this time, IN stage begin to cooldown until it reach zero
-- table is always prepended with an Angle()
-- only Pitch and Yaw are utilized
-- sampled point is added to aimvector of player
-- when they shoot
points = {
Angle(-1, 0.4),
Angle(-4, -2),
Angle(-6, -4),
Angle(-10, -6),
}
},
["loop"] = {
bezier = true,
func = "quintic",
-- this stage can not cooldown, so no cooldown_speed is defined
increase = 0.1, -- when LOOP stage reach 1, it is reset to 0
wait = 0.1, -- how much time do we wait in seconds after we stopped shooting
-- after this time, stage switch to OUT
-- table is NOT prepended with an Angle()
-- make sure it's starting point match the one from IN stage
-- last and first points are connected automatically
points = {
Angle(-10, -6),
Angle(-12, -0.4),
Angle(-8, 9),
Angle(-11, 12),
Angle(-13, 2),
Angle(-8, -4),
}
},
["out"] = {
bezier = true,
func = "quintic",
-- this stage is different
-- it is only started after LOOP took place
-- shooting in this stage will actually roll back it's state
-- until it reach zero and switch back to LOOP
-- cooling down actually increase stage's progress
cooldown_speed = 1,
-- increase act as negative number to reach zero in this stage
increase = 0.2,
-- after this stage reach 1, everything reset to IN and wait for next fire
-- table is always appended with an Angle()
-- starting point is dynamic
-- and will always match current LOOP's one
points = {
Angle(-7, -2),
Angle(-4, -1),
Angle(-2, 0),
}
}
}
]]
----------------- Penetration Related
-- AKA MaxPenetrationCounter / MaxPenetration
SWEP.Primary.MaxSurfacePenetrationCount = nil -- Defaults to infinity and is clamped by convar which defaults to 100
-- The maximum number of surface penetrations. You probably shouldn't touch this unless you need to remove penetration completely or limit it somehow
-- aside from Penetration power exhaust
SWEP.Primary.PenetrationPower = nil -- Defaults to autodetect
-- This control how much we can penetrate various surfaces in hammer units
-- So, PenetrationPower of 400 say that we can penetrate 400 hammer units of material with penetration multiplier of 1
-- 800 hammer units of material with penetration multiplier of 0.5
-- 1600 hammer units of material with penetration multiplier of 0.25
-- and so on
-- TFA Base is designed to work with small to insanely large penetration power values, so don't be shy at experimenting with this value
SWEP.Primary.PenetrationMultiplier = nil -- Defaults to 1
-- Change the amount of something this gun can penetrate through
-- the LESSER this value is, the BETTER is penetration
-- this is basically multiplier for next values
-- Checkout https://wiki.facepunch.com/gmod/Enums/MAT for list of all materials
--[==[
-- AKA PenetrationMaterials
SWEP.Primary.PenetrationMaterials = {
[MAT_NAME] = 0.5,
}
]==]
----------------- Mobility / Moving speed related
SWEP.AllowSprintAttack = nil -- Allows firing the weapon while sprinting; false by default
-- Multiplies moving speed (velocity) of owner by this value
-- e.g. if their WalkSpeed is 300 HU/s and they hold gun with multiplier of 0.75
-- then when they press +forward their speed will be capped at 225 HU/s
-- AKA MoveSpeed
SWEP.RegularMoveSpeedMultiplier = nil -- Defaults to 1
-- Multiply the player's movespeed by this when aiming down sights
-- !!! This penalty / bonus is not additive (multiplied by RegularMoveSpeedMultiplier) and is preemptive
-- (e.g. if RegularMoveSpeedMultiplier is 0.5 and AimingDownSightsSpeedMultiplier is 1, then when fully Aiming Down Sights
-- speed multiplier will be 1, when half-way ADS'ing speed will be 0.75 and so on
-- Keep in mind that this also affect mouse sensivity when aiming down sights (creating kind of "mouse weight" effect)
-- AKA IronSightsMoveSpeed
SWEP.AimingDownSightsSpeedMultiplier = nil -- Defaults to 0.8
----------------- ViewModel related
SWEP.ViewModel = "models/your/path/here.mdl" -- Viewmodel path
SWEP.ViewModelFOV = 65 -- This controls how big the viewmodel looks. Less is more.
SWEP.ViewModelFlip = false -- Set this to true for CSS models, or false for everything else (with a righthanded viewmodel.)
SWEP.UseHands = false -- Use gmod c_arms system.
-- The viewmodel positional offset, constantly.
-- Subtract this from any other modifications to viewmodel position.
-- AKA VMPos (SWEP Construction Kit naming, VMPos is always checked for presence and it always override ViewModelPosition if present)
SWEP.ViewModelPosition = Vector(0, 0, 0)
-- AKA VMAng (SWEP Construction Kit naming)
-- The viewmodel angular offset, constantly.
-- Subtract this from any other modifications to viewmodel angle.
SWEP.ViewModelAngle = Vector(0, 0, 0)
-- Position when sprinting
-- AKA RunSightsPos (SWEP Construction Kit naming)
SWEP.SprintViewModelPosition = Vector(0, 0, 0) -- Change this, using SWEP Creation Kit preferably
-- AKA RunSightsAng (SWEP Construction Kit naming)
SWEP.SprintViewModelAngle = Vector(0, 0, 0) -- Change this, using SWEP Creation Kit preferably
-- Position when crouching
-- Viewmodel offset when player is crouched
-- AKA CrouchPos
SWEP.CrouchViewModelPosition = nil -- Defaults to nothing, use Vector(0, 0, 0) as starting point
-- AKA CrouchAng
SWEP.CrouchViewModelAngle = nil -- Defaults to nothing, use Vector(0, 0, 0) as starting point
SWEP.IronSightsPosition = Vector(0, 0, 0) -- Change this, using SWEP Creation Kit preferably
SWEP.IronSightsAngle = Vector(0, 0, 0) -- Change this, using SWEP Creation Kit preferably
-- Inspection position
-- Replace with a vector, in style of ironsights position, to be used for inspection
SWEP.InspectPos = nil -- Vector(0, 0, 0)
SWEP.InspectAng = nil -- Vector(0, 0, 0) -- Replace with a vector, in style of ironsights angle, to be used for inspection
-- Whenever positions defined above are additive to any other position modification
-- Set to false for an easier time using VMPos
-- If true, VMPos will act as a constant value added to every other position modification
-- (iron sights position, run position, everything else)
-- AKA VMPos_Additive (SWEP Construction Kit naming)
SWEP.AdditiveViewModelPosition = true
SWEP.CenteredViewModelPosition = nil -- The viewmodel positional offset, used for centering. Leave nil to autodetect using ironsights.
SWEP.CenteredViewModelAngle = nil -- The viewmodel angular offset, used for centering. Leave nil to autodetect using ironsights.
SWEP.ViewModelBodygroups = nil -- {
-- [0] = 1,
-- [1] = 4,
-- [2] = etc.
-- }
-- Procedural sights position.
-- Applies !!BEFORE!! IronSightsPosition/IronSightsAngle and ViewModelPosition/ViewModelAngle
SWEP.ProceduralSight = nil -- Enables procedural viewmodel sight position lookup
SWEP.ProceduralSight_VElement = nil -- "reciever_p90_fn_p90_std" -- Name of VElement to follow; must be active to work; when not defined viewmodel is selected instead
-- Position lookup type: QC Attachment
-- SWEP.ProceduralSight_PositionType = TFA.Enum.SIGHTSPOS_ATTACH -- Enabled by default
-- SWEP.ProceduralSight_Attachment = "mod_aim_camera" -- $attachment name or ID to get the position of
-- Position lookup type: Bone
-- SWEP.ProceduralSight_PositionType = TFA.Enum.SIGHTSPOS_BONE
-- SWEP.ProceduralSight_Bone = "ValveBiped.P250_rootbone" -- Name of the bone to get the position of
SWEP.ProceduralSight_OffsetPos = nil -- Vector(0, 0, 0)
SWEP.ProceduralSight_OffsetAng = nil -- Angle(0, 0, 0)
SWEP.AllowIronSightsDoF = true -- whenever allow DoF effect on viewmodel when zoomed in with iron sights
SWEP.IronSightsDoF_FocusAttachment = nil -- number of the QC attachment used for DoF effect focus (autodetected to muzzle attachment by default)
-- Enable ADS reload animations support (requires animations to be enabled in SWEP.Animations)
SWEP.IronSightsReloadEnabled = nil
-- Lock ADS state when reloading
SWEP.IronSightsReloadLock = true
-- Export from SWEP Creation Kit (if it is being utilized to create gun)
-- For each item that can/will be toggled, set active = false in its individual table
-- AKA VElements (SWEP Construction Kit naming)
SWEP.ViewModelElements = nil --[[ {
["element_name"] = {
-- Basic SCK table syntax
-- Copy only one type element table!
-- Model element:
["type"] = "Model",
["model"] = "models/error.mdl", -- Model path
["bone"] = "", -- Bone name of the viewmodel/parent element to attach to (ignored when bonemerge is used)
["rel"] = "", -- Name of the parent element, empty means viewmodel
["pos"] = Vector(0, 0, 0), -- Position offset (ignored when bonemerge is used)
["angle"] = Angle(0, 0, 0), -- Angle offset (ignored when bonemerge is used)
["size"] = Vector(1, 1, 1), -- Element size (ignored when bonemerge is used)
["color"] = Color(255, 255, 255, 255), -- Color and opacity of the element
["surpresslightning"] = false, -- Suppress engine lighting for the element
["material"] = "", -- Singular material override (keps for backwards compatibilty, use the "materials" table below instead)
["skin"] = 0, -- Material skin index to use
["bodygroup"] = {}, -- Bodygroup overrides by index
["active"] = true, -- Element is active by default?
-- Sprite element:
["type"] = "Sprite",
["sprite"] = "sprites/glow1", -- Sprite texture path (for material use the "vmt" key instead)
["bone"] = "", -- Bone name of the viewmodel/parent element to attach to
["rel"] = "", -- Name of the parent element, empty means viewmodel
["pos"] = Vector(0, 0, 0), -- Position offset
["size"] = Vector(1, 1, 1), -- Sprite size
["color"] = Color(255, 255, 255, 255), -- Color and opacity of the element
-- VMT generation parameters:
["nocull"] = false,
["additive"] = false,
["vertexalpha"] = false,
["vertexcolor"] = false,
["ignorez"] = false,
["active"] = true, -- Element is active by default?
-- Quad element:
["type"] = "Quad",
["bone"] = "", -- Bone name of the viewmodel/parent element to attach to
["rel"] = "", -- Name of the parent element, empty means viewmodel
["pos"] = Vector(0, 0, 0), -- Position offset
["angle"] = Angle(0, 0, 0), -- Angle offset
["size"] = Vector(1, 1, 1), -- Element size
["draw_func"] = function(element) -- Draw function is called when element is active
-- your code here
end,
["active"] = true, -- Element is active by default?
-- Additional syntax from TFA Base:
["attachment"] = "muzzle", -- Parent attachment name, overrides the "bone" value (all types)
["bonemerge"] = false, -- Bonemerge model instead of positioning it at reference point (model only)
["materials"] = {}, -- Submaterials replacement table (model only)
["translucent"] = false, -- Workaround for translucent models drawing behind player hands (all types)
["draw_func_outer"] = function(element, pos, ang, size) -- Secondary draw function added to address stuff like player hands clipping (quad only)
-- your code here
end,
-- For models with stencil sights:
["mask"] = "models/error.mdl", -- Sight mask model path
["reticle"] = "models/error.mdl", -- Model path for model reticle type
}
}]]--
----------------- Iron sights related
-- AKA data.ironsights
SWEP.Secondary.IronSightsEnabled = true
-- Controls Field of View when scoping in.
-- Default FoV of Garry's Mod is 75, most of players prefer 90
-- Lesser FoV value means stronger "zoom"
-- Good value to begin experimenting with is 70
-- AKA Secondary.IronFOV
SWEP.Secondary.OwnerFOV = 70
-- AKA IronViewModelFOV
SWEP.Secondary.ViewModelFOV = nil -- Defaults to 65. Target viewmodel FOV when aiming down the sights.
----------------- Worldmodel related
SWEP.WorldModel = "models/your/wmodel/path/here.mdl" -- Weapon world model path
-- AKA Bodygroups_W
SWEP.WorldModelBodygroups = nil -- {
-- [0] = 1,
-- [1] = 4,
-- [2] = etc.
-- }
SWEP.HoldType = "" -- This is how others view you carrying the weapon. Options include:
-- normal melee melee2 fist knife smg ar2 pistol rpg physgun grenade shotgun crossbow slam passive
-- You're mostly going to use ar2, smg, shotgun or pistol. rpg and crossbow make for good sniper rifles
-- Holdtypes overrides (not cached, nil or "" to disable; only active when dynamic holdtypes are enabled except sprint override)
SWEP.IronSightHoldTypeOverride = nil -- ADS
SWEP.SprintHoldTypeOverride = nil -- Sprinting, holster and safety/passive hold
SWEP.ReloadHoldTypeOverride = nil -- Reloading
SWEP.CrouchHoldTypeOverride = nil -- Crouching
-- Procedural world model offset
-- Value below is good enough for Counter-Strike: Source worldmodels
--[[
-- AKA Offset
SWEP.WorldModelOffset = {
Pos = {
Up = 0,
Right = 0,
Forward = 0
},
Ang = {
Up = -1,
Right = -2,
Forward = 178
},
Scale = 1
}
]]
-- Export from SWEP Creation Kit.
-- For each item that can/will be toggled, set active = false in its individual table
-- AKA WElements (if it is being utilized to create gun)
SWEP.WorldModelElements = nil
----------------- Scopes related
SWEP.IronSightsSensitivity = 1 -- Useful for a RT scope. Change this to 0.25 for 25% sensitivity. This is if normal FOV compenstaion isn't your thing for whatever reason, so don't change it for normal scopes.
SWEP.BoltAction = false -- Unscope/sight after you shoot?
SWEP.Scoped = false -- Draw a scope overlay?
SWEP.ScopeOverlayThreshold = 0.875 -- Percentage you have to be sighted in to see the scope.
SWEP.BoltTimerOffset = 0.25 -- How long you stay sighted in after shooting, with a bolt action.
SWEP.ScopeScale = 0.5 -- Scale of the scope overlay
SWEP.ReticleScale = 0.7 -- Scale of the reticle overlay
-- GDCW Overlay Options. Only choose one.
SWEP.Secondary.UseACOG = false -- Overlay option
SWEP.Secondary.UseMilDot = false -- Overlay option
SWEP.Secondary.UseSVD = false -- Overlay option
SWEP.Secondary.UseParabolic = false -- Overlay option
SWEP.Secondary.UseElcan = false -- Overlay option
SWEP.Secondary.UseGreenDuplex = false -- Overlay option
-- Clientside only
-- Defines custom scope overlay
if CLIENT then
SWEP.Secondary.ScopeTable = nil --[[
{
ScopeBorder = Color(0, 0, 0, 255),
ScopeMaterial = Material("scope/gdcw_closedsight"),
ScopeOverlay = Material("effects/combine_binocoverlay"),
ScopeCrosshair = { -- can also be just a Material() value
r = 0, g = 0, b = 0, a = 255, -- color
scale = 1, -- scale or crosshair line width if no material specified
Material = Material("scope/gdcw_acogcross"), -- material, OPTIONAL!
}
}
]]
end
----------------- Looped reload related
-- AKA Shotgun
SWEP.LoopedReload = false -- Enable looped / shotgun style / one round at time reloading.
SWEP.ShotgunEmptyAnim = false -- Enable emtpy reloads on shotguns?
SWEP.ShotgunEmptyAnim_Shell = true -- Enable insertion of a shell directly into the chamber on empty reload?
SWEP.ShotgunStartAnimShell = false -- shotgun start anim inserts shell
-- For looped reloads, how long it take to insert extra round into weapon
-- Adjuct to match visual representation when it actually insert round
-- AKA ShellTime
SWEP.LoopedReloadInsertTime = 0.35
----------------- Animation stuff / procedural ones (Lua animated)
-- ViewModel custom blowback
SWEP.BlowbackEnabled = false -- Enable Blowback?
SWEP.BlowbackVector = Vector(0, -1, 0) -- Vector to move bone <or root> relative to bone <or view> orientation.
SWEP.BlowbackAngle = nil -- Angle(0, 0, 0)
SWEP.BlowbackCurrentRoot = 0 -- Amount of blowback currently, for root
SWEP.BlowbackCurrent = 0 -- Amount of blowback currently, for bones
SWEP.BlowbackBoneMods = nil -- Viewmodel bone mods via SWEP Creation Kit
SWEP.Blowback_Only_Iron = true -- Only do blowback on ironsights
SWEP.Blowback_PistolMode = false -- Do we recover from blowback when empty?
SWEP.Blowback_Shell_Enabled = true -- Shoot shells through blowback animations
SWEP.Blowback_Shell_Effect = "ShellEject" -- Which shell effect to use
SWEP.BlowbackAllowAnimation = nil -- Allow playing shoot animation with blowback?
-- Lua animated reload animation
-- Animate first person reload using Lua?
-- When reloading weapon will be offset to holster position (TODO: Add separate property for that)
-- AKA DoProceduralReload
SWEP.IsProceduralReloadBased = false
SWEP.ProceduralReloadTime = 1 -- Procedural reload time in seconds
-- Animation / sequence control
SWEP.StatusLengthOverride = {} -- Changes the status delay of a given animation; only used on reloads. Otherwise, use SequenceLengthOverride or one of the others
SWEP.SequenceLengthOverride = {} -- Changes both the status delay and the nextprimaryfire of a given animation
SWEP.SequenceTimeOverride = {} -- Like above but changes animation length to a target
SWEP.SequenceRateOverride = {} -- Like above but scales animation length rather than being absolute
SWEP.ProceduralHolsterEnabled = nil -- Defaults to autodetection (if weapon has no ACT_VM_HOLSTER animation this is enabled if not specified)
SWEP.ProceduralHolsterTime = 0.3
-- AKA ProceduralHolsterPos
SWEP.ProceduralHolsterPosition = Vector(3, 0, -5)
-- AKA ProceduralHolsterAng
SWEP.ProceduralHolsterAngle = Vector(-40, -30, 10)
----------------- Basic animation related
-- TFA.Enum.IDLE_DISABLED = No idle
-- TFA.Enum.IDLE_LUA = Lua animated idle
-- TFA.Enum.IDLE_ANI = Model's animated idle
-- TFA.Enum.IDLE_BOTH = TFA.Enum.IDLE_ANI + TFA.Enum.IDLE_LUA
SWEP.Idle_Mode = TFA.Enum.IDLE_BOTH
SWEP.Idle_Blend = 0.25 -- Start an idle this far early into the end of a transition
SWEP.Idle_Smooth = 0.05 -- Start an idle this far early into the end of another animation
-- Model based animations Below
-- TFA.Enum.LOCOMOTION_ANI = Model's animation
-- TFA.Enum.LOCOMOTION_LUA = Lua only
-- TFA.Enum.LOCOMOTION_HYBRID = TFA.Enum.LOCOMOTION_ANI + TFA.Enum.LOCOMOTION_LUA
-- Keep in mind that HYBRID sometimes produce very weird results, especially if
-- model's animation is "out of sync" with Lua's one
SWEP.Sights_Mode = TFA.Enum.LOCOMOTION_LUA
--[[
SWEP.IronAnimation = {
["in"] = {
["type"] = TFA.Enum.ANIMATION_SEQ, -- Sequence or act
["value"] = "Idle_To_Iron", -- Number for act, String/Number for sequence
["value_empty"] = "Idle_To_Iron_Dry",
["transition"] = true
}, -- Inward transition
["loop"] = {
["type"] = TFA.Enum.ANIMATION_SEQ, -- Sequence or act
["value"] = "Idle_Iron", -- Number for act, String/Number for sequence
["value_empty"] = "Idle_Iron_Dry"
}, -- Looping Animation
["out"] = {
["type"] = TFA.Enum.ANIMATION_SEQ, -- Sequence or act
["value"] = "Iron_To_Idle", -- Number for act, String/Number for sequence
["value_empty"] = "Iron_To_Idle_Dry",
["transition"] = true
}, -- Outward transition
["shoot"] = {
["type"] = TFA.Enum.ANIMATION_SEQ, -- Sequence or act
["value"] = "Fire_Iron", -- Number for act, String/Number for sequence
["value_last"] = "Fire_Iron_Last",
["value_empty"] = "Fire_Iron_Dry"
} -- What do you think
}
]]
-- TFA.Enum.LOCOMOTION_ANI = Model's animation
-- TFA.Enum.LOCOMOTION_LUA = Lua only
-- TFA.Enum.LOCOMOTION_HYBRID = TFA.Enum.LOCOMOTION_ANI + TFA.Enum.LOCOMOTION_LUA
SWEP.Sprint_Mode = TFA.Enum.LOCOMOTION_LUA
--[[
SWEP.SprintAnimation = {
["in"] = {
["type"] = TFA.Enum.ANIMATION_SEQ, -- Sequence or act
["value"] = "Idle_to_Sprint", -- Number for act, String/Number for sequence
["value_empty"] = "Idle_to_Sprint_Empty",
["transition"] = true
}, -- Inward transition
["loop"] = {
["type"] = TFA.Enum.ANIMATION_SEQ, -- Sequence or act
["value"] = "Sprint_", -- Number for act, String/Number for sequence
["value_empty"] = "Sprint_Empty_",
["is_idle"] = true
}, -- looping animation
["out"] = {
["type"] = TFA.Enum.ANIMATION_SEQ, -- Sequence or act
["value"] = "Sprint_to_Idle", -- Number for act, String/Number for sequence
["value_empty"] = "Sprint_to_Idle_Empty",
["transition"] = true
} -- Outward transition
}
]]
-- TFA.Enum.LOCOMOTION_ANI = Model's animation
-- TFA.Enum.LOCOMOTION_LUA = Lua only
-- TFA.Enum.LOCOMOTION_HYBRID = TFA.Enum.LOCOMOTION_ANI + TFA.Enum.LOCOMOTION_LUA
SWEP.Walk_Mode = TFA.Enum.LOCOMOTION_LUA
--[[
SWEP.WalkAnimation = {
["in"] = {
["type"] = TFA.Enum.ANIMATION_SEQ, -- Sequence or act
["value"] = "Idle_to_Walk", -- Number for act, String/Number for sequence
["value_empty"] = "Idle_to_Walk_Empty",
["transition"] = true
}, -- Inward transition
["loop"] = {
["type"] = TFA.Enum.ANIMATION_SEQ, -- Sequence or act
["value"] = "Walk", -- Number for act, String/Number for sequence
["value_empty"] = "Walk_Empty",
["is_idle"] = true
}, -- looping animation
["out"] = {
["type"] = TFA.Enum.ANIMATION_SEQ, -- Sequence or act
["value"] = "Walk_to_Idle", -- Number for act, String/Number for sequence
["value_empty"] = "Walk_to_Idle_Empty",
["transition"] = true
} -- Outward transition
}
]]
--[[
-- Looping fire animation (full-auto only)
SWEP.ShootAnimation = {
["in"] = {
["type"] = TFA.Enum.ANIMATION_SEQ, -- Sequence or act
["value"] = "ShootLoop_Start", -- Number for act, String/Number for sequence
["value_is"] = "ShootLoop_Iron_Start", -- Number for act, String/Number for sequence
["transition"] = true
}, -- Looping Start, fallbacks to loop
["loop"] = {
["type"] = TFA.Enum.ANIMATION_SEQ, -- Sequence or act
["value"] = "ShootLoop", -- Number for act, String/Number for sequence,
["value_is"] = "ShootLoop_Iron", -- Number for act, String/Number for sequence,
["is_idle"] = true,
}, -- Looping Animation
["out"] = {
["type"] = TFA.Enum.ANIMATION_SEQ, -- Sequence or act
["value"] = "ShootLoop_End", -- Number for act, String/Number for sequence
["value_is"] = "ShootLoop_Iron_End", -- Number for act, String/Number for sequence
["transition"] = true
}, -- Looping End
}
]]
-- TFA.Enum.LOCOMOTION_ANI = Model's animation
-- TFA.Enum.LOCOMOTION_LUA = Lua only
-- TFA.Enum.LOCOMOTION_HYBRID = TFA.Enum.LOCOMOTION_ANI + TFA.Enum.LOCOMOTION_LUA
SWEP.Customize_Mode = TFA.Enum.LOCOMOTION_LUA
--[[
SWEP.CustomizeAnimation = {
["in"] = {
["type"] = TFA.Enum.ANIMATION_SEQ, -- Sequence or act
["value"] = "customization_in", -- Number for act, String/Number for sequence
["transition"] = true
},
["loop"] = {
["type"] = TFA.Enum.ANIMATION_SEQ, -- Sequence or act
["value"] = "customization_idle", -- Number for act, String/Number for sequence
["is_idle"] = true
},
["out"] = {
["type"] = TFA.Enum.ANIMATION_SEQ, -- Sequence or act
["value"] = "customization_out", -- Number for act, String/Number for sequence
["transition"] = true
}
}
]]
--[[
SWEP.PumpAction = { -- Pump/bolt animations
["type"] = TFA.Enum.ANIMATION_ACT, -- Sequence or act
["value"] = ACT_VM_PULLBACK_HIGH, -- Number for act, String/Number for sequence
["value_empty"] = ACT_VM_PULLBACK, -- Last shot pump
["value_is"] = ACT_VM_PULLBACK_LOW, -- ADS pump
}
]] --
----------------- Effects related
-- Attachments
SWEP.MuzzleAttachment = "1" -- Should be "1" for CSS models or "muzzle" for hl2 models
SWEP.ShellAttachment = "2" -- Should be "2" for CSS models or "shell" for hl2 models
SWEP.MuzzleFlashEnabled = true -- Enable muzzle flash
SWEP.MuzzleAttachmentRaw = nil -- This will override whatever string you gave. This is the raw attachment NUMBER. This is overridden or created when a gun makes a muzzle event.
SWEP.AutoDetectMuzzleAttachment = false -- For multi-barrel weapons, detect the proper attachment?
SWEP.MuzzleFlashEffect = nil -- Change to a string of your muzzle flash effect. Copy/paste one of the existing from the base.
SWEP.SmokeParticle = nil -- Smoke particle (ID within the PCF), defaults to something else based on holdtype; "" to disable
SWEP.EjectionSmokeEnabled = true -- Disable automatic ejection smoke
-- Shell eject override
SWEP.LuaShellEject = false -- Enable shell ejection through lua?
SWEP.LuaShellEjectDelay = 0 -- The delay to actually eject things
SWEP.LuaShellModel = nil -- The model to use for ejected shells
SWEP.LuaShellScale = nil -- The model scale to use for ejected shells
SWEP.LuaShellYaw = nil -- The model yaw rotation ( relative ) to use for ejected shells
-- Tracer Stuff
SWEP.TracerName = nil -- Change to a string of your tracer name. Can be custom. There is a nice example at https://github.com/garrynewman/garrysmod/blob/master/garrysmod/gamemodes/base/entities/effects/tooltracer.lua
SWEP.TracerCount = 3 -- 0 disables, otherwise, 1 in X chance
-- Impact Effects
SWEP.ImpactEffect = nil -- Impact Effect
SWEP.ImpactDecal = nil -- Impact Decal
----------------- Event table
-- Utilized for firing custom events (including running Lua code) when an action is played.
-- This can even do stuff like playing a pump animation after shooting, discarding clip when reloading
-- playing sounds and so much more!
SWEP.EventTable = {}
-- example:
--[==[
SWEP.EventTable = {
[ACT_VM_RELOAD] = {
{["time"] = 0.1, ["type"] = "lua", ["value"] = function(wep, viewmodel, ifp --[[IsFirstTimePredicted()]]) end, ["client"] = true, ["server"] = true},
{["time"] = 0.1, ["type"] = "sound", ["value"] = Sound("x")}
}
}
]==]
----------------- Render target related
SWEP.RTMaterialOverride = nil -- Take the material you want out of PrintTable(LocalPlayer():GetViewModel():GetMaterials()), subtract 1 from its index, and set it to this.
SWEP.RTOpaque = false -- Do you want your render target to be opaque?
SWEP.RTCode = nil -- function(self) return end -- This is the function to draw onto your rendertarget
SWEP.RTBGBlur = true -- Draw background blur when 3D scope is active?
----------------- Akimbo related
-- AKA Akimbo
SWEP.IsAkimbo = false -- Akimbo gun? Alternates between primary and secondary attacks.
-- AKA AkimboHUD
SWEP.EnableAkimboHUD = true -- Draw holographic HUD for both weapons?
----------------- Attachments
SWEP.Attachments = {
--[[
[slot number] = {
atts = {
"si_eotech",
-- ...
}, -- table of available attachments IDs
sel = 0, -- index or ID of pre-selected attachment (index starts with 1)
default = nil, -- attachment ID to equip on deselect
hidden = nil, -- true to hide category from attachments selector (this does not prevent attachments to be selected through other means!)
}
]]
-- sel allows you to have an attachment pre-selected, and is used internally by the base to show which attachment is selected in each category.
}
SWEP.AttachmentDependencies = {} -- {["si_acog"] = {"bg_rail", ["type"] = "OR"}} -- type could also be AND to require multiple
SWEP.AttachmentExclusions = {} -- { ["si_iron"] = { [1] = "bg_heatshield"} }
SWEP.AttachmentTableOverride = {} --[[{ -- overrides WeaponTable for attachments
["ins2_ub_laser"] = { -- attachment id, root of WeaponTable override
["ViewModelElements"] = {
["laser_rail"] = {
["active"] = true
},
},
}
}]]
SWEP.AttachmentIconOverride = {} --[[{ -- overrides icons for attachments
["am_magnum"] = Material("entities/ammo_357.png", "smooth")
}]]
SWEP.DInv2_GridSizeX = nil -- DInventory/2 Specific. Determines weapon's width in grid. This is not TFA Base specific and can be specified to any Scripted SWEP.
SWEP.DInv2_GridSizeY = nil -- DInventory/2 Specific. Determines weapon's height in grid. This is not TFA Base specific and can be specified to any Scripted SWEP.
SWEP.DInv2_Volume = nil -- DInventory/2 Specific. Determines weapon's volume in liters. This is not TFA Base specific and can be specified to any Scripted SWEP.
SWEP.DInv2_Mass = nil -- DInventory/2 Specific. Determines weapon's mass in kilograms. This is not TFA Base specific and can be specified to any Scripted SWEP.
-- Stencil Sights.
SWEP.StencilSight = nil -- Enables stencil sight drawing
SWEP.StencilSight_MinPercent = nil -- Mimimum aim progress percentage to draw; 0.05 by default; set to 0 to always draw
SWEP.StencilSight_VElement = nil -- "scope_p90_fn_ring_sight_std" -- Name of VElement to draw sight on; must be active to work
SWEP.StencilSight_UseMask = nil -- Use the .mask value of VElement's table as stencil mask model (model must be bonemergeable on the sights VElement!)
-- Sight Type: Flat
-- SWEP.StencilSight_ReticleType = TFA.Enum.RETICLE_FLAT
-- SWEP.StencilSight_ReticleMaterial = "models/weapons/yurie_bcry2/scope_assault/reddot" -- Reticle material, accepts either string or Material() object; must be a square texture!
-- SWEP.StencilSight_ReticleSize = 256 -- Reticle size; scales with screen height using HL2 scale formula (size * (screen height / 480))
-- SWEP.StencilSight_ScaleReticleByScreenHeight = nil -- Reticle size is affected by screen height; true by default
-- SWEP.StencilSight_ScaleReticleByProgress = nil -- Scale reticle with aim progress for smoother fade-in; true by default
-- SWEP.StencilSight_FollowRecoil = nil -- If enabled, reticle follows crosshair recoil instead of being locked in center; true by default; affected by crosshair settings
-- SWEP.StencilSight_ReticleTint = nil -- Reticle color; Color(255, 255, 255) by default
-- SWEP.StencilSight_ReticleTintBySightColor = nil -- Use the "Reticule Color" value from base settings instead of StencilSight_ReticleTint? false by default
-- SWEP.StencilSight_FadeReticleByProgress = nil -- Fade-in reticle alpha with aim progress; false by default
-- // Sight Type: Flat
-- Sight Type: Model; requires .reticle value of VElement's table (same deal as UseMask)
-- SWEP.StencilSight_ReticleType = TFA.Enum.RETICLE_MODEL
-- SWEP.StencilSight_FadeReticleByProgress = nil -- Fade-in reticle alpha with aim progress; false by default
-- SWEP.StencilSight_EnableQuad = nil -- Enables drawing Quad type reticles (example below) over model ones
-- // Sight Type: Model
-- Sight Type: Quad (aka the old way from TFA INS2)
-- SWEP.StencilSight_ReticleType = TFA.Enum.RETICLE_QUAD
-- SWEP.StencilSight_ReticleMaterial = "models/weapons/yurie_eft/parts/scopes/scope_p90_fn_ring_sight_std_LOD0_marks" -- Reticle material, accepts either string or Material() object; must be a square texture!
-- SWEP.StencilSight_ReticleSize = 1 -- Reticle quad size
-- SWEP.StencilSight_ScaleReticleByProgress = nil -- Scale reticle with aim progress for smoother fade-in; true by default
-- SWEP.StencilSight_ReticleTint = nil -- Reticle color; Color(255, 255, 255) by default
-- SWEP.StencilSight_ReticleTintBySightColor = nil -- Use the "Reticule Color" value from base settings instead of StencilSight_ReticleTint? false by default
-- SWEP.StencilSight_FadeReticleByProgress = nil -- Fade-in reticle alpha with aim progress; false by default
-- Quad Reticle Position Lookup
-- Lookup Type: Attachment
-- SWEP.StencilSight_PositionType = TFA.Enum.SIGHTSPOS_ATTACH -- Enabled by default
-- SWEP.StencilSight_ReticleAttachment = "tag_reticle" -- Name or index of target $attachment
-- Lookup Type: Bone
-- SWEP.StencilSight_PositionType = TFA.Enum.SIGHTSPOS_BONE
-- SWEP.StencilSight_ReticleBone = "tag_reticle" -- Name or index of target bone
-- SWEP.StencilSight_ReticleOffsetPos = nil -- Vector(0, 0, 0)
-- SWEP.StencilSight_ReticleOffsetAng = nil -- Angle(0, 0, 0)
-- // Sight Type: Quad
-- [[ BASH BASE PARAMETERS ]] --
-- If you're using "tfa_bash_base" or something that's derived from it
SWEP.Secondary.CanBash = true -- set to false to disable bashing
SWEP.Secondary.BashDamage = 25 -- Melee bash damage
SWEP.Secondary.BashSound = "TFA.Bash" -- Soundscript name for bash swing sound
SWEP.Secondary.BashHitSound = "TFA.BashWall" -- Soundscript name for non-flesh hit sound
SWEP.Secondary.BashHitSound_Flesh = "TFA.BashFlesh" -- Soundscript name for flesh hit sound
SWEP.Secondary.BashLength = 54 -- Length of bash melee trace in units
SWEP.Secondary.BashDelay = 0.2 -- Delay (in seconds) from bash start to bash attack trace
SWEP.Secondary.BashDamageType = DMG_SLASH -- Damage type (DMG_ enum value)
SWEP.Secondary.BashEnd = nil -- Bash end time (in seconds), defaults to animation end if undefined
SWEP.Secondary.BashInterrupt = false -- Bash attack interrupts everything (reload, draw, whatever)
-- [[MISC INFO FOR MODELERS]] --
--[[
Utilized animations (for modelers):
ACT_VM_DRAW - Draw
ACT_VM_DRAW_EMPTY - Draw empty
ACT_VM_DRAW_SILENCED - Draw silenced, overrides empty
ACT_VM_IDLE - Idle
ACT_VM_IDLE_EMPTY - Idle empty, overwritten by silenced
ACT_VM_IDLE_SILENCED - Idle silenced
ACT_VM_PRIMARYATTACK - Shoot
ACT_VM_PRIMARYATTACK_EMPTY - Shoot last chambered bullet
ACT_VM_PRIMARYATTACK_SILENCED - Shoot silenced, overrides empty
ACT_VM_PRIMARYATTACK_1 - Shoot ironsights, overriden by everything besides normal shooting
ACT_VM_DRYFIRE - Dryfire
ACT_VM_RELOAD - Reload / Tactical Reload / Insert Shotgun Shell
ACT_SHOTGUN_RELOAD_START - Start shotgun reload, unless ACT_VM_RELOAD_EMPTY is there.
ACT_SHOTGUN_RELOAD_FINISH - End shotgun reload.
ACT_VM_RELOAD_EMPTY - Empty mag reload, chambers the new round. Works for shotguns too, where applicable.
ACT_VM_RELOAD_SILENCED - Silenced reload, overwrites all
ACT_VM_FIREMODE - Firemode switch
ACT_VM_IFIREMODE - ADS firemode switch
ACT_VM_FIDGET - Inspect/fidget animation (hold Reload key to play)
ACT_CROSSBOW_FIDGET_UNLOADED - Inspect empty
ACT_RPG_FIDGET_UNLOADED - Inspect silenced
ACT_VM_HOLSTER - Holster
ACT_VM_HOLSTER_SILENCED - Holster empty, overwritten by silenced
ACT_VM_HOLSTER_SILENCED - Holster silenced
ACT_VM_HITCENTER - Melee bash
ACT_VM_HITCENTER2 - Melee bash silenced (why would you use that)
ACT_VM_MISSCENTER - Melee bash empty
ACT_VM_MISSCENTER2 - Melee bash empty and silenced (...)
-- For more verbose list check lua/tfa/documentation/tfa_anims_template.lua
]] --
-- Define local BaseClass to be SWEP.Base table
-- Example usage (AND PROPER ONE!):
--[[
function SWEP:Think2(...) -- We're overriding Think2 without touching the main think function, which is called from there anyway
BaseClass.Think2(self, ...) -- THE MOST IMPORTANT LINE! It calls the Think2 function of the parent class, which is the base ifself
-- Your code here.
end
]]
-- Write any code involving `BaseClass` indexing (like above) STRICTLY below DEFINE_BASECLASS(SWEP.Base), otherwise it won't work!
-- You can do the same with ANY function defined in TFA Base itself, as long as you call BaseClass function
DEFINE_BASECLASS(SWEP.Base)
-- TFA Base custom hooks reference
-- To be used with https://wiki.facepunch.com/gmod/hook.Add in your own code
-- All returns are optional, you can use hooks just to listen for events happening
-- Where state is listed as Shared, hook has to be added both on server and client to avoid any issues!
---------------------------
-- --
-- BASE INITIALIZATION --
-- --
---------------------------
GM:TFABase_PreEarlyInit()
-- Hook name: TFABase_PreEarlyInit
-- Description: Called after base enums has been loaded; preparing to load official modules
-- State: Shared
GM:TFABase_EarlyInit()
-- Hook name: TFABase_EarlyInit
-- Description: Called after official base modules has been loaded
-- State: Shared
GM:TFABase_PreInit()
-- Hook name: TFABase_PreInit
-- Description: Called before unofficial modules has been loaded
-- State: Shared
GM:TFABase_Init()
-- Hook name: TFABase_Init
-- Description: Called after unofficial modules have been found and loaded
-- State: Shared
GM:TFABase_PreFullInit()
-- Hook name: TFABase_PreFullInit
-- Description: Called before loading external files
-- State: Shared
GM:TFABase_FullInit()
-- Hook name: TFABase_FullInit
-- Description: Called after external files have been loaded
-- State: Shared
GM:TFABase_LateInit()
-- Hook name: TFABase_LateInit
-- Description: Called after (re)initializing the attachments
-- State: Shared
----------------------------------
-- --
-- ATTACHMENTS INITIALIZATION --
-- --
----------------------------------
boolean GM:TFABase_ShouldLoadAttachment(string attachmentID, string path)
-- Hook name: TFABase_ShouldLoadAttachment
-- Description: Called to determine if attachment should be registered
-- State: Shared
-- Arguments:
-- 1. string attachmentID - Requested attachment ID
-- 2. string path - Attachment file path (without extension)
-- Returns:
-- 1. boolean - Return false to prevent attachment from loading and registration
-- Example:
hook.Add("TFABase_ShouldLoadAttachment", "TFA_Hooks_Example", function(id, path)
if id and (id == "ins2_fg_gp25" or id == "ins2_fg_m203") then
return false -- block INS2 Shared Parts grenade launcher attachments from loading
end
end)
GM:TFABase_PreBuildAttachment(string attachmentID, string path, table attTbl)
-- Hook name: TFABase_PreBuildAttachment
-- Description: Called before loading attachment file
-- State: Shared
-- Arguments:
-- 1. string attachmentID - Requested attachment ID
-- 2. string path - Attachment file path (without extension)
-- 3. table attTbl - Empty attachment reference table (only containing assigned ID)
GM:TFABase_BuildAttachment(string attachmentID, string path, table attTbl)
-- Hook name: TFABase_BuildAttachment
-- Description: Called after attachment file has been loaded and executed
-- State: Shared
-- Arguments:
-- 1. string attachmentID - Requested attachment ID
-- 2. string path - Attachment file path (without extension)
-- 3. table attTbl - Populated attachment reference table
GM:TFABase_RegisterAttachment(string attachmentID, table attTbl)
-- Hook name: TFABase_RegisterAttachment
-- Description: Called when attachment has been registered
-- State: Shared
-- Arguments:
-- 1. string attachmentID - Requested attachment ID
-- 2. table attTbl - Attachment reference table
GM:TFAAttachmentsLoaded()
-- Hook name: TFAAttachmentsLoaded
-- Description: Called after all attachments has been loaded and registered
-- State: Shared
GM:TFAAttachmentsInitialized()
-- Hook name: TFAAttachmentsInitialized
-- Description: Called after all attachments has been fully loaded and initialized
-- State: Shared
-------------------------
-- --
-- WEAPON STAT CACHE --
-- --
-------------------------
any GM:TFA_GetStat(Weapon weapon, string stat, any value)
-- Hook name: TFA_GetStat
-- Description: Called when a cached stat value is requested from weapon, allowing to intercept and modify it.
-- State: Shared
-- Arguments:
-- - 1. Weapon weapon
-- - 2. string stat - Cached stat name
-- - 3. any value - Cached stat value that was received from weapon
-- Returns:
-- - 1. any - Return the modified stat to pass it to :GetStat call
-- Example #1:
hook.Add("TFA_GetStat", "TFA_Hooks_Example", function(weapon, stat, value)
if stat == "Primary.ClipSize" then -- We want to modify SWEP.Primary.ClipSize which is a cached stat
return value + 10 -- We add 10 to it's current (number) value
end
end)
-- Example #2:
hook.Add("TFA_GetStat", "TFA_Hooks_Example_2", function(weapon, stat, value)
if stat == "Primary.AmmoConsumption" or stat == "Secondary.AmmoConsumption" then
return 0 -- We tell the base that the gun does not consume any ammo - infinite ammo hook!
end
end)
GM:TFA_ClearStatCache(Weapon weapon)
-- Hook name: TFA_ClearStatCache
-- Description: Called after weapon's stat cache has been cleared
-- State: Shared
-- Arguments:
-- 1. Weapon weapon
---------------------------------
-- --
-- DEPLOY AND INITIALIZATION --
-- --
---------------------------------
GM:TFA_SetupDataTables(Weapon weapon)
-- Hook name: TFA_SetupDataTables
-- Description: Called after WEAPON:SetupDataTables, allowing to add custom networked data values
-- State: Shared
-- Arguments:
-- 1. Weapon weapon
-- Example:
hook.Add("TFA_SetupDataTables", "TFA_Hooks_Example", function(weapon)
weapon:NetworkVarTFA("Bool", "TestVar") -- Adding a boolean variable with name TestVar with getter WEAPON:GetTestVar() and setter WEAPON:SetTestVar(true)
-- Syntax of WEAPON:NetworkVarTFA is quite identical to Entity:NetworkVar ( https://wiki.facepunch.com/gmod/Entity:NetworkVar )
-- WEAPON:NetworkVarTFA(string type, string name)
end)
GM:TFA_PreInitialize(Weapon weapon)
-- Hook name: TFA_PreInitialize
-- Description: Called from SWEP:Initialize, allowing to do things before weapon is initialized
-- State: Shared
-- Arguments:
-- 1. Weapon weapon
GM:TFA_Initialize(Weapon weapon)
-- Hook name: TFA_Initialize
-- Description: Called after weapon has been initialized from SWEP:Initialize
-- State: Shared
-- Arguments:
-- 1. Weapon weapon
GM:TFA_PreDeploy(Weapon weapon)
-- Hook name: TFA_PreDeploy
-- Description: Called from SWEP:Deploy before weapon has been deployed
-- State: Shared, Predicted (not called in SP clientside)
-- Arguments:
-- 1. Weapon weapon
boolean GM:TFA_Deploy(Weapon weapon)
-- Hook name: TFA_Deploy
-- Description: Called from SWEP:Deploy after weapon has been deployed.
-- State: Shared, Predicted (not called in SP clientside)
-- Arguments:
-- 1. Weapon weapon
-- Returns:
-- 1. boolean - Return a boolean to override SWEP:Deploy output (default behavior returns true)
---------------------------
-- --
-- HOLSTER AND REMOVAL --
-- --
---------------------------
boolean GM:TFA_PreHolster(Weapon weapon, Entity target)
-- Hook name: TFA_PreHolster
-- Description: Called from SWEP:Holster, enabling to prevent switching from currently equipped weapon
-- State: Shared, Predicted (not called in SP clientside)
-- Arguments:
-- 1. Weapon weapon
-- 2. Entity target - The weapon that is being switched to
-- Returns:
-- 1. boolean - Return true to switch to target weapon instantly
GM:TFA_Holster(Weapon weapon)
-- Hook name: TFA_Holster
-- Description: Called when weapon is finished holstering and ready to switch
-- State: Shared
-- Arguments:
-- 1. Weapon weapon
GM:TFA_OnRemove(Weapon weapon)
-- Hook name: TFA_OnRemove
-- Description: Called from SWEP:OnRemove when weapon is being removed
-- State: Shared
-- Arguments:
-- 1. Weapon weapon
GM:TFA_OnDrop(Weapon weapon)
-- Hook name: TFA_OnDrop
-- Description: Called from SWEP:OnDrop when weapon is dropped by the player
-- State: Server
-- Arguments:
-- 1. Weapon weapon
-------------------------------------
-- --
-- PRIMARY AND SECONDARY ATTACKS --
-- --
-------------------------------------
boolean GM:TFA_PreCanPrimaryAttack(Weapon weapon)
-- Hook name: TFA_PreCanPrimaryAttack
-- Description: Called before weapon checks if it can shoot
-- State: Shared, Predicted (not called in SP clientside)
-- Arguments:
-- 1. Weapon weapon
-- Returns:
-- 1. boolean - Return to override return value of SWEP:CanPrimaryAttack
-- Example:
hook.Add("TFA_PreCanPrimaryAttack", "TFA_Hooks_Example", function(weapon)
if IsValid(weapon:GetOwner()) and weapon:GetOwner():IsPlayer() and weapon:GetOwner():Crouching() then
return false -- we are blocking shooting if player that holding the weapon is crouching
end
end)
boolean GM:TFA_CanPrimaryAttack(Weapon weapon)
-- Hook name: TFA_CanPrimaryAttack
-- Description: Same as above but called after all checks were done (except jamming)
-- State: Shared, Predicted (not called in SP clientside)
-- Arguments:
-- 1. Weapon weapon
-- Returns:
-- 1. boolean - Return to override return value of SWEP:CanPrimaryAttack
boolean GM:TFA_PrimaryAttack(Weapon weapon)
-- Hook name: TFA_PrimaryAttack
-- Description: Called before weapon shoots
-- State: Shared, Predicted (not called in SP clientside)
-- Arguments:
-- 1. Weapon weapon
-- Returns:
-- 1. boolean - Return true to prevent weapon shooting
GM:TFA_PostPrimaryAttack(Weapon weapon)
-- Hook name: TFA_PostPrimaryAttack
-- Description: Called after successful weapon attack
-- State: Shared, Predicted (not called in SP clientside)
-- Arguments:
-- 1. Weapon weapon
boolean GM:TFA_SecondaryAttack(Weapon weapon)
-- Hook name: TFA_SecondaryAttack
-- Description: Called when weapon is attempting to attack with right click (AltAttack/melee bash)
-- State: Shared, Predicted (not called in SP clientside)
-- Arguments:
-- 1. Weapon weapon
-- Returns:
-- 1. boolean - Return true to prevent secondary attack
--------------------------
-- --
-- BULLET PENETRATION --
-- --
--------------------------
boolean GM:TFA_Bullet_Penetrate(Weapon weapon, Entity attacker, TraceResult traceres, CTakeDamageInfo dmginfo, table penetrated, Vector previousStartPos)
-- Hook name: TFA_Bullet_Penetrate
-- Description: Called before bullet is allowed to penetrate next surface
-- State: Shared
-- Arguments:
-- 1. Weapon weapon
-- 2. Entity attacker - The entity (player or NPC) who used the weapon
-- 3. TraceResult traceres - Bullet trace result
-- 4. CTakeDamageInfo dmginfo - Bullet callback damage info structure
-- 5. table penetrated - Table of entities bullet has gone through already
-- 6. Vector previousStartPos - Either previous penetration hit position or nil
-- Returns:
-- 1. boolean - Return false to block penetration
GM:TFA_BulletPenetration(Bullet bullet, Entity attacker, TraceResult traceres, CTakeDamageInfo dmginfo)
-- Hook name: TFA_BulletPenetration
-- Description: Called when bullet hits/penetrates surface
-- State: Shared
-- Arguments:
-- 1. Bullet bullet - The bullet (to access weapon which fired the bullet use bullet.Wep)
-- 2. Entity attacker - The entity (player or NPC) who used the weapon
-- 3. TraceResult traceres - Bullet trace result
-- 4. CTakeDamageInfo dmginfo - Bullet callback damage info structure
-----------------
-- --
-- RELOADING --
-- --
-----------------
boolean GM:TFA_PreReload(Weapon weapon, boolean released)
-- Hook name: TFA_PreReload
-- Description: Called when reload key is pressed/released (before any checks done)
-- State: Shared, Predicted (not called in SP clientside)
-- Arguments:
-- 1. Weapon weapon
-- 2. boolean released - If legacy reloads are enabled, reload happens when reload key is pressed, otherwise when it's released (allowing for stuff like inspect)
-- Returns:
-- 1. boolean - Return true to prevent weapon from reloading
boolean GM:TFA_Reload(Weapon weapon)
-- Hook name: TFA_Reload
-- Description: Called when weapon is attempting to enter reload status
-- State: Shared, Predicted (not called in SP clientside)
-- Arguments:
-- 1. Weapon weapon
-- Returns:
-- 1. boolean - Return true to prevent weapon from reloading
GM:TFA_PostReload(Weapon weapon)
-- Hook name: TFA_PostReload
-- Description: Called after reload status checks
-- State: Shared, Predicted (not called in SP clientside)
-- Arguments:
-- 1. Weapon weapon
boolean GM:TFA_LoadShell(Weapon weapon)
-- Hook name: TFA_LoadShell
-- Description: Called when shotgun reload type weapons attempt to enter looped reload status and play animation
-- State: Shared
-- Arguments:
-- 1. Weapon weapon
-- Returns:
-- 1. boolean - Return true to prevent default logic
boolean GM:TFA_Pump(Weapon weapon)
-- Hook name: TFA_Pump
-- Description: Called when weapon is attempting to play pump/bolt animation
-- State: Shared
-- Arguments:
-- 1. Weapon weapon
-- Returns:
-- 1. boolean - Return true to prevent default logic
boolean GM:TFA_CompleteReload(Weapon weapon)
-- Hook name: TFA_CompleteReload
-- Description: Called when weapon is exiting reloading status and trying to take ammo (and clear jamming status)
-- State: Shared
-- Arguments:
-- 1. Weapon weapon
-- Returns:
-- 1. boolean - Return true to prevent default logic
-- Example:
hook.Add("TFA_CompleteReload", "TFA_Hooks_Example", function(weapon)
weapon:SetClip1(weapon:GetPrimaryClipSizeForReload(true)) -- We set weapon's primary clip to max clipsize without taking ammo from the player
weapon:SetJammed(false) -- Force clear jammed status (since default logic does that)
return true -- Suppressing default logic
end)
boolean GM:TFA_CheckAmmo(Weapon weapon)
-- Hook name: TFA_CheckAmmo
-- Description: Called when player is holding Reload key to play inspect animation (called even if player has bound inspection keybind)
-- State: Shared
-- Arguments:
-- 1. Weapon weapon
-- Returns:
-- 1. boolean - Return true to prevent default logic
-------------------
-- --
-- ATTACHMENTS --
-- --
-------------------
GM:TFA_PreInitAttachments(Weapon weapon)
-- Hook name: TFA_PreInitAttachments
-- Description: Called before attachments are initialized
-- State: Shared
-- Arguments:
-- 1. Weapon weapon
GM:TFA_PostInitAttachments(Weapon weapon)
-- Hook name: TFA_PostInitAttachments
-- Description: Called after attachments sorting and initial setup but before cleanup and attachment cache build
-- State: Shared
-- Arguments:
-- 1. Weapon weapon
GM:TFA_FinalInitAttachments(Weapon weapon)
-- Hook name: TFA_FinalInitAttachments
-- Description: Called after full attachments setup/initialization
-- State: Shared
-- Arguments:
-- 1. Weapon weapon
boolean GM:TFA_PreCanAttach(Weapon weapon, string attachmentID)
-- Hook name: TFA_PreCanAttach
-- Description: Called before weapon checks to determine if attachment can be attached
-- State: Shared
-- Arguments:
-- 1. Weapon weapon
-- 2. string attachmentID - The ID of the attachment
-- Returns:
-- 1. boolean - Return a boolean to prevent checks and override
boolean GM:TFA_CanAttach(Weapon weapon, string attachmentID)
-- Hook name: TFA_CanAttach
-- Description: Called after default checks to determine if attachment can be attached
-- State: Shared
-- Arguments:
-- 1. Weapon weapon
-- 2. string attachmentID - The ID of the attachment
-- Returns:
-- 1. boolean - Return a boolean to override the return value
GM:TFA_Attachment_Attached(Weapon weapon, string attachmentID, table attTable, number category, number index, boolean forced)
-- Hook name: TFA_Attachment_Attached
-- Description: Called after attachment has been attached to the weapon
-- State: Shared
-- Arguments:
-- 1. Weapon weapon
-- 2. string attachmentID - The ID of the attachment
-- 3. table attTable - The ATTACHMENT reference table of the attachment
-- 4. number category - The category of the attachment in SWEP.Attachments
-- 5. number index - The index of the attachment in the category's attachments table
-- 6. boolean forced - If attachment was applied forcefully (bypassing any checks)
boolean GM:TFA_PreCanDetach(Weapon weapon, string attachmentID)
-- Hook name: TFA_PreCanDetach
-- Description: Equivalent of TFA_PreCanAttach but for detaching
-- State: Shared
-- Arguments:
-- 1. Weapon weapon
-- 2. string attachmentID - The ID of the attachment
-- Returns:
-- 1. boolean - Return a boolean to prevent checks and override
boolean GM:TFA_CanDetach(Weapon weapon, string attachmentID)
-- Hook name: TFA_CanDetach
-- Description: Equivalent of TFA_CanAttach but for detaching
-- State: Shared
-- Arguments:
-- 1. Weapon weapon
-- 2. string attachmentID - The ID of the attachment
-- Returns:
-- 1. boolean - Return a boolean to override the return value
GM:TFA_Attachment_Detached(Weapon weapon, string attachmentID, table attTable, number category, number index, boolean forced)
-- Hook name: TFA_Attachment_Detached
-- Description: Equivalent of TFA_Attachment_Attached but for detaching
-- State: Shared
-- Arguments:
-- 1. Weapon weapon
-- 2. string attachmentID - The ID of the attachment that was detached
-- 3. table attTable - The ATTACHMENT reference table of the attachment
-- 4. number category - The category of the attachment in SWEP.Attachments
-- 5. number index - The index of the attachment in the category's attachments table that's going to be selected
-- 6. boolean forced - If attachment was applied forcefully (bypassing any checks)
-----------
-- --
-- FOV --
-- --
-----------
number GM:TFA_PreTranslateFOV(Weapon weapon, number fov)
-- Hook name: TFA_PreTranslateFOV
-- Description: Called before weapon modifies player's FOV
-- State: Shared
-- Arguments:
-- 1. Weapon weapon
-- 2. number fov - Reference FOV received by weapon
-- Returns:
-- 1. number - Return a number to override FOV and prevent default logic
number GM:TFA_TranslateFOV(Weapon weapon, number fov)
-- Hook name: TFA_TranslateFOV
-- Description: Called after weapon calculated modified FOV
-- State: Shared
-- Arguments:
-- 1. Weapon weapon
-- 2. number fov - Modified FOV value returned by weapon
-- Returns:
-- 1. number - Return to override modified FOV
------------------
-- --
-- ANIMATIONS --
-- --
------------------
number GM:TFA_AnimationRate(Weapon weapon, number sequence, number rate)
-- Hook name: TFA_AnimationRate
-- Description: Called
-- State: Shared
-- Arguments:
-- 1. Weapon weapon
-- 2. number sequence - Index of sequence from viewmodel animations
-- 3. number rate - Playback speed multiplier calculated by weapon
-- Returns:
-- 1. number - Return modified playback speed multiplier to override
---------------
-- --
-- EFFECTS --
-- --
---------------
any GM:TFA_MakeShell(Weapon weapon)
-- Hook name: TFA_MakeShell
-- Description: Called when weapon is trying to emit a shell casing effect
-- State: Shared
-- Arguments:
-- 1. Weapon weapon
-- Returns:
-- 1. any - Return anything to cancel
any GM:TFA_EjectionSmoke(Weapon weapon)
-- Hook name: TFA_EjectionSmoke
-- Description: Called when weapon is trying to emit smoke from shell ejection port
-- State: Shared
-- Arguments:
-- 1. Weapon weapon
-- Returns:
-- 1. any - Return anything to cancel
any GM:TFA_MuzzleFlash(Weapon weapon)
-- Hook name: TFA_MuzzleFlash
-- Description: Called when weapon is trying to emit muzzle flash effect
-- State: Shared
-- Arguments:
-- 1. Weapon weapon
-- Returns:
-- 1. any - Return anything to cancel
any GM:TFA_MuzzleSmoke(Weapon weapon)
-- Hook name: TFA_MuzzleSmoke
-- Description: Called when weapon is trying to emit smoke from muzzle
-- State: Shared
-- Arguments:
-- 1. Weapon weapon
-- Returns:
-- 1. any - Return anything to cancel
------------------
-- --
-- IRONSIGHTS --
-- --
------------------
any GM:TFA_IronSightSounds(Weapon weapon)
-- Hook name: TFA_IronSightSounds
-- Description: Called when weapon tries to play ironsights enter/exit sound
-- State: Shared
-- Arguments:
-- 1. Weapon weapon
-- Returns:
-- 1. any - Return anything to cancel
-----------------------
-- --
-- MELEE / BASHING --
-- --
-----------------------
boolean GM:TFA_CanBash(Weapon weapon)
-- Hook name: TFA_CanBash
-- Description: Called when player is attempting to use melee bash attack (after initial checks)
-- State: Shared
-- Arguments:
-- 1. Weapon weapon
-- Returns:
-- 1. boolean - Return false to disallow melee attack
GM:TFA_Bash(Weapon weapon)
-- Hook name: TFA_Bash
-- Description: Called when weapon is about to perform a melee attack
-- State: Shared
-- Arguments:
-- 1. Weapon weapon
GM:TFA_PostBash(Weapon weapon)
-- Hook name: TFA_PostBash
-- Description: Called after weapon has entered melee attack status
-- State: Shared
-- Arguments:
-- 1. Weapon weapon
----------------------------
-- --
-- HUD / USER INTERFACE --
-- --
----------------------------
boolean GM:TFA_DrawCrosshair(Weapon weapon, number x, number y)
-- Hook name: TFA_DrawCrosshair
-- Description: Called from SWEP:DoDrawCrosshair when weapon is about to draw crosshair
-- State: Client
-- Arguments:
-- 1. Weapon weapon
-- 2. number x
-- 3. number y
-- Returns:
-- 1. boolean - Return false to draw only engine crosshair, true to block both
boolean, number, number, number GM:TFA_DrawHUDAmmo(Weapon weapon, number x, number y, number alpha)
-- Hook name: TFA_DrawHUDAmmo
-- Description: Called before drawing holographic ammo indicator on screen
-- State: Client
-- Arguments:
-- 1. Weapon weapon
-- 2. number x - left position
-- 3. number y - top position
-- 4. number alpha
-- Returns:
-- 1. boolean - Return false to prevent drawing (next returns ignored), true to modify following values:
-- 2. number - modified X position
-- 3. number - modified Y position
-- 4. number - modified alpha
boolean GM:TFA_DrawScopeOverlay(Weapon weapon)
-- Hook name: TFA_DrawScopeOverlay
-- Description: Called before drawing 2D scope overlay
-- State: Client
-- Arguments:
-- 1. Weapon weapon
-- Returns:
-- 1. boolean - Return true to prevent drawing the overlay
---------------------------------------
-- --
-- CUSTOMIZATION / INSPECTION MENU --
-- --
---------------------------------------
boolean GM:TFA_InspectVGUI_Start(Weapon weapon)
-- Hook name: TFA_InspectVGUI_Start
-- Description: Called before main customization screen panel is generated
-- State: Client
-- Arguments:
-- 1. Weapon weapon
-- Returns:
-- 1. boolean - Return false to prevent creation
GM:TFA_InspectVGUI_Finish(Weapon weapon, Panel mainpanel, Panel contentpanel)
-- Hook name: TFA_InspectVGUI_Finish
-- Description: Called after every panel has been initialized
-- State: Client
-- Arguments:
-- 1. Weapon weapon
-- 2. Panel mainpanel - The parent inspection screen panel
-- 3. Panel contentpanel - The padded panel that contains all elements
boolean GM:TFA_InspectVGUI_InfoStart(Weapon weapon, Panel contentpanel)
-- Hook name: TFA_InspectVGUI_InfoStart
-- Description: Called before populating screen with weapon info elements
-- State: Client
-- Arguments:
-- 1. Weapon weapon
-- 2. Panel contentpanel - The padded panel that contains all elements
-- Returns:
-- 1. boolean - Return false to prevent creation
GM:TFA_InspectVGUI_InfoFinish(Weapon weapon, Panel contentpanel)
-- Hook name: TFA_InspectVGUI_InfoFinish
-- Description: Called when weapon info elements are added
-- State: Client
-- Arguments:
-- 1. Weapon weapon
-- 2. Panel contentpanel - The padded panel that contains all elements
boolean GM:TFA_InspectVGUI_StatsStart(Weapon weapon, Panel contentpanel)
-- Hook name: TFA_InspectVGUI_StatsStart
-- Description: Called before adding weapon stats panel
-- State: Client
-- Arguments:
-- 1. Weapon weapon
-- 2. Panel contentpanel - The padded panel that contains all elements
-- Returns:
-- 1. boolean - Return false to prevent creation
GM:TFA_InspectVGUI_StatsFinish(Weapon weapon, Panel contentpanel)
-- Hook name: TFA_InspectVGUI_StatsFinish
-- Description: Called when weapon stats are added
-- State: Client
-- Arguments:
-- 1. Weapon weapon
-- 2. Panel contentpanel - The padded panel that contains all elements
boolean GM:TFA_InspectVGUI_AttachmentsStart(Weapon weapon, Panel contentpanel)
-- Hook name: TFA_InspectVGUI_AttachmentsStart
-- Description: Called before adding attachments selector panel
-- State: Client
-- Arguments:
-- 1. Weapon weapon
-- 2. Panel contentpanel - The padded panel that contains all elements
-- Returns:
-- 1. boolean - Return false to prevent creation (also blocks damage falloff graph)
GM:TFA_InspectVGUI_AttachmentsFinish(Weapon weapon, Panel contentpanel, Panel attachmentspanel)
-- Hook name: TFA_InspectVGUI_AttachmentsFinish
-- Description: Called after attachments selector panel is generated
-- State: Client
-- Arguments:
-- 1. Weapon weapon
-- 2. Panel contentpanel - The padded panel that contains all elements
-- 3. Panel attachmentspanel - The resulting attachments selector panel
boolean GM:TFA_InspectVGUI_FalloffStart(Weapon weapon, Panel contentpanel)
-- Hook name: TFA_InspectVGUI_FalloffStart
-- Description: Called before damage falloff graph is initialized
-- State: Client
-- Arguments:
-- 1. Weapon weapon
-- 2. Panel contentpanel - The padded panel that contains all elements
-- Returns:
-- 1. boolean - Return false to prevent creation
GM:TFA_InspectVGUI_FalloffFinish(Weapon weapon, Panel contentpanel, Panel falloffpanel)
-- Hook name: TFA_InspectVGUI_FalloffFinish
-- Description: Called after damage falloff graph panel is initialized
-- State: Client
-- Arguments:
-- 1. Weapon weapon
-- 2. Panel contentpanel - The padded panel that contains all elements
-- 3. Panel falloffpanel - The resulting damage falloff graph panel
----------------------
-- --
-- DEPTH OF FIELD --
-- --
----------------------
boolean GM:TFA_AllowDoFDraw(Weapon weapon, Player player, Entity viewmodel)
-- Hook name: TFA_AllowDoFDraw
-- Description: Called before drawing aim DoF effect on viewmodel
-- State: Client
-- Arguments:
-- 1. Weapon weapon
-- 2. Player player - The player that is currently holding the weapon
-- 3. Entity viewmodel - Weapon's viewmodel
-- Returns:
-- 1. boolean - Return false to prevent effect from drawing
number GM:TFA_GetDoFMuzzleAttachmentID(Weapon weapon, Player player, Entity viewmodel)
-- Hook name: TFA_GetDoFMuzzleAttachmentID
-- Description: Called when deciding reference attachment for DoF effect focus
-- State: Client.
-- Arguments:
-- 1. Weapon weapon
-- 2. Player player - The player that is currently holding the weapon
-- 3. Entity viewmodel - Weapon's viewmodel
-- Returns:
-- 1. number - Return viewmodel's attachment point index to override
-- TFA Base Template by TFA Base Devs
-- To the extent possible under law, the person who associated CC0 with
-- TFA Base Template has waived all copyright and related or neighboring rights
-- to TFA Base Template.
-- You should have received a copy of the CC0 legalcode along with this
-- work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --
-- ! ! --
-- ! WARNING! This template is outdated, not supported anymore ! --
-- ! and is only kept in for reference/comparison reasons. ! --
-- ! ! --
-- ! Please use the updated template ! --
-- ! located at lua/weapons/tfa_base_template/shared.lua ! --
-- ! for future weapon development purposes. ! --
-- ! ! --
-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --
SWEP.Base = "tfa_gun_base"
SWEP.Category = "TFA Template" -- The category. Please, just choose something generic or something I've already done if you plan on only doing like one swep..
SWEP.Manufacturer = nil -- Gun Manufactrer (e.g. Hoeckler and Koch )
SWEP.Author = "" -- Author Tooltip
SWEP.Contact = "" -- Contact Info Tooltip
SWEP.Purpose = "" -- Purpose Tooltip
SWEP.Instructions = "" -- Instructions Tooltip
SWEP.Spawnable = false -- Can you, as a normal user, spawn this?
SWEP.AdminSpawnable = false -- Can an adminstrator spawn this? Does not tie into your admin mod necessarily, unless its coded to allow for GMod's default ranks somewhere in its code. Evolve and ULX should work, but try to use weapon restriction rather than these.
SWEP.DrawCrosshair = true -- Draw the crosshair?
SWEP.DrawCrosshairIS = false -- Draw the crosshair in ironsights?
SWEP.PrintName = "TFA Base Template" -- Weapon name (Shown on HUD)
SWEP.Slot = 2 -- Slot in the weapon selection menu. Subtract 1, as this starts at 0.
SWEP.SlotPos = 73 -- Position in the slot
SWEP.AutoSwitchTo = true -- Auto switch to if we pick it up
SWEP.AutoSwitchFrom = true -- Auto switch from if you pick up a better weapon
SWEP.Weight = 30 -- This controls how "good" the weapon is for autopickup.
-- [[WEAPON HANDLING]] --
SWEP.Primary.Sound = Sound("") -- This is the sound of the weapon, when you shoot.
SWEP.Primary.SilencedSound = nil -- This is the sound of the weapon, when silenced.
SWEP.Primary.PenetrationMultiplier = 1 -- Change the amount of something this gun can penetrate through
-- the LESSER this value is, the BETTER is penetration
-- this is basically multiplier for next values
-- you don't need to uncomment these if you are not going to modify them!
--[[
SWEP.PenetrationMaterials = {
[MAT_DEFAULT] = 1,
[MAT_VENT] = 0.4, --Since most is aluminum and stuff
[MAT_METAL] = 0.6, --Since most is aluminum and stuff
[MAT_WOOD] = 0.2,
[MAT_PLASTIC] = 0.23,
[MAT_FLESH] = 0.48,
[MAT_CONCRETE] = 0.87,
[MAT_GLASS] = 0.16,
[MAT_SAND] = 1,
[MAT_SLOSH] = 1,
[MAT_DIRT] = 0.95, --This is plaster, not dirt, in most cases.
[MAT_FOLIAGE] = 0.9
}
]]
SWEP.Primary.Damage = 0.01 -- Damage, in standard damage points.
SWEP.Primary.DamageTypeHandled = true -- true will handle damagetype in base
SWEP.Primary.DamageType = nil -- See DMG enum. This might be DMG_SHOCK, DMG_BURN, DMG_BULLET, etc. Leave nil to autodetect. DMG_AIRBOAT opens doors.
SWEP.Primary.Force = nil -- Force value, leave nil to autocalc
SWEP.Primary.Knockback = nil -- Autodetected if nil; this is the velocity kickback
SWEP.Primary.HullSize = 0 -- Big bullets, increase this value. They increase the hull size of the hitscan bullet.
SWEP.Primary.NumShots = 1 -- The number of shots the weapon fires. SWEP.Shotgun is NOT required for this to be >1.
SWEP.Primary.Automatic = true -- Automatic/Semi Auto
SWEP.Primary.RPM = 600 -- This is in Rounds Per Minute / RPM
SWEP.Primary.RPM_Semi = nil -- RPM for semi-automatic or burst fire. This is in Rounds Per Minute / RPM
SWEP.Primary.RPM_Burst = nil -- RPM for burst fire, overrides semi. This is in Rounds Per Minute / RPM
SWEP.Primary.DryFireDelay = nil -- How long you have to wait after firing your last shot before a dryfire animation can play. Leave nil for full empty attack length. Can also use SWEP.StatusLength[ ACT_VM_BLABLA ]
SWEP.Primary.BurstDelay = nil -- Delay between bursts, leave nil to autocalculate
SWEP.Primary.LoopSound = nil -- Looped fire sound, unsilenced
SWEP.Primary.LoopSoundSilenced = nil -- Looped fire sound, silenced
SWEP.Primary.LoopSoundTail = nil -- Loop end/tail sound, unsilenced
SWEP.Primary.LoopSoundTailSilenced = nil -- Loop end/tail sound, silenced
SWEP.Primary.LoopSoundAutoOnly = false -- Play loop sound for full-auto only? Fallbacks to Primary.Sound for semi/burst if true
-- WORLD/THIRDPERSON/NPC FIRING SOUNDS! Fallbacks to first person sound if not defined.
SWEP.Primary.Sound_World = nil -- This is the sound of the weapon, when you shoot.
SWEP.Primary.SilencedSound_World = nil -- This is the sound of the weapon, when silenced.
SWEP.Primary.LoopSound_World = nil -- Looped fire sound, unsilenced
SWEP.Primary.LoopSoundSilenced_World = nil -- Looped fire sound, silenced
SWEP.Primary.LoopSoundTail_World = nil -- Loop end/tail sound, unsilenced
SWEP.Primary.LoopSoundTailSilenced_World = nil -- Loop end/tail sound, silenced
SWEP.ViewModelPunchPitchMultiplier = nil -- Default value is 0.5
SWEP.ViewModelPunchPitchMultiplier_IronSights = nil -- Default value is 0.09
SWEP.ViewModelPunch_MaxVertialOffset = nil -- Default value is 3
SWEP.ViewModelPunch_MaxVertialOffset_IronSights = nil -- Default value is 1.95
SWEP.ViewModelPunch_VertialMultiplier = nil -- Default value is 1
SWEP.ViewModelPunch_VertialMultiplier_IronSights = nil -- Default value is 0.25
SWEP.ViewModelPunchYawMultiplier = nil -- Default value is 0.6
SWEP.ViewModelPunchYawMultiplier_IronSights = nil -- Default value is 0.25
SWEP.CanJam = true -- whenever weapon cam jam
SWEP.JamChance = 0.04 -- the (maximal) chance the weapon will jam. Newly spawned weapon will never jam on first shot for example.
-- Default value is 0.04 (4%)
-- Maxmial value is 1, means weapon will always jam when factor become 100
-- Also remember that there is a minimal factor before weapon can jam
-- This number is not treated "as-is" but as basic value that needs to be concluded as chance
-- You don't really need to cry over it and trying to balance it, TFA Base will do the job for you
-- (TFA Base will calculate the best value between 0 and JamChance based on current JamFactor of the weapon)
SWEP.JamFactor = 0.06 -- How to increase jam factor after each shot.
-- When factor reach 100 it will mean that on each shot there will be SWEP.Primary.JamChance chance to jam
-- When factor reach 50 it will mean that on each shot there will be SWEP.Primary.JamChance / 2 chance to jam
-- and so on
-- Default value is 0.06, means weapon will jam with SWEP.Primary.JamChance chance right after 1666 shots
-- These settings are good for Assault Rifles, however, not good for anything else.
-- Suggested stats:
--[[
-- Pistols
SWEP.JamChance = 0.20
SWEP.JamFactor = 0.14
]]
--[[
-- Revolvers
SWEP.JamChance = 0.17
SWEP.JamFactor = 0.50
]]
--[[
-- Miniguns
SWEP.JamChance = 0.03
SWEP.JamFactor = 0.01
]]
--[[
-- Submachine gun
SWEP.JamChance = 0.04
SWEP.JamFactor = 0.09
]]
--[[
-- Auto shotguns
SWEP.JamChance = 0.15
SWEP.JamFactor = 0.2
]]
--[[
-- Pump-action shotguns
SWEP.JamChance = 0.25
SWEP.JamFactor = 0.3
]]
--[[
-- Sniper rifle
SWEP.JamChance = 0.17
SWEP.JamFactor = 0.35
]]
SWEP.FiresUnderwater = false
-- Miscelaneous Sounds
SWEP.IronInSound = nil -- Sound to play when ironsighting in? nil for default
SWEP.IronOutSound = nil -- Sound to play when ironsighting out? nil for default
-- Silencing
SWEP.CanBeSilenced = false -- Can we silence? Requires animations.
SWEP.Silenced = false -- Silenced by default?
-- Selective Fire Stuff
SWEP.SelectiveFire = false -- Allow selecting your firemode?
SWEP.DisableBurstFire = false -- Only auto/single?
SWEP.OnlyBurstFire = false -- No auto, only burst/single?
SWEP.BurstFireCount = nil -- Burst fire count override (autocalculated by the clip size if nil)
SWEP.DefaultFireMode = "" -- Default to auto or whatev
SWEP.FireModeName = nil -- Change to a text value to override it
SWEP.FireSoundAffectedByClipSize = true -- Whenever adjuct pitch (and proably other properties) of fire sound based on current clip / maxclip
-- This is always false when either:
-- Weapon has no primary clip
-- Weapon's clip is smaller than 4 rounds
-- Weapon is a shotgun
-- Ammo Related
SWEP.Primary.ClipSize = 0 -- This is the size of a clip
SWEP.Primary.DefaultClip = 0 -- This is the number of bullets the gun gives you, counting a clip as defined directly above.
SWEP.Primary.Ammo = "none" -- What kind of ammo. Options, besides custom, include pistol, 357, smg1, ar2, buckshot, slam, SniperPenetratedRound, and AirboatGun.
SWEP.Primary.AmmoConsumption = 1 -- Ammo consumed per shot
-- Pistol, buckshot, and slam like to ricochet. Use AirboatGun for a light metal peircing shotgun pellets
SWEP.DisableChambering = false -- Disable round-in-the-chamber
-- Recoil Related
SWEP.Primary.KickUp = 0 -- This is the maximum upwards recoil (rise)
SWEP.Primary.KickDown = 0 -- This is the maximum downwards recoil (skeet)
SWEP.Primary.KickHorizontal = 0 -- This is the maximum sideways recoil (no real term)
SWEP.Primary.StaticRecoilFactor = 0.5 -- Amount of recoil to directly apply to EyeAngles. Enter what fraction or percentage (in decimal form) you want. This is also affected by a convar that defaults to 0.5.
-- Firing Cone Related
SWEP.Primary.Spread = .01 -- This is hip-fire acuracy. Less is more (1 is horribly awful, .0001 is close to perfect)
SWEP.Primary.IronAccuracy = .005 -- Ironsight accuracy, should be the same for shotguns
-- Unless you can do this manually, autodetect it. If you decide to manually do these, uncomment this block and remove this line.
SWEP.Primary.SpreadMultiplierMax = nil -- How far the spread can expand when you shoot. Example val: 2.5
SWEP.Primary.SpreadIncrement = nil -- What percentage of the modifier is added on, per shot. Example val: 1/3.5
SWEP.Primary.SpreadRecovery = nil -- How much the spread recovers, per second. Example val: 3
-- Range Related
-- DEPRECATED. Automatically converted to RangeFalloffLUT table
SWEP.Primary.Range = -1 -- The distance the bullet can travel in source units. Set to -1 to autodetect based on damage/rpm.
SWEP.Primary.RangeFalloff = -1 -- The percentage of the range the bullet damage starts to fall off at. Set to 0.8, for example, to start falling off after 80% of the range.
-- Use these if you don't want/understand how to use LUT below. These values are automatically converted to RangeFalloffLUT table
SWEP.Primary.FalloffMetricBased = false -- Set to true if you set up values below
SWEP.Primary.FalloffByMeter = nil -- How much damage points will bullet loose when travel
SWEP.Primary.MinRangeStartFalloff = nil -- How long will bullet travel in Meters before starting to lose damage?
SWEP.Primary.MaxFalloff = nil -- Maximal amount of damage to be lost
-- Use this for full control over damage dropoff.
--[[
SWEP.Primary.RangeFalloffLUT = {
bezier = true, -- Whenever to use Bezier or not to interpolate points?
-- you probably always want it to be set to true
range_func = "quintic", -- function to spline range
-- "linear" for linear splining.
-- Possible values are "quintic", "cubic", "cosine", "sinusine", "linear" or your own function
units = "meters", -- possible values are "inches", "inch", "hammer", "hu" (are all equal)
-- everything else is considered to be meters
lut = { -- providing zero point is not required
-- without zero point it is considered to be as {range = 0, damage = 1}
{range = 5, damage = 0.9},
{range = 12, damage = 0.8},
{range = 18, damage = 0.5},
{range = 24, damage = 0.2},
{range = 30, damage = 0.55},
{range = 38, damage = 0.76},
{range = 50, damage = 1},
{range = 52, damage = 0.96},
{range = 60, damage = 0.3},
{range = 70, damage = 0.1},
}
}
]]
SWEP.DisplayFalloff = nil -- Defaults to true (false for melees)
--[[
SWEP.Primary.RecoilLUT_IronSightsMult = nil -- Defaults to 0.5
-- controls how much effective LUT is when iron sighting
SWEP.Primary.RecoilLUT_AnglePunchMult = nil -- Defaults to 0.25
-- controls how much effective LUT at pushing EyeAngles of shooter
SWEP.Primary.RecoilLUT_ViewPunchMult = nil -- Defaults to 1
-- controls how much effective LUT at viewpunch
SWEP.Primary.RecoilLUT = {
["in"] = {
bezier = true,
func = "quintic", -- function to inerpolate progress when sampling points from table
-- Possible values are "quintic", "cubic", "cosine", "sinusine", "linear" or your own function
cooldown_speed = 1, -- how much to loose progress when we are at this stage
-- 1 means we lose entire progress in a second
increase = 0.1, -- how much to increase progress after shot
-- 0.1 means that this stage would be full after 10 shots
wait = 0.1, -- how much time do we wait in seconds after we stopped shooting
-- after this time, IN stage begin to cooldown until it reach zero
-- table is always prepended with an Angle()
-- only Pitch and Yaw are utilized
-- sampled point is added to aimvector of player
-- when they shoot
points = {
Angle(-1, 0.4),
Angle(-4, -2),
Angle(-6, -4),
Angle(-10, -6),
}
},
["loop"] = {
bezier = true,
func = "quintic",
-- this stage can not cooldown, so no cooldown_speed is defined
increase = 0.1, -- when LOOP stage reach 1, it is reset to 0
wait = 0.1, -- how much time do we wait in seconds after we stopped shooting
-- after this time, stage switch to OUT
-- table is NOT prepended with an Angle()
-- make sure it's starting point match the one from IN stage
-- last and first points are connected automatically
points = {
Angle(-10, -6),
Angle(-12, -0.4),
Angle(-8, 9),
Angle(-11, 12),
Angle(-13, 2),
Angle(-8, -4),
}
},
["out"] = {
bezier = true,
func = "quintic",
-- this stage is different
-- it is only started after LOOP took place
-- shooting in this stage will actually roll back it's state
-- until it reach zero and switch back to LOOP
-- cooling down actually increase stage's progress
cooldown_speed = 1,
-- increase act as negative number to reach zero in this stage
increase = 0.2,
-- after this stage reach 1, everything reset to IN and wait for next fire
-- table is always appended with an Angle()
-- starting point is dynamic
-- and will always match current LOOP's one
points = {
Angle(-7, -2),
Angle(-4, -1),
Angle(-2, 0),
}
}
}
]]
-- Penetration Related
SWEP.MaxPenetrationCounter = 4 -- The maximum number of ricochets. To prevent stack overflows.
-- Misc
SWEP.IronRecoilMultiplier = 0.5 -- Multiply recoil by this factor when we're in ironsights. This is proportional, not inversely.
SWEP.CrouchAccuracyMultiplier = 0.5 -- Less is more. Accuracy * 0.5 = Twice as accurate, Accuracy * 0.1 = Ten times as accurate
-- Movespeed
SWEP.MoveSpeed = 1 -- Multiply the player's movespeed by this.
SWEP.IronSightsMoveSpeed = 0.8 -- Multiply the player's movespeed by this when sighting.
-- PROJECTILES
SWEP.Primary.Projectile = nil -- Entity to shoot
SWEP.Primary.ProjectileVelocity = 0 -- Entity to shoot's velocity
SWEP.Primary.ProjectileModel = nil -- Entity to shoot's model
-- VIEWMODEL
SWEP.ViewModel = "models/your/path/here.mdl" -- Viewmodel path
SWEP.ViewModelFOV = 65 -- This controls how big the viewmodel looks. Less is more.
SWEP.ViewModelFlip = false -- Set this to true for CSS models, or false for everything else (with a righthanded viewmodel.)
SWEP.UseHands = false -- Use gmod c_arms system.
SWEP.VMPos = Vector(0, 0, 0) -- The viewmodel positional offset, constantly. Subtract this from any other modifications to viewmodel position.
SWEP.VMAng = Vector(0, 0, 0) -- The viewmodel angular offset, constantly. Subtract this from any other modifications to viewmodel angle.
SWEP.VMPos_Additive = true -- Set to false for an easier time using VMPos. If true, VMPos will act as a constant delta ON TOP OF ironsights, run, whateverelse
SWEP.CenteredPos = nil -- The viewmodel positional offset, used for centering. Leave nil to autodetect using ironsights.
SWEP.CenteredAng = nil -- The viewmodel angular offset, used for centering. Leave nil to autodetect using ironsights.
SWEP.Bodygroups_V = nil -- {
-- [0] = 1,
-- [1] = 4,
-- [2] = etc.
-- }
SWEP.AllowIronSightsDoF = true -- whenever allow DoF effect on viewmodel when zoomed in with iron sights
SWEP.IronSightsReloadEnabled = nil -- Enable ADS reload animations support (requires animations to be enabled in SWEP.Animations)
SWEP.IronSightsReloadLock = true -- Lock ADS state when reloading
-- WORLDMODEL
SWEP.WorldModel = "models/your/wmodel/path/here.mdl" -- Weapon world model path
SWEP.Bodygroups_W = nil -- {
-- [0] = 1,
-- [1] = 4,
-- [2] = etc.
-- }
SWEP.HoldType = "" -- This is how others view you carrying the weapon. Options include:
-- normal melee melee2 fist knife smg ar2 pistol rpg physgun grenade shotgun crossbow slam passive
-- You're mostly going to use ar2, smg, shotgun or pistol. rpg and crossbow make for good sniper rifles
SWEP.Offset = {
Pos = {
Up = 0,
Right = 0,
Forward = 0
},
Ang = {
Up = -1,
Right = -2,
Forward = 178
},
Scale = 1
} -- Procedural world model animation, defaulted for CS:S purposes.
SWEP.ThirdPersonReloadDisable = false -- Disable third person reload? True disables.
-- SCOPES
SWEP.IronSightsSensitivity = 1 -- Useful for a RT scope. Change this to 0.25 for 25% sensitivity. This is if normal FOV compenstaion isn't your thing for whatever reason, so don't change it for normal scopes.
SWEP.BoltAction = false -- Unscope/sight after you shoot?
SWEP.Scoped = false -- Draw a scope overlay?
SWEP.ScopeOverlayThreshold = 0.875 -- Percentage you have to be sighted in to see the scope.
SWEP.BoltTimerOffset = 0.25 -- How long you stay sighted in after shooting, with a bolt action.
SWEP.ScopeScale = 0.5 -- Scale of the scope overlay
SWEP.ReticleScale = 0.7 -- Scale of the reticle overlay
-- GDCW Overlay Options. Only choose one.
SWEP.Secondary.UseACOG = false -- Overlay option
SWEP.Secondary.UseMilDot = false -- Overlay option
SWEP.Secondary.UseSVD = false -- Overlay option
SWEP.Secondary.UseParabolic = false -- Overlay option
SWEP.Secondary.UseElcan = false -- Overlay option
SWEP.Secondary.UseGreenDuplex = false -- Overlay option
if surface then
SWEP.Secondary.ScopeTable = nil --[[
{
scopetex = surface.GetTextureID("scope/gdcw_closedsight"),
reticletex = surface.GetTextureID("scope/gdcw_acogchevron"),
dottex = surface.GetTextureID("scope/gdcw_acogcross")
}
]] --
end
-- [[SHOTGUN CODE]] --
SWEP.Shotgun = false -- Enable shotgun style reloading.
SWEP.ShotgunEmptyAnim = false -- Enable emtpy reloads on shotguns?
SWEP.ShotgunEmptyAnim_Shell = true -- Enable insertion of a shell directly into the chamber on empty reload?
SWEP.ShotgunStartAnimShell = false -- shotgun start anim inserts shell
SWEP.ShellTime = .35 -- For shotguns, how long it takes to insert a shell.
-- [[SPRINTING]] --
SWEP.RunSightsPos = Vector(0, 0, 0) -- Change this, using SWEP Creation Kit preferably
SWEP.RunSightsAng = Vector(0, 0, 0) -- Change this, using SWEP Creation Kit preferably
-- [[CROUCHING]] --
-- Viewmodel offset when player is crouched
-- SWEP.CrouchPos = Vector(0, 0, 0)
-- SWEP.CrouchAng = Vector(0, 0, 0)
-- [[IRONSIGHTS]] --
SWEP.data = {}
SWEP.data.ironsights = 1 -- Enable Ironsights
SWEP.Secondary.IronFOV = 70 -- How much you "zoom" in. Less is more! Don't have this be <= 0. A good value for ironsights is like 70.
-- SWEP.IronViewModelFOV = 65 -- Target viewmodel FOV when aiming down the sights.
SWEP.IronSightsPos = Vector(0, 0, 0) -- Change this, using SWEP Creation Kit preferably
SWEP.IronSightsAng = Vector(0, 0, 0) -- Change this, using SWEP Creation Kit preferably
-- [[INSPECTION]] --
SWEP.InspectPos = nil -- Vector(0, 0, 0) -- Replace with a vector, in style of ironsights position, to be used for inspection
SWEP.InspectAng = nil -- Vector(0, 0, 0) -- Replace with a vector, in style of ironsights angle, to be used for inspection
-- [[VIEWMODEL BLOWBACK]] --
SWEP.BlowbackEnabled = false -- Enable Blowback?
SWEP.BlowbackVector = Vector(0, -1, 0) -- Vector to move bone <or root> relative to bone <or view> orientation.
SWEP.BlowbackAngle = nil -- Angle(0, 0, 0)
SWEP.BlowbackCurrentRoot = 0 -- Amount of blowback currently, for root
SWEP.BlowbackCurrent = 0 -- Amount of blowback currently, for bones
SWEP.BlowbackBoneMods = nil -- Viewmodel bone mods via SWEP Creation Kit
SWEP.Blowback_Only_Iron = true -- Only do blowback on ironsights
SWEP.Blowback_PistolMode = false -- Do we recover from blowback when empty?
SWEP.Blowback_Shell_Enabled = true -- Shoot shells through blowback animations
SWEP.Blowback_Shell_Effect = "ShellEject" -- Which shell effect to use
SWEP.BlowbackAllowAnimation = nil -- Allow playing shoot animation with blowback?
-- [[VIEWMODEL PROCEDURAL ANIMATION]] --
SWEP.DoProceduralReload = false -- Animate first person reload using lua?
SWEP.ProceduralReloadTime = 1 -- Procedural reload time?
-- [[HOLDTYPES]] --
SWEP.IronSightHoldTypeOverride = "" -- This variable overrides the ironsights holdtype, choosing it instead of something from the above tables. Change it to "" to disable.
SWEP.SprintHoldTypeOverride = "" -- This variable overrides the sprint holdtype, choosing it instead of something from the above tables. Change it to "" to disable.
-- [[ANIMATION]] --
SWEP.StatusLengthOverride = {} -- Changes the status delay of a given animation; only used on reloads. Otherwise, use SequenceLengthOverride or one of the others
SWEP.SequenceLengthOverride = {} -- Changes both the status delay and the nextprimaryfire of a given animation
SWEP.SequenceTimeOverride = {} -- Like above but changes animation length to a target
SWEP.SequenceRateOverride = {} -- Like above but scales animation length rather than being absolute
SWEP.ProceduralHolsterEnabled = nil
SWEP.ProceduralHolsterTime = 0.3
SWEP.ProceduralHolsterPos = Vector(3, 0, -5)
SWEP.ProceduralHolsterAng = Vector(-40, -30, 10)
SWEP.Idle_Mode = TFA.Enum.IDLE_BOTH -- TFA.Enum.IDLE_DISABLED = no idle, TFA.Enum.IDLE_LUA = lua idle, TFA.Enum.IDLE_ANI = mdl idle, TFA.Enum.IDLE_BOTH = TFA.Enum.IDLE_ANI + TFA.Enum.IDLE_LUA
SWEP.Idle_Blend = 0.25 -- Start an idle this far early into the end of a transition
SWEP.Idle_Smooth = 0.05 -- Start an idle this far early into the end of another animation
-- MDL Animations Below
SWEP.Sights_Mode = TFA.Enum.LOCOMOTION_LUA -- LOCOMOTION_ANI = mdl, LOCOMOTION_HYBRID = ani + lua, LOCOMOTION_LUA = lua only
--[[
SWEP.IronAnimation = {
["in"] = {
["type"] = TFA.Enum.ANIMATION_SEQ, -- Sequence or act
["value"] = "Idle_To_Iron", -- Number for act, String/Number for sequence
["value_empty"] = "Idle_To_Iron_Dry",
["transition"] = true
}, -- Inward transition
["loop"] = {
["type"] = TFA.Enum.ANIMATION_SEQ, -- Sequence or act
["value"] = "Idle_Iron", -- Number for act, String/Number for sequence
["value_empty"] = "Idle_Iron_Dry"
}, -- Looping Animation
["out"] = {
["type"] = TFA.Enum.ANIMATION_SEQ, -- Sequence or act
["value"] = "Iron_To_Idle", -- Number for act, String/Number for sequence
["value_empty"] = "Iron_To_Idle_Dry",
["transition"] = true
}, -- Outward transition
["shoot"] = {
["type"] = TFA.Enum.ANIMATION_SEQ, -- Sequence or act
["value"] = "Fire_Iron", -- Number for act, String/Number for sequence
["value_last"] = "Fire_Iron_Last",
["value_empty"] = "Fire_Iron_Dry"
} -- What do you think
}
]]
SWEP.Sprint_Mode = TFA.Enum.LOCOMOTION_LUA -- LOCOMOTION_ANI = mdl, LOCOMOTION_HYBRID = ani + lua, LOCOMOTION_LUA = lua only
--[[
SWEP.SprintAnimation = {
["in"] = {
["type"] = TFA.Enum.ANIMATION_SEQ, -- Sequence or act
["value"] = "Idle_to_Sprint", -- Number for act, String/Number for sequence
["value_empty"] = "Idle_to_Sprint_Empty",
["transition"] = true
}, -- Inward transition
["loop"] = {
["type"] = TFA.Enum.ANIMATION_SEQ, -- Sequence or act
["value"] = "Sprint_", -- Number for act, String/Number for sequence
["value_empty"] = "Sprint_Empty_",
["is_idle"] = true
}, -- looping animation
["out"] = {
["type"] = TFA.Enum.ANIMATION_SEQ, -- Sequence or act
["value"] = "Sprint_to_Idle", -- Number for act, String/Number for sequence
["value_empty"] = "Sprint_to_Idle_Empty",
["transition"] = true
} -- Outward transition
}
]]
SWEP.Walk_Mode = TFA.Enum.LOCOMOTION_LUA -- LOCOMOTION_ANI = mdl, LOCOMOTION_HYBRID = ani + lua, LOCOMOTION_LUA = lua only
--[[
SWEP.WalkAnimation = {
["in"] = {
["type"] = TFA.Enum.ANIMATION_SEQ, -- Sequence or act
["value"] = "Idle_to_Walk", -- Number for act, String/Number for sequence
["value_empty"] = "Idle_to_Walk_Empty",
["transition"] = true
}, -- Inward transition
["loop"] = {
["type"] = TFA.Enum.ANIMATION_SEQ, -- Sequence or act
["value"] = "Walk", -- Number for act, String/Number for sequence
["value_empty"] = "Walk_Empty",
["is_idle"] = true
}, -- looping animation
["out"] = {
["type"] = TFA.Enum.ANIMATION_SEQ, -- Sequence or act
["value"] = "Walk_to_Idle", -- Number for act, String/Number for sequence
["value_empty"] = "Walk_to_Idle_Empty",
["transition"] = true
} -- Outward transition
}
]]
--[[
-- Looping fire animation (full-auto only)
SWEP.ShootAnimation = {
["in"] = {
["type"] = TFA.Enum.ANIMATION_SEQ, -- Sequence or act
["value"] = "ShootLoop_Start", -- Number for act, String/Number for sequence
["value_is"] = "ShootLoop_Iron_Start", -- Number for act, String/Number for sequence
["transition"] = true
}, -- Looping Start, fallbacks to loop
["loop"] = {
["type"] = TFA.Enum.ANIMATION_SEQ, -- Sequence or act
["value"] = "ShootLoop", -- Number for act, String/Number for sequence,
["value_is"] = "ShootLoop_Iron", -- Number for act, String/Number for sequence,
["is_idle"] = true,
}, -- Looping Animation
["out"] = {
["type"] = TFA.Enum.ANIMATION_SEQ, -- Sequence or act
["value"] = "ShootLoop_End", -- Number for act, String/Number for sequence
["value_is"] = "ShootLoop_Iron_End", -- Number for act, String/Number for sequence
["transition"] = true
}, -- Looping End
}
]]
SWEP.Customize_Mode = TFA.Enum.LOCOMOTION_LUA -- LOCOMOTION_ANI = mdl, LOCOMOTION_HYBRID = ani + lua, LOCOMOTION_LUA = lua only
--[[
SWEP.CustomizeAnimation = {
["in"] = {
["type"] = TFA.Enum.ANIMATION_SEQ, -- Sequence or act
["value"] = "customization_in", -- Number for act, String/Number for sequence
["transition"] = true
},
["loop"] = {
["type"] = TFA.Enum.ANIMATION_SEQ, -- Sequence or act
["value"] = "customization_idle", -- Number for act, String/Number for sequence
["is_idle"] = true
},
["out"] = {
["type"] = TFA.Enum.ANIMATION_SEQ, -- Sequence or act
["value"] = "customization_out", -- Number for act, String/Number for sequence
["transition"] = true
}
}
]]
--[[
SWEP.PumpAction = { -- Pump/bolt animations
["type"] = TFA.Enum.ANIMATION_ACT, -- Sequence or act
["value"] = ACT_VM_PULLBACK_HIGH, -- Number for act, String/Number for sequence
["value_empty"] = ACT_VM_PULLBACK, -- Last shot pump
["value_is"] = ACT_VM_PULLBACK_LOW, -- ADS pump
}
]] --
-- [[EFFECTS]] --
-- Attachments
SWEP.MuzzleAttachment = "1" -- Should be "1" for CSS models or "muzzle" for hl2 models
SWEP.ShellAttachment = "2" -- Should be "2" for CSS models or "shell" for hl2 models
SWEP.MuzzleFlashEnabled = true -- Enable muzzle flash
SWEP.MuzzleAttachmentRaw = nil -- This will override whatever string you gave. This is the raw attachment number. This is overridden or created when a gun makes a muzzle event.
SWEP.AutoDetectMuzzleAttachment = false -- For multi-barrel weapons, detect the proper attachment?
SWEP.MuzzleFlashEffect = nil -- Change to a string of your muzzle flash effect. Copy/paste one of the existing from the base.
SWEP.SmokeParticle = nil -- Smoke particle (ID within the PCF), defaults to something else based on holdtype; "" to disable
SWEP.EjectionSmokeEnabled = true -- Disable automatic ejection smoke
-- Shell eject override
SWEP.LuaShellEject = false -- Enable shell ejection through lua?
SWEP.LuaShellEjectDelay = 0 -- The delay to actually eject things
SWEP.LuaShellModel = nil -- The model to use for ejected shells
SWEP.LuaShellScale = nil -- The model scale to use for ejected shells
SWEP.LuaShellYaw = nil -- The model yaw rotation ( relative ) to use for ejected shells
-- Tracer Stuff
SWEP.TracerName = nil -- Change to a string of your tracer name. Can be custom. There is a nice example at https://github.com/garrynewman/garrysmod/blob/master/garrysmod/gamemodes/base/entities/effects/tooltracer.lua
SWEP.TracerCount = 3 -- 0 disables, otherwise, 1 in X chance
-- Impact Effects
SWEP.ImpactEffect = nil -- Impact Effect
SWEP.ImpactDecal = nil -- Impact Decal
-- [[EVENT TABLE]] --
SWEP.EventTable = {} -- Event Table, used for custom events when an action is played. This can even do stuff like playing a pump animation after shooting.
-- example:
-- SWEP.EventTable = {
-- [ACT_VM_RELOAD] = {
-- -- ifp is IsFirstTimePredicted()
-- { ["time"] = 0.1, ["type"] = "lua", ["value"] = function( wep, viewmodel, ifp ) end, ["client"] = true, ["server"] = true},
-- { ["time"] = 0.1, ["type"] = "sound", ["value"] = Sound("x") }
-- }
-- }
-- [[RENDER TARGET]] --
SWEP.RTMaterialOverride = nil -- Take the material you want out of print(LocalPlayer():GetViewModel():GetMaterials()), subtract 1 from its index, and set it to this.
SWEP.RTOpaque = false -- Do you want your render target to be opaque?
SWEP.RTCode = nil -- function(self) return end -- This is the function to draw onto your rendertarget
SWEP.RTBGBlur = true -- Draw background blur when 3D scope is active?
-- [[AKIMBO]] --
SWEP.Akimbo = false -- Akimbo gun? Alternates between primary and secondary attacks.
SWEP.AnimCycle = 1 -- Start on the right
SWEP.AkimboHUD = true -- Draw holographic HUD for both weapons?
-- [[ATTACHMENTS]] --
SWEP.VElements = nil -- Export from SWEP Creation Kit. For each item that can/will be toggled, set active=false in its individual table
SWEP.WElements = nil -- Export from SWEP Creation Kit. For each item that can/will be toggled, set active=false in its individual table
SWEP.Attachments = {
-- [ORDER] = = { atts = { "si_eotech" }, sel = 0 }
-- sel allows you to have an attachment pre-selected, and is used internally by the base to show which attachment is selected in each category.
}
SWEP.AttachmentDependencies = {} -- {["si_acog"] = {"bg_rail", ["type"] = "OR"}} -- type could also be AND to require multiple
SWEP.AttachmentExclusions = {} -- { ["si_iron"] = { [1] = "bg_heatshield"} }
SWEP.AttachmentTableOverride = {} --[[{ -- overrides WeaponTable for attachments
["ins2_ub_laser"] = { -- attachment id, root of WeaponTable override
["VElements"] = {
["laser_rail"] = {
["active"] = true
},
},
}
}]]
SWEP.DInv2_GridSizeX = nil -- DInventory/2 Specific. Determines weapon's width in grid. This is not TFA Base specific and can be specified to any Scripted SWEP.
SWEP.DInv2_GridSizeY = nil -- DInventory/2 Specific. Determines weapon's height in grid. This is not TFA Base specific and can be specified to any Scripted SWEP.
SWEP.DInv2_Volume = nil -- DInventory/2 Specific. Determines weapon's volume in liters. This is not TFA Base specific and can be specified to any Scripted SWEP.
SWEP.DInv2_Mass = nil -- DInventory/2 Specific. Determines weapon's mass in kilograms. This is not TFA Base specific and can be specified to any Scripted SWEP.
-- [[MISC INFO FOR MODELERS]] --
--[[
Used Animations (for modelers):
ACT_VM_DRAW - Draw
ACT_VM_DRAW_EMPTY - Draw empty
ACT_VM_DRAW_SILENCED - Draw silenced, overrides empty
ACT_VM_IDLE - Idle
ACT_VM_IDLE_SILENCED - Idle empty, overwritten by silenced
ACT_VM_IDLE_SILENCED - Idle silenced
ACT_VM_PRIMARYATTACK - Shoot
ACT_VM_PRIMARYATTACK_EMPTY - Shoot last chambered bullet
ACT_VM_PRIMARYATTACK_SILENCED - Shoot silenced, overrides empty
ACT_VM_PRIMARYATTACK_1 - Shoot ironsights, overriden by everything besides normal shooting
ACT_VM_DRYFIRE - Dryfire
ACT_VM_RELOAD - Reload / Tactical Reload / Insert Shotgun Shell
ACT_SHOTGUN_RELOAD_START - Start shotgun reload, unless ACT_VM_RELOAD_EMPTY is there.
ACT_SHOTGUN_RELOAD_FINISH - End shotgun reload.
ACT_VM_RELOAD_EMPTY - Empty mag reload, chambers the new round. Works for shotguns too, where applicable.
ACT_VM_RELOAD_SILENCED - Silenced reload, overwrites all
ACT_VM_HOLSTER - Holster
ACT_VM_HOLSTER_SILENCED - Holster empty, overwritten by silenced
ACT_VM_HOLSTER_SILENCED - Holster silenced
]] --
DEFINE_BASECLASS( SWEP.Base )
-- TFA Base Melee Template by TFA Base Devs
-- To the extent possible under law, the person who associated CC0 with
-- TFA Base Template has waived all copyright and related or neighboring rights
-- to TFA Base Template.
-- You should have received a copy of the CC0 legalcode along with this
-- work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
-- M9K compatible version is dated as 0 (and 0 is also fallback if TFADataVersion not present)
-- as well as everything made for TFA Base before 4.7
SWEP.TFADataVersion = 1
----------------- Basic Garry's Mod SWEP structure stats / TFA Base properties
SWEP.Base = "tfa_melee_base"
SWEP.Category = "TFA Template" -- The category.
-- Please, just choose something generic or something I've already done if you plan on only doing like one (or two or three) swep(s).
SWEP.Manufacturer = nil -- Gun Manufactrer (e.g. Hoeckler and Koch)
SWEP.Author = "" -- Author Tooltip
SWEP.Contact = "" -- Contact Info Tooltip
SWEP.Purpose = "" -- Purpose Tooltip
SWEP.Instructions = "" -- Instructions Tooltip
SWEP.Spawnable = false -- Can you, as a normal user, spawn this?
SWEP.AdminSpawnable = false -- Can an adminstrator spawn this? Does not tie into your admin mod necessarily, unless its coded to allow for GMod's default ranks somewhere in its code. Evolve and ULX should work, but try to use weapon restriction rather than these.
SWEP.DrawCrosshair = true -- Draw the crosshair?
SWEP.PrintName = "TFA Base Melee Template" -- Weapon name (Shown on HUD)
SWEP.Slot = 0 -- Slot in the weapon selection menu. Subtract 1, as this starts at 0.
SWEP.SlotPos = 73 -- Position in the slot
SWEP.AutoSwitchTo = true -- Auto switch to if we pick it up
SWEP.AutoSwitchFrom = true -- Auto switch from if you pick up a better weapon
SWEP.Weight = 30 -- This controls how "good" the weapon is for autopickup.
-- For base values please refer to the base template at lua/weapons/tfa_base_template/shared.lua
-- Display values (inspection screen etc.)
SWEP.Primary.Damage = 0.01 -- Damage, in standard damage points.
SWEP.Primary.RPM = 600 -- This is in Rounds Per Minute / RPM
----------------- ViewModel related
SWEP.ViewModel = "models/your/path/here.mdl" -- Viewmodel path
SWEP.ViewModelFOV = 65 -- This controls how big the viewmodel looks. Less is more.
SWEP.ViewModelFlip = false -- Set this to true for CSS models, or false for everything else (with a righthanded viewmodel.)
SWEP.UseHands = false -- Use gmod c_arms system.
----------------- Worldmodel related
SWEP.WorldModel = "models/your/wmodel/path/here.mdl" -- Weapon world model path
SWEP.HoldType = "" -- This is how others view you carrying the weapon. Options include:
-- normal melee melee2 fist knife smg ar2 pistol rpg physgun grenade shotgun crossbow slam passive
-- Attacks - Primary
SWEP.Primary.Attacks = { -- main attacks table, the values are selected randomly
{
["act"] = ACT_VM_HITLEFT, -- Animation acvitity to use (ACT_ enum value)
["len"] = 8 * 4.5, -- Trace distance
["src"] = Vector(20, 10, 0), -- Trace source; X ( +right, -left ), Y ( +forward, -back ), Z ( +up, -down )
["dir"] = Vector(-40, 30, 0), -- Trace direction/length; X ( +right, -left ), Y ( +forward, -back ), Z ( +up, -down )
["dmg"] = 60, -- Damage
["dmgtype"] = DMG_SLASH, -- Damage type (DMG_ enum value)
["delay"] = 0.2, -- Delay (in seconds) before attack trace
["force"] = 12, -- Damage force
["hull"] = 10, -- Trace hull size
["spr"] = true, -- Allow attack while sprinting?
["snd"] = "Swing.Sound", -- Soundscript name for swing sound
["hitflesh"] = "TFA.BashFlesh", -- Soundscript name for flesh hit
["hitworld"] = "TFA.BashWall", -- Soundscript name for non-flesh hit
["snd_delay"] = 0.1, -- Delay before swing sound
["viewpunch"] = Angle(1, -10, 0), -- Viewpunch angle
["end"] = 0.5, -- Time (from attack start) until next attack is allowed
["direction"] = "L", -- Swing direction (for directional preference); L,R,F,B
},
}
SWEP.Primary.MaxCombo = -1 -- How many attacks are allowed on single attack key hold
SWEP.Primary.Directional = false -- Prefer attacks with player's movement direction first
-- Attacks - Secondary
-- If secondary attacks table is empty or not defined, it falls back to primary table
SWEP.Secondary.Attacks = {} -- same as SWEP.Primary.Attacks
SWEP.Secondary.MaxCombo = -1
SWEP.Secondary.Directional = false
-- Attacks - Alternative (melee bash)
SWEP.Secondary.CanBash = true -- set to false to disable bashing
SWEP.Secondary.BashDamage = 25 -- Melee bash damage
SWEP.Secondary.BashSound = "TFA.Bash" -- Soundscript name for bash swing sound
SWEP.Secondary.BashHitSound = "TFA.BashWall" -- Soundscript name for non-flesh hit sound
SWEP.Secondary.BashHitSound_Flesh = "TFA.BashFlesh" -- Soundscript name for flesh hit sound
SWEP.Secondary.BashLength = 54 -- Length of bash melee trace in units
SWEP.Secondary.BashDelay = 0.2 -- Delay (in seconds) from bash start to bash attack trace
SWEP.Secondary.BashDamageType = DMG_SLASH -- Damage type (DMG_ enum value)
SWEP.Secondary.BashEnd = nil -- Bash end time (in seconds), defaults to animation end if undefined
SWEP.Secondary.BashInterrupt = false -- Bash attack interrupts everything (reload, draw, whatever)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment