-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtfa_attachment_template.lua
95 lines (76 loc) · 3.36 KB
/
tfa_attachment_template.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
-- 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
]]--
--[[
-- Called before stencil sight reticle is drawn
function ATTACHMENT:PreDrawStencilSight(wep, vm, ply, sightVElementTable)
-- 3D rendering context from PostDrawViewModel
-- https://wiki.facepunch.com/gmod/3D_Rendering_Functions
-- return true -- to prevent SWEP:PreDrawStencilSight from being called
-- return false -- to stop reticle from drawing
end
]]--
--[[
-- Called right after stencil sight reticle is drawn
function ATTACHMENT:PostDrawStencilSight(wep, vm, ply, sightVElementTable)
-- 3D rendering context from PostDrawViewModel
-- https://wiki.facepunch.com/gmod/3D_Rendering_Functions
-- return true -- to prevent SWEP:PostDrawStencilSight from being called
end
]]--
if not TFA_ATTACHMENT_ISUPDATING then
TFAUpdateAttachments()
end