to understand Attack Computations..

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
User avatar
zoom
Grand Master
Posts: 1819
Joined: Tue Sep 23, 2003 1:27 am
Location: far away but close enough

to understand Attack Computations..

Post by zoom »

Can someone someday help me to figure out step by step what that is, please?:
http://www.dianneandpaul.net/CSBwin/doc ... Damage.png

maybe a sample instruction will have some value for the wiki in the future?

I have tried to understand it, with starting values some time ago.

(50 Strength, and a weapon weighing 4.2kg & the champion is not dead )
I utterly failed.
throwing distance was a bit more clear, I guess you have to start there, but I soon had difficulties with the syntax.

I do not get what "<-" means?

"smaller than minus"? is it an "arrow" sign?
what means += in that regard?

why are there two D7s? which one do I take when?
is it somehow displayed as a stack?
so upper one will be first to be computed?

where do I "find" P7 and P8?
I can only guess at monster.Desc.uBYTE8, but I would say it`s armor?

a search function (in a wiki) would come in handy, to collect and put all the relevant parts together!

Maybe Adamo , have you some information on this descriptor with
ADGE?

[8] Missile Range. This is computed by the following sequence of operations:
Range = Monster Descriptor Byte8[4] / 4 + 1

I would give this some patience but without help it is criptical to me
beyond hope.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4318
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Re: to understand Attack Computations..

Post by Paul Stevens »

zoooom wrote:
I do not get what "<-" means?

"smaller than minus"? is it an "arrow" sign?
what means += in that regard?


I would give this some patience but without help it is criptical to me
beyond hope.
<- is a 'movement of data'. The thing on the
left is assigned the value of the thing on the right.
a <- b+c means the new value of 'a' is the value of 'b'
plus the value of 'c'

+= means to add the value on the right to the variable on the left.
A+=1 means to increment A.

You can't figure it out???? You ain't alone.

I will take a look at this in a bit more detail and answer
some of your other questions (if possible).


If you turn on attack tracing and look at the trace
and the code you will get some notion of what kinds
of values are assigned to these variables.
For example, P8 is dependent on the type
of attack and the trace will tell you what the
actual value is.

Sophia may know much more about these
things than I. She seems to be very adept at
deciphering this terrible-looking code.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4318
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

I corrected some errors in the diagram.

P8 was, at one time, the eighth parameter
in the function call. P7 the seventh. Etc.
Now that things have been so wildly
rearranged, this is no longer true.
The function is only called from one place
so you can look to see what the parameters are.
User avatar
Adamo
Italodance spammer
Posts: 1534
Joined: Fri Apr 22, 2005 11:59 am
Location: Poland
Contact:

Post by Adamo »

here`s as I see the first line:

Code: Select all

function checks: is the attacking character dead?
[YES]-> the code cancels the operation.
[NO ]-> function checks: is the monster being attacked has nonmaterial flag set?
        [YES]-> function checks: does the character holds vorpal/disrupt in right hand?
                [YES]-> go to line 2 on the diagram.
                [NO ]-> function adjust stamina and cancel the operation. 
        [NO ]-> go to line 2 on the diagram.
Spoiler
(\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/)
Spoiler
(@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@)
Spoiler
(>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<)
User avatar
Adamo
Italodance spammer
Posts: 1534
Joined: Fri Apr 22, 2005 11:59 am
Location: Poland
Contact:

Post by Adamo »

what I don`t get is what function compares in the next step: D0 (quickness) with D1 (..?)
As I see it, D1 is either:
a) random number from 0 to 32 (??)
b) sum of D1 + monsterNumber + levelDiffucilty - 16 (??)

does function compare D0 (quickness) with D1a or D1b, or both of them? or id D1a compared with D1b?
______________________________________________________

EDITED:
OK, I`ve got it now. Function compares character`s quickness with a monster`s quickness, where monster`s quickness is also computed this way:
- random number from 0 to 31 is added to monster`s quickness
- level difficulty is added to monster`s quickness
- number 16 is distracted from monster`s quickness.

(credits for crunching this stuff to Sophia and Paul)
Last edited by Adamo on Fri Jan 25, 2008 3:22 pm, edited 1 time in total.
Spoiler
(\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/)
Spoiler
(@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@)
Spoiler
(>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<)
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Post by Sophia »

In the process of writing DSB, I had to try to understand this function (and I got a lot of it wrong, that had to be fixed later...), so I will do my best to try to explain what's going on.

monsterDesc.uByte8[4] is the monster's "quickness" value.
This value is added to the level's difficulty (that is, its experience multiplier), and a random number from 0 to 31. From this, 16 is subtracted. Then this value is compared with the champion's quickness.

