EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development::Development (https://www.eqemulator.org/forums/forumdisplay.php?f=590)
-   -   Some problems with the combat code: (https://www.eqemulator.org/forums/showthread.php?t=35992)

Furniture 11-14-2012 05:04 PM

Some problems with the combat code:
 
I have been analyzing the combat code as of late, and there are some things that look like need to be addressed to make it more live like.

1)EDIT - accuracy problem solved

2) Mitigation - I am also seeing issues with the Mitigation formula not properly reducing the damage to the proper interval. A level 40 with banded armor gets nearly identical damage mitigation to a level 40 with fine plate. I know this amount of AC difference is trivial at high end game, and changes must be made accordingly to end game content, but in its current state this is no where near live.

It is a messed up formula where if you are less then max level, playing in lower expansion zones, having a little bit of AC will give the same effect as having a high ac. For any server using this code and stock lower level zones/gear drops the 1-60 game is severaly 'bugged' so to speak.

Kayen 11-14-2012 05:27 PM

Your 'agility' statistic and your 'defensive skill' which makes up a portion of your AC value is what contributes to your 'chance to avoid melee' in the source.

Accuracy from items and spell effects is accounted for as well.

When YOU are attacked it checks the difference in level between YOU and attacker at derives the base line chance that you will be hit.

Then it subtracts from that value YOUR ( AC component[agility factor, defensive skills], spell and item bonus AVOIDANCE)

Then it adds back to that value the ATTACKER accuracy modifiers. (Accuracy from items / spells, Chance to Hit spell effects).

The final chance to hit value is then rolled to determine initial hit vs miss.

Furniture 11-14-2012 05:51 PM

Ok that makes sense, however it seems like the formula is changed a lot in the chance to hit code, where in the avoidance code it calculates it as:

int avoidance = (acmod() + ((GetSkill(DEFENSE) + itembonuses.HeroicAGI/10)*16)/9);

So does that mean the calculation of avoidance with this formula (which is the correct formula based on research) has nothing to do with combat and just for show in your AC values?

Furniture 11-14-2012 06:10 PM

When it comes to mitigation, what I'm looking to fix for low to mid game combat is basically:

1) Take more damage if mitigation rating is low

2) Take less damage if mitigation rating is high


Since these are tuned for higher level combat where you are expected to have very high mitigation it seems correct but like I said for lower level combat it is off.

I'm convinced theres somehow I can alter something in the following somehow to achieve my desired effects, but I havent figured it out yet:

Quote:

float d = 10.0;
float mit_roll = MakeRandomFloat(0, mitigation_rating);
float atk_roll = MakeRandomFloat(0, attack_rating);

if(atk_roll > mit_roll)
{
float a_diff = (atk_roll - mit_roll); //200
float thac0 = attack_rating * RuleR(Combat, ACthac0Factor); // 440
float thac0cap = ((attacker->GetLevel() * 9) + 20);
if(thac0 > thac0cap)
{
thac0 = thac0cap;
}
d -= 10.0 * (a_diff / thac0);
}
else if(mit_roll > atk_roll)
{
float m_diff = (mit_roll - atk_roll);
float thac20 = mitigation_rating * RuleR(Combat, ACthac20Factor);
float thac20cap = ((defender->GetLevel() * 9) + 20);
if(thac20 > thac20cap)
{
thac20 = thac20cap;
}
d += 10 * (m_diff / thac20);
}

if(d < 0.0)
{
d = 0.0;
}

if(d > 20)
{
d = 20.0;
}

float interval = (damage - minhit) / 20.0;
damage = damage - ((int)d * interval);
}

Any suggestions?

Furniture 11-14-2012 06:56 PM

Here is some parsing info:

I parsed a few different levels, 1-50 and found identical results.

Heres an example, a lvl 26 max defense character vs a white con lvl 26 warrior mob, on all values i parsed for a while until the data was rarely changing after time, my consistent results leads me to believe I have parsed for a significant amount of time


Quote:

Ungeared: AC - 323 Mitigation - 11
AVG Hit from mob - 37
Max Hit from mob - 52
Quote:

Full set of banded: AC - 466 Mitigation - 154
AVG Hit from mob - 25
Max Hit from mob - 52
Quote:

Full set of fine plate: AC - 537 Mitigation - 225
AVG Hit from mob - 24
Max Hit from mob - 52

As you can see, there was no significant damage mitigation increase from 154 mitigation to 225 mitigation, but there was a significant increase from 11 to 154.

What could be the cause?

ChaosSlayerZ 11-14-2012 07:15 PM

