WTF is going on with status effects

This forum is for talking about the game itself. Tips, strategy, story, whatever.

WTF is going on with status effects

Postby larsiusprime » Wed Apr 18, 2012 9:10 am

Hey guys, I keep hearing reports about status effect stacking not working, and I need to just get to the bottom of this and FIX this stupid bug once and for all as it's leading to some very weird strategies as people try to work around it.

So, here is how the algorithm is supposed to work:

A status effect, once applied, has two values, potency (P) and duration (D). An effect can be expressed like this: poison(0.5,1.0) for a poison with P=0.5 that lasts for 1 second.

"Potency" is interpreted in different ways depending on the effect. For chill, it slows enemies down. For poison, it's a multiplier against the associated attack damage (an attack that deals 10 damage, with poison(0.1,5), will deal 1 additional damage every second for five seconds). For bleed, it's how much extra damage they take. So bleed (1.05,5.0) means +5% damage from all incoming attacks for 5 seconds.

So, let's say Slak hits an enemy with bleed(1.05,5) and then Conan (generic berserker) hits an enemy with bleed (1.10,3). How are these combined?

Well, first we convert both values to (potency)x(duration):
Slak: 1.05 x 5 = 5.25 PD
Conan: 1.10 x 3 = 3.30 PD

Then we sum the PD values:
5.25 + 3.30 = 8.55 PD

Then, we match the highest potency of the two effects and convert the PD back into potency and duration:
Potency = 1.10
Duration = (8.55) / 1.10 = 7.77

So Slak's weaker bleed was converted into extra duration for Conan's stronger bleed. I decided to favor potency rather than duration because if we matched the longest duration then status effects could dilute one another - you'd still get the same DOT, but it would lead to weird situations where a "weaker" slow would cause the enemy to actually speed up.

At any rate, something is clearly broken as status effects are cancelling each other, diluting, or otherwise not stacking as intended. Anyone got any cases for me where the behavior is weird and not what it should be? I can figure out the code problem once I have some solid bugs to look at. I'm discussing this here rather than just in the bug forum because I'm wondering if there's some hidden "gotcha" in my algorithm I'm not considering and it seems like a pretty fundamental gameplay issue.

Basically, my goals for status effects are this:

  • Players should never have to worry about status effects interacting (other than obvious intentional stuff like fire/ice)
  • Should always help the player, or at least not hurt the player
  • Shouldn't give a "strange" result even if the mathematics is "right" (ie, an additional slow causing an enemy to speed up)
  • Shoudn't lead to easy exploits through exponential stacking
larsiusprime
 
Posts: 810
Joined: Mon Feb 13, 2012 10:13 am

Re: WTF is going on with status effects

Postby frostlion » Wed Apr 18, 2012 11:09 am

Hi larius,

Great to hear you're looking into this and your algorithm makes a lot of sense. Here's one example of a case where it goes wrong; I made it as simple as possible.


Situation 1
I'm playing the Extreme Storm the Sheep level, I have some berserkers on the side to clear out extra sheep. I summon one level 40 Ice Mage with no equipment on and with the following spec:
1 point Ice ball
1 point Ice shard
1 point ice splash
1 point blizzard
3 points chill (50%)
(other points unspent)

The mage starts attacking Axxima Mutanaxxor with ice ball and slows him to 0.05 speed and he turns blue.
I upgrade the mage to rank 2 and let her throw some ice shards, the slow persists. (ice shards don't seem to matter one way or another, so I won't write them down in the below)
I upgrade the mage to rank 3. A second or two after the upgrade, at the same time the Sleet animation starts, Axxima Mutanaxxor's speed is set to 0.1 and he turns back to normal color.
He gets hit by another ice ball and his speed goes back to 0.05
He gets hit by sleet again while still slowed and this time his speed changes to 0.09. After what I'd guess is about half a second (the sleet slow duration), his speed goes back to 0.1.
He gets hit by another ice ball and his speed goes to 0.05 again (it stays that way after another ice ball hit.)
Sleet: 0.09 goes to 0.1 after half a second.
ice ball: 0.05
Sleet: 0.09 goes to 0.1 after half a second.
ice ball: 0.05
Sleet: 0.1 directly
It switches between those two options for a bit.

It seems that depending on whether the 50% chill chance of sleet triggers or not, either the speed goes to 0.1 or 0.09


