Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Light Level Calculated incorrectly for low Stealth and negative perception #793

Open
philipandresen opened this issue Sep 27, 2023 · 0 comments

Comments

@philipandresen
Copy link

philipandresen commented Sep 27, 2023

Barony/src/entity.cpp

Lines 895 to 899 in 33b568c

if ( sneaking )
{
light /= 2; // halve for sneaking
}
light -= (light - TOUCHRANGE) * (1.0 * (myStats.PROFICIENCIES[PRO_STEALTH] / 100.0)); // reduce to 32 as sneak approaches 100

Evaluate this expression with minimum light (48) touch range (32) and stealth skill of zero. No observer or observer perception is zero

if ( sneaking ){ 48 /= 2; } // == 24
24 -= (24 - 32) * (1.0 * (0 / 100.0)); // 24 - (-8 * 0) = 24
// Visibility is 24

Evaluate with minimum light (48) touch range (32) and stealth skill of 100. No observer or observer perception is zero

if ( sneaking ){ 48 /= 2; } // == 24
24 -= (24 - 32) * (1.0 * (100 / 100.0)); // 24 - (-8 * 1) = 24 + 8 = 32
// Visibility is 32

This also makes enemies with negative perception scores give odd values - with higher stealth giving you worse ability to hide.

That's the bug report!

I submitted a fix here along with a refactor. I have a feeling this bug exists because this code is particularly confusing, so a refactor seemed appropriate.
#805

@philipandresen philipandresen changed the title Visibility is less when skill is zero, more when skill is 100 + suggested fix [Bug] Visibility is less when skill is zero, more when skill is 100 + suggested fix Sep 27, 2023
@philipandresen philipandresen changed the title [Bug] Visibility is less when skill is zero, more when skill is 100 + suggested fix [Bug] Light Level Calculated incorrectly for low Stealth and negative perception Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant