otland / forgottenserver

A free and open-source MMORPG server emulator written in C++
https://otland.net
GNU General Public License v2.0
1.57k stars 1.05k forks source link

Stepping into firefield while having fire condition from soulfire does not inflict damage #2651

Open djseban opened 5 years ago

djseban commented 5 years ago

Hey there,

recently I stumbled across the bug with conditions. Steps to reproduce:

  1. Get hurt by soulfire rune.
  2. Get hurt by firebomb and try to walk on fire fields

In this scenario player does not receive any damage from fields, and after a while player gets damage until he dies. Any ideas on how to fix it :)? Tested on newest rev of tfs 1.3.

I also found gif of this bug: https://imgur.com/2yEcJWy

Ochmar commented 4 years ago

I think soulfire should be it's own CONDITION, not the fire one. Correct me if I am wrong.

joseluis2g commented 4 years ago

Can you explain us how it should be.

TheSumm commented 4 years ago

The main issue with magic fields is that all the damage is applied through a damage condition, even the initial stepin damage. Conditions are only replaced if the newly applied condition does more total damage. Soul fire generally does more damage than a simply fire field due to its long duration. Thus, when the player is already affected by soulfire, the fire field condition will not be applied. This behaviour is correct, however the player should still suffer the initial stepin damage.

Zbizu commented 4 years ago

afaik in rl the most recent condition takes priority only when it has more damage to deal than already happening one (giant spider poison > poison field > poison spider poison) so a function to check remaining damage would be needed to assign condition priority

(or a simpler solution - total condition damage, if equal or higher than previous - overwrite, otherwise ignore)

TheSumm commented 4 years ago

That behaviour is already in place: https://github.com/otland/forgottenserver/blob/master/src/condition.cpp#L1011

Olrios commented 4 years ago

In real Tibia when you have soulfire condition on you, and when you step on firefield you getting 20 fire damage (or 10 if firefield is small) and everytime you step on it (on firefield). 1/2 dmg applies for PVP of course.

Soulfire applies 10 dmg ticks every 9 second, amount of ticks increases with you level and magic level. Formula for amount of ticks is very simple:

For mages: AMOUNT OF TICKS = (LEVEL + MAGIC) / 3 For paladins: AMOUNT OF TICKS = (LEVEL + MAGIC) / 15 For knights: AMOUNT OF TICKS = (LEVEL + MAGIC) / 20

Becouse we are using Open Tibia for custom servers it will be better to move the formula to LUA. With condition loop.

When you have soulfire dot and it's going to hit you only 4 more times and if you step on firefield which applies 7x 10dmg (each tick every 9 sec) then your condition will be equal to 7x 10 dmg.

If you have condition from firefield for 7x 10dmg and you get hit by weak soulfire for 5x 10dmg then your condition will be 7x 10dmg.

If you stay on big fire or medium fire you getting hit by 10 dmg every 9 second for infinity. If the firefield disappear then you getting 7x 10 dmg after firefield disappear.

If you staying of firefield and someone hits you with soulfire for 50x 10dmg then you getting hits for infinity or when firefield disappear then you getting 7x 10dmg or remaining soulfire Xtick for 10dmg. Always higher will be chosen.

If you have soulfire for 3x 10dmg and you enter big firefield you are getting initial 20 dmg and then damage over time for infinity or unitl firefield disappear, then only 7x 10dmg after field disappear.

Firefields and other fields (psn energy etc) are bugged in almost all OTS and they never were fixed after Yurots (idk started from 2007 year?)

nekiro commented 4 years ago

I just checked what @Olrios said. Field conditions are infinite when you stay on them. Code Snippet: https://github.com/otland/forgottenserver/blob/master/src/condition.cpp#L1106-L1107

Condition also continues after the field is gone.

Though this:

If you staying of firefield and someone hits you with soulfire for 50x 10dmg then you getting hits for infinity or when firefield disappear then you getting 7x 10dmg or remaining soulfire Xtick for 10dmg. Always higher will be chosen.

Makes no sense, like if you stay on firefield and you got "stronger" condition from soulfire, why would it choose to execute fire field condition which is weaker? In my opinion it should be executing soulfire after it ends, then inflict fire condition from the field. Are you sure about that?

About energy fields, you can fix that by simply editing items.xml

So conditions in general are working like they should?

About the bug: https://nekiro.s-ul.eu/KMdMY3SV I cant reproduce it or am I doing something wrong?

Olrios commented 4 years ago

Why no sense? If you staying of firefield which wont disappear then infinity is always higher then any other value. Infinity will be always "stronger". But what if soulfire will be very weak like 3x 10dmg? In this case again you didn't understood, becouse firefield again in this case - isn't weaker like you said. Also "soulfire condition" isn't executed after "firefield condition" ends becouse there are no two conditions but only one - fire condition. Also from code view its still just one. All what I wrote is how it works exactly in real Tibia. And in OTS conditions are not working like they should.

For me if you getting hit from fire condition code should check for "is player staying at firefield". If yes then fire condition should be updated and code should choose stronger DoT (firefield or remaining soulfire if applied). But still both firefield and soulfire should be handled in code as a one condition.

Soulfire applies 50x 10dmg fire condition and when player enters firefield then code should choose highest value (between 50x 10dmg and 7x 10dmg). If that player decide to stay at firefield then during next DoT hit code should choose between 49x 10 and 7x 10. Then 48x10 and 7x10 ... Then 6x10 and 7x10

Important. Becouse killing players with single firefield was common in the past. In some Tibia update staying on fire/psn/enefield no longer results in infinite condition (or for as long as field exist). I have no idea when that change happened and I don't know how it work for each field subtype (PVP field, world field, nonPVP field etc).

gerotib commented 4 years ago

@nekiro

I cant reproduce it or am I doing something wrong?

You cant soulfire yourself, you were burning already, so that was "regular" burning condition from fire field. Try with another character.

Biggest "ingame" problem with this whole issue I think is that you can "heal" yourself from soulfire by stepping on fire field, so burning time is reduced to only fire field burning duration. So soulfire rune is pretty much pointless, you can just throw fire bomb under enemy player.

EPuncker commented 4 years ago

is this somewhat involved with #2540 issue too?

nekiro commented 4 years ago

@EPuncker its not, but actually I fixed that issue in my recent pr, gonna link this issue too, thanks

EPuncker commented 2 years ago

@EPuncker its not, but actually I fixed that issue in my recent pr, gonna link this issue too, thanks

just tested it and the bug is still there, having soul fire, fire field doing no damage