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

Add CTakeDamageInfo natives to use with TakeDamage #48

Merged
merged 4 commits into from
Dec 28, 2023

Conversation

KitRifty
Copy link
Collaborator

@KitRifty KitRifty commented Dec 28, 2023

This PR adds natives for creating and applying custom CTakeDamageInfo parameters to entities using CBaseEntity::TakeDamage(). Plugins can use the GetGlobalDamageInfo native to specify custom parameters for use in TakeDamage.

CBaseEntity::TakeDamage was used over CBaseEntity::OnTakeDamage because it checks for damage filters and applies damage scaling before OnTakeDamage is called. In addition, not only is it used across the SDK, it's the recommended way of dealing damage to entities anyways. On the other hand, SDKHooks_OnTakeDamage bypasses that and calls CBaseEntity::OnTakeDamage directly.

Some other miscellaneous changes:

  • Added CBaseEntity::TakeDamage signature to gamedata
  • Imported Init and Set CTakeDamageInfo funcs from SDK
  • Fixed CTakeDamageInfo.Set/AddDamageType natives missing a parameter (reported by @Mikusch)
  • Fixed some CTakeDamageInfo natives not returning immediately after erroring

Add CBaseEntity.TakeDamageInfo native
 - Added signature to gamedata
Add CTakeDamageInfo.Set native
Add GetGlobalDamageInfo native
Imported Init and Set CTakeDamage funcs from SDK
Fix CTakeDamageInfo.AddDamageType missing parameter
Fix some CTakeDamageInfo natives not returning immediately after erroring
@Mikusch
Copy link
Member

Mikusch commented Dec 28, 2023

CTakeDamageInfo.SetDamageType is also missing its parameter in the include

Copy link
Collaborator

@Kenzzer Kenzzer left a comment

Choose a reason for hiding this comment

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

Some little nitpicks, but otherwise great work!

extension/natives/takedamageinfo.cpp Outdated Show resolved Hide resolved
extension/natives/takedamageinfo.cpp Outdated Show resolved Hide resolved
extension/natives/takedamageinfo.cpp Outdated Show resolved Hide resolved
extension/natives/takedamageinfo.cpp Outdated Show resolved Hide resolved
extension/sourcesdk/baseentity.h Outdated Show resolved Hide resolved
@Kenzzer Kenzzer merged commit 0598845 into master Dec 28, 2023
7 checks passed
@Kenzzer Kenzzer deleted the takedamage-natives branch December 28, 2023 22:30
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.

3 participants