F2: new change to the damage calculation - hopefully a fix

Status
Not open for further replies.

Glovz

Vault Dweller
Modder
I have re-examined the original damage formula again with the hope to change the weak damage results when using AP ammo and the overpowered results when using JHP ammo without having to modify the original .pro file values.

I believe I have accomplished this by breaking the one formula into six depending on specific conditions.

The changes I've made treat values from the ammo differently and how the damage resistance level of the armor is factored. Originally the values from the ammo would directly increase or decrease the value of the hit, causing drastic variations in damage caused by using different ammo, and the damage resistance value of the armor would amplify this variation by being a direct percentage of the hit. This meant the player was picking a weapon for the ammo it used rather than the hit/damage range the weapon had. I've changed this so the values from the ammo only affect an armor's ability to resist damage and the resistance percentage of the armor is a value of the armor's threshold, leaving the hit/damage range of the weapon to be a more intuitive indicator of what sort of damage the player could possibly expect while taking into account the damage threshold value of the target's armor.

I believe this is how a player expects to judge weapons, ammo and armor; with the notion that certain types of ammo may augment a weapons ability to do slightly better or worst damage against certain types of armor.

This will replace my previous Combat Overhaul Mod and Tweak. I think of this change as simply a Fix.

I may release a mod that changes .pro file values to hopefully address game balance in the near future.

I want thank Haenlomal for his great mod and help with my Fix. His analytical skills were immensely helpful in the early stages of the Fix and his approach to the damage calculation in his mod, were what got me thinking about where I went wrong in previous mods and how I might go about changing things this time.

Code:
ND = net damage value
RD = random damage value produced from weapons hit damage range
RB = ranged bonus (RB=0 unless the player has Bonus Ranged Damage perk)
CM = critical hit damage multiplier (if no critical hit then CM=2, otherwise assigned value from critical hit table)
ADR = armor damage resistance value
ADT = armor damage threshold value
X = ammo dividend
Y = ammo divisor
RM = ammo resistance modifier (only value allowed to be negative or positive in the equation)
CD = combat difficulty multiplier (Easy=75, Normal=100, Hard=125)

Original:
ND = (((RD+RB)*(X*CM)/Y/2*CD/100)-ADT)*((100-(ADR+RM))/100) // without a doubt this is the original formula, this is what is in the exe, not reverse engineered (though credit must go the Cubik2k for getting close without ever dissembling the exe)
ND then rounded to nearest whole number

Fix/Mod:
ND = ((RD+RB-(ADT+(ADT*1/100*X/Y))+X)*CM/2*CD/100) // if (ADR+RM) is less than or equal to 0
ND = ((RD+RB-(ADT+(ADT*100/100*X/Y))+X)*CM/2*CD/100) // if (ADR+RM) is greater than or equal to100
ND = ((RD+RB-((ADR+RM)/100*X/Y)+X)*CM/2*CD/100) // if ADT is less than or equal to 0
ND = ((RD+RB-(1/100*X/Y)+X)*CM/2*CD/100) // if ADT less than or equal to 0 AND (ADR+RM) is less than or equal to 0
ND = ((RD+RB-(100/100*X/Y)+X)*CM/2*CD/100) // if ADT less than or equal to 0 AND (ADR+RM) is greater than or equal to 100
ND = ((RD+RB-(ADT+(ADT*(ADR+RM)/100*X/Y))+X)*CM/2*CD/100) // all values are available
ND then rounded to nearest whole number

Take a look at the examples provided below. You can also use these links as references for values and test the calculations on your own:
http://fallout.gamepedia.com/wiki/Fallout_2_armor_and_clothing
http://fallout.gamepedia.com/wiki/Fallout_2_weapons
http://fallout.gamepedia.com/wiki/Fallout_2_ammunition

I will add more examples now and again.

Code:
Examples with some common armor and weapons (assuming no range bonus and no critical hit):
Armors:           
None          N
Leather       LA
Metal         MA
Combat        CA
Power         PA
Adv Power     APA
 
10mm Pistol with 10mm JHP Ammunition
Ammo     X/Y     2/1
Ammo     RM      25
 
        Original Formula                               Fixed Formula                                      
        N     LA     MA     CA     PA     APA          N     LA     MA     CA     PA     APA   
ADT     0     2      4      5      12     15           0     2      4      5      12     15 
ADR     0     25     30     40     40     55           0     25     30     40     40     55
--------------------------------------------------------------------------------------------
5       8     4      3      2      0      0            7     3      0      0      0      0
6       9     5      4      2      0      0            8     4      0      0      0      0
7       11    6      5      3      1      0            9     5      1      0      0      0
8       12    7      5      4      1      0            10    6      2      0      0      0
9       14    8      6      5      2      1            11    7      3      0      0      0
10      15    9      7      5      3      1            12    8      4      1      0      0
11      17    10     8      6      4      1            13    9      5      2      0      0
12      18    11     9      7      4      2            14    10     6      3      0      0
--------------------------------------------------------------------------------------------

10mm Pistol with 10mm AP Ammunition
Ammo     X/Y     1/2
Ammo     RM      -25
 
        Original Formula                               Fixed Formula                                      
        N     LA     MA     CA     PA     APA          N     LA     MA     CA     PA     APA   
ADT     0     2      4      5      12     15           0     2      4      5      12     15 
ADR     0     25     30     40     40     55           0     25     30     40     40     55
--------------------------------------------------------------------------------------------
5       3     1      0      0      0      0            6     4      2      1      0      0
6       4     1      0      0      0      0            7     5      3      2      0      0
7       4     2      0      0      0      0            8     6      4      3      0      0
8       5     2      0      0      0      0            9     7      5      4      0      0
9       6     3      0      0      0      0            10    8      6      5      0      0
10      6     3      1      0      0      0            11    9      7      6      0      0
11      7     4      1      0      0      0            12    10     8      7      0      0
12      8     4      2      1      0      0            13    11     9      8      0      0
--------------------------------------------------------------------------------------------

14mm Pistol with 14mm AP Ammunition
Ammo     X/Y     1/2
Ammo     RM      -50
 
        Original Formula                               Fixed Formula                                      
        N     LA     MA     CA     PA     APA          N     LA     MA     CA     PA     APA   
ADT     0     2      4      5      12     15           0     2      4      5      12     15 
ADR     0     25     30     40     40     55           0     25     30     40     40     55
--------------------------------------------------------------------------------------------
12      9     5      2      1      0      0            13    11     9      8      1      0
13      10    6      3      2      0      0            14    12     10     9      2      0
14      11    6      4      2      0      0            15    13     11     10     3      0
15      11    7      4      3      0      0            16    14     12     11     4      1
16      12    8      5      3      0      0            17    15     13     12     5      2
17      13    8      5      4      0      0            18    16     14     13     6      3
18      14    9      6      4      0      0            19    17     15     14     7      4
19      14    9      7      5      0      0            20    18     16     15     8      5
20      15    10     7      6      0      0            21    19     17     16     9      6
21      16    11     8      6      0      0            22    20     18     17     10     7
22      17    11     8      7      0      0            23    21     19     18     11     8
--------------------------------------------------------------------------------------------

Laser Pistol with Small Energy Cell Ammunition
Ammo     X/Y     1/1
Ammo     RM      0
 
        Original Formula                               Fixed Formula                                      
        N     LA     MA     CA     PA     APA          N     LA     MA     CA     PA     APA   
ADT     0     0      4      8      18     19           0     0      4      8      18     19 
ADR     0     20     75     60     80     90           0     20     75     60     80     90
--------------------------------------------------------------------------------------------
10      10    8      2      1      0      0            11    11     4      0      0      0
11      11    9      2      1      0      0            12    12     5      0      0      0
12      12    10     2      2      0      0            13    13     6      0      0      0
13      13    10     2      2      0      0            14    14     7      1      0      0
14      14    11     3      2      0      0            15    15     8      2      0      0
15      15    12     3      3      0      0            16    16     9      3      0      0
16      16    13     3      3      0      0            17    17     10     4      0      0
17      17    14     3      4      0      0            18    18     11     5      0      0
18      18    14     4      4      0      0            19    19     12     6      0      0
19      19    15     4      4      0      0            20    20     13     7      0      0
20      20    16     4      5      0      0            21    21     14     8      0      0
21      21    17     4      5      1      0            22    22     15     9      0      0
22      22    18     5      6      1      0            23    23     16     10     0      0
--------------------------------------------------------------------------------------------
EDIT:
In case I don't get around to adding full charts for them, these other weapons should be changing significantly as well:
The Assult Rifle - slightly weaker with JHP, but much better with AP
The Flamer - all around better
Any Laser, Electric, Plasma, and/or Pulse weapon - better.
 
Code:
// Damage Fix
// by Glovz with a little help from Haenlomal
static _declspec(naked) void DamageFunction1() {
_asm {
   aJmp:
            mov edx,dword ptr ds:[esi+4]; //
            mov eax,dword ptr ds:[esi]; //
            mov ebx,dword ptr ss:[esp+0x18]; // get bonus_ranged_damage
            call DamageFunctionSub1; //
            add ebx,eax; // damage = bonus_ranged_damage + raw_damage
            test ebx,ebx; // compare bonus_ranged_damage less than or equal to zero
            jle zJmp; // if true then skip ahead
            test ebp,ebp; // compare ammo_divisor greater than zero
            jg bJmp; // if true then skip ahead
            mov ebp,0x1; // set ammo_divisor to 1
   bJmp:
            mov eax,dword ptr ds:[esi+0x8]; // get pointer to critters weapon
            call GetAmmoDividend; // retrieve ammo_dividend
            test eax,eax; // compare ammo_dividend is greater than 0
            jg cJmp; // if true skip ahead
            mov eax,0x1; // set ammo_dividend to 1
   cJmp:
            mov edx,eax; // get ammo_dividend
            mov eax,edx; //
            sar edx,0x1f; //
            idiv ebp; // resistance_modifier = ammo_dividend divided by ammo_divisor
            cmp dword ptr ss:[esp+0x2c],0x190; // compare (armor_dr+dr_mod) greater than or equal to 400
            jge zJmp; // if true then ahead
            cmp dword ptr ss:[esp+0x2c],0x64; // compare (armor_dr+dr_mod) less than 100
            jle dJmp; // if true then ahead
            mov dword ptr ss:[esp+0x30],0x64; // some variable set to 100
            imul eax,0x64; // resistance_value = resistance_modifier * 100
            jmp fJmp; // skip ahead
   dJmp:
            cmp dword ptr ss:[esp+0x2c],0x0; // compare (armor_dr+dr_mod) greater than 0
            jg eJmp; // if true then ahead
            mov ebp,0x1; // set value to 1
            imul eax,ebp; // resistance_value = resistance_modifier * 1
            jmp fJmp; // skip ahead
  eJmp:
            imul eax,dword ptr ss:[esp+0x2c]; // resistance_value = resistance_modifier * (armor_dr+dr_mod)
    fJmp:
            mov edx,eax; // get resistance_value
            mov dword ptr ss:[esp+0x30],0x64; // some variable set to 100
            mov eax,edx; //
            sar edx,0x1f; //
            idiv dword ptr ss:[esp+0x30]; // resistance_value = resistance_value divided by 100
            cmp dword ptr ss:[esp+0x28],0x0; // compare armor_threshold less than or equal to 0
            jle gJmp; // if true then skip ahead
            imul eax,dword ptr ss:[esp+0x28]; // resistance_value = resistance_value * armor_threshold
            add eax,dword ptr ss:[esp+0x28]; // damage_reduction_value = resistance_value + armor_threshold
   gJmp:
            mov edx,eax; // get damage_reduction_value
            mov eax,dword ptr ds:[esi+0x8]; // get pointer to critters weapon
            call GetAmmoDividend; // retrieve ammo_dividend
            mov ebp,eax; // get ammo_dividend
            test eax,eax; // compare ammo_dividend is greater than 0
            jg hJmp; // if true skip ahead
            mov eax,0x1; // set ammo_dividend to 1
   hJmp:
            add edx,eax; // damage_reduction_value = damage_reduction_value + ammo_dividend
            sub ebx,edx; // damage = damage - damage_reduction_value
            test ebx,ebx; // compare damage less than or equal to zero
            jle zJmp; // if true then skip
            mov edx,dword ptr ss:[esp+0x24]; // get combined_damage_multiplier (ammo_dividend * critical_multiplier)
            test edx,edx; // compare combined_damage_multiplier greater than 0
            jg iJmp; // if true then skip ahead
            mov eax,0x1; // set critical_multiplier to 1
            jmp jJmp; // skip ahead
    iJmp:
            mov eax,edx; //
            sar edx,0x1f; //
            idiv ebp; // critical_multiplier = combined_damage_multiplier divided by ammo_dividend
            sar eax,0x1; // critical_multiplier = critical_multiplier divided by 2
    jJmp:
            imul ebx,eax; // damage = damage * critical_multiplier
            cmp dword ptr ss:[esp+0x20],0x0; // compare combat_difficulty_setting less than or equal to 0
            jle kJmp; // if true then skip ahead
            imul ebx,dword ptr ss:[esp+0x20]; // damage = damage * combat_difficulty_setting
            mov edx,ebx; // get damage
            mov dword ptr ss:[esp+0x30],0x64; // some variable set to 100
            mov eax,edx; //
            sar edx,0x1f; //
            idiv dword ptr ss:[esp+0x30]; // damage = damage by 100
            mov ebx,eax; // get damage
   kJmp:
            add dword ptr ds:[edi],ebx; // accumulate damage
    zJmp:
            mov eax,dword ptr ss:[esp+0x1c]; // get number of hits
            inc ecx; // counter increments by 1
            cmp ecx,eax; // is counter less than number of hits
            jl aJmp; // loop back to beginning
            jmp DamageFunctionReturn; //
  }
}
 
