mirror of
https://github.com/perfect-dark-pc-port/perfect_dark.git
synced 2026-10-23 15:52:41 +02:00
Merge pull request #631 from AL2009man/CrosshairFix
Crosshair Edge Deadzone slider and fixed `insightaim` Camera Movement
This commit is contained in:
5 files changed
+44
-17
No files matched your search
@@ -179,6 +179,7 @@ PD_CONSTRUCTOR static void gameConfigInit(void)
|
||||
configRegisterFloat(strFmt("Game.Player%d.MouseAimSpeedY", i), &g_PlayerExtCfg[j].mouseaimspeedy, 0.f, 10.f);
|
||||
configRegisterFloat(strFmt("Game.Player%d.RadialMenuSpeed", i), &g_PlayerExtCfg[j].radialmenuspeed, 0.f, 10.f);
|
||||
configRegisterFloat(strFmt("Game.Player%d.CrosshairSway", i), &g_PlayerExtCfg[j].crosshairsway, 0.f, 10.f);
|
||||
configRegisterFloat(strFmt("Game.Player%d.CrosshairEdgeBoundary", i), &g_PlayerExtCfg[j].crosshairedgeboundary, 0.0f, 1.0f);
|
||||
configRegisterInt(strFmt("Game.Player%d.CrouchMode", i), &g_PlayerExtCfg[j].crouchmode, 0, CROUCHMODE_TOGGLE_ANALOG);
|
||||
configRegisterInt(strFmt("Game.Player%d.ExtendedControls", i), &g_PlayerExtCfg[j].extcontrols, 0, 1);
|
||||
configRegisterUInt(strFmt("Game.Player%d.CrosshairColour", i), &g_PlayerExtCfg[j].crosshaircolour, 0, 0xFFFFFFFF);
|
||||
|
||||
@@ -1291,6 +1291,22 @@ static MenuItemHandlerResult menuhandlerCrosshairSway(s32 operation, struct menu
|
||||
return 0;
|
||||
}
|
||||
|
||||
static MenuItemHandlerResult menuhandlerCrosshairEdgeBoundary(s32 operation, struct menuitem* item, union handlerdata *data)
|
||||
{
|
||||
switch (operation) {
|
||||
case MENUOP_GETSLIDER:
|
||||
data->slider.value = (s32)(g_PlayerExtCfg[g_ExtMenuPlayer].crosshairedgeboundary * 10.f + 0.5f);
|
||||
break;
|
||||
case MENUOP_SET:
|
||||
g_PlayerExtCfg[g_ExtMenuPlayer].crosshairedgeboundary = (f32)data->slider.value / 10.f;
|
||||
break;
|
||||
case MENUOP_GETSLIDERLABEL:
|
||||
sprintf(data->slider.label, "%d", (s32)data->slider.value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static MenuItemHandlerResult menuhandlerCrosshairR(s32 operation, struct menuitem* item, union handlerdata* data)
|
||||
{
|
||||
u32 newColor;
|
||||
@@ -1512,6 +1528,14 @@ struct menuitem g_ExtendedGameMenuItems[] = {
|
||||
20,
|
||||
menuhandlerCrosshairSway,
|
||||
},
|
||||
{
|
||||
MENUITEMTYPE_SLIDER,
|
||||
0,
|
||||
MENUITEMFLAG_LITERAL_TEXT | MENUITEMFLAG_SLIDER_WIDE,
|
||||
(uintptr_t)"Crosshair Edge Deadzone",
|
||||
10,
|
||||
menuhandlerCrosshairEdgeBoundary,
|
||||
},
|
||||
{
|
||||
MENUITEMTYPE_SLIDER,
|
||||
0,
|
||||
|
||||
+17
-17
@@ -1412,31 +1412,31 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
|
||||
}
|
||||
|
||||
#ifndef PLATFORM_N64
|
||||
// Handle turning and looking up/down via mouselook when aiming
|
||||
if (g_Vars.currentplayer->insightaimmode && allowmcross && bgunGetWeaponNum(HAND_RIGHT) != WEAPON_HORIZONSCANNER) {
|
||||
if (g_Vars.currentplayer->swivelpos[0] > 0.9f) {
|
||||
movedata.aimturnrightspeed = (g_Vars.currentplayer->swivelpos[0] - 0.9f) / 0.1f;
|
||||
movedata.aimturnleftspeed = 0.f;
|
||||
} else if (g_Vars.currentplayer->swivelpos[0] < -0.9f) {
|
||||
movedata.aimturnleftspeed = (g_Vars.currentplayer->swivelpos[0] - -0.9f) / -0.1f;
|
||||
movedata.aimturnrightspeed = 0.f;
|
||||
// Handle turning and looking (x/y) via mouselook when aiming
|
||||
bool allowcross = allowmcross;
|
||||
if (g_Vars.currentplayer->insightaimmode && allowcross && bgunGetWeaponNum(HAND_RIGHT) != WEAPON_HORIZONSCANNER) {
|
||||
float edge_boundary = PLAYER_EXTCFG().crosshairedgeboundary;
|
||||
if (g_Vars.currentplayer->swivelpos[0] > edge_boundary) {
|
||||
movedata.aimturnrightspeed += (g_Vars.currentplayer->swivelpos[0] - edge_boundary) / (1.0f - edge_boundary);
|
||||
} else if (g_Vars.currentplayer->swivelpos[0] < -edge_boundary) {
|
||||
movedata.aimturnleftspeed += (g_Vars.currentplayer->swivelpos[0] + edge_boundary) / -(1.0f - edge_boundary);
|
||||
}
|
||||
f32 vertaup = 0.f, vertadown = 0.f;
|
||||
if (g_Vars.currentplayer->swivelpos[1] > 0.9f) {
|
||||
vertaup = (g_Vars.currentplayer->swivelpos[1] - 0.9f) / 0.1f;
|
||||
} else if (g_Vars.currentplayer->swivelpos[1] < -0.9f) {
|
||||
vertadown = (g_Vars.currentplayer->swivelpos[1] - -0.9f) / -0.1f;
|
||||
if (g_Vars.currentplayer->swivelpos[1] > edge_boundary) {
|
||||
vertaup = (g_Vars.currentplayer->swivelpos[1] - edge_boundary) / (1.0f - edge_boundary);
|
||||
} else if (g_Vars.currentplayer->swivelpos[1] < -edge_boundary) {
|
||||
vertadown = (g_Vars.currentplayer->swivelpos[1] + edge_boundary) / -(1.0f - edge_boundary);
|
||||
}
|
||||
// Uninvert pitch if needed
|
||||
if (movedata.invertpitch) {
|
||||
movedata.speedvertaup = vertadown;
|
||||
movedata.speedvertadown = vertaup;
|
||||
movedata.speedvertaup += vertadown;
|
||||
movedata.speedvertadown += vertaup;
|
||||
} else {
|
||||
movedata.speedvertaup = vertaup;
|
||||
movedata.speedvertadown = vertadown;
|
||||
movedata.speedvertaup += vertaup;
|
||||
movedata.speedvertadown += vertadown;
|
||||
}
|
||||
} else {
|
||||
// Reset mouse aim position when not mouse aiming
|
||||
// Reset mouse aim position when not aiming
|
||||
g_Vars.currentplayer->swivelpos[0] = 0.f;
|
||||
g_Vars.currentplayer->swivelpos[1] = 0.f;
|
||||
}
|
||||
|
||||
@@ -139,6 +139,7 @@ struct mpweapon g_MpWeapons[NUM_MPWEAPONS] = {
|
||||
.extcontrols = true, \
|
||||
.crosshaircolour = 0x00ff0028, \
|
||||
.crosshairsize = 2, \
|
||||
.crosshairedgeboundary = 0.7f, \
|
||||
.crosshairhealth = CROSSHAIR_HEALTH_OFF, \
|
||||
.usereloads = false, \
|
||||
}
|
||||
|
||||
@@ -6158,6 +6158,7 @@ struct extplayerconfig {
|
||||
s32 extcontrols;
|
||||
u32 crosshaircolour;
|
||||
u32 crosshairsize;
|
||||
f32 crosshairedgeboundary;
|
||||
s32 crosshairhealth;
|
||||
s32 usereloads;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user