situation 2
Same setup, but now I have a second mage with 9 points in chill (65%) and I keep both of them at rank 1.

I place the second mage and let her shoot the sheep. Its speed decreases to 0.03.
I recall the mage and after the sheep walks roughly its own length, the freeze goes away.

I place the second mage again and let her shoot the sheep. Its speed decreases to 0.03.
I now add the first mage and she shoots the sheep. Its speed jumps up to 0.05 and stays there, even when the second mage hits the sheep again with her more powerful slow.
I let both mages pommel on the sheep for a while, its speed stays at 0.05
I recall both mages. The sheep now walks roughly four times its own length at 0.05 speed before the freeze goes away.

I repeat the same, but without the pommeling this time (so as soon as the sheep jumps from 0.03 speed to 0.05 speed, I recall both mages). This time, it only stays frozen for less than half it's length.

situation 3
I won't bore you with the details, but if we add sleet back into the mix, I now get stuck at 0.9 speed pretty quickly and I can boost up the time that lasts pretty significantly as the sheep is hit by ice balls from two mages.



conclusions
It seems like you're picking the highest rather than the lowest speed, but the time calculation is done properly, leading to slows being weaker than they should be, but lasting a lot longer, provided the stronger slow stacks onto the weaker one and not the other way around. In that second case, you will actually see a short time and the slow can end altogether.

a second minor points is that it seems like you recalculate slows even when a slow effect misses (like for sleet). That shouldn't have to be a big problem if you solve the first one, but it should probably be fixed all the same, because it might lead to problems if you ever decide to change the way slowing stacks.
frostlion
 
Posts: 12
Joined: Mon Apr 16, 2012 9:09 am

Re: WTF is going on with status effects

Postby larsiusprime » Wed Apr 18, 2012 11:21 am

Interesting! Does the status effect problem only happen with slows? Ie, does it affect bleed, poison, etc in similar ways?

I should get some way to show what status effects are active on a monster. Would be very useful to the player and make this waaaaay easier to debug.

I think I might have stumbled across something:

Bleed has potency values all > 1, and then uses that as the enemy's multiplier towards incoming damage, (ie, I have bleed of 1.05, so I take 105% damage as opposed to the normal 100%).

HOWEVER, chill has potency values all < 1, so this becomes the enemy's multiplier for speed. This is all well and good until I stack them, because the algorithm matches the HIGHEST potency value - so if it's not making special checks for chill, what's going to happen is that it will match the WEAKEST slow (which is technically the higher number).... so that's dumb.

Example: a chill potency of 0.9 means "slow by 10%" whereas a potency of 0.5 means "slow by 50%", but the algorithm will think the first one is the strongest.
larsiusprime
 
Posts: 810
Joined: Mon Feb 13, 2012 10:13 am

Re: WTF is going on with status effects

Postby frostlion » Wed Apr 18, 2012 11:38 am

The way you describe it, it would make sense for this to only affect slows then.

I'll do some tests with poison now and see if I can get a poison value to decrease. I doubt it though.
frostlion
 
Posts: 12
Joined: Mon Apr 16, 2012 9:09 am

Re: WTF is going on with status effects

Postby frostlion » Wed Apr 18, 2012 12:09 pm

Poison seems to be working fairly well.

Level 1 halitosis on a lvl 40 dragon gives 6 ticks of 18 damage when recalled after one hit. 24 ticks of 18 damage when recalled after 4 hits.
Level 9 halitosis on a lvl 40 dragon gives 6 ticks of 45 damage when recalled after one hit.

A level 1 halitosis first and then a level 9 halitosis , gives one tick of 18 damage, then one of ~30 after the second dragon bites and then six of 45.
Weirdly though, if I then let my sheep get bitten by a level 1 halitosis again, it first takes a tick of ~30 before then going on to 5 bites of 18.
It seems like there is some kind of small error in the order things are calculated there, with poison damage being averaged or something for the first tick and only getting to the correct value for the second one. With so many ticks though, it hardly matters.

A level 9 bite first sets the damage to 45 and it stays that way when level 1 bites are added on. Adding a number of level 1 bites increases the number of 45 ticks by about 1 or 2 per bite, as you would expect with its lower potency.

Shooting with level 9 poison shot by a ranger using just basic shot, gives 21 damage per tick, for 18 ticks (consistent with the 18 second duration).

