add another local ticcmd builder so it can guess if we "moved" and put us into freecam state and shit
This commit is contained in:
1 parent
3dd0313d53
commit
bd989239ea
4 files changed
+79
-54
No files matched your search
@@ -538,8 +538,6 @@ typedef struct player_s
|
||||
INT32 awayviewtics;
|
||||
angle_t awayviewaiming; // Used for cut-away view
|
||||
|
||||
boolean speccam;
|
||||
|
||||
boolean spectator;
|
||||
UINT8 bot;
|
||||
|
||||
|
||||
+71
-37
@@ -848,6 +848,76 @@ static fixed_t forwardmove[2] = {25<<FRACBITS>>16, 50<<FRACBITS>>16};
|
||||
static fixed_t sidemove[2] = {2<<FRACBITS>>16, 4<<FRACBITS>>16};
|
||||
static fixed_t angleturn[3] = {KART_FULLTURN/2, KART_FULLTURN, KART_FULLTURN/4}; // + slow turn
|
||||
|
||||
// this is absolutely awful
|
||||
// but we need this if we dont want spectators to move but be able to go to freecam from watching someone
|
||||
static void G_BuildLocalTiccmd(UINT8 ssplayer)
|
||||
{
|
||||
const UINT8 forplayer = ssplayer-1;
|
||||
boolean forward, side, axis; //i
|
||||
boolean usejoystick;
|
||||
boolean turnleft, turnright;
|
||||
|
||||
ticcmd_t *cmd = D_LocalTiccmd(forplayer);
|
||||
|
||||
const boolean analogjoystickmove = cv_usejoystick[forplayer].value && !Joystick[forplayer].bGamepadStyle;
|
||||
const boolean gamepadjoystickmove = cv_usejoystick[forplayer].value && Joystick[forplayer].bGamepadStyle;
|
||||
|
||||
usejoystick = (analogjoystickmove || gamepadjoystickmove);
|
||||
|
||||
turnright = InputDown(gc_turnright, ssplayer);
|
||||
turnleft = InputDown(gc_turnleft, ssplayer);
|
||||
|
||||
axis = JoyAxis(AXISTURN, ssplayer);
|
||||
|
||||
if (gamepadjoystickmove && axis != 0)
|
||||
{
|
||||
turnright = turnright || (axis > 0);
|
||||
turnleft = turnleft || (axis < 0);
|
||||
}
|
||||
side = (turnright || turnleft || (analogjoystickmove && axis != 0));
|
||||
|
||||
forward = false;
|
||||
axis = JoyAxis(AXISAIM, ssplayer);
|
||||
if (InputDown(gc_aimforward, ssplayer) || (usejoystick && axis < 0))
|
||||
forward = true;
|
||||
if (InputDown(gc_aimbackward, ssplayer) || (usejoystick && axis > 0))
|
||||
forward = true;
|
||||
|
||||
axis = JoyAxis(AXISMOVE, ssplayer);
|
||||
if (InputDown(gc_accelerate, ssplayer) || (usejoystick && axis > 0))
|
||||
cmd->buttons |= BT_ACCELERATE;
|
||||
axis = JoyAxis(AXISBRAKE, ssplayer);
|
||||
if (InputDown(gc_brake, ssplayer) || (usejoystick && axis > 0))
|
||||
cmd->buttons |= BT_BRAKE;
|
||||
axis = JoyAxis(AXISFIRE, ssplayer);
|
||||
if (InputDown(gc_fire, ssplayer) || (usejoystick && axis > 0))
|
||||
cmd->buttons |= BT_ATTACK;
|
||||
|
||||
// drift with any button/key
|
||||
axis = JoyAxis(AXISDRIFT, ssplayer);
|
||||
if (InputDown(gc_drift, ssplayer) || (usejoystick && axis > 0))
|
||||
cmd->buttons |= BT_DRIFT;
|
||||
|
||||
// Lua scriptable buttons
|
||||
axis = JoyAxis(AXISCUSTOM1, ssplayer);
|
||||
if (InputDown(gc_custom1, ssplayer) || (usejoystick && axis > 0))
|
||||
cmd->buttons |= BT_CUSTOM1;
|
||||
axis = JoyAxis(AXISCUSTOM2, ssplayer);
|
||||
if (InputDown(gc_custom2, ssplayer) || (usejoystick && axis > 0))
|
||||
cmd->buttons |= BT_CUSTOM2;
|
||||
axis = JoyAxis(AXISCUSTOM3, ssplayer);
|
||||
if (InputDown(gc_custom3, ssplayer) || (usejoystick && axis > 0))
|
||||
cmd->buttons |= BT_CUSTOM3;
|
||||
|
||||
//Reset away view if a command is given.
|
||||
if ((forward || side || cmd->buttons)
|
||||
&& displayplayers[0] != consoleplayer && ssplayer == 1)
|
||||
{
|
||||
displayplayers[0] = consoleplayer;
|
||||
G_FixCamera(1);
|
||||
}
|
||||
}
|
||||
|
||||
void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
||||
{
|
||||
const UINT8 forplayer = ssplayer-1;
|
||||
@@ -916,43 +986,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
||||
// lmfao this is beyond hellish
|
||||
if (player->spectator)
|
||||
{
|
||||
usejoystick = (analogjoystickmove || gamepadjoystickmove);
|
||||
|
||||
axis = JoyAxis(AXISMOVE, ssplayer);
|
||||
if (InputDown(gc_accelerate, ssplayer) || (usejoystick && axis > 0))
|
||||
cmd->buttons |= BT_ACCELERATE;
|
||||
axis = JoyAxis(AXISBRAKE, ssplayer);
|
||||
if (InputDown(gc_brake, ssplayer) || (usejoystick && axis > 0))
|
||||
cmd->buttons |= BT_BRAKE;
|
||||
axis = JoyAxis(AXISFIRE, ssplayer);
|
||||
if (InputDown(gc_fire, ssplayer) || (usejoystick && axis > 0))
|
||||
cmd->buttons |= BT_ATTACK;
|
||||
|
||||
// drift with any button/key
|
||||
axis = JoyAxis(AXISDRIFT, ssplayer);
|
||||
if (InputDown(gc_drift, ssplayer) || (usejoystick && axis > 0))
|
||||
cmd->buttons |= BT_DRIFT;
|
||||
|
||||
// Lua scriptable buttons
|
||||
axis = JoyAxis(AXISCUSTOM1, ssplayer);
|
||||
if (InputDown(gc_custom1, ssplayer) || (usejoystick && axis > 0))
|
||||
cmd->buttons |= BT_CUSTOM1;
|
||||
axis = JoyAxis(AXISCUSTOM2, ssplayer);
|
||||
if (InputDown(gc_custom2, ssplayer) || (usejoystick && axis > 0))
|
||||
cmd->buttons |= BT_CUSTOM2;
|
||||
axis = JoyAxis(AXISCUSTOM3, ssplayer);
|
||||
if (InputDown(gc_custom3, ssplayer) || (usejoystick && axis > 0))
|
||||
cmd->buttons |= BT_CUSTOM3;
|
||||
|
||||
// Reset camera
|
||||
if (InputDown(gc_camreset, ssplayer))
|
||||
{
|
||||
if (thiscam->chase && !rd)
|
||||
P_ResetCamera(player, thiscam);
|
||||
rd = true;
|
||||
}
|
||||
else
|
||||
rd = false;
|
||||
G_BuildLocalTiccmd(ssplayer);
|
||||
|
||||
if (gamestate == GS_LEVEL)
|
||||
LUA_HookTiccmd(player, cmd, HOOK(PlayerCmd));
|
||||
|
||||
@@ -10710,7 +10710,6 @@ void P_SpawnPlayer(INT32 playernum)
|
||||
else if (!G_GametypeHasSpectators())
|
||||
{
|
||||
p->spectator = false;
|
||||
p->speccam = false;
|
||||
}
|
||||
else if (netgame && p->jointime <= 1 && pcount)
|
||||
{
|
||||
@@ -10745,7 +10744,6 @@ void P_SpawnPlayer(INT32 playernum)
|
||||
else // Otherwise, never spectator.
|
||||
{
|
||||
p->spectator = false;
|
||||
p->speccam = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+8
-13
@@ -2272,9 +2272,9 @@ static void P_MovePlayer(player_t *player)
|
||||
}
|
||||
}
|
||||
|
||||
// have to keep this crap for synch reasons
|
||||
if (player->spectator)
|
||||
{
|
||||
player->speccam = true;
|
||||
P_SpectatorMovement(player);
|
||||
return;
|
||||
}
|
||||
@@ -3360,17 +3360,14 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num)
|
||||
|
||||
// if you hold item, you will lock on to displayplayer. (The last player you were ""f12-ing"")
|
||||
// well this only really works in replays for us, since we still move our spec player around which causes displayplayer to be the spec player
|
||||
if (demo.playback)
|
||||
if (cmd->buttons & BT_ATTACK)
|
||||
{
|
||||
if (cmd->buttons & BT_ATTACK)
|
||||
{
|
||||
lastp = &players[displayplayers[0]]; // Fun fact, I was trying displayplayers[0]->mo as if it was Lua like an absolute idiot.
|
||||
lastp = &players[displayplayers[0]]; // Fun fact, I was trying displayplayers[0]->mo as if it was Lua like an absolute idiot.
|
||||
|
||||
const fixed_t dist = R_PointToDist2(cam->x, cam->y, lastp->mo->x, lastp->mo->y);
|
||||
cam->angle = R_PointToAngle2(cam->x, cam->y, lastp->mo->x, lastp->mo->y);
|
||||
cam->aiming = R_PointToAngle2(0, cam->z, dist, lastp->mo->z + lastp->mo->scale*128*P_MobjFlip(lastp->mo)); // This is still unholy. Aim a bit above their heads.
|
||||
cam->reset_aiming = false;
|
||||
}
|
||||
const fixed_t dist = R_PointToDist2(cam->x, cam->y, lastp->mo->x, lastp->mo->y);
|
||||
cam->angle = R_PointToAngle2(cam->x, cam->y, lastp->mo->x, lastp->mo->y);
|
||||
cam->aiming = R_PointToAngle2(0, cam->z, dist, lastp->mo->z + lastp->mo->scale*128*P_MobjFlip(lastp->mo)); // This is still unholy. Aim a bit above their heads.
|
||||
cam->reset_aiming = false;
|
||||
}
|
||||
|
||||
if (cmd->forwardmove != 0)
|
||||
@@ -3721,7 +3718,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
|
||||
num = 0;
|
||||
}
|
||||
|
||||
if (thiscam->freecam || (player->spectator && player->speccam == true))
|
||||
if (thiscam->freecam || player->spectator)
|
||||
{
|
||||
P_DemoCameraMovement(thiscam, num);
|
||||
return true;
|
||||
@@ -4101,7 +4098,6 @@ boolean P_SpectatorJoinGame(player_t *player)
|
||||
player->mo = NULL;
|
||||
}
|
||||
player->spectator = false;
|
||||
player->speccam = false;
|
||||
player->pflags &= ~PF_WANTSTOJOIN;
|
||||
player->kartstuff[k_spectatewait] = 0;
|
||||
player->ctfteam = changeto;
|
||||
@@ -4130,7 +4126,6 @@ boolean P_SpectatorJoinGame(player_t *player)
|
||||
player->mo = NULL;
|
||||
}
|
||||
player->spectator = false;
|
||||
player->speccam = false;
|
||||
player->pflags &= ~PF_WANTSTOJOIN;
|
||||
player->kartstuff[k_spectatewait] = 0;
|
||||
player->playerstate = PST_REBORN;
|
||||
|
||||
Reference in new issue
Block a user