Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Neverwinter Nights: Enhanced Edition has been released! Visit nwn.beamdog.com to make an order. NWN:EE FAQ is available.
Soundtracks for BG:EE, SoD, BG2:EE, IWD:EE, PST:EE are now available in the Beamdog store.
Attention, new and old users! Please read the new rules of conduct for the forums, and we hope you enjoy your stay!

Lower Reaches - Fireball fails to destroy 6 gibberlings

13»

Comments

  • AngulimalaAngulimala Member Posts: 32
    edited June 29
    @Grond0 I wonder if it's by design to ensure all HP rolls are at least half the hit dice, similar to the "NWN style" tweak. Perhaps the designers thought it would enhance game enjoyability for a majority of players.

  • Grond0Grond0 Member Posts: 5,139
    @Angulimala it's not a deliberate change by Beamdog. Nor is it a simple algorithm change. It's still possible to get low HP rolls - they just don't occur as often as high ones.

    Angulimala
  • MaurvirMaurvir Member Posts: 215
    That sure looks like a design change. I'm guessing people were grumbling that their fighters were getting crap HP rolls and being taken out by gibberlings.

  • Grond0Grond0 Member Posts: 5,139
    @Bubb - you're my hero :D.

    @JuliusBorisov from what was said in the review by Beamdog before (and what wasn't said in patch notes) this did not appear to be an intended change - though I imagine that reverting to vanilla behavior might not be that popular now people have had so long to get used to this behavior. Will you update your bug report, so the issue can be considered by developers?

    gorgonzolaBubb
  • JuliusBorisovJuliusBorisov Member, Administrator, Moderator, Developer Posts: 18,462
    Tagging @Hurricane as it was he who copied the report to the internal tracker.

  • HurricaneHurricane Member, Administrator, Developer, Translator (NDA) Posts: 643
    Yes, the behavior of rolling twice and using the higher of the two rolls was already considered when the issue was first looked at in 2017, but it is still unclear why this behavior did not occur prior to the v2.0 update because according to the developers' investigation, the way the hitpoints are rolled didn't change between versions. In any case, I've updated the bug report.

    elminsterBubbJuliusBorisov
  • BubbBubb Member Posts: 639
    edited July 1
    I should just leave it there, but the rolling function did change quite significantly between v1.3 and the current version of BG2EE.

    See the core part of v1.3's rolling function, (roughly translated from assembly to pseudo code, in part because of compiler optimizations):
    roll1 = (call rand) % nSides
    roll2 = (call rand) % nSides
    
    if roll1 <= roll2 then
    
        roll3 = (call rand) % nSides
    
        ::FIRST_CONDITION::
    
        roll3 = roll3 + 1
    
        if nMinRoll <= roll3 then
    
            roll4 = (call rand) % nSides
            roll5 = (call rand) % nSides
    
            if roll4 <= roll5 then
    
                roll6 = (call rand) % nSides
    
                ::SECOND_CONDITION::
    
                roll6 = roll6 + 1
    
                (roll6 is the only value that survives)
                return roll6
    
            else
    
                (same result as true condition evaluation: why is there a branch here?!)
    
                roll6 = (call rand) % nSides
                goto ::SECOND_CONDITION::
    
            end
    
        else
    
            (nMinRoll is the only value that survives)
            return nMinRoll
    
        end
    
    else
    
        (same result as true condition evaluation: why is there a branch here?!)
    
        roll3 = (call rand) % nSides
        goto ::FIRST_CONDITION::
    
    end
    

    Two things:
    1. It calls rand WAY too many times, and to no real result. roll6 and nMinRoll are the only possible values that survive, so in essence this function "works" as intended, (it returns the result of 1 die roll), but it does a ton of junk operations.

    2. The nMinRoll is checked against roll3, but not against roll6, so in many cases nMinRoll is ignored.

    Compare that to the core of v2.5.16.6's function:
    roll1 = (call rand) % nSides
    roll2 = (call rand) % nSides
    
    higher_of_two = max(roll1, roll2) + 1
    ensure_min = max(nMinRoll, higher_of_two)
    
    return ensure_min
    

    Much better, as you can see. All the junk is gone, with the only thing remaining being the double roll. I'm sure the devs know their way around the engine, but this is the function in question:
    CRuleTables::RollHitPoints(CRuleTables *this, int nSides, int nRolls, int nLevel, int nMinRoll, int nModifier)
    

    I'll stop talking and let the devs work now :p

    HurricaneGrond0JuliusBorisovSkatan
  • Grond0Grond0 Member Posts: 5,139
    Bubb wrote: »
    Compare that to the core of v2.5.16.6's function:
    roll1 = (call rand) % nSides
    roll2 = (call rand) % nSides
    
    higher_of_two = max(roll1, roll2) + 1
    ensure_min = max(nMinRoll, higher_of_two)
    
    return ensure_min
    

    @Bubb forgive the ignorance of someone who knows nothing about coding. However, looking at the statements above would suggest to me that you shouldn't be able to get a minimum HP roll as the higher_of_two function doesn't just take the higher of two rolls, but adds 1 to it as well (there's then a further comparison with nMinRoll - possibly to set max HPs if that option is set in Game Options?). It is though possible in the game to get minimum HPs. What am I missing?

    Bubb
  • jmerryjmerry Member Posts: 101
    What you're missing? The mod operator (%) has a range from zero to the second argument minus 1. To get a roll from 1 to nSides, we need (rand % nsides) +1 anyway. Putting the +1 in the higher_of_two function rather than applying it to the rolls first as a human would is confusing, but it works.

    Grond0Bubb
  • BubbBubb Member Posts: 639
    edited July 2
    The computer does the + 1 in the higher_of_two step because it saves one add instruction, but that is getting into arbitrary detail.

    @Grond0: The following line:
    ensure_min = max(nMinRoll, higher_of_two)
    

    is making sure that the minimum allowed value is met. For example, if higher_of_two got set to 1, and yet the minimum allowed roll value is 5 because of godlike constitution, this line would "bump" the roll up to a 5.

    In fact, this whole rolling function isn't even used if the Max HP rolls option is active.

    Grond0
  • Grond0Grond0 Member Posts: 5,139
    Bubb wrote: »
    For example, if higher_of_two got set to 1, and yet the minimum allowed roll value is 5 because of godlike constitution, this line would "bump" the roll up to a 5.

    Even godlike constitution (25) only gives you a minimum of 4 under 2nd edition rules, but I get the point :p. Thanks for your help.

    Bubb
  • subtledoctorsubtledoctor Member Posts: 11,131
    jmerry wrote: »
    How do we know it's not deliberate? If it were deliberate, it would be documented,

    hahahahahahaha :lol:

    DreadKhan
Sign In or Register to comment.