I had a couple of minutes of spare time before breakfast. Nothing better to start a day relaxed than by implementing some small addition to ADOM II I thought to myself. Amulets of life saving came to my mind (which still were missing in ADOM II). So things started to happen...
Warning: Technicalities mixed with internals and all kinds of other stuff coming up... I don't know if such ramblings make sense to anyone but me but here you go in any case...
- I decided to "quickly" add amulets of life saving yesterday morning before breakfast.
- Implementing the actual amulet was a matter of something like 5 minutes.
- While doing so I refactored a couple of interfaces for awareness (in that case OnDeathAware) and added another one for the basic event mechanism in ADOM II - which took another 10 minutes or so.
- Then I tested the new feature, fixed one bug (5 more minutes) and suddenly noticed that the occasional (more) prompt that is inserted into messaging doesn't work as well in ADOM II as in ADOM. The reason for this is the aforementioned awareness/event mechanism. When "something regular" happens the regular time flow in ADOM II quite often can be interrupted by "something else". I'll give you an example:
The regular combat flow is "attack, maybe hit, maybe damage, print messages in the meantime for each step". Now when damage causes a being to be killed an interrupt occurs and the OnDeathAware awareness is checked to see if anyone or anything is interested in that specific event. When wearing an amulet of life saving said amulet will be interested in your death to prevent it. Usually it will succeed in preventing your death, print some messages and interleave them with (more) prompts for more drama. Now sadly (more) prompts so far are created by synchronous calls to the UI interface (e.g. something like Game.getUserInterface().more()). Now to prevent intermixing messages during combat (the one situation when basically every micro-action could yield something special, e.g. poisoning, paralysis, attribute drain) all non-direct combat action messages are delayed after the main message (e.g. "The goblin attacks you critically hitting... and killing you!") is finished. Which worked nicely up until to the now new more() call mentioned above which is synchronous and thus might yield something like "The goblin attacks you critically hitting ... (more) (more) and killing you! Your amulet glows in a silvery light! You have been resurrected!" instead of "The goblin attacks you critically hitting ... and killing you! (more) Your amulet glows in a silvery light! (more) You have been resurrected!". Woe of a programmer not managing his internal program events correctly.
While pondering a solution I came up with the idea of using a special character sequence in the messages in order to cause the (more) prompt to show up instead of doing that with a separate UI call. E.g. using "Your amulet glows in a silvery light! <<more>>" instead of printing that message and calling Game.getUserInterface().more()(because then the delayed message handling also will cause the (more) prompt to be delayed and everything would be fine).
- Said and done. I searched for the correct place to add that special token code (which was easy to find)... and then noticed that it would be a great place to pick up an older discussion we had on this bog concerning message types.
- And added message coloring because that was at least as exciting. Messages now can be rated from "very good", "good", "neutral" to "bad" and "very bad" by inserting <<++>>, <<+>>, <<0>>, <<->> and <<-->> into arbitrary message positions leading to coloring in the message display (configurability of the colors will show up in some later ADOM II version).
- Again I tested and fixed a couple of bugs.
- Just to notice that time for breakfast ran out and I now had to hurry (yesterday being in a hotel in Hamburg).
- Later in the evening I finished the color implementation and proceeded to fine-tune it.
- Getting back to the amulets of life saving I noticed that in ADOM they included special handling for the rare situations when the PC dies of old age... so I added that.
- Now you need to understand that I am a kind of "top down programmer". I usually write down the high-level code first, using lots of not-yet-existant classes and types when introducing new concepts.
- Which was the case now... as aging requires something like age categories (e.g. young, old, ancient).
- So I introduced a new enumeration called AgeCategory to reflect that and wiring up all the required logic.
- Just when I wanted to proceed to the next level of detail by actually creating and implementing the concept behind AgeCategory I was surprised by the fact that Eclipse told me that said definition already exists in ADOM II. Scratching my head I searched for it... and Eclipse was right. The code stated that I actually implemented AgeCategory at the 3rd of March, 2008... and then forgot about it. Some part of the code was uncommented (which is usually never the case in ADOM II) which in turn indicates that I got sidetracked on said day by something else and never quite finished the concept.
- The good thing was that that old implementation was much better with what I came up on the spur of the moment yesterday evening and it also is way more robust than what is in good old ADOM. So I was very happy to find that I actually had done a lot of groundwork years ago.
- So I finished the aging implementation, finished the special age code in the implementation of amulets of life saving... and noticed that I had not yet tested the new <<more>> code :-)
So you might call me a "distracted programmer" - but only when doing ADOM II. Usually I'm very focussed but it's so easy to get excited by some new concept for ADOM II that I can get kind of lost. But now am happy as this will add even more cool features to the next release. The sad thing just being that "the quick addition of amulets of life savings" actually spawned so much new stuff that I get delayed ever more. Oh well, judge for yourself.
I probably just should not try to add "small things" between real periods of work on ADOM II ;-)