Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit fac95e7

Browse files
committed
Fix kbd only craft and crabs moving when you try to use the pie menu
Crabs will act like humans and keep previous movement. Craft will not cause they're big and clumsy
1 parent 9f87da4 commit fac95e7

File tree

3 files changed

+57
-43
lines changed

3 files changed

+57
-43
lines changed

Entities/ACrab.cpp

Lines changed: 48 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2195,50 +2195,57 @@ void ACrab::Update()
21952195
const float movementThreshold = 1.0F;
21962196
bool isStill = (m_Vel + m_PrevVel).MagnitudeIsLessThan(movementThreshold);
21972197

2198-
if (m_Controller.IsState(MOVE_RIGHT) || m_Controller.IsState(MOVE_LEFT) || m_MoveState == JUMP && m_Status != INACTIVE) {
2199-
if (m_MoveState != JUMP)
2200-
{
2201-
// Restart the stride if we're just starting to walk or crawl
2202-
if (m_MoveState != WALK)
2203-
{
2204-
m_StrideStart[LEFTSIDE] = true;
2205-
m_StrideStart[RIGHTSIDE] = true;
2206-
MoveOutOfTerrain(g_MaterialGrass);
2207-
}
2198+
// If the pie menu is on, try to preserve whatever move state we had before it going into effect.
2199+
// This is only done for digital input, where the user needs to use the keyboard to choose pie slices.
2200+
// For analog input, this doesn't matter - the mouse or aiming analog stick controls the pie menu.
2201+
bool keepOldState = m_Controller.IsKeyboardOnlyControlled() && m_Controller.IsState(PIE_MENU_ACTIVE);
2202+
2203+
if (!keepOldState) {
2204+
if (m_Controller.IsState(MOVE_RIGHT) || m_Controller.IsState(MOVE_LEFT) || m_MoveState == JUMP && m_Status != INACTIVE) {
2205+
if (m_MoveState != JUMP)
2206+
{
2207+
// Restart the stride if we're just starting to walk or crawl
2208+
if (m_MoveState != WALK)
2209+
{
2210+
m_StrideStart[LEFTSIDE] = true;
2211+
m_StrideStart[RIGHTSIDE] = true;
2212+
MoveOutOfTerrain(g_MaterialGrass);
2213+
}
22082214

2209-
m_MoveState = WALK;
2215+
m_MoveState = WALK;
22102216

2211-
for (int side = 0; side < SIDECOUNT; ++side)
2212-
{
2213-
m_Paths[side][FGROUND][m_MoveState].SetSpeed(m_Controller.IsState(MOVE_FAST) ? FAST : NORMAL);
2214-
m_Paths[side][BGROUND][m_MoveState].SetSpeed(m_Controller.IsState(MOVE_FAST) ? FAST : NORMAL);
2215-
}
2216-
}
2217+
for (int side = 0; side < SIDECOUNT; ++side)
2218+
{
2219+
m_Paths[side][FGROUND][m_MoveState].SetSpeed(m_Controller.IsState(MOVE_FAST) ? FAST : NORMAL);
2220+
m_Paths[side][BGROUND][m_MoveState].SetSpeed(m_Controller.IsState(MOVE_FAST) ? FAST : NORMAL);
2221+
}
2222+
}
22172223

2218-
// Walk backwards if the aiming is already focused in the opposite direction of travel.
2219-
if (std::abs(analogAim.m_X) > 0 || m_Controller.IsState(AIM_SHARP)) {
2220-
for (int side = 0; side < SIDECOUNT; ++side) {
2221-
m_Paths[side][FGROUND][m_MoveState].SetHFlip(m_Controller.IsState(MOVE_LEFT));
2222-
m_Paths[side][BGROUND][m_MoveState].SetHFlip(m_Controller.IsState(MOVE_LEFT));
2223-
}
2224-
} else if ((m_Controller.IsState(MOVE_RIGHT) && m_HFlipped) || (m_Controller.IsState(MOVE_LEFT) && !m_HFlipped)) {
2225-
m_HFlipped = !m_HFlipped;
2226-
m_CheckTerrIntersection = true;
2227-
MoveOutOfTerrain(g_MaterialGrass);
2228-
for (int side = 0; side < SIDECOUNT; ++side)
2229-
{
2230-
for (int layer = 0; layer < LAYERCOUNT; ++layer)
2231-
{
2232-
m_Paths[side][layer][m_MoveState].SetHFlip(m_HFlipped);
2233-
m_Paths[side][layer][WALK].Terminate();
2234-
m_Paths[side][layer][STAND].Terminate();
2235-
}
2236-
m_StrideStart[side] = true;
2237-
}
2238-
}
2239-
}
2240-
else
2241-
m_MoveState = STAND;
2224+
// Walk backwards if the aiming is already focused in the opposite direction of travel.
2225+
if (std::abs(analogAim.m_X) > 0 || m_Controller.IsState(AIM_SHARP)) {
2226+
for (int side = 0; side < SIDECOUNT; ++side) {
2227+
m_Paths[side][FGROUND][m_MoveState].SetHFlip(m_Controller.IsState(MOVE_LEFT));
2228+
m_Paths[side][BGROUND][m_MoveState].SetHFlip(m_Controller.IsState(MOVE_LEFT));
2229+
}
2230+
} else if ((m_Controller.IsState(MOVE_RIGHT) && m_HFlipped) || (m_Controller.IsState(MOVE_LEFT) && !m_HFlipped)) {
2231+
m_HFlipped = !m_HFlipped;
2232+
m_CheckTerrIntersection = true;
2233+
MoveOutOfTerrain(g_MaterialGrass);
2234+
for (int side = 0; side < SIDECOUNT; ++side)
2235+
{
2236+
for (int layer = 0; layer < LAYERCOUNT; ++layer)
2237+
{
2238+
m_Paths[side][layer][m_MoveState].SetHFlip(m_HFlipped);
2239+
m_Paths[side][layer][WALK].Terminate();
2240+
m_Paths[side][layer][STAND].Terminate();
2241+
}
2242+
m_StrideStart[side] = true;
2243+
}
2244+
}
2245+
} else {
2246+
m_MoveState = STAND;
2247+
}
2248+
}
22422249

