SW: Fix mouse aiming

git-svn-id: https://svn.eduke32.com/eduke32@8298 1a8010ca-5511-0410-912e-c29ae57300e0

# Conflicts:
#	source/sw/src/config.cpp
#	source/sw/src/game.cpp
This commit is contained in:
hendricks266 2019-11-26 08:24:19 +00:00 committed by Christoph Oelckers
parent 46d4855901
commit 2fc49b3489
5 changed files with 44 additions and 55 deletions

View file

@ -3911,7 +3911,6 @@ void GetHelpInput(PLAYERp pp)
}
short MirrorDelay;
int MouseYAxisMode = -1;
void getinput(SW_PACKET *loc)
{
@ -3930,16 +3929,11 @@ void getinput(SW_PACKET *loc)
#define MAXVEL ((NORMALKEYMOVE*2)+10)
#define MAXSVEL ((NORMALKEYMOVE*2)+10)
#define MAXANGVEL 100
#define MAXAIMVEL 128
#define SET_LOC_KEY(loc, sync_num, key_test) SET(loc, ((!!(key_test)) << (sync_num)))
ControlInfo info;
int32_t running;
int32_t turnamount;
static int32_t turnheldtime;
int32_t keymove;
int32_t momx, momy;
int aimvel;
int mouseaxis;
extern SWBOOL MenuButtonAutoRun;
extern SWBOOL MenuButtonAutoAim;
@ -3951,7 +3945,6 @@ void getinput(SW_PACKET *loc)
// reset all syncbits
loc->bits = 0;
svel = vel = angvel = aimvel = 0;
// MAKE SURE THIS WILL GET SET
SET_LOC_KEY(loc->bits, SK_QUIT_GAME, MultiPlayQuitFlag);
@ -3978,7 +3971,9 @@ void getinput(SW_PACKET *loc)
}
}
int const aimMode = TEST(pp->Flags, PF_MOUSE_AIMING_ON);
ControlInfo info;
CONTROL_GetInput(&info);
if (in_mousedeadzone)
@ -4065,36 +4060,10 @@ void getinput(SW_PACKET *loc)
SET_LOC_KEY(loc->bits, SK_SPACE_BAR, ((!!inputState.GetKeyStatus(KEYSC_SPACE)) | buttonMap.ButtonDown(gamefunc_Open)));
running = false;// G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run));
int const keyMove = running ? (NORMALKEYMOVE << 1) : NORMALKEYMOVE;
constexpr int const analogExtent = 32767; // KEEPINSYNC sdlayer.cpp
constexpr int const analogTurnAmount = (NORMALTURN << 1);
if (buttonMap.ButtonDown(gamefunc_Strafe) && !pp->sop)
{
static int strafeyaw;
svel = -(info.mousex + strafeyaw) >> 3;
strafeyaw = (info.mousex + strafeyaw) % 8;
svel -= info.dyaw * keyMove / analogExtent;
}
else
{
angvel = fix16_div(fix16_from_int(info.mousex), F16(32));
angvel += fix16_from_int(info.dyaw) / analogExtent * (analogTurnAmount << 1);
angvel >>= 15;
}
aimvel = fix16_div(fix16_from_int(info.mousey), F16(64));
if (!in_mouseflip) // SW's mouse is inverted by default.
aimvel = -aimvel;
aimvel -= fix16_from_int(info.dpitch) / analogExtent * analogTurnAmount;
aimvel >>= 15;
int const running = BUTTON(gamefunc_Run) || TEST(pp->Flags, PF_LOCK_RUN); // G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run));
int32_t turnamount;
int32_t keymove;
constexpr int const analogExtent = 32767; // KEEPINSYNC sdlayer.cpp
svel -= info.dx * keyMove / analogExtent;
vel -= info.dz * keyMove / analogExtent;
@ -4118,6 +4087,34 @@ void getinput(SW_PACKET *loc)
keymove = NORMALKEYMOVE;
}
info.dz = (info.dz * move_scale)>>8;
info.dyaw = (info.dyaw * turn_scale)>>8;
int32_t svel = 0, vel = 0, angvel = 0, aimvel = 0;
if (buttonMap.ButtonDown(gamefunc_Strafe) && !pp->sop)
{
svel = -info.mousex;
svel -= info.dyaw * keymove / analogExtent;
}
else
{
angvel = info.mousex / 32;
angvel += info.dyaw * (turnamount << 1) / analogExtent;
}
if (aimMode)
aimvel = -info.mousey / 64;
else
vel = -(info.mousey >> 6);
if (!in_mouseflip)
aimvel = -aimvel;
aimvel -= info.dpitch * turnamount / analogExtent;
svel -= info.dx * keymove / analogExtent;
vel -= info.dz * keymove / analogExtent;
if (buttonMap.ButtonDown(gamefunc_Strafe) && !pp->sop)
{
if (buttonMap.ButtonDown(gamefunc_Turn_Left))
@ -4170,19 +4167,11 @@ void getinput(SW_PACKET *loc)
if (buttonMap.ButtonDown(gamefunc_Move_Backward))
vel += -keymove;
vel = clamp(vel, -MAXVEL, MAXVEL);
svel = clamp(svel, -MAXSVEL, MAXSVEL);
if (vel < -MAXVEL)
vel = -MAXVEL;
if (vel > MAXVEL)
vel = MAXVEL;
if (svel < -MAXSVEL)
svel = -MAXSVEL;
if (svel > MAXSVEL)
svel = MAXSVEL;
if (angvel < -MAXANGVEL)
angvel = -MAXANGVEL;
if (angvel > MAXANGVEL)
angvel = MAXANGVEL;
angvel = clamp(angvel, -MAXANGVEL, MAXANGVEL);
aimvel = clamp(aimvel, -MAXAIMVEL, MAXAIMVEL);
momx = mulscale9(vel, sintable[NORM_ANGLE(newpp->pang + 512)]);
momy = mulscale9(vel, sintable[NORM_ANGLE(newpp->pang)]);

View file

@ -2251,7 +2251,6 @@ extern char keys[];
extern short screenpeek;
extern int dimensionmode, zoom;
extern int vel,svel,angvel;
#define STAT_DAMAGE_LIST_SIZE 20
extern int16_t StatDamageList[STAT_DAMAGE_LIST_SIZE];

View file

@ -134,7 +134,6 @@ extern SWBOOL FinishedLevel;
char PlayerGravity = PLAYER_JUMP_GRAV;
#endif
int vel, svel, angvel;
extern SWBOOL DebugOperate;
//unsigned char synctics, lastsynctics;
@ -3116,7 +3115,7 @@ DriveCrush(PLAYERp pp, int *x, int *y)
if (sp->z < sop->crush_z)
continue;
vel = FindDistance2D(pp->xvect>>8, pp->yvect>>8);
int32_t const vel = FindDistance2D(pp->xvect>>8, pp->yvect>>8);
if (vel < 9000)
{
DoActorBeginSlide(i, getangle(pp->xvect, pp->yvect), vel/8, 5);

View file

@ -493,6 +493,7 @@ int SaveGame(short save_num)
MWRITE(Track[i].TrackPoint, Track[i].NumPoints * sizeof(TRACK_POINT),1,fil);
}
int32_t svel = 0, vel = 0, angvel = 0;
MWRITE(&vel,sizeof(vel),1,fil);
MWRITE(&svel,sizeof(svel),1,fil);
MWRITE(&angvel,sizeof(angvel),1,fil);
@ -1013,6 +1014,7 @@ int LoadGame(short save_num)
}
}
int32_t svel, vel, angvel;
MREAD(&vel,sizeof(vel),1,fil);
MREAD(&svel,sizeof(svel),1,fil);
MREAD(&angvel,sizeof(angvel),1,fil);

View file

@ -9251,7 +9251,7 @@ DoVulcanBoulder(int16_t Weapon)
u->ret = move_missile(Weapon, u->xchange, u->ychange, u->zchange,
u->ceiling_dist, u->floor_dist, CLIPMASK_MISSILE, MISSILEMOVETICS);
vel = ksqrt(SQ(u->xchange) + SQ(u->ychange));
int32_t const vel = ksqrt(SQ(u->xchange) + SQ(u->ychange));
if (vel < 30)
{
@ -11268,7 +11268,7 @@ SpawnNuclearSecondaryExp(int16_t Weapon, short ang)
RESET(exp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
//ang = RANDOM_P2(2048);
vel = (2048+128) + RANDOM_RANGE(2048);
int32_t const vel = (2048+128) + RANDOM_RANGE(2048);
eu->xchange = MOVEx(vel, ang);
eu->ychange = MOVEy(vel, ang);
eu->Radius = 200; // was NUKE_RADIUS