Damage Resistance Calculations broken?

Discuss Chaos Strikes Back for Windows and Linux, an unofficial port of Chaos Strikes Back to PC by Paul Stevens, as well as CSBuild, an associated dungeon editor.

Moderator: Zyx

Forum rules
Please read the Forum rules and policies before posting.
Post Reply
Guest

Damage Resistance Calculations broken?

Post by Guest »

Okay, I downloaded CSB again and building up my party, got Sonja to level 12 ninja in a couple of hours on reaching the water elementals using the rope. Incidentally, it DOES reduce the damage she takes from ALL sources of damage. For example, I throw a level 4 fireball into a wall, and she only takes 50 damage when all my other guys take 250 damage. And the water elemental will only usually deal single-digit damage to Sonja.

Problem is, the damage resistance from skills, attributes and equipment sometime seems to be broken or disabled. I ran a save again and the elemental was doing up to 80 damage to Sonja. I threw a level 4 fireball at the wall, everyone got 400 damage. Then after a half hour, the damage resistance seemed to work again, Sonja taking the single-digit damage from our elemental and 50 damage from the level 4 fireball... I didn't change any options or do anything different.

I just found this to be very odd.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4319
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

If this really appears to be a problem we could investigate it
if you can supply savegames and recordings that demonstrate
the two different results. (Or one long recording that demonstrates
it.)
Guest

Post by Guest »

It seems to be working right again at this moment. It was just really wierd though.
Guest

Post by Guest »

Ok the problem with the damage resistance not being calculated seems to happen when I first load the game. That is, it was working earlier when I saved the game but not working later when I loaded it up again. I'm not sure how to get the savefile I'm working with onto the web however. Maybe I should get an account here, not that I'll be posting a whole lot.
Without Remorse
Novice
Posts: 19
Joined: Sun Jan 30, 2005 2:42 am
Location: Location: Location: Location: Location: Location: Location: Location: Location: Location: Location:

Post by Without Remorse »

Account: done. As I wrote, I'm not sure where to upload the savegame.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4319
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

Perhaps you can package the save file and the recordings
that demonstrate the difference in the damage calculations
into a .zip file and send it to my email address.
Without Remorse
Novice
Posts: 19
Joined: Sun Jan 30, 2005 2:42 am
Location: Location: Location: Location: Location: Location: Location: Location: Location: Location: Location:

Post by Without Remorse »

I didn't run the game in record mode, so forgive me if I don't have that information. Also, I would have sent the savefiles to you but for the fact that your e-mail doesn't show in your profile or a forum search, although I could be using the forum search incorrectly. It's just really annoying though, since the usually only randomly begins when I load the game I wonder if it has more to do with something esle on my computer than CSB itself, but it seems to save this problem to the savegame so I suppose it's worth a try.
User avatar
beowuuf
Archmastiff
Posts: 20687
Joined: Sat Sep 16, 2000 2:00 pm
Location: Basingstoke, UK

Post by beowuuf »

i think the e-mail address doens't display, i think it just provides a link to mail through - protects you address from being picked up and spammed, but the forum itself doesn't support attachments to e-mails!
Without Remorse
Novice
Posts: 19
Joined: Sun Jan 30, 2005 2:42 am
Location: Location: Location: Location: Location: Location: Location: Location: Location: Location: Location:

Post by Without Remorse »

I guess you're right about on-forum e-mail not allowing attatchments as I just checked yours. Anyway, I've finally got two savegames with working damage resistance and one with the malfunctioning damage resistance. I just checked again for the save where damage resistance isn't working correctly, apparently it's not just damage resistance from skills that isn't working but also damage resistance from armor and I suspect attributes as well. My guess is the problem is where overall damage resistance is calculated or whatever, but the only exception might have been the magic shield. The problem is, I can never tell if the magic shield ever actually provides damage resistance or not; I had that problem of seeing damage resistance from the shield playing DM on the Amiga too. If it does reduce damage it only seems to reduce it by about half on average, who knows.
User avatar
beowuuf
Archmastiff
Posts: 20687
Joined: Sat Sep 16, 2000 2:00 pm
Location: Basingstoke, UK

Post by beowuuf »

