Skip to content

Commit

Permalink
Fixed -turbo movement speed modifier. Plus now implemented in jhereti…
Browse files Browse the repository at this point in the history
…c and jHexen.

Fixed joystick turn issues (the delta was being applied twice).
  • Loading branch information
danij committed Aug 18, 2006
1 parent 5816cff commit 5e280af
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 42 deletions.
1 change: 1 addition & 0 deletions doomsday/plugins/common/include/p_ticcmd.h
Expand Up @@ -29,6 +29,7 @@ typedef struct ticcmd_s {
short pitch; // view pitch
char fly; // Fly up/down; fall down
byte arti;
byte speed;
// Actions:
char attack;
char use;
Expand Down
63 changes: 31 additions & 32 deletions doomsday/plugins/common/src/g_controls.c
Expand Up @@ -89,6 +89,7 @@ static void G_UpdateCmdControls(ticcmd_t *cmd, float elapsedTime);
// EXTERNAL DATA DECLARATIONS ----------------------------------------------

extern boolean sendpause;
extern float turbomul; // multiplier for turbo

// PUBLIC DATA DEFINITIONS -------------------------------------------------

Expand Down Expand Up @@ -459,7 +460,7 @@ static void G_UpdateCmdControls(ticcmd_t *cmd, float elapsedTime)
boolean strafe = 0;
boolean bstrafe = 0;
int speed = 0;
int tspeed = 0;
int turnSpeed = 0, fwdMoveSpeed = 0, sideMoveSpeed = 0;
int forward = 0;
int side = 0;
int turn = 0;
Expand All @@ -468,7 +469,7 @@ static void G_UpdateCmdControls(ticcmd_t *cmd, float elapsedTime)
int *axes[5] = { 0, &joyfwd, &joyturn, &joystrafe, &joylook };
int look = 0, lspeed = 0;
int flyheight = 0;
int pClass = players[consoleplayer].class;
classinfo_t *pClassInfo = PCLASS_INFO(players[consoleplayer].class);

// Check the joystick axes.
for(i = 0; i < 8; i++)
Expand All @@ -491,9 +492,9 @@ static void G_UpdateCmdControls(ticcmd_t *cmd, float elapsedTime)
turnheld = 0;

if(turnheld < SLOWTURNTICS)
tspeed = 2; // slow turn
turnSpeed = 2; // slow turn
else
tspeed = speed;
turnSpeed = speed;

// Determine the appropriate look speed based on how long the key
// has been held down.
Expand All @@ -507,13 +508,18 @@ static void G_UpdateCmdControls(ticcmd_t *cmd, float elapsedTime)
else
lspeed = 2;

// Return the max speed for the player's class.
// FIXME: the Turbo movement multiplier should happen server-side!
sideMoveSpeed = pClassInfo->sidemove[speed] * turbomul;
fwdMoveSpeed = pClassInfo->forwardmove[speed] * turbomul;

// let movement keys cancel each other out
if(strafe)
{
if(actions[A_TURNRIGHT].on)
side += PCLASS_INFO(pClass)->sidemove[speed];
side += sideMoveSpeed;
if(actions[A_TURNLEFT].on)
side -= PCLASS_INFO(pClass)->sidemove[speed];
side -= sideMoveSpeed;

// Swap strafing and turning.
i = joystrafe;
Expand All @@ -523,43 +529,39 @@ static void G_UpdateCmdControls(ticcmd_t *cmd, float elapsedTime)
else
{
if(actions[A_TURNRIGHT].on)
turn -= angleturn[tspeed];
turn -= angleturn[turnSpeed];
if(actions[A_TURNLEFT].on)
turn += angleturn[tspeed];
turn += angleturn[turnSpeed];
}

// Joystick turn.
if(joyturn > 0)
turn -= angleturn[tspeed] * JOY(joyturn);
turn -= angleturn[turnSpeed] * JOY(joyturn);
if(joyturn < -0)
turn += angleturn[tspeed] * JOY(-joyturn);
turn += angleturn[turnSpeed] * JOY(-joyturn);

// Joystick strafe.
if(joystrafe < -0)
side -= PCLASS_INFO(pClass)->sidemove[speed] * JOY(-joystrafe);
side -= sideMoveSpeed * JOY(-joystrafe);
if(joystrafe > 0)
side += PCLASS_INFO(pClass)->sidemove[speed] * JOY(joystrafe);
side += sideMoveSpeed * JOY(joystrafe);

if(joyfwd < -0)
forward += fwdMoveSpeed * JOY(-joyfwd);
if(joyfwd > 0)
forward -= fwdMoveSpeed * JOY(joyfwd);


if(actions[A_FORWARD].on)
forward += PCLASS_INFO(pClass)->forwardmove[speed];
forward += fwdMoveSpeed;

if(actions[A_BACKWARD].on)
forward -= PCLASS_INFO(pClass)->forwardmove[speed];

if(joyfwd < -0)
forward += PCLASS_INFO(pClass)->forwardmove[speed] * JOY(-joyfwd);
if(joyfwd > 0)
forward -= PCLASS_INFO(pClass)->forwardmove[speed] * JOY(joyfwd);
forward -= fwdMoveSpeed;

if(actions[A_STRAFERIGHT].on)
side += PCLASS_INFO(pClass)->sidemove[speed];
side += sideMoveSpeed;
if(actions[A_STRAFELEFT].on)
side -= PCLASS_INFO(pClass)->sidemove[speed];

if(joystrafe < -0)
side -= PCLASS_INFO(pClass)->sidemove[speed] * JOY(-joystrafe);
if(joystrafe > 0)
side += PCLASS_INFO(pClass)->sidemove[speed] * JOY(joystrafe);
side -= sideMoveSpeed;

// Look up/down/center keys
if(!cfg.lookSpring || (cfg.lookSpring && !forward))
Expand Down Expand Up @@ -903,7 +905,7 @@ static void G_UpdateCmdControls(ticcmd_t *cmd, float elapsedTime)

G_ResetMousePos();

#define MAXPLMOVE PCLASS_INFO(pClass)->maxmove
#define MAXPLMOVE pClassInfo->maxmove

if(forward > MAXPLMOVE)
forward = MAXPLMOVE;
Expand All @@ -926,11 +928,8 @@ static void G_UpdateCmdControls(ticcmd_t *cmd, float elapsedTime)
if(cfg.playerMoveSpeed > 1)
cfg.playerMoveSpeed = 1;

forward *= cfg.playerMoveSpeed;
side *= cfg.playerMoveSpeed;

cmd->forwardMove += forward;
cmd->sideMove += side;
cmd->forwardMove += forward * cfg.playerMoveSpeed;
cmd->sideMove += side * cfg.playerMoveSpeed;;

if(cfg.lookSpring && !actions[A_MLOOK].on &&
(cmd->forwardMove > MAXPLMOVE / 3 || cmd->forwardMove < -MAXPLMOVE / 3
Expand Down
2 changes: 2 additions & 0 deletions doomsday/plugins/common/src/g_game.c
Expand Up @@ -1841,6 +1841,7 @@ void G_InitNew(skill_t skill, int episode, int map)
respawnmonsters = cfg.respawnMonstersNightmare;
#endif

// KLUDGE:
#if __JDOOM__
// Fast monsters?
if(fastparm || (skill == sk_nightmare && gameskill != sk_nightmare))
Expand Down Expand Up @@ -1877,6 +1878,7 @@ void G_InitNew(skill_t skill, int episode, int map)
MonsterMissileInfo[i].speed[speed] << FRACBITS;
}
#endif
// <-- KLUDGE

if(!IS_CLIENT)
{
Expand Down
4 changes: 2 additions & 2 deletions doomsday/plugins/common/src/p_user.c
Expand Up @@ -790,7 +790,7 @@ void P_ClientSideThink()
{
P_DeathThink(pl);
}

cmd = &pl->cmd; // The latest local command.
P_CalcHeight(pl);

Expand Down Expand Up @@ -986,7 +986,7 @@ void P_PlayerThink(player_t *player)
#if __JHEXEN__
player->worldTimer++;
#endif

if(player->playerstate == PST_DEAD)
{
P_DeathThink(player);
Expand Down
8 changes: 4 additions & 4 deletions doomsday/plugins/jdoom/src/d_main.c
Expand Up @@ -49,6 +49,7 @@ boolean nomonsters; // checkparm of -nomonsters
boolean respawnparm; // checkparm of -respawn
boolean fastparm; // checkparm of -fast
boolean turboparm; // checkparm of -turbo
float turbomul; // multiplier for turbo

skill_t startskill;
int startepisode;
Expand Down Expand Up @@ -597,6 +598,7 @@ void D_PostInit(void)

// turbo option
p = ArgCheck("-turbo");
turbomul = 1.0f;
if(p)
{
int scale = 200;
Expand All @@ -609,11 +611,9 @@ void D_PostInit(void)
scale = 10;
if(scale > 400)
scale = 400;

Con_Message("turbo scale: %i%%\n", scale);
pclass->forwardmove[0] = pclass->forwardmove[0] * scale / 100;
pclass->forwardmove[1] = pclass->forwardmove[1] * scale / 100;
pclass->sidemove[0] = pclass->sidemove[0] * scale / 100;
pclass->sidemove[1] = pclass->sidemove[1] * scale / 100;
turbomul = scale / 100.f;
}

// Are we autostarting?
Expand Down
22 changes: 22 additions & 0 deletions doomsday/plugins/jheretic/src/h_main.c
Expand Up @@ -60,6 +60,8 @@ int verbose;
boolean devparm; // checkparm of -devparm
boolean nomonsters; // checkparm of -nomonsters
boolean respawnparm; // checkparm of -respawn
boolean turboparm; // checkparm of -turbo
float turbomul; // multiplier for turbo

boolean cdrom; // true if cd-rom mode active
boolean singletics; // debug flag to cancel adaptiveness
Expand Down Expand Up @@ -475,6 +477,26 @@ void H_PostInit(void)
autostart = true;
}

// turbo option
p = ArgCheck("-turbo");
turbomul = 1.0f;
if(p)
{
int scale = 200;
classinfo_t *pclass = PCLASS_INFO(PCLASS_PLAYER);

turboparm = true;
if(p < myargc - 1)
scale = atoi(Argv(p + 1));
if(scale < 10)
scale = 10;
if(scale > 400)
scale = 400;

Con_Message("turbo scale: %i%%\n", scale);
turbomul = scale / 100.f;
}

// -DEVMAP <episode> <map>
// Adds a map wad from the development directory to the wad list,
// and sets the start episode and the start map.
Expand Down
23 changes: 23 additions & 0 deletions doomsday/plugins/jhexen/src/h2_main.c
Expand Up @@ -90,6 +90,9 @@ boolean DevMaps; // true = Map development mode
char *DevMapsDir = ""; // development maps directory
boolean nomonsters; // checkparm of -nomonsters
boolean respawnparm; // checkparm of -respawn
boolean turboparm; // checkparm of -turbo
float turbomul; // multiplier for turbo

boolean randomclass; // checkparm of -randclass
boolean debugmode; // checkparm of -debug
boolean devparm; // checkparm of -devparm
Expand Down Expand Up @@ -477,6 +480,26 @@ static void HandleArgs()
netcheat = ArgExists("-netcheat");
dontrender = ArgExists("-noview");

// turbo option
p = ArgCheck("-turbo");
turbomul = 1.0f;
if(p)
{
int scale = 200;
classinfo_t *pclass = PCLASS_INFO(PCLASS_PLAYER);

turboparm = true;
if(p < myargc - 1)
scale = atoi(Argv(p + 1));
if(scale < 10)
scale = 10;
if(scale > 400)
scale = 400;

Con_Message("turbo scale: %i%%\n", scale);
turbomul = scale / 100.f;
}

// Process command line options
for(opt = ExecOptions; opt->name != NULL; opt++)
{
Expand Down
8 changes: 4 additions & 4 deletions doomsday/plugins/wolftc/src/d_main.c
Expand Up @@ -50,6 +50,7 @@ boolean nomonsters; // checkparm of -nomonsters
boolean respawnparm; // checkparm of -respawn
boolean fastparm; // checkparm of -fast
boolean turboparm; // checkparm of -turbo
float turbomul; // multiplier for turbo

skill_t startskill;
int startepisode;
Expand Down Expand Up @@ -598,6 +599,7 @@ void D_PostInit(void)

// turbo option
p = ArgCheck("-turbo");
turbomul = 1.0f;
if(p)
{
int scale = 200;
Expand All @@ -610,11 +612,9 @@ void D_PostInit(void)
scale = 10;
if(scale > 400)
scale = 400;

Con_Message("turbo scale: %i%%\n", scale);
pclass->forwardmove[0] = pclass->forwardmove[0] * scale / 100;
pclass->forwardmove[1] = pclass->forwardmove[1] * scale / 100;
pclass->sidemove[0] = pclass->sidemove[0] * scale / 100;
pclass->sidemove[1] = pclass->sidemove[1] * scale / 100;
turbomul = scale / 100.f;
}

// Are we autostarting?
Expand Down

0 comments on commit 5e280af

Please sign in to comment.