#[Core Keeper Modding] Player state detection

1 messages · Page 1 of 1 (latest)

sweet stone
#

I checked what's wrong and why it doesn't seem to work and, the usage of the State classes like Death etc is controlled by a bursted system PlayerState.UpdatePlayerStateSystem

What does this mean? It means that the code from PlayerState.Death is also compiled as long as the function fulfills bursting requiements, which it does in this case - the code we're reading and modifying is only a c# copy of it, there exists a separate compiled path for this function, so our modifications can't affect it

#

A few months ago I did some tests and you can circumvent bursting of a system - theoretically unbursting it's usage, but it's very new method with not known boundaries so you know... you could struggle a lot with it's usage and debugging when it doesnt work

Also it requires elevated permission if you don't want to upkeep the code on version updates if function signature would change

flint wadi
#

Do mods need to be added on a fresh world for them to work? I dont even know how to tell if mods uploaded correctly but everytime I try and join the server it says connection closed

sweet stone
#

You can use the normal chat, no worries, I just moved this topic to a separate one because it might be usefull for future ^^

sweet stone
quaint herald
#

and also am i to assume my attempt was valid?

#

but the code is just doing an "unexpected behaviour"

sweet stone
#

Yeah the patch is valid but the method is "not used"

#

Basically it has a separate native implementation - that's what bursting is

quaint herald
#

Sooo... I need to find the right function to patch as this is somehow not the right one??

sweet stone
sweet stone
quaint herald
#

So the game just ignores harmony patches sometimes?

sweet stone
quaint herald
#

I mean i can always just check if the player is dead in the update function i'm just seeking the optimal way (as i should)

sweet stone
# quaint herald So the game just ignores harmony patches sometimes?

Yeah from our perspective it look just like it would be ignored.
Overall the patch is applied, like if you were to call it manually you would see the effect... but as the system that actually changes the State is bursted -> native, this function also got bursted -> made native

Thats why you don't see this path, it's outside of the c#

quaint herald
#

That's a weird thing to happen. Is it intentional by the devs?

sweet stone
#

It's a side effect of optimization, the devs could disable it but the performance would also get a chunky hit if they just unbursted everything

#

Overall the default position of Unity ECS is to burst where possible

quaint herald
#

Oh that makes sense

sweet stone
#

I'll give a shot at making it work and share it, I have one working for StateUpdate, but that was honestly a lucky shot, it could break in the next update

quaint herald
#

So they basically have a function that once loaded gives the same result each time and is optimised to be unmodifiable

#

Or am i making a wrong assumption

#

So what you want to do is replicate the function to try and fool the optimisation system?

#

But if they update anything in the function you'd have to fix it again?

#

I am going to implement the functionality by checking player health in Update() function for now as this seems a bit too hard to pull off and maintain

#

Still interested in seeing a solution for this problem for sure though!

sweet stone
#

Yeah, gonna check few things and I'll come back to you ^.- Then I can actually explain what's going on

sweet stone
#

The PlayerState.Death.EnterStatePresentation, PlayerState.Death.UpdateStatePresentation and PlayerState.Death.ExitStatePresentation

Are called by a managed system ChangePlayerStatePresentationSystem so you can always patch those methods, but they run only on client (I mean it doesnt really matter in your case, but could if you wanted to expand to multiplayer later)

#

You can also get the PlayerState.PlayerStateCD component from player, it's used for those State systems so that's not a bad idea, PlayerController.IsDyingOrDead also takes this component as an argument

quaint herald
#

can confirm that patching PlayerState.Death.EnterStatePresentation works tho!

sweet stone
quaint herald
#

Yeah for now just the host being able to run the mod successfully in a multiplayer environment is more than enough 😅

#

The mod won't really be public cuz of it's niche use case, but a certain someone will be using it pretty soon :D

sweet stone
#

Great, hope it all works out 💪

sweet stone
#

Here's an example of how to unburst the PlayerState.ChangePlayerStateSystem
https://gist.github.com/Sashiri/13cc27f67189062cbacfe0f68c05ca9d#file-3-unburst-playerstate-changeplayerstatesystem-cs

I'm a bit fried from this so there's a lot of stuff that could've been simplified

Overall is it worth it to maintain those changes just have Death state notification? Probably not, but it has many more applications in the modding opportunities I guess 🤔 Or if you would need more states to be detected and directly on the server

Gist

Examples of how to unburst selected systems and jobs for harmony patching - 1.Unburst.Job.Example.cs