Skip to content

Conversation

@vurvdev
Copy link

@vurvdev vurvdev commented Jul 12, 2023

  • Add WireLib.CanDamage which uses CPPICanDamage or PlayerShouldTakeDamage if CPPI is absent.
  • Enables the damage extension by default (only allows getter functions and the event by default)
  • Add blastDamage(vnn), e:takeDamage(n), e:takeDamage(ne), e:takeDamage(nee), all disabled by default with wire_expression2_damage_enabled convar.
  • Add wire_expression2_damage_maxradius to control max blastDamage radius, default 2000.
  • Mark existing damage getter methods as nodiscard

Currently haven't implemented the equivalent of https://wiki.facepunch.com/gmod/Entity:TakeDamageInfo, mostly because apparently CTakeDamageInfo objects are shared, so I'd need to write a table wrapper in between E2 and GLua, and it just isn't worth it for the small extra functionality it would add, at least for now.

RFC:

  • Different convar names?
  • Should default max radius be adjusted?

Copy link
Contributor

@thegrb93 thegrb93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Helper update needed I think

@vurvdev
Copy link
Author

vurvdev commented Jul 13, 2023

Think this is fine?

--- Returns if given player can damage the given entity.
---@param player Player
---@param target Entity
function WireLib.CanDamage(player, target) ---@return boolean
	if target:IsPlayer() then
		return hook.Run("PlayerShouldTakeDamage", target, player)
	else
		return WireLib.CanTool(player, target, "")
	end
end

I'd go with just CanTool but seems pretty restrictive. Won't even be able to target yourself unless there's an edge case I put for it.

And I think any server that cares about being restrictive about this either will have an addon that defines CPPICanDamage, or just won't set wire_expression2_damage_enabled to 1.

@thegrb93
Copy link
Contributor

That probably works, ya

@vurvdev vurvdev merged commit 46f84f9 into wiremod:master Jul 13, 2023
@vurvdev vurvdev deleted the damage-pt-2 branch July 13, 2023 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants