my small change on damage formula and hth evade perk

crazycc

First time out of the vault
I try to change the damage formula so the damage range will be more acceptable, the bonus range attack now works as a percentage damage bonus, and I also make the hth evade perk works on both melee and unarmed attack.

The new damage formula is:
(base_dmg - dmg_tresh)*(100-dmg res)%*(dmg_multi/dmg_div)*(dmg_bonus+cmb_diff)%

and the code is
Code:
004249EC   8B5C24 24        MOV EBX,DWORD PTR SS:[ESP+24]	;load dmg_multi
004249F0   8B56 04          MOV EDX,DWORD PTR DS:[ESI+4]	;index of slot
004249F3   8B06             MOV EAX,DWORD PTR DS:[ESI]		;char ptr
004249F5   E8 4E3A0500      CALL fallout2.00478448		;get base dmg
004249FA   2B4424 28        SUB EAX,DWORD PTR SS:[ESP+28]	;base dmg - dmg tresh
004249FE   7E 3B            JLE SHORT fallout2.00424A3B		;branch if <= 0
00424A00   BA 64000000      MOV EDX,64
00424A05   2B5424 2C        SUB EDX,DWORD PTR SS:[ESP+2C]	;100 - dmg res
00424A09   F7E2             MUL EDX				;dmg*=(100-dmg res)
00424A0B   F7E3             MUL EBX				;dmg*=dmg_multi
00424A0D   D1E8             SHR EAX,1				;dmg/2
00424A0F   33D2             XOR EDX,EDX
00424A11   F7F5             DIV EBP				;dmg/dmg_div
00424A13   8B5C24 18        MOV EBX,DWORD PTR SS:[ESP+18]	;load bonus range dmg
00424A17   C1E3 03          SHL EBX,3				;bonus * 8
00424A1A   035C24 20        ADD EBX,DWORD PTR SS:[ESP+20]	;bonus + cmbt_multi
00424A1E   F7E3             MUL EBX				;dmg*=(bonus+comb_multi)
00424A20   BB 10270000      MOV EBX,2710
00424A25   33D2             XOR EDX,EDX
00424A27   F7F3             DIV EBX				;dmg/10000
00424A29   0107             ADD DWORD PTR DS:[EDI],EAX		;total dmg += dmg
00424A2B   B8 02000000      MOV EAX,2				;min_dmg_multi = 2
00424A30   8B5424 24        MOV EDX,DWORD PTR SS:[ESP+24]	;max_dmg_multi = dmg_multi
00424A34   E8 87E6FEFF      CALL fallout2.004A30C0		;get a random number [min_dmg_multi, max_dmg_multi]
00424A39   8BD8             MOV EBX,EAX				;ebx = new dmg_multi
00424A3B   8B4424 1C        MOV EAX,DWORD PTR SS:[ESP+1C]	;load # of att
00424A3F   90               NOP
    |       |               |
    |       |               |
    |       |               |
00424A5D   90               NOP
00424A5E   41               INC ECX
00424A5F   3BC8             CMP ECX,EAX
00424A61   7C 8D            JL SHORT fallout2.004249F0		;branch if more than one 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
 
Personally I've found the native damage formula to be pretty flexible, it's just the default armor and ammo stats that are bad. Also, HtH evade is one of my favorite perks, because it only checks for melee weapons or guns, meaning I can walk around with a Power Fist and a Plasma Grenade and still get the AC bonus.

Creds to you for modifying the engine, though. Sure wish I knew how to code in assembly. Where is this code from anyway, do you open the .exe in some debug program and then rewrite it? It surely isn't just a hex editor?
 
I use ollydbg to debug fallout, it is a free and good window debugger. Assembly is not that hard, you can learn by yourself if you want.

The reason I want to change to formula is the damage range is so unreliable. When it is a critical hit and bypass armor, both DR and DT reduce to 1/5, and the base damage increases 2 to 3 times, so a 10-15 damage weapon can deal 20-30+ damage to power armor while it can not deal any damage if it is not a critical hit. If it is a burst attack, like minigun, you are basically ruined. That is why sometimes you can see the damage go up to 400+ with burst attack.
 
crazycc said:
When it is a critical hit and bypass armor, both DR and DT reduce to 1/5, and the base damage increases 2 to 3 times, so a 10-15 damage weapon can deal 20-30+ damage to power armor while it can not deal any damage if it is not a critical hit. If it is a burst attack, like minigun, you are basically ruined. That is why sometimes you can see the damage go up to 400+ with burst attack.

Yes, i have to agree i find the 'bypass armor' sorry-you're-dead-even-if-enemy-is-only-using-a-crappy-SMG-and-you're-wearing-advanced-power-armor-mkII result sometimes seems a little OTT. Personally, i would like to see the DR & DT reduced to 1/2 or something similar....
 
From what little I understand,
XOR EDX, EDX
sets all the EDX bits to 0. I'm guessing it's some kind of measurement to prevent division by zero before an IDIV, but how does this work exactly?

By the way, how did you locate these code bits? using a C debugger to check the offset?

Also, I can't see how your new damage formula really differs from the old one. Reducing the power of criticals is probably a good idea, though.
 
Josan12 said:
Personally, i would like to see the DR & DT reduced to 1/2 or something similar....

Yeah, this is one solution, this code is at offset 0x42486f to 0x4248a6

Code:
0042486F   89CA             MOV EDX,ECX
00424871   C1E2 02          SHL EDX,2
00424874   01CA             ADD EDX,ECX
00424876   C1E2 02          SHL EDX,2
00424879   BB 64000000      MOV EBX,64
0042487E   89D0             MOV EAX,EDX
00424880   C1FA 1F          SAR EDX,1F
00424883   F7FB             IDIV EBX
00424885   8B5424 08        MOV EDX,DWORD PTR SS:[ESP+8]
00424889   894424 28        MOV DWORD PTR SS:[ESP+28],EAX
0042488D   8D0495 00000000  LEA EAX,DWORD PTR DS:[EDX*4]
00424894   01C2             ADD EDX,EAX
00424896   C1E2 02          SHL EDX,2
00424899   89D0             MOV EAX,EDX
0042489B   C1FA 1F          SAR EDX,1F
0042489E   F7FB             IDIV EBX
004248A0   894424 2C        MOV DWORD PTR SS:[ESP+2C],EAX
004248A4   EB 61            JMP SHORT fallout2.00424907


Magnus said:
From what little I understand,
XOR EDX, EDX
sets all the EDX bits to 0. I'm guessing it's some kind of measurement to prevent division by zero before an IDIV, but how does this work exactly?

By the way, how did you locate these code bits? using a C debugger to check the offset?

Also, I can't see how your new damage formula really differs from the old one. Reducing the power of criticals is probably a good idea, though.

If you divide a 32-bit integer, you need to put the dividend in eax and do the sign extension in edx, for positive number, the sign extension is zero.

You can use some software that can scan memory, like cheat engine, to locate some stats of the character, and then set a break on read/write at that address in the debugger. When the program breaks, you can check the codes around this location.

The new formula will give you advantage of high DT. Since the orignial formula applys dmg_multi before DT, a critical will work like some kind of armor bypass. The new one prevents this, if the DT is high enough, there will be no damage regarding critical as long as it is not armor bypass. Now those weapons with penetrate perk are very useful (.223 pistol, melee weapons)

I will work on this, probably will apply random number on dmg_multi if it is a burst attack to make dmg_multi of each bullet independent of another.
 
Nice work :)
However check your formula:

Code:
(base_dmg - dmg_tresh)*(100-dmg res)%*(dmg_multi/dmg_div)*(dmg_bonus+cmb_diff)%

Where is dmg_res_modifier of ammo???
 
Cubik2k said:
Where is dmg_res_modifier of ammo???

The dmg_res_modifier of ammo is included in the dmg_multi
dmg_multi = ammo_multi * critical_multi, the code is right before the damage calculation loop, some more detail

Code:
DT = armor DT
DS = armor DS
damage divisor = 1
damage multiplier = critical multiplier(2, 4, 6)
if (armor bypass)
    reduce DT and DS to 1/5 of value
else if (has weapon penetrate or some unarmed attacks)
   reduce DT to 1/5 of value
   if (has finesse trait) add 30 to DS

get the combat difficulty multiplier(75, 100, 125)
DS = DS + ammo_DS

if (DS smaller than 0)  DS = 0
if (DS larger than 100)  DS = 100

damage multiplier = critical multiplier * ammo multiplier
damage divisor = 1 * ammo divisor
damage caluculation loop

Updated the formula including random damage multiplier for burst attack
 
@crazycc

I gave modifying the damage formula a try but my understanding of the engine was limited.

Don't know if you reviewed my work, if you get a chance take a look.

You are definitely more skilled then I am.
 
Holy crap, some major staging going on in here. Perhaps you could team up with Glovz\Magnus or both of them and make a kick-ass balance mod?
 
I personally am not too keen on making burst damage more random than it already is. Really, it's like rolling a pair of dice with 100 sides blindfolded while standing on your head and clipping your toenails.
I do however like the idea of keeping more of the DR and DT effective against those massive criticals, which would go especially nice with the huge damage modifier I've given JHP in F2WR.
In any case I'd wait with modifying the engine until Killap releases Fallout 2.3, but I'd be thrilled to work with crazycc in any damage-balancing endeavour.

P.S:
Highest on my wish list right now is to reduce the AP cost of the Unarmed special attacks to the following:
Jab 3, Palm Strike 4, Pierce Strike 5
Hip Kick 5, Hook Kick 6, Pierce Kick 7
and to give Hip Kick a 10% bonus to critical so there's any point in using it. I could probably do the AP reduction myself, if I knew where the offsets were, but I'm guessing the AP stat will be a hell to locate in cheat engine... I'll give it a try.
 
