F to crouch w/ sniper

F to crouch with sniper
F + Z to crouch with sniper
This commit is contained in:
Catherine Reprobate 2023-08-19 14:47:43 -07:00
parent a71c7cbba2
commit c3dc838acb
4 changed files with 33 additions and 18 deletions

View File

@ -23,7 +23,7 @@ void amTick(void)
g_AmIndex = g_Vars.currentplayernum;
if (g_AmMenus[g_AmIndex].togglefunc) {
if (bgunConsiderToggleGunFunction(60, false, true) > 0) {
if (bgunConsiderToggleGunFunction(60, false, true, 0) > 0) {
g_AmMenus[g_AmIndex].togglefunc = false;
}
} else {

View File

@ -11686,19 +11686,26 @@ void bgunSetTriggerOn(s32 handnum, bool on)
* - USETIMER_STOP if the B button timer should stop (ie. the B press is consumed)
* - USETIMER_REPEAT if this function should be called again on each frame until B is released.
*/
s32 bgunConsiderToggleGunFunction(s32 usedowntime, bool trigpressed, bool fromactivemenu)
s32 bgunConsiderToggleGunFunction(s32 usedowntime, bool trigpressed, bool fromactivemenu, bool fromdedicatedbutton)
{
switch (bgunGetWeaponNum(HAND_RIGHT)) {
case WEAPON_SNIPERRIFLE:
// At 25 ticks (or B+Z), start showing the new function
if (usedowntime < 0) {
return USETIMER_CONTINUE;
}
// g_Vars.currentplayer->gunctrl.invertgunfunc = !g_Vars.currentplayer->gunctrl.invertgunfunc;
g_Vars.currentplayer->gunctrl.invertgunfunc = true;
// B+Z immediately triggers crouch or stand
if (trigpressed) {
g_Vars.currentplayer->hands[HAND_RIGHT].activatesecondary = true;
return USETIMER_STOP;
}
if (fromdedicatedbutton) {
g_Vars.currentplayer->hands[HAND_RIGHT].activatesecondary = true;
return USETIMER_CONTINUE;
}
// Don't do anything if B hasn't been held for 50/60ths of a second
if (ABS(usedowntime) < 0) {
return USETIMER_CONTINUE;
}
@ -11709,13 +11716,13 @@ s32 bgunConsiderToggleGunFunction(s32 usedowntime, bool trigpressed, bool fromac
// Do crouch or stand
g_Vars.currentplayer->hands[HAND_RIGHT].activatesecondary = true;
return USETIMER_REPEAT;
return USETIMER_STOP;
case WEAPON_RCP120:
case WEAPON_LAPTOPGUN:
case WEAPON_DRAGON:
case WEAPON_REMOTEMINE:
// These weapons use temporary alt functions
g_Vars.currentplayer->gunctrl.invertgunfunc = true;
g_Vars.currentplayer->gunctrl.invertgunfunc = !g_Vars.currentplayer->gunctrl.invertgunfunc;
if (fromactivemenu && bgunIsUsingSecondaryFunction() == true) {
g_Vars.currentplayer->hands[HAND_RIGHT].activatesecondary = true;
@ -11761,8 +11768,16 @@ s32 bgunConsiderToggleGunFunction(s32 usedowntime, bool trigpressed, bool fromac
void bgun0f0a8c50(void)
{
if (g_Vars.currentplayer->hands[HAND_RIGHT].activatesecondary == false) {
g_Vars.currentplayer->gunctrl.invertgunfunc = false;
switch (bgunGetWeaponNum(HAND_RIGHT)) {
case WEAPON_RCP120:
case WEAPON_LAPTOPGUN:
case WEAPON_DRAGON:
case WEAPON_REMOTEMINE:
return;
default:
if (g_Vars.currentplayer->hands[HAND_RIGHT].activatesecondary == false) {
g_Vars.currentplayer->gunctrl.invertgunfunc = false;
}
}
}

View File

@ -941,13 +941,13 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
if (g_Vars.currentplayer->usedowntime >= -1) {
if (joyGetButtonsPressedOnSample(i, shootpad, shootallowedbuttons & Z_TRIG)
&& g_Vars.currentplayer->usedowntime > -1
&& bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, true, false) != USETIMER_CONTINUE) {
&& bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, true, false, 0) != USETIMER_CONTINUE) {
g_Vars.currentplayer->usedowntime = -3;
}
if (g_Vars.currentplayer->usedowntime > -1) {
if (g_Vars.currentplayer->usedowntime > TICKS(25)) {
result = bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, false, false);
result = bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, false, false, 0);
if (result == USETIMER_STOP) {
g_Vars.currentplayer->usedowntime = -1;
@ -961,7 +961,7 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
}
}
} else if (g_Vars.currentplayer->usedowntime >= -2) {
bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, false, false);
bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, false, false, 0);
}
} else {
// Released B - activate or reload
@ -1313,13 +1313,13 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
if (g_Vars.currentplayer->usedowntime >= -1) {
if (joyGetButtonsPressedOnSample(i, contpad1, shootbuttons & c1allowedbuttons)
&& g_Vars.currentplayer->usedowntime >= 0
&& bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, true, false) != USETIMER_CONTINUE) {
&& bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, true, false, 0) != USETIMER_CONTINUE) {
g_Vars.currentplayer->usedowntime = -3;
}
if (g_Vars.currentplayer->usedowntime >= 0) {
if (g_Vars.currentplayer->usedowntime > TICKS(25)) {
s32 result = bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, false, false);
s32 result = bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, false, false, 0);
if (result == USETIMER_STOP) {
g_Vars.currentplayer->usedowntime = -1;
@ -1334,7 +1334,7 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
}
} else {
if (g_Vars.currentplayer->usedowntime >= -2) {
bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, false, false);
bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, false, false, 0);
}
}
} else {
@ -1356,7 +1356,7 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
if (g_Vars.currentplayer->altdowntime >= -1) {
if (joyGetButtonsPressedOnSample(i, contpad1, shootbuttons & c1allowedbuttons)
&& g_Vars.currentplayer->altdowntime >= 0
&& bgunConsiderToggleGunFunction(g_Vars.currentplayer->altdowntime, true, false) != USETIMER_CONTINUE) {
&& bgunConsiderToggleGunFunction(g_Vars.currentplayer->altdowntime, true, false, true) != USETIMER_CONTINUE) {
g_Vars.currentplayer->altdowntime = -3;
}
@ -1367,14 +1367,14 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
}
} else {
if (g_Vars.currentplayer->altdowntime == -2) {
bgunConsiderToggleGunFunction(g_Vars.currentplayer->altdowntime, false, false);
bgunConsiderToggleGunFunction(g_Vars.currentplayer->altdowntime, false, false, true);
g_Vars.currentplayer->altdowntime = -4;
}
}
} else {
// Released L
if (g_Vars.currentplayer->altdowntime != 0) {
s32 result = bgunConsiderToggleGunFunction(g_Vars.currentplayer->altdowntime, (g_Vars.currentplayer->altdowntime == -3 ? true: false), false);
s32 result = bgunConsiderToggleGunFunction(g_Vars.currentplayer->altdowntime, (g_Vars.currentplayer->altdowntime == -3 ? true: false), false, true);
if (result == USETIMER_STOP) {
g_Vars.currentplayer->altdowntime = -1;

View File

@ -145,7 +145,7 @@ void bgunPlayPropHitSound(struct gset *gset, struct prop *prop, s32 texturenum);
void bgunPlayGlassHitSound(struct coord *pos, RoomNum *rooms, s32 texturenum);
void bgunPlayBgHitSound(struct gset *gset, struct coord *hitpos, s32 texturenum, RoomNum *rooms);
void bgunSetTriggerOn(s32 handnum, bool on);
s32 bgunConsiderToggleGunFunction(s32 usedowntime, bool trigpressed, bool fromactivemenu);
s32 bgunConsiderToggleGunFunction(s32 usedowntime, bool trigpressed, bool fromactivemenu, bool fromdedicatedbutton);
void bgun0f0a8c50(void);
bool bgunIsUsingSecondaryFunction(void);
void bgunTickGameplay(bool triggeron);