22432250
////////////////////////////////////
22442251
// Reload held MO, if applicable

Entities/AHuman.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3091,7 +3091,7 @@ void AHuman::Update()
30913091
// If the pie menu is on, try to preserve whatever move state we had before it going into effect.
30923092
// This is only done for digital input, where the user needs to use the keyboard to choose pie slices.
30933093
// For analog input, this doesn't matter - the mouse or aiming analog stick controls the pie menu.
3094-
bool keepOldState = !m_Controller.IsMouseControlled() && !m_Controller.IsGamepadControlled() && m_Controller.IsState(PIE_MENU_ACTIVE);
3094+
bool keepOldState = m_Controller.IsKeyboardOnlyControlled() && m_Controller.IsState(PIE_MENU_ACTIVE);
30953095

30963096
if (!keepOldState) {
30973097
bool crouching = m_Controller.IsState(BODY_CROUCH);

System/Controller.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,14 @@ namespace RTE {
361361
m_ControlStates[ControlState::WEAPON_FIRE] = false;
362362
m_ControlStates[ControlState::AIM_UP] = false;
363363
m_ControlStates[ControlState::AIM_DOWN] = false;
364-
}
364+
365+
if (IsKeyboardOnlyControlled()) {
366+
m_ControlStates[ControlState::MOVE_RIGHT] = false;
367+
m_ControlStates[ControlState::MOVE_LEFT] = false;
368+
m_ControlStates[ControlState::MOVE_UP] = false;
369+
m_ControlStates[ControlState::MOVE_DOWN] = false;
370+
}
371+
}
365372
}
366373

367374
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)