Skip to content

Commit

Permalink
Reworked DOOM 3 Always Run. Now it can work also on SP (and while doi…
Browse files Browse the repository at this point in the history
…ng that it disables the stamina) (ref #91)
  • Loading branch information
MadDeCoDeR committed Dec 29, 2022
1 parent 3cdd931 commit d234e06
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 18 deletions.
2 changes: 2 additions & 0 deletions base/strings/english_bfa.lang
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
"#str_sapi" "Audio API"
"#str_swf_xaudio" "XAudio 2"
"#str_swf_openAL" "OpenAL-soft"
"#str_04102" "Always Run"
"#str_swf_only_MP" "Only MP"
// "#str_swf_custom_game" "Mod Name"
// "#str_swf_start_map" "First Map to load"
}
2 changes: 2 additions & 0 deletions base/strings/french_bfa.lang
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
"#str_sapi" "Audio API"
"#str_swf_xaudio" "XAudio 2"
"#str_swf_openAL" "OpenAL-soft"
"#str_04102" "Toujours exécuter"
"#str_swf_only_MP" "Seul MP"
// "#str_swf_custom_game" "Nom du mod"
// "#str_swf_start_map" "Première carte à charger"
}
2 changes: 2 additions & 0 deletions base/strings/german_bfa.lang
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
"#str_sapi" "Audio API"
"#str_swf_xaudio" "XAudio 2"
"#str_swf_openAL" "OpenAL-soft"
"#str_04102" "Immer ausführen"
"#str_swf_only_MP" "Nur MP"
// "#str_swf_custom_game" "Mod Name"
// "#str_swf_start_map" "Erste zu ladende Karte"
}
2 changes: 2 additions & 0 deletions base/strings/italian_bfa.lang
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
"#str_sapi" "Audio API"
"#str_swf_xaudio" "XAudio 2"
"#str_swf_openAL" "OpenAL-soft"
"#str_04102" "Corri sempre"
"#str_swf_only_MP" "Solo MP"
// "#str_swf_custom_game" "Nome mod"
// "#str_swf_start_map" "Prima mappa da caricare"
}
2 changes: 2 additions & 0 deletions base/strings/japanese_bfa.lang
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
"#str_sapi" "オーディオ API"
"#str_swf_xaudio" "XAudio 2"
"#str_swf_openAL" "OpenAL-soft"
"#str_04102" "常に実行"
"#str_swf_only_MP" "MPのみ"
// "#str_swf_custom_game" "Mod Name"
// "#str_swf_start_map" "最初にロードするマップ"
}
2 changes: 2 additions & 0 deletions base/strings/spanish_bfa.lang
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
"#str_sapi" "Audio API"
"#str_swf_xaudio" "XAudio 2"
"#str_swf_openAL" "OpenAL-soft"
"#str_04102" "Ejecutar siempre"
"#str_swf_only_MP" "Sólo MP"
// "#str_swf_custom_game" "Nombre del mod"
// "#str_swf_start_map" "Primer mapa para cargar"
}
12 changes: 11 additions & 1 deletion neo/d3xp/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ idCVar pm_clientAuthoritative_minSpeedSquared( "pm_clientAuthoritative_minSpeedS
//GK: Internal CVar in order to keep track on whenever the character is flipped or not
idCVar pm_flip("pm_flip", "0", CVAR_BOOL, "");
idCVar pm_smartHUD("pm_smartHUD", "0", CVAR_BOOL | CVAR_ARCHIVE | CVAR_GAME, "Enable Smart HUD functionality");
idCVar pm_alwaysRun("pm_alwaysRun", "0", CVAR_INTEGER | CVAR_GAME | CVAR_ROM, "Used to check if in_alwaysRun has changed value");

extern idCVar pm_classicPose;

Expand Down Expand Up @@ -1878,8 +1879,9 @@ void idPlayer::Init()
}

// disable stamina on hell levels
if( gameLocal.world && gameLocal.world->spawnArgs.GetBool( "no_stamina" ) )
if(( gameLocal.world && gameLocal.world->spawnArgs.GetBool( "no_stamina" ) ) || cvarSystem->GetCVarBool("in_alwaysRun"))
{
pm_staminaBackup.SetFloat(pm_stamina.GetFloat());
pm_stamina.SetFloat( 0.0f );
}

Expand Down Expand Up @@ -2881,6 +2883,7 @@ void idPlayer::Restore( idRestoreGame* savefile )

