Rezlind Posted December 18, 2021 Posted December 18, 2021 Hi there,I've attempted to delay the death sequence and also preventing movement that I've seen on various public sources that happens after a player dies.To achieve this I've done the following:Player dies Apply status FreezeSet a flag on the player server side indicating the player is in transition to death.Kick off an function to occur in 2 seconds via a timer which applies Freeze + Die status to character and causes the revive button to appear.The problem I'm encountering is there are instances where multiple entities can attack the same target while it does not have the die status on causing it to die multiple times from the entities. Usually this happens when the separate threads handling the monster AI are "killing" the player at exactly the same time before the player's alive status changes to In transition.Programmatically I'm not sure how I can handle this concurrency problem, I guess it's effectively a race condition :\. Quote
Spirited Posted December 18, 2021 Posted December 18, 2021 Yep, that's a race condition alright! It sounds like you might need to partition your AI threads a bit better. I'm not sure how you're splitting up your threads right now, but you might want to partition them by map or something like that. That way, only one AI thread is running per map. Though, if players and monsters can also attack at the same time, that might also be bad. I wrote an article about multi-threaded game servers here if you're interested in a few solutions / ideas: https://spirited.io/multi-threaded-game-server-design/. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.