forked from Ports/perfect_dark
port: don't uncrouch in spaces where we don't fit when using extended controls
This commit is contained in:
1 parent
683d083fab
commit
b2338179d6
3 files changed
+83
No files matched your search
@@ -1583,6 +1583,7 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
|
||||
}
|
||||
|
||||
// Handle xbla-style crouch cycling
|
||||
const s32 oldcrouchpos = g_Vars.currentplayer->crouchpos;
|
||||
for (i = 0; i < numsamples; i++) {
|
||||
// handle 1964GEPD style crouch setting
|
||||
s32 crouchsample;
|
||||
@@ -1624,6 +1625,10 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
|
||||
}
|
||||
}
|
||||
}
|
||||
// prevent uncrouching if we don't fit
|
||||
while (g_Vars.currentplayer->crouchpos > oldcrouchpos && !bwalkCanUncrouch()) {
|
||||
g_Vars.currentplayer->crouchpos--;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -237,6 +237,47 @@ s32 bwalkTryMoveUpwards(f32 amount)
|
||||
return result;
|
||||
}
|
||||
|
||||
bool bwalkCanMoveUpwards(f32 amount)
|
||||
{
|
||||
bool result;
|
||||
struct coord newpos;
|
||||
RoomNum rooms[8];
|
||||
u32 stack;
|
||||
u32 types;
|
||||
f32 ymax;
|
||||
f32 ymin;
|
||||
f32 radius;
|
||||
|
||||
if (g_Vars.currentplayer->floorflags & GEOFLAG_SLOPE) {
|
||||
g_Vars.enableslopes = false;
|
||||
} else {
|
||||
g_Vars.enableslopes = true;
|
||||
}
|
||||
|
||||
newpos.x = g_Vars.currentplayer->prop->pos.x;
|
||||
newpos.y = g_Vars.currentplayer->prop->pos.y + amount;
|
||||
newpos.z = g_Vars.currentplayer->prop->pos.z;
|
||||
|
||||
types = g_Vars.bondcollisions ? CDTYPE_ALL : CDTYPE_BG;
|
||||
|
||||
playerGetBbox(g_Vars.currentplayer->prop, &radius, &ymax, &ymin);
|
||||
func0f065e74(&g_Vars.currentplayer->prop->pos, g_Vars.currentplayer->prop->rooms, &newpos, rooms);
|
||||
bmoveFindEnteredRoomsByPos(g_Vars.currentplayer, &newpos, rooms);
|
||||
propSetPerimEnabled(g_Vars.currentplayer->prop, false);
|
||||
|
||||
ymin -= 0.1f;
|
||||
|
||||
result = cdTestVolume(&newpos, radius, rooms, types, CHECKVERTICAL_YES,
|
||||
ymax - g_Vars.currentplayer->prop->pos.y,
|
||||
ymin - g_Vars.currentplayer->prop->pos.y);
|
||||
|
||||
propSetPerimEnabled(g_Vars.currentplayer->prop, true);
|
||||
|
||||
g_Vars.enableslopes = true;
|
||||
|
||||
return (result == CDRESULT_NOCOLLISION);
|
||||
}
|
||||
|
||||
bool bwalkCalculateNewPosition(struct coord *vel, f32 rotateamount, bool apply, f32 extrawidth, s32 checktypes)
|
||||
{
|
||||
s32 result = CDRESULT_NOCOLLISION;
|
||||
@@ -1168,6 +1209,41 @@ void bwalkUpdateCrouchOffsetReal(void)
|
||||
}
|
||||
}
|
||||
|
||||
bool bwalkCanUncrouch(void)
|
||||
{
|
||||
f32 targetoffset = 0;
|
||||
|
||||
if (g_Vars.currentplayer->crouchpos == CROUCHPOS_SQUAT) {
|
||||
targetoffset = -90;
|
||||
} else if (g_Vars.currentplayer->crouchpos == CROUCHPOS_DUCK) {
|
||||
targetoffset = -45;
|
||||
}
|
||||
|
||||
if (targetoffset != g_Vars.currentplayer->crouchoffset) {
|
||||
f32 prevcrouchoffset = g_Vars.currentplayer->crouchoffset;
|
||||
f32 prevcrouchoffsetreal = g_Vars.currentplayer->crouchoffsetreal;
|
||||
f32 prevcrouchoffsetsmall = g_Vars.currentplayer->crouchoffsetsmall;
|
||||
f32 prevcrouchoffsetrealsmall = g_Vars.currentplayer->crouchoffsetrealsmall;
|
||||
f32 prevcrouchspeed = g_Vars.currentplayer->crouchspeed;
|
||||
|
||||
g_Vars.currentplayer->crouchoffset = targetoffset;
|
||||
|
||||
bwalkUpdateCrouchOffsetReal();
|
||||
|
||||
const bool result = bwalkCanMoveUpwards(0);
|
||||
|
||||
g_Vars.currentplayer->crouchoffset = prevcrouchoffset;
|
||||
g_Vars.currentplayer->crouchoffsetreal = prevcrouchoffsetreal;
|
||||
g_Vars.currentplayer->crouchoffsetsmall = prevcrouchoffsetsmall;
|
||||
g_Vars.currentplayer->crouchoffsetrealsmall = prevcrouchoffsetrealsmall;
|
||||
g_Vars.currentplayer->crouchspeed = prevcrouchspeed;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void bwalkUpdateCrouchOffset(void)
|
||||
{
|
||||
f32 targetoffset = 0;
|
||||
|
||||
@@ -10,6 +10,7 @@ void bwalkSetSwayTargetf(f32 value);
|
||||
void bwalkAdjustCrouchPos(s32 value);
|
||||
void bwalk0f0c3b38(struct coord *param_1, struct defaultobj *obj);
|
||||
s32 bwalkTryMoveUpwards(f32 amount);
|
||||
bool bwalkCanMoveUpwards(f32 amount);
|
||||
bool bwalkCalculateNewPosition(struct coord *vel, f32 rotateamount, bool apply, f32 extrawidth, s32 arg4);
|
||||
bool bwalkCalculateNewPositionWithPush(struct coord *delta, f32 rotateamount, bool apply, f32 extrawidth, s32 types);
|
||||
s32 bwalk0f0c4764(struct coord *delta, struct coord *arg1, struct coord *arg2, s32 types);
|
||||
@@ -21,6 +22,7 @@ void bwalkUpdateSpeedSideways(f32 targetspeed, f32 accelspeed, s32 mult);
|
||||
void bwalkUpdateSpeedForwards(f32 targetspeed, f32 accelspeed);
|
||||
void bwalkUpdateVertical(void);
|
||||
void bwalkApplyCrouchSpeed(void);
|
||||
bool bwalkCanUncrouch(void);
|
||||
void bwalkUpdateCrouchOffsetReal(void);
|
||||
void bwalkUpdateCrouchOffset(void);
|
||||
void bwalkUpdateTheta(void);
|
||||
|
||||
Reference in new issue
Block a user