dkfans/keeperfx

AK Lvl 13 Sloth - Orcs are too weak to progress the level.

elemanzer opened this issue · 96 comments

According to the lubiki AK walkthrough, the orcs in this level should have no trouble taking out the samurai. Instead, they get absolutely reamed on keeperfx.

Youtube videos for this level (on kfx) also have comments advising against playing the level on later versions of kfx.

See kfx versus vanilla under the same conditions.

On kfx:
https://github.com/user-attachments/assets/4d99b831-2d44-44e3-8d29-89a04e808836

On vanilla:
https://github.com/user-attachments/assets/adf61af5-5271-4677-8530-9c21df3f36a5

The level can still be completed, and people do. You need to split up the Samurai.

That being said, I fully agree that it is not as it was originally even though AK uses the legacy ruleset to emulate the original bugged stats. I would have no problems with further updates to the ruleset to improve this.

It would need somebody who would be willing to compare the legacy balance of all creatures and heroes against each other in low, medium and high levels and see what needs to be tweaked.

@Loobinex

The level can still be completed, and people do. You need to split up the Samurai.

I doubt this is realistic on current keeperfx versions. At the very least it'll take 20-30 tries to get the RNG and micro just right to survive 2 waves of samurai.

AK uses the legacy ruleset to emulate the original bugged stats.

Actually AK seems to be using /levels/legacy_crtr where orcs are set as str = 48 and dex = 45. This is different from the settings in both /config/creatrs and vanilla, both of which set orcs at str = 65 and dex = 60. Restoring just these two attributes makes things run a lot more as expected although a modicum of micro and RNG are still required to keep all 12 orcs alive. See video below:

ak13-kfx-str65-dex60.mp4

It would need somebody who would be willing to compare the legacy balance of all creatures and heroes against each other in low, medium and high levels and see what needs to be tweaked.

How would you go about this? Even if you time hundreds of simulations of creature vs. creature battles on vanilla, the speed spell being persistent on kfx changes the game drastically. An orc vs. samurai could be balanced like legacy since both have speed, but orc vs. wizard? I don't think it's possible to completely mimic legacy balance unless you give each creature dynamic stats based on which creature they are fighting.

@Loobinex

It would need somebody who would be willing to compare the legacy balance of all creatures and heroes against each other in low, medium and high levels and see what needs to be tweaked.

Giving this more thought, is there a way to give creatures perma speed in old DK? Doesn't have to be a permanent bug fix as the goal here is just to meaningfully time battles between permanently sped up creatures on old DK for later transplanting into keeperfx legacy cfgs. From there it would just be a matter of tweaking the attributes in legacy keeperfx until both line up.

@elemanzer yes, people have been defeating this level in keeperfx, and I think it is far too hard too. It is actually easier in current versions of keeperfx compared to very early versions which had no special rule set.

Orcs received lower strength to compensate for the fixing of the strength bug. In the original game they would cap at 255.
But you could set speed spell power to a really low value in the legacy configs I think. Also I am not sure if the strength value was set before the OVERFLOW_8BIT classic bug was introduced.

All in all, yes, it would be quite a time consuming job to balance around all things. Personally I have not been that interested there and would just avoid Ancient Keeper, but I would be more than happy for others to look into this.
One approach would be to restore all creature stats to original, and try to see where that still goes wrong with classic bug mode, and see if that mode could be improved.

@Loobinex

Damn, forgot about the overflow bug...

