Skip to content

Commit 7b82d52

Browse files
authored
TargetId: Let GM:TTTModifyTargetedEntity modify the target distance (#1828)
You can modify the target entity, but the distance value would remain the same since it couldn't be changed. This can make targetids to appear and disappear unexpectedly if the target entity was changed. I've made `GM:TTTModifyTargetedEntity` read a second return value for distance so devs can correct the distance or do as they please with it. I've checked and it doesn't let you use entities from far away if you force target them with distance set to 0.
1 parent 87d7307 commit 7b82d52

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ All notable changes to TTT2 will be documented here. Inspired by [keep a changel
1212
- Added support for coloring the entry's background box
1313
- Added support for specifying a custom height for an entry
1414
- Gave `GM:TTTBodySearchPopulate` hook a new boolean argument named `scoreboard` which becomes true if the hook is being called to populate the bodysearch info on the scoreboard
15+
- `GM:TTTModifyTargetedEntity` can now return a second value to modify the distance of a new target entity (by @TW1STaL1CKY)
1516

1617
### Fixed
1718

gamemodes/terrortown/gamemode/client/cl_targetid.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,15 @@ function GM:HUDDrawTargetID()
296296

297297
---
298298
-- @realm client
299-
local changedEnt = hook.Run("TTTModifyTargetedEntity", ent, distance)
299+
local changedEnt, changedDistance = hook.Run("TTTModifyTargetedEntity", ent, distance)
300300

301301
if changedEnt then
302302
unchangedEnt = ent
303303
ent = changedEnt
304+
305+
if isnumber(changedDistance) then
306+
distance = changedDistance
307+
end
304308
end
305309

306310
-- make sure it is a valid entity

0 commit comments

Comments
 (0)