Page 1 of 1

+Damage+

Posted: Wed Sep 08, 2004 7:23 pm
by Automaton
I looked through Paul's diagrams of how damage is calulated and I feel a "7 on the richter scale" headache coming on :wink:

Could Paul enlighten us a little better as to what the algorythm is doing and what values certain parameters can have and why?

e.g. What is "Quickness (hero)" and what values can it have and why?

Also, I haven't seen in any of my reading anything pertaining to dmg multipliers depending on which way a monster is facing when you hit it. Is it true you do (ooh eer missus) more dmg from the rear ? (Maybe this is expressed in the algorythmn somewhere and I just don't know what I'm looking at..)

Anyone care to enlighten ?

Cheers!

Autom

Posted: Thu Sep 09, 2004 2:27 am
by Paul Stevens
Thanks. I like questions. I'm trying to release version 9.8
right now. If I don't get back to this in a week, let me know.

Posted: Thu Sep 09, 2004 8:25 am
by beowuuf
I don't think you do more damage depending on monster facing, you are just more likely to take less damage : )
I'vve never noticed four square dances attacking unprotected flanks doing any more damage than stand up fights

Posted: Thu Sep 09, 2004 4:38 pm
by Paul Stevens
Good news. The term I labeled 'quickness' can be described on three lines:

Code: Select all

quickness = (dexterity + random(8)) * ( 1 - 0.5 * (load / maxLoad ))
if (sleeping) quickness /= 2
quickness = limit(quickness, random(8) + 1, 100 - random(8))
So the result is generally between about 5 and 95.

By the way........if you want to see the values and such....have you turned on
the trace and followed it through a couple of attacks along with studying the
flowchart? When you find things that don't match up or are still comfusing,
ask for additional trace points in the code. I will be happy to add them in
a day's time and post the new executable. I appreciate the difficulty of
studying these things and the general interest in understanding them. Anything
you can contribute to things like better variable names or simplified diagrams
is welcome.

Posted: Fri Sep 10, 2004 7:58 pm
by Automaton
Cheers Paul!

I ran some attack trace in CSBWin and it looked pretty clear.
I've tryed to split it into the exact functions which must be:-

Have I or haven't I hit ?
What dmg have I done?
Dec STA for trying anyhow.
Redu Monster HP by dmg done if it is done.

The interesting thing looks to be that XP is gained regardless of what dmg you do or if you miss or not the only requisites are that you are attacking a monster?