In any case, regarding the current issue, it looks like legacy config is used only by ancient keeper and post AK. Orcs don't play much of a role in the campaign's levels (at least up to lvl 15, dragonia which is where I'm at in the playthrough) so setting them back to str = 65 and dex = 60 either globally for all ak/pak levels or restricting the change to this specific level seems like it would work well and is the simplest solution. There's room to make the stats a tad lower even, in which case they wouldn't get as much of an advantage over the no-speed creatures in the level (wizards & knights).

As for completely overhauling legacy balance, I'm looking to take this on myself but I'm late to this game and there's a lot I don't know. I'll start a separate issue once I give it some more thought and figure out a possible way forward. A quick question in this vein if you would be so kind, though:

Where do lvl 9 and 10 creatures get their speed spell duration from on keeperfx? In old DK, lvl 9 creatures got it from MAGIC_SPEED power 8 and lvl 10 from MAGIC_PROTECT cost 0. In keeperfx I see only 9 values under /config/fxdata/magic.cfg/POWER_SPEED.

O shit, that is a problem yes. Both level 9 and level 10 creatures get it from the level 9 power, so it's not possible to 'configure' the value.

There's also maps on the workshop that get configured to use 'legacy' if it is found they need classic bugs to work. And people are free to put all custom maps in legacy if they are purists.

@Loobinex

There's also maps on the workshop that get configured to use 'legacy' if it is found they need classic bugs to work. And people are free to put all custom maps in legacy if they are purists.

So in testing the overflow bug was mostly a non-issue in old DK. Despite what the wiki says, lvl 10 Hornys consistently wipe the floor with lvl 6-9 Hornys and lvl 10 Samurai consistently beat lvl 9 Samurai. There are a few cases where lvl 9 creatures consistently beat lvl 10 (mistress9 vs mistress10, troll9 vs. troll10) but these come so close, it could be fixed by simply fixing the speed bug. But for the most part 10 > 9 in old DK. That leaves some imbalance in more obscure cases which is mostly where the overflow bug rears its head (e.g. Horny2 > Horny3, Horny 8 > Horny 9).

Since the legacy config caters to purists, the cleanest solution would be to reintroduce the bugged stats and speed bug that levels have already been designed around. If it's just AK/PAK we're talking about, there's little harm to game balance if you wanted to keep the speed bug fix which would address the few 9>10 cases.

If you agree, I can start an issue outlining the change for more feedback and begin calculating bugged attribute values and testing them on kfx. Lvl 10 creatures would still need a separate column to define the lowered spell power though.

Edit: Would also need a way to define specific attribute values per lvl instead of using a % modifier.

Funny you mention that, I believe a horny already suffers from the overflow bug at level 6, if not 6 then 7.
Also, when you tested, did you make sure you gave them enough time to charge up their speed spell at the start of the level?

Yeah my script uses 600 game turns + 60 before spawning to give things like speed and freeze time to recharge.

With reapers, overflow begins at lvl 3 with a huge drop in dex while strength bug caps to 255 at lvl 4. My best guess for what's happening in lvl 6 v 10 (from looking at the stats) is that both have 255 str, small dex gap of 30 points, and the huge skill/defence disparity is more than made up for with the 3000 additional hitpoints at lvl 10. You can see it in all its glory below.

The problem is that Level modifier provides a uniform increase in stats and therefore can't make a lvl 2 reaper stronger than lvl 3 as it was in old DK and if that's the kind of thing a legacy level was designed around. There's also no way to go from 255 str cap to 622 without expecting major balance issues on levels designed for 255.

The most I can think of is fixing the speed bug and additionally trying to increase the gap between select cases where the OF bug is most apparent - like lvl 2 v 3 or 7 v 8 reaper. Changing stats at both levels something like 5-10% in both directions until the higher level consistently beats the lower level creature again. For this there would need to be a way to explicitly define stats per level instead of using the modifier. Purists who want pure legacy won't be happy though.

reaper-6-v-10.mp4

@Loobinex

Here's a draft of the bugged stat values.

dk-original-bugged-stats.zip

I guess a good start would be to add a 10th power level on powers.

@Loobinex

Here's a draft of the bugged stat values.

dk-original-bugged-stats.zip

Your math seems to check out to me. It is weird though, because 150 is very decent dexterity still, but even in your video you notice the reaper misses almost all his attacks. What gives?

Also, see PR #3472 , would you be interested in finding the values for the bugged spells in dk1?

@Loobinex

A 255 DEX stat against a creature with 1 DEF/SKILL stat yielded a hit chance that looked to be (eyeballing it) about 90%. If we assume hit chance from DEX and dodge chance from DEF are evenly split (big assumption), that lvl 6 HR has a 32% hit chance which is further weighed against the LVL 10 HR's 6% dodge chance. There are likely finer details to the mechanics but this is my best guess without running a study.

#3472

Sweet! Well there are only something like 5 creature spells (including speed) that may be borrowing stats in a buggy way from MAGIC_SPELL with the rest coming from SHOT_SPELL. I'll verify where creatures are getting things like lightning spell power from and update you.

Tested and apart from SHOT_LIGHTNING, everything else comes from MAGIC_SPELL. Here are the bugged values.

spells-bugged.zip

Tested and apart from SHOT_LIGHTNING, everything else comes from MAGIC_SPELL. Here are the bugged values.

spells-bugged.zip

Thanks. I entered the legacy values on the PR.
Are we saying that if we use that PR and restore all the creature stats as they were in the original game, we get the exact original balance? Since we have OVERFLOW_8BIT classic bug enabled.

If you want to try, you can download that prototype here.

@Loobinex

Are we saying that if we use that PR and restore all the creature stats as they were in the original game, we get the exact original balance?

Hard to say with all the development and changes in kfx. The only thing I can do is test and report. I take it this means you're opting for the purist approach for legacy with overflow, strength and speed bugs all reintroduced?

Since we have OVERFLOW_8BIT classic bug enabled.

Did not realize this was a thing. Why on earth were the stats changed in the first place? I guess I'll find out while testing...

@Loobinex

Are we saying that if we use that PR and restore all the creature stats as they were in the original game, we get the exact original balance?

Hard to say with all the development and changes in kfx. The only thing I can do is test and report. I take it this means you're opting for the purist approach for legacy with overflow, strength and speed bugs all reintroduced?

Legacy has always been the mode for purists. And the OVERFLOW_8BIT is already enabled in legacy mode anyway.

Since we have OVERFLOW_8BIT classic bug enabled.

Did not realize this was a thing. Why on earth were the stats changed in the first place? I guess I'll find out while testing...

I do not know, it was ancient history, before I got involved. Perhaps they changed the stats before they classic bugs were introduced and then never changed back. I do know that in early versions of KeeperFX ancient keeper was truly impossible, that's why campaign specific configs were introduced.

@Loobinex

Happy to help get things squared off again then. Did some initial testing on the 1460 prototype to that end:

All the bugged lvl 10 spells work as desired except POWER_SIGHT. Warlocks appear to get their sight spell power from POWER_VISION instead and changing that value worked as intended.

It looks like STR values overflow instead of getting capped at 255 and I don't see a separate entry in rules.cfg for applying a strength bug. On old DK the logic for strength is basically:
If (STR >= 256)
STR = 255

This may be the actual source of a lot of the imbalance I saw throughout the AK campaign.

Still have to test dex, def, armour and luck but this will take some back and forth between old dk and kfx.

I can quite easily set the max strength to 255 with this classic bug enabled, but it looks to me strength currently is simple left alone to grow in classic bug mode. Agreed?

I updated the PR with a strength limit of 255 and POWER_SIGHT restored on sight spell: https://github.com/dkfans/keeperfx/actions/runs/10967814336

@Loobinex

I can quite easily set the max strength to 255 with this classic bug enabled, but it looks to me strength currently is simple left alone to grow in classic bug mode. Agreed?

Do you mean allow strength to overflow back to 0 or allow it to grow past 255? Either way the balance will be very different from the OG so not very legacy at all.

Did some extended attribute testing on prototype 1460.

Armour: According to the wiki, armour stays capped at 204 on old DK similar to strength (IF (ARMOUR >= 205) ARMOUR = 204). On KFX, it caps to 204 as it should but overflows to 0 when going beyond a value of 255. In other words overflow bug currently applies to armour when it should not.

Dex, Defence/Skill and Luck: All of these overflow beyond 255 on kfx exactly as they do in old DK. BUT there's a lot of inconsistency in combat rolls particularly when it comes to Defence. DK uses a simple RNG that appears to be based on game turn and changing these attribute values produce consistent results. There's a lot more variance for the same DEX/DEF value in KFX.

So to answer your previous question on whether restoring DK stats on kfx will lead to exact same balance, it won't be a 1:1 change but with the exception of Defence (and Dex since Dex rolls are made against Defence), it looks to me like it would be fairly similar, more so if the high variance on Defence rolls is addressed. You can see my attached measurements and draw your own conclusions on how it might pan out.

attribute-measurements.zip

@Loobinex

I updated the PR with a strength limit of 255 and POWER_SIGHT restored on sight spell: https://github.com/dkfans/keeperfx/actions/runs/10967814336

Warlock Sight spell is fixed but STR value of 256 still appears to overflow back to 0.

Edit: I guess I should test STR > 255 as applied by level modifier.

@Loobinex

Retested STR > 255 where applied by level modifier and it works as it should - STR is capped to 255. Probably better to also apply the same to STR values > 255 directly entered into creature.cfg to avoid confusion for testers.

Retested AK13:Sloth on prototype 1463 + original DK creature attribute values. As expected, it is not a 1:1 change due to aforementioned Defense variation but is definitely a lot better. Samurai v Orc battle on the level is harder than original DK but easier than before on KFX (less micro now required) and knight v orc battle is harder than both original DK and previously on KFX (a little micro now required),

It seems someone ran into the same issues with DEF before as KFX default creature cfg uses attribute values nearly identical to old DK except DEF is given a 50% increase across all creatures. Trying Sloth with old DK attributes + KFX's +50% DEF indeed yielded better results. Both Samurai and Knight battles become even easier (even less micro required).

This is a major change and I'll be retesting various AK levels to be sure they're playable but would you opt for 100% old DK cfg or old DK + 50% DEF increase? Both are attached below.

legacy_crtr-def-restored.zip
legacy_crtr-def-unchanged.zip

@elemanzer I would try to have legacy be 100% identical to old DK1 or as close as we can get. Is that the def-restored zip, or are there more things that need restoring?
Have you restored all values there to original, like strength and whatnot, as they were in the original creature.txt file?

And if with the stats restored, if it is not 100% identical, any idea where it still differs?

@Loobinex

Is that the def-restored zip, or are there more things that need restoring?

  1. def-restored (to DK) is original DK values (Str, Armour, Dex, Defence, Luck, Health, Pay, Base speed)
  2. def-unchanged (from KFX) is KFX's +50% Defence values, DK values for everything else. Sorry that was a stupid naming scheme in hindsight.

1 is identical to DK in values but 2 plays more like DK (on AK at least).

And if with the stats restored, if it is not 100% identical, any idea where it still differs?

Imho it differs because KFX applies Defence and Dexterity very differently from DK. To summarize:

Under controlled conditions, a defence value range (e.g. 178-255) produces a consistent miss rate in DK (e.g. 95-98 misses) but produces wildly different results on KFX (e.g. 109-193 misses) in a non linear, random fashion (defence 255 < 204 >186).

I observed the same with Dex but to a lower degree. Both are used to calculate whether a creature's attack hits or misses. I'm not sure why increasing Defence 50% on KFX brings it closer to DK. Maybe a higher miss chance levels the playing field. But I've retested several AK levels where the balance was particularly off on KFX and the balance has so far been much better (though still not 100% the same as DK). You can try the samurai and knight battles in AK: sloth on each config to get a quick idea of what to expect but to summarize the change on a difficulty scale of 1-10:

5 = AK on original DK
7 = AK on KFX with DK stats and +50% to defence (unchanged from KFX)
8-9 = AK on KFX with DK stats and DK defence (restored to DK)
10 = AK on KFX v1.1.0

I can collect data and make simple inferences but reworking combat mechanics is beyond me. For now I'm testing more AK levels on +50% defence version to be sure there are no blind alleys.

I would very much would like to understand -why- there's a difference still left there. I am not aware of any on purpose change to defense or dexterity calculations, so if something is going wrong by accident there it would be nice to find out where or why and fix the root cause.

@elemanzer trying to investigate that, I see you do not have any dexterity values in that first zip. KeeperFX reduced both defense and dexterity together (to allow them to grow better), but you cannot restore one without the other without effecting hit rates.
Are you sure you also tested it with the original values including original dexterity?

@Loobinex

Right so since dex is (mostly) not defined in the first zip of /legacy_crtr/ it should load dex values from the global /creatrs/ directory. KFX global values are nearly 100% identical to original DK apart from defence and some rebalancing of other attributes on one or two specific creatures (horned reapers and dragon iirc). So an orc for e.g. should load 60 dex from global and the original 65 defence defined in /legacy_crtr/orc.cfg - those are 100% original DK values.

I just double checked that global cfg is applied correctly to legacy map and str, dex and def are definitely being relayed correctly. They also scaled in my original measurements from 0 - 255. Scaled, yes, but with more inconsistency than DK.

You are right, shame. So I am still not understanding either why KeeperFX needs higher defense values to play out the same.

I am also not sure I fully understand what you mean by 'more inconsistency'. Do you mean that if you run the same testmap each time in DK1 you get the same result each time (because it has a fixed seed based on map layout) and in keeperfx a hit chance is a hit chance because we have a random seed?

@Loobinex

inconsistency

By inconsistency I mean the same value produces a very wide range of hit chance % and that lower values don't equate to a lower hit/miss chance.

why KeeperFX needs higher defense values to play out the same.

I have an idea on why this might be but IANA Statistician so it's just conjecture. Let's first confirm that my hypothesis is correct - that the difference is in fact due to defence and dex implementation.

I'll gather a larger sample of dk vs kfx hit chances (both on original dk attributes) with Dex/Def set to 0/0 and 255/255. If their means are similar for 0 but get significantly further away at 255, that should confirm the hypothesis. If not the variance or deviation might.

I can also gather a sample of DK/KFX at Dex/Def 255/0 and 0/255 and together, all four samples should tell you pretty accurately what the hit chance is for these values on DK and what it should be on KFX legacy. Hopefully that should be enough to work out a formula.

Give me some time...

why KeeperFX needs higher defense values to play out the same.

Edit: And thanks for this. I thought it might be based on game turn. Shouldn't affect above data collection over a large enough sample.

I think one approach would be to see which one is correct, if we are saying keeperfx and dk1 are not the same. Calculate what the hit chance needs to be given specific values, and see what the actual hit chances are for dk1 and fx. Then if DK1 is correct, great, then we can probably figure out why the hit chance is not that on FX and fix it.

And just to be sure,... if you put BOTH dex and defense to 0, and then BOTH to 255, you do not get the results you want. If you want high hit chances you set the attacker to high dexterity and the defender to low defense.

@Loobinex

BOTH to 255, you do not get the results you want

0/0 = Minimum hit chance
255/0 = Max hit chance due to dex
0/255 = Max miss chance (or hit chance of attacker) due to def
255/255 = Try to see how dex and def fuse together to create hit chance. Middle ground numbers like 96, 160 might further elucidate the relationship.

Calculate what the hit chance needs to be given specific values

How would you do this for DK? RNG aside is KFX's formula for hit chance a 1:1 imitation of DK or was it tweaked at some point? If nothing else I can gather data and try to arrive at effective hit chance % on DK for comparison with KFX projected numbers.

Then if DK1 is correct, great, then we can probably figure out why the hit chance is not that on FX and fix it.

'Correct' doesn't mean much in either case if it affects game balance negatively. For legacy, DK1 would be correct for purists even if the projected numbers were not. For KFX specific maps it depends entirely on whether the config and game balance is more fun or not.

For as far I can see the calculations have been left 100% the same, so the hit chances should be 100% the same. But you are telling me they are not.

We can calculate an expected hit chance from the numbers, and then see if they match with what we see in DK and FX, if they do in FX and not in DK there is indeed not much we can do, but if in FX it is wrong that could very well be something that needs fixing anyway.

@Loobinex

I have some preliminary results for you (attached below). Sorry it takes so long to gather enough data and assign each attack as a hit or miss by hand. I'm no statistician but so far it looks to me like:

  • KFX battles on 100% DK creature config replicates DK perfectly at higher hit rates (DEX/DEF = 255/0)
  • KFX deviates from DK at lower hit rates (DEX/DEF = 0/255)
  • Where KFX deviates, there's a bias towards the extremes of the hit chance range.
  • The length of battles was universally shorter on KFX compared to DK. Only luck could have caused this imo since str, dex and def should be accounted for. Note that luck at default values of the creatures (12 and 30) is on the lower end of the spectrum. iirc no creature has luck > 40.

In the Orc v Samurai battle on Sloth, Increasing DEF +50% probably works because double damage events from lucky attacks is reduced. Retesting the level with luck @ 0 did indeed have similar effects to DEF +50% though still not as easy as it runs on DK.

I could further focus on luck specifically or do middle ranges of dex/def next to see if the above deviations scale depending on attribute value. But with how long it takes to gather data I wanted your read on the data first.

dex-def-data.zip

There's also one differentce in battle mechanics I noticed that might have small implications: On DK, orcs activate protect creature only when in melee range. On KFX orcs activate protect as soon as they see an enemy creature. Since protect spell duration is now low due to lvl 10 bug, they might be losing some of the ~5s duration running down the target or due to samurai freeze.

I was planning to look into this too, but I have been putting it off because it is annoying to test and figure out.

Looking at your sheet, tell me if I understand this wrong, but I see that in KFX the amount of hits is actually lower, and assuming you count a battle until the creature is dead, this means the damage output is different. The hit chance in both cases seems to be around 13% in all 4 cases, which is close enough. The other test has it 87% in all cases, so that seems to be very consistent to me.

If you want to know about damage, you could check if you remove armour and lightning from the orc/samurai it will then move it even closer together, or if there is something with luck after all.

@Loobinex

in KFX the amount of hits is actually lower, and assuming you count a battle until the creature is dead, this means the damage output is different.

Yes and I believe that's due to luck. Based on the data I expect that if I increase luck to 255 in both DK and KFX, The total number of attacks before either creature dies will move closer. This was going to be my next test.

The hit chance in both cases seems to be around 13% in all 4 cases, which is close enough.

In the 2 max hit chance tests, you're right,, Hit chance is actually close enough. In the minimum hit chance test, there's a different story told by the SD:

  • Orc hit chance mean: 12.89% vs 13.77%. Small but significant difference.
  • Assuming a normal distribution, SD for above indicates the hit chance range for 95% of attacks falls between 6.57% to 19.21% on DK but 3.53% to 24.01% on KFX.
  • Samurai 95% hit chance ranges: 6.79% to 18.47% on DK vs 1.98% to 25.26% KFX,

This is based on the SD rule where in a normal distribution of data, 68% of values will fall within 1 SD of the mean, while 95% of the data will fall within 2x SD of the mean. There's probably a way to figure out from the data if the bias is more towards one end of the range than the other (something like interquartile range?) but honestly I suck at statistics.

For max hit chance, these SD values are very similar to perfectly aligned with DK. So a fix imho would probably require the RNG where dex, def and luck is lower to have more bias for the mean so that the hit chance and luck chance ranges would beccome more similar to DK ranges. This sounds like a massive pita but if you're up for it I can try to help by collecting similar data sets at different values.

A temp fix of +50% def on the other hand is a whole lot easier and works pretty well on the AK levels I tested so far. Some battles are harder than DK but a lot easier than KFX. Combining with a lower luck % would likely bring things even closer.

The orc armor may create a minimal difference but I mentioned it only because it probably adds up in Sloth together with the differences in dex, def and luck.

@Loobinex

If you want to know about damage, you could check if you remove armour and lightning from the orc/samurai it will then move it even closer together, or if there is something with luck after all.

The tests were carried out on lvl 1 units. No armour or lightning so should be just luck involved. Was going to check DEX/DEF/LCK 255/0/255 to remove influence of hit chance as previous data suggested.

I appreciate the differences are statistically significant, but they are small enough that they are impossible for me to quickly test and tweak code. If we would have a test case where the difference is between 10 and 30%, I can run a scenario with 3 battles and count the hits and immediately get a result. Here it is hard.
If we have a clear idea what the fix could be, then yes, we could implement and test that. I can reduce the randomization in the code, I will try to look back at the original dk decompiled source to see if I can find a difference there.

Before you run an entire suite for luck, first check the exact damage numbers without lucky shots and health. If every hit does more damage in keeperfx that would reduce the amount of needed hits too.

@Loobinex

first check the exact damage numbers without lucky shots and health

The max/min hit chance tests were run on your last prototype so I'd already verified that strength was being applied accurately. Just went through another ~450 hits on the same prototype (hp/str/luck 901/100/0) and not one of them caused more damage than expected. Needed to verify that lowest possible luck chance was in fact 0% anyway.

Here it is hard.

I understand completely it seems like a lot of painfully slow work. I'll run a few more tests and maybe they will indicate an easier way. One of the reasons I want to do middle value tests is that if the variation doesn't scale uniformly from 0-255 but rather switches on/off at some point, it might indicate something more trivial in the code like maybe a negative number being passed somewhere that can't handle negative values.

On that note, I saw on the wiki that luck means not just chance for a double hit but also 2x defensive rolls to dodge an attack. Is it possible that maybe one of the 2 defensive rolls is using the wrong value? E.g. one could be using OF values and the other the regular scaled values?

If I find anything in further testing I'll attach it here in case someone wants to take a closer look at the issue at some point in the future.

I never heard about luck giving 2 defense rolls, checked now, and unless I am missing it, do not see it in the code either.

but if you never had double damage because of luck, then how can you have cases where you have fewer hits to kill a creature than expected?

@Loobinex

From the Luck section in the first table on the wiki.

The probability of dealing double damage or having double defence.
Specifically, this number is the probability, as a fraction of 255, that a creature will do a double attack/cast or make two defensive Skill rolls (see below). Melee attacks and defensive rolls are still not guaranteed to work.

And this:

but if you never had double damage because of luck, then how can you have cases where you have fewer hits to kill a creature than expected?

I assume it would work like this: when creature 1 attacks creature 2, 1 makess a luck roll to see if they get double damage and 2 makes a luck roll to see if they get a second defence roll to evade (if the first defence roll failed).

So if this is actually a thing and is missing on keeperfx, on Sloth for e.g., the samurai with 30 luck value get all the benefits of double damage while the already struggling orc with 12(?) luck gets even more reamed with missed defensive rolls.

Edit: So the battle would end in fewer hits than it does on DK.

No evidence of luck providing extra dodge chance on old DK.

luck-dodge-tests.zip

@Loobinex

Corrected some values in legacy cfg trapdoor and magic that differ from DK values (in the interest of purism). A couple notes:

The changes were applied on top of your last prototype
Magic door: Melee attack damage is reduced to 10% on KFX but 12% on DK. Magic doors will be a little stronger to melee on KFX as a result. It is currently not possible to configure magic door physical resistance via cfgs.
Magic.cfg: The only difference I could find was with meteor spell damage (2x on DK for 100 damage). Since meteor spell itself seems changed on KFX at first glance, I can't tell if the damage increase will have unintended effects.

legacy_cfgs-dk-values.zip

No evidence of luck providing extra dodge chance on old DK.

luck-dodge-tests.zip

I don't think it did either, I took a look on the fx code and here luck is only used for the attacks.

@walt253

I guess it's another one of those things stated in the DK manual that was simply wrong. Too bad since I was hoping for an easier fix.

I am considering just setting the magic door back to 1/8th damage all around. Don't see why it would be 10%.

But seeing your luck study, you seem to check for extra dodge, but does as luck does double damage, does different luck not simply cause fewer hits because they kill the enemy faster? Not saying there is a difference in luck, but if there is,...

Magic.cfg: The only difference I could find was with meteor spell damage (2x on DK for 100 damage). Since meteor spell itself seems changed on KFX at first glance, I can't tell if the damage increase will have unintended effects.

This is not correct. DK1 had a bug of exploding shots not exploding when they hit creatures, so all the area damage of meteor was ignored. Meteor was then rebalanced around having actual area damage. If we want the original 'effects' we should also remove the area damage from the shot, but it would not be a perfect imitation because in dk1 the meteor would explode when hitting floors or walls.

@Loobinex

But seeing your luck study, you seem to check for extra dodge, but does as luck does double damage, does different luck not simply cause fewer hits because they kill the enemy faster?

The attacker had 0 luck. Should be 0% chance of double damage but on the off chance it's 1/255 or 0.4% chance, it won't affect the results due to the minimal difference. The attackee had altered luck 0 vs 255 but 0 strength. No chance of the battle ending due to the attackee due to 0 damage so the total hits are completely influenced by the attacker. Ergo double damage events should be well controlled here.

If we want the original 'effects' we should also remove the area damage from the shot, but it would not be a perfect imitation because in dk1 the meteor would explode when hitting floors or walls.

iirc from my limited reading of the code, shots could differentiate between hitting creatures and objects, no? Still would have to limit the change exclusively to legacy though.

Back to the original differences,...

image

This is the biggest one to me, that in KeeperFX the samurai frequently killed the Orc in 8 or 9 hits, where in DK1 it never took less than 10. What is the cause, is this more lucky hits in FX or what explains this?

@Loobinex

What is the cause, is this more lucky hits in FX or what explains this?

afaict yes since other attributes are controlled. Low attribute values = wider range on hit chance and luck chance compared to DK.

@Loobinex

What is the cause, is this more lucky hits in FX or what explains this?

afaict yes since other attributes are controlled. Low attribute values = wider range on hit chance and luck chance compared to DK.

I analyzed the code and believe I found a difference.

  • KeeperFX does double damage if the Luck stat is higher than a random number below 100
  • DK1 does double damage if the Luck stat is higher than a random number below 255

Could I bother you again by asking you to see if you divide legacy luck values 2,5 times if that then matches with the KeeperFX outcomes?

@Loobinex

Ah I noticed that in the code and just assumed fraction of 100 is how DK also did it despite what the wiki says.

Sure I'll do a simulation but just to confirm what data set you want. You want e.g. samurai (default 20 luck) on DK Luck = 8 compared to KFX Luck = 20? (I'll control other attributes to isolate just differences in luck implementation).

Feel free to add any other data sets you might want.

Well, anything really. If indeed we went from luck/255 to luck/100, see if we can get an accurate legacy ruleset by compensating for this. If this is it, then we have completely restored the legacy ruleset with the PR and have Ancient Keeper fully playable again. (With a tiny inaccuracy in hit chances left).

@Loobinex

Looking good. With 2.5x factor the data is nearly identical (attached below).

luck-2.5-data .zip

have Ancient Keeper fully playable again

As much as I hope for this to be the case, I'd already tested sloth with orc/samurai luck=0 in kfx and it was at best similar in difficulty to defence +50% config. Any luck value above 0 (even if the 100>255 fix is made) would logically only serve to increase the difficulty more.

Is the DK decompiled source available on github? I'd like to take a closer look at hit chance. Particularly the 96 and 128 numbers in thing_shots.c:

hitchance

It is not. You have a discord account right, PM me and I will send it to you.

I am receiving conflicting information from you now, or I fail to understand you. In your original test data we found 2 differences:

  1. different hit chance
  2. in keeperfx the units needing fewer hits to kill.

1 has something to do with dex and def and whatnot.
2 Then 2 days ago you said 'afaict yes since other attributes are controlled.' to my question if the different damage values are purely related to luck. Now I propose a luck fix, and you say this will not help with the amount of hits needed.

@Loobinex

My apologies for any miscommunication. I've dumped so much info, data and assumptions here that it's only natural for confusion to arise.

in KeeperFX the samurai frequently killed the Orc in 8 or 9 hits, where in DK1 it never took less than 10. What is the cause, is this more lucky hits in FX or what explains this?

afaict yes since other attributes are controlled. Low attribute values = wider range on hit chance and luck chance compared to DK.

Based on the data I was sure that there were more lucky hits in FX (since shorter battles kept happening regardless of wide changes in dex/def), but not that the battles ending in lesser hits were 100% caused by luck (haven't collected enough data to say this with confidence).

Since ime luck=0 was similar to def=+50%, I'm guessing a luck fix will still require ~+25% def for the AK campaign to play as smoothly as on DK. But I've been wrong plenty so far and maybe I'm being overly pessimistic. So do a luck fix and I'll give you a new dataset with 100% default DK values on both DK and KFX and keep my fingers crossed.

def and dex only relates to hit chances is my understanding. So if in DK1 it takes 12 hits to kill, and in FX it takes 10 hits to kill, more dex or less def will not make a difference. It can only change the amount of -attacks-, not hits.

@Loobinex

def and dex only relates to hit chances is my understanding. So if in DK1 it takes 12 hits to kill, and in FX it takes 10 hits to kill, more dex or less def will not make a difference. It can only change the amount of -attacks-, not hits.

We're on the same page here. In any case, removing luck discrepancy from the equation will make it easier to zone in on whatever continues to cause differences in Sloth.

@Loobinex

Ok so with the luck mystery more or less solved I did some digging into dex/def and think I found the crux of the issue. The formula:

hitchance

I did the math and the formula seemed to give an overwhelming advantage to lower stat creatures versus higher stat creatures. In the orc v samurai battle on sloth for example, a L10 Orc with a bugged dex/def of 249/14 would have a hit chance of 87.5% while a L10 Samurai with a bugged dex/def of 118/35 has a hit chance of 70.31%. WTF?!

I ran a quick dk vs. kfx simulation and a L10 Samurai on KFX does indeed have a mean hit chance of 70.05% when he should have closer to a 23% chance as on DK. It doesn't seem to be an issue of fetching incorrect stat values as the +128 portion is what exponentially closes the gap between low stat and high stat creatures.

l10-sam-vs-l10-orc-data.zip

ok, now we are getting somewhere interesting. Just to confirm before I try to debug:

  • On KeeperFX with legacy stats a Samurai has a 70% hitrate
  • On DK that same Samurai has a 23% hitrate, and you believe KeeperFX should have that too.

So I can make a legacy testmap with just a lvl10 samurai and orc, and trace the stats back to see where the calculation returns 70 instead of 23.

@Loobinex

On KeeperFX with legacy stats a Samurai has a 70% hitrate
On DK that same Samurai has a 23% hitrate, and you believe KeeperFX should have that too.

Correct. Might also want to check DK source to see which formula is 'correct'. Does 23% sound accurate for 118 dex? Even against the Orc's defence, 118-14 = 104, which Intuitively should at least be ~35% hit chance. So the discrepancy might be due to yet another DK bug.

I used your file 'legacy_crtr-def-restored' from a while back on this issue. And took a Lvl10 Orc and Lvl10 Samurai.
These are the lvl10 stats:
Samurai: 34 Def, 117 Dex
Orc: 13 Def, 249 Dex

Does this match the stats you have in FX and DK1?

Then I calculated the hit chance.
Samurai to hit Orc: ( ( (117-13) /2) +128) / 256) = 70,3%
Orc to hit Samurai: ( ( (249-34) /2) +128) / 256) = 92,0%

Checking your l10-sam-vs-l10-orc-data.zip file, you got a 70,05% actual hit rate, that sounds to me like well within the expected range.

@Loobinex

Does this match the stats you have in FX and DK1?

Very close to the bugged dex/def I previously attached which iirc was:
Sam10: 118/35
Orc10: 249/14

Not sure which is more accurate. It was a while ago so I can't remember what simulations I used to verify my numbers.

Moving on, I similarly determined L10 Orc's hit chance on DK (mean 44.84, attached below) which allowed me to figure out the approximate hit chance formula used in DK. With L10 Samurai for e.g.:

hit_chance = (sam_dex - orc_def) / 2 = (118 - 14) / 2 = 52
hit_chance = (hit_chance / hit_chance_cap) * max_possible_hit_chance = 52 / 224 * 91 = 21.125

21.125% is very close to the samurai hit chance mean of 21.87% in the DK simulations
Similarly the orc's hit chance:

hit_chance = (orc_dex - sam_def) / 2 = (249 - 35) / 2 = 107
hit_chance = (hit_chance / hit_chance_cap) * max_possible_hit_chance = 107 / 224 * 91 = 43.468

43.468% is very close to the 44.84% mean in my data.

The exact numbers used for hit_chance_cap and max_possible_hit_chance do still need to be verified.

l10-sam-orc-hc-data.zip

ok, put a lvl10 samurai and a lvl10 Orc in DK1,m and confirmed it has the same stats there (accounting for incorrect names, icons and 255 overflow). I also did it briefly but it indeed seems the samurai has a hit rate well below 50%, that 23% could be it but if you would have told me it was lower I would have believed you too.

So, two possibilities I see:

  1. The samurai misses for another reason in DK1 unrelated to stats (say, aim or distance or whatever)
  2. There are different calculations for the hit chance.

Edit: I wrote this message before you posted yours, just posted it later.

@elemanzer interesting calculations. We'll have to compare your theory against this:

  if ( v5->is_melee )
  {
    v42 = (char)shotng->field_20;
    v12 = &shot_stats[shotng->model];
    if ( target->health < 0 )
      return 0;
    v13 = 0;
    if ( shotng->index != shotng->parent_idx )
      v13 = game.things.lookup[(unsigned __int16)shotng->parent_idx];
    v14 = game.creature_stats_OLD[target->model].defense;
    v15 = (shotng->byte_13
         + -35
         * v14
         * (unsigned __int8)game.persons.cctrl_lookup[(unsigned __int16)target->ccontrol_idx]->explevel
         / 100
         - v14)
        / 2;
    if ( v15 >= -96 )
    {
      if ( v15 > 96 )
        v15 = 96;
    }
    else
    {
      v15 = -96;
    }
    game.action_rand_seed = __ROR4__(9377 * game.action_rand_seed + 9439, 13);
    v16 = LOBYTE(game.action_rand_seed) < (unsigned int)(v15 + 128);
v16 is 'does it hit' here I believe, and the rand_seed is a value between 0~255.

@Loobinex

I'll study it and think on it more. But instinctively the key difference to me thus far appears to be the fractions applied (samurai) 52 * (91/224) on DK vs. (52+128)/256 on KFX.

I'm not seeing that 91/224 reflected in the code though. And since you have it everywhere, it would 'simply' reduce all hit chances by 60%.

Your earlier difference of 118/14 compared to 117/13 is a mistake I think, where you subtracted 255 instead of 256 of the number. But '0' is a possibility too, so I really do believe 117/13 (like FX displays it) is correct.

I studied it a bit but have not found where DK1 differs from FX. Dexterity calculations in the creating of the shot seem to match, and I believe the hit chance codes matches too. This would mean there is something else at play than just hit chance.

I think I have an idea,... what if defense does in fact not overflow here?

These are the lvl10 stats:
Samurai: 290 Def, 117 Dex
Orc: 248 Def, 249 Dex

Samurai to hit Orc: ( ( (117-248) /2) +128) / 256) = 24,4%
Orc to hit Samurai: ( ( (249-290) /2) +128) / 256) = 42,0%

Edit: I really think this is the case. I think I have this fixed. Try this prototype: https://github.com/dkfans/keeperfx/actions/runs/11185626824

@Loobinex

lol just found the exact same thing and came here to report.

I want to expand to some other melee creatures that overflow to be 100% sure but yeah this seems to be it. Also explains why I found less of a discrepancy in the formula for non OF creature levels like 5 and 7.

Edit: Also wanted to ask if defence is used anywhere else that might use OF values.

If it is, I addressed it at the source, so all places will use the bigger defense value now.

@Loobinex

I addressed it at the source, so all places will use the bigger defense value now.

That's actually what I'm worried about. Since until now DEF was assumed to overflow, I wanted to be sure that the assumption did not come from some other place where OF DEF values are still required.

Moving on, did a bunch of stuff:

    1. Based on additional simulations, I'm confident that OF DEX and non-OF DEF values are used in the hit chance calculation.
    1. Tested your last prototype with original DK stats (luck = 0) and DK and KFX are now 1:1 in hit chance in both OF and non OF cases. Data for 1 and 2:

hc-data-full.zip

    1. Sloth: Samurai and Knight battles in the Prototype run way more like DK now with maybe a tiny difference that's probably due to the luck issue remaining unchanged. DK vs KFX difficulty scale comparison = 5 vs 6
    1. Antak's Ruin: This is the mission with the lone dragon1 against an army of archer10's. This was still way off compared to DK despite the def fix and the difficulty scale (dk/kfx = 5/9) couldn't be explained by luck alone. Did some investigating and it turns out KFX calculates archer arrow damage based on Strength+modifier whereas DK uses a fixed damage of 30. Changed the shot to reflect the difference and Antak's ruin now runs as it should. Attached legacy magic.cfg with fixed SHOT_ARROW below:
      ** Applied on top of your last prototype
      ** Left the meteor damage change out (DK=100, KFX=50) since I'm not sure where you want to go with that.
      ** Did a quick proofread and no other shot uses strength where DK doesn't.

legacy_cfgs-shot_arrow-fix.zip

    1. That leaves the pending luck fix and adding DK creature stats to legacy. Trapdoors too (Boulders are used almost exclusively as a nuisance in AK so less boulder health = less nuisance).

I'll also recheck all the changes to date in this issue (str cap, power 10, etc.) and do a more thorough review of creatures.cfg, magic.cfg and trapdoors.cfg because I'd love to put this purism endeavor to bed once and for all.

Yes, standard made arrow strength based, legacy should compensate for that like classic but I see it didn't. I updated the PR to fix this. I did it a bit different from your fix.

@elemanzer Please check out this prototype: https://github.com/dkfans/keeperfx/actions/runs/11193696009

  • it holds all previous changes/fixes you tried before
  • it has the arrow fix I mentioned 24 minutes ago
  • firebomb should be similar to dk1
  • I put in the creature stats from legacy_crtr-def-restored.zip

Am I correct that I then need to wait for you to provide updated configs with luck, and that then everything is done and fully in line with DK1?
Or is there something else I am forgetting?

@Loobinex

legacy_crtr-def-restored.zip is 100% DK stats. Nothing needs to be added or changed unless you want to deviate from pure DK. EDIT: The only reason to change it would be if the main cfg files in /creatrs/ are altered as currently they hold most of the same legacy values.

You had previously found the cause of the lower hits on KFX was that luck on KFX was using a fraction of 100 instead of DK's 255. You asked me to test luck values altered by a factor of 2.5 which completely fixed the discrepancy. Has this been fixed in the prototype?

One minor change required with the strength cap based on testing the previous 4123 prototype. STR should actually be capped to 256 instead of 255 as creatures die when health < 0 and not health = 0. So a level scaled STR of 256 kills a creature with 255 hp with one hit on DK whereas on KFX, 255 HP = 2 hits and 254 HP = 1 hit.

I was actually kind of hoping/expecting you would provide updated luck stats of all the creatures to the corrected ratio. Will you or do I need to do so myself? I was not planning on changing the default luck calculation at this point and a legacy rule would seem unneeded because the changed stats would work I think.

Are you saying in DK1 creatures did die at 0, where in FX they only die below 0?
Edit, I checked the original code:

  if ( thing->health < 0 )
  {
    kill_creature(thing, game.things.lookup[0], -1, 0, 0, 0);
    return 0;
  }

So, seems to be the same to me.

@Loobinex

Are you saying in DK1 creatures did die at 0, where in FX they only die below 0?

Not at all. So in DK a creature with 256 str needs 1 hit to kill a creature with 255 HP, 2 hits to kill 256 HP (because the difference = 0; not <0). While retesting the STR cap on KFX I noticed that it take 256 str 2 hits for 255 HP instead of 1. This is because STR is capped to 255 on KFX whereas it's 256 on DK. It was a little tricky to get there just using the level modifier but I verified that this is how it works on DK.

I was actually kind of hoping/expecting you would provide updated luck stats of all the creatures to the corrected ratio.

I would have done this 2 days ago to give you an alternative but unfortunately it's a dirty fix. The samurai I used for the test specifically because 20/2.55 was close enough to 8 that I could round it up for testing purposes. Things get messy with various creatures since I would have to round up or down. Dwarf: 2/2.55 = 0.78 > 1, Spider: 3/2.55 = 1.18 < 1, Orc: 12/2.55 = 4.70 > 5... you get the idea.

But I kinda can't believe that after getting this far you'd want to abandon purism at the last step. S*it I was happy with +50% defence but went the extra mile because not taking the easy way out I was pushing seemed kinda admirable. It's upto you my dude. I'll do the dirty fix if that's what you really want.

@Loobinex

I gave this some thought and you're probably concerned that fixing luck would break non legacy campaign balance.

I think you originally added +50% defence in #1430 to make battles longer. We now know that those battles were probably short in the first place due to the 2.5x luck and in my AK tests, removing luck from the equation (luck = 0) was nearly the same as adding +50% defence to DK stats.

So one possible alternative would be to fix the luck issue now so that it's /255 again and at the same time restore original dk def values to non legacy campaigns and test for any imbalance.

If not, I'm happy with a difficulty scale of 5 on DK vs. 6 on KFX. So we can stop here and shelve the issue for whenever you want to deal with rebalancing creatures on main.

@Loobinex

I gave this some thought and you're probably concerned that fixing luck would break non legacy campaign balance.

I think you originally added +50% defence in #1430 to make battles longer. We now know that those battles were probably short in the first place due to the 2.5x luck and in my AK tests, removing luck from the equation (luck = 0) was nearly the same as adding +50% defence to DK stats.

So one possible alternative would be to fix the luck issue now so that it's /255 again and at the same time restore original dk def values to non legacy campaigns and test for any imbalance.

If not, I'm happy with a difficulty scale of 5 on DK vs. 6 on KFX. So we can stop here and shelve the issue for whenever you want to deal with rebalancing creatures on main.

Those values were not increased because of luck, but because of the differences to dex/def. In the original game they grew by 35% per level and had the dexterity overflow bug. But unlike strength which was simply uncapped, dex/def do not make sense as too large numbers so the growths were reduced instead. And then later on #1430 the base values too. So unrelated to luck.
I am fine with luck being a percentage instead of a /256 rate, so I think just bumping the legacy stats is easiest.

I would be willing to look into def/dex at some point too, to see if that can be made better now that we are free to change all stat files, but would prefer to do that in a new PR.

@Loobinex

So unrelated to luck.

You're right but giving creatures a 255% boost to luck absolutely reduces combat times. A horny for e.g. has a 30% chance for double damage on kfx where it should be closer to 11% as on DK. At L10 non legacy that would be some 700 damage in one hit, every 3 hits.

I took a look at the standalone maps and campaigns included with kfx and the majority would benefit from fixing the luck bug since they were designed on DK. But I see that you would have to take a 2nd look for kfx era campaigns like assimist, revlord and origplus, plus all the standard maps. I don't see it affecting balance too much but you never know with fine-line battles like the samurai-orc in AK.

/256 rate, so I think just bumping the legacy stats is easiest.

Is it 256 or 255? I'm going from the wiki saying it's 255. Also kfx currently increases luck 2.5x more than it should be so we would be bumping down the luck 2.5x on legacy. Classic campaigns like keeporig, burdened imps, twin keepers, etc. would also continue to have the luck bug. It makes more sense to fix the bug universally and increase luck 2.5x for campaigns if they need it since those appear to be in the minority.

I am fine with luck being a percentage instead of a /256 rate

