Potions!

The first task that i worked on this week was to make sure that restoration and regeneration system created are working fine when used from other systems.

Since the main change in restoration was to change DoHealEvent -> DoRestoreEvent, that went pretty smoothly.

But things got a little twist when I tried to refactor regen code of potions, which depended on Alteration Effects for applying the effect.

The twist was that the new regen requires unique id for every regen attached to an entity, but the previous system, which relied on its own regen implementation (complete with a regenComponent) did not have id based regen. So, I tried to find a unique identifier to each potion. Luckily, I found two candidates: one in itemComponent and the other in nameComponent.

I went ahead with the itemComponent option because, well, every potion is an item. So it will necessarily have an item component, which can not be said with surity for name component.

Otherwise, this too was simple, because all we have to add a new regen is to send ActivateRegen event. But the pr is not complete right now, as I have to still add some “event” chains followed in all Alteration Effects.

This was kind of a in-game testing of the newly created health system.

Covering up backlog

Currently, I have reached a stage where backlog issues (although some small) are as many as tasks to be done in a month. So, I planned to cover up some of the backlog issues before moving on.

The first one i worked on was the bug on saving and reloading. So, when a game is reloaded, the entities which were damaged and were getting regenerated became “stuck” in their damaged state.

This one took some effort to get it to working, as my first attempt to add the regens to the scheduler in a postBegin() failed. I found out that entities are instantiated after the post begin method (except for world entity, i think). I had to look for another way to achieve this. So, I went for the next option at hand: the OnActivatedComponent event.

But, I found out that things were going “crazy” on reload. One main thing was that event though regen was getting added to scheduler, it failed to regenerate. It took me couple of hours (thanks to the debugger tools of IntelliJ Idea) to point out the exact cause of the “funny” behaviour. It was that on relaod, Long.MAX_VALUE got saved as -1, messing up the scheduler. I used this value for baseRegen because base regeneration has to carry on till it gets full health.

So, to circumvent the bug, I explicitly set the endTime of base regen as -1, making up changes to everything to account for this special case.

Presently, the issue is solved, with regeneration working fine on save and reload.

Did I miss something?

This week, I was supposed to start refactoring all modules to depend on the newly created Health Module. But, we postponed it by two weeks, as a major thing which was pushed back earlier has to be discussed now, before doing the refactor. Yes, the point pools. So, we have to decide on this on how are we having a unified pool/meter module before going on overall refactoring.

What next?

The next part is to decide on how to handle unified point system (hunger, thirst, etc.) and work on its implementation. After that comes the refactoring of modules to depend on extracted and modified health logic