damage calculation fixed - AP ammo fixed - just an exe mod

Glovz

Vault Dweller
Modder
Overview
The fallout2.exe from killap's patch was modified to correct the damage calculation bug of how different types of ammo did not perform correctly against different types of armor. The mod is simply to address the bug, it may improve balance in the game but it is certainly will not perfect it.

Phase 1
The details to understanding the change to the damage calculation in the modded exe:
(my reasoning is all based on research in the forum, game play, and analysis of the exe and proto files)

1- Since there was no true way to determine what type of ammo was being used, I choose to use the damage multiplier value as the determinant.
a- a multiplier of 1 would mean AP and CELL ammo
b- a multiplier of 2 would mean JHP and SHELL ammo
c- a multiplier of 3 would mean EC, FMJ, FUEL and BB ammo

2- since there was no true way to determine what type of armor was being used, I choose to use the armor threshold value as the determinant.
a- a threshold value of less than 4 would mean nonmetallic based armor
b- a threshold value of 4 or more would mean a metallic based armor

3- determining the ammo type and armor type being hit allowed me to apply an increase or decrease to damage as appropriate

4- to be able to do all this unfortunately meant that I had to remove the code which used the damage divisor from the proto files of ammo, but I am still using an assumed damage divisor which leads to now having to modify the current ammo proto files and setting limits/rules around what the damage multiplier and the damage divisor must be for the different ammo types

AP and CELL ammo now must have a multiplier of 1 and an assumed divisor of 1.
JHP and SHELL ammo now must have a multiplier of 2 and an assumed divisor of 1.
EC, FMJ, FUEL and BB ammo now must have a multiplier of 3 and an assumed divisor of 2.

This does not drastically harm the damage calculation as the most significant value used is the DR modification value also housed in the ammo proto file. But, now all ammo must have a multiplier of 1, 2, or 3 and while technically they may no longer need a divisor value it is technically now limited to 1 or 2 based strictly on it's relationship to the multiplier.

Phase 2
I will modify some ammo proto files to ensure compliance with the modded exe.

Phase 3
This will need someone (because try as I might I cannot understand how to use the mapper properly) to use the mapper to change the necessary proto files in all the maps.

Using one of the following commands should rebuild the proto files for a map:
F9: /Rebuild item protos (Librarian menu - need librarian=1 in cfg)
F10: Quit/Rebuild proto lists (Librarian menu - need librarian=1 in cfg)

F11: /Rebuild all (Librarian menu - need librarian=1 in cfg)

It also might be possible that the F11 command in the mapper may just do it all, but again I need someone with extensive mapper experience to confirm the what and how.

Future Considerations
This mod only fixes how damage is calculated based on ammo and armor type, it does not address the ammo, weapon, armor balance issues in the game. Almost all proto files and possibly all maps would need to be modified to achieve balance. If it is found that the F11 mapper function can do this in one easy step then I will look further into the game balance issue.

http://www.mediafire.com/?dljwdgmxkgw
 
Double posting isn't a problem if you have a legitimate reason to bump a month-old thread. We yell at people when they bump their own post within hours or days and/or have nothing significant to add.
 
Update time!

Tested the modified exe - corrected a couple of bugs - working well now.

I have had it crash on me twice but have not been able to reproduce the error consistently. If anyone can by using the exe, please let me know the exact conditions.

http://www.mediafire.com/?dljwdgmxkgw
 
