luttje / gmod-experiment-redux

'Experiment' is an FPS RPG for the Helix framework in Garry's Mod.
https://experiment.games/
MIT License
5 stars 0 forks source link

Test weapon attachments, balance prices #4

Closed luttje closed 3 months ago

luttje commented 5 months ago

Add more of the TacRP weapons as items

Currently done:

Help would be appreciated, check out these weapons for examples. Should be relatively straight forward to add more.

The following ammo types exist:

  • "xbowbolt": "5.7x28mm Rounds"
  • "smg1": "5.56x45mm Rounds"
  • "ar2": "7.62x39mm"
  • "357": ".357 Rounds"
  • "ar2altfire": "Beanbag Pellets"
  • "pistol": "9x19mm Rounds"
  • "buckshot": "12 Gauge Buckshot"
  • "alyxgun": ".45 ACP Rounds"
  • "airboatgun": ".40 S&W"

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:

-- Inside the item script, below all other ITEM properties:
ITEM.forcedWeaponCalibre = "12 Gauge" -- where 12 Gauge matches the short name as registered in the sh_ammo.lua

This issue isn't finished yet, we still have to:

I'm going to need help from someone who actually knows guns for this one if we want realism.

luttje commented 4 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

Instructions

  1. Copy the script to the garrysmod/lua folder as generate_experiment.lua
  2. Run the script using lua_openscript generate_experiment.lua
  3. 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$' }
  4. The items are ready to be copied to the experiment-redux/plugins/customizable_weaponry/items/customizable_weaponry
luttje commented 4 months ago

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.

luttje commented 4 months ago

Things to keep an eye out for:

luttje commented 3 months ago

Closing this as finished. If anything pops up related to this, feel free to make a new issue.