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

feat(extra-natives/five): GET_ENTITY_HEALTH_FLOAT #2274

Closed
wants to merge 1 commit into from
Closed

feat(extra-natives/five): GET_ENTITY_HEALTH_FLOAT #2274

wants to merge 1 commit into from

Conversation

packfile
Copy link
Contributor

Currently only the C# runtime has a way to obtain this (Entity.HealthFloat)

@thorium-cfx thorium-cfx added enhancement Feature or other request that adds functionality or improved usability triage Needs a preliminary assessment to determine the urgency and required action labels Nov 13, 2023
Copy link
Contributor

@Disquse Disquse left a comment

Choose a reason for hiding this comment

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

We usually try to patternify offsets, but since it's CPhysical I guess there's a very little chance this offset would ever be changed. So LGTM, tested on all game builds.

@thorium-cfx
Copy link
Contributor

We usually try to patternify offsets, but since it's CPhysical I guess there's a very little chance this offset would ever be changed. So LGTM, tested on all game builds.

@Disquse Any reason not to add this as a function (maybe with a field) to fwEntity? May it change then we can address it in there directly and patch all usage.

@thorium-cfx thorium-cfx removed the triage Needs a preliminary assessment to determine the urgency and required action label Nov 16, 2023
@Disquse
Copy link
Contributor

Disquse commented Nov 16, 2023

I don't like how we are using rage::fwEntity when actually expecting it to be at least CDynamicEntity in our code. It won't work for other CEntity inherited classes such as CLightEntity, CBuilding, etc. This needs to be refactored in the future. Talking about this specific case, we definitely don't want to add CPhysical fields into rage::fwEntity making it even worse. We can add GetHealth method and use the offset but we will need to add extensible base type check (IsOfType) inside. However, even this solution will require a refactor in the future (i.e. moving this method into CPhysical class).

@gottfriedleibniz
Copy link
Contributor

gottfriedleibniz commented Nov 16, 2023

we will need to add extensible base type check (IsOfType) inside.

Should also decide whether this native should be allowed to write to any arbitrary entity/script-extension instead of using IsOfType, FromGUID<CPhysical>, or whatever (what happens now).

@packfile
Copy link
Contributor Author

Should also decide whether this native should be allowed to write to any arbitrary entity/script-extension instead of using IsOfType, FromGUID<CPhysical>, or whatever.

I'll add an IsOfType check shortly, apologies. This code is mimicking the behaviour of the C# runtime however, so an issue lies there too? (Its using GET_ENTITY_ADDRESS without any additional checks for the type either)

@gottfriedleibniz
Copy link
Contributor

so an issue lies there too?

Yes. That is one of its many issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature or other request that adds functionality or improved usability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants