Fix PlayerCmd not handling angle and aiming correctly

This commit is contained in:
LJ Sonic 2020-11-23 01:23:34 +01:00
parent e95a05880f
commit 7ff6443659

View file

@ -1677,10 +1677,26 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
}
}
// Note: Lat originally made the PlayerCmd hook for SRB2 Kart so credit goes to him.
// At this point, cmd doesn't contain the final angle yet,
// So we need to temporarily transform it so Lua scripters
// don't need to handle it differently than in other hooks.
if (gamestate == GS_LEVEL)
{
INT16 extra = ticcmd_oldangleturn[forplayer] - player->oldrelangleturn;
INT16 origangle = cmd->angleturn;
INT16 orighookangle = (INT16)(origangle + player->angleturn + extra);
INT16 origaiming = cmd->aiming;
cmd->angleturn = orighookangle;
LUAh_PlayerCmd(player, cmd);
extra = cmd->angleturn - orighookangle;
cmd->angleturn = origangle + extra;
*myangle += extra << 16;
*myaiming += (cmd->aiming - origaiming) << 16;
}
//Reset away view if a command is given.
if (ssplayer == 1 && (cmd->forwardmove || cmd->sidemove || cmd->buttons)
&& displayplayer != consoleplayer)