savefile->ReadFloat( set );
pm_stamina.SetFloat( set );
pm_staminaBackup.SetFloat(pm_stamina.GetFloat());

// create combat collision hull for exact collision detection
SetCombatModel();
Expand Down Expand Up @@ -3831,6 +3834,13 @@ void idPlayer::UpdateConditions()

AI_RUN = ( usercmd.buttons & BUTTON_RUN ) && ( ( !pm_stamina.GetFloat() ) || ( stamina > pm_staminathreshold.GetFloat() ) );
AI_DEAD = ( health <= 0 );

if (cvarSystem->GetCVarInteger("in_alwaysRun") != pm_alwaysRun.GetInteger()) {
pm_alwaysRun.SetInteger(cvarSystem->GetCVarInteger("in_alwaysRun"));
pm_stamina.SetFloat(cvarSystem->GetCVarInteger("in_alwaysRun") == 1 || (cvarSystem->GetCVarInteger("in_alwaysRun") == 2 && common->IsMultiplayer()) ? 0.0f : pm_staminaBackup.GetFloat());
stamina = pm_stamina.GetFloat();
}

}

/*
Expand Down
1 change: 1 addition & 0 deletions neo/d3xp/gamesys/SysCvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ idCVar pm_usecylinder( "pm_usecylinder", "0", CVAR_GAME | CVAR_NETWORKSYN
idCVar pm_minviewpitch( "pm_minviewpitch", "-89", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT, "amount player's view can look up (negative values are up)" );
idCVar pm_maxviewpitch( "pm_maxviewpitch", "89", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT, "amount player's view can look down" );
idCVar pm_stamina( "pm_stamina", "24", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT, "length of time player can run" );
idCVar pm_staminaBackup( "pm_staminaBackup", "24", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT, "backup for pm_stamina");
idCVar pm_staminathreshold( "pm_staminathreshold", "45", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT, "when stamina drops below this value, player gradually slows to a walk" );
idCVar pm_staminarate( "pm_staminarate", "0.75", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT, "rate that player regains stamina. divide pm_stamina by this value to determine how long it takes to fully recharge." );
idCVar pm_crouchheight( "pm_crouchheight", "38", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT, "height of player's bounding box while crouched" );
Expand Down
1 change: 1 addition & 0 deletions neo/d3xp/gamesys/SysCvar.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ extern idCVar pm_usecylinder;
extern idCVar pm_minviewpitch;
extern idCVar pm_maxviewpitch;
extern idCVar pm_stamina;
extern idCVar pm_staminaBackup;
extern idCVar pm_staminathreshold;
extern idCVar pm_staminarate;
extern idCVar pm_crouchheight;
Expand Down
5 changes: 3 additions & 2 deletions neo/d3xp/menus/MenuScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -1043,12 +1043,13 @@ class idMenuScreen_Shell_GameOptions : public idMenuScreen
virtual bool IsDataChanged() const;

// retrieves a particular field for reading or updating
virtual idSWFScriptVar GetField( const int fieldIndex ) const
virtual idSWFScriptVar GetField(const int fieldIndex) const;/*
{
return fields[ fieldIndex ];
}
}*/

virtual void AdjustField( const int fieldIndex, const int adjustAmount );
virtual int AdjustOption(int currentValue, const int values[], int numValues, int adjustment);

private:
idStaticList< idSWFScriptVar, MAX_GAME_FIELDS > fields;
Expand Down
7 changes: 5 additions & 2 deletions neo/d3xp/menus/MenuScreen_HUD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@ If you have questions concerning this license or the applicable additional terms
===========================================================================
*/
#pragma hdrstop

#include "precompiled.h"
#pragma hdrstop
#include "../Game_local.h"

//extern idCVar pm_stamina;

//extern idCVar flashlight_batteryDrainTimeMS;

extern idCVar in_alwaysRun;

