Facing Some issues

At the beginning of this week, we found out two issues in the Regeneration system. One, that on reloading a game, entities which were being restored “froze” in their saved state. This needs a bit of searching in Delay Manager to check out how that works, and to come up with a solution to this.

Second, hitting a group of blocks resulted in some of them freezing in a damaged or partially healed state. This was a significant issue, as a Health system is supposed to handle as many entities as there can be. This was happening in a PR, which was a few commits behind the master branch. So, I thought rebasing should probably solve the issue (as those commits in master were to solve some similar issue). But that didn’t resolve the issue.

As this seemed a major issue, I continued to work on it in the same PR.

The issue was that the scheduler removed all regeneration of a given endTime if even one entity with that endTime has fully regenerated. When a group of blocks are damaged simultaneously, they get almost the same endTime, hence, as soon as one gets fully regenerated, others’ regen froze. It turned out it was just a single line which was to be changed to get the regen back to work, but finding out that it was this line, took a little too long.

Restoration, finally…

After the problem of regen sorted, I moved on to Restoration logic flow. The idea for restoration is that it creates a set of events (similar to the previously present Heal set of events), which are sent only when an entity is restored. So, I added DoRestoreEvent which sets off the restoration chain for an entity, triggering BeforeRestoreEvent, looking for any modifiers. Based on the modified value of restoration amount, either health is increased, or “HEAL” damage is dealt to the entity. OnRestoredEvent marks that the entity has been restored.

Just having events doesn’t make the player healthy. So I added RestorationAuthoritySystem to listen for restoration and increase health accordingly.

I also add docs to everything on the go but forgot for the restore system. So had to add it in a separate PR

Tests and validations

I also added some tests for making sure that the restoration works, thinking of all the use cases of the events, and edge cases. Currently not very extensive, but the tests make sure that no hell breaks loose.

Tests are all okay, but the health is such a critical system that it needs proper in-game testing. I have picked up Potions module for testing, as it has the requirement of both regeneration and restoration flow of healing.

A few line changes enabled me to make the potion work with the new restoration logic.

What next?

First off, I have to rewrite the regeneration effects application of Alteration Effects module. It is the module on which Potions depend on for regeneration based potions. Since the current implementation there is based on update() ticks, I think I will have to rewrite the whole regeneration effect system there.

Once both regeneration and restoration are working fine for Potions, I will have to refactor all systems (which depend on Core:Health) to depend on the newly created module.