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

Faerachnidendro
Copy link
Contributor

@Faerachnidendro 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.

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 The pull request is for TTT and will be handled by svdm. 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)
Copy link
Collaborator

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.

Copy link
Contributor Author

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)
Copy link
Collaborator

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.

Copy link
Contributor Author

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
Copy link
Collaborator

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 locals

Copy link
Contributor Author

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
Copy link
Collaborator

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.

Copy link
Contributor Author

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?

@robotboy655
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
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 merged commit d85e2b7 into Facepunch:master Oct 30, 2016
@Faerachnidendro
Copy link
Contributor Author

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

@svdm
Copy link
Collaborator

svdm commented Oct 31, 2016

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

@Faerachnidendro
Copy link
Contributor Author

Righto, will do :)

svdm added a commit that referenced this pull request Nov 2, 2016
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
Labels
TTT The pull request is for TTT and will be handled by svdm.
Projects
None yet
3 participants