Replaced flashlight shadows option with classic flashlight

This commit is contained in:
Robert Beckebans 2024-06-27 23:12:37 +02:00
parent d147b7f038
commit ce68905287
5 changed files with 45 additions and 12 deletions

View file

@ -1990,6 +1990,7 @@ void idPlayer::Init()
achievementManager.Init( this );
flashlightBattery = flashlight_batteryDrainTimeMS.GetInteger(); // fully charged
flashlightReset = false;
aimAssist.Init( this );
@ -5987,6 +5988,33 @@ void idPlayer::UpdateFlashlight()
return;
}
if( !flashlightReset )
{
flashlight->Clear();
if( UsesClassicFlashlight() && !gameLocal.world->spawnArgs.GetBool( "no_Weapons" ) )
{
GiveItem( "weapon_flashlight" );
}
flashlightReset = true;
}
if( ng_classicFlashlight.IsModified() && !fileSystem->IsDoom2004() && !gameLocal.world->spawnArgs.GetBool( "no_Weapons" ) )
{
flashlight->Clear();
if( UsesClassicFlashlight() )
{
// we might have missed the opportunity at level load
GiveItem( "weapon_flashlight" );
}
ng_classicFlashlight.ClearModified();
}
// Don't update the flashlight if dead in MP.
// Otherwise you can see a floating flashlight worldmodel near player's skeletons.
if( common->IsMultiplayer() )
@ -6072,6 +6100,7 @@ void idPlayer::UpdateFlashlight()
// adjust position / orientation of flashlight
idAnimatedEntity* worldModel = flashlight.GetEntity()->GetWorldModel();
if( !UsesClassicFlashlight() )
{
worldModel->BindToJoint( this, "Chest", true );
@ -6102,6 +6131,7 @@ void idPlayer::UpdateFlashlight()
//GK: This time make sure there is NO second flashlight model rendered
worldModel->Hide();
}
if( flashlight.GetEntity()->lightOn )
{
if( ( flashlightBattery < flashlight_batteryChargeTimeMS.GetInteger() / 2 ) && ( gameLocal.random.RandomFloat() < flashlight_batteryFlickerPercent.GetFloat() ) )
@ -6116,7 +6146,7 @@ void idPlayer::UpdateFlashlight()
flashlight.GetEntity()->PresentWeapon( true );
if( !UsesClassicFlashlight() ) //GK: Not legacy no care
if( !UsesClassicFlashlight() )
{
if( gameLocal.world->spawnArgs.GetBool( "no_Weapons" ) || gameLocal.inCinematic || spectating || fl.hidden )
{
@ -7733,7 +7763,7 @@ void idPlayer::PerformImpulse( int impulse )
if( flashlight.IsValid() )
{
// GK: support old flash light
if( flashlight.GetEntity()->lightOn && UsesClassicFlashlight() && currentWeapon != weapon_flashlight )
if( UsesClassicFlashlight() && currentWeapon != weapon_flashlight && flashlight.GetEntity()->lightOn )
{
flashlight.GetEntity()->lightOn = false;
}
@ -7751,7 +7781,8 @@ void idPlayer::PerformImpulse( int impulse )
{
if( UsesClassicFlashlight() )
{
SelectWeapon( weapon_flashlight, false );
// RB: force flash light selection even if it is not in the inventory
SelectWeapon( weapon_flashlight, true );
}
FlashlightOn();
}

View file

@ -337,6 +337,8 @@ public:
idInventory inventory;
idTarget_SetPrimaryObjective* primaryObjective;
// RB: hack to reinit flash light when switching between classic mode
bool flashlightReset;
int flashlightBattery;
idEntityPtr<idWeapon> flashlight;

View file

@ -138,7 +138,7 @@ idCVar cg_projectile_clientAuthoritative_maxCatchup( "cg_projectile_clientAuthor
idCVar g_useWeaponDepthHack( "g_useWeaponDepthHack", "1", CVAR_BOOL, "Crunch z depth on weapons" );
idCVar g_weaponShadows( "g_weaponShadows", "0", CVAR_BOOL | CVAR_ARCHIVE, "Cast shadows from weapons" );
idCVar g_weaponShadows( "g_weaponShadows", "1", CVAR_BOOL | CVAR_ARCHIVE, "UNUSED: Cast shadows from weapons" );
extern idCVar cg_predictedSpawn_debug;
@ -1548,7 +1548,7 @@ void idWeapon::UpdateFlashPosition()
// be at least 8 units away from a solid
muzzleFlash.origin = tr.endpos - playerViewAxis[0] * 8;
muzzleFlash.noShadows = !g_weaponShadows.GetBool();
muzzleFlash.noShadows = false; //!g_weaponShadows.GetBool();
// put the world muzzle flash on the end of the joint, no matter what
GetGlobalJointTransform( false, flashJointWorld, worldMuzzleFlash.origin, worldMuzzleFlash.axis );

View file

@ -1018,7 +1018,7 @@ public:
GAME_FIELD_AUTO_RELOAD,
GAME_FIELD_AIM_ASSIST,
GAME_FIELD_ALWAYS_SPRINT,
GAME_FIELD_FLASHLIGHT_SHADOWS,
GAME_FIELD_CLASSIC_FLASHLIGHT,
GAME_FIELD_MUZZLE_FLASHES,
MAX_GAME_FIELDS
};

View file

@ -120,8 +120,8 @@ void idMenuScreen_Shell_GameOptions::Initialize( idMenuHandler* data )
control = new( TAG_SWF ) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_TOGGLE );
control->SetLabel( "#str_swf_flashlight_shadows" );
control->SetDataSource( &systemData, idMenuDataSource_GameSettings::GAME_FIELD_FLASHLIGHT_SHADOWS );
control->SetLabel( "Classic Flashlight" );
control->SetDataSource( &systemData, idMenuDataSource_GameSettings::GAME_FIELD_CLASSIC_FLASHLIGHT );
control->SetupEvents( DEFAULT_REPEAT_TIME, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, options->GetChildren().Num() );
options->AddChild( control );
@ -301,7 +301,7 @@ extern idCVar ui_autoReload;
extern idCVar aa_targetAimAssistEnable;
extern idCVar in_alwaysRun;
extern idCVar g_checkpoints;
extern idCVar g_weaponShadows;
extern idCVar ng_classicFlashlight;
extern idCVar g_muzzleFlash;
/*
@ -328,7 +328,7 @@ void idMenuScreen_Shell_GameOptions::idMenuDataSource_GameSettings::LoadData()
fields[ GAME_FIELD_AUTO_RELOAD ].SetBool( ui_autoReload.GetBool() );
fields[ GAME_FIELD_AIM_ASSIST ].SetBool( aa_targetAimAssistEnable.GetBool() );
fields[ GAME_FIELD_ALWAYS_SPRINT ].SetBool( in_alwaysRun.GetBool() );
fields[ GAME_FIELD_FLASHLIGHT_SHADOWS ].SetBool( g_weaponShadows.GetBool() );
fields[ GAME_FIELD_CLASSIC_FLASHLIGHT ].SetBool( ng_classicFlashlight.GetBool() );
fields[ GAME_FIELD_MUZZLE_FLASHES ].SetBool( g_muzzleFlash.GetBool() );
originalFields = fields;
}
@ -349,7 +349,7 @@ void idMenuScreen_Shell_GameOptions::idMenuDataSource_GameSettings::CommitData()
ui_autoReload.SetBool( fields[ GAME_FIELD_AUTO_RELOAD ].ToBool() );
aa_targetAimAssistEnable.SetBool( fields[ GAME_FIELD_AIM_ASSIST ].ToBool() );
in_alwaysRun.SetBool( fields[ GAME_FIELD_ALWAYS_SPRINT ].ToBool() );
g_weaponShadows.SetBool( fields[ GAME_FIELD_FLASHLIGHT_SHADOWS ].ToBool() );
ng_classicFlashlight.SetBool( fields[ GAME_FIELD_CLASSIC_FLASHLIGHT ].ToBool() );
g_muzzleFlash.SetBool( fields[ GAME_FIELD_MUZZLE_FLASHES ].ToBool() );
cvarSystem->SetModifiedFlags( CVAR_ARCHIVE );
@ -413,7 +413,7 @@ bool idMenuScreen_Shell_GameOptions::idMenuDataSource_GameSettings::IsDataChange
return true;
}
if( fields[ GAME_FIELD_FLASHLIGHT_SHADOWS ].ToBool() != originalFields[ GAME_FIELD_FLASHLIGHT_SHADOWS ].ToBool() )
if( fields[ GAME_FIELD_CLASSIC_FLASHLIGHT ].ToBool() != originalFields[ GAME_FIELD_CLASSIC_FLASHLIGHT ].ToBool() )
{
return true;
}