Does this mod include changes to certain weapons like laser pistols being a lot more powerful? Because in vanilla Fallout 2 laser pistols were pathetic, which made the Salvatores WAY to easy to beat.
 
BarbadosSlim said:
Does this mod include changes to certain weapons like laser pistols being a lot more powerful? Because in vanilla Fallout 2 laser pistols were pathetic, which made the Salvatores WAY to easy to beat.
Take a look at the first post - the Laser Pistol has been added.
 
Great work Glovz! But where do you put this code, just inject the assembly parts into the .exe itself? Wouldn't that break sfall compatibility? EDIT: Ah, stupid me, it's included in Sfall already.

You could also check out my mod, F2WR, Barbados. It powers up the laser weapons + balances many other things, but you can choose which parts you want to install. Installing the Armor, Ammo or Energy parts of F2WR will conflict with this fix, everything else should be fine.
 
Magnus said:
You could also check out my mod, F2WR, Barbados. It powers up the laser weapons + balances many other things, but you can choose which parts you want to install. Installing the Armor, Ammo or Energy parts of F2WR will conflict with this fix, everything else should be fine.

Advertising your own mod in competition's thread? Nasty :twisted:
 
I added the 14mm Pistol with 14mm AP Ammunition to the first post.

It is now the hand cannon it was meant to be. :)
 
hakimio said:
Does this fix affect melee weapons?
I believe melee and hand-to-hand are handled by a different portion of code in the exe. I'm not 100% positive though. I have made sure that the changes I made contain enough value checks that no zero result is returned unintentionally.
 
Glovz said:
I believe melee and hand-to-hand are handled by a different portion of code in the exe. I'm not 100% positive though. I have made sure that the changes I made contain enough value checks that no zero result is returned unintentionally.

Actually, both melee and hand-to-hand uses the same damage calculation procedure. As far as I can tell, if you're using a HtH attack, then the function that normally returns damage from the Bonus Ranged Damage Perk instead returns damage from Bonus HtH Damager perk plus any additional damage from the special Unarmed attacks. The procedure that normally return ammo_dr_mod returns 0 instead, and the procedures ammo_mult and ammo_div return 1 instead (not quite sure about these last two).

-- The Haen.
 
Haenlomal said:
Glovz said:
I believe melee and hand-to-hand are handled by a different portion of code in the exe. I'm not 100% positive though. I have made sure that the changes I made contain enough value checks that no zero result is returned unintentionally.

Actually, both melee and hand-to-hand uses the same damage calculation procedure. As far as I can tell, if you're using a HtH attack, then the function that normally returns damage from the Bonus Ranged Damage Perk instead returns damage from Bonus HtH Damager perk plus any additional damage from the special Unarmed attacks. The procedure that normally return ammo_dr_mod returns 0 instead, and the procedures ammo_mult and ammo_div return 1 instead (not quite sure about these last two).

-- The Haen.
Once again Haen comes through! :ok: :notworthy:

I will double check, but I am 99.99% sure the checks for values in my code and the structure of my formula(s) accommodate this appropriately.

Cheers,
Glovz

EDIT:
Checked - 100% sure all handled.
 
Glovz said:
Once again Haen comes through! :ok: :notworthy:

I will double check, but I am 99.99% sure the checks for values in my code and the structure of my formula(s) accommodate this appropriately.

Cheers,
Glovz

Just did some very quick checking of my notes, and now I'm pretty certain ammo_mult and ammo_div return 1 in the event of a HtH attack. However, it seems like cumulative damage from Bonus HtH attack is added to maximum attack potential of any HtH attack instead of stacked on as a separate bonus. So the damage formula for a HtH attack goes something like this:

raw_damage = random(1, damage_range_of_weapon + melee_damage_bonus_from_strength + bonus_HtH_damage) + special_unarmed_attack_bonus

