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

TTT: Added hooks to allow easier modification of corpse id/search behavior. #1268

Merged
merged 4 commits into from Oct 30, 2016

Conversation

Projects
None yet
3 participants
@Faerachnidendro
Copy link
Contributor

Faerachnidendro commented Oct 28, 2016

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.

Add hooks to allow easier modification of corpse id/search behavior.
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.

@Faerachnidendro Faerachnidendro changed the title Add hooks to allow easier modification of corpse id/search behavior. TTT: Add hooks to allow easier modification of corpse id/search behavior. Oct 28, 2016

@robotboy655 robotboy655 added the TTT label Oct 28, 2016

@@ -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)

This comment has been minimized.

@svdm

svdm Oct 29, 2016

Collaborator

Spaces after commas, same for the other hook below.

This comment has been minimized.

@Faerachnidendro

Faerachnidendro Oct 29, 2016

Author Contributor

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)

This comment has been minimized.

@svdm

svdm Oct 29, 2016

Collaborator

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.

This comment has been minimized.

@Faerachnidendro

Faerachnidendro Oct 29, 2016

Author Contributor

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

This comment has been minimized.

@svdm

svdm Oct 29, 2016

Collaborator

Move above the block of locals

This comment has been minimized.

@Faerachnidendro

Faerachnidendro Oct 29, 2016

Author Contributor

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

This comment has been minimized.

@svdm

svdm Oct 29, 2016

Collaborator

Also move above the locals, but after the IsOnFire check, unless you move that to the hook's default implementation.

This comment has been minimized.

@Faerachnidendro

Faerachnidendro Oct 29, 2016

Author Contributor

Done, hard to decide if IsOnFire check should be within hook's default implementation, thoughts?

@robotboy655

This comment has been minimized.

Copy link
Collaborator

robotboy655 commented Oct 29, 2016

@svdm, if you could look into the TTT PRs on page 2, I'd appreciate that.

@Faerachnidendro Faerachnidendro changed the title TTT: Add hooks to allow easier modification of corpse id/search behavior. TTT: Added hooks to allow easier modification of corpse id/search behavior. Oct 29, 2016

Faerachnidendro added some commits Oct 29, 2016

Added hook for when a new corpse has been created.
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.
@svdm

svdm approved these changes Oct 30, 2016

@svdm svdm merged commit d85e2b7 into Facepunch:master Oct 30, 2016

@Faerachnidendro

This comment has been minimized.

Copy link
Contributor Author

Faerachnidendro commented Oct 30, 2016

2 errors in merged commit, have been fixed in my branch, should (I/we) revert this?

@svdm

This comment has been minimized.

Copy link
Collaborator

svdm commented Oct 31, 2016

I believe it's easiest/cleanest if you create a new PR for those fixes.

@Faerachnidendro

This comment has been minimized.

Copy link
Contributor Author

Faerachnidendro commented Nov 1, 2016

Righto, will do :)

svdm added a commit that referenced this pull request Nov 2, 2016

TTT: fix bugs in corpse hooks
Fixes based on #1270, for changes made in #1268
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.