level 1 halitosis followed by poison shot increases the damage to 21 (with the expected tick of only 20 first).

level 9 halitosis followed by poison shot keeps the damage at 45, but extends the duration a lot if you proc enough.



In short, there is just one small calculation error on the first tick of an increased poison value or on the application of a weaker poison after a stronger one has expired. But all the main stuff seems to be working as intended and I have no reason to assume it would be different for bleed.
frostlion
 
Posts: 12
Joined: Mon Apr 16, 2012 9:09 am

Re: WTF is going on with status effects

Postby coyot » Wed Apr 18, 2012 12:36 pm

The calculation errors might not be errors at all, but rather effect application in ticks vs. seconds.

I mean, what is the timing of the hits and timing of the ticks?

If the ticks happen once per second, with countdown starting at first hit, what behaviour should we expect if the second hit happens anywhere "between" ticks?

Time in seconds:
0: hit with poison 18
1: 18 dmg tick
2: 18 dmg tick
2.3: hit with poison 45.

Now, according to the calculation, there was P=18 D=3.7 and P=45 D=6 - total 336.6, with max(P)=45 it gives D=7.48.

But when does the next "tick" happen? If it happens exactly at 3.0 seconds, then in the timespan between 2.0 and 3.0 we had 0.3*18 + 0.7*45 = 36.9 dmg, not 45.
coyot
 
Posts: 466
Joined: Mon Feb 20, 2012 4:48 am

Re: WTF is going on with status effects

Postby frostlion » Wed Apr 18, 2012 12:44 pm

Hey coyot,

That makes a lot of sense, so I checked it and you are right. If I simply let a 6-second poison expire and then apply a new one, never having had overlapping ones, nothing weird happens.
The only weird side-effect of this is that the (near) analog times do not match up with the discrete (one per second) poison ticks, which means you can lose half of your last poison tick, because the poison ends after, for example, 6.5 seconds, while the last tick was after 6.0 seconds.
It seems like you then only get this last 0.5 second of poison if you apply another poison and it gets tacked onto the start of that.

It would be nicer if there was either a 'weaker' tick when the poison effect ends (6.5 seconds) / the first full second after (7 seconds) or if there was a boost to the last tick (6 seconds). As I said above, not really a big deal though.
frostlion
 
Posts: 12
Joined: Mon Apr 16, 2012 9:09 am

Re: WTF is going on with status effects

Postby coyot » Wed Apr 18, 2012 12:50 pm

larsiusprime wrote:Example: a chill potency of 0.9 means "slow by 10%" whereas a potency of 0.5 means "slow by 50%", but the algorithm will think the first one is the strongest.


This would be easily solved by reverting "negative" effects to be expressed as positive in calculations - so slow by 10% should be expressed as 0.1 (and the transformation done in the actual speed calculation).

BTW, there were some mockups showing status effects on creeps, isn't that in the works? This would make things much easier.

And as a last resort for debugging - wouldn't it be possible to just log everything into a text file, when enabled by a parameter? This would be actually quite useful even for observing other game mechanics and looking for possible bugs.
The log could look like this:
Battle X start.
Time - Subject - action - target - results
00:02:10.240: B1 - A1 - W10.3 - damage 60, Bleed P=0.3 D=5.0
(Or something less cryptic, using names and texts: Zerk - Slash - Wave 10 revenant 3....)

Sure the files could be quite big, but would be of tremendous help - and could be even used by players to figure out attack cycles and stuff, calculate effectiveness of characters etc...
coyot
 
Posts: 466
Joined: Mon Feb 20, 2012 4:48 am

Re: WTF is going on with status effects

Postby larsiusprime » Wed Apr 18, 2012 1:13 pm

Okay! I believe I've fixed it!

From now on, all status effects must have their amounts set according to a "bigger is better" scheme.

So instead of "0.6" meaning "enemy is at 60% of speed", it's now, "0.4", meaning, "enemy is slowed by 40%, or at 60% (100-40) of speed".

Very likely this means Ice Mages will suddenly become super powerful because this whole time they've been unintentionally nerfed!

I'm working on the status effects panel now, and as for battle logs - sounds really cool, but I'm holding off for now as Anthony's tightening my leash to diminish feature creep :)
larsiusprime
 
Posts: 810
Joined: Mon Feb 13, 2012 10:13 am


Return to Gameplay

Who is online

Users browsing this forum: No registered users and 0 guests

cron