Fallout 2 mod F2: damage calculation change, a FIX (v3 by my count)

Discussion in 'Fallout General Modding' started by Glovz, Jul 10, 2013.

  1. Glovz

    Glovz Vault Dweller
    Modder

    Sep 16, 2005
    try the new version I just uploaded for me - if it fails then I will make this change - I just want to verify if the cmp command had anything to do with it
     
  2. gvx

    gvx First time out of the vault

    Apr 4, 2008
    test ebx,ebx; // compare the number of hits to 0
    jle DamageFunctionReturn; // exit

    TOO still can not compile
     
  3. NovaRain

    NovaRain Casual Modder

    Mar 10, 2007
    The new version still fails during the compilation, with the error message:
    Code:
    1>AmmoMod.cpp(35): error C2415: improper operand type
    I don't have any knowledge of assembly language, but judging from YAAM's code it seems jle can't work with DamageFunctionReturn. gvx's modification works fine.

    I like the new calculation logic, much better than the previous one as now you can modify both DR/DT separately with ammo multiplier and divisor. Just curious about two things:
    1. When or where is the additional 30% DR from Finetrait applied in the new calculation?
    2. Don't know if I miss something, but in the middle of the calculation:
    With unmodified ammo protos, since all JHPs have amDRM greater than 0, it seems "armDR=armDR+amDRM+CD" (should be "armDRM+amDRM"?) will be reduced to a simple "armDR=CD".
    With modified ammo protos, since there's no amDRM greater than 0, unless CD > 0 and with extremely high armDRM (like power armors' Laser DR), armDR >= 100 will be very unlikely.
    Is there any other occasion that armDR >= 100 for amX coming into play? Or I should ask what exactly amX does except dividing armDR when armDR >= 100 in the new calculation? :oops:

    EDIT: Uh, from your HTML it seems as long as amX is greater than 1, it will divide armDR no matter armDR is greater than 100 or not. That's why that if I change the modified ammoX of 5mm JHP from 2 to 1, the result with ADT 2 & ADR 30 will be different by 1. Because with ammoX=2, final armDR will be lower to 7 during the process.
     
  4. Glovz

    Glovz Vault Dweller
    Modder

    Sep 16, 2005
    new version has been uploaded to the same link - modified code for that one line to be like Haen's YAAM

    answers
    1. "Finetrait"? As far as I am aware all trait's benefits and penalties that apply to combat are added before the section of code I have modified. So when a value is called in to the damage calculation it will already have been adjusted for any impact from a chosen trait
    2. Yes I made the decision to not allow for ammoDRM to be a positive number, and instead of converting an existing positive ammoDRM to 0 I choose to convert it to a negative. I did this because I wanted my fix to be able to stand alone with unmodified proto files and bring some correction to the game. In the original, weapons using JHP ammo are overpowered; but if I had not done this, then weapons using JHP ammo would have been too weak.

    After a lot of thought, it made no sense that ammo would ever add DR. I think the original devs realized the damage calculation was messed up, but instead of correcting the calculation they tried using the values fed into it to correct the output. Its any old trick, don't blame the math, blame the data.

    I also had to account for high armor DR values given EMP DR for all armor is 500, but I think that's a bug to be corrected as well, by some other mod though. ;)

    Remember, my mod does nothing to affect ammo, weapons, or armor, I just changed how the values they pass into the damage calculation are used.

    The modified ammo values I used in my html/javascript are just examples of what I think the ammo values should be to bring a bit more balance to the game inconjunction with my mod. :D
     
  5. NovaRain

    NovaRain Casual Modder

    Mar 10, 2007
    @Glovz
    Oops, I mean the +30 DR modifier from Finesse trait. :oops:

    And don't know if I misunderstand the HTML code. There are two lines in the description in new calculation don't seem right for me:
    Code:
    if armDR>=100 and amX is greater than 1 then armDR is divided by amX
    Actually as long as amX>1, armDR will be divided by amX.
    Both IF statements for checking armDR ("temp" in HTML) greater or less than 100 have amX subtraction loops.

    Code:
    if armDR is less than or equal to 0 and amX and/or is greater than 1 then temp=(ND*small bonus percent)/100, ND=ND+temp
    It seems the bonus part "if (amX>1 && amY<=1)" section doesn't check for armDR. Or did I miss something? The sentence itself also seems a bit weird.
     
  6. Glovz

    Glovz Vault Dweller
    Modder

    Sep 16, 2005
    You are correct that my description does not exactly match what's going on in the javascript, that's because I was lazy and I should correct it for those who do not know how to read javascript - sorry. :(

    The point at which the bonus is added, it's already determined in the code that the armorDR is 0 or less.
     
  7. Glovz

    Glovz Vault Dweller
    Modder

    Sep 16, 2005
    I found a small bug in my assembly code and uploaded a new version.

    I'm just about satisfied with my trace throughs. I will be in game testing soon.
     
  8. Glovz

    Glovz Vault Dweller
    Modder

    Sep 16, 2005
    I'm working on reducing the code in the javascript to only what is needed. (i.e. removing checks for values of greater than 0 or 1 where their not absolutely necessary)

    I'm doing this so the code is more easily understood by others and hopefully will reduce the assembly code version further.

    @NovaRain
    I updated the description of the current javascript in the first post.

    Given you were able to compile the code, just curious if you've tested the change in game at all and whether you've seen anything unexpected?
     
  9. NovaRain

    NovaRain Casual Modder

    Mar 10, 2007
    I didn't formally test the new formula in game yet, just try killing a few critters using AP ammo with vanilla value and see if the damage is better.
    I'll go for vacation for next 8 days, so I can only start testing/verifying after that. :oops:
     
  10. Glovz

    Glovz Vault Dweller
    Modder

    Sep 16, 2005
    No rush - I was just curious. ;)
     
  11. NovaRain

    NovaRain Casual Modder

    Mar 10, 2007
    So the current HTML calculator didn't get changed yet?
    I just saved a copy of it for comparing to understand what you'll reduce or simplify, a working/personal habit.
     
  12. Glovz

    Glovz Vault Dweller
    Modder

    Sep 16, 2005
    Nope, not yet. But the output will not change greatly from the current version.
     
  13. NovaRain

    NovaRain Casual Modder

    Mar 10, 2007
    I think in theory the output shouldn't change at all, given if you only simplify the code for readability by removing redundant/unnecessary checks. Or are you planning to tweak the formula further?
     
  14. Glovz

    Glovz Vault Dweller
    Modder

    Sep 16, 2005
    No tweaking - but it seems with what I have so far, I may have corrected inadvertently a rounding error. So when you compare the output of the current version with that of the next, you'll see a few numbers change. I've walked through it and where I was "dividing" but 100 I had missed a condition when checking what was being "divided" was either greater than or less than, I missed equal to.

    So really the next version; while being simplified, also has a bug fix. :)
     
  15. gvx

    gvx First time out of the vault

    Apr 4, 2008
    Can you add modify time in assemblyCode.txt?

    ex:
    static const DWORD GetAmmoDTMod = 0x004791E0;

    // Damage Fix v3 by Glovz 2013.7.21.06.00
    static __declspec(naked) void DamageFunction1() {
     
  16. Glovz

    Glovz Vault Dweller
    Modder

    Sep 16, 2005
    Sure, did you want me to update the version that's up now with it or just starting from the next?
     
  17. Glovz

    Glovz Vault Dweller
    Modder

    Sep 16, 2005
  18. JimTheDinosaur

    JimTheDinosaur Vault Dweller
    Modder

    Mar 17, 2013
    A bit off topic (sorry), but am I right that armor bypassing doesn't factor into this part of the damage formula? I suppose it then gets factored in during the total calculation afterwards (along with Living Anatomy etc.), but how do they do that then? Do they simply multiply the damage by five, or what?
     
  19. Glovz

    Glovz Vault Dweller
    Modder

    Sep 16, 2005
    To the best of my understanding, any adjustments that are made to any of the values used in the portion of code I've modified, are made before hand. So when those values are used in this portion of code they are final/adjusted.
     
  20. JimTheDinosaur

    JimTheDinosaur Vault Dweller
    Modder

    Mar 17, 2013
    By the way, do you need a sfall script to change all the existing ammo values to the ones you need for your mod, or do you already have that covered?