OK but luck will have to accept float values either in creature cfg or I think it's better to convert /256 numbers in the code.

I would be willing to look into def/dex at some point too, to see if that can be made better now that we are free to change all stat files, but would prefer to do that in a new PR.

Yeah honestly I've been thinking about this too. The DK formula is @%# that forces hit chance into an arbitrary -37.5% to 37.5% range and adds 50% to that to produce a hit chance range of 12.5% to 87.5%. With dex OF fixed that means a lot more creatures are bumping up against that 87.5% cap which with the STR cap removed (and luck 2.5x too now) makes for terrible balance. I've got some ideas if you should ever get around to it.

I am unsure about the luck. I traced it back to when it got introduced: be3b568#diff-34d21af3c614ea3cee120df276c9c4ae95053830d7f1d3deaf009a4625409ad2

It got clearly changed from a 255 to a 100 range without any comments as to why or how. Over 14 years ago now.
But what makes more sense here, yes, reaper has 30 luck so that is a big number, but that is the second highest value in the game after the Fairy, with 20 being a high number already and with half the units having 10 or less. Now a 10% chance to do double damage does seem like a much more sensible value than a 4% chance. And this is how spellcasters do differentiate in damage, a fairy now does 30% more damage per spell than a wizard or witch, which is decent but not extreme. Compared to 12% which is almost meaningless.

@Loobinex

Ah so you want to reimagine luck for all non legacy campaigns? Okay then it makes sense to change things only on legacy.

As far as fairies go they are actually quite powerful on DK with DK values. They have lightning in addition to freeze and slow and can be devastating if not dispatched quickly. They have 15% luck chance on DK which is about 1 in 6 hits which imo is both perfect for fairies and perfect as a maximum luck chance any creature should have.

Priestesses also have lightning and wind that can make battles a nightmare, Wizards too have a decent amount of health + heal in addition to hailstorm for brutal damage if left unchecked. Warlocks also deal massive damage with meteor - although they get the short end of the stick wherever rebound is involved. Damage wise I don't think any of these creatures need any additional luck.

But I agree that at the lower end on DK luck is set way too low. Dwarves have a 1 in 128 chance for e.g which might as well be 0. So I guess it comes down to what you think the minimum and maximum luck chance should be. I think 1 in 6 is a good maximum but that the minimum should not go below 1 in 20.

Attached below is what luck would look like if scaled uniformly across creatures on DK values with a new minimum and maximum. The lower tier get a decent but non extreme luck boost. I think a good cutoff point is everything above the knight at default 15 luck. From here you can individually address specific creatures to make luck a more pertinent stat.

But honestly this should come after addressing the imbalances caused by no str cap and dex OF fix since battles are shorter than on DK as it is. No str cap means more lvl 10 creatures cross the 256 threshold and more luck chance means more 512+ damage hits.

luck-scaled.zip

'Want to re-imagine' is put too strongly, more that 'this is how it has been for 14 years now'. And yes, all creatures stronger than an Orc have gotten a strength boost at higher levels through the fixing of the stat bug, but there is also more health I believe and we raised defense and spells do more damage on higher levels and Horned reaper has had his strength reduced, so we do have a new balance.
So I happily take your new luck values for legacy for now, and if at some point we want to redo the entire default balance and this would include lower luck values, then we can always revert that bit.

EDIT: Should have read better, this is sheet with info, not new configs. I will do something myself.

Ok, then this should be pretty much perfectly math DK1: https://github.com/dkfans/keeperfx/actions/runs/11213932302
Merge this?

@Loobinex

Ok, then this should be pretty much perfectly math DK1: https://github.com/dkfans/keeperfx/actions/runs/11213932302
Merge this?

Not if legacy is for purists as you said. Look I've been through this and the numbers always end up messy with a lot of rounding up and down. Since we're making small numbers smaller, the rounding has a much larger impact than if you were multiplying standard values by 2.55. I've come at this from every angle possible and there's only 4 ways to configure luck accurately for legacy:

    1. Allow creature cfg to accept float values so e.g. I can set a dwarf to Luck=0.78 instead of DK's 2 (2/255*100=0.78)
    1. Convert legacy DK luck values to % values within the code so e.g. dwarfa.cfg with Luck=2 becomes 0.78 during lucky chance calculations (Luck=(Luck/255)*100).
    1. Fix the bug universally by changing the fraction from 100 back to 255 and then add 2.55x luck to standard creature configs. (This is easiest and the numbers actually work out much cleaner in this case: creatrs-2.55x-luck.zip )
    1. Leave things unchanged and let legacy use standard config luck until you want to tackle either 1, 2 or 3.

If not 1-3, I pick 4! No measures are better than half-measures.