If phase 1 testing is successful, then phase 2 is basically complete (I'll just need to tweak my previous mod a bit - http://www.nma-fallout.com/forum/dload.php?action=file&file_id=753), but phase 3 will definitely need to be done by someone else *looks in killap's direction with hope* given it will be all mapper work (hopefully not as extensive as one might first think).

I don't want to get to ahead of myself just yet.
 
EDIT:
Changes are now complete and I need the communities help with testing and feedback.

Code:
MOV EDX,DWORD PTR DS:[ESI+4] ; start of damage loop 
MOV EAX,DWORD PTR DS:[ESI] 
MOV EBX,DWORD PTR SS:[ESP+18] 
CALL fallout2.00478448 
ADD EBX,EAX ; raw damage 

SUB EBX,DWORD PTR SS:[ESP+28] ; damage minus threshold 
IMUL EBX,DWORD PTR SS:[ESP+20] ; damage multiplied by difficulty setting 
MOV EAX,64 ; assign value of one hundred 
SUB EAX,DWORD PTR SS:[ESP+2C] ; subtract damage resistance adjustor from one hundred 
IMUL EBX,EAX ; damage multiplied by new damage resistance adjustor 
MOV EAX,EBX ; assign current damage value 
MOV EBX,68DB9 ; assign value of ten thousand 
IMUL EBX ; divide by one over ten thousand 
MOV EBX,EDX ; assign new damage value 
IMUL EBX,DWORD PTR SS:[ESP+24] ; damage multiplied by damage multiplier 
TEST EBX,EBX ; is result zero or not 
JLE SHORT zJmp ; if less than or equal to zero then jump to lastJmp 

CMP DWORD PTR SS:[ESP+24],6 ; damage multiplier minus three with no assignment 
JE SHORT bJmp ; if equal to zero then jump to triLastJmp 

CMP DWORD PTR SS:[ESP+28],4 ; threshold minus four with no assignment 
JGE SHORT metalArmor ; if threshold is greater than or equal to four then jump to metalArmor 
JMP SHORT nonMetalArmor ; else then jump to nonMetalArmor 

nonMetalArmor: 
CMP DWORD PTR SS:[ESP+24],4 ; damage multiplier minus two with no assignment 
JE SHORT increaseDamage ; if zero then jump to increaseDamage 
JMP SHORT decreaseDamage ; else then jump to decreaseDamage 

metalArmor: 
CMP DWORD PTR SS:[ESP+24],2 ; damage multiplier minus two with no assignment 
JE SHORT increaseDamage ; if zero then jump to increaseDamage 
JMP SHORT decreaseDamage ; else then jump to decreaseDamage 

increaseDamage: 
IMUL EBX,5 ; multiple damage by five 
JMP SHORT aJmp ; done 

decreaseDamage: 
IMUL EBX,3 ; multiple damage by three 

aJmp: 
SAR EBX,3 ; divide damage by eight
JMP SHORT cJmp 

bJmp: 
SAR EBX,2 ; divide damage by four 

cJmp:
ADD DWORD PTR DS:[EDI],EBX ; accumulate damage 

zJmp: 
MOV EAX,DWORD PTR SS:[ESP+1C] ; no damage 
INC ECX 
CMP ECX,EAX 
JL SHORT fallout2.004249EC ; loop back to start

The tool I used to make these changes is OllyDbg 1.10

EDIT:
Link to the modded exe for testing:
http://www.mediafire.com/?dljwdgmxkgw
 
I couple of things I discovered when creating the modded exe.

Engine quirks:
1- The damage multiplier is doubled by the engine from what is listed in the proto files.
2- It was never using the damage divider value from the proto files.
 
Glovz said:
2- It was never using the damage divider value from the proto files.
Say, did you mod this? It's using the divider now properly?

Once again, Hail to the King Glovz, baby!
 
Not exactly - I will try to put together a full explanation of what I have done and what limits there are now when modding the proto files for ammo.

Edit:
I have updated the first post of this thread with an explanation and added a link to a compressed file that contains the exe (Phase 1) and the modded ammo proto files (Phase 2).

I would still like people to test the exe and verify that the changes do meet everyones approval for fixing the bug of AP vs JHP damage. Thus maybe then it could be included into killap's patch.

To the forum admins and moderators:
Please ignore any previous files I have uploaded to the forum and take the one found here - http://www.mediafire.com/?dljwdgmxkgw
 
Last but not least the formula:

[the damage multiplier is doubled for some reason from what value is found in the prototype]

damage=raw_damage-dmg_tresh
ammo_dr_adj=(100-(DR mod + DR))
damage=damage*combat_difficulty*ammo_dr_adj/10000*dmg_mult
if damage<0 then damage=0

AP and CELL ammo to do more or less damage, the 4 is the starting range of metal type armor
if dmg_mult==2 && dmg_tresh>=4 then damage=damage*5/8
if dmg_mult==2 && dmg_tresh<4 then damage=damage*3/8

JHP and SHELL ammo to do more or less damage, the 4 is the starting range of metal type armor
if dmg_mult==4 && dmg_tresh>=4 then damage=damage*3/8
if dmg_mult==4 && dmg_tresh<4 then damage=damage*5/8

EC, FMJ, FUEL, and BB ammo
if dmg_mult==6 then damage=damage/4
 
Glovz, could you make some example table i.e. in excel sheet to show the result values of your algo? I do not understand right the algo.
For example:
weapon base damage == 15

Armor1 DT=2 DR=25%
Armor2 DT=4 DR=30%
Armor3 DT=5 DR=40%

Ammo JHP 2/1 25%
Ammo AP 1/2 -25%
Ammo FMJ 1/1 -25%

this could help to understand your idea.
 
I went back to the beginning and thought again. The changes I have made this time improve AP ammo damage and now make it a little more important to choose the appropriate ammo to use.

All the details are in the files. A spreadsheet has been included to demonstrate example damage values using every type of ammo in the game against every type of armor in the game.

http://www.mediafire.com/?1zcnwxx6cro

EDIT:
The exe file that was modified is the one found in killap's patch.
 
I've been using (not testing, though) your "mod" for some days. I really appreciate your great work, and have a question to be asked.
In your latest "release" from 10th of august there are only a modded exe, a spreadsheet etc. But in the previous to that release (28th of june) there are also edited proto files, which match the modded exe's new formulas and whatever.
So, why aren't there no proto files in the recent release pack? Considering, that you've greatly (i guess) modified the formula in that release, aren't the protos (from 28th of june, for ex.) to be modified again to "ensure compliance"? Or there is no urgency and i may use 28 june's protos, or maybe even original ones?
 
Short Answer:
The latest change simply addresses what many people feel is a bug in the damage calculation related directly to AP and JHP ammo against metal based and non-metal based armor. This "fix" attempts in no way to address balance in regards to ammo/weapons/armor. Thus no need for any other files then the modded exe.

Long Answer:
When I first started tinkering with the exe code, I didn't take the time to test or evaluate results. Later I tested and did do evaluations but also thought I could address game balance issues. I came to the realization that balance could not be addressed properly without modifying proto files and map files. So I went back, rethought my approach and tweaked my "fix" without attempting to adjust game balance.

Future work (maybe):
I have revisited on paper different results using changes to the damage formula and values found in the ammo protos, but this is going very slowly. I have found I will have to look at what ammo is used for which weapons, weapon damage ranges, which weapons are expected to be used against what armor, and then factor in what level the user might be at during the time they are able to obtain such weapons and armor. All this will be necessary before even attempting to modify all the necessary files to "correct" game balance.

What I wish was possible:
I wish ammo contained/affected the damage range values and weapons contained/affected accuracy. It would be much easier to adjust balance (on paper anyway). Unfortunately in the files it's vice versa and is not something that can be changed (or at least that I could change).
 
Got it :) Having analyzed the spreadsheet thoroughly, i understood that original ammos have already been quite balanced, except the ammo for shotguns (really they can barely handle leather armor, but in the game they penetrate even APAmkII sometimes :D . I'll have the modding of theirs on my own.
Your idea for splitting the effects for jhp and ap for metal and non-metal armor is great! Do you understand that with the proper modding of protos we can have the most realistic mod for the game ever? :) So, i wish you good luck in your "Future work (maybe)" :) We and I will be looking forward to your futher optimizations and interesting ideas!

