Closed luttje closed 3 months ago
For reference: I used this script to quickly generate items for all weapons in TacRP
local allWeapons = weapons.GetList()
function getCategoryFromSubCatType(subCatType)
if (subCatType == "4Assault Rifle") then
return "primary"
elseif (subCatType == "9Anti-Materiel Rifle") then
return "primary"
elseif (subCatType == "5Sporter Carbine") then
return "primary"
elseif (subCatType == "4Machine Gun") then
return "primary"
elseif (subCatType == "5Shotgun") then
return "primary"
elseif (subCatType == "6Precision Rifle") then
return "primary"
elseif (subCatType == "7Sniper Rifle") then
return "primary"
elseif (subCatType == "3Submachine Gun") then
return "primary"
elseif (subCatType == "1Sidearm") then
return "sidearm"
elseif (subCatType == "2Machine Pistol") then
return "sidearm"
end
return nil -- ignore throwables and equipments for now
end
file.CreateDir("experiment-redux-generated/items")
-- Generate the items to the data folder
for _, weapon in ipairs(allWeapons) do
if (weapons.IsBasedOn(weapon.ClassName, "tacrp_base")) then
local category = getCategoryFromSubCatType(weapon.SubCatType)
if (category == nil) then
continue
end
if (not weapon.Trivia_Caliber) then
weapon.Trivia_Caliber = "5.56x45mm" -- tacrp_ar15 and tacrp_civ_g36k
ErrorNoHalt("Weapon " .. weapon.ClassName .. " does not have a Trivia_Caliber field. Using 5.56x45mm for it.\n")
end
local script = [[local ITEM = ITEM
ITEM.name = "]] .. weapon.PrintName .. [["
ITEM.description = "]] .. weapon.Description:Replace("\n", "\\n") .. [["
ITEM.price = 8100 -- TODO: Set this value
ITEM.class = "]] .. weapon.ClassName .. [["
ITEM.weaponCategory = "]] .. category .. [["
ITEM.model = "]] .. weapon.WorldModel .. [["
ITEM.width = ]] .. (category == "primary" and 3 or 2) .. [[
ITEM.height = ]] .. (category == "primary" and 2 or 2) .. [[
ITEM.forcedWeaponCalibre = "]] .. weapon.Trivia_Caliber .. [["
]]
local fileName = weapon.ClassName:Replace("tacrp_", "sh_") .. ".lua.txt"
local path = "experiment-redux-generated/items/" .. fileName
file.Write(path, script)
end
end
garrysmod/lua
folder as generate_experiment.lua
lua_openscript generate_experiment.lua
Now use the following command inside the experiment-redux-generated/items/
folder to rename the files to lua files:
Linux shell:
find . -type f -name "*.lua.txt" -exec sh -c 'mv "$1" "${1%.txt}"' _ {} \;
Windows Powershell:
Get-ChildItem -Path . -Filter "*.lua.txt" | Rename-Item -NewName { $_.Name -replace '\.txt$' }
experiment-redux/plugins/customizable_weaponry/items/customizable_weaponry
This issue isn't finished yet, we still have to:
* [x] Add ammo for all calibres * [ ] Change and balance prices for the weapons * [ ] Change and balance prices for the ammo * [ ] Remove redundant weapons (there are duplicates and I'm nut sure if they are redundant, e.g: there's `tacrp_civ_p90` and `tacrp_p90`, of which the former is semi-automatic?)
I'm going to need help from someone who actually knows guns for this one if we want realism.
Things to keep an eye out for:
Closing this as finished. If anything pops up related to this, feel free to make a new issue.
Add more of the TacRP weapons as items
Currently done:
tacrp_ex_m1911
)tacrp_civ_g36k
)tacrp_sphinx
)tacrp_ex_usp
)tacrp_dsa58
)tacrp_ex_hecate
)tacrp_m14
)tacrp_ex_m4a1
)tacrp_m4star10
)tacrp_aug
)tacrp_uzi
)tacrp_sg551
)tacrp_bekas
)tacrp_pdw
)tacrp_g36k
)tacrp_tgs12
)tacrp_ex_ump45
)tacrp_xd45
)tacrp_uratio
)tacrp_p2000
)tacrp_m1
)tacrp_superv
)tacrp_spr
)tacrp_skorpion
)tacrp_ak47
)tacrp_civ_mp5
)tacrp_ar15
)tacrp_p250
)tacrp_mp7
)tacrp_mp5
)tacrp_vertec
)tacrp_m4star10
)tacrp_m4
)tacrp_k1a
)tacrp_civ_p90
)tacrp_gsr1911
)tacrp_as50
)tacrp_hk417
)tacrp_fp6
)tacrp_ex_mp9
)tacrp_ex_mac10
)tacrp_ex_hk45c
)tacrp_p90
)tacrp_mtx_dual
)tacrp_mg4
)tacrp_amd65
)tacrp_ex_ak47
)tacrp_ex_glock
)tacrp_ks23
)Help would be appreciated, check out these weapons for examples. Should be relatively straight forward to add more.
The following ammo types exist:
As defined here: https://github.com/luttje/gmod-experiment-redux/blob/79c34807a3ebe72bf419cd0f9f63f66b805967ae/schema/libs/sh_ammo.lua#L15
Supposedly ammo always has to map to an existing ammo type or one added with
game.AddAmmoType
(untested)More ammo types now exist, check out the
schema/libs/sh_ammo.lua
file to see them.You can specify the ammo for a weapon using:
This issue isn't finished yet, we still have to:
tacrp_civ_p90
andtacrp_p90
, of which the former is semi-automatic?)I'm going to need help from someone who actually knows guns for this one if we want realism.