Garry's Mod

Garry's Mod

Not enough ratings
TFA Weapons Server Configuration for TTT
By Karate Walrus
*** About ***
This is the edited tfa_tttpatch.lua I use so that tfa weapons work well with the ttt gamemode.

*** Installation ***
You need to create and place the tfa_tttpatch.lua into the garrysmod\addons\tfa_base_reduxed\lua\tfa\modules\ directory. You will probably have to create that directory. Alternatively, you can download this, extract it, and place it on the server's addons folder: https://my.pcloud.com/publink/show?code=XZm22TkZgxuRsL3G4oznWSOAH7wu8SHmRkTX

*** Changes ***
Added shop compatibility for the survivalist, mercenary, hypnotist, vampire, assassin, killer, and zombie.
Enabled Sprinting Animations
Changed menu key to the letter L
Disabled Attachments
Enabled Ballistics and at 90% bullet speed (because ttt maps aren't really that big)
Added a popup text when people join the server to give them instructions on the tfa menu key and f1 keys
Disabled Blur when aiming down sights.
   
Award
Favorite
Favorited
Unfavorite
tfa_tttpatch.lua
-- Copyright (c) 2018 TFA Base Devs

-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:

-- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software.

-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.

if SERVER then
AddCSLuaFile()
end
-- luacheck: globals WEAPON_NONE WEAPON_MELEE WEAPON_PISTOL WEAPON_HEAVY WEAPON_NADE WEAPON_CARRY WEAPON_EQUIP1 WEAPON_EQUIP2 WEAPON_ROLE WEAPON_EQUIP WEAPON_UNARMED ROLE_INNOCENT ROLE_TRAITOR ROLE_DETECTIVE ROLE_NONE
WEAPON_NONE = WEAPON_NONE or 0
WEAPON_MELEE = WEAPON_MELEE or 1
WEAPON_PISTOL = WEAPON_PISTOL or 2
WEAPON_HEAVY = WEAPON_HEAVY or 3
WEAPON_NADE = WEAPON_NADE or 4
WEAPON_CARRY = WEAPON_CARRY or 5
WEAPON_EQUIP1 = WEAPON_EQUIP1 or 6
WEAPON_EQUIP2 = WEAPON_EQUIP2 or 7
WEAPON_ROLE = WEAPON_ROLE or 8
WEAPON_EQUIP = WEAPON_EQUIP or WEAPON_EQUIP1
WEAPON_UNARMED = WEAPON_UNARMED or -1
ROLE_INNOCENT = ROLE_INNOCENT or 0
ROLE_TRAITOR = ROLE_TRAITOR or 1
ROLE_DETECTIVE = ROLE_DETECTIVE or 2
ROLE_NONE = ROLE_NONE or ROLE_INNOCENT

local KindTable = {
[0] = WEAPON_MELEE,
[1] = WEAPON_PISTOL,
[2] = WEAPON_HEAVY,
[3] = WEAPON_HEAVY,
[4] = WEAPON_HEAVY,
[5] = WEAPON_EQUIP1,
[6] = WEAPON_EQUIP2
}

local TypeStrings = {
[WEAPON_NONE] = "Invalid",
[WEAPON_MELEE] = "Melee",
[WEAPON_PISTOL] = "Pistol",
[WEAPON_HEAVY] = "Heavy",
[WEAPON_NADE] = "Grenade",
[WEAPON_CARRY] = "Carry",
[WEAPON_CARRY] = "Equipment",
[WEAPON_EQUIP2] = "Equipment",
[WEAPON_ROLE] = "Role"
}

local function PatchWep(wep)
local tbl = weapons.GetStored(wep)
if not tbl then return end
if not tbl.Base then return end
if (not tbl.ISTFAWeapon) and (not string.find(tbl.Base, "tfa")) and (not string.find(tbl.Category or "", "TFA")) then return end

if (not tbl.Kind) or (not isnumber(tbl.Kind)) then
tbl.Kind = KindTable[tbl.Slot or 2] or WEAPON_HEAVY

if (tbl.ProjectileVelocity and tbl.ProjectileVelocity < 1000 and tbl.ProjectileVelocity > 0) or string.find(tbl.Base or "", "nade") then
tbl.Kind = WEAPON_NADE
end

if not tbl.Spawnable then
tbl.Kind = WEAPON_NONE
end
end

--if not tbl.Icon then
-- tbl.Icon = nil--"vgui/entities/" .. wep
--end
tbl.model = tbl.model or tbl.WorldModel

if not tbl.CanBuy then
--if tbl.Spawnable then
-- tbl.CanBuy = { ROLE_TRAITOR, ROLE_DETECTIVE }
--else
tbl.CanBuy = {}
--end
end

for _, v in pairs(tbl.CanBuy) do
--KarateWalrus added shop compatibility for additional roles for tfa weapons
if v ~= ROLE_TRAITOR and v ~= ROLE_DETECTIVE and v ~= ROLE_SURVIVALIST and v ~= ROLE_MERCENARY and v ~= ROLE_HYPNOTIST and v ~= ROLE_VAMPIRE and v ~= ROLE_ASSASSIN and v ~= ROLE_KILLER and v ~= ROLE_ZOMBIE then
table.RemoveByValue(tbl.CanBuy, v)
end
end

if (not tbl.Icon) or (string.len(tbl.Icon) <= 0) then
tbl.Icon = nil
if file.Exists("materials/entities/" .. wep .. ".png", "GAME") then
tbl.Icon = "entities/" .. wep .. ".png"
elseif file.Exists("materials/vgui/entities/" .. wep .. ".vmt", "GAME") then
tbl.Icon = "vgui/entities/" .. wep
end
end

if tbl.LimitedStock == nil then
tbl.LimitedStock = false
end

if not tbl.EquipMenuData then
tbl.EquipMenuData = {
["type"] = TypeStrings[tbl.Kind],
["desc"] = tbl.PrintName or wep
}
end

if tbl.IsSilent == nil then
tbl.IsSilent = false
end

if tbl.NoSights == nil then
if tbl.data then
tbl.NoSights = tbl.data.ironsights ~= 0
end

if tbl.NoSights == nil then
tbl.NoSights = false
end
end

if tbl.AutoSpawnable == nil then
tbl.AutoSpawnable = tbl.Spawnable
end
end

local function Patch()
if engine.ActiveGamemode() == "terrortown" then
for _, v in pairs(weapons.GetList()) do
local wep = v.ClassName

if wep then
PatchWep(wep)
end
end

if SERVER then
RunConsoleCommand("sv_tfa_sprint_enabled", "1")
--Enables sprint animations if you use a sprint addon
RunConsoleCommand("sv_tfa_cmenu_key", "22")
--Changed menu key to lowercase L rather than c because c is already used in ttt
RunConsoleCommand("sv_tfa_attachments_enabled", "0")
--Disabled attachments for any tfa weapons that have them as certain weapon configs I wanted the same for all players
RunConsoleCommand("sv_tfa_ballistics_enabled", "1")
RunConsoleCommand("sv_tfa_ballistics_bullet_velocity", "0.90")
--Bullet ballistics enabled so longer snipes are harder against moving targets. .90 seemed pretty good for bullet speed.
--RunConsoleCommand("sv_tfa_default_clip", "2") Still gives ammo upon pickup of a weapon each time its dropped and picked up again.
end
if CLIENT then
local ply = LocalPlayer()
ply:PrintMessage( HUD_PRINTTALK, "The letter l key let's you view weapon stats. F1 -> TFA Settings tab let's you adjust weapon visuals and functions." )
LocalPlayer():ConCommand("cl_tfa_fx_rtscopeblur_mode 0")
end
end
end

if SERVER then
hook.Add("InitPostEntity", "TFAPatchTTT", Patch)
end
if CLIENT then
hook.Add("HUDPaint", "TFAPatchTTT", function()
if LocalPlayer():IsValid() then
Patch()
hook.Remove("HUDPaint","TFAPatchTTT")
end
end)
end