Why Melee Damage is so low (and 0 damage hits)

Discussion in 'Bug Reports' started by Nightwolf, Sep 11, 2014.

  1. Nightwolf

    Nightwolf Active Member
    UO:R Subscriber

    Joined:
    Aug 1, 2014
    Messages:
    85
    Likes Received:
    106
    I found there is a error in default RunUO (at least for a PreAOS codebase) in the OnHit function in BaseArmor.

    EDIT: Verified on the UODemo as not a bug. With that, lets discuss weapon damage : )

    Default RunUO
    Code:
    public virtual int OnHit( BaseWeapon weapon, int damageTaken )
            {
                double HalfAr = ArmorRating / 2.0;
                int Absorbed = (int)(HalfAr + HalfAr*Utility.RandomDouble());
    
                damageTaken -= Absorbed;
                if ( damageTaken < 0 )
                    damageTaken = 0;
    
                if ( Absorbed < 2 )
                    Absorbed = 2;
    
    Fixed Code
    Code:
    public virtual int OnHit( BaseWeapon weapon, int damageTaken )
            {
                double HalfAr = ArmorRatingScaled / 2.0;
                int Absorbed = (int)(HalfAr + HalfAr*Utility.RandomDouble());
    
                damageTaken -= Absorbed;
                if ( damageTaken < 0 )
                    damageTaken = 0;
    
                if ( Absorbed < 2 )
                    Absorbed = 2;
    
    HalfAr should be calling the function ArmorRatingScaled rather than ArmorRating. This means the default code is calculating absorbed damage from the total AR of a FULL suit of armor rather than the AR of the individual piece of armor that was hit. Resulting in very low damage to those wearing armor.

    https://web.archive.org/web/19990502215932/http://uo.stratics.com/combat.htm#8

    Plate Gorget Example
    - I'm naked and only wearing a Plate Gorget that has an AR of 4.2
    - Note: a Full Plate Suit has an AR of 30
    - There is a 7% chance a melee weapon hits my Plate Gorget

    Lets say a weapon hits the Plate Gorget. The old code will absorb 30 AR worth of damage! The new code will use ArmorRatingScaled and correctly absorb 4.2 AR worth of damage.

    Test Case A
    - Vanilla out of the box RunUO with AOS ruleset

    Test Case B
    - Vanilla out of the box RunUO with PreAOS ruleset

    Test Case C
    - Fixed RunUO with PreAOS ruleset (using the solution purposed in my original post)
    [​IMG]

    Preconditions
    - Each player has identical skills and stats. All GM skills and 100/100/100 stats
    - Each test is run with a fresh suit of leather armor (not exceptional) providing an overall AR of 40 Edit: AR of 13
    - Each test is run with a fresh Katana
    - AOS Katana does 11 - 13 damage
    - PreAOS Katana does 5 - 26 damage

    Here are the results
    [​IMG]
    Last edited: Sep 14, 2014
    Vlar, Liberation, Gozinya and 2 others like this.
  2. Supra

    Supra Active Member

    Joined:
    Sep 5, 2014
    Messages:
    115
    Likes Received:
    54
    So you are telling that the "FORMULA: Damage Absorbed= Random value between of 1/2 AR to full AR of Hit Location's piece of armor." is not applied right now? Instead the full AR of all body parts is used?
  3. Nightwolf

    Nightwolf Active Member
    UO:R Subscriber

    Joined:
    Aug 1, 2014
    Messages:
    85
    Likes Received:
    106
    Correct, that formula is currently only being applied to Virtual Armor such as those on NPC monsters. For Player worn armor, it is using the full suit AR value on any individual piece of armor
    Last edited: Sep 11, 2014
    Brymstone likes this.
  4. Brymstone

    Brymstone Well-Known Member

    Joined:
    Jul 31, 2012
    Messages:
    460
    Likes Received:
    337
    Congrats Nightwolf, I believe you might be on to something here. Many on this shard have seen the lowball damage done in melee combat and this may very well be the culprit. This may account for the minimal damage done to those wearing barbed leather as every body part is being recognized as having an AR of 37.

    Hopefully this will be looked at and addressed in the near future.
  5. Dalavar

    Dalavar Well-Known Member
    UO:R Subscriber

    Joined:
    Aug 11, 2013
    Messages:
    3,336
    Likes Received:
    1,915
    To possibly clear one thing up, Displayed AR != AR. Displayed AR is meaningless for combat calculations. Your plate gorget itself may have an AR of 30. Displayed AR tries to "estimate" your overall AR by combining the AR of the armor piece with the approximate chance of getting hit in that region.


    I think this is working as intented, assuming indeed there is a 7% chance the gorget is hit.
  6. Dalavar

    Dalavar Well-Known Member
    UO:R Subscriber

    Joined:
    Aug 11, 2013
    Messages:
    3,336
    Likes Received:
    1,915
    I should add, there is supposedly a bunch of non-default code in the combat system here. I don't really know how it works, but I think the bottom line is that leather armor is a little too effective in terms of AR.
  7. Nightwolf

    Nightwolf Active Member
    UO:R Subscriber

    Joined:
    Aug 1, 2014
    Messages:
    85
    Likes Received:
    106
    It is not meaningless. The AR of an individual piece of armor is supposed to be scaled depending on the location the body. Displayed AR and chance of getting hit in a location are independent of each other.

    For example: NPC Monster Armor inside AbsorbDamage in BaseWeapon
    Code:
    double chance = Utility.RandomDouble();
    
    if ( virtualArmor > 0 )
                {
                    double scalar;
    
                    if ( chance < 0.14 )
                        scalar = 0.07; // NeckArmor and HandArmor
                    else if ( chance < 0.28 )
                        scalar = 0.14; // ArmsArmor
                    else if ( chance < 0.43 )
                        scalar = 0.15; // HeadArmor
                    else if ( chance < 0.65 )
                        scalar = 0.22; // LegsArmor
                    else
                        scalar = 0.35; // ChestArmor
    
                    int from = (int)(virtualArmor * scalar) / 2;
                    int to = (int)(virtualArmor * scalar);
    
                    damage -= Utility.Random( from, (to - from) + 1 );
                }
    This is a proper damage absorption calculation. In this case, VirtualArmor is used by monsters and the Protection spell. For example, a ogre will have VirtualArmor of 60. This code uses a scalar to reduce 60 to different AR values depending on where the weapon hit. This is not the case with Player armor.


    It's impossible to tell without the UOR source code and it may or may not have already been noticed. This bug is easy to miss and with all the complaints of low damage towards armor wearers I thought I would at least bring it up.
    Last edited: Sep 12, 2014
    Gozinya likes this.
  8. Gozinya

    Gozinya Active Member
    UO:R Subscriber

    Joined:
    Sep 3, 2014
    Messages:
    155
    Likes Received:
    68
    Nice catch. I definitely have noticed a problem with melee combat damage,but just assumed it was part of the server settings to try and balance something.
  9. Dalavar

    Dalavar Well-Known Member
    UO:R Subscriber

    Joined:
    Aug 11, 2013
    Messages:
    3,336
    Likes Received:
    1,915
    No. The chance to hit that part of the body is what scales the effectiveness of a piece of armor in that part of the body. The actual AR of the piece of armor is the same. That is....

    ...a plate gorget of fortification has an actual AR of 35 (for example)
    ...a plate tunic of fortification has an actual AR of 35, too

    However, the reason displayed AR shows a higher number for the tunic is because it gets hit more often, 44% versus 7% or so.

    Given a 40-damage hit to a plate gorget of fortification, and a 40-damage hit to a plate tunic of fortification, both would be expected to absorb the same amount of damage.

    They are not, and this is easy to prove by looking at a correlation between the AR of an item and the chance of it getting hit. Tunic/chest pieces tend to have higher displayed ARs, and also get hit the most often.
  10. Nightwolf

    Nightwolf Active Member
    UO:R Subscriber

    Joined:
    Aug 1, 2014
    Messages:
    85
    Likes Received:
    106
    If your theory is correct, why then is VirtualArmor (monster armor) absorption calculated differently than Player Armor absorption? It goes against your theory that Displayed AR is meaningless.

    Just stand back and look at the logic, you'll see why what you are saying makes no sense. 35 AR on a single piece of armor absorbs A LOT of damage!

    Edit: wording
    Last edited: Sep 12, 2014
  11. Liberation

    Liberation Well-Known Member

    Joined:
    Jun 4, 2013
    Messages:
    776
    Likes Received:
    326
    awesome! i wouldn't be sad if dexxers were a bit stronger

    if i understand correctly, Dalavar is just correcting a tangential statement that is not at all foundational to the real point of this post. is that correct?
  12. Gozinya

    Gozinya Active Member
    UO:R Subscriber

    Joined:
    Sep 3, 2014
    Messages:
    155
    Likes Received:
    68
    I'm assuming this is also why I sometimes only hit for 4-5 damage on a mummy or bone knight using a silver battleaxe of power with 80+ swords, anatomy & tacts and 40+ lumberjacking?

    Most of my hits are 25-45 damage, but there's like 1 or 2 out of 10 hit chance that I'll only do like 4 damage.
  13. Dalavar

    Dalavar Well-Known Member
    UO:R Subscriber

    Joined:
    Aug 11, 2013
    Messages:
    3,336
    Likes Received:
    1,915
    Super helpful link about UO combat:
    http://www.uorenaissance.com/stratics/combat

    And about magic armor (and how all Plate armors of Hardening have the same AR):
    http://www.uorenaissance.com/stratics/armor

    Because most monsters don't wear armor (slimes, etc.), so there is certainly the thematic argument. Additionally, for those that thematically could (a troll, perhaps), it makes no sense to add complexity to how the combat system works by allowing them the flexibility to wear a virtual plate helmet, plate tunic, leather sleeves, no leg armor, etc. Just give them one universal AR number and apply it as you wish. At least that would be my guess at their rationale. But again, I'm not a coder. I just figure out how things work, not *why* they were designed a certain way.

    Monster AR is a system completely unrelated to humanoid AR. The "theories" do not require reconciliation.

    No kidding. Good armor is good. What's your point?

    The data you see in my links above was tested on a prior shard by devs by examining the source code of the UO Demo, which represented the actual UO production code of 1998, and determined to be accurate.

    You do not understand correctly. I am correcting the central statement of the original post, that displayed AR has a role to play in combat calculations.

    There are two reasons for this. One is that weapons on this shard are very swingy. That is, if they do 5 to 35 damage, this might have been represented by 5d7 back in production UO. This leads to a very tight average hit of 18 damage. For server memory reasons, rolling 5 times the dice is I guess pretty expensive. So on this shard, 5 to 35 is represented by 4 + 1d31. The result is you are much more likely to do damage rolls at the ends of the spectrum.

    The other reason is what Nightwolf cited, which is that monster AR uses a sort of exponential system, in which about 35% of hits block a bunch of damage, 14% of hits block almost nothing, etc.
  14. Nightwolf

    Nightwolf Active Member
    UO:R Subscriber

    Joined:
    Aug 1, 2014
    Messages:
    85
    Likes Received:
    106
    Some example calculations:

    I'm using a Katana at 26 max damage. I'm hitting a Plate Gorget at 4.2 AR individually (30 AR full suit). Lets assume the armor is able to absorb it's maximum amount (its AR value).

    Old Code
    HalfAR = 30 / 2 = 15
    Absorbed = HalfAR + HalfAR * 1.0 = 30
    Damage = KatanaMax - Absorbed = 26 - 30 = -4 = 0 damage

    -> A standard Katana hit for MAX damage on only a gorget and hit for 0 damage. If I was wearing full platemail, I would be invincible!

    Fixed Code
    HalfAR = 4.2 / 2 = 2.1
    Absorbed = HalfAR + HalfAR * 1.0 = 4.2
    Damage = KatanaMax - Absorbed = 26 - 4.2 = 21.8 damage

    -> The result is more reasonable


    EDIT: Please note this is an example using extreme values. Don't be scared that it says 21.8 damage, that would be the exception rather than the rule.
    Last edited: Sep 12, 2014
  15. Dalavar

    Dalavar Well-Known Member
    UO:R Subscriber

    Joined:
    Aug 11, 2013
    Messages:
    3,336
    Likes Received:
    1,915
    Nightwolf, let me try to sum up... I understand why the Monster AR calculations lead you to believe that player AR calculations should work that way too. This just isn't the way UO worked, though, as evidenced by Stratics and the Demo code and such.
  16. Nightwolf

    Nightwolf Active Member
    UO:R Subscriber

    Joined:
    Aug 1, 2014
    Messages:
    85
    Likes Received:
    106
    I think you missed the point. I'm talking about the logic and calculations behind armor absorption, not thematic reasoning.

    An ogre has 60 Virtual Armor. This is just a way to give armor to monsters in code. This is analogous to a player wearing a suit of armor for a total of 60 AR. Thematic reasoning does not account for why they would have different calculations.

    It is much more reasonable to argue that damage absorbed by a monster goes by the same logic of damage absorbed by a player.
  17. Dalavar

    Dalavar Well-Known Member
    UO:R Subscriber

    Joined:
    Aug 11, 2013
    Messages:
    3,336
    Likes Received:
    1,915
    In fact, Damage absorbed should be 0.5 to 1.0 the AR value of the armor. So you don't absorb 30 every time, but rather 15 to 30. I think you missed the "RandomDouble" part of the code, which I assume picks a number between 0 and 1.

    If you think this is a reasonable way to do things, you're going to have people in full plate getting 2-shotted by high-end halberds.
  18. Dalavar

    Dalavar Well-Known Member
    UO:R Subscriber

    Joined:
    Aug 11, 2013
    Messages:
    3,336
    Likes Received:
    1,915
    Sure it does, to me. But either way, this is an opinion statement.

    I already made my point, which is that the Combat calculator I linked to above has been seen to be accurate based on actual OSI code. I don't really have too much else to say if you're unwilling to acknowledge that.
  19. Nightwolf

    Nightwolf Active Member
    UO:R Subscriber

    Joined:
    Aug 1, 2014
    Messages:
    85
    Likes Received:
    106
    I acknowledge it, and even used that very same link in my first post. The Combat calculator doesn't describe the same thing you are.
  20. Brymstone

    Brymstone Well-Known Member

    Joined:
    Jul 31, 2012
    Messages:
    460
    Likes Received:
    337
    Not to be a fly in the ointment, because I think you're a great guy Dalavar, but if in fact the combat calculator is taken from the original OSI source code (which I don't beleive since the only real code anyone has produced has been from the demo code and that by admission a long time ago was changed time and time again on the production shards).

    Point being is that I NEVER hit for just 1 point of damage in melee on Lake Superior or Great Lakes, even against invulnerability plate mail using an exceptional katana. I remember distinctly many fights and at no time did 1 damage ever happen. there were low rolls to be sure but 1 point of damage is simply unheard of, especially when it consistently happens even if the opponent is wearing leather armor. I've tested this with a supremely accurate katana of vanquishing versus exceptional barbed just to see how it played out. The results simply were amazing, I hit for 1-4 points of damage on a consistent basis with anything over 5 being rare. Maybe it was just bad "rolls" but I see this in too many fights for it to be simply random bad luck "rolls".

    I will admit that every once and awhile I will see a large spike in damage and those usually occur when I'm using a vanquishing or power weapon, which is as it should be, but if someone is using a ruin, might, force or exceptional weapon on this server they're practically useless vs. an armored opponent.

    I don't want to see melee re-vamped to some ridiculous degree but I do feel the AR and combat calculator should be looked at and assessed with a little more scrutiny.
    Gozinya likes this.

Share This Page