Merge autoaim X and Y into just autoaim

This commit is contained in:
Ryan Dwyer 2022-11-12 20:59:58 +10:00
parent c7a85d503f
commit aeb09b7afa
6 changed files with 45 additions and 116 deletions

View File

@ -44,15 +44,15 @@ void bmoveSetAutoMoveCentreEnabled(bool enabled)
g_Vars.currentplayer->automovecentreenabled = enabled;
}
void bmoveSetAutoAimY(bool enabled)
void bmoveSetAutoAim(bool enabled)
{
g_Vars.currentplayer->autoyaimenabled = enabled;
g_Vars.currentplayer->autoaimenabled = enabled;
}
bool bmoveIsAutoAimYEnabled(void)
bool bmoveIsAutoAimEnabled(void)
{
if (!g_Vars.normmplayerisrunning) {
return g_Vars.currentplayer->autoyaimenabled;
return g_Vars.currentplayer->autoaimenabled;
}
if (g_MpSetup.options & MPOPTION_NOAUTOAIM) {
@ -62,7 +62,7 @@ bool bmoveIsAutoAimYEnabled(void)
return optionsGetAutoAim(g_Vars.currentplayerstats->mpindex);
}
bool bmoveIsAutoAimYEnabledForCurrentWeapon(void)
bool bmoveIsAutoAimEnabledForCurrentWeapon(void)
{
struct weaponfunc *func = currentPlayerGetWeaponFunction(0);
@ -76,7 +76,7 @@ bool bmoveIsAutoAimYEnabledForCurrentWeapon(void)
}
}
return bmoveIsAutoAimYEnabled();
return bmoveIsAutoAimEnabled();
}
bool bmoveIsInSightAimMode(void)
@ -84,75 +84,23 @@ bool bmoveIsInSightAimMode(void)
return g_Vars.currentplayer->insightaimmode;
}
void bmoveUpdateAutoAimYProp(struct prop *prop, f32 autoaimy)
void bmoveUpdateAutoAimProp(struct prop *prop, f32 x, f32 y)
{
if (g_Vars.currentplayer->autoyaimtime60 >= 0) {
g_Vars.currentplayer->autoyaimtime60 -= g_Vars.lvupdate60;
if (g_Vars.currentplayer->autoaimtime60 >= 0) {
g_Vars.currentplayer->autoaimtime60 -= g_Vars.lvupdate60;
}
if (prop != g_Vars.currentplayer->autoyaimprop) {
if (g_Vars.currentplayer->autoyaimtime60 < 0) {
g_Vars.currentplayer->autoyaimtime60 = TICKS(30);
g_Vars.currentplayer->autoyaimprop = prop;
if (prop != g_Vars.currentplayer->autoaimprop) {
if (g_Vars.currentplayer->autoaimtime60 < 0) {
g_Vars.currentplayer->autoaimtime60 = TICKS(30);
g_Vars.currentplayer->autoaimprop = prop;
} else {
return;
}
}
g_Vars.currentplayer->autoaimy = autoaimy;
}
void bmoveSetAutoAimX(bool enabled)
{
g_Vars.currentplayer->autoxaimenabled = enabled;
}
bool bmoveIsAutoAimXEnabled(void)
{
if (!g_Vars.normmplayerisrunning) {
return g_Vars.currentplayer->autoxaimenabled;
}
if (g_MpSetup.options & MPOPTION_NOAUTOAIM) {
return false;
}
return optionsGetAutoAim(g_Vars.currentplayerstats->mpindex);
}
bool bmoveIsAutoAimXEnabledForCurrentWeapon(void)
{
struct weaponfunc *func = currentPlayerGetWeaponFunction(0);
if (func) {
if (func->flags & FUNCFLAG_NOAUTOAIM) {
return false;
}
if ((func->type & 0xff) == INVENTORYFUNCTYPE_CLOSE) {
return true;
}
}
return bmoveIsAutoAimXEnabled();
}
void bmoveUpdateAutoAimXProp(struct prop *prop, f32 autoaimx)
{
if (g_Vars.currentplayer->autoxaimtime60 >= 0) {
g_Vars.currentplayer->autoxaimtime60 -= g_Vars.lvupdate60;
}
if (prop != g_Vars.currentplayer->autoxaimprop) {
if (g_Vars.currentplayer->autoxaimtime60 < 0) {
g_Vars.currentplayer->autoxaimtime60 = TICKS(30);
g_Vars.currentplayer->autoxaimprop = prop;
} else {
return;
}
}
g_Vars.currentplayer->autoaimx = autoaimx;
g_Vars.currentplayer->autoaimx = x;
g_Vars.currentplayer->autoaimy = y;
}
struct prop *bmoveGetHoverbike(void)
@ -1732,9 +1680,8 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
if (
(
movedata.canautoaim
&& (bmoveIsAutoAimXEnabledForCurrentWeapon() || bmoveIsAutoAimYEnabledForCurrentWeapon())
&& g_Vars.currentplayer->autoxaimprop
&& g_Vars.currentplayer->autoyaimprop
&& bmoveIsAutoAimEnabledForCurrentWeapon()
&& g_Vars.currentplayer->autoaimprop
&& weaponHasAimFlag(weaponnum, INVAIMFLAG_AUTOAIM)
)
|| (bgunGetWeaponNum(HAND_RIGHT) == WEAPON_CMP150 && g_Vars.currentplayer->hands[HAND_RIGHT].gset.weaponfunc == FUNC_SECONDARY)) {

View File

@ -692,15 +692,11 @@ void playerLoadDefaults(void)
g_Vars.currentplayer->automovecentre = true;
g_Vars.currentplayer->insightaimmode = false;
g_Vars.currentplayer->autoyaimenabled = true;
g_Vars.currentplayer->autoaimy = 0;
g_Vars.currentplayer->autoyaimprop = NULL;
g_Vars.currentplayer->autoyaimtime60 = -1;
g_Vars.currentplayer->autoxaimenabled = true;
g_Vars.currentplayer->autoaimenabled = true;
g_Vars.currentplayer->autoaimx = 0;
g_Vars.currentplayer->autoxaimprop = NULL;
g_Vars.currentplayer->autoxaimtime60 = -1;
g_Vars.currentplayer->autoaimy = 0;
g_Vars.currentplayer->autoaimprop = NULL;
g_Vars.currentplayer->autoaimtime60 = -1;
g_Vars.currentplayer->autoaimdamp = (PAL ? 0.974f : 0.979f);
@ -2955,8 +2951,7 @@ void playerTick(bool arg0)
playerUpdateColourScreenProperties();
playerTickChrFade();
bmoveSetAutoAimY(optionsGetAutoAim(g_Vars.currentplayerstats->mpindex));
bmoveSetAutoAimX(optionsGetAutoAim(g_Vars.currentplayerstats->mpindex));
bmoveSetAutoAim(optionsGetAutoAim(g_Vars.currentplayerstats->mpindex));
bmoveSetAutoMoveCentreEnabled(optionsGetLookAhead(g_Vars.currentplayerstats->mpindex));
bgunSetGunAmmoVisible(GUNAMMOREASON_OPTION, optionsGetAmmoOnScreen(g_Vars.currentplayerstats->mpindex));
bgunSetSightVisible(GUNSIGHTREASON_1, true);

View File

@ -270,15 +270,11 @@ void playermgrAllocatePlayer(s32 index)
g_Vars.players[index]->automovecentre = true;
g_Vars.players[index]->insightaimmode = false;
g_Vars.players[index]->autoyaimenabled = true;
g_Vars.players[index]->autoaimy = 0;
g_Vars.players[index]->autoyaimprop = NULL;
g_Vars.players[index]->autoyaimtime60 = -1;
g_Vars.players[index]->autoxaimenabled = true;
g_Vars.players[index]->autoaimenabled = true;
g_Vars.players[index]->autoaimx = 0;
g_Vars.players[index]->autoxaimprop = NULL;
g_Vars.players[index]->autoxaimtime60 = -1;
g_Vars.players[index]->autoaimy = 0;
g_Vars.players[index]->autoaimprop = NULL;
g_Vars.players[index]->autoaimtime60 = -1;
g_Vars.players[index]->vv_theta = 0;
g_Vars.players[index]->speedtheta = 0;

View File

@ -2282,7 +2282,7 @@ f32 func0f06438c(struct prop *prop, struct coord *arg1, f32 *arg2, f32 *arg3, f3
sp8c[0] = floorf(sp8c[0]);
sp84[0] = ceilf(sp84[0]);
if (bmoveIsAutoAimXEnabledForCurrentWeapon() || cangangsta) {
if (bmoveIsAutoAimEnabledForCurrentWeapon() || cangangsta) {
if (sp8c[0] <= right && left <= sp84[0]) {
sp48 = (sp84[0] - sp8c[0]) * 1.5f;
@ -2325,7 +2325,7 @@ f32 func0f06438c(struct prop *prop, struct coord *arg1, f32 *arg2, f32 *arg3, f3
arg4[1] = value;
if (bmoveIsAutoAimXEnabledForCurrentWeapon() || cangangsta) {
if (bmoveIsAutoAimEnabledForCurrentWeapon() || cangangsta) {
f32 value = spa0[0];
if (value < left) {
@ -2521,9 +2521,7 @@ void autoaimTick(void)
break;
}
}
} else if ((bmoveIsAutoAimYEnabledForCurrentWeapon()
|| bmoveIsAutoAimXEnabledForCurrentWeapon()
|| cangangsta) && !isclose) {
} else if ((bmoveIsAutoAimEnabledForCurrentWeapon() || cangangsta) && !isclose) {
// Standard auto aim
f32 bestthing = -1;
struct prop *prop;
@ -2570,12 +2568,10 @@ void autoaimTick(void)
}
if (bestprop) {
if (bmoveIsAutoAimYEnabledForCurrentWeapon() || iscmpsec) {
bmoveUpdateAutoAimYProp(bestprop, (aimpos[1] - camGetScreenTop()) / (camGetScreenHeight() * 0.5f) - 1);
}
if (bmoveIsAutoAimXEnabledForCurrentWeapon() || iscmpsec) {
bmoveUpdateAutoAimXProp(bestprop, (aimpos[0] - camGetScreenLeft()) / (camGetScreenWidth() * 0.5f) - 1);
if (bmoveIsAutoAimEnabledForCurrentWeapon() || iscmpsec) {
f32 x = (aimpos[0] - camGetScreenLeft()) / (camGetScreenWidth() * 0.5f) - 1;
f32 y = (aimpos[1] - camGetScreenTop()) / (camGetScreenHeight() * 0.5f) - 1;
bmoveUpdateAutoAimProp(bestprop, x, y);
}
if (cangangsta) {
@ -2594,8 +2590,7 @@ void autoaimTick(void)
}
} else {
u32 stack;
bmoveUpdateAutoAimYProp(NULL, 0);
bmoveUpdateAutoAimXProp(NULL, 0);
bmoveUpdateAutoAimProp(NULL, 0, 0);
g_Vars.currentplayer->gunctrl.gangsta = false;
}

View File

@ -6,15 +6,11 @@
void bmoveSetControlDef(u32 controldef);
void bmoveSetAutoMoveCentreEnabled(bool enabled);
void bmoveSetAutoAimY(bool enabled);
bool bmoveIsAutoAimYEnabled(void);
bool bmoveIsAutoAimYEnabledForCurrentWeapon(void);
void bmoveSetAutoAim(bool enabled);
bool bmoveIsAutoAimEnabled(void);
bool bmoveIsAutoAimEnabledForCurrentWeapon(void);
bool bmoveIsInSightAimMode(void);
void bmoveUpdateAutoAimYProp(struct prop *prop, f32 autoaimy);
void bmoveSetAutoAimX(bool enabled);
bool bmoveIsAutoAimXEnabled(void);
bool bmoveIsAutoAimXEnabledForCurrentWeapon(void);
void bmoveUpdateAutoAimXProp(struct prop *prop, f32 autoaimx);
void bmoveUpdateAutoAimProp(struct prop *prop, f32 x, f32 y);
struct prop *bmoveGetHoverbike(void);
struct prop *bmoveGetGrabbedProp(void);
void bmoveGrabProp(struct prop *prop);

View File

@ -2390,15 +2390,15 @@ struct player {
/*0x011c*/ bool automovecentre;
/*0x0120*/ bool insightaimmode;
/*0x0124*/ bool autoyaimenabled;
/*0x0124*/ bool autoaimenabled;
/*0x0128*/ f32 autoaimx;
/*0x0128*/ f32 autoaimy;
/*0x012c*/ struct prop *autoyaimprop;
/*0x0130*/ s32 autoyaimtime60;
/*0x012c*/ struct prop *autoaimprop;
/*0x0130*/ s32 autoaimtime60;
/*0x0134*/ bool autoxaimenabled;
/*0x0138*/ f32 autoaimx;
/*0x013c*/ struct prop *autoxaimprop;
/*0x0140*/ s32 autoxaimtime60;
/*0x0124*/ bool autoxaimenabled;
/*0x012c*/ struct prop *autoaimxprop;
/*0x0130*/ s32 autoaimxtime60;
/*0x0144*/ f32 vv_theta; // turn angle in degrees
/*0x0148*/ f32 speedtheta; // turn speed