Working on a TTT Customizable Weaponry Convertion - Final Steps!
1 replies, posted
As the Title says...
(this convertion is to exclusively to personal use... I will only release this if authorized by the creator)
Everything is working fine! You can customize your weapons pretty much as expected.
But there is only a little thing that is not working yet, the reticle render system (example: red dot on attachments).
Those aim related attachments just appear empty with no aim reticle at all... All I know is that it is related to the particleprecache.lua lucated in lua/autorun:
[CODE]game.AddParticles("particles/cstm_muzzleflashes.pcf")
game.AddParticles("particles/cstm_muzzleflashes2.pcf")
PrecacheParticleSystem("cstm_child_sparks_small")
PrecacheParticleSystem("cstm_child_sparks_medium")
PrecacheParticleSystem("cstm_child_sparks_large")
PrecacheParticleSystem("cstm_child_sparks_verylarge")
PrecacheParticleSystem("cstm_child_smoke_small")
PrecacheParticleSystem("cstm_child_smoke_medium")
PrecacheParticleSystem("cstm_child_smoke_large")
PrecacheParticleSystem("cstm_child_smoke_verylarge")
PrecacheParticleSystem("cstm_child_muzzle_small")
PrecacheParticleSystem("cstm_child_muzzle_medium")
PrecacheParticleSystem("cstm_child_muzzle_large")
PrecacheParticleSystem("cstm_child_heat")
PrecacheParticleSystem("cstm_muzzle_pistol")
PrecacheParticleSystem("cstm_muzzle_smg")
PrecacheParticleSystem("cstm_muzzle_ar")
PrecacheParticleSystem("cstm_muzzle_br")
PrecacheParticleSystem("cstm_incendiary_hit")
PrecacheParticleSystem("cstm_frag_fly")
PrecacheParticleSystem("cstm_frag_expl")
local pmodel = util.PrecacheModel
pmodel("models/attachments/kascope.mdl")
pmodel("models/attachments/cmore.mdl")
pmodel("models/bunneh/scope01.mdl")
pmodel("models/wystan/cmag.mdl")
pmodel("models/wystan/2cog.mdl")
pmodel("models/wystan/2octorrds.mdl")
pmodel("models/wystan/2otech557sight.mdl")
pmodel("models/wystan/aimpoint.mdl")
pmodel("models/wystan/akrailmount.mdl")
pmodel("models/wystan/bipod.mdl")
pmodel("models/wystan/foregrip1.mdl")
pmodel("models/wystan/m203.mdl")
pmodel("models/wystan/rail.mdl")
pmodel("models/props_c17/oildrum001.mdl")
pmodel("models/props_c17/FurnitureBoiler001a.mdl")
/*timer.Simple(3, function()
for k, v in pairs(weapons.GetList()) do
if v.ThisClass and v.ThisClass:find("cstm_") then
if v.ViewModel then
pmodel(v.ViewModel)
end
end
end
end)*/
FS = {}
FS["CSTM_SilencedShot"] = "weapons/m4a1/m4a1-1.wav"
local tbl = {channel = CHAN_WEAPON,
volume = 1,
soundlevel = 120,
pitchstart = 100,
pitchend = 100}
for k, v in pairs(FS) do
tbl.name = k
tbl.sound = v
sound.Add(tbl)
end
AttEnum = {
["acog"] = 2,
["aimpoint"] = 3,
["eotech"] = 4,
["kobra"] = 5,
["grenadelauncher"] = 6,
["vertgrip"] = 7,
["cmag"] = 8,
["reflex"] = 9,
["laser"] = 10,
["bipod"] = 11,
["riflereflex"] = 12,
["ballistic"] = 13,
["elcan"] = 14}
CWAttachments = {}
CWAttachmentsMeta = {}
CWInternalParts = {}
CWInternalPartsMeta = {}
local clip, ammo, x, y, old, FT, ply, Lens
local BlackAmt, CamData, Ini = 1, {}, true
if CLIENT then
Lens = surface.GetTextureID("models/wystan/attachments/acog/lense2")
end
--[[
The following function allows you to register a weapon attachment for use with Customizable Weaponry weapons.
The first argument (key) should be a string. This argument has to be what you're going to call the attachment's VElement and WElement name.
The second argument (name) should be a string. The name should NOT match any other attachment names.
The third argument (num) should be the attachment's number. This number should NOT match any other attachment numbers.
The fourth argument (displaytexture) should be the attachment's texture it's going to use in the customization menu. It needs to be set on the client.
The fifth argument (scope) should be a table. If it's going to be a scope attachment - here is where shit gets tricky; if it's not going to be a scope - set it to false or nil.
== == == == == == == == == == == ==
The first variable within the scope table you're going to set is the aiming texture, this variable is called mat.
The second variable is going to be the size of the texture, this variable is called size. The size should lower as texture resolution rises.
So if you are going to draw a 64x64 texture, set size to 0.1, if you're going to draw a 128x128 texture, set size to 0.05, if you're going to draw a 256x256 texture, set size to 0.025 and so on.
Regardless, you should still pick the size you think looks best.
The third variable is going to be a string, this variable is called dist. This variable is going to tell the difference between his aiming position and the reticle that you can set on a SWEP.
So if you set it to "MyAttachmentDist", then in the SWEP's lua file you'll have to set SWEP.MyAttachmentDist to a number.
This is primarily used for render target scopes when the texture clips with the model, making it invisible/partially visible.
The fourth variable is going to be a number, this variable is called distno.
This variable will be used the same way as the variable 'dist', but it'll be used when the weapon's 'dist' variable is not defined.
The fifth variable is going to be a string, this variable is called pos. This variable is needed if the attachment you're going to add has back-up sights.
The variable should be named after the aiming position.
This prevents the code from drawing the aiming reticle when you're using the sight's back-up sights.
The sixth variable is going to be a boolean, this boolean is called aimmove. If you set it to true, then the aiming reticle will move along with the weapon when you take aim and move your mouse around.
The seventh variable is going to be how much we're going to zoom in when taking aim, this variable is called fovmod.
Usually for reflex sights I use 15.
(OPTIONAL) The eighth variable is going to be the rendering function, and it should be called renderfunc. This can be used if you're going to make a render target based scope. (in other words, a scope that magnifies)
== == == == == == == == == == == ==
The sixth argument (incompability) should be a table. This table has to contain the attachments it's not compatible with, AKA attachments it should hide when attaching this attachment.
The seventh argument (description) should be a table. This table will contain the attachment's description when opening the customization menu and attaching it to a weapon.
The eighth argument (attfunc) is going to be a function. This function will be called when you attach the attachment to a weapon. So if you need to modify the weapon's stats - use this function.
The ninth argument (deattfunc) is going to be a function. This function will be called when you detach the attachmen from a weapon. So if you need to revert a weapon's stats to what it was - use this function.
The tenth argument (modelattfunc) is going to be a function. This function will be called on the CLIENT when you attach the attachment.
This function will tell the client what to do with other models when attaching the attachment. You can also use this function to update certain variables without having to network additional stuff.
The argument you're going to provide it with is the weapon entity.
]]--
AutoAtt, AutoPart = {}, {}
function CSTM_AddAttachment(tbl) //name, num, scope, incompability, description, svattfunc, svdeattfunc, clattfunc, cldeattfunc)
CWAttachments[tbl.key] = {key = tbl.key, name = tbl.name, num = tbl.num, displaytexture = tbl.displaytexture, scope = tbl.scope, incompability = tbl.incompability, description = tbl.description, canattach = tbl.canattach, svattfunc = tbl.svattfunc, svdeattfunc = tbl.svdeattfunc, clattfunc = tbl.clattfunc, cldeattfunc = tbl.cldeattfunc}
CWAttachmentsMeta[tbl.num] = tbl.key
if SERVER then
CreateConVar("cstm_att_" .. tbl.key, "0", {FCVAR_REPLICATED, FCVAR_ARCHIVE, FCVAR_NOTIFY})
AutoAtt["cstm_att_" .. tbl.key] = tbl.key
else
CreateClientConVar("cstm_att_" .. tbl.key .. "_cl", "0", true, true)
end
end
----
-- WEAPON ATTACHMENTS
----
local NA = {}
NA.key = "reflex"
NA
I'm doing the same thing but I'm having the same issue, not sure why TTT is being weird. There's not even a lua error to point me int he right direction. I'm going to try printing some things to console in the code while this is running and see what is and isn't running compared between sandbox and ttt, in the meantime what I've done is if the player has a sight and they're aiming down the sights it unhides the cross hair.
Sorry, you need to Log In to post a reply to this thread.