For unarmed attacks, damage_range_of_weapon is 2. Otherwise, it is the maximum value of whatever the melee weapon stats say.

melee_damage_bonus_from_strength is given by max(player_strength - 5, 1). So the range of this bonus goes from 1-5.

bonus_HtH_damage takes on the values of 0, 2, 4, or 6. Each rank of the Bonus HtH damage perk grants +2 damage bonus. Note that this damage added to the maximum damage potential, so it is part of the initial damage roll. This is different from how Bonus Ranged Damage is processed (i.e. as a tacked on bonus after the damage has been rolled.)

special_unarmed_attack_bonus is the bonus given by the special unarmed attacks. The ReadMe File that comes with the vanilla Fallout 2 installation has the figures. They range from 3 to 12. I see that I had this stat circled in my notes, which I think was an indicator to me to find out whether this increases the maximum Unarmed attack damage potential, or it is tacked on as a bonus after the damage is rolled. Maybe I'll try to figure this out once I get back home later tonight.

At any rate, all this should be calculated by the same function that normally returns raw damage for a ranged attack.

Cheers,

-- The Haen.
 
Haenlomal said:
Glovz said:
Once again Haen comes through! :ok: :notworthy:

I will double check, but I am 99.99% sure the checks for values in my code and the structure of my formula(s) accommodate this appropriately.

Cheers,
Glovz

Just did some very quick checking of my notes, and now I'm pretty certain ammo_mult and ammo_div return 1 in the event of a HtH attack. However, it seems like cumulative damage from Bonus HtH attack is added to maximum attack potential of any HtH attack instead of stacked on as a separate bonus. So the damage formula for a HtH attack goes something like this:

raw_damage = random(1, damage_range_of_weapon + melee_damage_bonus_from_strength + bonus_HtH_damage) + special_unarmed_attack_bonus

For unarmed attacks, damage_range_of_weapon is 2. Otherwise, it is the maximum value of whatever the melee weapon stats say.

melee_damage_bonus_from_strength is given by max(player_strength - 5, 1). So the range of this bonus goes from 1-5.

bonus_HtH_damage takes on the values of 0, 2, 4, or 6. Each rank of the Bonus HtH damage perk grants +2 damage bonus. Note that this damage added to the maximum damage potential, so it is part of the initial damage roll. This is different from how Bonus Ranged Damage is processed (i.e. as a tacked on bonus after the damage has been rolled.)

special_unarmed_attack_bonus is the bonus given by the special unarmed attacks. The ReadMe File that comes with the vanilla Fallout 2 installation has the figures. They range from 3 to 12. I see that I had this stat circled in my notes, which I think was an indicator to me to find out whether this increases the maximum Unarmed attack damage potential, or it is tacked on as a bonus after the damage is rolled. Maybe I'll try to figure this out once I get back home later tonight.

At any rate, all this should be calculated by the same function that normally returns raw damage for a ranged attack.

Cheers,

-- The Haen.
Hmmm...if the above holds true then it looks like another fix is needed. Do you agree?

Small change from this:
raw_damage = random(1, damage_range_of_weapon + melee_damage_bonus_from_strength + bonus_HtH_damage) + special_unarmed_attack_bonus

To this:
raw_damage = random(1, damage_range_of_weapon) + melee_damage_bonus_from_strength + bonus_HtH_damage + special_unarmed_attack_bonus

Also, could you clarify:
melee_damage_bonus_from_strength is given by max(player_strength - 5, 1). So the range of this bonus goes from 1-5.
If the player_strength was equal to 1 then would the above work out to a range of -4 to 1 or would it disallow negatives and force a 0 to 1 range?

Regardless, this might make more sense if changed to:
temp=player_strength divided by 2
temp rounded to nearest whole number
if (temp less than 1) then set temp = 1 --- this is with the assumption that the players strength should never be considered 0
melee_damage_bonus_from_strength = max(temp,1)
 
Bonus HtH damage is definitely added to the maximum damage instead of the minimum like the description says, this has annoyed me since I got the game. It also cannot go below 1.
I made the Melee damage equal to ST/2 with a script, but couldn't find a way to make it add to the minimum damage only.
If you decide to fix this, could you possibly make it a separate option in the sfall ini, as I for one would prefer having only that one activated :)
 
Magnus said:
Bonus HtH damage is definitely added to the maximum damage instead of the minimum like the description says, this has annoyed me since I got the game. It also cannot go below 1.
I made the Melee damage equal to ST/2 with a script, but couldn't find a way to make it add to the minimum damage only.
If you decide to fix this, could you possibly make it a separate option in the sfall ini, as I for one would prefer having only that one activated :)
If this gets fixed then I definitely would want to see it as seperate from the damage calculation fix, for the exact reason of giving modders options. I'm hoping to work with Haen on this, as he is better at debugging/tracing the exe then I am.
 
Hi Glovz,

First of all, some clarification:

Glovz said:
Also, could you clarify:
melee_damage_bonus_from_strength is given by max(player_strength - 5, 1). So the range of this bonus goes from 1-5.
If the player_strength was equal to 1 then would the above work out to a range of -4 to 1 or would it disallow negatives and force a 0 to 1 range?

Actually, notice that I wrote max(player_strength - 5, 1), so if player_strength - 5 dips below 1, then it will be a 1. Also, I forgot about the Heavy Handed Trait. If the player has the Heavy Handed Trait, then add 4 to the figure.

=======

Anyway, I've had some time to work my way through the damage code tonight. I still haven't traced through everything, but I can present some of my findings:

  1. With respect to Melee and Unarmed attacks, the interesting part of the code happens in the function located in offset 0x00478448, the same one named DamageFunctionSub1 in sfall.
  2. 0x00478448 retrieves the max damage and min damage of the weapon in question. If it's an attack made without weapons, max damage is 2 (0x004784A7), and min damage is 1 (0x00478492).
  3. If the attack is made without weapons, then the Melee Damage stat is retrieved and added to the maximum possible damage. Due to processing for the special unarmed attacks (see next point), this occurs in two places in the code: 0x004784A2 and 0x0047854C.

    [list:0f6f73dae9]
  4. Side Note: The function that does the actual work of retrieving the Melee Damage Stat is located at offset 0x004AEF48, which is a very complicated function, and called from all over the place in the exe. I think it's a generic GetCritterStat( CRITTER* a , int stat ) function. Register EAX contains a pointer to the critter, and register EDX contains a constant which corresponds to the specific critter attribute to be retrieved. In our case, EDX contains the value of "0x0B", and according to define.h, attribute 11 is STAT_melee_dmg. :) By looking up the proper constants from define.h, we can make very good use of this function -- at least in theory. :P

[*] If the attack is made without weapons, then there's a further determination made to see if the attack is a special Unarmed attack. If it is, then unarmed_attack_bonus is set to its proper value via a case statement. This occurs in offset 0x004784AA - 0x004784F5 of the code. Unarmed_attack_bonus is then added to BOTH the max and min damage (0x0047855C - 0x0047855F).

[*] After all of the above is done, the maximum and minimum damage is sent off to a function that simply returns a random integer between the maximum value and minimum value inclusive. This occurs near the end of the function at offset 0x00478560.

[*] So where does the Bonus HtH Damage perk come in? Good question. It's actually returned as part of the GetCritterStat function. Apparently, whenever the player gets a rank of the Bonus HtH Damage perk, the Melee Damage is updated immediately by +2. So when the game retrieves the Melee Damage info for the player, the return figure already has the damage from Bonus HtH Damage perk included. It isn't immediately obvious (at least to me) how we go about isolating Bonus HtH Damage perk from the normal Melee Damage stat. I have a few ideas, but will need more time to test them out...
[/list:o:0f6f73dae9]

Based on the above, the damage formula for any hand-to-hand weapon and ordinary unarmed attack (min 1, max 2) seem to be:

Code:
raw_damage = random(min_damage_of_weapon, max_damage_of_weapon + bonus_melee_damage)

Where:

Code:
bonus_melee_damage = max(player_strength - 5, 1) + heavy_handed_bonus + (2 * rank_of_bonus_hth_damage_perk)

And heavy_handed_bonus is 4 if the player has the Heavy Handed Trait, zero otherwise.

For a special unarmed attack, the formula changes a bit to:

Code:
raw_damage = random(1 + unarmed_attack_bonus, 2 + bonus_melee_damage + unarmed_attack_bonus).

Cheers,

-- The Haen.
 
Haenlomal said:
Based on the above, the damage formula for any hand-to-hand weapon and ordinary unarmed attack (min 1, max 2) seem to be:

Code:
raw_damage = random(min_damage_of_weapon, max_damage_of_weapon + bonus_melee_damage)

Where:

Code:
bonus_melee_damage = max(player_strength - 5, 1) + heavy_handed_bonus + (2 * rank_of_bonus_hth_damage_perk)

And heavy_handed_bonus is 4 if the player has the Heavy Handed Trait, zero otherwise.

