mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-20 00:11:19 +00:00
Allow switching lockon targets with turn buttons
This commit is contained in:
parent
d14fa39d7a
commit
bc4b1e1abe
2 changed files with 22 additions and 1 deletions
21
src/g_game.c
21
src/g_game.c
|
@ -1057,6 +1057,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
|||
static boolean keyboard_look[2]; // true if lookup/down using keyboard
|
||||
static boolean resetdown[2]; // don't cam reset every frame
|
||||
static boolean joyaiming[2]; // check the last frame's value if we need to reset the camera
|
||||
static boolean zchange[2]; // only switch z targets once per press
|
||||
UINT8 forplayer = ssplayer-1;
|
||||
|
||||
if (ssplayer == 1)
|
||||
|
@ -1322,6 +1323,26 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
|||
P_SetTarget(&ticcmd_ztargetfocus[forplayer], NULL);
|
||||
else
|
||||
{
|
||||
mobj_t *newtarget = NULL;
|
||||
if (zchange[forplayer])
|
||||
{
|
||||
if (!turnleft && !turnright && abs(cmd->angleturn) < angleturn[0])
|
||||
zchange[forplayer] = false;
|
||||
}
|
||||
else if (turnleft || cmd->angleturn > angleturn[0])
|
||||
{
|
||||
zchange[forplayer] = true;
|
||||
newtarget = P_LookForFocusTarget(player, ticcmd_ztargetfocus[forplayer], 1, cv_cam_lockonboss[forplayer].value);
|
||||
}
|
||||
else if (turnright || cmd->angleturn < -angleturn[0])
|
||||
{
|
||||
zchange[forplayer] = true;
|
||||
newtarget = P_LookForFocusTarget(player, ticcmd_ztargetfocus[forplayer], -1, cv_cam_lockonboss[forplayer].value);
|
||||
}
|
||||
|
||||
if (newtarget)
|
||||
P_SetTarget(&ticcmd_ztargetfocus[forplayer], newtarget);
|
||||
|
||||
if (P_AproxDistance(
|
||||
player->mo->x - ticcmd_ztargetfocus[forplayer]->x,
|
||||
player->mo->y - ticcmd_ztargetfocus[forplayer]->y
|
||||
|
|
|
@ -9162,7 +9162,7 @@ mobj_t *P_LookForFocusTarget(player_t *player, mobj_t *exclude, SINT8 direction,
|
|||
if (mo->flags & MF_NOCLIPTHING)
|
||||
continue;
|
||||
|
||||
if (mo == player->mo)
|
||||
if (mo == player->mo || mo == exclude)
|
||||
continue;
|
||||
|
||||
if (mo->health <= 0) // dead
|
||||
|
|
Loading…
Reference in a new issue