You've also got a 1 in 4 (the "random(4)" thing) chance of a lucky hit even if you're not quick enough. Finally, your luck value is checked against 75 - P7, where P7 = a "required luck" value specified by the attack method. This is where it comes from.

After this, the chart is easier (well, sort of) to follow. You can see the calculations done to the "throwing distance." P8 is another value specified by the attack method. DSB calls it "power" for lack of a better term-- it's added to the damage that you're going to do.

Meanwhile, D4 gets a random value plus monsterDesc.uByte8[0], which is an armor value for the monster, plus the difficulty again. This value is reduced if you're using the special weapons Diamond Edge or Executioner. Then, the damage you would do (D7) has a random value added to it and the monster's defense (D4) subtracted from it. This value is stored in D6.

All that stuff with "delta" in the lower right is giving you some random chance of doing a little more damage if your attack is so pathetic you somehow managed to do negative damage.

Finally, experience is allocated, by taking into account the monster's "experience factor" (word16.bits8-11) as well as the damage done. You also get a bonus of 3 xp. (Why 3? Who knows...)

I think that in this place where experience is allocated, there's a mistake in the chart. It says:

Code: Select all

D0 = D7
D0 += monsterDesc.word16.bits8-11
D0 += 3
However, the original code has:

Code: Select all

D0W = sw((D7W * pmtDesc->word16_8_11() / 16) + 3);
So unless I've misinterupted something it seems like it should be

Code: Select all

D0 = D7 * monsterDesc.word16.bits8-11
D0 /= 16
D0 += 3
Anyone who is interested could always dig around in the CSBwin or DSB source code if you really want to get up close and personal with this stuff. :)
I think the DSB code is a little more readable, but I can't guarantee it's 100% accurate to DM. (It's only as accurate as I'm able to understand this stuff!) Of course the CSB code is the most authentic and if you really want to dive in I'd recommend it.
Paul Stevens wrote:She seems to be very adept at deciphering this terrible-looking code.
So I could write some of my own terrible-looking code. ;)
User avatar
Adamo
Italodance spammer
Posts: 1534
Joined: Fri Apr 22, 2005 11:59 am
Location: Poland
Contact:

Post by Adamo »

10000* thanx for Paul and Sophia for the diagram and a description!!! Even I`m starting to understand some stuff
So I could write some of my own terrible-looking code. Wink
please do complicate DSB functions!! Maybe 20 years later some maniacs will be decyphering the code and wonder "what the hell was it for?" :lol:
Spoiler
(\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/)
Spoiler
(@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@)
Spoiler
(>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<)
User avatar
Gambit37
Should eat more pies
Posts: 13715
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Post by Gambit37 »

Sophia wrote:All that stuff with "delta" in the lower right is giving you some random chance of doing a little more damage if your attack is so pathetic you somehow managed to do negative damage.
I'm not that interested in the inner workings of DM, but that made me laugh. Is it really possible to do negative damage? Would that be like dropping your own sword on your foot? :-)
User avatar
Paul Stevens
CSBwin Guru
Posts: 4318
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

Thanks, Sophia. I fixed the diagram to
repair that computation. I also added some
of your words as comments.
User avatar
zoom
Grand Master
Posts: 1819
Joined: Tue Sep 23, 2003 1:27 am
Location: far away but close enough

Post by zoom »

Thanks go out to Paul for explaining the chart basics, Adamo for being there and his enthusiasm. Finally Sophia for pointing things out as best as possible ! :o
It is beginning to make sense, and basically I understand it.
thanks again.
... the "throwing distance." P8 is another value specified by the attack method. DSB calls it "power" for lack of a better term-- it's added to the damage that you're going to do.
below is an incomplete chart [image].
there is the "rating" of some weapons shown
(maybe that is P8 from the determinePhysicalAttackdamage-chart?)

took base damage values from the encyclopaedia
basically the rating is the weapon base damage / 32
rating gets then multiplied by each attack method`s value

Code: Select all

base damage  	name of item  	swingrating (16 damage)choprating (48 damage) meleerating (60 damage)

58 		THE INQUISITOR 	29 	n.a. 	n.a.

70 		HARDCLEAVE 	n.a. 	105 	n.a.

60 		MORNING STAR 	30      n.a.  	112
so an axe has as result a lower swing rating as the inquisitor and a morning star has the best swing rating in game!

Image

I would have liked to simulate a sample fight with a screamer on level 2.(start counting with 0). Take any champion and any weapnn.
then see what damage range you may deal. Maybe I do not do it. :idea:
Post Reply

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