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
TTT: Added hooks to allow easier modification of corpse id/search behavior. #1268
Conversation
I would like to propose these hook additions which would allow modders (if not just myself, others also) to easily create weapons and entities and other conditions which interrupt the ability for players to identify/search a corpse - without making changes to the corpse.lua files ourselves. I am happy to privately share examples where this is sorely needed, for at least my own purposes - but let your imagination run wild a bit yourself ;) Ideally, this would be something for traitors to benefit from only( and in fair ways pertaining to the use of equipment items ), though it could be abused in ways that really ruin the gameplay - that said, if someone were determined enough to do that, they would almost certainly have done so already with or without such hooks.
@@ -36,6 +36,12 @@ end | |||
-- If detective mode, announce when someone's body is found | |||
local bodyfound = CreateConVar("ttt_announce_body_found", "1") | |||
|
|||
-- opportunity for addons to introduce ways for traitors(ideally) to interrupt corpse searching. | |||
function GM:TTTInterruptCorpseIdentify(identifier,corpse,corpse_is_traitor) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spaces after commas, same for the other hook below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
woops, hasty fingers, sorry
@@ -36,6 +36,12 @@ end | |||
-- If detective mode, announce when someone's body is found | |||
local bodyfound = CreateConVar("ttt_announce_body_found", "1") | |||
|
|||
-- opportunity for addons to introduce ways for traitors(ideally) to interrupt corpse searching. | |||
function GM:TTTInterruptCorpseIdentify(identifier,corpse,corpse_is_traitor) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I would suggest TTTCanIdentifyCorpse
and TTTCanSearchCorpse
as hook names, with the default implementation returning true. This fits in a bit better with standard hooks like PlayerCanPickupWeapon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opted for default implementation as false(or nil), in case modders wanted to easily break out of all hook checks without interrupting the id/search, but have no arguments against your suggestion there.
-- opportunity for addons to introduce ways for traitors(ideally) to interrupt corpse identification. | ||
if hook.Run("TTTInterruptCorpseIdentify", ply, rag, traitor) then | ||
return | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move above the block of local
s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah no worries, this was placed here because I was originally going to suggest passing said locals through the hook, but decided against it and forgot to move it.
-- opportunity for addons to introduce ways for traitors(ideally) to interrupt corpse searching. | ||
if hook.Run("TTTInterruptCorpseSearch", ply, rag, traitor) then | ||
return | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also move above the locals, but after the IsOnFire
check, unless you move that to the hook's default implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, hard to decide if IsOnFire check should be within hook's default implementation, thoughts?
@svdm, if you could look into the TTT PRs on page 2, I'd appreciate that. |
Sorry for the late addition, this one slipped my mind earlier but should have been included in the initial suggestion. This hook, "TTTOnCorpseCreated", is a good opportunity to set variables on a corpse for later use in the other 2 hooks suggested.
2 errors in merged commit, have been fixed in my branch, should (I/we) revert this? |
I believe it's easiest/cleanest if you create a new PR for those fixes. |
Righto, will do :) |
I would like to propose these hook additions which would allow modders (if not just myself, others also) to easily create weapons and entities and other conditions which interrupt the ability for players to identify/search a corpse - without making changes to the corpse.lua file.
I am happy to privately share examples where these are sorely needed, for at least my own purposes - but let your imagination run wild a bit yourself ;)
"TTTCanIdentifyCorpse" (ply, corpse, corpse_was_traitor)
Called to determine if a player can identify the corpse they are trying to inspect; return true to allow, false to disallow.
"TTTCanSearchCorpse" (ply, corpse, corpse_was_traitor)
Called to determine if a player can view the search interface for the corpse they are trying to inspect; return true to allow, false to disallow.
"TTTOnCorpseCreated" (corpse)
Called after a player has been killed and their corpse has been created and spawned with all essential variables set.
Ideally, this would be something for traitors to benefit from only( and in fair ways pertaining to the use of equipment items ), though it could be abused in ways that really ruin the gameplay - that said, if someone were determined enough to do that, they would almost certainly have done so already with or without such hooks.