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

[CR]Add night vision from perception, fix flashlight exploit #19010

Merged
merged 5 commits into from Oct 31, 2016

Conversation

Projects
None yet
2 participants
@Coolthulhu
Copy link
Contributor

commented Oct 29, 2016

Night vision was bugged: the formulas used were calculated using wrong constants and also included rounding where none was expected.
The formulas had comments indicating expected ranges, meaning that author probably expected to keep the old (pre light rework) ranges, like 2 tiles for night vision.

New values are expressed through a clean function that takes expected range as argument and use the correct constants.

The ranges in total darkness are currently ([CR]):

  • Base is 1 + (perception / 3) - (eye encumbrance / 10)
  • Low night vision adds 2
  • Medium night vision (upgraded, ursine, feline or elf) adds 4.5
  • Full night vision (full, upgraded elf, cephalophod or nv goggles) adds 10
  • Avian eye adds 1
  • Low cap of 1

Night vision traits don't stack - best one applies. Avian eye stacks with everything except low cap.

You can still easily wear sunglasses even if your vision isn't augmented, but if you have "round" (to nearest multiple of 3) perception and no other encumbrance, that will be noticeable in total darkness.

The range here is a radius, meaning it scales really well and NV trait will help both the low perception characters who want to avoid tripping over everything and high perception ones who want to see everything during night raids.

So, for example:

Character NV range
9 per + NV 6
8 per 3
20 per + full NV 20
10 per + goggles 9
4 per + ursine + ballistic glasses 6

Flashlight exploit is when you apply flashlight twice in the same turn to see without being seen. This is fixed by adding a "lit up" effect if your inventory provides more light than some low constant and also more than the ambient light. The effect in turn low caps your light by that low constant for the rest of the turn.

@mugling

This comment has been minimized.

Copy link
Contributor

commented Oct 29, 2016

Overall these numbers look too generous, especially those from PER. I can see why you want to keep the scalar low to maintain granularity so it might be worth adding a lower bound so that the bonus is 1 in 2 above PER 8?

@Coolthulhu

This comment has been minimized.

Copy link
Contributor Author

commented Oct 30, 2016

Overall these numbers look too generous, especially those from PER.

I'm trying to keep it conservative with the current generous numbers so that it doesn't result in going back to old (pre-rework) ones. What would be good numbers?

Current master has 1 for no NV trait and 6 or so with it.

adding a lower bound so that the bonus is 1 in 2 above PER 8

I'd rather avoid thresholds like that. They encourage dumping stats and create breakpoints, while also removing rewards for bumping stats from "bad" to "mediocre".

@mugling

This comment has been minimized.

Copy link
Contributor

commented Oct 30, 2016

I see your point about breakpoints but the problem is a typical player (PER 10) now has fairly good out-of-box night vision of 4 tiles. You could drop the base 1 tile but retain the lower bound?

@mugling mugling self-assigned this Oct 30, 2016

float const held_luminance = p.active_light();
if( held_luminance > LIGHT_AMBIENT_LOW ) {
apply_light_source( p.pos(), held_luminance );
}

if( held_luminance >= 4 && held_luminance > ambient_light_at( p.pos() ) - 0.5f ) {
p.add_effect( effect_haslight, 1 );

This comment has been minimized.

Copy link
@mugling

mugling Oct 31, 2016

Contributor

It's crude but I can't think of a better solution?

This comment has been minimized.

Copy link
@Coolthulhu

Coolthulhu Oct 31, 2016

Author Contributor

The worst part is that it is in the vision code.
The problem is, there is no callback like "on player's luminance changed", since luminance is recalculated once per turn and involves effects, items and bionics.

@mugling

This comment has been minimized.

Copy link
Contributor

commented Oct 31, 2016

For an existing save if I reduced PER to 0 without other mutations I get a 1 tile radius (correct). Increasing PER sequentially gives no effect until PER 10 or above?

@mugling

This comment has been minimized.

Copy link
Contributor

commented Oct 31, 2016

Lit-up effect works correctly though

@Coolthulhu

This comment has been minimized.

Copy link
Contributor Author

commented Oct 31, 2016

Increasing PER sequentially gives no effect until PER 10 or above?

Eye encumbrance?
Are you in total darkness? Partial light will blind NV at a different rate than it grants regular vision. The numbers were never balanced against each other, so little light can be worse than no light.

@mugling

This comment has been minimized.

Copy link
Contributor

commented Oct 31, 2016

Zero encumbrance, pitch black (basement)

@Coolthulhu

This comment has been minimized.

Copy link
Contributor Author

commented Oct 31, 2016

Try debugging in NV and then removing it. It sometimes fails to update for some reason.

@mugling

This comment has been minimized.

Copy link
Contributor

commented Oct 31, 2016

No change

// Range 7.
threshold = 2.65;

float range = get_per() / 4.0f - encumb( bp_eyes ) / 10.0f;

This comment has been minimized.

Copy link
@mugling

mugling Oct 31, 2016

Contributor

Should that not be

float range = get_per() / 3.0f - encumb( bp_eyes ) / 10.0f;

This comment has been minimized.

Copy link
@Coolthulhu

Coolthulhu Oct 31, 2016

Author Contributor

Should probably be.

But that still doesn't explain the 10 per thing.

Is 10 the threshold or just the first value tested that worked?

This comment has been minimized.

Copy link
@mugling

mugling Oct 31, 2016

Contributor

If you adjust it to 3.0f you get a lower bound of PER 6 for the first increase to two tiles (which makes sense considering you get one point at PER 3 but this is masked by the default lower bound)

@Coolthulhu

This comment has been minimized.

Copy link
Contributor Author

commented Oct 31, 2016

Shit, I'll need to look into it.

Is the rest working fine?

@mugling mugling merged commit e545da2 into CleverRaven:master Oct 31, 2016

@illi-kun illi-kun referenced this pull request Nov 4, 2016

Closed

fixing Night Vision 1 #18640

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.