April 24, 2018

The DayKnight 30-day project - Week 2

Following the initial plan, I worked on effects this week. Effects (buffs/debuffs) can have positive or negative consequences, like stat boosts, damage over time and so on. Skills can apply effects, and effects can also apply other effects.

I made a few improvements in other places as well. A gif should say way more than a thousand words;

GIF of new features

Notice that text is more animated now? I’ve also made changes to existing skills and started adding new ones, I’ll talk more about this next week.

Ordering of combat steps

One of my goals for this game is to have deterministic, turn based, combat. This means that there is no random number generator involved. There are no critical hits, random misses, or random ordering.

Who goes first is determined by the dexterity stat, however if they are equal, both players act at the same time. This is especially challenging to implement, combat (skills and effects) has to be broken down into multiple steps. The outcome should be completely deterministic regardless of what functions are technically called first. Current steps for case when both players act at the same time:

  1. Calculate outcome of skills for both players - amount of damage, healing etc. to apply
  2. Apply outcomes of skills - Use data from step 1 to deal damage, heal, etc.
  3. Add any queued effects to players (Skills can queue effects to be added)
  4. Remove any expired/duplicate effects
  5. Outcomes of effects are calculated
  6. Stats are reset to base before reapplying effects
  7. Effects are applied (damage, healing, etc.)
  8. Add any queued effects to players (effects can add other effects)
  9. Remove any expired/duplicate effects

Luckily, the logic for calculating and applying effects and skills is very similar. They are even using the same base class internally.

The important takeaway here is that outcomes of skills and effects are calculated for both players, before being applied. This way, skills can be based on remaining health, mana, etc. and outcomes will still be consistent. An interesting consequence of this system is that no skills or effects can set a stat to a value, when applying they can only add or subtract as these are commutative operations.

Next week

As stated in the intro post I will be working on progression next week. The most important features would be to implement skill unlocks, and more interesting content after that.

Changelog

Just like last week here is a changelog generated from my git history:

Generated using git log.

© Ole Herman Schumacher Elgesem 2021

Powered by Hugo & Kiss.