For a special unarmed attack, the formula changes a bit to:

Code:
raw_damage = random(1 + unarmed_attack_bonus, 2 + bonus_melee_damage + unarmed_attack_bonus).

Cheers,

-- The Haen.
Hi Haen,

If you were to provide me with the the original section of code with minimal commenting as to where there values come in, I should be able to help out with changes.

I figure the changes should be:
Code:
raw_damage = random(min_damage_of_weapon, max_damage_of_weapon) + bonus_melee_damage
Code:
bonus_melee_damage = max(player_strength - 5, 1 + (2 * rank_of_bonus_hth_damage_perk)) + heavy_handed_bonus
Code:
raw_damage = random(1 + unarmed_attack_bonus, 2 + unarmed_attack_bonus) + bonus_melee_damage

This change by cracycc also seems to be interesting, just wondering if you had a chance to evaluate it and/or if it would interfere with anything we are trying to do now:
crazycc said:
I also made the hth evade perk works on both melee and unarmed attack.The code for hth evade is
Code:
004AF007   BA 5D000000      MOV EDX,5D				;h2h evade
004AF00C   E8 677BFEFF      CALL fallout2.00496B78
004AF011   85C0             TEST EAX,EAX
004AF013   0F84 83000000    JE fallout2.004AF09C
004AF019   A1 B8106600      MOV EAX,DWORD PTR DS:[6610B8]
004AF01E   E8 4D2BFCFF      CALL fallout2.00471B70		;get item ptr on right slot
004AF023   89C2             MOV EDX,EAX
004AF025   85C0             TEST EAX,EAX
004AF027   74 16            JE SHORT fallout2.004AF03F
004AF029   E8 CE8AFCFF      CALL fallout2.00477AFC		;get item type
004AF02E   83F8 03          CMP EAX,3
004AF031   75 0C            JNZ SHORT fallout2.004AF03F
004AF033   8BC2             MOV EAX,EDX
004AF035   E8 6E9DFCFF      CALL fallout2.00478DA8		;get weapon type
004AF03A   83F8 04          CMP EAX,4
004AF03D   7F 5D            JG SHORT fallout2.004AF09C		;branch if gun type
004AF03F   A1 B8106600      MOV EAX,DWORD PTR DS:[6610B8]
004AF044   E8 732BFCFF      CALL fallout2.00471BBC		;get item ptr on left slot
004AF049   8BD0             MOV EDX,EAX
004AF04B   85C0             TEST EAX,EAX
004AF04D   74 16            JE SHORT fallout2.004AF065
004AF04F   E8 A88AFCFF      CALL fallout2.00477AFC		;get item type
004AF054   83F8 03          CMP EAX,3
004AF057   75 0C            JNZ SHORT fallout2.004AF065
004AF059   8BC2             MOV EAX,EDX
004AF05B   E8 489DFCFF      CALL fallout2.00478DA8		;get weapon type
004AF060   83F8 04          CMP EAX,4
004AF063   7F 37            JG SHORT fallout2.004AF09C		;branch if gun type
004AF065   8B5424 04        MOV EDX,DWORD PTR SS:[ESP+4]
004AF069   03D2             ADD EDX,EDX
004AF06B   A1 B8106600      MOV EAX,DWORD PTR DS:[6610B8]
004AF070   895424 04        MOV DWORD PTR SS:[ESP+4],EDX
004AF074   BA 03000000      MOV EDX,3				;unarmed
004AF079   E8 DAB4FFFF      CALL fallout2.004AA558		;get skill level
004AF07E   8BF8             MOV EDI,EAX
004AF080   A1 B8106600      MOV EAX,DWORD PTR DS:[6610B8]
004AF085   BA 04000000      MOV EDX,4				;melee
004AF08A   E8 C9B4FFFF      CALL fallout2.004AA558		;get skill level
004AF08F   03C7             ADD EAX,EDI				;unarmed + melee
004AF091   C1F8 04          SAR EAX,4				;skill / 16
004AF094   90               NOP
004AF095   90               NOP
004AF096   90               NOP
004AF097   90               NOP
004AF098   90               NOP
004AF099   90               NOP
004AF09A   89C5             MOV EBP,EAX
If it seems viable the way it is and does not interfere then I will put it in a form that can be added to sfall (of course with surely some help from Timeslip :D ).
 
I'd like to comment.
bonus_melee_damage = max(player_strength - 5, 1 + (2 * rank_of_bonus_hth_damage_perk)) + heavy_handed_bonus
What is this going to do? From the look of it, it appears that player's strength bonuses and perk bonuses will be mutually exclusive, which seem wrong to me.

