Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EquipmentEditor: Set clip on buy #1499

Merged
merged 13 commits into from
May 11, 2024
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ All notable changes to TTT2 will be documented here. Inspired by [keep a changel
- Added `TTT2CanTakeCredits` hook for overriding whether a player is allowed to take credits from a given corpse. (by @Spanospy)
- Disabled locational voice during the preparing phase by default
- Added a ConVar `ttt_locational_voice_prep` to reenable it
- Added `SWEP.SetClipOnBuy` and `SWEP.ClipOnBuy` to set the weapon's clip on buy via the equipment editor (by @TimGoll)
- Added Text / Nickname length limiting (by @TimGoll)
- Added `ttt_locational_voice_range` to set a cut-off radius for the locational voice chat range
- Added a convar `ttt2_inspect_credits_always_visible` to control whether credits are visible to players that do not have a shop
Expand Down
10 changes: 10 additions & 0 deletions gamemodes/terrortown/entities/weapons/weapon_tttbase.lua
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ SWEP.silentPickup = false
-- Can be useful if you have multiple instances, that rely on global variables stored via weapons.GetStored()
SWEP.HotReloadableKeys = {}

-- Set this to true if the weapon should have a custom clip size on buy that can be set in the equipment editor
SWEP.SetClipOnBuy = false

-- The defult clip on buy if `SWEP.SetClipOnBuy` is set to true
TimGoll marked this conversation as resolved.
Show resolved Hide resolved
SWEP.ClipOnBuy = 1

-- If this weapon should be given to players upon spawning, set a table of the
-- roles this should happen for here
-- SWEP.InLoadoutFor = {ROLE_TRAITOR, ROLE_DETECTIVE, ROLE_INNOCENT}
Expand Down Expand Up @@ -1484,6 +1490,10 @@ function SWEP:Initialize()
self:InitializeCustomModels()
end

if self.SetClipOnBuy then
self:SetClip1(self.ClipOnBuy or self.Primary.DefaultClip)
end

TimGoll marked this conversation as resolved.
Show resolved Hide resolved
if CLIENT and self:Clip1() == -1 then
self:SetClip1(self.Primary.DefaultClip)
elseif SERVER then
Expand Down
5 changes: 5 additions & 0 deletions gamemodes/terrortown/gamemode/shared/sh_shopeditor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ ShopEditor.savingKeys = {
bits = 8,
default = 1,
},
ClipOnBuy = {
typ = "number",
bits = 8,
default = 1,
},
AllowDrop = {
typ = "bool",
default = true,
Expand Down
5 changes: 5 additions & 0 deletions lua/terrortown/lang/en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2222,6 +2222,11 @@ L.help_locational_voice_prep = [[By default the proximity chat is disabled in th
Note: Proximity chat is always disabled during the post round phase.]]
L.help_voice_duck_spectator = "Ducking spectators makes other spectators quieter in comparison to living players. This can be useful if one wants to listen closely to the discussions of the living players."

L.help_equipmenteditor_clip_on_buy = [[The clip size on buy defines the amount of uses the weapon has when bought in the shop.

Note: This setting is only available for weapons that enable this feature.]]
ZenBre4ker marked this conversation as resolved.
Show resolved Hide resolved
L.label_equipmenteditor_clip_on_buy = "Clip size on buy"

-- 2024-04-06
L.help_locational_voice_range = [[This convar constrains the maximum range at which players can hear each other. It does not change how the volume decreases with distance but rather sets a hard cut-off point.

Expand Down
66 changes: 40 additions & 26 deletions lua/terrortown/menus/gamemode/equipment/base_equipment.lua
Original file line number Diff line number Diff line change
Expand Up @@ -128,21 +128,41 @@ function CLGAMEMODESUBMENU:Populate(parent)
master = master,
})

form:MakeSlider({
label = "equipmenteditor_name_min_players",
min = 0,
max = 63,
decimal = 0,
database = DatabaseElement(accessName, itemName, "minPlayers"),
master = master,
})

form:MakeSlider({
label = "equipmenteditor_name_credits",
min = 0,
max = 20,
decimal = 0,
database = DatabaseElement(accessName, itemName, "credits"),
master = master,
})

if not self.isItem then
form:MakeHelp({
local form2 = vgui.CreateTTT2Form(parent, "header_equipment_value_setup")

form2:MakeHelp({
label = "equipmenteditor_desc_allow_drop",
})

form:MakeCheckBox({
form2:MakeCheckBox({
label = "equipmenteditor_name_allow_drop",
database = DatabaseElement(accessName, itemName, "AllowDrop"),
})

form:MakeHelp({
form2:MakeHelp({
label = "equipmenteditor_desc_drop_on_death_type",
})

form:MakeComboBox({
form2:MakeComboBox({
label = "equipmenteditor_name_drop_on_death_type",
database = DatabaseElement(accessName, itemName, "overrideDropOnDeath"),
choices = {
Expand All @@ -151,38 +171,32 @@ function CLGAMEMODESUBMENU:Populate(parent)
{ title = TryT("drop_on_death_type_deny"), value = DROP_ON_DEATH_TYPE_DENY },
},
})
end

form = vgui.CreateTTT2Form(parent, "header_equipment_value_setup")

form:MakeSlider({
label = "equipmenteditor_name_min_players",
min = 0,
max = 63,
decimal = 0,
database = DatabaseElement(accessName, itemName, "minPlayers"),
})

form:MakeSlider({
label = "equipmenteditor_name_credits",
min = 0,
max = 20,
decimal = 0,
database = DatabaseElement(accessName, itemName, "credits"),
})

if not self.isItem then
form:MakeHelp({
form2:MakeHelp({
label = "equipmenteditor_desc_damage_scaling",
})

form:MakeSlider({
form2:MakeSlider({
label = "equipmenteditor_name_damage_scaling",
min = 0,
max = 8,
decimal = 2,
database = DatabaseElement(accessName, itemName, "damageScaling"),
})

if equipment.SetClipOnBuy then
form2:MakeHelp({
label = "help_equipmenteditor_clip_on_buy",
})

form2:MakeSlider({
label = "label_equipmenteditor_clip_on_buy",
min = 1,
max = 20,
decimal = 0,
database = DatabaseElement(accessName, itemName, "ClipOnBuy"),
})
end
end

local equipmentClass = WEPS.GetClass(equipment)
Expand Down