i would have simplified/rewritten entire combat formula from scratch and make it much
more straightforward and not level based at all, so ac/stats play more significant role....
Of course it won't be live-like anymore.... so forgive me for ranting ;)

KLS 11-14-2012 07:28 PM

In all fairness so would I but alas. The reason why there's a huge jump from ungeared to geared then a small one beyond that is because there are very severe AC softcaps in play.

Furniture 11-14-2012 07:37 PM

The plate softcap for raw ac is 300, im not hitting anywhere close to that with my fine plate.

Unless Im missing something I dont see how the softcaps are effecting my mitigation, seeing how
Quote:

if(armor > softcap)
{
should be coming out false



I think I will mess with the ACthac20Factor and ACthac0Factor rules and see if I can get desired effects that way.

Furniture 11-14-2012 08:41 PM

unless the softcaps kls mentioned is the thac0cap and the thac20cap?

EDIT - I removed the thac0cap and the thac20cap and still no change in parse data

lerxst2112 11-14-2012 09:34 PM

Quote:

Originally Posted by Furniture (Post 214339)
should be coming out false

No reason to ever say "should be". Add some code to tell you for certain if it is true or not.

Furniture 11-14-2012 10:34 PM

well i understand how this works enough to know that im not hitting that armor softcap so I wonder if theres another cap that im not seeing thats effecting this somehow

Furniture 11-15-2012 01:27 AM

EDIT - Nevermind, still need help here


I'll probably just have to add a + % bonus on armor rating while raising npc's attack rating so they hit for proper intervals, will be a lot of testing at varius levels to get things right but thats probably how ill have to do it

Furniture 11-15-2012 03:45 AM

Update: I figured it out, also parses on a nice bell curve for distribution like in on live/classic, just have to fine tune it

trevius 11-15-2012 03:53 AM

As far as parses for lower level content goes, you may want to refer to this thread as well, which I believe mostly deals with chance for min/max hits based on level:

http://www.eqemulator.org/forums/showthread.php?t=35666

game 03-23-2013 07:54 PM

EpicEmu has a fix for this which will be released after more testing, you can read up on the changes on the forums, you may need to sign up to read it: https://epicemu.com/forum/ac-new-dam...ing-code-tests

The graphs show how the new code will reduce damage based on armor, so a full plate wearer will take less damage than a chain -> leather -> cloth -> etc. It factors in for the levels automatically and shifts the chance to miss making mobs chance to hit YOU scale with its level rather than be a flat % like most servers use now.

AudioGarden21 04-15-2013 12:57 PM

Fyi
 
Here's an updated link to the EpicEmu fix mentioned above.

AC - Dynamic Hit Modification

Furniture 06-09-2013 02:35 AM

I ended up not actually fixing it and giving up.

This is still a major issue and this issue is known among eqemu players, causing them to not care about AC.

Its great that kegz has fixed the issue on his server, but that doesnt help anyone else.

Can anyone please share a working fix so we can all have AC function properly?

jsr 06-09-2013 08:05 AM

Str opposes mitigation, so.. You could run a query to reduce str

Code:

Update npc_types set astr = astr - 10 where level = (level you have issues with)
Do that, parse, if damage is still too high then repeat.


Backup tables first :). And I'm not sure of implications of negative str

jsr 06-09-2013 01:37 PM

A good way to parse;

1.Copy a mob
2. Set min dmg to 1, max dmg to 20, str to the value you want to test
3. Set attack speed to -99 (fast)
3. Create an item with 999 regen and 9999hp . I use one of these for ac 10-1000 in increments of 10
4. Adjust regen cap in server rules to 999
5. /log on, equip item, spawn mob and attack.
6. #damage mob when you want to end fight.

I do this for mitigation testing, it is pretty fast. Gamparse will give you a breakdown of the # of huts at each dmg interval from 1-20. You can graph this to see where the bell curve is compared to live, and increase/decrease str until it is close to where you want it.

KLS 06-13-2013 01:33 AM

I'd like to revisit this, but I'd also like to start some discussion of what exactly we need to fix and how we're going to go about it.

1) AC doesn't have enough of an effect on actually mitigating damage.

-> Two ways to address this, we can either increase the effect of AC within our current formula or we can come up with a new one.

2) Hit chance has somewhat hard to predict scaling and can be kind of a nightmare to balance.

-> I don't think there's a way to really address this without redoing the existing formula which might be disruptive to servers that have balanced around the old (whacky as it may be) formula.

3) The order of avoid damage and check hit chance has always been swapped from what it is on live.

-> This is just a matter of rewriting a lot of the combat code to swap them.

