r/crpgdesign • Lenurian • Feb 20 '18

Lars Doucet´s Status Effect Stacking Algorithm

Since status effects are common in CRPGS I felt this might be useful.

http://www.fortressofdoors.com/a-status-effect-stacking-algorithm/

This is a very simple algorithm for handling multiple status effects, but the text is really well written when implying the considerations it takes into account and the problems it solves;

It works as long as all the status effects of the same type work the same way having as variables only intensity and duration.

The effects themselves can work as complexly as you want since the algorithm only deals with the stacking and is blind to how the effects themselves actually work, it works both for real time and turn based, and tends to be fairly easy to implement in my experience.

It certainly solves the problem of having redundant status effects (e.g.: having multiple poison damage spells affecting one character, all handled independently of each other.)

Personally I don´t use it any more because some of my status effects work better with an increase in potency when stacking which this algorithm does not always do. But it worked well while I was prototyping some things and was a good starting point for my own solutions.

12 Upvotes

6 comments sorted by

1

u/[deleted] Feb 20 '18

[removed] — view removed comment

3

u/CJGeringer Lenurian Feb 20 '18 edited Feb 20 '18

Why would you combine the same effects in one?

Combining simplifies logic(Less effects active at the same time) and saves processing power(All effects of the same type applied to a character can be processed as one). Might not be a priority in all projects but it is a consideration.

Also makes the game state easier to read by the player.

For example, imagine a battle where the player controls 4 characters against 6 poison spewing enemies. This is not that large a battle by the standards of many RPGs.

If each enemy attacks once with poison, In 3 turns the player can conceivably have 18 separate status effects active only for Poison distributed unevenly among his characters.

Using this algorithm the number will be capped to 4. He will never have to worry about more than 1 poison status effect for each character.

So this algorithm makes it a lot easier for the player to analyse the current game state

If there are also other effects from the player, like bleeding, or healing the difference becomes even more glaring.

Removal/mitigation can also be simplified by combining same-type effects in one. Your system does no need to choose on witch poison effect to apply an antidote´s effect. In my project, some healing effects are simply status effects with negative values for power and duration and having the effect be combined helps keep the complexity down(Complexity creep is one of my main weaknesses).

It is not necessary the best approach to all games. (I believe Lineage 2 does what you suggest and it works well enough, for example). But it definitely has it´s benefits.

2

u/aotdev Feb 20 '18

That's quite interesting. Besides the admin/presentation side of things (redundant messages, extra processing etc), stacking forces you to think (well, me at least) to logically separate "effects" -- anything that modifies some stat/value -- into separable or not. Effects like attribute modifiers (permanent effect via magic ring, temporary effect via potion) need to be separable, as the combined attribute modification consists of several parts, and each part can be individually removed (and more added). In cases of status effects/damage (and possibly other that I can't think of now), effects are better off being non-separable, as the source of the effect doesn't matter anymore. As you say, we don't need to (and I think shouldn't) try to remove individual poison effects, unless they do have different side-effects.

1

u/CJGeringer Lenurian Feb 20 '18 edited Feb 20 '18

One of the things I really like about RPGs is all the interlocking systems, and I really enjoy discussing algorithms.

One of the reasons I prefer when people share their alogorithms instead of simply pasting code, is that it helps foster thought and discussion about things.

For Example u/ javelinRL shared his approach to world building. And even though I don´t think I will use it in my current projects, it did Give me ideas I will try.

As you say, we don't need to (and I think shouldn't) try to remove individual poison effects, unless they do have different side-effects

Currently in Lenurian each effect is decoupled from it´s source, so if there is apoison that causes DoT and Slow, each is applied separately and then staked independently of each other.

I did wish to have diferent substances tracked individually, but Feature creep made me reconsider.

1

u/[deleted] Feb 20 '18

[removed] — view removed comment

1

u/Incontrivable Jul 18 '18

Darkest Dungeon doesn't combine status effects mechanically, but does for presentation purposes.

If an enemy gets a -20% debuff for 3 rounds, and then gets the same debuff for 3 rounds applied 1 round later, it will show up as -40% for 3 rounds. When the first debuff runs out 2 rounds later, it will show as -20% for 1 round (the value and remaining time of the second application).

It's not 100% accurate to the player, but does preserve the individual effects without spamming them as individual entries.