Duke 3D: Viewscreens pre-placed with a yvel of 1 no longer display their camera feed
Forum thread: https://forums.duke4.net/topic/10446-r7326-fog-and-viewscreens/
https://www.youtube.com/watch?v=p86F2RIlQqo
The viewscreens shown in the video by design cannot be activated by the use key, but instead are supposed to display their camera image while the player stands in range. This is done by setting yvel of the viewscreen to 1, and relying on the fact that all viewscreens begin displaying an image when one has activated.
This behavior was intentionally disabled in 5f63918c, and the relevant code sections are more or less unchanged since then. The following is in actors.cpp
:
{
const int32_t p = A_FindPlayer(s, &x);
const DukePlayer_t *const ps = g_player[p].ps;
if (dist(&sprite[ps->i], s) < VIEWSCREEN_ACTIVE_DISTANCE)
{
#if 0
if (sprite[i].yvel == 1) // VIEWSCREEN_YVEL
g_curViewscreen = i;
#endif
}
else if (g_curViewscreen == i /*&& T1 == 1*/)
{
g_curViewscreen = -1;
sprite[i].yvel = 0; // VIEWSCREEN_YVEL
T1 = 0;
walock[TILE_VIEWSCR] = 199;
}
Relevant to the activation of the viewscreen at close ranges is the #if0 portion of the code. This is what reset the screen to the camera view when coming close to the screen, and it relies on the yvel of the screen being 1. Note that every screen has its yvel set to 1 after being used, but screens may also be placed this way in the map itself. The attached map shows how this could be used, and it may have been utilized in real usermaps.
The else-if portion of the code sets the yvel back to 0. This also prevents the screen from showing the camera view when being close, so this also needs to be removed if one wants to restore this functionality.
Then we have the following in game.cpp
:
else if (g_curViewscreen == i && display_mirror != 3 && waloff[TILE_VIEWSCR] && walock[TILE_VIEWSCR] > 200)
The conditional check was changed from g_curViewscreen >= 0
to g_curViewscreen == i
. This means that only a single viewscreen may be active at a time. This may be important to reconsider for potential multiplayer.
Finally, in a previous commit, the VIEWSCREEN_ACTIVE_DISTANCE
has been increased from 2048 to 8192. This has an effect on the viewscreen in the attached test map, in the sense that the active distance of both screens overlaps. If both are active, it will show the same view from both of them.
The following map is a particularly extreme example, relying on several tricks to display the camera image: ___scrn2.map
I will leave it up to the maintainers to decide what should be done with this functionality -- whether it should be kept as is at the expense of potential map-placed active viewscreens (for which we don't even know if a real usermap exists with this functionality) or whether any of this behavior should be changed.