Personally I like the idea of 'bonus_melee_damage' increasing only maximum damage. I like the way the damage is randomised. Though I agree that the placement of 'rank_of_bonus_hth_damage_perk' is wrong and this perk should increase 'raw_damage' directly (and seeing it's drawbacks, maybe 'heavy_handed_bonus' should, too).

I propose:
raw_damage = random(min_damage_of_weapon, max_damage_of_weapon + bonus_melee_damage) + (2 * rank_of_bonus_hth_damage_perk)

bonus_melee_damage = max(player_strength - 5, 1) + heavy_handed_bonus

raw_damage = random(1 + unarmed_attack_bonus, 2 + bonus_melee_damage + unarmed_attack_bonus) + (2 * rank_of_bonus_hth_damage_perk).

After all, it clearly says in the perk's description that after picking 'Bonus HtH Damage' all your HtH attacks will be dealing additional 2 pts of damage, but nowhere does it say that STR stat and heavy handed trait work in the same way.
 
Nevill said:
I'd like to comment.
bonus_melee_damage = max(player_strength - 5, 1 + (2 * rank_of_bonus_hth_damage_perk)) + heavy_handed_bonus
What is this going to do? From the look of it, it appears that player's strength bonuses and perk bonuses will be mutually exclusive, which seem wrong to me.

Personally I like the idea of 'bonus_melee_damage' increasing only maximum damage. I like the way the damage is randomised. Though I agree that the placement of 'rank_of_bonus_hth_damage_perk' is wrong and this perk should increase 'raw_damage' directly (and seeing it's drawbacks, maybe 'heavy_handed_bonus' should, too).

I propose:
raw_damage = random(min_damage_of_weapon, max_damage_of_weapon + bonus_melee_damage) + (2 * rank_of_bonus_hth_damage_perk)

bonus_melee_damage = max(player_strength - 5, 1) + heavy_handed_bonus

raw_damage = random(1 + unarmed_attack_bonus, 2 + bonus_melee_damage + unarmed_attack_bonus) + (2 * rank_of_bonus_hth_damage_perk).

After all, it clearly says in the perk's description that after picking 'Bonus HtH Damage' all your HtH attacks will be dealing additional 2 pts of damage, but nowhere does it say that STR stat and heavy handed trait work in the same way.
Hi Nevill,

First, thank you for the input - different opinions are always welcome.

Not sure I agree with your changes, something to consider is that bonus values should almost always be added after primary calculations.

Not entirely sure of what changes will be feasible at this point until Haen considers the purposed changes and/or posts the original code.

Cheers,
Glovz
 
Hi all,

First, my apologies to Glovz for de-railing his thread. If you want, maybe we get a mod to move all relevant posts to another thread?

Scond, I'll be busy most of the day with at a friend's wedding this afternoon, so I won't be able to contribute much today. I'll say, though, that I've managed to isolate the function that returns whether or not a player has a certain trait, so with this, I should be able to isolate the raw melee bonus damage from the heavy handed bonus and from the bonus Hth damage perk. The code would look something like this:

Code:
mov edx, 0x0B;   // set Melee Damage attribute argument
mov eax, ecx;     // set pointer to critter (assuming it's stored in ecx)
call 0x004aef48; // call GetCritterStat( CRITTER* eax, 0x0B)
mov ebp, eax;    // store result in ebp
mov eax, 0x06;  // Pass argument 6 (TRAIT_heavy_handed)
call 0x004B3bc8; // Retrieve Player Trait
cmp eax, 0x01;   // does player have heavy handed trait?
jne ajmp;
imul eax, 0x04;
sub ebp, eax;    // if yes, subtract 4 from melee damage
ajmp:
xor edx, edx;   // set Strength attribute argument
mov eax, ecx;     // set pointer to critter (assuming it's stored in ecx)
call 0x004aef48; // call GetCritterStat( CRITTER* eax, 0x00)
sub eax, 0x05;  // subtract 5 from strength to get melee bonus
cmp eax, 0x01; // is it less than 1?
jge bjmp;
mov eax, 0x01; // if yes, set it to 1
bjmp:
sub ebp, eax; // subtract melee bonus to get bonus from bonus hth perk

Of course, I haven't added checks to make sure the critter is the PC, or else I think that has_trait call may crash the game. But it's a start.

Cheers,

-- The Haen.
 
Status
Not open for further replies.
Back
Top