Skip to content

Commit

Permalink
Gameover additions (#651)
Browse files Browse the repository at this point in the history
* rebase

* fix eos build

* * fix up cursor_hand alignment

* * add openGL vendor info in log on boot

* * export high performance NVIDIA/AMD variables on windows to auto-select high perf gfx

* * hide old tinkering ui
* robots have health percentage in tooltips and tinker ui
* misc clean up

* * missed a bit old tinkering menu removal

* * make player not able to interact after dying until deatth message appears
* add function to determine if !command but checks if using keyboard control

* * more deprecation of !command to allow other players to do stuff with chat open

* * make deathcam rotate as soon as grave falls

* * rename bUsingCommand to usingCommand

* * rename bGameoverActive to isGameoverActive

* * always select first chest slot on open

* * more fixes for disabling player control when game paused

* * another gitignore update

* * shops work better in splitscreen
* other control fixes
* minor cursor fix when swapping to charsheet + inventory

* * add cleanup to player pointers on gui resize
* add auto aspect ratio detection on boot

Co-authored-by: SheridanR <sheridan.rathbun@gmail.com>
Co-authored-by: WALL OF JUSTICE <->
  • Loading branch information
WALLOFJUSTICE and SheridanR authored May 5, 2022
1 parent 8efb92c commit edaf62c
Show file tree
Hide file tree
Showing 18 changed files with 488 additions and 170 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ steam_appid.txt
*.opendb
/VS.2015/Release/
*.lib
*.exp
*.exp
/VS.2015/x64/Steam Crossplay
6 changes: 4 additions & 2 deletions src/acthudweapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3198,12 +3198,14 @@ void actHudShield(Entity* my)
bool wouldBeDefending = false; // to handle different block/sneaking hotkeys. not allowed to sneak if we would be defending on the same hotkey
bool sneaking = false;
const bool shootmode = players[HUDSHIELD_PLAYERNUM]->shootmode;
if (!command && !swimming && shootmode)
if ( !players[HUDSHIELD_PLAYERNUM]->usingCommand()
&& players[HUDSHIELD_PLAYERNUM]->bControlEnabled
&& !gamePaused
&& !swimming && shootmode)
{
if ( players[HUDSHIELD_PLAYERNUM] && players[HUDSHIELD_PLAYERNUM]->entity
&& shootmode
&& players[HUDSHIELD_PLAYERNUM]->entity->isMobile()
&& !gamePaused
&& !cast_animation[HUDSHIELD_PLAYERNUM].active
&& !cast_animation[HUDSHIELD_PLAYERNUM].active_spellbook
&& (!spellbook || (spellbook && hideShield)) )
Expand Down
132 changes: 81 additions & 51 deletions src/actplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,51 +102,64 @@ void actDeathCam(Entity* my)
{
MainMenu::openGameoverWindow(DEATHCAM_PLAYERNUM);
}
DEATHCAM_IDLETIME = TICKS_PER_SECOND * 3;
}
bool shootmode = players[DEATHCAM_PLAYERNUM]->shootmode;
if ( shootmode && !gamePaused )

if ( DEATHCAM_TIME >= deathcamGameoverPromptTicks )
{
if ( smoothmouse )
{
DEATHCAM_ROTX += mousex_relative * .006 * (mouse_speed / 128.f);
DEATHCAM_ROTX = fmin(fmax(-0.35, DEATHCAM_ROTX), 0.35);
}
else
if ( !players[DEATHCAM_PLAYERNUM]->GUI.isGameoverActive() )
{
DEATHCAM_ROTX = std::min<float>(std::max<float>(-0.35f, mousex_relative * .01f * (mouse_speed / 128.f)), 0.35f);
}
my->yaw += DEATHCAM_ROTX;
if ( my->yaw >= PI * 2 )
{
my->yaw -= PI * 2;
}
else if ( my->yaw < 0 )
{
my->yaw += PI * 2;
players[DEATHCAM_PLAYERNUM]->bControlEnabled = true;
}
}

if ( smoothmouse )
{
DEATHCAM_ROTY += mousey_relative * .006 * (mouse_speed / 128.f) * (reversemouse * 2 - 1);
DEATHCAM_ROTY = fmin(fmax(-0.35, DEATHCAM_ROTY), 0.35);
}
else
{
DEATHCAM_ROTY = std::min<float>(std::max<float>(-0.35f, mousey_relative * .01f * (mouse_speed / 128.f) * (reversemouse * 2 - 1)), 0.35f);
}
my->pitch -= DEATHCAM_ROTY;
if ( my->pitch > PI / 2 )
{
my->pitch = PI / 2;
}
else if ( my->pitch < -PI / 2 )
bool shootmode = players[DEATHCAM_PLAYERNUM]->shootmode;
if ( shootmode && !gamePaused )
{
if ( !players[DEATHCAM_PLAYERNUM]->GUI.isGameoverActive() )
{
my->pitch = -PI / 2;
if ( smoothmouse )
{
DEATHCAM_ROTX += mousex_relative * .006 * (mouse_speed / 128.f);
DEATHCAM_ROTX = fmin(fmax(-0.35, DEATHCAM_ROTX), 0.35);
}
else
{
DEATHCAM_ROTX = std::min<float>(std::max<float>(-0.35f, mousex_relative * .01f * (mouse_speed / 128.f)), 0.35f);
}
my->yaw += DEATHCAM_ROTX;
if ( my->yaw >= PI * 2 )
{
my->yaw -= PI * 2;
}
else if ( my->yaw < 0 )
{
my->yaw += PI * 2;
}

if ( smoothmouse )
{
DEATHCAM_ROTY += mousey_relative * .006 * (mouse_speed / 128.f) * (reversemouse * 2 - 1);
DEATHCAM_ROTY = fmin(fmax(-0.35, DEATHCAM_ROTY), 0.35);
}
else
{
DEATHCAM_ROTY = std::min<float>(std::max<float>(-0.35f, mousey_relative * .01f * (mouse_speed / 128.f) * (reversemouse * 2 - 1)), 0.35f);
}
my->pitch -= DEATHCAM_ROTY;
if ( my->pitch > PI / 2 )
{
my->pitch = PI / 2;
}
else if ( my->pitch < -PI / 2 )
{
my->pitch = -PI / 2;
}
}

if ( abs(DEATHCAM_ROTX) < 0.0001 && abs(DEATHCAM_ROTY) < 0.0001
&& DEATHCAM_PLAYERTARGET == DEATHCAM_PLAYERNUM
&& (DEATHCAM_TIME >= deathcamGameoverPromptTicks + TICKS_PER_SECOND * 3) )
&& (DEATHCAM_TIME >= deathcamGameoverPromptTicks) )
{
++DEATHCAM_IDLETIME;
if ( DEATHCAM_IDLETIME >= TICKS_PER_SECOND * 3 )
Expand Down Expand Up @@ -225,7 +238,9 @@ void actDeathCam(Entity* my)
{
// do nothing if still alive
}
else if (Input::inputs[DEATHCAM_PLAYERNUM].consumeBinaryToggle("Attack") && shootmode)
else if (Input::inputs[DEATHCAM_PLAYERNUM].consumeBinaryToggle("Attack") && shootmode
&& !players[DEATHCAM_PLAYERNUM]->GUI.isGameoverActive() && players[DEATHCAM_PLAYERNUM]->bControlEnabled
&& !gamePaused )
{
DEATHCAM_PLAYERTARGET++;
if (DEATHCAM_PLAYERTARGET >= MAXPLAYERS)
Expand Down Expand Up @@ -509,7 +524,9 @@ void Player::PlayerMovement_t::handlePlayerCameraUpdate(bool useRefreshRateDelta
{
refreshRateDelta *= TICKS_PER_SECOND / (real_t)fpsLimit;
}
if ( players[playernum]->shootmode && !command )
if ( player.shootmode && !player.usingCommand()
&& !gamePaused
&& player.bControlEnabled )
{
if ( Input::inputs[playernum].consumeBinaryToggle("Quick Turn") )
{
Expand All @@ -518,7 +535,8 @@ void Player::PlayerMovement_t::handlePlayerCameraUpdate(bool useRefreshRateDelta
}

// rotate
if ( !command && my->isMobile() && !inputs.hasController(PLAYER_NUM) )
if ( !player.usingCommand()
&& player.bControlEnabled && !gamePaused && my->isMobile() && !inputs.hasController(PLAYER_NUM) )
{
if ( !stats[playernum]->EFFECTS[EFF_CONFUSED] )
{
Expand Down Expand Up @@ -632,7 +650,8 @@ void Player::PlayerMovement_t::handlePlayerCameraUpdate(bool useRefreshRateDelta
}

// look up and down
if ( !command && my->isMobile() && !inputs.hasController(PLAYER_NUM) )
if ( !player.usingCommand()
&& player.bControlEnabled && !gamePaused && my->isMobile() && !inputs.hasController(PLAYER_NUM) )
{
if ( !stats[PLAYER_NUM]->EFFECTS[EFF_CONFUSED] )
{
Expand Down Expand Up @@ -802,14 +821,16 @@ void Player::PlayerMovement_t::handlePlayerCameraBobbing(bool useRefreshRateDelt
PLAYER_BOBMOVE -= .03 * refreshRateDelta;
}
}
else if ( (!inputs.hasController(PLAYER_NUM)
else if ( !gamePaused
&& ((!inputs.hasController(PLAYER_NUM)
&& ((input.binary("Move Forward") || input.binary("Move Backward"))
|| (input.binary("Move Left") - input.binary("Move Right"))))
|| (inputs.hasController(PLAYER_NUM)
&& (inputs.getController(PLAYER_NUM)->getLeftXPercentForPlayerMovement()
|| inputs.getController(PLAYER_NUM)->getLeftYPercentForPlayerMovement())) )
|| inputs.getController(PLAYER_NUM)->getLeftYPercentForPlayerMovement()))) )
{
if ( !command && !swimming )
if ( !player.usingCommand()
&& player.bControlEnabled && !swimming )
{
if ( !(stats[PLAYER_NUM]->defending || stats[PLAYER_NUM]->sneaking == 0) )
{
Expand Down Expand Up @@ -842,7 +863,10 @@ void Player::PlayerMovement_t::handlePlayerCameraBobbing(bool useRefreshRateDelt
PLAYER_BOBMODE = 0;
}

if ( !command && !swimming && !inputs.hasController(PLAYER_NUM) && (input.binary("Move Left") - input.binary("Move Right")) )
if ( !player.usingCommand()
&& player.bControlEnabled
&& !gamePaused
&& !swimming && !inputs.hasController(PLAYER_NUM) && (input.binary("Move Left") - input.binary("Move Right")) )
{
if ( (input.binary("Move Right") && !input.binary("Move Backward")) ||
(input.binary("Move Left") && input.binary("Move Backward")) )
Expand Down Expand Up @@ -873,7 +897,10 @@ void Player::PlayerMovement_t::handlePlayerCameraBobbing(bool useRefreshRateDelt
}
}
}
else if ( !command && !swimming && inputs.hasController(PLAYER_NUM) && abs(inputs.getController(PLAYER_NUM)->getLeftXPercentForPlayerMovement()) > 0.001 )
else if ( !player.usingCommand()
&& player.bControlEnabled
&& !gamePaused
&& !swimming && inputs.hasController(PLAYER_NUM) && abs(inputs.getController(PLAYER_NUM)->getLeftXPercentForPlayerMovement()) > 0.001 )
{
auto controller = inputs.getController(PLAYER_NUM);
if ( (controller->getLeftXPercentForPlayerMovement() > 0.001 && controller->getLeftYPercentForPlayerMovement() >= 0.0)
Expand Down Expand Up @@ -1119,7 +1146,8 @@ void Player::PlayerMovement_t::handlePlayerMovement(bool useRefreshRateDelta)
}
}

if ( (!command || pacified) && allowMovement )
if ( ((!player.usingCommand() && player.bControlEnabled && !gamePaused) || pacified)
&& allowMovement )
{
//x_force and y_force represent the amount of percentage pushed on that respective axis. Given a keyboard, it's binary; either you're pushing "move left" or you aren't. On an analog stick, it can range from whatever value to whatever.
float x_force = 0;
Expand Down Expand Up @@ -1509,7 +1537,7 @@ void doStatueEditor(int player)
}
}

if ( !command )
if ( !players[player]->usingCommand() )
{
if ( Entity* limb = uidToEntity(StatueManager.lastEntityUnderMouse) )
{
Expand Down Expand Up @@ -4413,7 +4441,7 @@ void actPlayer(Entity* my)
{
selectedEntity[PLAYER_NUM] = NULL;

if ( !command && input.binaryToggle("Use") )
if ( !players[PLAYER_NUM]->usingCommand() && players[PLAYER_NUM]->bControlEnabled && !gamePaused && input.binaryToggle("Use") )
{
if ( !followerMenu.menuToggleClick && followerMenu.selectMoveTo )
{
Expand Down Expand Up @@ -4544,7 +4572,9 @@ void actPlayer(Entity* my)
}
}

if ( !command && !followerMenu.followerToCommand && followerMenu.recentEntity )
if ( !players[PLAYER_NUM]->usingCommand() && players[PLAYER_NUM]->bControlEnabled
&& !gamePaused
&& !followerMenu.followerToCommand && followerMenu.recentEntity )
{
auto& b = input.getBindings();
bool showNPCCommandsOnGamepad = false;
Expand Down Expand Up @@ -5185,8 +5215,8 @@ void actPlayer(Entity* my)
}
}

players[PLAYER_NUM]->bookGUI.closeBookGUI();

players[PLAYER_NUM]->closeAllGUIs(CloseGUIShootmode::CLOSEGUI_ENABLE_SHOOTMODE, CloseGUIIgnore::CLOSEGUI_CLOSE_ALL);
players[PLAYER_NUM]->bControlEnabled = false;
#ifdef SOUND
levelmusicplaying = true;
combatmusicplaying = false;
Expand All @@ -5213,7 +5243,7 @@ void actPlayer(Entity* my)
}
}

if ( multiplayer == SINGLE || !(svFlags & SV_FLAG_KEEPINVENTORY) )
if ( (multiplayer == SINGLE && !splitscreen) || !(svFlags & SV_FLAG_KEEPINVENTORY) )
{
for ( node = stats[PLAYER_NUM]->inventory.first; node != nullptr; node = nextnode )
{
Expand Down
48 changes: 36 additions & 12 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4067,17 +4067,27 @@ void ingameHud()
{
for ( int player = 0; player < MAXPLAYERS; ++player )
{
if ( players[player]->isLocalPlayerAlive() )
{
players[player]->bControlEnabled = true;
}
bool& bControlEnabled = players[player]->bControlEnabled;

Input& input = Input::inputs[player];

// toggle minimap
// player not needed to be alive
if ( players[player]->shootmode && !command && input.consumeBinaryToggle("Toggle Minimap") && !gamePaused ) {
if ( players[player]->shootmode && !players[player]->usingCommand() && input.consumeBinaryToggle("Toggle Minimap")
&& !gamePaused
&& bControlEnabled ) {
openMinimap(player);
}

// inventory interface
// player not needed to be alive
if ( players[player]->isLocalPlayer() && !command && input.consumeBinaryToggle("Character Status") && !gamePaused )
if ( players[player]->isLocalPlayer() && !players[player]->usingCommand() && input.consumeBinaryToggle("Character Status")
&& !gamePaused
&& bControlEnabled )
{
if ( players[player]->shootmode )
{
Expand All @@ -4091,7 +4101,9 @@ void ingameHud()

// spell list
// player not needed to be alive
if ( players[player]->isLocalPlayer() && !command && input.consumeBinaryToggle("Spell List") && !gamePaused ) //TODO: Move to function in interface or something?
if ( players[player]->isLocalPlayer() && !players[player]->usingCommand() && input.consumeBinaryToggle("Spell List")
&& !gamePaused
&& bControlEnabled ) //TODO: Move to function in interface or something?
{
if ( input.input("Spell List").isBindingUsingGamepad() )
{
Expand All @@ -4113,7 +4125,8 @@ void ingameHud()

// spellcasting
// player needs to be alive
if ( players[player]->isLocalPlayerAlive() && !gamePaused )
if ( players[player]->isLocalPlayerAlive()
&& !gamePaused )
{
const bool shootmode = players[player]->shootmode;
bool hasSpellbook = false;
Expand All @@ -4130,7 +4143,7 @@ void ingameHud()
{
allowCasting = true;
}
else if (!command && shootmode)
else if ( !players[player]->usingCommand() && shootmode && bControlEnabled )
{
if (tryHotbarQuickCast || input.binaryToggle("Cast Spell") || (hasSpellbook && input.binaryToggle("Block")) )
{
Expand Down Expand Up @@ -4233,7 +4246,9 @@ void ingameHud()
}
players[player]->magic.resetQuickCastSpell();

if ( !command && input.consumeBinaryToggle("Open Log") && !gamePaused )
if ( !players[player]->usingCommand() && input.consumeBinaryToggle("Open Log")
&& !gamePaused
&& bControlEnabled )
{
// TODO perhaps this should open the new chat log window.
}
Expand All @@ -4243,7 +4258,9 @@ void ingameHud()
&& players[player]->worldUI.bTooltipInView
&& players[player]->worldUI.tooltipsInRange.size() > 1);

if ( !command && input.consumeBinaryToggle("Cycle NPCs") && !gamePaused )
if ( !players[player]->usingCommand() && input.consumeBinaryToggle("Cycle NPCs")
&& !gamePaused
&& bControlEnabled )
{
if ( !worldUIBlocksFollowerCycle && players[player]->shootmode )
{
Expand All @@ -4263,8 +4280,10 @@ void ingameHud()

// commands - uses local clientnum only
Input& input = Input::inputs[clientnum];

if ( (input.binaryToggle("Chat") || input.binaryToggle("Console Command")) && !command && !gamePaused )
bool& bControlEnabled = players[clientnum]->bControlEnabled;
if ( (input.binaryToggle("Chat") || input.binaryToggle("Console Command")) && !command
&& !gamePaused
&& bControlEnabled )
{
cursorflash = ticks;
command = true;
Expand Down Expand Up @@ -4319,7 +4338,12 @@ void ingameHud()
chosen_command = NULL;
command = false;
}
if ( keystatus[SDL_SCANCODE_RETURN] ) // enter
if ( !players[commandPlayer]->bControlEnabled )
{
chosen_command = NULL;
command = false;
}
else if ( keystatus[SDL_SCANCODE_RETURN] ) // enter
{
input.consumeBinaryToggle("Chat");
input.consumeBinaryToggle("Console Command");
Expand Down Expand Up @@ -5957,12 +5981,12 @@ int main(int argc, char** argv)

for ( int i = 0; i < MAXPLAYERS; ++i )
{
if ( !players[i]->isLocalPlayer() && !gamePaused )
if ( !players[i]->isLocalPlayer() && !(gamePaused || players[i]->GUI.isGameoverActive()) )
{
continue;
}

if ( gamePaused )
if ( gamePaused || players[i]->GUI.isGameoverActive() )
{
if ( inputs.bPlayerUsingKeyboardControl(i) )
{
Expand Down
Loading

0 comments on commit edaf62c

Please sign in to comment.