Magnus said:
Highest on my wish list right now is to reduce the AP cost of the Unarmed special attacks to the following:
Jab 3, Palm Strike 4, Pierce Strike 5
Hip Kick 5, Hook Kick 6, Pierce Kick 7
and to give Hip Kick a 10% bonus to critical so there's any point in using it. I could probably do the AP reduction myself, if I knew where the offsets were.

sure and nice :)
Find the swing and thrust mode of unarmed/melee weapons, too :)
 
Magnus said:
(...) Highest on my wish list right now is to reduce the AP cost of the Unarmed special attacks to the following:
Jab 3, Palm Strike 4, Pierce Strike 5
Hip Kick 5, Hook Kick 6, Pierce Kick 7
and to give Hip Kick a 10% bonus to critical so there's any point in using it (...)

That sounds pretty good!!, and it would make the unarmed skill (bare handed) more useful. :)
 
Glovz said:
I gave modifying the damage formula a try but my understanding of the engine was limited.

Don't know if you reviewed my work, if you get a chance take a look.

You are definitely more skilled then I am.

I just read your post, it seems my formula is the same as yours except for the ammo part :D, yeah, we share the same idea. I think you only need a small modification to get the correct damage multiplier, then the code will work again. There is a function some lines before the damage loop will return the ammo damage multiplier in eax. Before I started to modify the code, I found a modification in cubik2k's website when I downloaded f2wedit, but I don't fully agreed with it, so I decided to make my own.

Magnus said:
In any case I'd wait with modifying the engine until Killap releases Fallout 2.3, but I'd be thrilled to work with crazycc in any damage-balancing endeavour

That is nice, I just started to play the game again one month ago, you certainly have more experience than me regarding balance issue. Right now, I try to improve some useless trait, perk, and sfall script is very handful to do some "softcore" modification. Any idea what should be buff?

Some special unarmed attacks
Code:
AP cost
palm strike - 478bd1: mov ebx, 6
hip, hook kick - 478be5: mov ebx, 7
piercing strike - 478bf4: mov ebx, 8
piercing kick - 478c03: mov ebx, 9
strong, snap, power kick - 478bb3: mov ebx, 4

sub_478b24
function: get the AP cost for the given attack
param: eax = char ptr, edx = attack type
return: eax = AP cost
[/quote]
 
crazycc said:
Before I started to modify the code, I found a modification in cubik2k's website when I downloaded f2wedit, but I don't fully agreed with it, so I decided to make my own.

Sure, everybody works on his own :)
I discover the damage formula from Fallout1/2 few years ago (2004), made first ammo mods in 2005, described formula here in 2005 and I did not use assembler! My first modifications based on original damage formula.

There was a new "fixed" formula discovered by me in 2007, the patch for FO2 was made by Ravachol. There I made few new ammo mods based on Ravachol damage patch.



My main idea of ammo types was like in original Fallout (for original damage formula):
JHP - example 2/1 25% - (dam_mult/dam_div)>>1, dam_res_mod>0%
FMJ - example 1/1 -5% - (dam_mult/dam_div)=1, dam_res_mod<=0%
AP - example 4/5 -35% - (dam_mult/dam_div)<1, dam_res_mod<<0%


Look at those formulas (original, new from 2007 and patched, and newest from 2007 too but never ptch made:/ ):
http://ammo-mod.fmcx.pl/pliki/damage_algorithms.png
 
Last edited:
I like algorithm version 2, it looks even realistic. But AP could become slightly more powerful - so it's better than JHP for Leather Armor, the current version has just 1 more damage than the JHP, but a no-armor crit from JHP should do about 50% more than a no-armor crit from AP, so overall JHP is better.

This could be not so realistic, but there are lots of AP, so there should be lots of targets for it, too. 2 damage over JHP's should be enough.
 
Here some changes,
bruiser: ignore DS for melee attack
heavy handed: ignore DT for unamred attack
kamikaze: 0 ac, +20 sequence
skilled: -8 skill points per level, gain perk every 2 level

perk:
finesse: +10 critical, +30 DS, +15 better critical
more critical: +30 critical
living anatomy: +10 damage
dodge: +15 AC
 
What about swing/thrust mode for melee/unarmed weapons? Can you handle this?
 
crazycc said:
Cubik2k said:
What about swing/thrust mode for melee/unarmed weapons? Can you handle this?

What is the problem of these modes?

The problem is that those modes don't work.

There is a suggestion on Fallout Modding Wiki to make those modes to work:
swing - as critical damage or reduce armor class (increase hitting the target) (i.e. reduce AC of armor by -5% or more)
thrust - as armor piercing (i.e. reduce DR of armor by -15%)
 
Back
Top