snip-------------------------------------------------------------------------------
Char and position;TUNDA attacks from 08(0a,0b) to 08(0a,0c)
Compute XP gain;Attack type = 25 = MELEE
Compute XP gain;Skill number required = 06
Compute XP gain;Byte20046[attackType=25] = 25
Compute XP gain;w_10 = Byte20046[attackType=25] + Random(1) = 26
Compute XP gain;experiencedGained = Byte20178[attackType=25] = 24
?; Enter TAG01bc2a (attackType=25, skillNumber=6)
?; D6W=Byte20002[attackType=25]=64
?; D7W=Byte19958[attackType=25]=60
?; Calling TAG00f930(character, monster, D5W-1, D6W, D7W, skillNumber)
?; Entering TAG00f930(char=0,monster,P4=1,P7=64,P8=60,skillNumber=6)
?; levelDifficulty = 4
?; pi26 word2 &0x40 == 0 or vorpalOrDisrupt
Compute "to hit" roll; Entering function to determine character's Quickness
Compute "to hit" roll; quickness = (Dexterity=58) + (random(8)=2) --> 60
Compute "to hit" roll; About to compute Maximum load
Compute "to hit" roll; Loading effect=(quickness/2)*(load=306)/(maxload=540)-->17
Compute "to hit" roll; Subtract loading effect from quickness -->43
Compute "to hit" roll; Low Limit = random(8) + 1 --> 2
Compute "to hit" roll; High Limit = 100-random(8) --> 95
Compute "to hit" roll; Final quickness = 21
Compute "to hit" roll; character's quickenss = 21
Compute "to hit" roll; required quickness = (pi26.uByte8[4]=40) + (random(32)=12) + (levelDifficulty=4) - 16 = 40
Compute "to hit" roll; Enter TAG016476 (TUNDA , (P2=11))
Compute "to hit" roll; Returning 1 Attack was successful because TAG016476 returned non-zero value
Compute dmg to inflict; D7W = Throwing distance=62
Compute dmg to inflict; D7W = D7W+random(D7W/2+1) = 84
Compute dmg to inflict; D7W = D7W*(P8=60)/32 = 157
Compute dmg to inflict; D4W = (i26->uByte8[0]=25) + (levelDifficulty=4) + (random(32)=18) = 47
Compute dmg to inflict; D7W = D7W + (random(32)=6) - (D4W=47) = 116
Compute dmg to inflict; D6W = D7W = 116
Compute dmg to inflict; Divide D7W by 2 --> 58
Compute dmg to inflict; D0W=random(D7W) --> 37
Compute dmg to inflict; D7W += (random(4)=1) + (D0W=37) --> 96
Compute dmg to inflict; D7W += (random(D7W)=87)--> 183
Compute dmg to inflict; Divide D7W by 4 --> 45
Compute dmg to inflict; D7W += (random(4)=0) + 1 --> 46
Compute dmg to inflict; Enter DetermineMastery(hero=TUNDA, skill=6)
Compute dmg to inflict; Extract two flags from skill number.
Compute dmg to inflict; flag8000 = skill&0x8000 --> 0
Compute dmg to inflict; flag4000 = skill&0x4000 --> 0
Compute dmg to inflict; SkillNumber = 6
Compute dmg to inflict; Mastery = log2(Experience=269) --> 8
Compute dmg to inflict; Mastery of skill 6 is 8
Compute dmg to inflict; w_2 = DamageMonster(D7W=46) --> 1
?; D0W = ((D7W=46) * (Bits8_11(i26.word16)=4)/16) + 3 --> 14
?; AdjustSkills((skill=6), (D0W=14))
STA drain for sucessful move?; Decrement Stamina by random(4)+4 = 4
dmg inflicted result?; TAG00f930 returning D7W = 46
Result variable passed from sub rout to main game?; Word20264 = Result of calling TAG00f930 = 46
Return to caller?; Return 1
snip-------------------------------------------------------------------------------

I think your quickness you could rename to the D&D "To hit"

Paul, can you precise on what some of this trace code is telling us?

Kudos for the trace in the first place.

I would realy like to know which line is saying "do this damage to the monster that was hit" and exactly what the throwing distance has to do with the price of a hallibut in any case???

And what does it mean? My final To hit=21 and the required is 40, but returning a non zero value is OK.... ??

Cheers!

Autom

Posted: Fri Sep 10, 2004 9:31 pm
by Paul Stevens
I think your quickness you could rename to the D&D "To hit"
Unfortunately, the function that computes this is used for many
other things. "To not be hit", etc. In this context, we could
certainly say that "to-hit = quickness". But one should be careful
not to confuse matters with many names for the same calculation.
I will wait until you are rather sure you know what is happening before
renaming things.
can you precise on what some of this trace code is telling us?
Good grief, no! If I knew what was going on then I would never have
produced this ugly trace with the unnamed functions and variables. The
purpose of the trace was to give someone (perhaps a graduate student
with a year on his hands) some hope of deciphering the code. If I were
to attempt this I would examine the trace along with the diagram I have
drawn along with the code itself. Try to make some sense out of some
small part of it. Comment the code a little better. Change a variable
name to something more informative. Redraw part of the diagram.
Improve one of the traces. Add a new trace. If doing these things seems
to have helped with your understanding then adopt the changes and start
over in the hope that something else can be improved/documented.
would realy like to know which line is saying "do this damage to the monster that was hit"
Indeed. When you find it and decipher it we will all be interested in your
astute analysis.
And what does it mean
I hope you are not asking me! I never figured it out. I like to think that
this is because I am lazy rather than that it is beyond my comprehension.