--Added--

Something interesting happens with your modded exe + original proto files. Sometimes (i haven't yet found out in what cases exactly) the damage, dealt to someone, is negative (-x).
Judging by your formulas,
damage=base_damage-DT
ammo_dr_adj=combat_difficulty-(DR + DR Mod)
damage=damage*ammo_dr_adj*dmg_mult/dmg_div/100/2

it's possible for ammo_dr_adj to easily become below zero. I thought you might make a workaround for that case, but i found nothing like that one in assembly.txt (though, i might be wrong indeed). Could you shed some light on this matter please?
PS: Because it's particularly interesting for me, if i may set very high/very low DR mod for ammos (for ex +/-200). And don't ask why i need it :)

--Added--

Mm.. nevermind about the DR mod. I've tested it thoroughly, and found out what's the best one for the shotgun shells. Dmg mult/div = 7/1, DR mod = 62, AC mod = 30 (but it doesn't make such sense as the previous values). And what we have: combat shotgun does nothing to combat armor (except for crits), does some <5 dmg to metal armor, but does huge numbers of 30-50 to to unarmored and 20-35 to leather. That's like in real life :)
And actually, i'm sorry for such a useless discussion i made here, but i'm going do more thorough testing with YOUR mod particularly, hope it helps us somehow.

And finally, about your modded exe. You said it's from the killap's patch (yeah, i like it too), but from what version exactly? I doubt it can be from 19th october 2007, cause you had uploaded your release 11 days before the patch :(
So, if it's not from the latest patch, could you mod the latest exe please? I'm afraid of problems that can be with your exe and the files from the latest patch.
 
The exe file in killap's patch does not change from version to version so no worries there.

The code in the exe that I modified and even before seemed to change nagative values to zero before using them further. So you are right when doing the calculations manually that negatives should occur, but even if a negative was applied I added conditions (and there was originally as well) to deal with it.
 
Back
Top