Open TrainTurningPoint opened 5 years ago
I'd advise against this. It would be very complex.
The player vision code works roughly by propagating 8 cones, each 45 degrees wide. This is easy to do from one point, but there is no obvious solution for extending it to an area - other than by scanning with more cones (vision is one of the most expensive computations in the game already). NPCs and monsters work differently. They trace lines from their point to the target. This is expensive (already) and gets obscene with many monsters of different factions leering each other.
Then there is an issue of a special case of monster-player vision. You might have noticed monsters seeing you through the camera - that is because they quite literally see you when you see them. They use same line of sight, just different ranges on it. It doesn't sound compatible with peek-vision.
Yes, I suspected this much. Direct implementation with calculating vision for every point will likely tank the performance. Still I'd like to try and have a go at it eventually.
I dislike current implementation of the peeking mechanic very much. Each peeking iteration requires the player to perform three keypresses - once to peek, second time to select direction, then dismiss looking around mode. At the same time, the operation is almost free from character's point of view, and it's benefit is huge, especially in areas with ranged enemies (mostly labs). That means that the optimum way to play (peek around every corner and doorway) is hidden behind a wall of tedium and poor UI. That is not a good solution, so I believe peeking mechanic should be reworked.
Solution
Expand player vision area as if it was coming from a 5-tile cross-shaped area (+) instead of a single tile. Essentially, assume that player is constantly peeking in 4 directions every turn, only without making keypresses or spending action points. Remove the peeking action. Make sure that player is not visible to creatures from former blind spots. Make sure same logic works for peeking through closed curtains (player sees through them if he stands point blank to the curtain while being on the correct side of the glass).
Describe alternatives you've considered
Expand the player vision as if it was coming from 9-tile area - too overpowered because it will allow player to see the entire room without entering it. Give the same ability to creatures and NPCs - would cause too many seemingly unfair situations where monster detects the PC while PC can't see it yet.
Additional context I haven't actually explored the code related to player vision area. It might be possible that the desired solution is unreasonably hard to implement. Different solutions will be investigated in this case.