Although I made the first comment questioning the point of degrading the experience of a portion of your audience for no apparent gain, I still find it an interesting question from a technical point of view.
I just had this idea: What cheaters do is find values that change and freeze them. The search would then happen only between deaths or events that changed the player's health. Moreover, the cheater could be refining the search by filtering out what changed when he was "not dying".
What if the "health" counter is changing the whole time? Make it a pointer and reallocate it every frame or every N frames if the performance hit is too big. Or XOR it with a random value that changes every frame (XORing again against the same value for decrypting before encrypting with a new random value).
If you have other in-game data also changing the whole time (including x and y positions of the player character, or the time counter), that might make it harder to find out which of all the changing data is the health. And freezing the whole game state is a no-go for the cheater.
Para engañar aún más, en realidad puede almacenar la salud en una variable de solo escritura que se entiende como un tarro de miel.
Editar :
Aún así, el tramposo podría tratar de encontrar cuál de las variables que está cambiando todo el tiempo es la que se congela a través de prueba y error. Una posible solución sería acoplar las variables juntas.
Un ejemplo:
En lugar de almacenar la salud (h) y la posición (x), las almacena en dos variables a y b, desde donde puede recuperar los valores más adelante:
a = x+h; b = x-h
x = (a+b)/2; h = (a-b)/2
De esta manera, si el tramposo congela solo uno de ellos y luego mueve al personaje, la posición se ve afectada y, dependiendo de cuál se haya congelado, h se vuelve negativo (muerte instantánea). Puede cambiar entre las fórmulas anteriores y:
a = x-h; b = x+h
x = (a+b)/2; h = (b-a)/2
In consecutive frames, and you guarantee that in at most 2 frames after either one of the variables have been frozen health will turn 0 the moment x changes. Remember that you are storing only a and b. Combine this with the continuous XOR as mentioned above. The result is a collection of variables that are changing every frame to seemingly random values, and freezing any single one or a subset of them only produces undesired side effects in the game, instant death being one of them.