jsr 06-13-2013 02:20 AM

IMO if the goal is to emulate live for mitigation, there are really two options;

1) Put together test scenarios and methods to perform some controlled parsing on live. This requires significant collaboration and effort to get sufficient data in the right way.

2) Look at AC on existing items, assign an expected PC level range to these items to derive a scaling factor per level, and design the inputs from mob stats (str/offense in existing code) to scale at the same rate.

Happy to clarify if this is unclear.

Furniture 06-16-2013 03:42 PM

The way I see it, this is something that is blatantly not working the way it should be. The way it stands, there is no reason to try to increase a characters AC in game and that is a huge flaw. I understand that established servers have their own makeshift balances around this to make it work, but that still leaves this flaw intact. Maybe theres a way to rewrite this and give older servers a way to keep the old code for their servers?

Also I am not understanding this correctly about the STR. Do you mean that if you lower mobs strength, AC will parse with significant damage reduction in regards to the different armor types that I originally parsed with?

The way I have been doing it as of late is by adding a huge bonus to player AC directly in the code. That seems to be working thus far, but for high end game I'm not sure how it would work out.

Kegz from the sleeper says that he will be releasing his fix sometime. Hopefully he has a good solution

jsr 06-16-2013 07:52 PM

Yes STR is opposed to AC in the calculation. If you reduce mob strength you will see an improvement in mitigation.

Basically; STR + Offsense - AC - Defense = mitigation.

In my opinion, you're exaggerating the extent of this issue when you say things like 'there is no reason to try to increase a characters AC in game and that is a huge flaw'.

Furniture 06-16-2013 08:14 PM

I do admit I did exaggerate a bit, but the parse clearly shows in its current state trivial mitigation between banded and fine plate and to me that is definitely a huge flaw. Perhaps the issue all along was the STR of the mobs being too high, I will test and see how it goes, thanks.

ChaosSlayerZ 06-17-2013 12:53 AM

thats because the difference between banded and fine plate is insignificant in raw numbers - its what like 25-30 extra AC? It is a gain but its about maybe 5% improvement. Thats how EQ always was - stats are almost irrelevant unless you have a ton of them.
Not saying its good system, but thats just how it is.

Goryani 06-18-2013 02:37 PM

Quote:

Originally Posted by Furniture (Post 214334)
Here is some parsing info:

I parsed a few different levels, 1-50 and found identical results.

Heres an example, a lvl 26 max defense character vs a white con lvl 26 warrior mob, on all values i parsed for a while until the data was rarely changing after time, my consistent results leads me to believe I have parsed for a significant amount of time


Ungeared: AC - 323 Mitigation - 11
AVG Hit from mob - 37
Max Hit from mob - 52

Full set of banded: AC - 466 Mitigation - 154
AVG Hit from mob - 25
Max Hit from mob - 52

Full set of fine plate: AC - 537 Mitigation - 225
AVG Hit from mob - 24
Max Hit from mob - 52


As you can see, there was no significant damage mitigation increase from 154 mitigation to 225 mitigation, but there was a significant increase from 11 to 154.

What could be the cause?

Unfortunately, these results are not sufficient to determine if any problem exists.

Due to the way the D20 system works, infinite AC should result in an average damage per hit around the 4th DI interval. No min hit is listed but a mob that hits for 52 max and average of below 32 should have a min hit around 14. That would put DI = 2. The 4th DI would be ~18 damage. Therefore, infinite AC should result in an average hit of 18.

Mitigation is subject to diminishing returns (and not just because of any softcaps). A min hit can't be mitigated any lower. Extra AC has zero effect on min hits at the old AC value. It doesn't seem unreasonable that banded is already well into diminishing returns territory. The test needs to be repeated with leather and silk equivalent. It also needs to be repeated for upgrading more than the 7 slots covered by banded/fine plate.

Quote:

Originally Posted by Furniture (Post 221782)
I do admit I did exaggerate a bit, but the parse clearly shows in its current state trivial mitigation between banded and fine plate and to me that is definitely a huge flaw. Perhaps the issue all along was the STR of the mobs being too high, I will test and see how it goes, thanks.

A 4-5% increase in mitigation is not trivial. It's actually quite large. How many extra swings does it take to kill the fine plate geared toon compared to the banded toon? How much time is that?

Furniture 07-10-2013 11:11 AM

Quote:

Originally Posted by jsr (Post 221780)
Yes STR is opposed to AC in the calculation. If you reduce mob strength you will see an improvement in mitigation.

Basically; STR + Offsense - AC - Defense = mitigation.

