Skip to content

Commit e43f7aa

Browse files
authored
Body armour adjustments (#1783)
- adds a new cvar for blocking crowbar damage - removed crowbar damage being reduced by "classic" armour: crowbar damage was never blocked by armour in ttt - set headshot damage to be reduced by default: this was never an oversight or mistake in ttt, it is a deliberate balance change, body armour initially only protected against shots to the torso but bku updated it to also protect against headshots and limbshots - adds TTT2ArmorHandlePlayerTakeDamage hook (probably needs a better name) this is a draft because this is untested right now, will test later
1 parent 5413e42 commit e43f7aa

File tree

5 files changed

+46
-6
lines changed

5 files changed

+46
-6
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,20 @@ All notable changes to TTT2 will be documented here. Inspired by [keep a changel
99
- Added C4 cvars for adjusting the range & falloff of C4 explosions (by @Spanospy)
1010
- C4 explosions will now also respect the weapon's configured damage scaling
1111
- Added option to select preferred unit of length for distance displays (by @wgetJane)
12+
- Added `GM:TTT2ArmorHandlePlayerTakeDamage` hook for modifying/overriding armor behavior (by @wgetJane)
13+
- Added server option for body armor to protect against crowbar damage (by @wgetJane)
1214
- Added `GM:TTTLastWordsMsg` hook from base TTT (Facepunch/garrysmod/pull/2227, by @wgetJane)
1315
- Port new TTT entity ttt_filter_role to TTT2 (Facepunch/garrysmod/pull/2225 by @figardo, ported by @wgetJane)
1416

1517
### Changed
18+
1619
- Updated Russian and English localization files (by @Satton2)
1720
- Updated the list of troublesome addons used by the addonchecker
18-
- Allow workshop addons to pack rearm scripts (Facepunch/garrysmod/pull/2139, by @figardo)
21+
- Changed option for body armor to protect against headshot damage by default (by @wgetJane)
1922

2023
### Fixed
2124

25+
- Fixed classic armour protecting against crowbar damage (by @wgetJane)
2226
- Fixed C4/Radio sounds not playing outside of PAS (Facepunch/garrysmod/pull/2203, by @figardo)
2327
- Fixed players sometimes being revealed as dead when they chat/voicechat right as they die (Facepunch/garrysmod/pull/2229, by @wgetJane)
2428

gamemodes/terrortown/gamemode/server/sv_armor.lua

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ ARMOR.cv = {
6464
-- @realm server
6565
item_armor_block_headshots = CreateConVar(
6666
"ttt_item_armor_block_headshots",
67-
0,
67+
1,
6868
{ FCVAR_NOTIFY, FCVAR_ARCHIVE }
6969
),
7070

@@ -75,6 +75,14 @@ ARMOR.cv = {
7575
0,
7676
{ FCVAR_NOTIFY, FCVAR_ARCHIVE }
7777
),
78+
79+
---
80+
-- @realm server
81+
item_armor_block_clubdmg = CreateConVar(
82+
"ttt_item_armor_block_clubdmg",
83+
0,
84+
{ FCVAR_NOTIFY, FCVAR_ARCHIVE }
85+
),
7886
}
7987

8088
hook.Add("TTT2SyncGlobals", "AddArmorGlobals", function()
@@ -160,10 +168,15 @@ function ARMOR:HandlePlayerTakeDamage(ply, infl, att, amount, dmginfo)
160168
return
161169
end
162170

171+
-- handle if crowbar damage should be ignored by the armor
172+
if dmginfo:IsDamageType(DMG_CLUB) and not self.cv.item_armor_block_clubdmg:GetBool() then
173+
return
174+
end
175+
163176
-- fallback for players who prefer the vanilla armor
164177
if not self.cv.armor_dynamic:GetBool() then
165-
-- classic armor only shields from bullet/crowbar damage
166-
if dmginfo:IsDamageType(DMG_BULLET) or dmginfo:IsDamageType(DMG_CLUB) then
178+
-- classic armor only shields from bullet damage
179+
if dmginfo:IsDamageType(DMG_BULLET) then
167180
dmginfo:ScaleDamage(0.7)
168181
end
169182

@@ -191,6 +204,19 @@ function ARMOR:HandlePlayerTakeDamage(ply, infl, att, amount, dmginfo)
191204
dmginfo:SetDamage(damageReduced * self.cv.health_factor + damage - damageReduced)
192205
end
193206

207+
---
208+
-- Handles the @{ARMOR} of a @{Player}, called by @{GM:PlayerTakeDamage}
209+
-- @param Player ply The @{Player} taking damage
210+
-- @param Entity infl The inflictor
211+
-- @param Player|Entity att The attacker
212+
-- @param number amount Amount of damage
213+
-- @param CTakeDamageInfo dmginfo Damage info
214+
-- @realm server
215+
-- @hook
216+
function GM:TTT2ArmorHandlePlayerTakeDamage(ply, infl, att, amount, dmginfo)
217+
return ARMOR:HandlePlayerTakeDamage(ply, infl, att, amount, dmginfo)
218+
end
219+
194220
---
195221
-- @class Player
196222

gamemodes/terrortown/gamemode/server/sv_player.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1486,9 +1486,11 @@ function GM:PlayerTakeDamage(ent, infl, att, amount, dmginfo)
14861486
dmginfo:ScaleDamage(att:GetDamageFactor())
14871487
end
14881488

1489+
--
14891490
-- before the karma is calculated, but after all other damage hooks / damage change is processed,
14901491
-- the armor system should come into place (GM functions are called last)
1491-
ARMOR:HandlePlayerTakeDamage(ent, infl, att, amount, dmginfo)
1492+
-- @realm server
1493+
hook.Run("TTT2ArmorHandlePlayerTakeDamage", ent, infl, att, amount, dmginfo)
14921494

14931495
if ent ~= att then
14941496
-- process the effects of the damage on karma

lua/terrortown/lang/en.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1609,7 +1609,7 @@ Haste mode balances the game by increasing the round time with every dead player
16091609
If haste mode is enabled, the fixed round time is ignored.]]
16101610
L.help_round_limit = "After one of the set limit conditions is met, a map change is triggered."
16111611
L.help_armor_balancing = "The following values can be used to balance the armor."
1612-
L.help_item_armor_classic = "If classic armor mode is enabled, only the previous settings matter. Classic armor mode means that a player can only buy armor once in a round, and that this armor blocks 30% of the incoming bullet and crowbar damage until they die."
1612+
L.help_item_armor_classic = "If classic armor mode is enabled, only the previous settings matter. Classic armor mode means that a player can only buy armor once in a round, and that this armor blocks 30% of the incoming bullet damage until they die."
16131613
L.help_item_armor_dynamic = [[
16141614
Dynamic armor is the TTT2 approach to make armor more interesting. The amount of armor that can be bought is now unlimited, and the armor value stacks. Getting damaged decreases the armor value. The armor value per bought armor item is set in the 'Equipment Settings' of said item.
16151615
@@ -2829,3 +2829,6 @@ L.choice_distance_unit_0 = "Inches"
28292829
L.choice_distance_unit_1 = "Meters"
28302830
L.choice_distance_unit_2 = "Yards"
28312831
L.choice_distance_unit_3 = "Feet"
2832+
2833+
-- 2025-03-06
2834+
L.label_armor_block_clubdmg = "Enable armor blocking crowbar damage"

lua/terrortown/menus/gamemode/administration/playersettings.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ function CLGAMEMODESUBMENU:Populate(parent)
3636
label = "label_armor_block_blastdmg",
3737
})
3838

39+
form2:MakeCheckBox({
40+
serverConvar = "ttt_item_armor_block_clubdmg",
41+
label = "label_armor_block_clubdmg",
42+
})
43+
3944
form2:MakeHelp({
4045
label = "help_item_armor_classic",
4146
})

0 commit comments

Comments
 (0)