/*
========================
idMenuScreen_HUD::Initialize
Expand Down Expand Up @@ -330,7 +333,7 @@ void idMenuScreen_HUDLocal::UpdateStamina( idPlayer* player )
if( stamSprite != NULL )
{

if( common->IsMultiplayer() )
if( common->IsMultiplayer() || in_alwaysRun.GetInteger() == 1)
{
stamSprite->SetVisible( false );
}
Expand Down
58 changes: 50 additions & 8 deletions neo/d3xp/menus/MenuScreen_Shell_GameOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void idMenuScreen_Shell_GameOptions::Initialize( idMenuHandler* data )
options->AddChild( control );

control = new( TAG_SWF ) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_TOGGLE );
control->SetOptionType( OPTION_SLIDER_TEXT );
control->SetLabel( "#str_04102" ); // Always Run
control->SetDataSource( &systemData, idMenuDataSource_GameSettings::GAME_FIELD_ALWAYS_SPRINT );
control->SetupEvents( DEFAULT_REPEAT_TIME, options->GetChildren().Num() );
Expand Down Expand Up @@ -339,7 +339,7 @@ void idMenuScreen_Shell_GameOptions::idMenuDataSource_GameSettings::LoadData()
fields[ GAME_FIELD_AUTO_SWITCH ].SetBool( ui_autoSwitch.GetBool() );
fields[ GAME_FIELD_AUTO_RELOAD ].SetBool( ui_autoReload.GetBool() );
fields[ GAME_FIELD_AIM_ASSIST ].SetBool(game->GetCVarBool("aa_targetAimAssistEnable") );
fields[ GAME_FIELD_ALWAYS_SPRINT ].SetBool( in_alwaysRun.GetBool() );
fields[ GAME_FIELD_ALWAYS_SPRINT ].SetInteger( in_alwaysRun.GetInteger() );
fields[ GAME_FIELD_FLASHLIGHT_SHADOWS ].SetBool(game->GetCVarBool("g_weaponShadows") );
fields[ GAME_FIELD_MUZZLE_FLASHES ].SetBool(game->GetCVarBool("g_muzzleFlash") );
originalFields = fields;
Expand All @@ -360,7 +360,7 @@ void idMenuScreen_Shell_GameOptions::idMenuDataSource_GameSettings::CommitData()
ui_autoSwitch.SetBool( fields[ GAME_FIELD_AUTO_SWITCH ].ToBool() );
ui_autoReload.SetBool( fields[ GAME_FIELD_AUTO_RELOAD ].ToBool() );
game->SetCVarBool("aa_targetAimAssistEnable", fields[ GAME_FIELD_AIM_ASSIST ].ToBool() );
in_alwaysRun.SetBool( fields[ GAME_FIELD_ALWAYS_SPRINT ].ToBool() );
in_alwaysRun.SetInteger( fields[ GAME_FIELD_ALWAYS_SPRINT ].ToInteger() );
game->SetCVarBool("g_weaponShadows", fields[ GAME_FIELD_FLASHLIGHT_SHADOWS ].ToBool() );
game->SetCVarBool("g_muzzleFlash", fields[ GAME_FIELD_MUZZLE_FLASHES ].ToBool() );

Expand All @@ -377,13 +377,55 @@ idMenuScreen_Shell_GameOptions::idMenuDataSource_AudioSettings::AdjustField
*/
void idMenuScreen_Shell_GameOptions::idMenuDataSource_GameSettings::AdjustField( const int fieldIndex, const int adjustAmount )
{
if( fieldIndex == GAME_FIELD_FOV )
const int sprintValues[3] = { 0, 1, 2 };
switch (fieldIndex) {
case GAME_FIELD_FOV:
fields[fieldIndex].SetInteger(idMath::ClampInt(MIN_FOV, MAX_FOV, fields[fieldIndex].ToInteger() + adjustAmount * 5));
break;
case GAME_FIELD_ALWAYS_SPRINT:
fields[fieldIndex].SetInteger(AdjustOption(fields[fieldIndex].ToInteger(), sprintValues, 3, adjustAmount));
break;
default:
fields[fieldIndex].SetBool(!fields[fieldIndex].ToBool());
}
}

int idMenuScreen_Shell_GameOptions::idMenuDataSource_GameSettings::AdjustOption(int currentValue, const int values[], int numValues, int adjustment)
{
int index = 0;
for (int i = 0; i < numValues; i++)
{
fields[ fieldIndex ].SetInteger( idMath::ClampInt( MIN_FOV, MAX_FOV, fields[ fieldIndex ].ToInteger() + adjustAmount * 5 ) );
if (currentValue == values[i])
{
index = i;
break;
}
}
else
index += adjustment;
while (index < 0)
{
fields[ fieldIndex ].SetBool( !fields[ fieldIndex ].ToBool() );
index += numValues;
}
index %= numValues;
return values[index];
}

/*
========================
idMenuScreen_Shell_GameOptions::idMenuDataSource_AudioSettings::AdjustField
========================
*/
idSWFScriptVar idMenuScreen_Shell_GameOptions::idMenuDataSource_GameSettings::GetField(const int fieldIndex) const
{
idList<idStr> sprintValues {
idStr("#str_swf_disabled"),
idStr("#str_swf_enabled"),
idStr("#str_swf_only_MP")
};
if (fieldIndex == GAME_FIELD_ALWAYS_SPRINT) {
return sprintValues[fields[fieldIndex].ToInteger()].c_str();
} else {
return fields[fieldIndex];
}
}

