Call P_ResetCamera Upon Switching To/From an Away View Camera

This commit is contained in:
SMS Alfredo 2023-06-03 15:43:58 -05:00
parent d6d424f102
commit aa43aa7c8c
3 changed files with 22 additions and 4 deletions

View file

@ -710,6 +710,10 @@ static int player_set(lua_State *L)
if (!lua_isnil(L, 3)) if (!lua_isnil(L, 3))
mo = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); mo = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ));
P_SetTarget(&plr->awayviewmobj, mo); P_SetTarget(&plr->awayviewmobj, mo);
if (plr == &players[displayplayer])
P_ResetCamera(plr, &camera); // reset p1 camera on p1 getting an awayviewmobj
else if (splitscreen && plr == &players[secondarydisplayplayer])
P_ResetCamera(plr, &camera2); // reset p2 camera on p2 getting an awayviewmobj
} }
else if (fastcmp(field,"awayviewtics")) else if (fastcmp(field,"awayviewtics"))
{ {

View file

@ -2669,6 +2669,11 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
{ {
P_SetTarget(&mo->player->awayviewmobj, altview); P_SetTarget(&mo->player->awayviewmobj, altview);
mo->player->awayviewtics = line->args[1]; mo->player->awayviewtics = line->args[1];
if (mo->player == &players[displayplayer])
P_ResetCamera(mo->player, &camera); // reset p1 camera on p1 getting an awayviewmobj
else if (splitscreen && mo->player == &players[secondarydisplayplayer])
P_ResetCamera(mo->player, &camera2); // reset p2 camera on p2 getting an awayviewmobj
} }
aim = udmf ? altview->spawnpoint->pitch : line->args[2]; aim = udmf ? altview->spawnpoint->pitch : line->args[2];

View file

@ -11507,15 +11507,24 @@ void P_PlayerThink(player_t *player)
if (player->awayviewmobj && P_MobjWasRemoved(player->awayviewmobj)) if (player->awayviewmobj && P_MobjWasRemoved(player->awayviewmobj))
{ {
P_SetTarget(&player->awayviewmobj, NULL); // remove awayviewmobj asap if invalid P_SetTarget(&player->awayviewmobj, NULL); // remove awayviewmobj asap if invalid
player->awayviewtics = 0; // reset to zero player->awayviewtics = 1; // reset to one, the below code will immediately set it to zero
}
if (player->awayviewtics && player->awayviewtics != -1)
{
player->awayviewtics--;
if (!(player->awayviewtics))
{
if (player == &players[displayplayer])
P_ResetCamera(player, &camera); // reset p1 camera on p1 running out of awayviewtics
else if (splitscreen && player == &players[secondarydisplayplayer])
P_ResetCamera(player, &camera2); // reset p2 camera on p2 running out of awayviewtics
}
} }
if (player->flashcount) if (player->flashcount)
player->flashcount--; player->flashcount--;
if (player->awayviewtics && player->awayviewtics != -1)
player->awayviewtics--;
/// \note do this in the cheat code /// \note do this in the cheat code
if (player->pflags & PF_NOCLIP) if (player->pflags & PF_NOCLIP)
player->mo->flags |= MF_NOCLIP; player->mo->flags |= MF_NOCLIP;