If you e-mail paul, then he can bounce the e-mail back so you have his address for attaching the game
User avatar
Gambit37
Should eat more pies
Posts: 13720
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Post by Gambit37 »

Hmmm.. this all seems very strange. The game has a certain amount of randomness thrown into it's calculations, how can you possibly tell that something is broken against simply being a random spike?
User avatar
Paul Stevens
CSBwin Guru
Posts: 4319
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

You can find my email address in the 'Help/About' menu.
Without Remorse
Novice
Posts: 19
Joined: Sun Jan 30, 2005 2:42 am
Location: Location: Location: Location: Location: Location: Location: Location: Location: Location: Location:

Post by Without Remorse »

Gambit37 wrote:Hmmm.. this all seems very strange. The game has a certain amount of randomness thrown into it's calculations, how can you possibly tell that something is broken against simply being a random spike?
There are actually 2 more things that help me ID the problem. First, slamming a door on my party's head will cause damage like nobody has skills or helmets in the bugged game, whereas in the game where calculations are normal helmets DO protect against doors while Sonja's skills also reduce damage to 5-6.

I also just tested by running into walls. In the bugged game the characters take 2 damage running into the wall while the ok game they take only 1 damage.

Fireballs at the wall also helped to determine this.

Also, just watching the damage my characters took from the water elemental helped ID the problem; it was suspicious to me when the damage Sonja took went from single digits on average to 70+ damage.

And Paul, I found your e-mail. DOH! I wish I thought of looking there earlier.

EDIT: Just re-tested, running into the wall doesn't look like a good testing idea after all, sorry about that.
Without Remorse
Novice
Posts: 19
Joined: Sun Jan 30, 2005 2:42 am
Location: Location: Location: Location: Location: Location: Location: Location: Location: Location: Location:

Post by Without Remorse »

Ok I think I have an idea what might be causing the damage resistance to vary so much. I've been training Stamm today and noticed that his damage resistance went down, up, down, up, then down again just like with Sonja. More importantly, the damage resistance for Stamm changed at the same rope-climbing skill levels as it did for Sonja! I think we've got some integer or floating-point variable wrapping around at regular intervals. One such point seems to lie somewhere between

0x001e0000
and
0x00200000

For both Sonja and Stamm the damage resistance seemed non-existant at 0x001e0000, but it improved back to normal somewhere around 0x001f0000. Also, the rope-climbing skill is listed as skill number 8. Hope this helps.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4319
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

There were some relatively recent changes in exactly
this area. While stepping through the code using your
savegame4 I came to the point where a this recent
correction was made.

You did not say what version of CSBwin you are using.
Could you try the most recent version to see if things seem better?
In any case that is the version I will want to fix if is still broken.

http://dianneandpaul.net/CSBwin/CSBwin98v29.rar
Without Remorse
Novice
Posts: 19
Joined: Sun Jan 30, 2005 2:42 am
Location: Location: Location: Location: Location: Location: Location: Location: Location: Location: Location:

Post by Without Remorse »

Under the 'about' menu it says that I'm using CSB version 9.8? That's odd, because I just downloaded it from the dmweb.free.fr site less than a week ago. I would have thought they'd automatically have the latest version. I'll DL this file and double-check though.
Without Remorse
Novice
Posts: 19
Joined: Sun Jan 30, 2005 2:42 am
Location: Location: Location: Location: Location: Location: Location: Location: Location: Location: Location:

Post by Without Remorse »

I DL'd the 9.8v29, but it doesn't seem to have changed the character damage resistances from what they were before. Also, I'm a little confused about that download because it only uncompressed to release notes and the sword icon labelled 'CSBwin'. Is that all there should be to it?

EDIT: I was previously using the version that just said "version 9.8".
User avatar
beowuuf
Archmastiff
Posts: 20687
Joined: Sat Sep 16, 2000 2:00 pm
Location: Basingstoke, UK

Post by beowuuf »

The official release is 9.8 on the encyclopaedia website
As you may notice Paul is highly active in bug fixing, and other people *cough zyx* are equaally active in asking for things : )
So basically Paul makes each new version that has a bug-fix or added feature available on his webspace (just the core csbwin.exe engine), but since the changes could generate further bugs he doesn't put them up officially
User avatar
Paul Stevens
CSBwin Guru
Posts: 4319
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

I DL'd the 9.8v29, but it doesn't seem to have changed the character damage resistances
Thank you. I didn't want to waste time trying to fix something that was
already fixed. I am adding a lot of trace code to trace the calculations
when the party receives damage.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4319
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

I found a basic flaw in the logic.

When a hero attacks a small adjustment is made to damage resistance.
This can be positive or negative depending on the attack type. The adjustment
is in effect until the attack "recovers", that is until the hero can attack
again (in other words, while the attack button is greyed out). Then the
adjustment is subtracted again.

Now here is the problem. Some attacks (under some circumstances that
I don't understand) have no "timeout". You can attack again immediately. In
these cases the adjustment is made to the damage resistance at the time of the
attack but because there is no "timeout" the adjustment is not deleted.
This is true for your first character when using "PUNCH", for example.
The result is that if every time you do a PUNCH the adjustment is incremented
and eventually gets so big that it goes negative. Then is suddenly changes from
maximum to minimum.

This adjustment was probably intended for things like PARRY to reduce
damage for awhile. Or for stab, to increase damage while you are out of
position and not defending. The graphics file has the adjustment for each
attack type.

The origianl plan was probably to use it for other things because it is a full
16 bits and they add and subtract rather than set and clear. But it is only
used for this one thing. So I think I will fix it by changing it to Set/Clear.
But I am going to sleep on it before making any changes.
Without Remorse
Novice
Posts: 19
Joined: Sun Jan 30, 2005 2:42 am
Location: Location: Location: Location: Location: Location: Location: Location: Location: Location: Location:

Post by Without Remorse »

Wow, that explains it then. There's no delay for using ropes, so that means it wouldn't be resetting the adjusted damage resistance, and why a high rope skill corresponded with a high damage resistance. Thanks for following the lead on this!
User avatar
Paul Stevens
CSBwin Guru
Posts: 4319
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

CSBwin version 9.8v30 is posted. Here is what I wrote in it.

Code: Select all

  i16 word64; // In the original it appeared that this was
              // intended to hold an adjustment to damage
              // resistance.  When an attack was made by a
              // character a positive or negative value was
              // added to this word.  When the attack expired
              // (when the character's attack was no longer
              // disabled) the adjustment was subtracted.
              // Unfortuately, some attacks required no time
              // for recovery.  In such cases the adjustment
              // was made when the attack occurred but, since
              // it never timed out, the adjustment was never
              // canceled.  When a player did hundreds of these
              // attacks the adjustments added up until they
              // overflowed.  Then the value suddenly changed
              // from +32767 to -32768.  It was not too terrible
              // because the final computation was limited to
              // to the range (0, 100).  But it was noticeable
              // and probably hid smaller effects of armor, etc.
              // Since this word is used for only this one thing
              // and since only one adjustment can be in effect
              // at a time I have changed it to set the value
              // and clear the value instead of adding and
              // subtracting.  Wish me luck.


Here is the computation that uses the word describe above.

  D7W = sw(  D7W
           + pcA3->word64
           + pcA3->shieldStrength
           + d.PartyShield
           + D6W);


  D0W = ApplyLimits(0, D7W >>1, 100);

You can see that word64 is used on a par with ShieldStrength
and PartyShield. The limits at the end cause a clipping. THe result
is that when word64 is less than -200 or greater than 200 the effects
are clipped and any shield effects are totally lost.

I am convinced that this was in the original code and not introduced
by my translation.
Without Remorse
Novice
Posts: 19
Joined: Sun Jan 30, 2005 2:42 am
Location: Location: Location: Location: Location: Location: Location: Location: Location: Location: Location:

Post by Without Remorse »

The good news of the update is that damage resistance doesn't oscillate anymore. The bad news is, my characters no longer have the truly rediculous levels of damage resistance they used to!

Haha, actually, thanks for the fix. Really! It's good to have armor, shields and the like useful once again. I can see fire resistance acting the way it's supposed to now, relatively as Gothmog and Stamm don't take quite as much fire damage as my other guys.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4319
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

thanks for the fix
And thank you for the tedious work of uncovering the problem
and insisting that it was a problem.
Post Reply

Return to “Chaos Strikes Back for Windows & Linux (CSBWin) / CSBuild”