Moving on, here are the FINAL legacy_cfg changes. legacy_cfgs-4123_4641f2d.zip. With this everything from DK creatures.txt has been transplanted into legacy with a few caveats:

  • Applied on top of prototype 4123_4641f2d
  • creatures.cfg:
    • Time & Action time differences were left as is as they appear to be important for KFX attack implementation
    • The litany of Forcedvisibility differences were ignored in all but one case (where it's an important legacy feature)
  • magic.cfg:
    • Some differences to shot health, damage and speed (=0) left out as it seems that KFX uses these values while DK does not.

Please review.

This should leave only the correction to STR cap from 255 to 256.

As for luck, while rounding is never perfect, you'd be half a percentage off at most, so you do 99.5% the same damage as before, which is more than close enough for me, and I am assuming the other differences in behavior between keeperfx and dk1 are big enough that this 0.5% is negligible.

Moving on, here are the FINAL legacy_cfg changes. legacy_cfgs-4123_4641f2d.zip. With this everything from DK creatures.txt has been transplanted into legacy with a few caveats:

* Applied on top of prototype 4123_4641f2d

* creatures.cfg:

* * Time & Action time differences were left as is as they appear to be important for KFX attack implementation

* * The litany of Forcedvisibility differences were ignored in all but one case (where it's an important legacy feature)

* magic.cfg:

* * Some differences to shot health, damage and speed (=0) left out as it seems that KFX uses these values while DK does not.

I pushed your changes with 2 exceptions:

  1. Imp cost: I have 150 in the configs where DK1 had 300, but the DK code first halved the price for no reason before applying it. This recently changed in KeeperFX

  2. The torture convert chance to 10%. I am seeing the 10% in the dk1 creature.txt, but find it really strange. I will double check first to see if it really was used like that in the original game, and if so, apply it.

This should leave only the correction to STR cap from 255 to 256.

I really believe the cap is correct at 255, and the same as in the original game. I forgot to mention it but checked it and also in the original game do creatures only die when they get below 0 health.


EDIT: I checked the torture chance and my gut feeling was correct. The 10% value of the original game was incorrect and it simply took a 1/3 hardcoded chance to convert.

@Loobinex

I really believe the cap is correct at 255, and the same as in the original game.

Here's my str cap test data that both shows that DK creatures die < 0 and that the cap is 256 compared to KFX's current 255. My apologies for not being thorough the first time around:
str-cap-test.zip

99.5%

Where did you get that number from? Your PR luck approximations lead to creatures having between -15% to +27.5% more or less luck than they should (e.g. thief 5.49 > 5 = ((5-5.49)/ 5.49) * 100 = -8.93%). If you leave the scale at 255 on the other hand, rounding only produces an error range of -1.96% to 4.58% with 45% of the values landing in the 0.xx% range (since these are reimagined values the differences don't even matter in the first place).

Good enough for standard and classic but is it good enough for purists/legacy? You're so close to telling purists legacy is 100% DK that this seems like a silly point to stumble on with 'good enough' when the innacuracy is easy enough to address. I say leave it for when you want to deal with it. I can look into doing (1) myself if you want (get luck to accept x.xx values everywhere it is used since you seem determined to have luck as a more intuitive %).

I pushed your changes with 2 exceptions:

These are the things I don't know so thanks for reviewing. Do you want legacy creatures with str,arm,dex,def clearly defined? This would leave you free to change values on standard without also having to change legacy.

@Loobinex

I really believe the cap is correct at 255, and the same as in the original game.

Here's my str cap test data that both shows that DK creatures die < 0 and that the cap is 256 compared to KFX's current 255. My apologies for not being thorough the first time around: str-cap-test.zip

Ok, I am not sure what is going on here. If this is a rounding issue (say, with keeperfx first rounding to a whole number before doing damage, and DK1 using the raw values), when I increase the strength limit to 256 that would not help us. Then there are cases where rounding would have us do 1 more damage than expected.

99.5%

Where did you get that number from? Your PR luck approximations lead to creatures having between -15% to +27.5% more or less luck than they should (e.g. thief 5.49 > 5 = ((5-5.49)/ 5.49) * 100 = -8.93%). If you leave the scale at 255 on the other hand, rounding only produces an error range of -1.96% to 4.58% with 45% of the values landing in the 0.xx% range (since these are reimagined values the differences don't even matter in the first place).

Good enough for standard and classic but is it good enough for purists/legacy? You're so close to telling purists legacy is 100% DK that this seems like a silly point to stumble on with 'good enough' when the innacuracy is easy enough to address. I say leave it for when you want to deal with it. I can look into doing (1) myself if you want (get luck to accept x.xx values everywhere it is used since you seem determined to have luck as a more intuitive %).

You say how much % more/less luck, which with low values can be bigger numbers. I am saying % extra or less damage. Since we are rounding whole luck points that represent 1% chance of double damage each, rounding will get at max give a difference of 0.5 luck points, meaning a 0.5% difference in damages.
With your example, that thief with 100 hits would do 105 hits worth of damage in FX (5 lucky hits) and 105.49 hits in DK1, which is less than 1% difference in damage. And yes, even purists would never notice that.

I pushed your changes with 2 exceptions:

These are the things I don't know so thanks for reviewing. Do you want legacy creatures with str,arm,dex,def clearly defined? This would leave you free to change values on standard without also having to change legacy.

No need, whenever I make a change to standard, I add the original values to legacy/classic at that point. So better to keep legacy as clean as possible, making it easier for people to see where the differences lie.

@Loobinex

If this is a rounding issue (say, with keeperfx first rounding to a whole number before doing damage, and DK1 using the raw values), when I increase the strength limit to 256 that would not help us. Then there are cases where rounding would have us do 1 more damage than expected.

No evidence for a rounding error. The data consistently shows creatures on DK die only when HP < 0 whether the str value is a direct input whole number or a scaled number, and that the str cap is 256 no matter what the value > 256. Maybe look at the data again or run some tests yourself. Or not because in the end we want the same cap of 256 and there's no indication of +1 extra damage anywhere.

And yes, even purists would never notice that.

Purists, ime, don't just notice palpable changes. They go into the config files, notice the different values and then moan about the differences. And in this case, the differences are because luck for some reason ends up the only attribute that's a fraction of 100. Well sucks to be them cause I looked into it briefly and it seems the only viable option is to change the fraction back to 255 which you're dead set against. Shame.

No evidence for a rounding error. The data consistently shows creatures on DK die only when HP < 0 whether the str value is a direct input whole number or a scaled number, and that the str cap is 256 no matter what the value > 256. Maybe look at the data again or run some tests yourself. Or not because in the end we want the same cap of 256 and there's no indication of +1 extra damage anywhere.

Ok, think I found it. It was not a strength cap, but a hardcoded shot damage limit to 256. Think I should have compensated for it now.

Purists, ime, don't just notice palpable changes. They go into the config files, notice the different values and then moan about the differences. And in this case, the differences are because luck for some reason ends up the only attribute that's a fraction of 100. Well sucks to be them cause I looked into it briefly and it seems the only viable option is to change the fraction back to 255 which you're dead set against. Shame.

If they go into config files to find a 0.5% damage difference then i have no problem telling them to go play DK1 instead because other differences account to much more than 0.5% differences. Most of the purists do in fact complain about differences they experience.

New prototype: https://github.com/dkfans/keeperfx/actions/runs/11236919263

@Loobinex

New prototype: https://github.com/dkfans/keeperfx/actions/runs/11236919263

Thanks! I'll give sloth, antak and a few other peoblem levels a quick playthrough to be sure there are no issues and report back.

Most of the purists do in fact complain about differences they experience.

Based on what I see on youtube comments, a lot of people (purists or not) are going to end up in creature config and the first thing they'll notice is the lower luck stat and ask why. For legacy at least, I'd like to avoid having the question raised in the first place and reassure users that legacy is 100% DK if that's what they want (and by extension that they can have better than legacy on standard/classic if they want to try it). Well I figured out one possible way to do this without adding too much code so you can have your cake and eat it too:

thing-stats

i have no problem telling them to go play DK1 instead

That's a mistake. We should avoid any scenario where we tell any subset of users to go get bent, especially if it's easy to do at no additional cost. An adversarial philosophy of "If you don't like it, f off back to DK" will not serve KFX well if the goal is to migrate as many DK players to KFX as possible.

Well, if they are going in the config I documented it there that the value is corrected to be like the original game.

But no, there is only so far I am willing to go to cater to purists, because it would add a lot of overhead which is not worth it. KeeperFX is improved and it provides the original experience through rose tinted glasses. Most people do see that, and those that really hate even a 0.5% damage difference too much, they would hate so many other changes more. That means this is simply not the product for them.
The goal is to provide a fun experience for the people who want to use it.

@Loobinex

0.5% damage difference too much

It's not about the damage difference. It's about reassuring people that kfx legacy tries to be as much as DK as possible. This is important to both people that dislike a 0.5% difference and those that wouldn't mind it, but walk away due to the impression it leaves that KFX is heavily modified and not the original DK experience they might want.

they would hate so many other changes more

And they could be right a lot of the time. More users means more bugs reported that other types of players might not notice, which ultimately means a better kfx. "We don't serve your kind here" is short sighted and exclusionary.

it would add a lot of overhead which is not worth it

In my example, there's very little overhead and a low bar to have legacy use a 255 fraction. Are you saying you don't want to go even this route? You can have your cake and eat it too, no?

@Loobinex

0.5% damage difference too much

It's not about the damage difference. It's about reassuring people that kfx legacy tries to be as much as DK as possible. This is important to both people that dislike a 0.5% difference and those that wouldn't mind it, but walk away due to the impression it leaves that KFX is heavily modified and not the original DK experience they might want.

they would hate so many other changes more

And they could be right a lot of the time. More users means more bugs reported that other types of players might not notice, which ultimately means a better kfx. "We don't serve your kind here" is short sighted and exclusionary.

It's not about excluding people, it is being a small team and having clear focus. If we try to please everybody we please nobody. So the focus is on people that do enjoy fixes, and we provide a legacy mode so old content can still be enjoyed, but won't try to pretend it is 100% or even 95% the same as the original game.

In my example, there's very little overhead and a low bar to have legacy use a 255 fraction. Are you saying you don't want to go even this route? You can have your cake and eat it too, no?

Correct. I am saying it is a needless complication to hide different calculations in an unrelated classic bug mode and I truly believe what you fear will never come up. But tell you what, if it ever does I'll revisit.

@Loobinex

I truly believe what you fear will never come up.

The first thing I do when trying a new legacy game with some kind of keeperfx-esque modern update is try to work out how much the modernized version might differ from the original and whether it's a better idea to enjoy the original first before trying the addon. I truly believe you're wrong and that kfx comes very close to the original, especially with the legacy balance now being fixed. But I tried. Consider the matter closed.

New prototype: https://github.com/dkfans/keeperfx/actions/runs/11236919263

I still need to test some problem levels like Avatar's revenge (24 HR vs 4 Avatar battle balance was way off) and Salaar's test (final keeper battle was impossible to win the traditional way) but based on how Sloth and Antak's ruin played, I see no reason to think that the others won't also be 1:1 in balance. Glad I could take part in fixing legacy balance. Consider the issue closed.

ak13-sloth-kfx-4135_102708e.mp4