In my opinion, you're exaggerating the extent of this issue when you say things like 'there is no reason to try to increase a characters AC in game and that is a huge flaw'.

While this makes sense, when increasing or decreasing a mobs strength by large amounts, I have seen absolutely 0 change in mitigation. (From Mobs). I'm not sure why that was happening as I didnt spend a whole lot of time with it. (just in game changed mobs STR to 1 or 999). It seems to work pretty well for client attacks though

Furniture 07-10-2013 11:14 AM

Quote:

Originally Posted by Goryani (Post 221817)

Due to the way the D20 system works, infinite AC should result in an average damage per hit around the 4th DI interval. No min hit is listed but a mob that hits for 52 max and average of below 32 should have a min hit around 14. That would put DI = 2. The 4th DI would be ~18 damage. Therefore, infinite AC should result in an average hit of 18.

Mitigation is subject to diminishing returns (and not just because of any softcaps). A min hit can't be mitigated any lower. Extra AC has zero effect on min hits at the old AC value. It doesn't seem unreasonable that banded is already well into diminishing returns territory. The test needs to be repeated with leather and silk equivalent. It also needs to be repeated for upgrading more than the 7 slots covered by banded/fine plate.



A 4-5% increase in mitigation is not trivial. It's actually quite large. How many extra swings does it take to kill the fine plate geared toon compared to the banded toon? How much time is that?

While this seems like it would be correct, when you actually add in absurd amounts of AC directly, mitigation is reduced to the first interval 100% of the time.


The way I've dealt with this whole thing which works quite well, is by adding a bonus to the amount of AC. At varying levels of increased AC, there is significant mitigation differences between armor sets.

jsr 07-10-2013 10:59 PM

Quote:

While this makes sense, when increasing or decreasing a mobs strength by large amounts, I have seen absolutely 0 change in mitigation.
Quote:

It seems to work pretty well for client attacks though
I'd expect this outcome if you changed an NPC's stats without doing a #repop.

wtbmacestun 02-23-2014 11:26 PM

I have a copy of the code kegz used to fix ac on his server if anyone is interested.

Actually I found it in his github as well. Here you go

https://github.com/epicemu/Server/bl...one/attack.cpp

Code:

if(RuleB(Combat, UseIntervalAC)) {                       
                        //int8 leveldif = ((other->GetLevel()) - (this->GetLevel())); // //AC Damage Reduction Level Diff - Kegz @ EpicEmu.com
                        damage = ((max_dmg+eleBane) - (otherac * acdiv/100.0f)); //AC Damage Reduction - Kegz @ EpicEmu.com
                }
                else {
                        //float acdiv2 = 0.25;
                        //int otherac = other->GetAC();
                        //damage = ((max_dmg+eleBane) - (otherac * acdiv2/100.0f));
                        damage = ((max_dmg+eleBane) - (otherac * acdiv/100.0f));
                }               

                //check if we're hitting above our max or below it.
                if((min_dmg+eleBane) != 0 && damage < (min_dmg+eleBane)) {
                        mlog(COMBAT__DAMAGE, "Damage (%d) is below min (%d). Setting to min.", damage, (min_dmg+eleBane));
                    //damage = (min_dmg+eleBane);
                        damage = ((min_dmg+eleBane) - (otherac * acdiv/100.0f));
                }
                if((max_dmg+eleBane) != 0 && damage > (max_dmg+eleBane)) {
                        mlog(COMBAT__DAMAGE, "Damage (%d) is above max (%d). Setting to max.", damage, (max_dmg+eleBane));
                    //damage = (max_dmg+eleBane);
                        damage = ((max_dmg+eleBane) - (otherac * acdiv/100.0f));
                }


moofta 02-25-2014 01:52 AM

Quote:

Originally Posted by KLS (Post 221670)
-> I don't think there's a way to really address this without redoing the existing formula which might be disruptive to servers that have balanced around the old (whacky as it may be) formula.


Perhaps it could be set up as a define that you could enable/disable using cmake? So in effect you could choose between the two systems when compiling, opting out if you've already done the tweaking.

wtbmacestun 02-25-2014 02:20 AM

kegz used the code i posted in the forums and defined acdiv in the sql table so you could adjust it until it was right. I think, i cant remember, but i think he had it set at 20. just play around with it and it will work. you dont have to revamp anything unless youve completely reedited the stats of mobs so they seemed normal. in which case you fucked up your server instead of fixing the problem to begin with.... which i would guess is every server including p99. One of the reasons why kegz and i wanted to fix this on his server before messing with mob stats and other settings.


All times are GMT -4. The time now is 11:36 PM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.