Expand Down Expand Up @@ -420,7 +462,7 @@ bool idMenuScreen_Shell_GameOptions::idMenuDataSource_GameSettings::IsDataChange
return true;
}

if( fields[ GAME_FIELD_ALWAYS_SPRINT ].ToBool() != originalFields[ GAME_FIELD_ALWAYS_SPRINT ].ToBool() )
if( fields[ GAME_FIELD_ALWAYS_SPRINT ].ToInteger() != originalFields[ GAME_FIELD_ALWAYS_SPRINT ].ToInteger() )
{
return true;
}
Expand Down
10 changes: 5 additions & 5 deletions neo/framework/UsercmdGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ idCVar joy_dampenLook( "joy_dampenLook", "1", CVAR_BOOL | CVAR_ARCHIVE, "Do not
idCVar joy_deltaPerMSLook( "joy_deltaPerMSLook", "0.003", CVAR_FLOAT | CVAR_ARCHIVE, "Max amount to be added on look per MS" );

idCVar in_mouseSpeed( "in_mouseSpeed", "1", CVAR_ARCHIVE | CVAR_FLOAT, "speed at which the mouse moves", 0.25f, 4.0f );
idCVar in_alwaysRun( "in_alwaysRun", "1", CVAR_SYSTEM | CVAR_ARCHIVE | CVAR_BOOL, "always run (reverse _speed button) - only in MP" );
idCVar in_alwaysRun( "in_alwaysRun", "2", CVAR_SYSTEM | CVAR_ARCHIVE | CVAR_INTEGER, "always run (reverse _speed button) 1- Both SP And MP 2- only in MP", 0, 2 );
//GK: in_alwaysRunCl
idCVar in_alwaysRunCl("in_alwaysRunCl", "0", CVAR_SYSTEM | CVAR_ARCHIVE | CVAR_BOOL, "always run (reverse _speed button) - only in Classic");
//GK End
Expand Down Expand Up @@ -451,7 +451,7 @@ void idUsercmdGenLocal::AdjustAngles()
{
float speed = MS2SEC( 16 );

if( toggled_run.on || ( in_alwaysRun.GetBool() && common->IsMultiplayer() ) )
if( toggled_run.on || in_alwaysRun.GetInteger() == 1 || (in_alwaysRun.GetInteger() == 2 && common->IsMultiplayer() ) )
{
speed *= in_angleSpeedKey.GetFloat();
}
Expand Down Expand Up @@ -1108,7 +1108,7 @@ void idUsercmdGenLocal::CmdButtons()
}

// check the run button
if( toggled_run.on || ( in_alwaysRun.GetBool() && common->IsMultiplayer() ) )
if( toggled_run.on || in_alwaysRun.GetInteger() == 1 || (in_alwaysRun.GetInteger() == 2 && common->IsMultiplayer()))
{
cmd.buttons |= BUTTON_RUN;
}
Expand Down Expand Up @@ -1153,7 +1153,7 @@ void idUsercmdGenLocal::InitCurrent()
memset( &cmd, 0, sizeof( cmd ) );
cmd.impulseSequence = impulseSequence;
cmd.impulse = impulse;
cmd.buttons |= ( in_alwaysRun.GetBool() && common->IsMultiplayer() ) ? BUTTON_RUN : 0;
cmd.buttons |= ( in_alwaysRun.GetInteger() == 1 || (in_alwaysRun.GetInteger() == 2 && common->IsMultiplayer())) ? BUTTON_RUN : 0;
}

/*
Expand Down Expand Up @@ -1227,7 +1227,7 @@ void idUsercmdGenLocal::MakeCurrent()

// update toggled key states
toggled_crouch.SetKeyState(ButtonState(UB_MOVEDOWN), in_toggleCrouch.GetBool());
toggled_run.SetKeyState(ButtonState(UB_SPEED), in_toggleRun.GetBool() && common->IsMultiplayer());
toggled_run.SetKeyState(ButtonState(UB_SPEED), in_toggleRun.GetBool());
toggled_zoom.SetKeyState(ButtonState(UB_ZOOM), in_toggleZoom.GetBool());

// get basic movement from mouse
Expand Down

0 comments on commit d234e06

Please sign in to comment.