From e4f953b523f5e260736b43a5f71f037acdc28dd2 Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Fri, 21 Jun 2024 02:14:08 +0200 Subject: [PATCH] Sikkmod v1.1 (game/ only) --- game/AFEntity.cpp | 16 +- game/AFEntity.h | 5 + game/Actor.cpp | 10 +- game/Entity.cpp | 8 +- game/Fx.cpp | 6 + game/Game_local.cpp | 355 ++++++- game/Game_local.h | 48 + game/Grab.cpp | 216 +++++ game/Grab.h | 43 + game/Item.cpp | 266 +++++- game/Item.h | 34 + game/Light.cpp | 32 +- game/Light.h | 6 +- game/Misc.cpp | 65 ++ game/Misc.h | 21 + game/Moveable.cpp | 3 + game/Player.cpp | 1170 +++++++++++++++++++++-- game/Player.h | 80 +- game/PlayerView.cpp | 1798 ++++++++++++++++++++++++++++++----- game/PlayerView.h | 147 ++- game/Projectile.cpp | 23 +- game/Pvs.cpp | 30 +- game/Pvs.h | 2 + game/SmokeParticles.cpp | 2 + game/Weapon.cpp | 35 +- game/Weapon.h | 20 +- game/ai/AAS.cpp | 14 + game/ai/AAS.h | 3 + game/ai/AAS_local.h | 2 + game/ai/AI.cpp | 56 +- game/ai/AI.h | 7 + game/gamesys/SysCvar.cpp | 239 ++++- game/gamesys/SysCvar.h | 215 +++++ game/physics/Force_Grab.cpp | 153 +++ game/physics/Force_Grab.h | 54 ++ 35 files changed, 4794 insertions(+), 390 deletions(-) create mode 100644 game/Grab.cpp create mode 100644 game/Grab.h create mode 100644 game/physics/Force_Grab.cpp create mode 100644 game/physics/Force_Grab.h diff --git a/game/AFEntity.cpp b/game/AFEntity.cpp index 686263f..532e494 100644 --- a/game/AFEntity.cpp +++ b/game/AFEntity.cpp @@ -965,6 +965,7 @@ idAFEntity_Gibbable::idAFEntity_Gibbable( void ) { skeletonModel = NULL; skeletonModelDefHandle = -1; gibbed = false; + searchable = false; // sikk - Searchable Corpses } /* @@ -987,6 +988,8 @@ idAFEntity_Gibbable::Save void idAFEntity_Gibbable::Save( idSaveGame *savefile ) const { savefile->WriteBool( gibbed ); savefile->WriteBool( combatModel != NULL ); + + savefile->WriteBool( searchable ); // sikk - Searchable Corpses } /* @@ -1000,6 +1003,8 @@ void idAFEntity_Gibbable::Restore( idRestoreGame *savefile ) { savefile->ReadBool( gibbed ); savefile->ReadBool( hasCombatModel ); + savefile->ReadBool( searchable ); // sikk - Searchable Corpses + InitSkeletonModel(); if ( hasCombatModel ) { @@ -1017,6 +1022,8 @@ void idAFEntity_Gibbable::Spawn( void ) { InitSkeletonModel(); gibbed = false; + + spawnArgs.GetBool( "searchable", "0", searchable ); // sikk - Searchable Corpses } /* @@ -1173,14 +1180,19 @@ void idAFEntity_Gibbable::Gib( const idVec3 &dir, const char *damageDefName ) { UnlinkCombat(); if ( g_bloodEffects.GetBool() ) { - if ( gameLocal.time > gameLocal.GetGibTime() ) { + // sikk - Since "nextGibTime" is a member of idGameLocal and not idAFEntity||idAFEntity_Gibbable + // the folloing if statement is only true once per damage event instead of per entity being damaged. + // This is why only one entity will get gibbed while the rest just disappear after a few seconds. + // I commented this out instead of moving the variable to the proper class because it's easier and + // the delay is only 200ms so the difference should be unnoticable +// if ( gameLocal.time > gameLocal.GetGibTime() ) { gameLocal.SetGibTime( gameLocal.time + GIB_DELAY ); SpawnGibs( dir, damageDefName ); renderEntity.noShadow = true; renderEntity.shaderParms[ SHADERPARM_TIME_OF_DEATH ] = gameLocal.time * 0.001f; StartSound( "snd_gibbed", SND_CHANNEL_ANY, 0, false, NULL ); gibbed = true; - } +// } } else { gibbed = true; } diff --git a/game/AFEntity.h b/game/AFEntity.h index bc7dee4..ae9e5ae 100644 --- a/game/AFEntity.h +++ b/game/AFEntity.h @@ -228,6 +228,11 @@ public: virtual void Damage( idEntity *inflictor, idEntity *attacker, const idVec3 &dir, const char *damageDefName, const float damageScale, const int location ); virtual void SpawnGibs( const idVec3 &dir, const char *damageDefName ); +// sikk---> Searchable Corpses + bool searchable; + bool IsGibbed( void ) { return gibbed; }; +// <---sikk + protected: idRenderModel * skeletonModel; int skeletonModelDefHandle; diff --git a/game/Actor.cpp b/game/Actor.cpp index 15061a2..8a5c441 100644 --- a/game/Actor.cpp +++ b/game/Actor.cpp @@ -625,7 +625,7 @@ void idActor::Spawn( void ) { } } - finalBoss = spawnArgs.GetBool( "finalBoss" ); + finalBoss = g_cyberdemonDamageType.GetBool() ? false : spawnArgs.GetBool( "finalBoss" ); // sikk - Cyberdemon Damage Type FinishSetup(); } @@ -2179,7 +2179,13 @@ void idActor::Damage( idEntity *inflictor, idEntity *attacker, const idVec3 &dir gameLocal.Error( "Unknown damageDef '%s'", damageDefName ); } - int damage = damageDef->GetInt( "damage" ) * damageScale; +// sikk---> Ammo Management: Custom Ammo Damage + int damage; + if ( g_ammoDamageType.GetBool() && damageDef->GetInt( "custom_damage" ) ) + damage = damageDef->GetInt( "custom_damage" ) * damageScale; + else + damage = damageDef->GetInt( "damage" ) * damageScale; +// <---sikk damage = GetDamageForLocation( damage, location ); // inform the attacker that they hit someone diff --git a/game/Entity.cpp b/game/Entity.cpp index 1983a4c..af954f9 100644 --- a/game/Entity.cpp +++ b/game/Entity.cpp @@ -2998,7 +2998,13 @@ void idEntity::Damage( idEntity *inflictor, idEntity *attacker, const idVec3 &di gameLocal.Error( "Unknown damageDef '%s'\n", damageDefName ); } - int damage = damageDef->GetInt( "damage" ); +// sikk---> Ammo Management: Custom Ammo Damage + int damage; + if ( g_ammoDamageType.GetBool() && damageDef->GetInt( "custom_damage" ) ) + damage = damageDef->GetInt( "custom_damage" ); + else + damage = damageDef->GetInt( "damage" ); +// <---sikk // inform the attacker that they hit someone attacker->DamageFeedback( this, inflictor, damage ); diff --git a/game/Fx.cpp b/game/Fx.cpp index 549f9e1..5476cc6 100644 --- a/game/Fx.cpp +++ b/game/Fx.cpp @@ -509,6 +509,9 @@ void idEntityFx::Run( int time ) { useAction->renderEntity.shaderParms[ SHADERPARM_TIMEOFFSET ] = -MS2SEC( time ); useAction->renderEntity.shaderParms[3] = 1.0f; useAction->renderEntity.shaderParms[5] = 0.0f; + + useAction->renderEntity.suppressSurfaceInViewID = -8; // sikk - depth render + if ( useAction->renderEntity.hModel ) { useAction->renderEntity.bounds = useAction->renderEntity.hModel->Bounds( &useAction->renderEntity ); } @@ -593,6 +596,9 @@ void idEntityFx::Spawn( void ) { PostEventMS( &EV_Activate, 0, this ); } } + + // We don't want particles in depth render. + renderEntity.suppressSurfaceInViewID = -8; // sikk - Depth Render } /* diff --git a/game/Game_local.cpp b/game/Game_local.cpp index a2cefa6..0d5347d 100644 --- a/game/Game_local.cpp +++ b/game/Game_local.cpp @@ -254,6 +254,20 @@ void idGameLocal::Clear( void ) { savedEventQueue.Init(); memset( lagometer, 0, sizeof( lagometer ) ); + +// sikk---> Portal Sky Box + portalSkyEnt = NULL; + portalSkyActive = false; +// <---sikk + + currentLights.Clear(); // sikk - Soft Shadows PostProcess + +// sikk---> Random Encounters System + randomEnemyListNum = 0; + randomEnemyTime = 0; + randomEnemyTally = 0; + randomEnemyList.Clear(); +// <---sikk } /* @@ -576,10 +590,22 @@ void idGameLocal::SaveGame( idFile *f ) { savegame.WriteVec3( gravity ); // gamestate - savegame.WriteBool( influenceActive ); savegame.WriteInt( nextGibTime ); +// sikk---> Portal Sky Box + portalSkyEnt.Save( &savegame ); + savegame.WriteBool( portalSkyActive ); +// <---sikk + +// sikk---> Random Encounters System + savegame.WriteInt( randomEnemyTally ); + savegame.WriteInt( randomEnemyList.Num() ); + for( i = 0; i < randomEnemyList.Num(); i++ ) { + savegame.WriteInt( randomEnemyList[ i ] ); + } +// <---sikk + // spawnSpots // initialSpots // currentInitialSpot @@ -938,6 +964,20 @@ void idGameLocal::LoadMap( const char *mapName, int randseed ) { playerPVS.i = -1; playerConnectedAreas.i = -1; + currentLights.Clear(); // sikk - Soft Shadows PostProcess + +// sikk---> Portal Sky Box + portalSkyEnt = NULL; + portalSkyActive = false; +// <---sikk + +// sikk---> Random Encounters System + randomEnemyListNum = 0; + randomEnemyTime = 0; + randomEnemyTally = 0; + //randomEnemyList.Clear(); +// <---sikk + // load navigation system for all the different monster sizes for( i = 0; i < aasNames.Num(); i++ ) { aasList[ i ]->Init( idStr( mapFileName ).SetFileExtension( aasNames[ i ] ).c_str(), mapFile->GetGeometryCRC() ); @@ -1430,6 +1470,22 @@ bool idGameLocal::InitFromSaveGame( const char *mapName, idRenderWorld *renderWo savegame.ReadBool( influenceActive ); savegame.ReadInt( nextGibTime ); +// sikk---> Portal Sky Box + portalSkyEnt.Restore( &savegame ); + savegame.ReadBool( portalSkyActive ); +// <---sikk + +// sikk---> Random Encounters System + savegame.ReadInt( randomEnemyTally ); + savegame.ReadInt( randomEnemyListNum ); + randomEnemyList.Clear(); + for( i = 0; i < randomEnemyListNum; i++ ) { + int j; + savegame.ReadInt( j ); + randomEnemyList.Append( j ); + } +// <---sikk + // spawnSpots // initialSpots // currentInitialSpot @@ -2040,6 +2096,26 @@ void idGameLocal::SetupPlayerPVS( void ) { pvs.FreeCurrentPVS( otherPVS ); playerConnectedAreas = newPVS; } + +// sikk---> Portal Sky Box + // if portalSky is preset, then merge into pvs so we get rotating brushes, etc + if ( portalSkyEnt.GetEntity() ) { + idEntity *skyEnt = portalSkyEnt.GetEntity(); + + otherPVS = pvs.SetupCurrentPVS( skyEnt->GetPVSAreas(), skyEnt->GetNumPVSAreas() ); + newPVS = pvs.MergeCurrentPVS( playerPVS, otherPVS ); + pvs.FreeCurrentPVS( playerPVS ); + pvs.FreeCurrentPVS( otherPVS ); + playerPVS = newPVS; + + otherPVS = pvs.SetupCurrentPVS( skyEnt->GetPVSAreas(), skyEnt->GetNumPVSAreas() ); + newPVS = pvs.MergeCurrentPVS( playerConnectedAreas, otherPVS ); + pvs.FreeCurrentPVS( playerConnectedAreas ); + pvs.FreeCurrentPVS( otherPVS ); + playerConnectedAreas = newPVS; + } +// <---sikk + } } @@ -2247,7 +2323,7 @@ gameReturn_t idGameLocal::RunFrame( const usercmd_t *clientCmds ) { gameRenderWorld->SetRenderView( view ); } } - + // clear any debug lines from a previous frame gameRenderWorld->DebugClearLines( time ); @@ -3171,10 +3247,24 @@ bool idGameLocal::InhibitEntitySpawn( idDict &spawnArgs ) { } const char *name; - if ( g_skill.GetInteger() == 3 ) { + if ( g_skill.GetInteger() == 3 || g_healthManagementType.GetInteger() == 2 ) { // sikk - Health Management System (Health Regen) - inhibit medkits when using health regen name = spawnArgs.GetString( "classname" ); if ( idStr::Icmp( name, "item_medkit" ) == 0 || idStr::Icmp( name, "item_medkit_small" ) == 0 ) { result = true; + +// sikk---> Health Management System (Health Regen) + // if medkit has a target, replace it with an adrenaline - This should be done in Nightmare difficulty as well + if ( spawnArgs.GetString( "target" ) != "" ) { + idEntity *ent; + idDict args; + args.Set( "classname", "powerup_adrenaline" ); +// args.Set( "name", spawnArgs.GetString( "name" ) ); + args.Set( "target", spawnArgs.GetString( "target" ) ); + args.Set( "origin", spawnArgs.GetString( "origin" ) ); + args.Set( "rotation", spawnArgs.GetString( "rotation" ) ); + gameLocal.SpawnEntityDef( args, &ent ); + } +// <---sikk } } @@ -3609,6 +3699,13 @@ void idGameLocal::RadiusDamage( const idVec3 &origin, idEntity *inflictor, idEnt radius = 1; } +// sikk---> Explosion FX PostProcess + explosionOrigin = origin; + explosionRadius = radius; + explosionDamage = damage; + explosionTime = time + g_explosionFXTime.GetInteger() * 1000; +// <---sikk + bounds = idBounds( origin ).Expand( radius ); // get all entities touching the bounds @@ -4409,3 +4506,255 @@ idGameLocal::GetMapLoadingGUI =============== */ void idGameLocal::GetMapLoadingGUI( char gui[ MAX_STRING_CHARS ] ) { } + + +// sikk---> Random Encounters System +/* +=============== +idGameLocal::SpawnRandomEnemy +=============== +*/ +bool idGameLocal::SpawnRandomEnemy() +{ + if ( !g_useRandomEncounters.GetBool() ) + return false; + + if ( !randomEnemyList.Num() ) + return false; + + if ( randomEnemyTally >= g_randomEncountersMaxSpawns.GetInteger() ) + return false; + + idStr mapscript = world->spawnArgs.GetString( "call" ); + // we don't want random spawns in first or last level + if ( mapscript == "map_hellhole::main" || mapscript == "map_marscity1::main" ) + return false; + + + idAAS *pAAS48 = gameLocal.GetAAS( "aas48" ); + idAAS *pAAS96 = gameLocal.GetAAS( "aas96" ); + idAAS *pAASMan = gameLocal.GetAAS( "aas_mancubus" ); + + if ( pAAS48 ) { + idEntity *ent; + idDict args; + idVec3 origin; + idVec3 playerPos, enemyPos; + int playerAreaNum, enemyAreaNum; + aasPath_t aaspath; + + float randFloat = gameLocal.random.RandomFloat(); + int randNum = gameLocal.random.RandomInt( randomEnemyList.Num() ); + + idStr defName = GetEnemyNameFromNum( randomEnemyList[ randNum ] ); + if ( defName == "monster_zombie_maint" ) + defName += ( 0.5f < randFloat ) ? "" : "2"; + int num = GetEnemyNumFromName( defName ); + if ( !num || defName == "" ) + return false; + + // we only want demons or monster_zombie_boney in Hell + if ( mapscript == "map_hell1::main" && ( num > 1 && num < 31 ) ) + return false; + + if ( num >= 39 && pAAS96 ) { + if ( num == 41 && pAASMan ) { + enemyAreaNum = randFloat * pAASMan->GetNumAreas( 3 ); + origin = pAASMan->AreaCenter( enemyAreaNum ) + idVec3( 0.0f, 0.0f, 1.0f ); + } else { + enemyAreaNum = randFloat * pAAS96->GetNumAreas( 1 ); + origin = pAAS96->AreaCenter( enemyAreaNum ) + idVec3( 0.0f, 0.0f, 1.0f ); + } + } else if ( num < 39 && pAAS48 ) { + enemyAreaNum = randFloat * pAAS48->GetNumAreas( 0 ); + origin = pAAS48->AreaCenter( enemyAreaNum ) + idVec3( 0.0f, 0.0f, 1.0f ); + if ( num < 31 ) { + trace_t trace; + idVec3 start = GetLocalPlayer()->GetEyePosition(); + idVec3 end = origin + idVec3( 0.0f, 0.0f, 64.0f ); + clip.TracePoint( trace, start, end, MASK_OPAQUE, NULL ); + + idVec3 viewVector = GetLocalPlayer()->viewAngles.ToForward(); + idVec3 dir = end - start; + dir.Normalize(); + float cos = viewVector * dir; + float fov = idMath::Cos( g_fov.GetFloat() * 0.5f ); + + // for enemies that don't teleport, if we can "see" it spawn, don't spawn + if ( trace.fraction >= 1.0f && cos >= fov ) + return false; + } + } else { + return false; + } + + trace_t t; + idBounds b = idBounds( idVec3( -32.0f, -32.0f, 0.0f ), idVec3( 32.0f, 32.0f, 63.0f ) ); + if ( clip.TraceBounds( t, origin, origin + idVec3( 0.0f, 0.0f, 1.0f ), b, MASK_ALL, NULL ) ) + return false; + + args.Set( "classname", defName ); + args.SetInt( "isRandom", 1 ); + args.SetVector( "origin", origin ); + args.SetInt( "angle", gameLocal.random.RandomInt( 359 ) ); + // teleport in if it's a demon + if ( num >= 31 ) + args.Set( "teleport", "1" ); + // use Hell skin if we're in Hell + if ( mapscript == "map_hell1::main" && ( num == 1 || num == 31 || num == 41 ) ) { + args.Set( "skin", GetHellSkin( num ) ); + } + + SpawnEntityDef( args, &ent ); + ent->Signal( SIG_TRIGGER ); + ent->ProcessEvent( &EV_Activate, GetLocalPlayer() ); + program.ReturnEntity( ent ); + args.Clear(); + + return true; + } + + return false; +} + +/* +=============== +idGameLocal::GetEnemyNumFromName +=============== +*/ +int idGameLocal::GetEnemyNumFromName( idStr name ) +{ + int num = 0; + + // Zombies + if ( name == "monster_zombie_boney" ) num = 1; + else if ( name == "monster_zombie_bernie" ) num = 2; + else if ( name == "monster_zombie_fat" ) num = 3; + else if ( name == "monster_zombie_fat2" ) num = 4; + else if ( name == "monster_zombie_fat_wrench" ) num = 5; + else if ( name == "monster_zombie_jumpsuit" ) num = 6; + else if ( name == "monster_zombie_labcoat_limb" ) num = 7; + else if ( name == "monster_zombie_labcoat_neckstump" ) num = 8; + else if ( name == "monster_zombie_labcoat_pipe" ) num = 9; + else if ( name == "monster_zombie_labcoat_skinny" ) num = 10; + else if ( name == "monster_zombie_maint" ) num = 11; + else if ( name == "monster_zombie_maint2" ) num = 12; + else if ( name == "monster_zombie_maint_bald" ) num = 13; + else if ( name == "monster_zombie_maint_fast" ) num = 14; + else if ( name == "monster_zombie_maint_flashlight" ) num = 15; + else if ( name == "monster_zombie_maint_no_jaw" ) num = 16; + else if ( name == "monster_zombie_maint_nojaw" ) num = 17; + else if ( name == "monster_zombie_maint_skinny" ) num = 18; + else if ( name == "monster_zombie_maint_wrench" ) num = 19; + else if ( name == "monster_zombie_morgue" ) num = 20; + else if ( name == "monster_zombie_suit_bloodymouth" ) num = 21; + else if ( name == "monster_zombie_suit_neckstump" ) num = 22; + else if ( name == "monster_zombie_suit_skinny" ) num = 23; + else if ( name == "monster_zombie_tshirt_bald" ) num = 24; + else if ( name == "monster_zombie_tshirt_blown" ) num = 25; + else if ( name == "monster_zombie_sawyer" ) num = 26; + + // ZSecs + else if ( name == "monster_zsec_pistol" ) num = 27; + else if ( name == "monster_zsec_machinegun" ) num = 28; + else if ( name == "monster_zsec_shotgun" ) num = 29; + else if ( name == "monster_zsec_shield" ) num = 30; + + // Demons (aas48) + else if ( name == "monster_demon_imp" ) num = 31; + else if ( name == "monster_demon_maggot" ) num = 32; + else if ( name == "monster_demon_wraith" ) num = 33; + else if ( name == "monster_demon_cherub" ) num = 34; + else if ( name == "monster_demon_revenant" ) num = 35; + else if ( name == "monster_zombie_commando" ) num = 36; + else if ( name == "monster_zombie_commando_cgun" ) num = 37; + else if ( name == "monster_demon_archvile" ) num = 38; + + // Demons (aas96) + else if ( name == "monster_demon_pinky" ) num = 39; + else if ( name == "monster_demon_hellknight" ) num = 40; + else if ( name == "monster_demon_mancubus" ) num = 41; + + return num; +} + +/* +=============== +idGameLocal::GetEnemyNameFromNum +=============== +*/ +idStr idGameLocal::GetEnemyNameFromNum( int num ) +{ + idStr name = ""; + switch ( num ) { + // Zombies + case 1: name = "monster_zombie_boney"; break; + case 2: name = "monster_zombie_bernie"; break; + case 3: name = "monster_zombie_fat"; break; + case 4: name = "monster_zombie_fat2"; break; + case 5: name = "monster_zombie_fat_wrench"; break; + case 6: name = "monster_zombie_jumpsuit"; break; + case 7: name = "monster_zombie_labcoat_limb"; break; + case 8: name = "monster_zombie_labcoat_neckstump"; break; + case 9: name = "monster_zombie_labcoat_pipe"; break; + case 10: name = "monster_zombie_labcoat_skinny"; break; + case 11: name = "monster_zombie_maint"; break; + case 12: name = "monster_zombie_maint2"; break; + case 13: name = "monster_zombie_maint_bald"; break; + case 14: name = "monster_zombie_maint_fast"; break; + case 15: name = "monster_zombie_maint_flashlight"; break; + case 16: name = "monster_zombie_maint_no_jaw"; break; + case 17: name = "monster_zombie_maint_nojaw"; break; + case 18: name = "monster_zombie_maint_skinny"; break; + case 19: name = "monster_zombie_maint_wrench"; break; + case 20: name = "monster_zombie_morgue"; break; + case 21: name = "monster_zombie_suit_bloodymouth"; break; + case 22: name = "monster_zombie_suit_neckstump"; break; + case 23: name = "monster_zombie_suit_skinny"; break; + case 24: name = "monster_zombie_tshirt_bald"; break; + case 25: name = "monster_zombie_tshirt_blown"; break; + case 26: name = "monster_zombie_sawyer"; break; + + // ZSecs + case 27: name = "monster_zsec_pistol"; break; + case 28: name = "monster_zsec_machinegun"; break; + case 29: name = "monster_zsec_shotgun"; break; + case 30: name = "monster_zsec_shield"; break; + + // Demons (aas48) + case 31: name = "monster_demon_imp"; break; + case 32: name = "monster_demon_maggot"; break; + case 33: name = "monster_demon_wraith"; break; + case 34: name = "monster_demon_cherub"; break; + case 35: name = "monster_demon_revenant"; break; + case 36: name = "monster_zombie_commando"; break; + case 37: name = "monster_zombie_commando_cgun"; break; + case 38: name = "monster_demon_archvile"; break; + + // Demons (aas96) + case 39: name = "monster_demon_pinky"; break; + case 40: name = "monster_demon_mancubus"; break; + case 41: name = "monster_demon_hellknight"; break; + + default: name = ""; break; + } + + return name; +} +/* +=============== +idGameLocal::GetHellSkin +=============== +*/ +idStr idGameLocal::GetHellSkin( int num ) +{ + idStr name = ""; + switch ( num ) { + case 1: name = "skins/monsters/zombies/adrianboney01"; break; + case 31: name = "skins/models/monsters/a_hellimp"; break; + case 41: name = "skins/models/monsters/a_hk_branded"; break; + default: name = ""; break; + } + + return name; +}// <---sikk diff --git a/game/Game_local.h b/game/Game_local.h index df7456d..d22d350 100644 --- a/game/Game_local.h +++ b/game/Game_local.h @@ -294,6 +294,34 @@ public: idEntityPtr lastGUIEnt; // last entity with a GUI, used by Cmd_NextGUI_f int lastGUI; // last GUI on the lastGUIEnt + idList currentLights; // sikk - Soft Shadows PostProcess + +// sikk---> Explosion FX PostProcess + idVec3 explosionOrigin; + int explosionRadius; + int explosionDamage; + int explosionTime; +// <---sikk + +// sikk---> Random Encounters System + idList randomEnemyList; // current list of eligible enemies + int randomEnemyListNum; // holds the size of the list for when loading a save game + int randomEnemyTime; // holds next spawn time + int randomEnemyTally; // holds number of random enemies that are active + int GetEnemyNumFromName( idStr name ); + idStr GetEnemyNameFromNum( int num ); + idStr GetHellSkin( int num ); + bool SpawnRandomEnemy( void ); +// <---sikk + +// sikk---> Portal Sky Box + idEntityPtr portalSkyEnt; + bool portalSkyActive; + void idGameLocal::SetPortalSkyEnt( idEntity *ent ) { portalSkyEnt = ent; } + bool idGameLocal::IsPortalSkyAcive( void ) { return portalSkyActive; } + pvsHandle_t GetPlayerPVS( void ) { return playerPVS; }; +// <---sikk + // ---------------------- Public idGame Interface ------------------- idGameLocal(); @@ -657,3 +685,23 @@ extern const idVec3 DEFAULT_GRAVITY_VEC3; extern const int CINEMATIC_SKIP_DELAY; #endif /* !__GAME_LOCAL_H__ */ + +#if 0 // TODO: DG: ??? +#include "physics/Force.h" +#include "physics/Force_Constant.h" +#include "physics/Force_Drag.h" +#include "physics/Force_Grab.h" // sikk - Object Manipulation +#include "physics/Force_Field.h" +#include "physics/Force_Spring.h" +#include "physics/Physics.h" + +#include "physics/Physics_AF.h" + +#include "SmokeParticles.h" +#include "Entity.h" +#include "GameEdit.h" +#include "Grab.h" // sikk - Object Manipulation +#include "AF.h" +#include "IK.h" +#include "AFEntity.h" +#endif // 0 diff --git a/game/Grab.cpp b/game/Grab.cpp new file mode 100644 index 0000000..9f5e397 --- /dev/null +++ b/game/Grab.cpp @@ -0,0 +1,216 @@ +// sikk---> Object Manipulation + +#include "../idlib/precompiled.h" +#pragma hdrstop + +#include "Game_local.h" +#include "Misc.h" + +#define MAX_DRAG_TRACE_DISTANCE 80.0f +#define TRACE_BOUNDS_SIZE 3.0f +#define MAX_HOLD_DISTANCE 96.0f +#define MIN_HOLD_DISTANCE 48.0f +#define DRAG_FAIL_LEN 64.0f +#define FAIL_TIME 1000 +#define THROW_TIME 500 +#define THROW_SCALE 20000 +#define MAX_PICKUP_VELOCITY 1000 * 1000 +#define MAX_PICKUP_SIZE 96.0f + +/* +=============================================================================== + + Allows entities to be dragged through the world with physics. + +=============================================================================== +*/ + +CLASS_DECLARATION( idEntity, idGrabEntity ) +END_CLASS + +/* +============== +idGrabEntity::idGrabEntity +============== +*/ +idGrabEntity::idGrabEntity( void ) { + Clear(); +} + +/* +============== +idGrabEntity::~idGrabEntity +============== +*/ +idGrabEntity::~idGrabEntity( void ) { + StopDrag( owner, true ); +} + +/* +============== +idGrabEntity::Clear +============== +*/ +void idGrabEntity::Clear() { + dragEnt = NULL; + owner = NULL; + id = 0; + oldUcmdFlags = 0; + dragFailTime = 0; + lastThrownTime = 0; + localPlayerPoint.Zero(); + saveGravity.Zero(); +} +/* +============== +idGrabEntity::StartDrag +============== +*/ +void idGrabEntity::StartDrag( idPlayer *player, idEntity *grabEnt, int id ) { + if ( grabEnt && grabEnt->GetPhysics()->GetBounds().GetRadius() < MAX_PICKUP_SIZE && + grabEnt->GetPhysics()->GetLinearVelocity().LengthSqr() < MAX_PICKUP_VELOCITY ) { + + dragFailTime = gameLocal.time + FAIL_TIME; + + oldUcmdFlags = player->usercmd.flags; + + // This is the new object to drag around + dragEnt = grabEnt; + + // Get the current physics object to manipulate + idPhysics *phys = grabEnt->GetPhysics(); + + // Turn off gravity on object + saveGravity = phys->GetGravity(); + phys->SetGravity( vec3_origin ); + + // hold it directly in front of player, distance depends on object size + float lerp = 1.0f - ( grabEnt->GetPhysics()->GetBounds().GetRadius() / MAX_HOLD_DISTANCE ); + lerp *= lerp; + float holdDist = lerp * MIN_HOLD_DISTANCE + ( 1.0f - lerp ) * MAX_HOLD_DISTANCE; + localPlayerPoint = ( player->firstPersonViewAxis[0] * holdDist ) * player->firstPersonViewAxis.Transpose(); + + // Start up the Force_Drag to bring it in + drag.Init( g_dragDamping.GetFloat() ); + drag.SetPhysics( phys, id, player->firstPersonViewOrigin + localPlayerPoint * player->firstPersonViewAxis ); + + player->StartSoundShader( declManager->FindSound( "use_grab" ), SND_CHANNEL_VOICE, 0, false, NULL ); + } +} + +/* +============== +idGrabEntity::StopDrag +============== +*/ +void idGrabEntity::StopDrag( idPlayer *player, bool drop ) { + if ( dragEnt.IsValid() ) { + idEntity *ent = dragEnt.GetEntity(); + + // If a cinematic has started, allow dropped object to think in cinematics + if ( gameLocal.inCinematic ) + ent->cinematic = true; + + // Restore Gravity + ent->GetPhysics()->SetGravity( saveGravity ); + + // If the object isn't near its goal, just drop it in place. + if ( drop || drag.GetDistanceToGoal() > DRAG_FAIL_LEN ) { + ent->GetPhysics()->SetLinearVelocity( vec3_origin ); + } else { // throw the object forward + ent->ApplyImpulse( player, 0, ent->GetPhysics()->GetOrigin(), player->firstPersonViewAxis[0] * THROW_SCALE ); + player->StartSoundShader( declManager->FindSound( "use_throw" ), SND_CHANNEL_VOICE, 0, false, NULL ); + } + // Remove the Force_Drag's control of the entity + drag.RemovePhysics( ent->GetPhysics() ); + + lastThrownTime = gameLocal.time + THROW_TIME; + } + + dragEnt = NULL; +} + +/* +============== +idGrabEntity::Update +============== +*/ +void idGrabEntity::Update( idPlayer *player ) { + trace_t trace; + idEntity *newEnt; + + owner = player; + + if ( lastThrownTime > gameLocal.time ) { + prevViewAngles = player->viewAngles; + return; + } + + bool valid = dragEnt.IsValid(); + + // Check if object being held has been removed or player is dead + if ( valid && dragEnt.GetEntity()->IsHidden() || player->health <= 0 ) { + StopDrag( player, true ); + prevViewAngles = player->viewAngles; + return; + } + + // attack throws object + if ( valid && player->usercmd.buttons & BUTTON_ATTACK ) { + StopDrag( player, false ); + prevViewAngles = player->viewAngles; + return; + } + + // if there is an entity selected for dragging + if ( dragEnt.GetEntity() ) { + idPhysics *entPhys = dragEnt.GetEntity()->GetPhysics(); + idVec3 goalPos; + + // Check if the player is standing on the object + idBounds playerBounds; + idBounds objectBounds = entPhys->GetAbsBounds(); + idVec3 newPoint = player->GetPhysics()->GetOrigin(); + + // create a bounds at the players feet + playerBounds.Clear(); + playerBounds.AddPoint( newPoint ); + newPoint.z -= 1.0f; + playerBounds.AddPoint( newPoint ); + playerBounds.ExpandSelf( 8.0f ); + + // If it intersects the object bounds, then drop it + if ( playerBounds.IntersectsBounds( objectBounds ) ) { + StopDrag( player, true ); + prevViewAngles = player->viewAngles; + return; + } + + idAngles ang = entPhys->GetAxis().ToAngles(); + ang.yaw += player->viewAngles.yaw - prevViewAngles.yaw; + if ( ang.yaw > 180.0f ) + ang.yaw -= 360.0f; + else if ( ang.yaw < -180.0f ) + ang.yaw += 360.0f; + entPhys->SetAxis( ang.ToMat3() ); + + // Set and evaluate drag force + goalPos = player->firstPersonViewOrigin + localPlayerPoint * player->firstPersonViewAxis; + + drag.SetGoalPosition( goalPos ); + drag.Evaluate( gameLocal.time ); + + // If the object is stuck away from its intended position for more than 500ms, let it go. + if ( drag.GetDistanceToGoal() > DRAG_FAIL_LEN ) { + if ( dragFailTime < gameLocal.time ) { + StopDrag( player, true ); + prevViewAngles = player->viewAngles; + return; + } + } else { + dragFailTime = gameLocal.time + 1000; + } + } + prevViewAngles = player->viewAngles; +} +// <---sikk \ No newline at end of file diff --git a/game/Grab.h b/game/Grab.h new file mode 100644 index 0000000..badab5f --- /dev/null +++ b/game/Grab.h @@ -0,0 +1,43 @@ +// sikk---> Object Manipulation +/* +=============================================================================== + + Grab Object - Class to extend idWeapon to include functionality for + manipulating physics objects. + +=============================================================================== +*/ + +class idGrabEntity : public idEntity { +public: + CLASS_PROTOTYPE( idGrabEntity ); + + idGrabEntity( void ); + ~idGrabEntity( void ); + + void Clear(); + + void Update( idPlayer *player ); + void StartDrag( idPlayer *player, idEntity *grabEnt, int id ); + void StopDrag( idPlayer *player, bool drop ); + + idEntity * GetGrabEntity( void ) const { return dragEnt.GetEntity(); } + int GetThrownTime( void ) const { return lastThrownTime; } + int SetThrownTime( int time ) { lastThrownTime = time; } + +private: + idEntityPtr dragEnt; // entity being dragged + idForce_Grab drag; + idPlayer* owner; + + idVec3 saveGravity; + idVec3 localPlayerPoint; // dragged point in player space + idAngles prevViewAngles; // Holds previous frame's player view angles + + int id; // id of body being dragged + int oldUcmdFlags; + int dragFailTime; + int lastThrownTime; + +}; +// <---sikk \ No newline at end of file diff --git a/game/Item.cpp b/game/Item.cpp index 97ae952..91d3733 100644 --- a/game/Item.cpp +++ b/game/Item.cpp @@ -76,6 +76,9 @@ idItem::idItem() { orgOrigin.Zero(); canPickUp = true; fl.networkSync = true; + + removeable = true; // sikk - Item Management: Random Item Removal + noPickup = false; // sikk - Item Management: Manual Item Pickup } /* @@ -108,6 +111,8 @@ void idItem::Save( idSaveGame *savefile ) const { savefile->WriteInt( inViewTime ); savefile->WriteInt( lastCycle ); savefile->WriteInt( lastRenderViewTime ); + + savefile->WriteBool( removeable ); // sikk - Item Management: Random Item Removal } /* @@ -129,6 +134,8 @@ void idItem::Restore( idRestoreGame *savefile ) { savefile->ReadInt( lastCycle ); savefile->ReadInt( lastRenderViewTime ); + savefile->ReadBool( removeable ); // sikk - Item Management: Random Item Removal + itemShellHandle = -1; } @@ -266,6 +273,19 @@ void idItem::Present( void ) { } } +// sikk---> Item Management: Random Item Value +/* +================ +idItem::GetRandomValue +================ +*/ +int idItem::GetRandomValue( const char* invName ) { + int n = spawnArgs.GetInt( invName ) * ( 1.0f - g_itemValueFactor.GetFloat() * gameLocal.random.RandomFloat() ); + n = ( n < 1 ) ? 1 : n; + return n; +} +// <---sikk + /* ================ idItem::Spawn @@ -317,6 +337,48 @@ void idItem::Spawn( void ) { lastCycle = -1; itemShellHandle = -1; shellMaterial = declManager->FindMaterial( "itemHighlightShell" ); + +// sikk---> Item Management: Random Item Value + if ( g_itemValueFactor.GetFloat() ) { + // random ammo values + if ( spawnArgs.GetInt( "inv_ammo_shells" ) ) + spawnArgs.SetInt( "inv_ammo_shells", GetRandomValue( "inv_ammo_shells" ) ); + if ( spawnArgs.GetInt( "inv_ammo_bullets" ) ) + spawnArgs.SetInt( "inv_ammo_bullets", GetRandomValue( "inv_ammo_bullets" ) ); + if ( spawnArgs.GetInt( "inv_ammo_rockets" ) ) + spawnArgs.SetInt( "inv_ammo_rockets", GetRandomValue( "inv_ammo_rockets" ) ); + if ( spawnArgs.GetInt( "inv_ammo_cells" ) ) + spawnArgs.SetInt( "inv_ammo_cells", GetRandomValue( "inv_ammo_cells" ) ); + if ( spawnArgs.GetInt( "inv_ammo_grenades" ) ) + spawnArgs.SetInt( "inv_ammo_grenades", GetRandomValue( "inv_ammo_grenades" ) ); + if ( spawnArgs.GetInt( "inv_ammo_bfg" ) ) + spawnArgs.SetInt( "inv_ammo_bfg", GetRandomValue( "inv_ammo_bfg" ) ); + if ( spawnArgs.GetInt( "inv_ammo_clip" ) ) + spawnArgs.SetInt( "inv_ammo_clip", GetRandomValue( "inv_ammo_clip" ) ); + if ( spawnArgs.GetInt( "inv_ammo_belt" ) ) + spawnArgs.SetInt( "inv_ammo_belt", GetRandomValue( "inv_ammo_belt" ) ); + + // random health values + if ( spawnArgs.GetInt( "inv_health" ) ) + spawnArgs.SetInt( "inv_health", GetRandomValue( "inv_health" ) ); + + // random armor values + if ( spawnArgs.GetInt( "inv_armor" ) ) + spawnArgs.SetInt( "inv_armor", GetRandomValue( "inv_armor" ) ); + + // random air values + if ( spawnArgs.GetInt( "inv_air" ) ) + spawnArgs.SetInt( "inv_air", GetRandomValue( "inv_air" ) ); + } + +// sikk---> Item Management: Random Item Removal + if ( g_itemRemovalFactor.GetFloat() && ( spawnArgs.GetBool( "removeable", "0" ) && removeable ) ) { + if ( ( gameLocal.random.RandomFloat() <= g_itemRemovalFactor.GetFloat() ) && spawnArgs.GetString( "target" ) == "" ) + PostEventMS( &EV_Remove, 0 ); + else + removeable = false; + } +// <---sikk } /* @@ -346,6 +408,11 @@ bool idItem::GiveToPlayer( idPlayer *player ) { return false; } +// sikk---> Item Management: Manual Item Pickup + if ( noPickup ) + return false; +// <---sikk + if ( spawnArgs.GetBool( "inv_carry" ) ) { return player->GiveInventoryItem( &spawnArgs ); } @@ -408,6 +475,8 @@ bool idItem::Pickup( idPlayer *player ) { } } + noPickup = true; // sikk - Item Management: Manual Item Pickup + BecomeInactive( TH_THINK ); return true; } @@ -516,7 +585,10 @@ void idItem::Event_Touch( idEntity *other, trace_t *trace ) { return; } - Pickup( static_cast(other) ); +// sikk---> Manual Item Pickup + if ( !g_itemPickupType.GetBool() || spawnArgs.GetBool( "autopickup" ) ) + Pickup( static_cast(other) ); +// <---sikk } /* @@ -636,8 +708,12 @@ bool idItemPowerup::GiveToPlayer( idPlayer *player ) { if ( player->spectating ) { return false; } - player->GivePowerUp( type, time * 1000 ); - return true; + +// sikk---> Adrenaline Pack System +// player->GivePowerUp( type, time * 1000 ); +// return true; + return player->GivePowerUp( type, time * 1000 ); +// <---sikk } /* @@ -712,6 +788,26 @@ void idObjective::Event_CamShot( ) { renderView_t fullView = *view; fullView.width = SCREEN_WIDTH; fullView.height = SCREEN_HEIGHT; + +// sikk---> Portal Sky Box + // HACK : always draw sky-portal view if there is one in the map, this isn't real-time + if ( gameLocal.portalSkyEnt.GetEntity() && g_enablePortalSky.GetBool() ) { + renderView_t portalView = fullView; + portalView.vieworg = gameLocal.portalSkyEnt.GetEntity()->GetPhysics()->GetOrigin(); + + // setup global fixup projection vars + int i, w, h; + + renderSystem->GetGLSettings( w, h ); + for ( i = 1; i < w; i <<= 1 ) {} + fullView.shaderParms[4] = (float)w / (float)i; + for ( i = 1; i < h; i <<= 1 ) {} + fullView.shaderParms[5] = (float)h / (float)i; + gameRenderWorld->RenderScene( &portalView ); + renderSystem->CaptureRenderToImage( "_currentRender" ); + } +// <---sikk + // draw a view to a texture renderSystem->CropRenderSize( 256, 256, true ); gameRenderWorld->RenderScene( &fullView ); @@ -924,7 +1020,7 @@ void idMoveableItem::Spawn( void ) { idBounds bounds; // create a trigger for item pickup - spawnArgs.GetFloat( "triggersize", "16.0", tsize ); + spawnArgs.GetFloat( "triggersize", "32.0", tsize ); // sikk - Changed default trigger size from 16 to 32 trigger = new idClipModel( idTraceModel( idBounds( vec3_origin ).Expand( tsize ) ) ); trigger->Link( gameLocal.clip, this, 0, GetPhysics()->GetOrigin(), GetPhysics()->GetAxis() ); trigger->SetContents( CONTENTS_TRIGGER ); @@ -954,16 +1050,26 @@ void idMoveableItem::Spawn( void ) { spawnArgs.GetFloat( "bouncyness", "0.6", bouncyness ); bouncyness = idMath::ClampFloat( 0.0f, 1.0f, bouncyness ); +// sikk---> Temp Fix for moveable items that spawn inside geometry + idVec3 offset = idVec3( 0.0f, 0.0f, 0.0f ); + if ( spawnArgs.GetString( "bind" ) == "" ) + offset = idVec3( 0.0f, 0.0f, 4.0f ); +// <---sikk + // setup the physics physicsObj.SetSelf( this ); physicsObj.SetClipModel( new idClipModel( trm ), density ); - physicsObj.SetOrigin( GetPhysics()->GetOrigin() ); + physicsObj.SetOrigin( GetPhysics()->GetOrigin() + offset ); // sikk - Temp Fix for moveable items that spawn inside geometry physicsObj.SetAxis( GetPhysics()->GetAxis() ); physicsObj.SetBouncyness( bouncyness ); physicsObj.SetFriction( 0.6f, 0.6f, friction ); physicsObj.SetGravity( gameLocal.GetGravity() ); - physicsObj.SetContents( CONTENTS_RENDERMODEL ); - physicsObj.SetClipMask( MASK_SOLID | CONTENTS_MOVEABLECLIP ); +// sikk---> We want moveable items to clip with other items and we also want ragdolls to clip with items + //physicsObj.SetContents( CONTENTS_RENDERMODEL ); + //physicsObj.SetClipMask( MASK_SOLID | CONTENTS_MOVEABLECLIP ); + physicsObj.SetContents( CONTENTS_RENDERMODEL | CONTENTS_CORPSE ); + physicsObj.SetClipMask( MASK_SOLID | CONTENTS_CORPSE | CONTENTS_MOVEABLECLIP | CONTENTS_RENDERMODEL ); +// <---sikk SetPhysics( &physicsObj ); smoke = NULL; @@ -974,6 +1080,40 @@ void idMoveableItem::Spawn( void ) { smokeTime = gameLocal.time; BecomeActive( TH_UPDATEPARTICLES ); } + +// sikk---> Item Management: Helmet factor (replaces security armor) + bool bRemoved = false; + idStr defName = GetEntityDefName(); + if ( !idStr::Icmp( defName, "item_armor_security" ) && ( g_itemHelmetFactor.GetFloat() && gameLocal.random.RandomFloat() <= g_itemHelmetFactor.GetFloat() ) ) { + idEntity *ent; + idDict args; + + args.Set( "classname", "item_armor_helmet" ); + args.Set( "name", GetName() ); +// args.Copy( spawnArgs ); + args.Set( "target", spawnArgs.GetString( "target" ) ); + args.Set( "origin", spawnArgs.GetString( "origin" ) ); + args.Set( "rotation", spawnArgs.GetString( "rotation" ) ); + args.Set( "no_touch", spawnArgs.GetString( "no_touch" ) ); + args.Set( "bind", spawnArgs.GetString( "bind" ) ); + args.Set( "triggerFirst", spawnArgs.GetString( "triggerFirst" ) ); + args.Set( "triggersize", spawnArgs.GetString( "triggersize" ) ); + +// PostEventMS( &EV_Remove, 0 ); + delete this; + gameLocal.SpawnEntityDef( args, &ent ); + bRemoved = true; + } +// <---sikk + +// sikk---> Item Management: Random Item Removal + if ( g_itemRemovalFactor.GetFloat() && ( spawnArgs.GetBool( "removeable", "0" ) && removeable ) && !bRemoved ) { + if ( ( gameLocal.random.RandomFloat() < g_itemRemovalFactor.GetFloat() ) && ( spawnArgs.GetString( "target" ) == "" ) ) + PostEventMS( &EV_Remove, 0 ); + else + removeable = false; + } +// <---sikk } /* @@ -1046,7 +1186,7 @@ idEntity *idMoveableItem::DropItem( const char *classname, const idVec3 &origin, removeDelay = 5 * 60 * 1000; } // always remove a dropped item after 5 minutes in case it dropped to an unreachable location - item->PostEventMS( &EV_Remove, removeDelay ); +// item->PostEventMS( &EV_Remove, removeDelay ); // sikk - Dropped moveable items are no longer removed } return item; } @@ -1206,6 +1346,116 @@ bool idMoveablePDAItem::GiveToPlayer(idPlayer *player) { return true; } +// sikk---> Moveable Video CD +/* +=============================================================================== + + idMoveableVideoCDItem + +=============================================================================== +*/ + +CLASS_DECLARATION( idMoveableItem, idMoveableVideoCDItem ) +END_CLASS + +/* +================ +idMoveableVideoCDItem::Spawn +================ +*/ +void idMoveableVideoCDItem::Spawn( void ) { +} + +/* +================ +idMoveableVideoCDItem::GiveToPlayer +================ +*/ +bool idMoveableVideoCDItem::GiveToPlayer( idPlayer *player ) { + idStr str = spawnArgs.GetString( "video" ); + if ( player && str.Length() ) { + player->GiveVideo( str, &spawnArgs ); + } + return true; +} +// <---sikk + +// sikk---> Moveable Powerup +/* +=============================================================================== + + idMoveableItemPowerup + +=============================================================================== +*/ + +/* +=============== +idMoveableItemPowerup +=============== +*/ + +CLASS_DECLARATION( idMoveableItem, idMoveableItemPowerup ) +END_CLASS + +/* +================ +idMoveableItemPowerup::idMoveableItemPowerup +================ +*/ +idMoveableItemPowerup::idMoveableItemPowerup() { + time = 0; + type = 0; +} + +/* +================ +idMoveableItemPowerup::Save +================ +*/ +void idMoveableItemPowerup::Save( idSaveGame *savefile ) const { + savefile->WriteInt( time ); + savefile->WriteInt( type ); +} + +/* +================ +idMoveableItemPowerup::Restore +================ +*/ +void idMoveableItemPowerup::Restore( idRestoreGame *savefile ) { + savefile->ReadInt( time ); + savefile->ReadInt( type ); +} + +/* +================ +idMoveableItemPowerup::Spawn +================ +*/ +void idMoveableItemPowerup::Spawn( void ) { + time = spawnArgs.GetInt( "time", "30" ); + type = spawnArgs.GetInt( "type", "0" ); +} + +/* +================ +idMoveableItemPowerup::GiveToPlayer +================ +*/ +bool idMoveableItemPowerup::GiveToPlayer( idPlayer *player ) { + if ( player->spectating ) { + return false; + } + +// sikk---> Adrenaline Pack System +// player->GivePowerUp( type, time * 1000 ); +// return true; + return player->GivePowerUp( type, time * 1000 ); +// <---sikk +} +// <---sikk + /* =============================================================================== diff --git a/game/Item.h b/game/Item.h index acf7c0c..9d7f3d6 100644 --- a/game/Item.h +++ b/game/Item.h @@ -71,6 +71,10 @@ public: virtual void WriteToSnapshot( idBitMsgDelta &msg ) const; virtual void ReadFromSnapshot( const idBitMsgDelta &msg ); + int GetRandomValue( const char* invName ); // sikk - Item Management: Random Item Value + bool removeable; // sikk - Item Management: Random Item Removal + bool noPickup; // sikk - Item Management: Manual Item Pickup + private: idVec3 orgOrigin; bool spin; @@ -87,6 +91,7 @@ private: mutable int lastCycle; mutable int lastRenderViewTime; + bool UpdateRenderEntity( renderEntity_s *renderEntity, const renderView_t *renderView ) const; static bool ModelCallback( renderEntity_s *renderEntity, const renderView_t *renderView ); @@ -188,6 +193,35 @@ public: virtual bool GiveToPlayer( idPlayer *player ); }; +// sikk---> Moveable Video CD +class idMoveableVideoCDItem : public idMoveableItem { +public: + CLASS_PROTOTYPE( idMoveableVideoCDItem ); + + void Spawn(); + virtual bool GiveToPlayer( idPlayer *player ); +}; +// <---sikk + +// sikk---> Moveable Powerup +class idMoveableItemPowerup : public idMoveableItem { +public: + CLASS_PROTOTYPE( idMoveableItemPowerup ); + + idMoveableItemPowerup(); + + void Save( idSaveGame *savefile ) const; + void Restore( idRestoreGame *savefile ); + + void Spawn(); + virtual bool GiveToPlayer( idPlayer *player ); + +private: + int time; + int type; +}; +// <---sikk + /* =============================================================================== diff --git a/game/Light.cpp b/game/Light.cpp index cc24a42..fa03e98 100644 --- a/game/Light.cpp +++ b/game/Light.cpp @@ -300,6 +300,13 @@ void idLight::Restore( idRestoreGame *savefile ) { lightDefHandle = -1; +// sikk---> Soft Shadows PostProcess + // only put lights that cast shadows into the list + if ( spawnArgs.GetInt( "noshadows" ) == 0 ) { + gameLocal.currentLights.Append( entityNumber ); + } +// <---sikk + SetLightLevel(); } @@ -417,6 +424,13 @@ void idLight::Spawn( void ) { PostEventMS( &EV_PostSpawn, 0 ); +// sikk---> Soft Shadows PostProcess + // only put lights that cast shadows into the list + if ( spawnArgs.GetInt( "noshadows" ) == 0 ) { + gameLocal.currentLights.Append( entityNumber ); + } +// <---sikk + UpdateVisuals(); } @@ -673,7 +687,7 @@ void idLight::BecomeBroken( idEntity *activator ) { } - ActivateTargets( activator ); + ActivateTargets( activator ); // offset the start time of the shader to sync it to the game time renderEntity.shaderParms[ SHADERPARM_TIMEOFFSET ] = -MS2SEC( gameLocal.time ); @@ -1156,3 +1170,19 @@ bool idLight::ClientReceiveEvent( int event, int time, const idBitMsg &msg ) { return idEntity::ClientReceiveEvent( event, time, msg ); } + +// sikk---> Soft Shadows PostProcess +/* +================ +idLight::UpdateShadowState +================ +*/ +void idLight::UpdateShadowState( void ) { + // let the renderer apply it to the world + if ( ( lightDefHandle != -1 ) ) { + gameRenderWorld->UpdateLightDef( lightDefHandle, &renderLight ); + } else { + lightDefHandle = gameRenderWorld->AddLightDef( &renderLight ); + } +} +// <---sikk \ No newline at end of file diff --git a/game/Light.h b/game/Light.h index 340a0b9..535eea6 100644 --- a/game/Light.h +++ b/game/Light.h @@ -91,12 +91,16 @@ public: EVENT_BECOMEBROKEN = idEntity::EVENT_MAXEVENTS, EVENT_MAXEVENTS }; - virtual void ClientPredictionThink( void ); virtual void WriteToSnapshot( idBitMsgDelta &msg ) const; virtual void ReadFromSnapshot( const idBitMsgDelta &msg ); virtual bool ClientReceiveEvent( int event, int time, const idBitMsg &msg ); +// sikk---> Soft Shadows PostProcess + renderLight_t* GetRenderLight( void ) { return &renderLight; }; + void UpdateShadowState( void ); +// <---sikk + private: renderLight_t renderLight; // light presented to the renderer idVec3 localLightOrigin; // light origin relative to the physics origin diff --git a/game/Misc.cpp b/game/Misc.cpp index bfde719..0c5eaca 100644 --- a/game/Misc.cpp +++ b/game/Misc.cpp @@ -1423,6 +1423,11 @@ void idStaticEntity::Spawn( void ) { if ( model.Find( ".prt" ) >= 0 ) { // we want the parametric particles out of sync with each other renderEntity.shaderParms[ SHADERPARM_TIMEOFFSET ] = gameLocal.random.RandomInt( 32767 ); + +// sikk---> Depth Render + renderEntity.suppressSurfaceInViewID = -8; + renderEntity.noShadow = 1; +// <---sikk } fadeFrom.Set( 1, 1, 1, 1 ); @@ -3156,3 +3161,63 @@ void idPhantomObjects::Think( void ) { BecomeInactive( TH_THINK ); } } + +// sikk---> Portal Sky Box +/* +=============================================================================== + +idPortalSky + +=============================================================================== +*/ + +CLASS_DECLARATION( idEntity, idPortalSky ) + EVENT( EV_PostSpawn, idPortalSky::Event_PostSpawn ) + EVENT( EV_Activate, idPortalSky::Event_Activate ) +END_CLASS + +/* +=============== +idPortalSky::idPortalSky +=============== +*/ +idPortalSky::idPortalSky( void ) { +} + +/* +=============== +idPortalSky::~idPortalSky +=============== +*/ +idPortalSky::~idPortalSky( void ) { +} + +/* +=============== +idPortalSky::Spawn +=============== +*/ +void idPortalSky::Spawn( void ) { + if ( !spawnArgs.GetBool( "triggered" ) ) { + PostEventMS( &EV_PostSpawn, 1 ); + } +} + +/* +================ +idPortalSky::Event_PostSpawn +================ +*/ +void idPortalSky::Event_PostSpawn() { + gameLocal.SetPortalSkyEnt( this ); +} + +/* +================ +idPortalSky::Event_Activate +================ +*/ +void idPortalSky::Event_Activate( idEntity *activator ) { + gameLocal.SetPortalSkyEnt( this ); +} +// <---sikk \ No newline at end of file diff --git a/game/Misc.h b/game/Misc.h index 89a4235..b0b4ca3 100644 --- a/game/Misc.h +++ b/game/Misc.h @@ -765,4 +765,25 @@ private: idList lastTargetPos; }; +// sikk---> Portal Sky Box +/* +=============================================================================== + +idPortalSky + +=============================================================================== +*/ +class idPortalSky : public idEntity { +public: + CLASS_PROTOTYPE( idPortalSky ); + + idPortalSky(); + ~idPortalSky(); + + void Spawn( void ); + void Event_PostSpawn(); + void Event_Activate( idEntity *activator ); +}; +// <---sikk + #endif /* !__GAME_MISC_H__ */ diff --git a/game/Moveable.cpp b/game/Moveable.cpp index e3458b3..5bfac1d 100644 --- a/game/Moveable.cpp +++ b/game/Moveable.cpp @@ -907,6 +907,9 @@ void idExplodingBarrel::AddParticles( const char *name, bool burn ) { particleRenderEntity.shaderParms[ SHADERPARM_ALPHA ] = rgb; particleRenderEntity.shaderParms[ SHADERPARM_TIMEOFFSET ] = -MS2SEC( gameLocal.realClientTime ); particleRenderEntity.shaderParms[ SHADERPARM_DIVERSITY ] = ( burn ) ? 1.0f : gameLocal.random.RandomInt( 90 ); + + particleRenderEntity.suppressSurfaceInViewID = -8; // sikk - Depth Render + if ( !particleRenderEntity.hModel ) { particleRenderEntity.hModel = renderModelManager->FindModel( name ); } diff --git a/game/Player.cpp b/game/Player.cpp index 8308c96..2743555 100644 --- a/game/Player.cpp +++ b/game/Player.cpp @@ -178,6 +178,9 @@ void idInventory::Clear( void ) { ammoPulse = false; weaponPulse = false; armorPulse = false; + + healthPackAmount = 0; // sikk - Health Management System (Health Pack) + adrenalineAmount = 0; // sikk - Adrenaline Pack System } /* @@ -513,6 +516,9 @@ void idInventory::Save( idSaveGame *savefile ) const { savefile->WriteBool( armorPulse ); savefile->WriteInt( lastGiveTime ); + + savefile->WriteInt( healthPackAmount ); // sikk - Health Management System (Health Pack) + savefile->WriteInt( adrenalineAmount ); // sikk - Adrenaline Pack System } /* @@ -633,6 +639,9 @@ void idInventory::Restore( idRestoreGame *savefile ) { savefile->ReadBool( armorPulse ); savefile->ReadInt( lastGiveTime ); + + savefile->ReadInt( healthPackAmount ); // sikk - Health Management System (Health Pack) + savefile->ReadInt( adrenalineAmount ); // sikk - Adrenaline Pack System } /* @@ -650,6 +659,11 @@ idInventory::AmmoIndexForAmmoClass ============== */ int idInventory::MaxAmmoForAmmoClass( idPlayer *owner, const char *ammo_classname ) const { +// sikk---> Ammo Capacity Type + if ( g_ammoCapacityType.GetBool() ) + return owner->spawnArgs.GetInt( va( "custom_max_%s", ammo_classname ), "0" ); +// <---sikk + return owner->spawnArgs.GetInt( va( "max_%s", ammo_classname ), "0" ); } @@ -746,13 +760,27 @@ bool idInventory::Give( idPlayer *owner, const idDict &spawnArgs, const char *st if ( !idStr::Icmpn( statname, "ammo_", 5 ) ) { i = AmmoIndexForAmmoClass( statname ); max = MaxAmmoForAmmoClass( owner, statname ); + +// sikk---> Ammo Management: Ammo Usage Type/Capacity Type + if ( g_ammoUsageType.GetBool() ) { + int j = WeaponIndexForAmmoClass( spawnArgs, statname ); + const char *weapon_classname = spawnArgs.GetString( va( "def_weapon%d", j ) ); + if ( weapon_classname ) { + const idDeclEntityDef *decl = gameLocal.FindEntityDef( weapon_classname, false ); + if ( decl ) + max -= atoi( g_ammoCapacityType.GetBool() ? decl->dict.GetString( "custom_clipSize" ) : decl->dict.GetString( "clipSize" ) ) - clip[ j ]; + } + } +// <---sikk + if ( ammo[ i ] >= max ) { return false; } amount = atoi( value ); if ( amount ) { ammo[ i ] += amount; - if ( ( max > 0 ) && ( ammo[ i ] > max ) ) { + + if ( ( max > 0 ) && ( ammo[ i ] > max ) ) { ammo[ i ] = max; } ammoPulse = true; @@ -1133,6 +1161,40 @@ idPlayer::idPlayer() { isChatting = false; selfSmooth = false; + +// sikk---> Health Management System + healthPackAmount = 0; + healthPackTimer = 0; + nextHealthRegen = 0; + prevHeatlh = health; +// <---sikk + + focusMoveableTimer = 0; // sikk - Object Manipulation + + focusItem = NULL; // sikk - Manual Item Pickup + + searchTimer = 0; // sikk - Searchable Corpses + + adrenalineAmount = 0; // sikk - Adrenaline Pack System + + bViewModelsModified = false; // sikk - Depth Render + + v3CrosshairPos.Zero(); // sikk - Crosshair Positioning + + bIsZoomed = false; // sikk - Depth of Field PostProcess + + bAmbientLightOn = false; // sikk - Global Ambient Light + + nScreenFrostAlpha = 0; // sikk - Screen Frost + +// sikk--> Infrared Goggles/Headlight Mod + bIRGogglesOn = false; + bHeadlightOn = false; + nIRGogglesTime = 0; + nHeadlightTime = 0; + nBattery = 100; + fIntensity = 1.0f; +// <---sikk } /* @@ -1247,6 +1309,42 @@ void idPlayer::Init( void ) { talkCursor = 0; focusVehicle = NULL; + focusMoveableTimer = 0; // sikk - Object Manipulation + + focusItem = NULL; // sikk - Manual Item Pickup + + searchTimer = 0; // sikk - Searchable Corpses + + adrenalineAmount = 0; // sikk - Adrenaline Pack System + + bViewModelsModified = false; // sikk - Depth Render + + v3CrosshairPos.Zero(); // sikk - Crosshair Positioning + + bIsZoomed = false; // sikk - Depth of Field PostProcess + + bAmbientLightOn = false; // sikk - Global Ambient Light + + nScreenFrostAlpha = 0; // sikk - Screen Frost + +// sikk---> Health Management System + healthPackAmount = 0; + healthPackTimer = 0; + nextHealthRegen = 0; + prevHeatlh = health; +// <---sikk + +// sikk--> Infrared Goggles/Headlight PostProcess + bIRGogglesOn = false; + bHeadlightOn = false; + nIRGogglesTime = 0; + nHeadlightTime = 0; + nBattery = 100; + fIntensity = 1.0f; +// <---sikk + + gameLocal.randomEnemyTime = gameLocal.time + g_randomEncountersMinTime.GetInteger() * 1000; // sikk - Random Encounters System + // remove any damage effects playerView.ClearEffects(); @@ -1264,7 +1362,7 @@ void idPlayer::Init( void ) { healthPulse = false; nextHealthTake = 0; healthTake = false; - + SetupWeaponEntity(); currentWeapon = -1; previousWeapon = -1; @@ -1476,7 +1574,7 @@ void idPlayer::Spawn( void ) { // load the armor sound feedback declManager->FindSound( "player_sounds_hitArmor" ); - // set up conditions for animation + // set up conditions for animation LinkScriptVariables(); animator.RemoveOriginOffset( true ); @@ -1528,6 +1626,26 @@ void idPlayer::Spawn( void ) { idEntity *ent = gameLocal.FindEntity( "devmap" ); if ( ent ) { ent->ActivateTargets( this ); + +// sikk---> Random Encounters System + // sikk - this alows the list to be filled with a preset list for when a map is loaded by "map" or "devmap" + if ( g_useRandomEncounters.GetBool() ) { + gameLocal.randomEnemyList.Clear(); + const char* mapname = gameLocal.GetLevelMap()->GetName(); + const idDeclEntityDef *decl = gameLocal.FindEntityDef( mapname, false ); + if ( decl ) { + const idKeyValue *kv = decl->dict.MatchPrefix( "re_" ); + if ( kv ) { + while( kv ) { + int n = gameLocal.GetEnemyNumFromName( kv->GetValue() ); + gameLocal.randomEnemyList.Append( n ); + kv = decl->dict.MatchPrefix( "re_", kv ); + } + } + } + } +// <---sikk + } } if ( hud ) { @@ -1584,7 +1702,9 @@ void idPlayer::Spawn( void ) { } } else { g_damageScale.SetFloat( 1.0f ); - g_armorProtection.SetFloat( ( g_skill.GetInteger() < 2 ) ? 0.4f : 0.2f ); + +// sikk - Commented to allow this to be set by the user +// g_armorProtection.SetFloat( ( g_skill.GetInteger() < 2 ) ? 0.4f : 0.2f ); if ( g_skill.GetInteger() == 3 ) { healthTake = true; @@ -1592,6 +1712,57 @@ void idPlayer::Spawn( void ) { } } } + +// sikk---> Random Encounters System + // preload monster defs to avoid hitching during play + if ( g_useRandomEncounters.GetBool() ) { + declManager->FindType( DECL_ENTITYDEF, "monster_zombie_boney" ); + declManager->FindType( DECL_ENTITYDEF, "monster_zombie_bernie" ); + declManager->FindType( DECL_ENTITYDEF, "monster_zombie_fat" ); + declManager->FindType( DECL_ENTITYDEF, "monster_zombie_fat2" ); + declManager->FindType( DECL_ENTITYDEF, "monster_zombie_fat_wrench" ); + declManager->FindType( DECL_ENTITYDEF, "monster_zombie_jumpsuit" ); + declManager->FindType( DECL_ENTITYDEF, "monster_zombie_labcoat_limb" ); + declManager->FindType( DECL_ENTITYDEF, "monster_zombie_labcoat_neckstump" ); + declManager->FindType( DECL_ENTITYDEF, "monster_zombie_labcoat_pipe" ); + declManager->FindType( DECL_ENTITYDEF, "monster_zombie_labcoat_skinny" ); + declManager->FindType( DECL_ENTITYDEF, "monster_zombie_maint" ); + declManager->FindType( DECL_ENTITYDEF, "monster_zombie_maint2" ); + declManager->FindType( DECL_ENTITYDEF, "monster_zombie_maint_bald" ); + declManager->FindType( DECL_ENTITYDEF, "monster_zombie_maint_fast" ); + declManager->FindType( DECL_ENTITYDEF, "monster_zombie_maint_flashlight" ); + declManager->FindType( DECL_ENTITYDEF, "monster_zombie_maint_no_jaw" ); + declManager->FindType( DECL_ENTITYDEF, "monster_zombie_maint_nojaw" ); + declManager->FindType( DECL_ENTITYDEF, "monster_zombie_maint_skinny" ); + declManager->FindType( DECL_ENTITYDEF, "monster_zombie_maint_wrench" ); + declManager->FindType( DECL_ENTITYDEF, "monster_zombie_morgue" ); + declManager->FindType( DECL_ENTITYDEF, "monster_zombie_suit_bloodymouth" ); + declManager->FindType( DECL_ENTITYDEF, "monster_zombie_suit_neckstump" ); + declManager->FindType( DECL_ENTITYDEF, "monster_zombie_suit_skinny" ); + declManager->FindType( DECL_ENTITYDEF, "monster_zombie_tshirt_bald" ); + declManager->FindType( DECL_ENTITYDEF, "monster_zombie_tshirt_blown" ); + declManager->FindType( DECL_ENTITYDEF, "monster_zombie_sawyer" ); + + // ZSecs + declManager->FindType( DECL_ENTITYDEF, "monster_zsec_pistol" ); + declManager->FindType( DECL_ENTITYDEF, "monster_zsec_machinegun" ); + declManager->FindType( DECL_ENTITYDEF, "monster_zsec_shotgun" ); + declManager->FindType( DECL_ENTITYDEF, "monster_zsec_shield" ); + + // Demons (aas48) + declManager->FindType( DECL_ENTITYDEF, "monster_demon_imp" ); + declManager->FindType( DECL_ENTITYDEF, "monster_demon_maggot" ); + declManager->FindType( DECL_ENTITYDEF, "monster_demon_wraith" ); + declManager->FindType( DECL_ENTITYDEF, "monster_demon_cherub" ); + declManager->FindType( DECL_ENTITYDEF, "monster_demon_revenant" ); + declManager->FindType( DECL_ENTITYDEF, "monster_zombie_commando" ); + declManager->FindType( DECL_ENTITYDEF, "monster_zombie_commando_cgun" ); + declManager->FindType( DECL_ENTITYDEF, "monster_demon_archvile" ); + declManager->FindType( DECL_ENTITYDEF, "monster_demon_pinky" ); + declManager->FindType( DECL_ENTITYDEF, "monster_demon_mancubus" ); + declManager->FindType( DECL_ENTITYDEF, "monster_demon_hellknight" ); + } +// <---sikk } /* @@ -1811,6 +1982,24 @@ void idPlayer::Save( idSaveGame *savefile ) const { savefile->WriteFloat( pm_stamina.GetFloat() ); + savefile->WriteInt( nScreenFrostAlpha ); // sikk - Screen Frost + + savefile->WriteInt( adrenalineAmount ); // sikk - Adrenaline Pack System + +// sikk---> Health Management System + savefile->WriteInt( healthPackAmount ); + savefile->WriteInt( nextHealthRegen ); + savefile->WriteInt( prevHeatlh ); +// <---sikk + +// sikk--> Infrared Goggles/Headlight/Global Ambient light + savefile->WriteBool( bAmbientLightOn ); + savefile->WriteBool( bIRGogglesOn ); + savefile->WriteBool( bHeadlightOn ); + savefile->WriteFloat( fIntensity ); + savefile->WriteInt( nBattery ); +// <---sikk + if ( hud ) { hud->SetStateString( "message", common->GetLanguageDict()->GetString( "#str_02916" ) ); hud->HandleNamedEvent( "Message" ); @@ -2061,6 +2250,26 @@ void idPlayer::Restore( idRestoreGame *savefile ) { savefile->ReadFloat( set ); pm_stamina.SetFloat( set ); + savefile->ReadInt( nScreenFrostAlpha ); // sikk - Screen Frost + + savefile->ReadInt( adrenalineAmount ); // sikk - Adrenaline Pack System + +// sikk---> Health Management System + savefile->ReadInt( healthPackAmount ); + savefile->ReadInt( nextHealthRegen ); + savefile->ReadInt( prevHeatlh ); +// <---sikk + +// sikk--> Infrared Goggles/Headlight Mod/Global Ambient Light + savefile->ReadBool( bAmbientLightOn ); + savefile->ReadBool( bIRGogglesOn ); + savefile->ReadBool( bHeadlightOn ); + savefile->ReadFloat( fIntensity ); + savefile->ReadInt( nBattery ); +// <---sikk + + grabEntity.Clear(); // sikk - Object Manipulation + // create combat collision hull for exact collision detection SetCombatModel(); @@ -2300,6 +2509,9 @@ void idPlayer::SavePersistantInfo( void ) { inventory.GetPersistantData( playerInfo ); playerInfo.SetInt( "health", health ); playerInfo.SetInt( "current_weapon", currentWeapon ); + + playerInfo.SetInt( "healthPackAmount", healthPackAmount ); // sikk - Health Management System (Health Pack) + playerInfo.SetInt( "adrenalineAmount", adrenalineAmount ); // sikk - Adrenaline Pack System } /* @@ -2321,6 +2533,9 @@ void idPlayer::RestorePersistantInfo( void ) { if ( !gameLocal.isClient ) { idealWeapon = spawnArgs.GetInt( "current_weapon", "1" ); } + + healthPackAmount = spawnArgs.GetInt( "healthPackAmount", "0" ); // sikk - Health Management System (Health Pack) + adrenalineAmount = spawnArgs.GetInt( "adrenalineAmount", "0" ); // sikk - Health Management System (Health Pack) } /* @@ -2484,6 +2699,8 @@ void idPlayer::UpdateHudAmmo( idUserInterface *_hud ) { int inclip; int ammoamount; + bool bStatsChanged = false; // sikk - Dynamic hud System + assert( weapon.GetEntity() ); assert( _hud ); @@ -2494,6 +2711,13 @@ void idPlayer::UpdateHudAmmo( idUserInterface *_hud ) { _hud->SetStateString( "player_ammo", "" ); _hud->SetStateString( "player_totalammo", "" ); } else { +// sikk---> Dynamic Hud System + if ( atoi( _hud->GetStateString( "player_ammo" ) ) != inclip || + atoi( _hud->GetStateString( "player_totalammo" ) ) != ( ammoamount - inclip ) ) { + bStatsChanged = true; + } +// <---sikk + // show remaining ammo _hud->SetStateString( "player_totalammo", va( "%i", ammoamount - inclip ) ); _hud->SetStateString( "player_ammo", weapon.GetEntity()->ClipSize() ? va( "%i", inclip ) : "--" ); // how much in the current clip @@ -2506,6 +2730,18 @@ void idPlayer::UpdateHudAmmo( idUserInterface *_hud ) { _hud->SetStateBool( "player_clip_low", ( weapon.GetEntity()->ClipSize() ? inclip <= weapon.GetEntity()->LowAmmo() : false ) ); _hud->HandleNamedEvent( "updateAmmo" ); + +// sikk---> Dynamic Hud System + if ( bStatsChanged ) + nShowHudTimer = gameLocal.time + g_dynamicHudTime.GetInteger() * 1000; + + if ( g_useDynamicHud.GetBool() ) { + float f = idMath::ClampInt( 0, 1000, ( nShowHudTimer - gameLocal.time ) ); + _hud->SetStateFloat( "hud_alpha", f * 0.001f ); + } else { + _hud->SetStateFloat( "hud_alpha", 1.0f ); + } +// <---sikk } /* @@ -2517,6 +2753,8 @@ void idPlayer::UpdateHudStats( idUserInterface *_hud ) { int staminapercentage; float max_stamina; + bool bStatsChanged = false; // sikk - Dynamic hud System + assert( _hud ); max_stamina = pm_stamina.GetFloat(); @@ -2527,6 +2765,13 @@ void idPlayer::UpdateHudStats( idUserInterface *_hud ) { staminapercentage = idMath::FtoiFast( 100.0f * stamina / max_stamina ); } +// sikk---> Dynamic Hud System + if ( _hud->GetStateInt( "player_health" ) != health || + _hud->GetStateInt( "player_armor" ) != inventory.armor ) { + bStatsChanged = true; + } +// <---sikk + _hud->SetStateInt( "player_health", health ); _hud->SetStateInt( "player_stamina", staminapercentage ); _hud->SetStateInt( "player_armor", inventory.armor ); @@ -2565,6 +2810,35 @@ void idPlayer::UpdateHudStats( idUserInterface *_hud ) { } UpdateHudAmmo( _hud ); + +// sikk---> Health Management System (Health Pack) + if ( g_healthManagementType.GetInteger() == 1 ) { + if ( _hud->GetStateInt( "player_healthpack" ) != healthPackAmount ) + bStatsChanged = true; + _hud->SetStateInt( "player_healthpack", healthPackAmount ); + } else + _hud->SetStateInt( "player_healthpack", 0 ); + _hud->HandleNamedEvent( "UpdateHealhPack" ); +// <---sikk + +// sikk---> Adrenaline Pack System + if ( _hud->GetStateInt( "player_adrenaline" ) != adrenalineAmount ) + bStatsChanged = true; + _hud->SetStateInt( "player_adrenaline", adrenalineAmount ); + _hud->HandleNamedEvent( "UpdateAdrenaline" ); +// <---sikk + +// sikk---> Dynamic Hud System + if ( bStatsChanged ) + nShowHudTimer = gameLocal.time + g_dynamicHudTime.GetInteger() * 1000; + + if ( g_useDynamicHud.GetBool() ) { + float f = idMath::ClampInt( 0, 1000, ( nShowHudTimer - gameLocal.time ) ); + _hud->SetStateFloat( "hud_alpha", f * 0.001f ); + } else { + _hud->SetStateFloat( "hud_alpha", 1.0f ); + } +// <---sikk } /* @@ -2859,20 +3133,34 @@ bool idPlayer::Give( const char *statname, const char *value ) { } if ( !idStr::Icmp( statname, "health" ) ) { - if ( health >= inventory.maxHealth ) { - return false; - } - amount = atoi( value ); - if ( amount ) { - health += amount; - if ( health > inventory.maxHealth ) { - health = inventory.maxHealth; +// sikk---> Health Management System (Health Pack) + if ( g_healthManagementType.GetInteger() == 1 ) { + if ( healthPackAmount >= g_healthPackTotal.GetInteger() ) { + return false; } - if ( hud ) { - hud->HandleNamedEvent( "healthPulse" ); + amount = atoi( value ); + if ( amount ) { + healthPackAmount += amount; + if ( healthPackAmount > g_healthPackTotal.GetInteger() ) { + healthPackAmount = g_healthPackTotal.GetInteger(); + } + } + } else { +// <---sikk + if ( health >= inventory.maxHealth ) { + return false; + } + amount = atoi( value ); + if ( amount ) { + health += amount; + if ( health > inventory.maxHealth ) { + health = inventory.maxHealth; + } + if ( hud ) { + hud->HandleNamedEvent( "healthPulse" ); + } } } - } else if ( !idStr::Icmp( statname, "stamina" ) ) { if ( stamina >= 100 ) { return false; @@ -3033,6 +3321,11 @@ bool idPlayer::GivePowerUp( int powerup, int time ) { if ( powerup >= 0 && powerup < MAX_POWERUPS ) { +// sikk---> Adrenaline Pack System + if ( powerup == ADRENALINE && adrenalineAmount ) + return false; +// <---sikk + if ( gameLocal.isServer ) { idBitMsg msg; byte msgBuf[MAX_EVENT_PARAM_SIZE]; @@ -3043,7 +3336,7 @@ bool idPlayer::GivePowerUp( int powerup, int time ) { ServerSendEvent( EVENT_POWERUP, &msg, false, -1 ); } - if ( powerup != MEGAHEALTH ) { + if ( powerup != MEGAHEALTH && powerup != ADRENALINE ) { // sikk---> Adrenaline Pack System inventory.GivePowerUp( this, powerup, time ); } @@ -3078,7 +3371,14 @@ bool idPlayer::GivePowerUp( int powerup, int time ) { break; } case ADRENALINE: { - stamina = 100.0f; +// sikk---> Adrenaline Pack System + if ( adrenalineAmount >= 1 ) + return false; + adrenalineAmount += 1; + if ( adrenalineAmount > 1 ) + adrenalineAmount = 1; +// <---sikk +// stamina = 100.0f; break; } case MEGAHEALTH: { @@ -3185,6 +3485,39 @@ void idPlayer::UpdatePowerUps( void ) { nextHealthTake = gameLocal.time + g_healthTakeTime.GetInteger() * 1000; healthTake = true; } + +// sikk---> Health Management System (Health Regen) + if ( g_healthManagementType.GetInteger() == 2 && + !gameLocal.inCinematic && + !influenceActive && + g_skill.GetInteger() != 3 && + gameLocal.time > nextHealthRegen && + gameLocal.time > ( lastDmgTime + ( g_healthRegenDelay.GetInteger() * 1000 ) ) && + health < g_healthRegenLimit.GetInteger() && + health < prevHeatlh && + !AI_DEAD ) { + + int currentRegenStep; + + if ( g_healthRegenSteps.GetInteger() > 1 ) { + currentRegenStep = g_healthRegenLimit.GetInteger() / g_healthRegenSteps.GetInteger(); + for ( int i = 0; i < g_healthRegenSteps.GetInteger(); i++ ) + if ( health > currentRegenStep ) + currentRegenStep += ( g_healthRegenLimit.GetInteger() / g_healthRegenSteps.GetInteger() ); + } + + assert( !gameLocal.isClient ); // healthPool never be set on client + health += g_healthRegenAmt.GetInteger(); + + if ( g_healthRegenSteps.GetInteger() > 1 && health > currentRegenStep ) { + health = currentRegenStep; + } + if ( health > g_healthRegenLimit.GetInteger() ) { + health = g_healthRegenLimit.GetInteger(); + } + nextHealthRegen = gameLocal.time + g_healthRegenTime.GetInteger() * 1000; + } +// <---sikk } /* @@ -4057,8 +4390,21 @@ void idPlayer::UpdateWeapon( void ) { } else if ( ActiveGui() ) { // gui handling overrides weapon use Weapon_GUI(); - } else if ( focusCharacter && ( focusCharacter->health > 0 ) ) { + } else if ( focusCharacter && ( focusCharacter->health > 0 ) ) { Weapon_NPC(); +// sikk---> Health Management System (Health Pack)|Manual Item Pickup|Searchable Corpses|Object Manipulation + } else if ( ( g_weaponHandlingType.GetBool() && ( healthPackTimer > gameLocal.time ) || ( searchTimer > gameLocal.time ) ) || + ( g_grabMode.GetBool() && ( grabEntity.GetGrabEntity() || grabEntity.GetThrownTime() > gameLocal.time ) ) ) { + StopFiring(); + weapon.GetEntity()->LowerWeapon(); +// <---sikk +// sikk---> Weapon Handling System + } else if ( GetWeaponHandling() ) { + if ( idealWeapon != currentWeapon ) + Weapon_Combat(); + StopFiring(); + weapon.GetEntity()->LowerWeapon(); +// <---sikk } else { Weapon_Combat(); } @@ -4069,6 +4415,12 @@ void idPlayer::UpdateWeapon( void ) { // update weapon state, particles, dlights, etc weapon.GetEntity()->PresentWeapon( showWeaponViewModel ); + +// sikk---> Object Manipulation + if ( g_grabMode.GetBool() && !g_dragEntity.GetBool() ) { + grabEntity.Update( this ); + } +// <---sikk } /* @@ -4186,6 +4538,9 @@ bool idPlayer::HandleSingleGuiCommand( idEntity *entityGui, idLexer *src ) { entityGui->GetRenderEntity()->gui[ 0 ]->SetStateInt( "gui_parm1", _health ); } health += amt; + + prevHeatlh = health; // sikk - Health Management System (Health Regen) + if ( health > 100 ) { health = 100; } @@ -4325,6 +4680,10 @@ void idPlayer::ClearFocus( void ) { focusUI = NULL; focusVehicle = NULL; talkCursor = 0; + focusItem = NULL; // sikk - Manual Item Pickup + focusCorpse = NULL; // sikk - Searchable Corpses + focusMoveable = NULL; // sikk - Object Manipulation + focusMoveableId = 0; // sikk - Object Manipulation } /* @@ -4543,6 +4902,47 @@ void idPlayer::UpdateFocus( void ) { } } +// sikk---> Use Function + gameLocal.clip.TracePoint( trace, start, end, MASK_SHOT_RENDERMODEL | CONTENTS_BODY, this ); + if ( trace.fraction < 1.0f ) { + ent = gameLocal.entities[ trace.c.entityNum ]; +// sikk---> Object Manipulation + if ( ent && ent->IsType( idMoveable::Type ) && g_grabMode.GetBool() ) { + ClearFocus(); + focusMoveable = ent; + focusMoveableId = trace.c.id; + focusTime = gameLocal.time + FOCUS_TIME; + focusMoveableTimer = gameLocal.time + 1000; + } +// <---sikk +// sikk---> Searchable Corpses + if ( ent && ent->IsType( idAFEntity_Gibbable::Type ) && g_itemSearchFactor.GetFloat() ) { + if ( static_cast( ent )->searchable && !static_cast( ent )->IsGibbed() ) { + if ( ent->IsType( idAI::Type ) ) { + if ( static_cast( ent )->IsDead() ) { + ClearFocus(); + focusCorpse = static_cast( ent ); + focusTime = gameLocal.time + FOCUS_TIME; + } + } else if ( static_cast( ent )->IsAtRest() ) { + ClearFocus(); + focusCorpse = static_cast( ent ); + focusTime = gameLocal.time + FOCUS_TIME; + } + } + } +// <---sikk +// sikk---> Item Management: Pickup Type + if ( ent && ent->IsType( idItem::Type ) && g_itemPickupType.GetBool() && !ent->spawnArgs.GetBool( "nopickup" ) ) { + ClearFocus(); + focusItem = static_cast( ent ); + focusMoveableId = trace.c.id; + focusTime = gameLocal.time + FOCUS_TIME; + } +// <---sikk + } +// <---sikk + if ( focusGUIent && focusUI ) { if ( !oldFocus || oldFocus != focusGUIent ) { // DG: tell the old UI it isn't focused anymore @@ -4999,8 +5399,12 @@ void idPlayer::SetCurrentHeartRate( void ) { int base = idMath::FtoiFast( ( BASE_HEARTRATE + LOWHEALTH_HEARTRATE_ADJ ) - ( (float) health / 100.0f ) * LOWHEALTH_HEARTRATE_ADJ ); - if ( PowerUpActive( ADRENALINE )) { + if ( PowerUpActive( ADRENALINE ) ) { heartRate = 135; +// sikk---> Health Management System (Health Regen) + } else if ( g_healthManagementType.GetInteger() == 2 && health < g_healthRegenLimit.GetInteger() && health > 0 ) { + heartRate = 130 - health; +// <---sikk } else { heartRate = idMath::FtoiFast( heartInfo.GetCurrentValue( gameLocal.time ) ); int currentRate = GetBaseHeartRate(); @@ -5031,6 +5435,13 @@ void idPlayer::SetCurrentHeartRate( void ) { pct += (float)zeroVol; if ( pct != zeroVol ) { +// sikk---> Health Management System (Health Regen) + if ( g_healthManagementType.GetInteger() == 2 && health < g_healthRegenLimit.GetInteger() && health > 0 ) { + float f = 40 * ( 1.0f - (float)health / g_healthRegenLimit.GetInteger() ) - 10; + if ( pct < f ) + pct = f; + } +// <---sikk StartSound( "snd_heartbeat", SND_CHANNEL_HEART, SSF_PRIVATE_SOUND, false, NULL ); // modify just this channel to a custom volume soundShaderParms_t parms; @@ -5054,7 +5465,7 @@ void idPlayer::UpdateAir( void ) { } // see if the player is connected to the info_vacuum - bool newAirless = false; + bool newAirless = false; if ( gameLocal.vacuumAreaNum != -1 ) { int num = GetNumPVSAreas(); @@ -5064,7 +5475,7 @@ void idPlayer::UpdateAir( void ) { // if the player box spans multiple areas, get the area from the origin point instead, // otherwise a rotating player box may poke into an outside area if ( num == 1 ) { - const int *pvsAreas = GetPVSAreas(); + const int *pvsAreas = GetPVSAreas(); areaNum = pvsAreas[0]; } else { areaNum = gameRenderWorld->PointInArea( this->GetPhysics()->GetOrigin() ); @@ -5093,6 +5504,14 @@ void idPlayer::UpdateAir( void ) { } } +// sikk---> Screen Frost + if ( g_screenFrostTime.GetInteger() ) { + int n = g_screenFrostTime.GetInteger() * 60; + nScreenFrostAlpha++; + nScreenFrostAlpha = ( nScreenFrostAlpha > n ) ? n : nScreenFrostAlpha; + } +// <---sikk + } else { if ( airless ) { StartSound( "snd_recompress", SND_CHANNEL_ANY, SSF_GLOBAL, false, NULL ); @@ -5105,6 +5524,14 @@ void idPlayer::UpdateAir( void ) { if ( airTics > pm_airTics.GetInteger() ) { airTics = pm_airTics.GetInteger(); } + +// sikk---> Screen Frost + if ( g_screenFrostTime.GetInteger() ) { + nScreenFrostAlpha -= 2; + nScreenFrostAlpha = ( nScreenFrostAlpha < 0 ) ? 0 : nScreenFrostAlpha; + } +// <---sikk + } airless = newAirless; @@ -5521,25 +5948,13 @@ void idPlayer::SetClipModel( void ) { idPlayer::UseVehicle ============== */ -void idPlayer::UseVehicle( void ) { - trace_t trace; - idVec3 start, end; - idEntity *ent; - - if ( GetBindMaster() && GetBindMaster()->IsType( idAFEntity_Vehicle::Type ) ) { - Show(); - static_cast(GetBindMaster())->Use( this ); +void idPlayer::UseVehicle( bool drive ) { + if ( drive ) { + Hide(); + focusVehicle->Use( this ); } else { - start = GetEyePosition(); - end = start + viewAngles.ToForward() * 80.0f; - gameLocal.clip.TracePoint( trace, start, end, MASK_SHOT_RENDERMODEL, this ); - if ( trace.fraction < 1.0f ) { - ent = gameLocal.entities[ trace.c.entityNum ]; - if ( ent && ent->IsType( idAFEntity_Vehicle::Type ) ) { - Hide(); - static_cast(ent)->Use( this ); - } - } + Show(); + static_cast( GetBindMaster() )->Use( this ); } } @@ -5568,6 +5983,7 @@ void idPlayer::PerformImpulse( int impulse ) { switch( impulse ) { case IMPULSE_13: { + nShowHudTimer = gameLocal.time + g_dynamicHudTime.GetInteger() * 1000; // sikk - Dynamic Hud System Reload(); break; } @@ -5625,10 +6041,73 @@ void idPlayer::PerformImpulse( int impulse ) { } break; } - case IMPULSE_40: { - UseVehicle(); + +// sikk---> Headlight Mod + case IMPULSE_23: { + if ( GetCurrentWeapon() < 11 && !gameLocal.inCinematic ) + ToggleHeadlight(); break; } +// <---sikk +// sikk---> Infrared Goggles PostProcess + case IMPULSE_24: { + if ( GetCurrentWeapon() != 12 && !gameLocal.inCinematic && ( !GetInfluenceMaterial() && GetInfluenceEntity() == NULL ) ) + ToggleIRGoggles(); + break; + } +// <---sikk +// sikk---> Health Management System (Health Pack) + case IMPULSE_25: { + if ( g_healthManagementType.GetInteger() == 1 ) + UseHealthPack(); + break; + } +// <---sikk +// sikk---> Arenaline Pack System + case IMPULSE_26: { + if ( !PowerUpActive( ADRENALINE ) ) + UseAdrenaline(); + break; + } +// <---sikk +// sikk---> Random Encounters System - Print info + case IMPULSE_27: { + gameLocal.Printf( "randomEnemyTally = %d list size = %d\n", gameLocal.randomEnemyTally, gameLocal.randomEnemyList.Num() ); + break; + } +// <---sikk +// sikk---> Use Function: Overriding the default UseVehicle() call but still allowing a vehicle to be used + case IMPULSE_40: { + bool valid = false; + if ( grabEntity.GetGrabEntity() ) { + grabEntity.StopDrag( this, true ); + valid = true; + } else { + if ( GetBindMaster() && GetBindMaster()->IsType( idAFEntity_Vehicle::Type ) ) { + UseVehicle( false ); + valid = true; + } else if ( focusVehicle ) { + UseVehicle( true ); + valid = true; + } else if ( focusItem ) { + if ( !focusItem->Pickup( this ) && grabEntity.GetThrownTime() < gameLocal.time ) + grabEntity.StartDrag( this, focusItem, focusMoveableId ); + valid = true; + } else if ( focusCorpse ) { + SearchCorpse( focusCorpse ); + valid = true; + } else if ( focusMoveable && grabEntity.GetThrownTime() < gameLocal.time ) { + grabEntity.StartDrag( this, focusMoveable, focusMoveableId ); + valid = true; + } + } + + if ( !valid ) + StartSoundShader( declManager->FindSound( "use_fail" ), SND_CHANNEL_VOICE, 0, false, NULL ); + + break; + } +// <---sikk } } @@ -5715,6 +6194,7 @@ void idPlayer::AdjustSpeed( void ) { bobFrac = stamina / pm_staminathreshold.GetFloat(); } speed = pm_walkspeed.GetFloat() * ( 1.0f - bobFrac ) + pm_runspeed.GetFloat() * bobFrac; + speed *= ( !g_weaponHandlingType.GetBool() && bIsZoomed ? 0.75f : 1.0f ); // sikk - Decreased movement speed when zoomed } else { rate = pm_staminarate.GetFloat(); @@ -5727,7 +6207,7 @@ void idPlayer::AdjustSpeed( void ) { if ( stamina > pm_stamina.GetFloat() ) { stamina = pm_stamina.GetFloat(); } - speed = pm_walkspeed.GetFloat(); + speed = pm_walkspeed.GetFloat() * ( bIsZoomed ? 0.75f : 1.0f ); // sikk - Decreased movement speed when zoomed bobFrac = 0.0f; } @@ -6125,6 +6605,73 @@ void idPlayer::UpdateHud( void ) { } else { hud->SetStateString( "hudLag", "0" ); } + +// sikk---> Crosshair Positioning + idStr buf; + if ( g_crosshairType.GetBool() && !GetTalkCursor() && !( focusItem || focusCorpse ) ) { + trace_t tr; + idVec3 ndc; + idVec3 muzzleOrigin; + idMat3 muzzleAxis; + + // detemine the point at which the weapon is aiming + if ( weapon.GetEntity()->GetBarrelJointView() != INVALID_JOINT && + weapon.GetEntity()->GetProjectileDict().GetBool( "launchFromBarrel" ) && + ( GetCurrentWeapon() < 6 || GetCurrentWeapon() > 8 ) ) { + // there is an explicit joint for the muzzle + weapon.GetEntity()->GetGlobalJointTransform( true, weapon.GetEntity()->GetBarrelJointView(), muzzleOrigin, muzzleAxis ); + } else { + // go straight out of the view + muzzleOrigin = firstPersonViewOrigin; + muzzleAxis = firstPersonViewAxis; + } + idVec3 endPos = muzzleOrigin + ( muzzleAxis.ToAngles().ToForward() * 65536.0f ); + gameLocal.clip.TracePoint( tr, muzzleOrigin, endPos, MASK_SHOT_RENDERMODEL, this ); + endPos = tr.endpos; + v3CrosshairPos.Lerp( endPos, v3CrosshairPos, g_crosshairLerp.GetFloat() ); + renderSystem->GlobalToNormalizedDeviceCoordinates( v3CrosshairPos, ndc ); + ndc.x = ( ( ndc.x * 0.5 + 0.5 ) * SCREEN_WIDTH ); + ndc.y = ( ( 1.0f - ( ndc.y * 0.5 + 0.5 ) ) * SCREEN_HEIGHT ); + sprintf( buf, "%d %d 100 32", (int)ndc.x - 16, (int)ndc.y - 16); + } else { + sprintf( buf, "%d %d 100 32", 304, 224 ); + } +// <---sikk + +// sikk---> Crosshair Cvar + int crosshairType = g_crosshair.GetInteger(); + if ( crosshairType == 0 ) { + cursor->SetStateString( "combatcursor", "0" ); + } else if ( crosshairType == 1 ) { + if ( !grabEntity.GetGrabEntity() && ( focusItem || focusCorpse || focusMoveable ) ) { + cursor->SetStateString( "combatcursor", "0" ); + cursor->SetStateString( "pickupcursor", "1" ); + } else { + cursor->SetStateString( "combatcursor", "1" ); + cursor->SetStateString( "pickupcursor", "0" ); + } + cursor->SetStateString( "cursorposition", buf ); + } else if ( crosshairType == 2 ) { + cursor->SetStateString( "cursorposition", buf ); + if ( ( bIsZoomed || GetTalkCursor() ) && + !( g_weaponHandlingType.GetBool() && ( bWATrace || bWAIsSprinting || OnLadder() ) ) && + ( GetCurrentWeapon() > 0 && GetCurrentWeapon() < 9 ) ) { + if ( !grabEntity.GetGrabEntity() && ( focusItem || focusCorpse || focusMoveable ) ) { + cursor->SetStateString( "combatcursor", "0" ); + cursor->SetStateString( "pickupcursor", "1" ); + } else { + cursor->SetStateString( "combatcursor", "1" ); + cursor->SetStateString( "pickupcursor", "0" ); + } + } else { + cursor->SetStateString( "combatcursor", "0" ); + if ( !grabEntity.GetGrabEntity() && ( focusItem || focusCorpse || focusMoveable ) ) + cursor->SetStateString( "pickupcursor", "1" ); + else + cursor->SetStateString( "pickupcursor", "0" ); + } + } +// <---sikk } /* @@ -6256,11 +6803,21 @@ void idPlayer::Think( void ) { if ( ( usercmd.buttons ^ oldCmd.buttons ) & BUTTON_ZOOM ) { if ( ( usercmd.buttons & BUTTON_ZOOM ) && weapon.GetEntity() ) { zoomFov.Init( gameLocal.time, 200.0f, CalcFov( false ), weapon.GetEntity()->GetZoomFov() ); + bIsZoomed = true; // sikk - Depth of Field PostProcess } else { zoomFov.Init( gameLocal.time, 200.0f, zoomFov.GetCurrentValue( gameLocal.time ), DefaultFov() ); + bIsZoomed = false; // sikk - Depth of Field PostProcess } } +// sikk---> Weapon Handling System + if ( g_weaponHandlingType.GetBool() && !weapon.GetEntity()->IsReady() && bIsZoomed ) { + zoomFov.Init( gameLocal.time, 200.0f, zoomFov.GetCurrentValue( gameLocal.time ), DefaultFov() ); + usercmd.buttons ^= BUTTON_ZOOM; + bIsZoomed = false; + } +// <---sikk + // if we have an active gui, we will unrotate the view angles as // we turn the mouse movements into gui events idUserInterface *gui = ActiveGui(); @@ -6337,6 +6894,15 @@ void idPlayer::Think( void ) { UpdateWeapon(); } +// sikk---> Global Ambient Light + if ( g_useAmbientLight.GetBool() ) + ToggleAmbientLight( true ); + else + ToggleAmbientLight( false ); +// <---sikk + + UpdateBattery(); // sikk--> Infrared Goggles/Headlight Mod + UpdateAir(); UpdateHud(); @@ -6363,6 +6929,25 @@ void idPlayer::Think( void ) { } } +// sikk---> First Person Body + idStr skinname = spawnArgs.GetString( "spawn_skin" ); + if ( g_showFirstPersonBody.GetBool() && !pm_thirdPerson.GetBool() && !gameLocal.inCinematic ) { + if ( skinname == "skins/characters/player/tshirt_mp" ) { + SetSkin( declManager->FindSkin( "skins/characters/player/tshirt_mp_fpb" ) ); + head.GetEntity()->SetModel( "head_player" ); + } else { + SetSkin( declManager->FindSkin( "skins/characters/player/greenmarine_fpb" ) ); + } + } else { + if ( skinname == "skins/characters/player/tshirt_mp" ) { + SetSkin( declManager->FindSkin( "skins/characters/player/tshirt_mp" ) ); + head.GetEntity()->SetModel( "head_player" ); + } else { + SetSkin( declManager->FindSkin( "skins/characters/player/greenmarine" ) ); + } + } +// <---sikk + if ( gameLocal.isMultiplayer || g_showPlayerShadow.GetBool() ) { renderEntity.suppressShadowInViewID = 0; if ( headRenderEnt ) { @@ -6406,6 +6991,21 @@ void idPlayer::Think( void ) { } gameLocal.Printf( "%d: enemies\n", num ); } + +// sikk---> Portal Sky Box + // determine if portal sky is in pvs + gameLocal.portalSkyActive = gameLocal.pvs.CheckAreasForPortalSky( gameLocal.GetPlayerPVS(), GetPhysics()->GetOrigin() ); +// <---sikk + +// sikk---> Random Encounters System + if ( g_useRandomEncounters.GetBool() && !gameLocal.inCinematic && gameLocal.randomEnemyTime <= gameLocal.time ) { + if ( gameLocal.SpawnRandomEnemy() ) { + gameLocal.randomEnemyTally++; + int randTime = gameLocal.random.RandomInt( g_randomEncountersMaxTime.GetInteger() - g_randomEncountersMinTime.GetInteger() ); + gameLocal.randomEnemyTime = gameLocal.time + ( randTime + g_randomEncountersMinTime.GetInteger() ) * 1000; + } + } +// <---sikk } /* @@ -6630,7 +7230,7 @@ void idPlayer::CalcDamagePoints( idEntity *inflictor, idEntity *attacker, const } } - damage *= damageScale; + damage *= damageScale * ( PowerUpActive( ADRENALINE ) ? 0.5f : 1.0f ); // always give half damage if hurting self if ( attacker == this ) { @@ -7167,9 +7767,10 @@ void idPlayer::OffsetThirdPersonView( float angle, float range, float height, bo angles = viewAngles; GetViewPos( origin, axis ); - if ( angle ) { - angles.pitch = 0.0f; - } +// sikk - commented out to allow camera to follow pitch when "pm_thirdPersonAngle" != 0 +// if ( angle ) { +// angles.pitch = 0.0f; +// } if ( angles.pitch > 45.0f ) { angles.pitch = 45.0f; // don't go too far overhead @@ -7185,7 +7786,11 @@ void idPlayer::OffsetThirdPersonView( float angle, float range, float height, bo idMath::SinCos( DEG2RAD( angle ), sideScale, forwardScale ); view -= range * forwardScale * renderView->viewaxis[ 0 ]; - view += range * sideScale * renderView->viewaxis[ 1 ]; + +// sikk---> Thirdpesron Camera - adjustable horizontal position +// view += range * sideScale * renderView->viewaxis[ 1 ]; + view += range * ( sideScale - ( pm_thirdPersonOffest.GetFloat() * 0.01 ) ) * renderView->viewaxis[ 1 ]; +// <---sikk if ( clip ) { // trace a ray from the origin to the viewpoint to make sure the view isn't @@ -7270,7 +7875,6 @@ idPlayer::CalculateFirstPersonView void idPlayer::CalculateFirstPersonView( void ) { if ( ( pm_modelView.GetInteger() == 1 ) || ( ( pm_modelView.GetInteger() == 2 ) && ( health <= 0 ) ) ) { // Displays the view from the point of view of the "camera" joint in the player model - idMat3 axis; idVec3 origin; idAngles ang; @@ -7278,10 +7882,12 @@ void idPlayer::CalculateFirstPersonView( void ) { ang = viewBobAngles + playerView.AngleOffset(); ang.yaw += viewAxis[ 0 ].ToYaw(); - jointHandle_t joint = animator.GetJointHandle( "camera" ); - animator.GetJointTransform( joint, gameLocal.time, origin, axis ); - firstPersonViewOrigin = ( origin + modelOffset ) * ( viewAxis * physicsObj.GetGravityAxis() ) + physicsObj.GetOrigin() + viewBob; - firstPersonViewAxis = axis * ang.ToMat3() * physicsObj.GetGravityAxis(); + jointHandle_t joint = animator.GetJointHandle( "camera" ); // sikk - Modified - "pm_modelView" Fix +// jointHandle_t joint = head.GetEntity()->GetAnimator()->GetJointHandle( "mouth12" ); // sikk - Added -"pm_modelView" Fix + GetViewPos( firstPersonViewOrigin, firstPersonViewAxis ); // sikk - Added -"pm_modelView" Fix + animator.GetJointTransform( joint, gameLocal.time, origin, axis ); // sikk - Commented - "pm_modelView" Fix + firstPersonViewOrigin = ( origin ) * ( viewAxis * physicsObj.GetGravityAxis() ) + physicsObj.GetOrigin() + viewBob; +// firstPersonViewAxis = axis * ang.ToMat3() * physicsObj.GetGravityAxis(); // sikk - Commented - "pm_modelView" Fix } else { // offset for local bobbing and kicks GetViewPos( firstPersonViewOrigin, firstPersonViewAxis ); @@ -7362,7 +7968,15 @@ void idPlayer::CalculateRenderView( void ) { // set the viewID to the clientNum + 1, so we can suppress the right player bodies and // allow the right player view weapons - renderView->viewID = entityNumber + 1; + if ( pm_modelView.GetInteger() == 0 ) { + renderView->viewID = entityNumber + 1; +// sikk---> First Person Body + if ( g_showFirstPersonBody.GetBool() ) + renderEntity.suppressSurfaceInViewID = 0; + else + renderEntity.suppressSurfaceInViewID = entityNumber + 1; +// <---sikk + } } // field of view @@ -7424,7 +8038,7 @@ void idPlayer::AddProjectilesFired( int count ) { /* ============= -idPlayer::AddProjectileHites +idPlayer::AddProjectileHits ============= */ void idPlayer::AddProjectileHits( int count ) { @@ -7907,11 +8521,12 @@ void idPlayer::ClientPredictionThink( void ) { headRenderEnt->suppressShadowInViewID = 0; } } else { - renderEntity.suppressShadowInViewID = entityNumber+1; + renderEntity.suppressShadowInViewID = entityNumber + 1; if ( headRenderEnt ) { - headRenderEnt->suppressShadowInViewID = entityNumber+1; + headRenderEnt->suppressShadowInViewID = entityNumber + 1; } } + // never cast shadows from our first-person muzzle flashes renderEntity.suppressShadowInLightID = LIGHTID_VIEW_MUZZLE_FLASH + entityNumber; if ( headRenderEnt ) { @@ -7935,6 +8550,13 @@ void idPlayer::ClientPredictionThink( void ) { if ( gameLocal.isNewFrame && entityNumber == gameLocal.localClientNum ) { playerView.CalculateShake(); } + +// sikk---> Portal Sky Box + // determine if portal sky is in pvs + pvsHandle_t clientPVS = gameLocal.pvs.SetupCurrentPVS( GetPVSAreas(), GetNumPVSAreas() ); + gameLocal.portalSkyActive = gameLocal.pvs.CheckAreasForPortalSky( clientPVS, GetPhysics()->GetOrigin() ); + gameLocal.pvs.FreeCurrentPVS( clientPVS ); +// <---sikk } /* @@ -8532,3 +9154,439 @@ bool idPlayer::NeedsIcon( void ) { // local clients don't render their own icons... they're only info for other clients return entityNumber != gameLocal.localClientNum && ( isLagged || isChatting ); } + +// sikk---> Depth Render +/* +================== +idPlayer::ToggleSuppression +================== +*/ +void idPlayer::ToggleSuppression( bool bSuppress ) { + int headHandle = head.GetEntity()->GetModelDefHandle(); + int weaponHandle = weapon.GetEntity()->GetModelDefHandle(); + int weaponWorldHandle = weapon.GetEntity()->GetWorldModel()->GetEntity()->GetModelDefHandle(); + renderEntity_t *headRenderEntity = head.GetEntity()->GetRenderEntity(); + renderEntity_t *weaponRenderEntity = weapon.GetEntity()->GetRenderEntity(); + renderEntity_t *weaponWorldRenderEntity = weapon.GetEntity()->GetWorldModel()->GetEntity()->GetRenderEntity(); + + if ( bSuppress ) { + if ( modelDefHandle != -1 ) { +// sikk---> First Person Body + if ( !g_showFirstPersonBody.GetBool() ) { + // suppress body in DoF render view + renderEntity.suppressSurfaceInViewID = -8; + gameRenderWorld->UpdateEntityDef( modelDefHandle, &renderEntity ); + } +// <---sikk + if ( head.GetEntity() && headHandle != -1 ) { + // suppress head in DoF render view + headRenderEntity->suppressSurfaceInViewID = -8; + gameRenderWorld->UpdateEntityDef( headHandle, headRenderEntity ); + } + + if ( weaponEnabled && weapon.GetEntity() && weaponHandle != -1 ) { + // allow weapon view model in DoF render view + weaponRenderEntity->allowSurfaceInViewID = -8; + gameRenderWorld->UpdateEntityDef( weaponHandle, weaponRenderEntity ); + + if ( weaponWorldHandle != -1 ) { + // suppress weapon world model in DoF render view + weaponWorldRenderEntity->suppressSurfaceInViewID = -8; + gameRenderWorld->UpdateEntityDef( weaponWorldHandle, weaponWorldRenderEntity ); + } + } + } + + bViewModelsModified = true; + } else { + if ( modelDefHandle != -1 ) { + // restore suppression of body + renderEntity.suppressSurfaceInViewID = entityNumber + 1; + gameRenderWorld->UpdateEntityDef( modelDefHandle, &renderEntity ); + + if ( head.GetEntity() && headHandle != -1 ) { + // restore suppression of head + headRenderEntity->suppressSurfaceInViewID = entityNumber + 1; + gameRenderWorld->UpdateEntityDef( headHandle, headRenderEntity ); + } + + if ( weaponEnabled && weapon.GetEntity() && weaponHandle != -1 ) { + // restore allowance of weapon view model + weaponRenderEntity->allowSurfaceInViewID = entityNumber + 1; + gameRenderWorld->UpdateEntityDef( weaponHandle, weaponRenderEntity ); + + if ( weaponWorldHandle != -1 ) { + // restore suppression of weapon world model + weaponWorldRenderEntity->suppressSurfaceInViewID = entityNumber + 1; + gameRenderWorld->UpdateEntityDef( weaponWorldHandle, weaponWorldRenderEntity ); + } + } + } + + bViewModelsModified = false; + } +} +// <---sikk + +// sikk---> Infrared Goggles/Headlight/Ambient light Mod +/* +================== +idPlayer::UpdateBattery +================== +*/ +void idPlayer::UpdateBattery() { + // update ir goggle's battery usage + if ( bIRGogglesOn ) { + if ( nIRGogglesTime <= gameLocal.time ) { + nBattery--; + nIRGogglesTime = ( g_batteryLife.GetInteger() * 10 ) + gameLocal.time; + } + if ( nBattery <= 0 ) { + nBattery = 0; + ToggleIRGoggles(); + } else if ( GetCurrentWeapon() == 12 || gameLocal.inCinematic || PowerUpActive( BERSERK ) || ( GetInfluenceMaterial() || GetInfluenceEntity() ) ) { + ToggleIRGoggles(); + } + } + + // update headlight's battery usage + if ( bHeadlightOn ) { + idEntity *ent = gameLocal.FindEntity( name + "_headlight" ); + + if ( nHeadlightTime <= gameLocal.time ) { + nHeadlightTime = ( g_batteryLife.GetInteger() * 10 ) + gameLocal.time; + nBattery--; + } + + // update headlight angle and intensity + if ( ent ) { + ent->SetAngles( viewAngles ); + + if ( nBattery > 5 ) + fIntensity = 1.0f; + else { + fIntensity = fIntensity * 0.95 + ( nBattery * 0.2 ) * 0.05; + } + + static_cast( ent )->SetLightParms( 1.0f, 1.0f, 1.0f, fIntensity ); + } + + if ( nBattery <= 0 ) { + nBattery = 0; + ToggleHeadlight(); + } else if ( GetCurrentWeapon() >= 11 || gameLocal.inCinematic ) { + ToggleHeadlight(); + } + } + + if ( nBattery < 100 && !bIRGogglesOn && !bHeadlightOn ) { + if ( nHeadlightTime <= gameLocal.time && nIRGogglesTime <= gameLocal.time ) { + nHeadlightTime = nIRGogglesTime = ( g_batteryRechargeRate.GetInteger() * 10 ) + gameLocal.time; + nBattery++; + } + if ( nBattery >= 100 ) + nBattery = 100; + } + + // update hud element + if ( hud ) { + hud->SetStateInt( "player_battery", nBattery ); + hud->HandleNamedEvent( "UpdateBattery" ); + } +} + +/* +================== +idPlayer::ToggleIRGoggles +================== +*/ +void idPlayer::ToggleIRGoggles() { + if ( !gameLocal.GetLocalPlayer() ) + return; + + bIRGogglesOn = !bIRGogglesOn; + + if ( bIRGogglesOn ) { + idEntity *ent; + idDict args; + + // play sound + StartSoundShader( declManager->FindSound( "player_sounds_irgoggles_on" ), SND_CHANNEL_VOICE, 0, false, NULL ); + + if ( !g_goggleType.GetBool() ) { + // spawn ir ambient light + args.Set( "classname", "light" ); + args.Set( "name", name + "_irlight" ); // light name + args.Set( "texture", "lights/ambientLight" ); // light texture + args.Set( "_color", "0.0625 0.0625 0.0625" ); // light color + args.Set( "light_radius", "512 512 512" ); // light radius + args.Set( "light_center", "-256 0 0" ); // light center + gameLocal.SpawnEntityDef( args, &ent ); + ent->Bind( this, true ); // light bind parent + ent->SetOrigin( idVec3( 256, 0, 48 ) ); // light origin + } + + // save current bloom parms + fIRBloomParms[ 0 ] = r_useBloom.GetBool(); + fIRBloomParms[ 1 ] = r_bloomBufferSize.GetInteger(); + fIRBloomParms[ 2 ] = r_bloomBlurIterations.GetInteger(); + fIRBloomParms[ 3 ] = r_bloomBlurScaleX.GetFloat(); + fIRBloomParms[ 4 ] = r_bloomBlurScaleY.GetFloat(); + fIRBloomParms[ 5 ] = r_bloomScale.GetFloat(); + fIRBloomParms[ 6 ] = r_bloomGamma.GetFloat(); + + if ( !g_goggleType.GetBool() ) { + // set specific bloom parms for ir + r_useBloom.SetBool( true ); + r_bloomBufferSize.SetInteger( 2 ); + r_bloomBlurIterations.SetInteger( 1 ); + r_bloomBlurScaleX.SetFloat( 1.0f ); + r_bloomBlurScaleY.SetFloat( 1.0f ); + r_bloomScale.SetFloat( 1.25f ); + r_bloomGamma.SetFloat( 1.25f ); + } + } else { + // play sound + StartSoundShader( declManager->FindSound( "player_sounds_irgoggles_off" ), SND_CHANNEL_VOICE, 0, false, NULL ); + + // reset bloom parms + r_useBloom.SetBool( (bool)fIRBloomParms[ 0 ] ); + r_bloomBufferSize.SetInteger( (int)fIRBloomParms[ 1 ] ); + r_bloomBlurIterations.SetInteger( (int)fIRBloomParms[ 2 ] ); + r_bloomBlurScaleX.SetFloat( (int)fIRBloomParms[ 3 ] ); + r_bloomBlurScaleY.SetFloat( fIRBloomParms[ 4 ] ); + r_bloomScale.SetFloat( fIRBloomParms[ 5 ] ); + r_bloomGamma.SetFloat( fIRBloomParms[ 6 ] ); + + // find and remove ir ambient light + idEntity *ent = gameLocal.FindEntity( name + "_irlight" ); + if ( !ent ) + return; + delete ent; + } +} + +/* +================== +idPlayer::ToggleHeadlight +================== +*/ +void idPlayer::ToggleHeadlight() { + if ( !gameLocal.GetLocalPlayer() ) + return; + + bHeadlightOn = !bHeadlightOn; + + if ( bHeadlightOn ) { + idEntity *ent; + idDict args; + + // play sound + StartSoundShader( declManager->FindSound( "player_sounds_headlight_on" ), SND_CHANNEL_VOICE, 0, false, NULL ); + + // spawn headlight light + args.Set( "classname", "light" ); + args.Set( "name", name + "_headlight" ); // light name + args.Set( "texture", "lights/headlight" ); // light texture + args.Set( "light_target", "768 0 0" ); // light cone direction + args.Set( "light_up", "0 0 192" ); // light cone height + args.Set( "light_right", "0 -192 0" ); // light cone width + gameLocal.SpawnEntityDef( args, &ent ); + ent->BindToJoint( this, "head", 0.0f ); // light bind parent joint + ent->SetOrigin( idVec3( 8, -12, 4 ) ); // light origin + ent->SetAngles( viewAngles ); // light angle + } else { + // play sound + StartSoundShader( declManager->FindSound( "player_sounds_headlight_off" ), SND_CHANNEL_VOICE, 0, false, NULL ); + + // find and remove headlight light + idEntity *ent = gameLocal.FindEntity( name + "_headlight" ); + if ( !ent ) + return; + delete ent; + } +} + +/* +================== +idPlayer::ToggleAmbientLight +================== +*/ +void idPlayer::ToggleAmbientLight( bool bOn ) { + if ( !gameLocal.GetLocalPlayer() ) + return; + + idEntity *ent; + renderView_t *rv = GetRenderView(); + + // this is so we update on any changes to color or radius + if ( bOn && bAmbientLightOn ) { + ent = gameLocal.FindEntity( name + "_ambientlight" ); + if ( !ent ) { + bAmbientLightOn = false; + return; + } + + // update light origin & angle + ent->SetOrigin( rv->vieworg + ( rv->viewaxis.ToAngles().ToForward() * 256.0f ) ); // light origin +// ent->SetAngles( rv->viewaxis.ToAngles() ); // light angle + + // this is so we update on any changes to color or radius + // we remove it and spawn it again below + if ( szAmbientLightColor != g_ambientLightColor.GetString() || + szAmbientLightRadius != g_ambientLightRadius.GetString() ) { + // remove ambient light + delete ent; + bAmbientLightOn = false; + } + } + + szAmbientLightColor = g_ambientLightColor.GetString(); + szAmbientLightRadius = g_ambientLightRadius.GetString(); + + if ( bOn && !bAmbientLightOn ) { + idEntity *ent; + idDict args; + + // spawn ambient light + args.Set( "classname", "light" ); + args.Set( "name", name + "_ambientlight" ); // light name + args.Set( "texture", "lights/ambientLight" ); // light texture + args.Set( "_color", szAmbientLightColor ); // light color + args.Set( "light_radius", szAmbientLightRadius ); // light radius + gameLocal.SpawnEntityDef( args, &ent ); + + ent->SetOrigin( rv->vieworg + ( rv->viewaxis.ToAngles().ToForward() * 256.0f ) ); // light origin + + bAmbientLightOn = true; + } else if ( !bOn && bAmbientLightOn ) { + // find and remove ambient light + idEntity *ent = gameLocal.FindEntity( name + "_ambientlight" ); + if ( !ent ) { + bAmbientLightOn = false; + return; + } + delete ent; + bAmbientLightOn = false; + } +} +// <---sikk + +// sikk---> Health Management System (Health Pack) +/* +================== +idPlayer::UseHealthPack +================== +*/ +void idPlayer::UseHealthPack() { + if ( ( health > 0 ) && ( health < inventory.maxHealth ) && healthPackAmount ) { + int oldhealth = health; + int oldhealthPackAmount = healthPackAmount; + + healthPackAmount -= g_healthPackTotal.GetInteger() / g_healthPackUses.GetInteger(); + healthPackAmount = ( healthPackAmount < 0 ) ? 0 : healthPackAmount; + + health += ( oldhealthPackAmount - healthPackAmount ); + if ( health > inventory.maxHealth ) + health = inventory.maxHealth; + if ( hud ) + hud->HandleNamedEvent( "healthPulse" ); + + int time = ( health - oldhealth ) * g_healthPackTime.GetInteger() * 10; + time = ( time < 1000 ) ? 1000 : time; + healthPackTimer = gameLocal.time + time; + StartSoundShader( declManager->FindSound( "pack_pickup" ), SND_CHANNEL_ITEM, 0, false, NULL ); + } +} +// <---sikk + +// sikk---> Adrenaline Pack System +/* +================== +idPlayer::UseAdrenaline +================== +*/ +void idPlayer::UseAdrenaline() { + if ( adrenalineAmount ) { + inventory.GivePowerUp( this, ADRENALINE, 0 ); + StartSoundShader( declManager->FindSound( "pickup_adrenaline" ), SND_CHANNEL_ITEM, 0, false, NULL ); + stamina = 100.0f; + adrenalineAmount = 0; + } +} +// <---sikk + +// sikk---> Searchable Corpses +/* +================== +idPlayer::SearchCorpse +================== +*/ +void idPlayer::SearchCorpse( idAFEntity_Gibbable* corpse ) { + StartSoundShader( declManager->FindSound( "use_search" ), SND_CHANNEL_VOICE, 0, false, NULL ); + searchTimer = gameLocal.time + 1500; + corpse->searchable = false; + + if ( g_itemSearchFactor.GetFloat() >= gameLocal.random.RandomFloat() ) { + idEntity *ent; + idDict args; + idVec3 itemOrg = GetEyePosition() + viewAngles.ToForward() * 32.0f; + + float random = gameLocal.random.RandomFloat(); + const char* defItem = corpse->spawnArgs.GetString( "def_searchItem" ); + if ( defItem == "" ) { + if ( random <= 0.1 ) + defItem = "powerup_adrenaline"; + else if ( random <= 0.5 ) + defItem = "item_medkit_small"; + else + defItem = "item_armor_shard"; + } else { + if ( random <= 0.05 ) + defItem = "powerup_adrenaline"; + else if ( random <= 0.33333333 ) + defItem = "item_medkit_small"; + else if ( random <= 0.66666666 ) + defItem = "item_armor_shard"; + } + + args.Set( "classname", defItem ); + args.Set( "removeable", "0" ); + args.SetVector( "origin", itemOrg ); + gameLocal.SpawnEntityDef( args, &ent ); + } +} +// <---sikk + +// sikk---> Weapon Handling System +/* +================== +idPlayer::GetWeaponHandling +================== +*/ +bool idPlayer::GetWeaponHandling() { + if ( g_weaponHandlingType.GetBool() ) { + idEntity *ent; + trace_t trace; + idVec3 start = GetEyePosition(); + idVec3 end = start + viewAngles.ToForward() * 32.0f; + gameLocal.clip.TracePoint( trace, start, end, MASK_SHOT_RENDERMODEL, this ); + bWATrace = false; + + if ( ( trace.fraction < 1.0f ) && ( GetCurrentWeapon() > 0 && GetCurrentWeapon() < 9 ) ) { + ent = gameLocal.entities[ trace.c.entityNum ]; + if ( ent && !ent->IsType( idAI::Type ) ) + bWATrace = true; + if ( ent->GetBindMaster() && ent->GetBindMaster()->IsType( idAI::Type ) ) + bWATrace = false; + } + + bWAIsSprinting = ( ( GetCurrentWeapon() > 0 ) && AI_RUN && ( AI_FORWARD || AI_BACKWARD || AI_STRAFE_LEFT || AI_STRAFE_RIGHT ) ); + + if ( bWATrace || bWAIsSprinting || OnLadder() ) + return true; + } + + return false; +} +// <---sikk diff --git a/game/Player.h b/game/Player.h index b411a0c..050ab70 100644 --- a/game/Player.h +++ b/game/Player.h @@ -194,6 +194,9 @@ public: int onePickupTime; idList pickupItemNames; idList objectiveNames; + + int healthPackAmount; // sikk - Health Management System (Health Pack) + int adrenalineAmount; // sikk - Adrenaline Pack System }; typedef struct { @@ -284,7 +287,6 @@ public: bool healthTake; int nextHealthTake; - bool hiddenWeapon; // if the weapon is hidden ( in noWeapons maps ) idEntityPtr soulCubeProjectile; @@ -524,6 +526,80 @@ public: bool SelfSmooth( void ); void SetSelfSmooth( bool b ); + int nScreenFrostAlpha; // sikk - Screen Frost + + int nShowHudTimer; // sikk - Dynamic hud system - Used to say when to show the hud as well as fade it in/out (just for health/armor/ammo/weapon changes) + + idItem* focusItem; // sikk - Manual Item Pickup + +// sikk---> Searchable Corpses + void SearchCorpse( idAFEntity_Gibbable* corpse ); + idAFEntity_Gibbable* focusCorpse; + int searchTimer; +// <---sikk + +// sikk---> Object Manipulation + idGrabEntity grabEntity; + idEntity* focusMoveable; + int focusMoveableId; + int focusMoveableTimer; +// <---sikk + +// sikk---> Adrenaline Pack System + void UseAdrenaline( void ); + int adrenalineAmount; +// <---sikk + +// sikk---> Health Management System + void UseHealthPack( void ); + int healthPackAmount; + int healthPackTimer; + int nextHealthRegen; + int prevHeatlh; // sikk - holds player health after Health station has been used +// <---sikk + +// sikk---> Crosshair Positioning + int GetCurrentWeapon( void ) { return currentWeapon; }; + idVec3 v3CrosshairPos; +// <---sikk + +// sikk---> Weapon Handling System + bool GetWeaponHandling( void ); + bool bWATrace; + bool bWAIsSprinting; +// <---sikk + +// sikk---> Depth Render + void ToggleSuppression( bool bSuppress ); + bool bViewModelsModified; +// <---sikk + +// sikk---> Depth of Field PostProcess + int GetTalkCursor( void ) { return talkCursor; }; // used to check if character has focus + bool bIsZoomed; +// <---sikk + +// sikk---> Global Ambient Light + void ToggleAmbientLight( bool bOn ); + bool bAmbientLightOn; + idStr szAmbientLightColor; + idStr szAmbientLightRadius; +// <---sikk + +// sikk---> Infrared Goggles/Headlight Mod + void UpdateBattery( void ); + void ToggleIRGoggles( void ); + void ToggleHeadlight( void ); + + bool bIRGogglesOn; + bool bHeadlightOn; + int nIRGogglesTime; + int nHeadlightTime; + int nBattery; + float fIntensity; + float fIRBloomParms[ 7 ]; +// <---sikk + private: jointHandle_t hipJoint; jointHandle_t chestJoint; @@ -675,7 +751,7 @@ private: void ExtractEmailInfo( const idStr &email, const char *scan, idStr &out ); void UpdateObjectiveInfo( void ); - void UseVehicle( void ); + void UseVehicle( bool drive ); void Event_GetButtons( void ); void Event_GetMove( void ); diff --git a/game/PlayerView.cpp b/game/PlayerView.cpp index 149b829..2c4e489 100644 --- a/game/PlayerView.cpp +++ b/game/PlayerView.cpp @@ -37,6 +37,15 @@ If you have questions concerning this license or the applicable additional terms #include "PlayerView.h" const int IMPULSE_DELAY = 150; + +// sikk---> Portal Sky Box +static int MakePowerOfTwo( int num ) { + int pot; + for ( pot = 1; pot < num; pot <<= 1 ) {} + return pot; +} +// <---sikk + /* ============== idPlayerView::idPlayerView @@ -45,22 +54,74 @@ idPlayerView::idPlayerView idPlayerView::idPlayerView() { memset( screenBlobs, 0, sizeof( screenBlobs ) ); memset( &view, 0, sizeof( view ) ); - player = NULL; - dvMaterial = declManager->FindMaterial( "_scratch" ); - tunnelMaterial = declManager->FindMaterial( "textures/decals/tunnel" ); - armorMaterial = declManager->FindMaterial( "armorViewEffect" ); - berserkMaterial = declManager->FindMaterial( "textures/decals/berserk" ); - irGogglesMaterial = declManager->FindMaterial( "textures/decals/irblend" ); - bloodSprayMaterial = declManager->FindMaterial( "textures/decals/bloodspray" ); - bfgMaterial = declManager->FindMaterial( "textures/decals/bfgvision" ); - lagoMaterial = declManager->FindMaterial( LAGO_MATERIAL, false ); - bfgVision = false; - dvFinishTime = 0; - kickFinishTime = 0; + player = NULL; + + armorMaterial = declManager->FindMaterial( "armorViewEffect" ); + tunnelMaterial = declManager->FindMaterial( "textures/decals/tunnel" ); + berserkMaterial = declManager->FindMaterial( "textures/decals/berserk" ); +// irGogglesMaterial = declManager->FindMaterial( "textures/decals/irblend" ); + irGogglesMaterial = declManager->FindMaterial( "postProcess/irGoggles" ); // sikk - Infrared Goggles PostProcess Effect + bloodSprayMaterial = declManager->FindMaterial( "textures/decals/bloodspray" ); + bfgMaterial = declManager->FindMaterial( "textures/decals/bfgvision" ); + lagoMaterial = declManager->FindMaterial( LAGO_MATERIAL, false ); + +// sikk---> PostProcess Effects + blackMaterial = declManager->FindMaterial( "_black" ); + whiteMaterial = declManager->FindMaterial( "_white" ); + currentRenderMaterial = declManager->FindMaterial( "_currentRender" ); + scratchMaterial = declManager->FindMaterial( "_scratch" ); + depthMaterial = declManager->FindMaterial( "render/depth" ); + normalsMaterial = declManager->FindMaterial( "render/normals" ); + softShadowsMaterial = declManager->FindMaterial( "postProcess/softShadows" ); + edgeAAMaterial = declManager->FindMaterial( "postProcess/edgeAA" ); + hdrLumBaseMaterial = declManager->FindMaterial( "postProcess/hdrLumBase" ); + hdrLumAverageMaterial = declManager->FindMaterial( "postProcess/hdrLumAverage" ); + hdrLumAdaptedMaterial = declManager->FindMaterial( "postProcess/hdrLumAdapted" ); + hdrBrightPass1Material = declManager->FindMaterial( "postProcess/hdrBrightPass1" ); + hdrBrightPass2Material = declManager->FindMaterial( "postProcess/hdrBrightPass2" ); + hdrBrightPass3Material = declManager->FindMaterial( "postProcess/hdrBrightPass3" ); + hdrBrightPass4Material = declManager->FindMaterial( "postProcess/hdrBrightPass4" ); + hdrBrightPass5Material = declManager->FindMaterial( "postProcess/hdrBrightPass5" ); + hdrBloomMaterial = declManager->FindMaterial( "postProcess/hdrBloom" ); + hdrFlareMaterial = declManager->FindMaterial( "postProcess/hdrFlare" ); + hdrGlareMaterial = declManager->FindMaterial( "postProcess/hdrGlare" ); + hdrFinalMaterial = declManager->FindMaterial( "postProcess/hdrFinal" ); + bloomMaterial = declManager->FindMaterial( "postProcess/bloom" ); + ssilMaterial = declManager->FindMaterial( "postProcess/ssil" ); + ssaoMaterial = declManager->FindMaterial( "postProcess/ssao" ); + sunShaftsMaterial = declManager->FindMaterial( "postProcess/sunShafts" ); + lensFlareMaterial = declManager->FindMaterial( "postProcess/lensFlare" ); + dofMaterial = declManager->FindMaterial( "postProcess/dof" ); + motionBlurMaterial = declManager->FindMaterial( "postProcess/motionBlur" ); + colorGradingMaterial = declManager->FindMaterial( "postProcess/colorGrading" ); + explosionFXMaterial = declManager->FindMaterial( "postProcess/explosionFX" ); + screenFrostMaterial = declManager->FindMaterial( "postProcess/screenFrost" ); + celShadingMaterial = declManager->FindMaterial( "postProcess/celShading" ); + filmgrainMaterial = declManager->FindMaterial( "postProcess/filmgrain" ); + vignettingMaterial = declManager->FindMaterial( "postProcess/vignetting" ); + tunnel2Material = declManager->FindMaterial( "postProcess/tunnel" ); + adrenalineMaterial = declManager->FindMaterial( "postProcess/adrenaline" ); + bSoftShadows = false; + bDepthRendered = false; + bDitherRendered = false; + focusDistance = 0.0f; + prevViewAngles.Zero(); +// <---sikk + +// sikk---> Explosion FX PostProcess + gameLocal.explosionOrigin.Zero(); + gameLocal.explosionRadius = 0; + gameLocal.explosionDamage = 0; + gameLocal.explosionTime = 0; +// <---sikk + + bfgVision = false; + dvFinishTime = 0; + kickFinishTime = 0; kickAngles.Zero(); - lastDamageTime = 0.0f; - fadeTime = 0; - fadeRate = 0.0; + lastDamageTime = 0.0f; + fadeTime = 0; + fadeRate = 0.0; fadeFromColor.Zero(); fadeToColor.Zero(); fadeColor.Zero(); @@ -95,7 +156,7 @@ void idPlayerView::Save( idSaveGame *savefile ) const { } savefile->WriteInt( dvFinishTime ); - savefile->WriteMaterial( dvMaterial ); + savefile->WriteMaterial( scratchMaterial ); savefile->WriteInt( kickFinishTime ); savefile->WriteAngles( kickAngles ); savefile->WriteBool( bfgVision ); @@ -130,7 +191,7 @@ void idPlayerView::Restore( idRestoreGame *savefile ) { screenBlob_t *blob; blob = &screenBlobs[ 0 ]; - for( i = 0; i < MAX_SCREEN_BLOBS; i++, blob++ ) { + for ( i = 0; i < MAX_SCREEN_BLOBS; i++, blob++ ) { savefile->ReadMaterial( blob->material ); savefile->ReadFloat( blob->x ); savefile->ReadFloat( blob->y ); @@ -146,7 +207,7 @@ void idPlayerView::Restore( idRestoreGame *savefile ) { } savefile->ReadInt( dvFinishTime ); - savefile->ReadMaterial( dvMaterial ); + savefile->ReadMaterial( scratchMaterial ); savefile->ReadInt( kickFinishTime ); savefile->ReadAngles( kickAngles ); savefile->ReadBool( bfgVision ); @@ -191,7 +252,7 @@ void idPlayerView::ClearEffects() { dvFinishTime = ( gameLocal.time - 99999 ); kickFinishTime = ( gameLocal.time - 99999 ); - for ( int i = 0 ; i < MAX_SCREEN_BLOBS ; i++ ) { + for ( int i = 0; i < MAX_SCREEN_BLOBS; i++ ) { screenBlobs[i].finishTime = gameLocal.time; } @@ -205,7 +266,7 @@ idPlayerView::GetScreenBlob ============== */ screenBlob_t *idPlayerView::GetScreenBlob() { - screenBlob_t *oldest = &screenBlobs[0]; + screenBlob_t *oldest = &screenBlobs[0]; for ( int i = 1 ; i < MAX_SCREEN_BLOBS ; i++ ) { if ( screenBlobs[i].finishTime < oldest->finishTime ) { @@ -224,15 +285,12 @@ which will determine the head kick direction ============== */ void idPlayerView::DamageImpulse( idVec3 localKickDir, const idDict *damageDef ) { - // - // double vision effect - // + // keep shotgun from obliterating the view if ( lastDamageTime > 0.0f && SEC2MS( lastDamageTime ) + IMPULSE_DELAY > gameLocal.time ) { - // keep shotgun from obliterating the view return; } - float dvTime = damageDef->GetFloat( "dv_time" ); + float dvTime = damageDef->GetFloat( "dv_time" ); if ( dvTime ) { if ( dvFinishTime < gameLocal.time ) { dvFinishTime = gameLocal.time; @@ -244,23 +302,18 @@ void idPlayerView::DamageImpulse( idVec3 localKickDir, const idDict *damageDef ) } } - // // head angle kick - // - float kickTime = damageDef->GetFloat( "kick_time" ); + float kickTime = damageDef->GetFloat( "kick_time" ); if ( kickTime ) { kickFinishTime = gameLocal.time + g_kickTime.GetFloat() * kickTime; // forward / back kick will pitch view kickAngles[0] = localKickDir[0]; - // side kick will yaw view - kickAngles[1] = localKickDir[1]*0.5f; - + kickAngles[1] = localKickDir[1] * 0.5f; // up / down kick will pitch view kickAngles[0] += localKickDir[2]; - - // roll will come from side + // roll will come from side kickAngles[2] = localKickDir[1]; float kickAmplitude = damageDef->GetFloat( "kick_amplitude" ); @@ -269,23 +322,23 @@ void idPlayerView::DamageImpulse( idVec3 localKickDir, const idDict *damageDef ) } } - // // screen blob - // - float blobTime = damageDef->GetFloat( "blob_time" ); + float blobTime = damageDef->GetFloat( "blob_time" ); if ( blobTime ) { - screenBlob_t *blob = GetScreenBlob(); + screenBlob_t *blob = GetScreenBlob(); blob->startFadeTime = gameLocal.time; blob->finishTime = gameLocal.time + blobTime * g_blobTime.GetFloat(); + + blob->driftAmount = 0.0f; // sikk - Blood Spray Screen Effect - keeps damage blood splats from drifting const char *materialName = damageDef->GetString( "mtr_blob" ); blob->material = declManager->FindMaterial( materialName ); blob->x = damageDef->GetFloat( "blob_x" ); - blob->x += ( gameLocal.random.RandomInt()&63 ) - 32; + blob->x += ( gameLocal.random.RandomInt() & 63 ) - 32; blob->y = damageDef->GetFloat( "blob_y" ); - blob->y += ( gameLocal.random.RandomInt()&63 ) - 32; + blob->y += ( gameLocal.random.RandomInt() & 63 ) - 32; - float scale = ( 256 + ( ( gameLocal.random.RandomInt()&63 ) - 32 ) ) / 256.0f; + float scale = ( 256 + ( ( gameLocal.random.RandomInt() & 63 ) - 32 ) ) / 256.0f; blob->w = damageDef->GetFloat( "blob_width" ) * g_blobSize.GetFloat() * scale; blob->h = damageDef->GetFloat( "blob_height" ) * g_blobSize.GetFloat() * scale; blob->s1 = 0; @@ -294,11 +347,8 @@ void idPlayerView::DamageImpulse( idVec3 localKickDir, const idDict *damageDef ) blob->t2 = 1; } - // - // save lastDamageTime for tunnel vision accentuation - // + // save lastDamageTime for tunnel vision attenuation lastDamageTime = MS2SEC( gameLocal.time ); - } /* @@ -310,10 +360,18 @@ but having it localized here lets the material be pre-looked up etc. ================== */ void idPlayerView::AddBloodSpray( float duration ) { -/* if ( duration <= 0 || bloodSprayMaterial == NULL || g_skipViewEffects.GetBool() ) { return; } + +// sikk---> Blood Spray Screen Effect + // Use random material + if ( gameLocal.random.RandomFloat() < 0.5f ) + bloodSprayMaterial = declManager->FindMaterial( "postProcess/bloodspray1" ); + else + bloodSprayMaterial = declManager->FindMaterial( "postProcess/bloodspray2" ); +// <---sikk + // visit this for chainsaw screenBlob_t *blob = GetScreenBlob(); blob->startFadeTime = gameLocal.time; @@ -321,15 +379,16 @@ void idPlayerView::AddBloodSpray( float duration ) { blob->material = bloodSprayMaterial; blob->x = ( gameLocal.random.RandomInt() & 63 ) - 32; blob->y = ( gameLocal.random.RandomInt() & 63 ) - 32; - blob->driftAmount = 0.5f + gameLocal.random.CRandomFloat() * 0.5; - float scale = ( 256 + ( ( gameLocal.random.RandomInt()&63 ) - 32 ) ) / 256.0f; - blob->w = 600 * g_blobSize.GetFloat() * scale; + blob->driftAmount = 0.0f;// 0.5f + gameLocal.random.CRandomFloat() * 0.5f; // sikk - No more drifting + float scale = ( 256 + ( ( gameLocal.random.RandomInt() & 63 ) - 32 ) ) / 256.0f; + blob->w = 640 * g_blobSize.GetFloat() * scale; // sikk - This was "600". Typo? blob->h = 480 * g_blobSize.GetFloat() * scale; float s1 = 0.0f; float t1 = 0.0f; float s2 = 1.0f; float t2 = 1.0f; - if ( blob->driftAmount < 0.6 ) { +// sikk---> No more drifting +/* if ( blob->driftAmount < 0.6 ) { s1 = 1.0f; s2 = 0.0f; } else if ( blob->driftAmount < 0.75 ) { @@ -340,12 +399,25 @@ void idPlayerView::AddBloodSpray( float duration ) { s2 = 0.0f; t1 = 1.0f; t2 = 0.0f; + }*/ + float f = gameLocal.random.CRandomFloat(); + if ( f < 0.25 ) { + s1 = 1.0f; + s2 = 0.0f; + } else if ( f < 0.5 ) { + t1 = 1.0f; + t2 = 0.0f; + } else if ( f < 0.75 ) { + s1 = 1.0f; + s2 = 0.0f; + t1 = 1.0f; + t2 = 0.0f; } +// <---sikk blob->s1 = s1; blob->t1 = t1; blob->s2 = s2; blob->t2 = t2; -*/ } /* @@ -356,9 +428,8 @@ Called when a weapon fires, generates head twitches, etc ================== */ void idPlayerView::WeaponFireFeedback( const idDict *weaponDef ) { - int recoilTime; + int recoilTime = weaponDef->GetInt( "recoilTime" ); - recoilTime = weaponDef->GetInt( "recoilTime" ); // don't shorten a damage kick in progress if ( recoilTime && kickFinishTime < gameLocal.time ) { idAngles angles; @@ -367,7 +438,6 @@ void idPlayerView::WeaponFireFeedback( const idDict *weaponDef ) { int finish = gameLocal.time + g_kickTime.GetFloat() * recoilTime; kickFinishTime = finish; } - } /* @@ -377,14 +447,12 @@ idPlayerView::CalculateShake */ void idPlayerView::CalculateShake() { idVec3 origin, matrix; - float shakeVolume = gameSoundWorld->CurrentShakeAmplitudeForPosition( gameLocal.time, player->firstPersonViewOrigin ); - // + // shakeVolume should somehow be molded into an angle here // it should be thought of as being in the range 0.0 -> 1.0, although // since CurrentShakeAmplitudeForPosition() returns all the shake sounds // the player can hear, it can go over 1.0 too. - // shakeAng[0] = gameLocal.random.CRandomFloat() * shakeVolume; shakeAng[1] = gameLocal.random.CRandomFloat() * shakeVolume; shakeAng[2] = gameLocal.random.CRandomFloat() * shakeVolume; @@ -407,21 +475,18 @@ idPlayerView::AngleOffset =================== */ idAngles idPlayerView::AngleOffset() const { - idAngles ang; + idAngles ang; ang.Zero(); if ( gameLocal.time < kickFinishTime ) { float offset = kickFinishTime - gameLocal.time; - ang = kickAngles * offset * offset * g_kickAmplitude.GetFloat(); - - for ( int i = 0 ; i < 3 ; i++ ) { - if ( ang[i] > 70.0f ) { + for ( int i = 0; i < 3; i++ ) { + if ( ang[i] > 70.0f ) ang[i] = 70.0f; - } else if ( ang[i] < -70.0f ) { + else if ( ang[i] < -70.0f ) ang[i] = -70.0f; - } } } return ang; @@ -432,165 +497,64 @@ idAngles idPlayerView::AngleOffset() const { idPlayerView::SingleView ================== */ -void idPlayerView::SingleView( idUserInterface *hud, const renderView_t *view ) { - +void idPlayerView::SingleView( const renderView_t *view ) { // normal rendering if ( !view ) { return; } - // place the sound origin for the player - gameSoundWorld->PlaceListener( view->vieworg, view->viewaxis, player->entityNumber + 1, gameLocal.time, hud ? hud->State().GetString( "location" ) : "Undefined" ); - // if the objective system is up, don't do normal drawing if ( player->objectiveSystemOpen ) { player->objectiveSystem->Redraw( gameLocal.time ); return; } +// sikk---> PostProccess Scaling Fix + if ( screenHeight != renderSystem->GetScreenHeight() || screenWidth != renderSystem->GetScreenWidth() ) { + renderSystem->GetGLSettings( screenWidth, screenHeight ); + float f = MakePowerOfTwo( screenWidth ); + shiftScale.x = (float)screenWidth / f; + f = MakePowerOfTwo( screenHeight ); + shiftScale.y = (float)screenHeight / f; + } +// <---sikk + // hack the shake in at the very last moment, so it can't cause any consistency problems - renderView_t hackedView = *view; + hackedView = *view; hackedView.viewaxis = hackedView.viewaxis * ShakeAxis(); +// sikk---> Portal Sky Box + if ( gameLocal.portalSkyEnt.GetEntity() && gameLocal.IsPortalSkyAcive() && g_enablePortalSky.GetBool() ) { + renderView_t portalView = hackedView; + portalView.vieworg = gameLocal.portalSkyEnt.GetEntity()->GetPhysics()->GetOrigin(); + + // setup global fixup projection vars + hackedView.shaderParms[4] = shiftScale.x; + hackedView.shaderParms[5] = shiftScale.y; + + gameRenderWorld->RenderScene( &portalView ); + renderSystem->CaptureRenderToImage( "_currentRender" ); + + hackedView.forceUpdate = true; // FIX: for smoke particles not drawing when portalSky present + } +// <---sikk + +// sikk---> Soft Shadows PostProcess + if ( r_useSoftShadows.GetBool() && !g_skipViewEffects.GetBool() ) { + playerPVS = gameLocal.pvs.SetupCurrentPVS( player->GetPVSAreas(), player->GetNumPVSAreas() ); + + ToggleShadows( false ); + gameRenderWorld->RenderScene( &hackedView ); + renderSystem->CaptureRenderToImage( "_ssRender" ); + ToggleShadows( true ); + + gameLocal.pvs.FreeCurrentPVS( playerPVS ); + } +// <---sikk + gameRenderWorld->RenderScene( &hackedView ); - - if ( player->spectating ) { - return; - } - - // draw screen blobs - if ( !pm_thirdPerson.GetBool() && !g_skipViewEffects.GetBool() ) { - for ( int i = 0 ; i < MAX_SCREEN_BLOBS ; i++ ) { - screenBlob_t *blob = &screenBlobs[i]; - if ( blob->finishTime <= gameLocal.time ) { - continue; - } - - blob->y += blob->driftAmount; - - float fade = (float)( blob->finishTime - gameLocal.time ) / ( blob->finishTime - blob->startFadeTime ); - if ( fade > 1.0f ) { - fade = 1.0f; - } - if ( fade ) { - renderSystem->SetColor4( 1,1,1,fade ); - renderSystem->DrawStretchPic( blob->x, blob->y, blob->w, blob->h,blob->s1, blob->t1, blob->s2, blob->t2, blob->material ); - } - } - player->DrawHUD( hud ); - - // armor impulse feedback - float armorPulse = ( gameLocal.time - player->lastArmorPulse ) / 250.0f; - - if ( armorPulse > 0.0f && armorPulse < 1.0f ) { - renderSystem->SetColor4( 1, 1, 1, 1.0 - armorPulse ); - renderSystem->DrawStretchPic( 0, 0, 640, 480, 0, 0, 1, 1, armorMaterial ); - } - - - // tunnel vision - float health = 0.0f; - if ( g_testHealthVision.GetFloat() != 0.0f ) { - health = g_testHealthVision.GetFloat(); - } else { - health = player->health; - } - float alpha = health / 100.0f; - if ( alpha < 0.0f ) { - alpha = 0.0f; - } - if ( alpha > 1.0f ) { - alpha = 1.0f; - } - - if ( alpha < 1.0f ) { - renderSystem->SetColor4( ( player->health <= 0.0f ) ? MS2SEC( gameLocal.time ) : lastDamageTime, 1.0f, 1.0f, ( player->health <= 0.0f ) ? 0.0f : alpha ); - renderSystem->DrawStretchPic( 0.0f, 0.0f, 640.0f, 480.0f, 0.0f, 0.0f, 1.0f, 1.0f, tunnelMaterial ); - } - - if ( player->PowerUpActive(BERSERK) ) { - int berserkTime = player->inventory.powerupEndTime[ BERSERK ] - gameLocal.time; - if ( berserkTime > 0 ) { - // start fading if within 10 seconds of going away - alpha = (berserkTime < 10000) ? (float)berserkTime / 10000 : 1.0f; - renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, alpha ); - renderSystem->DrawStretchPic( 0.0f, 0.0f, 640.0f, 480.0f, 0.0f, 0.0f, 1.0f, 1.0f, berserkMaterial ); - } - } - - if ( bfgVision ) { - renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f ); - renderSystem->DrawStretchPic( 0.0f, 0.0f, 640.0f, 480.0f, 0.0f, 0.0f, 1.0f, 1.0f, bfgMaterial ); - } - - } - - // test a single material drawn over everything - if ( g_testPostProcess.GetString()[0] ) { - const idMaterial *mtr = declManager->FindMaterial( g_testPostProcess.GetString(), false ); - if ( !mtr ) { - common->Printf( "Material not found.\n" ); - g_testPostProcess.SetString( "" ); - } else { - renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f ); - renderSystem->DrawStretchPic( 0.0f, 0.0f, 640.0f, 480.0f, 0.0f, 0.0f, 1.0f, 1.0f, mtr ); - } - } } -/* -=================== -idPlayerView::DoubleVision -=================== -*/ -void idPlayerView::DoubleVision( idUserInterface *hud, const renderView_t *view, int offset ) { - - if ( !g_doubleVision.GetBool() ) { - SingleView( hud, view ); - return; - } - - float scale = offset * g_dvAmplitude.GetFloat(); - if ( scale > 0.5f ) { - scale = 0.5f; - } - float shift = scale * sin( sqrtf( offset ) * g_dvFrequency.GetFloat() ); - shift = fabs( shift ); - - // if double vision, render to a texture - renderSystem->CropRenderSize( 512, 256, true ); - SingleView( hud, view ); - renderSystem->CaptureRenderToImage( "_scratch" ); - renderSystem->UnCrop(); - - // carry red tint if in berserk mode - idVec4 color(1, 1, 1, 1); - if ( gameLocal.time < player->inventory.powerupEndTime[ BERSERK ] ) { - color.y = 0; - color.z = 0; - } - - renderSystem->SetColor4( color.x, color.y, color.z, 1.0f ); - renderSystem->DrawStretchPic( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, shift, 1, 1, 0, dvMaterial ); - renderSystem->SetColor4( color.x, color.y, color.z, 0.5f ); - renderSystem->DrawStretchPic( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 1, 1-shift, 0, dvMaterial ); -} - -/* -=================== -idPlayerView::BerserkVision -=================== -*/ -void idPlayerView::BerserkVision( idUserInterface *hud, const renderView_t *view ) { - renderSystem->CropRenderSize( 512, 256, true ); - SingleView( hud, view ); - renderSystem->CaptureRenderToImage( "_scratch" ); - renderSystem->UnCrop(); - renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f ); - renderSystem->DrawStretchPic( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 1, 1, 0, dvMaterial ); -} - - /* ================= idPlayerView::Flash @@ -598,8 +562,8 @@ idPlayerView::Flash flashes the player view with the given color ================= */ -void idPlayerView::Flash(idVec4 color, int time ) { - Fade(idVec4(0, 0, 0, 0), time); +void idPlayerView::Flash( idVec4 color, int time ) { + Fade( idVec4( 0.0f, 0.0f, 0.0f, 0.0f ), time); fadeFromColor = colorWhite; } @@ -612,7 +576,6 @@ assumes: color.w is 0 or 1 ================= */ void idPlayerView::Fade( idVec4 color, int time ) { - if ( !fadeTime ) { fadeFromColor.Set( 0.0f, 0.0f, 0.0f, 1.0f - color[ 3 ] ); } else { @@ -625,7 +588,7 @@ void idPlayerView::Fade( idVec4 color, int time ) { time = 0; fadeColor = fadeToColor; } else { - fadeRate = 1.0f / ( float )time; + fadeRate = 1.0f / (float)time; } if ( gameLocal.realClientTime == 0 && time == 0 ) { @@ -641,58 +604,21 @@ idPlayerView::ScreenFade ================= */ void idPlayerView::ScreenFade() { - int msec; - float t; - - if ( !fadeTime ) { - return; - } - - msec = fadeTime - gameLocal.realClientTime; + int msec = fadeTime - gameLocal.realClientTime; + float t; if ( msec <= 0 ) { fadeColor = fadeToColor; - if ( fadeColor[ 3 ] == 0.0f ) { + if ( fadeColor[ 3 ] == 0.0f ) fadeTime = 0; - } } else { - t = ( float )msec * fadeRate; + t = (float)msec * fadeRate; fadeColor = fadeFromColor * t + fadeToColor * ( 1.0f - t ); } if ( fadeColor[ 3 ] != 0.0f ) { renderSystem->SetColor4( fadeColor[ 0 ], fadeColor[ 1 ], fadeColor[ 2 ], fadeColor[ 3 ] ); - renderSystem->DrawStretchPic( 0, 0, 640, 480, 0, 0, 1, 1, declManager->FindMaterial( "_white" ) ); - } -} - -/* -=================== -idPlayerView::InfluenceVision -=================== -*/ -void idPlayerView::InfluenceVision( idUserInterface *hud, const renderView_t *view ) { - - float distance = 0.0f; - float pct = 1.0f; - if ( player->GetInfluenceEntity() ) { - distance = ( player->GetInfluenceEntity()->GetPhysics()->GetOrigin() - player->GetPhysics()->GetOrigin() ).Length(); - if ( player->GetInfluenceRadius() != 0.0f && distance < player->GetInfluenceRadius() ) { - pct = distance / player->GetInfluenceRadius(); - pct = 1.0f - idMath::ClampFloat( 0.0f, 1.0f, pct ); - } - } - if ( player->GetInfluenceMaterial() ) { - SingleView( hud, view ); - renderSystem->CaptureRenderToImage( "_currentRender" ); - renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, pct ); - renderSystem->DrawStretchPic( 0.0f, 0.0f, 640.0f, 480.0f, 0.0f, 0.0f, 1.0f, 1.0f, player->GetInfluenceMaterial() ); - } else if ( player->GetInfluenceEntity() == NULL ) { - SingleView( hud, view ); - return; - } else { - int offset = 25 + sinf( gameLocal.time ); - DoubleVision( hud, view, pct * offset ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 0.0f, 1.0f, 1.0f, whiteMaterial ); } } @@ -704,23 +630,1367 @@ idPlayerView::RenderPlayerView void idPlayerView::RenderPlayerView( idUserInterface *hud ) { const renderView_t *view = player->GetRenderView(); - if ( g_skipViewEffects.GetBool() ) { - SingleView( hud, view ); - } else { - if ( player->GetInfluenceMaterial() || player->GetInfluenceEntity() ) { - InfluenceVision( hud, view ); - } else if ( gameLocal.time < dvFinishTime ) { - DoubleVision( hud, view, dvFinishTime - gameLocal.time ); - } else if ( player->PowerUpActive( BERSERK ) ) { - BerserkVision( hud, view ); - } else { - SingleView( hud, view ); - } + // place the sound origin for the player + gameSoundWorld->PlaceListener( view->vieworg, view->viewaxis, player->entityNumber + 1, gameLocal.time, hud ? hud->State().GetString( "location" ) : "Undefined" ); + + SingleView( view ); + + if ( !g_skipViewEffects.GetBool() && !player->objectiveSystemOpen ) + DoPostFX(); + + // if the objective system is up, don't draw hud + if ( !player->objectiveSystemOpen ) + player->DrawHUD( hud ); + + if ( fadeTime ) ScreenFade(); - } if ( net_clientLagOMeter.GetBool() && lagoMaterial && gameLocal.isClient ) { renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f ); renderSystem->DrawStretchPic( 10.0f, 380.0f, 64.0f, 64.0f, 0.0f, 0.0f, 1.0f, 1.0f, lagoMaterial ); } + + prevTime = gameLocal.time; // sikk - update prevTime } + +// sikk---> PostProcess Effects +/* +=================== +idPlayerView::DoPostFX +=================== +*/ +void idPlayerView::DoPostFX() { + // screen space reflection stuff + //renderSystem->CaptureRenderToImage( "_currentRender" ); + //renderSystem->CropRenderSize( 256, 128, true, true ); + //renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 0.0f ); + //renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, shiftScale.y, shiftScale.x, 0.0f, declManager->FindMaterial( "postProcess/ssReflection", false ) ); + //renderSystem->CaptureRenderToImage( "_ssReflect" ); + //renderSystem->UnCrop(); + //renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, shiftScale.y, shiftScale.x, 0.0f, currentRenderMaterial ); + + bDepthRendered = false; + + if ( r_useSoftShadows.GetBool() ) + PostFX_SoftShadows(); + else if ( bSoftShadows ) + ResetShadows(); + + if ( r_useEdgeAA.GetBool() ) + PostFX_EdgeAA(); + + if ( r_useCelShading.GetBool() ) + PostFX_CelShading(); + + if ( r_useSSIL.GetBool() ) + PostFX_SSIL(); + + if ( r_useSSAO.GetBool() ) + PostFX_SSAO(); + + if ( r_useSunShafts.GetBool() ) + PostFX_SunShafts(); + + if ( r_useHDR.GetBool() ) { + cvarSystem->SetCVarBool( "r_testARBProgram", true ); + PostFX_HDR(); + } else { + cvarSystem->SetCVarBool( "r_testARBProgram", false ); + } + + if ( r_useBloom.GetBool() ) + PostFX_Bloom(); + + if ( r_useLensFlare.GetBool() ) + PostFX_LensFlare(); + + if ( g_useExplosionFX.GetBool() ) + PostFX_ExplosionFX(); + + if ( r_useDepthOfField.GetBool() ) + PostFX_DoF(); + + if ( r_useMotionBlur.GetBool() ) + PostFX_MotionBlur(); + + if ( player->PowerUpActive( ADRENALINE ) ) + PostFX_AdrenalineVision(); + + if ( r_useColorGrading.GetBool() ) + PostFX_ColorGrading(); + + if ( g_screenFrostTime.GetInteger() ) + PostFX_ScreenFrost(); + + PostFX_ScreenBlobs(); + + PostFX_IRGoggles(); + + PostFX_ArmorPulse(); + + if ( bfgVision ) + PostFX_BFGVision(); + + if ( !gameLocal.inCinematic ) + PostFX_TunnelVision(); + + if ( r_useVignetting.GetBool() && !r_useHDR.GetBool() ) // HDR uses it's own vignette solution + PostFX_Vignetting(); + + if ( r_useFilmgrain.GetBool() ) + PostFX_Filmgrain(); + + if ( player->GetInfluenceMaterial() || player->GetInfluenceEntity() ) + PostFX_InfluenceVision(); + + if ( g_doubleVision.GetBool() && gameLocal.time < dvFinishTime ) + PostFX_DoubleVision(); + + if ( player->PowerUpActive( BERSERK ) ) + PostFX_BerserkVision(); + + // test a single material drawn over everything + if ( g_testPostProcess.GetString()[0] && !player->spectating ) { + const idMaterial *mtr = declManager->FindMaterial( g_testPostProcess.GetString(), false ); + if ( !mtr ) { + common->Printf( "Material not found.\n" ); + g_testPostProcess.SetString( "" ); + } else { + renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 0.0f, 1.0f, 1.0f, mtr ); + } + } +} + +/* +=================== +idPlayerView::RenderDepth +=================== +*/ +void idPlayerView::RenderDepth( bool bCrop ) { + // modify player related models in depth render. + if ( !player->IsHidden() && !pm_thirdPerson.GetBool() ) + player->ToggleSuppression( true ); + + if ( bCrop && !bDepthRendered ) { + int nWidth = renderSystem->GetScreenWidth() / 2; + int nHeight = renderSystem->GetScreenHeight() / 2; + + renderSystem->CropRenderSize( nWidth, nHeight, true ); + +// if ( r_useSoftShadows.GetBool() ) { +// renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, shiftScale.y, shiftScale.x, 0.0f, declManager->FindMaterial( "crop/depth", false ) ); +// renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0, 1.0, 0.0f, declManager->FindMaterial( "crop/depth", false ) ); +// renderSystem->CaptureRenderToImage( "_depth" ); +// } else { + // set our depthView parms + renderView_t depthView = hackedView; + depthView.viewID = -8; +// depthView.globalMaterial = depthMaterial; + cvarSystem->SetCVarString( "r_materialOverride", "render/depth" ); + // render scene + gameRenderWorld->RenderScene( &depthView ); + // capture image for our depth buffer + renderSystem->CaptureRenderToImage( "_depth" ); + cvarSystem->SetCVarString( "r_materialOverride", "" ); +// } + renderSystem->UnCrop(); + bDepthRendered = true; + } else if ( !bCrop ) { // uncropped depth is used specifically for soft shadows + // set our depthView parms + renderView_t depthView = hackedView; + depthView.viewID = -8; +// depthView.globalMaterial = depthMaterial; + cvarSystem->SetCVarString( "r_materialOverride", "render/depth" ); + // render scene + gameRenderWorld->RenderScene( &depthView ); + // capture image for our depth buffer + renderSystem->CaptureRenderToImage( "_ssDepth" ); + cvarSystem->SetCVarString( "r_materialOverride", "" ); + } + + // Restore player models + if ( !player->IsHidden() && !pm_thirdPerson.GetBool() && player->bViewModelsModified ) + player->ToggleSuppression( false ); +} + +/* +=================== +idPlayerView::RenderNormals +=================== +*/ +void idPlayerView::RenderNormals( bool bFace ) { + int nWidth = renderSystem->GetScreenWidth() / 2; + int nHeight = renderSystem->GetScreenHeight() / 2; + + if ( bFace ) { + renderSystem->CropRenderSize( nWidth, nHeight, true ); + renderSystem->SetColor4( g_fov.GetFloat(), 1.0f, 1.0f, bFace ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, normalsMaterial ); + renderSystem->CaptureRenderToImage( "_normals" ); + renderSystem->UnCrop(); + } else { + // modify player related models in normals render. + if ( !player->IsHidden() && !pm_thirdPerson.GetBool() ) + player->ToggleSuppression( true ); + + renderSystem->CropRenderSize( nWidth, nHeight, true ); + // set our normalsView parms + renderView_t normalsView = hackedView; + normalsView.viewID = -8; + normalsView.globalMaterial = normalsMaterial; + // render scene + gameRenderWorld->RenderScene( &normalsView ); + // capture image for our normals buffer + renderSystem->CaptureRenderToImage( "_normals" ); + renderSystem->UnCrop(); + + // Restore player models + if ( !player->IsHidden() && !pm_thirdPerson.GetBool() && player->bViewModelsModified ) + player->ToggleSuppression( false ); + } +} + +/* +=================== +idPlayerView::PostFX_SoftShadows +=================== +*/ +void idPlayerView::PostFX_SoftShadows() { + bSoftShadows = true; + + renderSystem->CaptureRenderToImage( "_currentRender" ); + + RenderDepth( false ); + + // create shadow mask texture + renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 0.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, softShadowsMaterial ); + renderSystem->CaptureRenderToImage( "_ssMask" ); + + // blur shadow mask texture and modulate scene in the same pass + if ( r_softShadowsBlurFilter.GetInteger() && r_softShadowsBlurFilter.GetInteger() < 4 ) { + renderSystem->SetColor4( r_softShadowsBlurScale.GetFloat(), r_softShadowsBlurEpsilon.GetFloat(), g_fov.GetFloat(), r_softShadowsBlurFilter.GetFloat() ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, softShadowsMaterial ); + if ( r_softShadowsBlurFilter.GetInteger() == 3 ) { + renderSystem->CaptureRenderToImage( "_ssMask" ); + renderSystem->SetColor4( r_softShadowsBlurScale.GetFloat(), r_softShadowsBlurEpsilon.GetFloat(), g_fov.GetFloat(), ( r_softShadowsBlurFilter.GetFloat() + 1.0f ) ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, softShadowsMaterial ); + } + } else { + renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 5.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, softShadowsMaterial ); + } +} + +/* +=============== +idPlayerView::ToggleShadows +=============== +*/ +void idPlayerView::ToggleShadows( bool noShadows ) { + idEntity *ent; + idLight *light; + + // handle player's flashlight specifically + if ( player->GetCurrentWeapon() == 11 ) { + if ( pm_thirdPerson.GetBool() ) { + renderLight_t *mf = player->weapon.GetEntity()->GetWorldMuzzleFlash(); + int mfHandle = player->weapon.GetEntity()->GetWorldMuzzleFlashHandle(); + + mf->noShadows = noShadows; + if ( mfHandle != -1 ) + gameRenderWorld->UpdateLightDef( mfHandle, mf ); + } else { + renderLight_t *mf = player->weapon.GetEntity()->GetMuzzleFlash(); + int mfHandle = player->weapon.GetEntity()->GetMuzzleFlashHandle(); + + mf->noShadows = noShadows; + if ( mfHandle != -1 ) + gameRenderWorld->UpdateLightDef( mfHandle, mf ); + } + } + + for ( int i = 0; i < gameLocal.currentLights.Num(); i++ ) { + if ( gameLocal.entities[ gameLocal.currentLights[ i ] ] == NULL ) { + gameLocal.currentLights.RemoveIndex( i ); + } else { + ent = gameLocal.entities[ gameLocal.currentLights[ i ] ]; + + if ( gameLocal.pvs.InCurrentPVS( playerPVS, ent->GetPVSAreas(), ent->GetNumPVSAreas() ) ) { + light = static_cast( ent ); + light->GetRenderLight()->noShadows = noShadows; + light->UpdateShadowState(); + } else { + light = static_cast( ent ); + + if ( light->GetRenderLight()->noShadows == true ) { + light->GetRenderLight()->noShadows = false; + light->UpdateShadowState(); + } + } + } + } +} + +/* +=============== +idPlayerView::ResetShadows +=============== +*/ +void idPlayerView::ResetShadows() { + idEntity *ent; + idLight *light; + + // handle player's flashlight specifically + if ( player->GetCurrentWeapon() == 11 ) { + if ( pm_thirdPerson.GetBool() ) { + renderLight_t *mf = player->weapon.GetEntity()->GetWorldMuzzleFlash(); + int mfHandle = player->weapon.GetEntity()->GetWorldMuzzleFlashHandle(); + + mf->noShadows = false; + if ( mfHandle != -1 ) + gameRenderWorld->UpdateLightDef( mfHandle, mf ); + } else { + renderLight_t *mf = player->weapon.GetEntity()->GetMuzzleFlash(); + int mfHandle = player->weapon.GetEntity()->GetMuzzleFlashHandle(); + + mf->noShadows = false; + if ( mfHandle != -1 ) + gameRenderWorld->UpdateLightDef( mfHandle, mf ); + } + } + + for ( int i = 0; i < gameLocal.currentLights.Num(); i++ ) { + if ( gameLocal.entities[ gameLocal.currentLights[ i ] ] == NULL ) { + gameLocal.currentLights.RemoveIndex( i ); + } else { + ent = gameLocal.entities[ gameLocal.currentLights[ i ] ]; + light = static_cast( ent ); + + if ( light->GetRenderLight()->noShadows == true ) { + light->GetRenderLight()->noShadows = false; + light->UpdateShadowState(); + } + } + } + + bSoftShadows = false; +} + +/* +=================== +idPlayerView::PostFX_EdgeAA +=================== +*/ +void idPlayerView::PostFX_EdgeAA() { + renderSystem->CaptureRenderToImage( "_currentRender" ); + renderSystem->SetColor4( r_edgeAASampleScale.GetFloat(), r_edgeAAFilterScale.GetFloat(), 1.0f, 1.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, edgeAAMaterial ); +} + +/* +=================== +idPlayerView::PostFX_CelShading +=================== +*/ +void idPlayerView::PostFX_CelShading() { + renderSystem->CaptureRenderToImage( "_currentRender" ); + RenderDepth( true ); + renderSystem->SetColor4( r_celShadingScale.GetFloat(), r_celShadingThreshold.GetFloat(), 1.0f, r_celShadingMethod.GetInteger() ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, celShadingMaterial ); +} + +/* +=================== +idPlayerView::PostFX_HDR +=================== +*/ +void idPlayerView::PostFX_HDR() { + float fElapsedTime = MS2SEC( gameLocal.time - prevTime ); + int nBloomWidth = renderSystem->GetScreenWidth() / 4; + int nBloomHeight = renderSystem->GetScreenHeight() / 4; + int nGlareWidth = renderSystem->GetScreenWidth() / 8; + int nGlareHeight = renderSystem->GetScreenHeight() / 8; + + // capture original scene image + renderSystem->CaptureRenderToImage( "_currentRender" ); + + // create lower res luminance map + renderSystem->CropRenderSize( 256, 256, true, true ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, shiftScale.y, shiftScale.x, 0.0f, currentRenderMaterial ); + renderSystem->CaptureRenderToImage( "_hdrLum" ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrLumBaseMaterial ); + renderSystem->CaptureRenderToImage( "_hdrLum" ); + renderSystem->CaptureRenderToImage( "_hdrLumAvg" ); + renderSystem->UnCrop(); + + // create average scene luminance map by using a 4x4 downsampling chain and box-filtering + // Output will be a 1x1 pixel of the average luminance + for ( int i = 256; i > 1; i *= 0.5 ) { + renderSystem->CropRenderSize( i, i, true, true ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrLumAverageMaterial ); + renderSystem->CaptureRenderToImage( "_hdrLumAvg" ); + renderSystem->UnCrop(); + } + + // create adapted luminance map based on current average luminance and previous adapted luminance maps + renderSystem->CropRenderSize( 2, 2, true, true ); + renderSystem->SetColor4( r_hdrAdaptationRate.GetFloat(), fElapsedTime, r_hdrLumThresholdMin.GetFloat(), r_hdrLumThresholdMax.GetFloat() ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrLumAdaptedMaterial ); + renderSystem->CaptureRenderToImage( "_hdrLumAdpt" ); + renderSystem->UnCrop(); + + if ( r_hdrGlareStyle.GetInteger() ) { + // perform bright pass filter on _currentRender for bloom/glare textures + renderSystem->CropRenderSize( nBloomWidth, nBloomHeight, true, true ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, shiftScale.y, shiftScale.x, 0.0f, currentRenderMaterial ); + renderSystem->CaptureRenderToImage( "_hdrBloom" ); + renderSystem->SetColor4( r_hdrBloomMiddleGray.GetFloat(), r_hdrBloomWhitePoint.GetFloat(), r_hdrBloomThreshold.GetFloat(), r_hdrBloomOffset.GetFloat() ); + if ( r_hdrBloomToneMapper.GetInteger() == 0 ) + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrBrightPass1Material ); + else if ( r_hdrBloomToneMapper.GetInteger() == 1 ) + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrBrightPass2Material ); + else if ( r_hdrBloomToneMapper.GetInteger() == 2 ) + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrBrightPass3Material ); + else if ( r_hdrBloomToneMapper.GetInteger() == 3 ) + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrBrightPass4Material ); + else if ( r_hdrBloomToneMapper.GetInteger() == 4 ) + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrBrightPass5Material ); + renderSystem->CaptureRenderToImage( "_hdrBloom" ); + renderSystem->CaptureRenderToImage( "_hdrFlare" ); + renderSystem->UnCrop(); + + // create bloom texture + for ( int i = 0; i < 2; i++ ) { + renderSystem->CropRenderSize( nBloomWidth, nBloomHeight, true, true ); + renderSystem->SetColor4( r_hdrBloomSize.GetFloat(), 0.0f, 1.0f, 1.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrBloomMaterial ); + renderSystem->CaptureRenderToImage( "_hdrBloom" ); + renderSystem->SetColor4( 0.0f, r_hdrBloomSize.GetFloat(), r_hdrBloomScale.GetFloat(), 1.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrBloomMaterial ); + renderSystem->CaptureRenderToImage( "_hdrBloom" ); + renderSystem->UnCrop(); + } + + // create lens flare texture + if ( r_hdrFlareScale.GetFloat() ) { + renderSystem->CropRenderSize( nGlareWidth, nGlareHeight, true, true ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 1.0f, 0.0f, 0.0f, 1.0f, declManager->FindMaterial( "_hdrFlare" ) ); + renderSystem->CaptureRenderToImage( "_hdrFlare" ); + renderSystem->SetColor4( r_hdrFlareGamma.GetFloat(), 1.0f, 1.0f, 0.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrFlareMaterial ); + renderSystem->CaptureRenderToImage( "_hdrFlare" ); + renderSystem->SetColor4( r_hdrFlareSize.GetFloat(), 1.0f, 1.0f, 1.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrFlareMaterial ); + renderSystem->CaptureRenderToImage( "_hdrFlare" ); + renderSystem->SetColor4( DEG2RAD( r_hdrFlareSize.GetFloat() ), 1.0f, 1.0f, 2.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrFlareMaterial ); + renderSystem->CaptureRenderToImage( "_hdrFlare" ); + renderSystem->SetColor4( DEG2RAD( r_hdrFlareSize.GetFloat() ), r_hdrFlareScale.GetFloat(), 1.0f, 2.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrFlareMaterial ); + renderSystem->CaptureRenderToImage( "_hdrFlare" ); + renderSystem->UnCrop(); + } + } + + // create glare textures + if ( r_hdrGlareStyle.GetInteger() == 0 ) { + // bloom off (clear textures) + renderSystem->CropRenderSize( 1, 1, true, true ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, blackMaterial ); + renderSystem->CaptureRenderToImage( "_hdrBloom" ); + renderSystem->CaptureRenderToImage( "_hdrFlare" ); + renderSystem->CaptureRenderToImage( "_hdrGlare" ); + renderSystem->UnCrop(); + } else if ( r_hdrGlareStyle.GetInteger() == 1 ) { + // natural bloom (clear just _hdrGlare) + renderSystem->CropRenderSize( 1, 1, true, true ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, blackMaterial ); + renderSystem->CaptureRenderToImage( "_hdrGlare" ); + renderSystem->UnCrop(); + } else if ( r_hdrGlareStyle.GetInteger() > 1 ) { + int nGlareBlend; + + // crop _hdrBloom1 for glare textures + renderSystem->CropRenderSize( nGlareWidth, nGlareHeight, true, true ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, declManager->FindMaterial( "_hdrBloom" ) ); + renderSystem->CaptureRenderToImage( "_hdrGlareX" ); + renderSystem->CaptureRenderToImage( "_hdrGlareY" ); + renderSystem->CaptureRenderToImage( "_hdrGlareZ" ); + + switch ( r_hdrGlareStyle.GetInteger() ) { + case 2: // star glare + for ( int i = 1; i <= 3; i++ ) { + renderSystem->SetColor4( r_hdrGlareSize.GetFloat(), i, 1.0f, 0.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrGlareMaterial ); + renderSystem->CaptureRenderToImage( "_hdrGlareX" ); + renderSystem->SetColor4( r_hdrGlareSize.GetFloat(), i, 1.0f, 1.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrGlareMaterial ); + renderSystem->CaptureRenderToImage( "_hdrGlareY" ); + } + nGlareBlend = 2; + break; + case 3: // cross glare + for ( int i = 1; i <= 3; i++ ) { + renderSystem->SetColor4( r_hdrGlareSize.GetFloat(), i, 1.0f, 2.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrGlareMaterial ); + renderSystem->CaptureRenderToImage( "_hdrGlareX" ); + renderSystem->SetColor4( r_hdrGlareSize.GetFloat(), i, 1.0f, 3.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrGlareMaterial ); + renderSystem->CaptureRenderToImage( "_hdrGlareY" ); + } + nGlareBlend = 2; + break; + case 4: // snow cross glare + for ( int i = 1; i <= 3; i++ ) { + renderSystem->SetColor4( r_hdrGlareSize.GetFloat(), i, 1.0f, 4.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrGlareMaterial ); + renderSystem->CaptureRenderToImage( "_hdrGlareX" ); + renderSystem->SetColor4( r_hdrGlareSize.GetFloat(), i, 1.0f, 5.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrGlareMaterial ); + renderSystem->CaptureRenderToImage( "_hdrGlareY" ); + renderSystem->SetColor4( r_hdrGlareSize.GetFloat(), i, 1.0f, 6.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrGlareMaterial ); + renderSystem->CaptureRenderToImage( "_hdrGlareZ" ); + } + nGlareBlend = 3; + break; + case 5: // horizontal glare + for ( int i = 1; i <= 3; i++ ) { + renderSystem->SetColor4( r_hdrGlareSize.GetFloat(), i, 1.0f, 7.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrGlareMaterial ); + renderSystem->CaptureRenderToImage( "_hdrGlareX" ); + } + nGlareBlend = 0; + break; + case 6: // vertical glare + for ( int i = 1; i <= 3; i++ ) { + renderSystem->SetColor4( r_hdrGlareSize.GetFloat(), i, 1.0f, 8.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrGlareMaterial ); + renderSystem->CaptureRenderToImage( "_hdrGlareY" ); + } + nGlareBlend = 1; + break; + case 7: // star glare with chromatic abberation + for ( int i = 1; i <= 3; i++ ) { + renderSystem->SetColor4( r_hdrGlareSize.GetFloat(), i, 1.0f, 9.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrGlareMaterial ); + renderSystem->CaptureRenderToImage( "_hdrGlareX" ); + renderSystem->SetColor4( r_hdrGlareSize.GetFloat(), i, 1.0f, 10.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrGlareMaterial ); + renderSystem->CaptureRenderToImage( "_hdrGlareY" ); + } + nGlareBlend = 2; + break; + case 8: // cross glare with chromatic abberation + for ( int i = 1; i <= 3; i++ ) { + renderSystem->SetColor4( r_hdrGlareSize.GetFloat(), i, 1.0f, 11.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrGlareMaterial ); + renderSystem->CaptureRenderToImage( "_hdrGlareX" ); + renderSystem->SetColor4( r_hdrGlareSize.GetFloat(), i, 1.0f, 12.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrGlareMaterial ); + renderSystem->CaptureRenderToImage( "_hdrGlareY" ); + } + nGlareBlend = 2; + break; + case 9: // snow cross glare with chromatic abberation + for ( int i = 1; i <= 3; i++ ) { + renderSystem->SetColor4( r_hdrGlareSize.GetFloat(), i, 1.0f, 13.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrGlareMaterial ); + renderSystem->CaptureRenderToImage( "_hdrGlareX" ); + renderSystem->SetColor4( r_hdrGlareSize.GetFloat(), i, 1.0f, 14.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrGlareMaterial ); + renderSystem->CaptureRenderToImage( "_hdrGlareY" ); + renderSystem->SetColor4( r_hdrGlareSize.GetFloat(), i, 1.0f, 15.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrGlareMaterial ); + renderSystem->CaptureRenderToImage( "_hdrGlareZ" ); + } + nGlareBlend = 3; + break; + case 10: // horizontal glare with chromatic abberation + for ( int i = 1; i <= 3; i++ ) { + renderSystem->SetColor4( r_hdrGlareSize.GetFloat(), i, 1.0f, 16.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrGlareMaterial ); + renderSystem->CaptureRenderToImage( "_hdrGlareX" ); + } + nGlareBlend = 0; + break; + case 11: // vertical glare with chromatic abberation + for ( int i = 1; i <= 3; i++ ) { + renderSystem->SetColor4( r_hdrGlareSize.GetFloat(), i, 1.0f, 17.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrGlareMaterial ); + renderSystem->CaptureRenderToImage( "_hdrGlareY" ); + } + nGlareBlend = 1; + break; + } + // blend glare textures and capture to a single texture + renderSystem->SetColor4( r_hdrGlareScale.GetFloat(), 1.0f, nGlareBlend, 18.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrGlareMaterial ); + renderSystem->CaptureRenderToImage( "_hdrGlare" ); + renderSystem->UnCrop(); + } + + if ( r_hdrDither.GetBool() && ( !bDitherRendered || ( fDitherSize != r_hdrDitherSize.GetFloat() ) ) ) { + float size = 16.0f * r_hdrDitherSize.GetFloat(); + renderSystem->SetColor4( renderSystem->GetScreenWidth() / size, renderSystem->GetScreenHeight() / size, 1.0f, -1.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrFinalMaterial ); + renderSystem->CaptureRenderToImage( "_hdrDither" ); + bDitherRendered = true; + } else if ( !r_hdrDither.GetBool() && bDitherRendered ) { + renderSystem->CropRenderSize( 1, 1, true, true ); + renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, -2.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrFinalMaterial ); + renderSystem->CaptureRenderToImage( "_hdrDither" ); + renderSystem->UnCrop(); + bDitherRendered = false; + } + fDitherSize = r_hdrDitherSize.GetFloat(); + + // perform final tone mapping + renderSystem->SetColor4( r_hdrMiddleGray.GetFloat(), r_hdrWhitePoint.GetFloat(), r_hdrBlueShiftFactor.GetFloat(), r_hdrToneMapper.GetInteger() + 5 * r_useVignetting.GetBool() ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, hdrFinalMaterial ); +} + +/* +=================== +idPlayerView::PostFX_Bloom +=================== +*/ +void idPlayerView::PostFX_Bloom() { + // determine bloom buffer size + int nBufferSize = 32; + for ( int i = 0; i < r_bloomBufferSize.GetInteger() && i < 5; i++ ) + nBufferSize <<= 1; + + renderSystem->CaptureRenderToImage( "_currentRender" ); + + // create bloom texture + renderSystem->CropRenderSize( nBufferSize, nBufferSize, true, true ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, shiftScale.y, shiftScale.x, 0.0f, currentRenderMaterial ); + renderSystem->CaptureRenderToImage( "_bloom" ); + renderSystem->SetColor4( r_bloomGamma.GetFloat(), 1.0f, 1.0f, 0.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, bloomMaterial ); + renderSystem->CaptureRenderToImage( "_bloom" ); + + for ( int i = 0; i < r_bloomBlurIterations.GetInteger(); i++ ) { + renderSystem->SetColor4( r_bloomBlurScaleX.GetFloat(), 1.0f, 1.0f, 1.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, bloomMaterial ); + renderSystem->CaptureRenderToImage( "_bloom" ); + renderSystem->SetColor4( r_bloomBlurScaleY.GetFloat(), 1.0f, 1.0f, 2.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, bloomMaterial ); + renderSystem->CaptureRenderToImage( "_bloom" ); + } + renderSystem->UnCrop(); + + // blend original and bloom textures + renderSystem->SetColor4( r_bloomScale.GetFloat(), 1.0f, 1.0f, 3.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, bloomMaterial ); +} + +/* +=================== +idPlayerView::PostFX_SSIL +=================== +*/ +void idPlayerView::PostFX_SSIL() { + int nWidth = renderSystem->GetScreenWidth() / 2.0f; + int nHeight = renderSystem->GetScreenHeight() / 2.0f; + + renderSystem->CaptureRenderToImage( "_currentRender" ); + + RenderDepth( true ); + RenderNormals( false ); + + renderSystem->CropRenderSize( nWidth, nHeight, true, true ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, shiftScale.y, shiftScale.x, 0.0f, currentRenderMaterial ); + renderSystem->CaptureRenderToImage( "_ssil" ); + + renderSystem->SetColor4( r_ssilRadius.GetFloat(), r_ssilAmount.GetFloat(), 1.0f, 0.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, ssilMaterial ); + renderSystem->CaptureRenderToImage( "_ssil" ); + // blur ssil buffer + for ( int i = 0; i < r_ssilBlurQuality.GetInteger(); i++ ) { + renderSystem->SetColor4( r_ssilBlurScale.GetFloat(), 0.0f, r_ssilBlurEpsilon.GetFloat(), ( r_ssilBlurMethod.GetFloat() + 1.0f ) ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, ssilMaterial ); + renderSystem->CaptureRenderToImage( "_ssil" ); + renderSystem->SetColor4( 0.0f, r_ssilBlurScale.GetFloat(), r_ssilBlurEpsilon.GetFloat(), ( r_ssilBlurMethod.GetFloat() + 1.0f ) ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, ssilMaterial ); + renderSystem->CaptureRenderToImage( "_ssil" ); + } + renderSystem->UnCrop(); + + // blend scene with ssil buffer + renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 3.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, ssilMaterial ); +} + +/* +=================== +idPlayerView::PostFX_SSAO +=================== +*/ +void idPlayerView::PostFX_SSAO() { + int nWidth = renderSystem->GetScreenWidth() / 2.0f; + int nHeight = renderSystem->GetScreenHeight() / 2.0f; + + renderSystem->CaptureRenderToImage( "_currentRender" ); + + RenderDepth( true ); + + renderSystem->CropRenderSize( nWidth, nHeight, true ); + + // sample occlusion using our depth buffer + renderSystem->SetColor4( r_ssaoRadius.GetFloat(), r_ssaoBias.GetFloat(), r_ssaoAmount.GetFloat(), ( r_ssaoMethod.GetFloat() < 0.0f ? 0.0f : r_ssaoMethod.GetFloat() ) ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, ssaoMaterial ); + renderSystem->CaptureRenderToImage( "_ssao" ); + // blur ssao buffer + for ( int i = 0; i < r_ssaoBlurQuality.GetInteger(); i++ ) { + renderSystem->SetColor4( r_ssaoBlurScale.GetFloat(), 0.0f, r_ssaoBlurEpsilon.GetFloat(), -( r_ssaoBlurMethod.GetFloat() + 1.0f ) ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, ssaoMaterial ); + renderSystem->CaptureRenderToImage( "_ssao" ); + if ( r_ssaoBlurMethod.GetInteger() >= 2 ) { + renderSystem->SetColor4( 0.0f, r_ssaoBlurScale.GetFloat(), r_ssaoBlurEpsilon.GetFloat(), -( r_ssaoBlurMethod.GetFloat() + 1.0f ) ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, ssaoMaterial ); + renderSystem->CaptureRenderToImage( "_ssao" ); + } + } + renderSystem->UnCrop(); + + // modulate scene with ssao buffer + renderSystem->SetColor4( r_ssaoBlendPower.GetFloat(), r_ssaoBlendScale.GetFloat(), 1.0f, -5.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, ssaoMaterial ); +} + +/* +=================== +idPlayerView::PostFX_SunShafts +=================== +*/ +void idPlayerView::PostFX_SunShafts() { + idMat3 axis; + idVec3 origin; + idVec3 viewVector[3]; + player->GetViewPos( origin, axis ); + player->viewAngles.ToVectors( &viewVector[0], &viewVector[1], &viewVector[2] ); + + idVec3 sunOrigin = idVec3( r_sunOriginX.GetFloat(), r_sunOriginY.GetFloat(), r_sunOriginZ.GetFloat() ) ; + idVec3 dist = origin - sunOrigin; + float length = dist.Length(); + idVec3 sunVector = dist / length; + + float VdotS[3]; + for ( int i = 0; i < 3; i++ ) { + VdotS[i] = viewVector[i] * -sunVector; + } +// float sign = VdotS[0]; +// VdotS[0] = idMath::ClampFloat( 0.0f, 1.0f, VdotS[0] ); + idVec3 ndc; + renderSystem->GlobalToNormalizedDeviceCoordinates( sunOrigin, ndc ); + ndc.x = ndc.x * 0.5 + 0.5; + ndc.y = ndc.y * 0.5 + 0.5; + + int nWidth = renderSystem->GetScreenWidth() / 2.0f; + int nHeight = renderSystem->GetScreenHeight() / 2.0f; + renderSystem->CaptureRenderToImage( "_currentRender" ); + + RenderDepth( true ); + + renderSystem->CropRenderSize( nWidth, nHeight, true, true ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, shiftScale.y, shiftScale.x, 0.0f, currentRenderMaterial ); + renderSystem->CaptureRenderToImage( "_sunShafts" ); + + renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, sunShaftsMaterial ); + renderSystem->CaptureRenderToImage( "_sunShafts" ); + + renderSystem->SetColor4( VdotS[0], 1.0f, 1.0f, 2.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, sunShaftsMaterial ); + renderSystem->CaptureRenderToImage( "_sunShaftsMask" ); + + // blur textures + for ( int i = 0; i < r_sunShaftsQuality.GetInteger(); i++ ) { + renderSystem->SetColor4( r_sunShaftsSize.GetFloat(), ndc.x, ndc.y, 3.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, sunShaftsMaterial ); + renderSystem->CaptureRenderToImage( "_sunShafts" ); + renderSystem->SetColor4( r_sunShaftsSize.GetFloat(), ndc.x, ndc.y, 4.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, sunShaftsMaterial ); + renderSystem->CaptureRenderToImage( "_sunShaftsMask" ); + } + renderSystem->UnCrop(); + + // add mask to scene + renderSystem->SetColor4( r_sunShaftsStrength.GetFloat(), r_sunShaftsMaskStrength.GetFloat(), 1.0f, 5.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, sunShaftsMaterial ); +} + +/* +=================== +idPlayerView::PostFX_LensFlare +=================== +*/ +void idPlayerView::PostFX_LensFlare() { + idMat3 axis; + idVec3 origin; + idVec3 viewVector[3]; + player->GetViewPos( origin, axis ); + player->viewAngles.ToVectors( &viewVector[0], &viewVector[1], &viewVector[2] ); + + idVec3 sunOrigin = idVec3( r_sunOriginX.GetFloat(), r_sunOriginY.GetFloat(), r_sunOriginZ.GetFloat() ) ; + idVec3 dist = origin - sunOrigin; + idVec3 sunVector = dist / dist.Length(); + + float VdotS[ 3 ]; + for ( int i = 0; i < 3; i++ ) { + VdotS[ i ] = viewVector[ i ] * -sunVector; + } + VdotS[ 0 ] = idMath::ClampFloat( 0.0f, 1.0f, VdotS[ 0 ] ); + VdotS[ 0 ] *= VdotS[ 0 ]; + + + if ( VdotS[ 0 ] > 0 ) { + trace_t trace; + gameLocal.clip.TracePoint( trace, origin, sunOrigin, MASK_SOLID, player ); + + if ( trace.c.material->NoFragment() || trace.fraction == 1.0f ) { // Trace succeeded, or it hit a skybox + float strength = VdotS[ 0 ] * r_lensFlareStrength.GetFloat(); + float length; + idVec3 ndc; + idVec2 ssDir, ssDist, uv; + + renderSystem->GlobalToNormalizedDeviceCoordinates( sunOrigin, ndc ); + + ndc.x = ndc.x * 0.5f + 0.5f; + ndc.y = 1.0f - ( ndc.y * 0.5f + 0.5f ); + ssDist.x = 0.5f - ndc.x; + ssDist.y = 0.5f - ndc.y; + length = ssDist.Length(); + ssDir = ssDist / length; + + // Draw a lens flare on the screen + uv.x = ( ndc.x * SCREEN_WIDTH ) - 256.0f; + uv.y = ( ndc.y * SCREEN_HEIGHT ) - 256.0f; + renderSystem->SetColor4( VdotS[ 0 ], VdotS[ 0 ], VdotS[ 0 ], 0.0f ); + renderSystem->DrawStretchPic( uv.x, uv.y, 512.0f, 512.0f, 0.0f, 1.0f, 1.0f, 0.0f, lensFlareMaterial ); + + uv.x = ( ( length * -1.25f * ssDir.x + 0.5f ) * SCREEN_WIDTH ) - 32.0f; + uv.y = ( ( length * -1.25f * ssDir.y + 0.5f ) * SCREEN_HEIGHT ) - 32.0f; + renderSystem->SetColor4( strength * 0.1, strength * 0.3, strength * 1.0, 1.0f ); + renderSystem->DrawStretchPic( uv.x, uv.y, 64.0f, 64.0f, 0.0f, 1.0f, 1.0f, 0.0f, lensFlareMaterial ); + + uv.x = ( ( length * 0.05f * ssDir.x + 0.5f ) * SCREEN_WIDTH ) - 16.0f; + uv.y = ( ( length * 0.05f * ssDir.y + 0.5f ) * SCREEN_HEIGHT ) - 16.0f; + renderSystem->SetColor4( strength * 0.1, strength * 0.3, strength * 1.0, 1.0f ); + renderSystem->DrawStretchPic( uv.x, uv.y, 32.0f, 32.0f, 0.0f, 1.0f, 1.0f, 0.0f, lensFlareMaterial ); + + uv.x = ( ( length * -0.3333f * ssDir.x + 0.5f ) * SCREEN_WIDTH ) - 16.0f; + uv.y = ( ( length * -0.3333f * ssDir.y + 0.5f ) * SCREEN_HEIGHT ) - 16.0f; + renderSystem->SetColor4( strength * 0.1, strength * 0.3, strength * 1.0, 2.0f ); + renderSystem->DrawStretchPic( uv.x, uv.y, 32.0f, 32.0f, 0.0f, 1.0f, 1.0f, 0.0f, lensFlareMaterial ); + + uv.x = ( ( length * 0.75f * ssDir.x + 0.5f ) * SCREEN_WIDTH ) - 64.0f; + uv.y = ( ( length * 0.75f * ssDir.y + 0.5f ) * SCREEN_HEIGHT ) - 64.0f; + renderSystem->SetColor4( strength * 0.1, strength * 0.3, strength * 1.0, 2.0f ); + renderSystem->DrawStretchPic( uv.x, uv.y, 128.0f, 128.0f, 0.0f, 1.0f, 1.0f, 0.0f, lensFlareMaterial ); + + uv.x = ( ( length * 0.15f * ssDir.x + 0.5f ) * SCREEN_WIDTH ) - 32.0; + uv.y = ( ( length * 0.15f * ssDir.y + 0.5f ) * SCREEN_HEIGHT ) - 32.0f; + renderSystem->SetColor4( strength * 0.1, strength * 0.3, strength * 1.0, 3.0f ); + renderSystem->DrawStretchPic( uv.x, uv.y, 64.0f, 64.0f, 0.0f, 1.0f, 1.0f, 0.0f, lensFlareMaterial ); + + uv.x = ( ( length * -0.6f * ssDir.x + 0.5f ) * SCREEN_WIDTH ) - 16.0; + uv.y = ( ( length * -0.6f * ssDir.y + 0.5f ) * SCREEN_HEIGHT ) - 16.0f; + renderSystem->SetColor4( strength * 0.1, strength * 0.3, strength * 1.0, 3.0f ); + renderSystem->DrawStretchPic( uv.x, uv.y, 32.0f, 32.0f, 0.0f, 1.0f, 1.0f, 0.0f, lensFlareMaterial ); + + uv.x = ( ( length * -0.1f * ssDir.x + 0.5f ) * SCREEN_WIDTH ) - 16.0; + uv.y = ( ( length * -0.1f * ssDir.y + 0.5f ) * SCREEN_HEIGHT ) - 16.0f; + renderSystem->SetColor4( strength * 0.1, strength * 0.3, strength * 1.0, 3.0f ); + renderSystem->DrawStretchPic( uv.x, uv.y, 32.0f, 32.0f, 0.0f, 1.0f, 1.0f, 0.0f, lensFlareMaterial ); + + uv.x = ( ( length * 0.4f * ssDir.x + 0.5f ) * SCREEN_WIDTH ) - 16.0f; + uv.y = ( ( length * 0.4f * ssDir.y + 0.5f ) * SCREEN_HEIGHT ) - 16.0f; + renderSystem->SetColor4( strength * 0.1, strength * 0.3, strength * 1.0, 4.0f ); + renderSystem->DrawStretchPic( uv.x, uv.y, 32.0f, 32.0f, 0.0f, 1.0f, 1.0f, 0.0f, lensFlareMaterial ); + + uv.x = ( ( length * -0.4f * ssDir.x + 0.5f ) * SCREEN_WIDTH ) - 32.0f; + uv.y = ( ( length * -0.4f * ssDir.y + 0.5f ) * SCREEN_HEIGHT ) - 32.0f; + renderSystem->SetColor4( strength * 0.1, strength * 0.3, strength * 1.0, 4.0f ); + renderSystem->DrawStretchPic( uv.x, uv.y, 64.0f, 64.0f, 0.0f, 1.0f, 1.0f, 0.0f, lensFlareMaterial ); + + uv.x = ( ( length * 0.5f * ssDir.x + 0.5f ) * SCREEN_WIDTH ) - 128.0f; + uv.y = ( ( length * 0.5f * ssDir.y + 0.5f ) * SCREEN_HEIGHT ) - 128.0f; + renderSystem->SetColor4( strength * 0.1, strength * 0.3, strength * 1.0, 5.0f ); + renderSystem->DrawStretchPic( uv.x, uv.y, 256.0f, 256.0f, 0.0f, 1.0f, 1.0f, 0.0f, lensFlareMaterial ); + } + } +} + +/* +=================== +idPlayerView::PostFX_DoF +=================== +*/ +void idPlayerView::PostFX_DoF() { + if ( r_useDepthOfField.GetInteger() == 1 && !gameLocal.inCinematic ) { + trace_t trace; + idVec3 start = hackedView.vieworg; + idVec3 end = start + hackedView.viewaxis.ToAngles().ToForward() * 8192.0f; + gameLocal.clip.TracePoint( trace, start, end, MASK_SHOT_RENDERMODEL, player ); + focusDistance = focusDistance * 0.9 + trace.fraction * 0.1; + } + + if ( DoFConditionCheck() ) { + int nWidth = renderSystem->GetScreenWidth() / 2.0f; + int nHeight = renderSystem->GetScreenHeight() / 2.0f; + renderSystem->CaptureRenderToImage( "_currentRender" ); + + RenderDepth( true ); + + renderSystem->CropRenderSize( nWidth, nHeight, true, true ); + if ( r_useDepthOfField.GetInteger() == 2 ) + renderSystem->SetColor4( r_dofNear.GetInteger(), r_dofFocus.GetInteger(), r_dofFar.GetInteger(), 2.0f ); + else if ( gameLocal.inCinematic ) + renderSystem->SetColor4( r_dofNear.GetInteger(), r_dofFocus.GetInteger(), r_dofFar.GetInteger(), 2.0f ); // don't blur in front of the focal plane for cinematics + else if ( player->weapon.GetEntity()->IsReloading() ) + renderSystem->SetColor4( -1.0f, 0.5f, 64.0f, 2.0f ); // use specific settings for reloading dof + else if ( player->bIsZoomed ) + renderSystem->SetColor4( focusDistance, 1.0f, 1.0f, 1.0f ); // zoom uses a mask texture + else + renderSystem->SetColor4( focusDistance, 1.0f, 1.0f, 0.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, dofMaterial ); + renderSystem->CaptureRenderToImage( "_dof" ); + renderSystem->UnCrop(); + + // blur scene using our depth of field mask + renderSystem->SetColor4( r_dofBlurScale.GetFloat(), r_dofBlurQuality.GetInteger(), 1.0f, 3.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, dofMaterial ); + if ( r_dofBlurQuality.GetInteger() == 2 ) { + renderSystem->CaptureRenderToImage( "_currentRender" ); + renderSystem->SetColor4( r_dofBlurScale.GetFloat(), r_dofBlurQuality.GetInteger() + 2.0f, 1.0f, 3.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, dofMaterial ); + } + } +} + +/* +=================== +idPlayerView::DoFConditionCheck +=================== +*/ +bool idPlayerView::DoFConditionCheck() { + if ( r_dofConditionCinematic.GetBool() && gameLocal.inCinematic || + r_dofConditionGUI.GetBool() && player->GuiActive() || + r_dofConditionReload.GetBool() && player->weapon.GetEntity()->IsReloading() || + r_dofConditionTalk.GetBool() && player->GetTalkCursor() || + r_dofConditionZoom.GetBool() && player->bIsZoomed || + r_dofConditionAlways.GetBool() ) + return true; + else + return false; +} + +/* +=================== +idPlayerView::PostFX_MotionBlur +=================== +*/ +void idPlayerView::PostFX_MotionBlur() { + float fFPS = idMath::ClampFloat( 0.0f, 1.0f, 1.0f / ( (float)( gameLocal.time - prevTime ) * 0.06f ) ); + + if ( r_useMotionBlur.GetInteger() > 1 ) { + renderSystem->CaptureRenderToImage( "_currentRender" ); + renderSystem->SetColor4( r_motionBlurLerp.GetFloat() * fFPS, 1.0f, 1.0f, 0.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, motionBlurMaterial ); + renderSystem->CaptureRenderToImage( "_prevRender" ); + } + + if ( MBConditionCheck() && ( r_useMotionBlur.GetInteger() == 1 || r_useMotionBlur.GetInteger() == 3 ) ) { + int nWidth = renderSystem->GetScreenWidth() / 2.0f; + int nHeight = renderSystem->GetScreenHeight() / 2.0f; + int nQuality = idMath::ClampInt( 1, 4, r_motionBlurQuality.GetInteger() ); + + float parm[6]; + parm[0] = player->viewAngles.yaw - prevViewAngles.yaw; + parm[1] = player->viewAngles.pitch - prevViewAngles.pitch; + if ( parm[0] > 180.0f ) { + parm[0] -= 360.0f; + prevViewAngles.yaw += 360.0f; + } + if ( parm[0] < -180.0f ) { + parm[0] += 360.0f; + prevViewAngles.yaw -= 360.0f; + } + parm[0] = idMath::ClampFloat( -r_motionBlurMaxThreshold.GetInteger(), r_motionBlurMaxThreshold.GetInteger(), parm[0] ); + parm[1] = idMath::ClampFloat( -r_motionBlurMaxThreshold.GetInteger(), r_motionBlurMaxThreshold.GetInteger(), parm[1] ); + float f = idMath::Fabs( player->viewAngles.pitch ) / 90.0f * 0.5f; + parm[2] = player->viewAngles.pitch < 0.0f ? 1.0f - f : f; + parm[3] = idMath::Fabs( parm[0] ) > idMath::Fabs( parm[1] ) ? idMath::Fabs( player->viewAngles.pitch ) / 90.0f : 0.0f; + parm[4] = r_motionBlurFactor.GetFloat(); + + parm[0] *= r_motionBlurScale.GetFloat() * fFPS; + parm[1] *= r_motionBlurScale.GetFloat() * fFPS; + + renderSystem->CaptureRenderToImage( "_currentRender" ); + + RenderDepth( true ); + + renderSystem->CropRenderSize( nWidth, nHeight, true, true ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, shiftScale.y, shiftScale.x, 0.0f, currentRenderMaterial ); + renderSystem->CaptureRenderToImage( "_mbXY" ); + renderSystem->CaptureRenderToImage( "_mbZ" ); + for ( int i = 0; i < nQuality; i++ ) { + renderSystem->SetColor4( parm[0], parm[1], r_motionBlurMaskDistance.GetFloat(), 1.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, motionBlurMaterial ); + renderSystem->CaptureRenderToImage( "_mbXY" ); + renderSystem->SetColor4( parm[0], parm[2], r_motionBlurMaskDistance.GetFloat(), 2.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, motionBlurMaterial ); + renderSystem->CaptureRenderToImage( "_mbZ" ); + } + renderSystem->UnCrop(); + + renderSystem->SetColor4( parm[3], parm[4], r_motionBlurMaskDistance.GetFloat(), 3.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, motionBlurMaterial ); + } + + float fLerp = 0.5f;//idMath::ClampFloat( 0.0f, 0.99f, r_motionBlurLerp.GetFloat() ); + prevViewAngles = prevViewAngles * fLerp + player->viewAngles * ( 1.0 - fLerp ); +} + +/* +=================== +idPlayerView::MBConditionCheck +=================== +*/ +bool idPlayerView::MBConditionCheck() { + int nThreshold = r_motionBlurMinThreshold.GetInteger() < 1 ? 1 : r_motionBlurMinThreshold.GetInteger(); + + if ( gameLocal.inCinematic || player->GuiActive() || ( gameLocal.time - prevTime ) > SEC2MS( 1.0f / r_motionBlurFPSThreshold.GetFloat() ) ) + return false; + + if ( ( player->viewAngles.pitch >= prevViewAngles.pitch + nThreshold ) || + ( player->viewAngles.pitch <= prevViewAngles.pitch - nThreshold ) || + ( player->viewAngles.yaw >= prevViewAngles.yaw + nThreshold ) || + ( player->viewAngles.yaw <= prevViewAngles.yaw - nThreshold ) ) + return true; + else + return false; +} + +/* +=================== +idPlayerView::PostFX_ColorGrading +=================== +*/ +void idPlayerView::PostFX_ColorGrading() { + int nWidth = renderSystem->GetScreenWidth() / 2.0f; + int nHeight = renderSystem->GetScreenHeight() / 2.0f; + + renderSystem->CaptureRenderToImage( "_currentRender" ); + + // unsharp mask buffer + renderSystem->CropRenderSize( nWidth, nHeight, true, true ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, shiftScale.y, shiftScale.x, 0.0f, currentRenderMaterial ); + renderSystem->CaptureRenderToImage( "_blurRender" ); + renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 0.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, colorGradingMaterial ); + renderSystem->CaptureRenderToImage( "_blurRender" ); + renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, colorGradingMaterial ); + renderSystem->CaptureRenderToImage( "_blurRender" ); + renderSystem->UnCrop(); + + renderSystem->SetColor4( r_colorGradingParm.GetInteger(), r_colorGradingSharpness.GetFloat(), 1.0f, ( r_colorGradingType.GetFloat() + 2.0f ) ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, colorGradingMaterial ); +} + +/* +=================== +idPlayerView::PostFX_ExplosionFX +=================== +*/ +void idPlayerView::PostFX_ExplosionFX() { + if ( gameLocal.explosionTime >= gameLocal.time ) { + idMat3 axis; + idVec3 origin; + idVec3 viewVector[3]; + player->GetViewPos( origin, axis ); + player->viewAngles.ToVectors( &viewVector[0], &viewVector[1], &viewVector[2] ); + + idVec3 expOrigin = gameLocal.explosionOrigin; + idVec3 dist = origin - expOrigin; + float length = dist.Length(); + idVec3 expVector = dist / length; + + float VdotE = idMath::ClampFloat( 0.0f, 1.0f, viewVector[ 0 ] * -expVector ); + + idVec3 ndc; + renderSystem->GlobalToNormalizedDeviceCoordinates( gameLocal.explosionOrigin, ndc ); + + renderSystem->CaptureRenderToImage( "_currentRender" ); + ndc.x = ndc.x * 0.5 + 0.5; + ndc.y = ndc.y * 0.5 + 0.5; + + float time = (float)gameLocal.explosionTime - (float)gameLocal.time; + float radius = idMath::ClampFloat( 0.0f, 1.0f, gameLocal.explosionRadius / 200.0f ); + float damage = idMath::ClampFloat( 0.0f, 1.0f, gameLocal.explosionDamage / 250.0f ); + float distance = 1.0f - idMath::ClampFloat( 0.0f, 1.0f, length / 1024.0f ); + float atten = idMath::ClampFloat( 0.0f, 1.0f, time / ( g_explosionFXTime.GetFloat() * 1000 ) ); + float scale = radius * damage * distance * atten * VdotE * g_explosionFXScale.GetFloat(); + + renderSystem->SetColor4( ndc.x, ndc.y, scale, 1.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, explosionFXMaterial ); + } +} + +/* +=================== +idPlayerView::PostFX_IRGoggles +=================== +*/ +void idPlayerView::PostFX_IRGoggles() { + if ( player->bIRGogglesOn && !player->PowerUpActive( BERSERK ) ) { + renderSystem->CaptureRenderToImage( "_currentRender" ); + renderSystem->SetColor4( renderSystem->GetScreenWidth() / 256.0f, renderSystem->GetScreenHeight() / 256.0f, 1.0f, g_goggleType.GetFloat() ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, irGogglesMaterial ); + } +} + +/* +=================== +idPlayerView::PostFX_ScreenFrost +=================== +*/ +void idPlayerView::PostFX_ScreenFrost() { + float alpha = player->nScreenFrostAlpha / ( g_screenFrostTime.GetFloat() * 60.0f ); + if ( alpha ) { + renderSystem->CaptureRenderToImage( "_currentRender" ); + renderSystem->SetColor4( alpha, 1.0f, 1.0f, 1.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, screenFrostMaterial ); + } +} + +/* +=================== +idPlayerView::PostFX_Vignetting +=================== +*/ +void idPlayerView::PostFX_Vignetting() { + renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 0.0f, 1.0f, 1.0f, vignettingMaterial ); +} + +/* +=================== +idPlayerView::PostFX_Filmgrain +=================== +*/ +void idPlayerView::PostFX_Filmgrain() { + float size = 128.0f * r_filmgrainScale.GetFloat(); + renderSystem->SetColor4( renderSystem->GetScreenWidth() / size, renderSystem->GetScreenHeight() / size, r_filmgrainStrength.GetFloat(), r_filmgrainBlendMode.GetInteger() ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 0.0f, 1.0f, 1.0f, filmgrainMaterial ); +} + +/* +=================== +idPlayerView::PostFX_AdrenalineVision +=================== +*/ +void idPlayerView::PostFX_AdrenalineVision() { + int nWidth = renderSystem->GetScreenWidth() / 2.0f; + int nHeight = renderSystem->GetScreenHeight() / 2.0f; + + renderSystem->CaptureRenderToImage( "_currentRender" ); + + // unsharp mask buffer + renderSystem->CropRenderSize( nWidth, nHeight, true, true ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, shiftScale.y, shiftScale.x, 0.0f, currentRenderMaterial ); + renderSystem->CaptureRenderToImage( "_blurRender" ); + renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 0.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, adrenalineMaterial ); + renderSystem->CaptureRenderToImage( "_blurRender" ); + renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, adrenalineMaterial ); + renderSystem->CaptureRenderToImage( "_blurRender" ); + renderSystem->UnCrop(); + + int adrenalTime = player->inventory.powerupEndTime[ ADRENALINE ] - gameLocal.time; + float alpha = ( adrenalTime < 10000 ) ? (float)adrenalTime / 10000 : 1.0f; + alpha = ( alpha < 0.0f ) ? 0.0f : alpha; + + renderSystem->SetColor4( alpha, ( alpha + 1.0f ), 1.0f, 2.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, adrenalineMaterial ); +} + +/* +=================== +idPlayerView::PostFX_DoubleVision +=================== +*/ +void idPlayerView::PostFX_DoubleVision() { + int nWidth = renderSystem->GetScreenWidth() / 2; + int nHeight = renderSystem->GetScreenHeight() / 2; + int offset = dvFinishTime - gameLocal.time; + float scale = ( offset * g_dvAmplitude.GetFloat() ) > 0.5f ? 0.5f : offset * g_dvAmplitude.GetFloat(); + float shift = fabs( scale * sin( sqrtf( offset ) * g_dvFrequency.GetFloat() ) ); + + renderSystem->CaptureRenderToImage( "_currentRender" ); + + // if double vision, render to a texture + renderSystem->CropRenderSize( nWidth, nHeight, true, true ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, shiftScale.y, shiftScale.x, 0.0f, currentRenderMaterial ); + renderSystem->CaptureRenderToImage( "_scratch" ); + renderSystem->UnCrop(); + + // carry red tint if in berserk mode + idVec4 color( 1.0f, 1.0f, 1.0f, 1.0f ); + if ( gameLocal.time < player->inventory.powerupEndTime[ BERSERK ] ) + color.y = color.z = 0.0f; + + renderSystem->SetColor4( color.x, color.y, color.z, 1.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, shift, 1.0f, 1.0f, 0.0f, scratchMaterial ); + renderSystem->SetColor4( color.x, color.y, color.z, 0.5f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f - shift, 0.0f, scratchMaterial ); +} + +/* +=================== +idPlayerView::PostFX_BerserkVision +=================== +*/ +void idPlayerView::PostFX_BerserkVision() { + int berserkTime = player->inventory.powerupEndTime[ BERSERK ] - gameLocal.time; + if ( berserkTime > 0 ) { + // start fading if within 10 seconds of going away + float alpha = ( berserkTime < 10000 ) ? (float)berserkTime / 10000 : 1.0f; + renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, alpha ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 0.0f, 1.0f, 1.0f, berserkMaterial ); + } + + int nWidth = renderSystem->GetScreenWidth() / 2; + int nHeight = renderSystem->GetScreenHeight() / 2; + + renderSystem->CaptureRenderToImage( "_currentRender" ); + + // if double vision, render to a texture + renderSystem->CropRenderSize( nWidth, nHeight, true, true ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, shiftScale.y, shiftScale.x, 0.0f, currentRenderMaterial ); + renderSystem->CaptureRenderToImage( "_scratch" ); + renderSystem->UnCrop(); + + renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 1.0f, 1.0f, 0.0f, scratchMaterial ); +} + +/* +=================== +idPlayerView::PostFX_InfluenceVision +=================== +*/ +void idPlayerView::PostFX_InfluenceVision() { + float distance = 0.0f; + float pct = 1.0f; + + if ( player->GetInfluenceEntity() ) { + distance = ( player->GetInfluenceEntity()->GetPhysics()->GetOrigin() - player->GetPhysics()->GetOrigin() ).Length(); + if ( player->GetInfluenceRadius() != 0.0f && distance < player->GetInfluenceRadius() ) { + pct = distance / player->GetInfluenceRadius(); + pct = 1.0f - idMath::ClampFloat( 0.0f, 1.0f, pct ); + } + } + if ( player->GetInfluenceMaterial() ) { + renderSystem->CaptureRenderToImage( "_currentRender" ); + renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, pct ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 0.0f, 1.0f, 1.0f, player->GetInfluenceMaterial() ); + } else if ( player->GetInfluenceEntity() ) { + int offset = 25 + sinf( gameLocal.time ); +// PostFX_DoubleVision( view, pct * offset ); + } +} + +/* +=================== +idPlayerView::PostFX_BFGVision +=================== +*/ +void idPlayerView::PostFX_BFGVision() { + renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 0.0f, 1.0f, 1.0f, bfgMaterial ); +} + +/* +=================== +idPlayerView::PostFX_TunnelVision +=================== +*/ +void idPlayerView::PostFX_TunnelVision() { + float health = 0.0f; + float alpha; + + if ( g_testHealthVision.GetFloat() != 0.0f ) + health = g_testHealthVision.GetFloat(); + else + health = player->health; + +// sikk---> Health Management System (Health Regen) + if ( g_healthManagementType.GetInteger() == 2 ) + alpha = idMath::ClampFloat( 0.0f, 1.0f, health / g_healthRegenFeedback.GetFloat() ); + else + alpha = idMath::ClampFloat( 0.0f, 1.0f, health / 100.0f ); +// <---sikk + + if ( alpha < 1.0f ) { +// sikk---> Health Management System (Health Regen) ( also fix for "g_testHealthVision" ) + if ( g_healthManagementType.GetInteger() == 2 || g_testHealthVision.GetFloat() ) + renderSystem->SetColor4( MS2SEC( gameLocal.time ), 1.0f, 1.0f, alpha ); + else + renderSystem->SetColor4( ( player->health <= 0.0f ) ? MS2SEC( gameLocal.time ) : lastDamageTime, 1.0f, 1.0f, ( player->health <= 0.0f ) ? 0.0f : alpha ); + if ( g_healthManagementType.GetInteger() == 2 ) + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 0.0f, 1.0f, 1.0f, tunnel2Material ); + else + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 0.0f, 1.0f, 1.0f, tunnelMaterial ); +// <---sikk + } +} + +/* +=================== +idPlayerView::PostFX_ScreenBlobs +=================== +*/ +void idPlayerView::PostFX_ScreenBlobs() { + for ( int i = 0; i < MAX_SCREEN_BLOBS; i++ ) { + screenBlob_t *blob = &screenBlobs[ i ]; + + if ( blob->finishTime <= gameLocal.time ) + continue; + + blob->y += blob->driftAmount; + + float fade = (float)( blob->finishTime - gameLocal.time ) / ( blob->finishTime - blob->startFadeTime ); + + if ( fade > 1.0f ) + fade = 1.0f; + + if ( fade ) { + renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, fade ); + renderSystem->DrawStretchPic( blob->x, blob->y, blob->w, blob->h, blob->s1, blob->t1, blob->s2, blob->t2, blob->material ); + } + } +} + +/* +=================== +idPlayerView::PostFX_ArmorPulse +=================== +*/ +void idPlayerView::PostFX_ArmorPulse() { + float armorPulse = ( gameLocal.time - player->lastArmorPulse ) / 250.0f; + + if ( armorPulse > 0.0f && armorPulse < 1.0f ) { + renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f - armorPulse ); + renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 0.0f, 1.0f, 1.0f, armorMaterial ); + } +} +// <---sikk diff --git a/game/PlayerView.h b/game/PlayerView.h index bc90458..7dd7641 100644 --- a/game/PlayerView.h +++ b/game/PlayerView.h @@ -83,52 +83,135 @@ public: void RenderPlayerView( idUserInterface *hud ); void Fade( idVec4 color, int time ); - void Flash( idVec4 color, int time ); - void AddBloodSpray( float duration ); // temp for view testing void EnableBFGVision( bool b ) { bfgVision = b; }; private: - void SingleView( idUserInterface *hud, const renderView_t *view ); - void DoubleVision( idUserInterface *hud, const renderView_t *view, int offset ); - void BerserkVision( idUserInterface *hud, const renderView_t *view ); - void InfluenceVision( idUserInterface *hud, const renderView_t *view ); - void ScreenFade(); + void SingleView( const renderView_t *view ); + // sikk - Commented: Functions overridden + //void DoubleVision( const renderView_t *view, int offset ); + //void BerserkVision( const renderView_t *view ); + //void InfluenceVision( const renderView_t *view ); + void ScreenFade( void ); + screenBlob_t * GetScreenBlob( void ); - screenBlob_t * GetScreenBlob(); + const idMaterial * tunnelMaterial; // health tunnel vision + const idMaterial * armorMaterial; // armor damage view effect + const idMaterial * berserkMaterial; // berserk effect + const idMaterial * irGogglesMaterial; // ir effect + const idMaterial * bloodSprayMaterial; // blood spray + const idMaterial * bfgMaterial; // when targeted with BFG + const idMaterial * lagoMaterial; // lagometer drawing + + int dvFinishTime; // double vision will be stopped at this time + int kickFinishTime; // view kick will be stopped at this time + idAngles kickAngles; + bool bfgVision; // + idVec4 fadeColor; // fade color + idVec4 fadeToColor; // color to fade to + idVec4 fadeFromColor; // color to fade from + float fadeRate; // fade rate + int fadeTime; // fade time + float lastDamageTime; // accentuate the tunnel effect for a while screenBlob_t screenBlobs[MAX_SCREEN_BLOBS]; - int dvFinishTime; // double vision will be stopped at this time - const idMaterial * dvMaterial; // material to take the double vision screen shot - - int kickFinishTime; // view kick will be stopped at this time - idAngles kickAngles; - - bool bfgVision; // - - const idMaterial * tunnelMaterial; // health tunnel vision - const idMaterial * armorMaterial; // armor damage view effect - const idMaterial * berserkMaterial; // berserk effect - const idMaterial * irGogglesMaterial; // ir effect - const idMaterial * bloodSprayMaterial; // blood spray - const idMaterial * bfgMaterial; // when targeted with BFG - const idMaterial * lagoMaterial; // lagometer drawing - float lastDamageTime; // accentuate the tunnel effect for a while - - idVec4 fadeColor; // fade color - idVec4 fadeToColor; // color to fade to - idVec4 fadeFromColor; // color to fade from - float fadeRate; // fade rate - int fadeTime; // fade time - - idAngles shakeAng; // from the sound sources + idAngles shakeAng; // from the sound sources idPlayer * player; renderView_t view; + +// sikk---> PostProcess Effects + void DoPostFX( void ); + void PostFX_SoftShadows( void ); + void PostFX_EdgeAA( void ); + void PostFX_HDR( void ); + void PostFX_Bloom( void ); + void PostFX_MotionBlur( void ); + void PostFX_DoF( void ); + void PostFX_SSIL( void ); + void PostFX_SSAO( void ); + void PostFX_SunShafts( void ); + void PostFX_LensFlare( void ); + void PostFX_ColorGrading( void ); + void PostFX_ExplosionFX( void ); + void PostFX_IRGoggles( void ); + void PostFX_ScreenFrost( void ); + void PostFX_CelShading( void ); + void PostFX_Filmgrain( void ); + void PostFX_Vignetting( void ); + + void PostFX_AdrenalineVision( void ); + void PostFX_DoubleVision( void ); + void PostFX_BerserkVision( void ); + void PostFX_InfluenceVision( void ); + void PostFX_BFGVision( void ); + void PostFX_TunnelVision( void ); + void PostFX_ScreenBlobs( void ); + void PostFX_ArmorPulse( void ); + + void RenderDepth( bool bCrop ); + void RenderNormals( bool bFace ); + void ToggleShadows( bool noShadows ); + void ResetShadows( void ); + bool DoFConditionCheck( void ); + bool MBConditionCheck( void ); + + const idMaterial * blackMaterial; // Black material (for general use) + const idMaterial * whiteMaterial; // White material (for general use) + const idMaterial * currentRenderMaterial; // Current Render material (for general use) + const idMaterial * scratchMaterial; // Scratch material (for general use) + const idMaterial * depthMaterial; // Depth material (for general use) + const idMaterial * normalsMaterial; // View Space Normals material (for general use) + const idMaterial * softShadowsMaterial; // Soft Shadow material + const idMaterial * edgeAAMaterial; // Edge AA material + const idMaterial * hdrLumBaseMaterial; // HDR Luminance Base material + const idMaterial * hdrLumAverageMaterial; // HDR Luminance Average material + const idMaterial * hdrLumAdaptedMaterial; // HDR Luminance Adapted material + const idMaterial * hdrBrightPass1Material; // HDR Bright Pass Filter material (Reinhard RGB) + const idMaterial * hdrBrightPass2Material; // HDR Bright Pass Filter material (Reinhard Yxy) + const idMaterial * hdrBrightPass3Material; // HDR Bright Pass Filter material (Exp) + const idMaterial * hdrBrightPass4Material; // HDR Bright Pass Filter material (Filmic simple) + const idMaterial * hdrBrightPass5Material; // HDR Bright Pass Filter material (Filmic complex) + const idMaterial * hdrBloomMaterial; // HDR Bloom material + const idMaterial * hdrFlareMaterial; // HDR Lens Flare material + const idMaterial * hdrGlareMaterial; // HDR Glare material + const idMaterial * hdrFinalMaterial; // HDR Final Tone Mapping material + const idMaterial * bloomMaterial; // Bloom material + const idMaterial * ssilMaterial; // SSIL material + const idMaterial * ssaoMaterial; // SSAO material + const idMaterial * sunShaftsMaterial; // Sun Shafts material + const idMaterial * lensFlareMaterial; // Lens Flare material + const idMaterial * dofMaterial; // DoF material + const idMaterial * motionBlurMaterial; // Motion Blur material + const idMaterial * colorGradingMaterial; // Color Grading material + const idMaterial * screenFrostMaterial; // Screen Frost material + const idMaterial * celShadingMaterial; // Cel Shading material + const idMaterial * filmgrainMaterial; // Filmgrain material + const idMaterial * vignettingMaterial; // Vignetting material + const idMaterial * tunnel2Material; // health tunnel vision for Health Management System (Health Regen) + const idMaterial * adrenalineMaterial; // Adrenaline Vision material + const idMaterial * explosionFXMaterial; // Explosion FX material + + renderView_t hackedView; + float focusDistance; // Holds focus distance for depth of field + idAngles prevViewAngles; // Holds previous frame's player view angles + int prevTime; // Holds previous frame's time + bool bDepthRendered; // Holds whether the depth map has been rendered for the current frame + bool bDitherRendered; // Holds whether the dither map has been rendered + float fDitherSize; // Holds previous frame's dither size to check for changes + pvsHandle_t playerPVS; // Holds player's current pvs (for soft shadows) + bool bSoftShadows; // a soft shadows toggle used so ResetShadows() is only run once when r_useSoftShadows = 0 +// <---sikk + +// sikk---> PostProccess Scaling Fix + int screenHeight; + int screenWidth; + idVec2 shiftScale; +// <---sikk }; #endif /* !__GAME_PLAYERVIEW_H__ */ diff --git a/game/Projectile.cpp b/game/Projectile.cpp index 6460ae0..d4bfe32 100644 --- a/game/Projectile.cpp +++ b/game/Projectile.cpp @@ -248,6 +248,8 @@ void idProjectile::Create( idEntity *owner, const idVec3 &start, const idVec3 &d damagePower = 1.0f; + renderEntity.suppressSurfaceInViewID = -8; // sikk - Depth Render + UpdateVisuals(); state = CREATED; @@ -368,7 +370,7 @@ void idProjectile::Launch( const idVec3 &start, const idVec3 &dir, const idVec3 } // don't do tracers on client, we don't know origin and direction - if ( spawnArgs.GetBool( "tracers" ) && gameLocal.random.RandomFloat() > 0.5f ) { + if ( spawnArgs.GetBool( "tracers" ) && ( gameLocal.random.RandomFloat() < g_tracerFrequency.GetFloat() ) ) { // sikk - Tracer Frequency SetModel( spawnArgs.GetString( "model_tracer" ) ); projectileFlags.isTracer = true; } @@ -587,6 +589,14 @@ bool idProjectile::Collide( const trace_t &collision, const idVec3 &velocity ) { idPlayer *player = static_cast( owner.GetEntity() ); player->AddProjectileHits( 1 ); damageScale *= player->PowerUpModifier( PROJECTILE_DAMAGE ); + +// sikk---> Blood Spray Screen Effect + if ( g_showBloodSpray.GetBool() ) { + idVec3 vLength = player->GetEyePosition() - ent->GetPhysics()->GetOrigin(); + if ( vLength.Length() <= g_bloodSprayDistance.GetFloat() && gameLocal.random.RandomFloat() < g_bloodSprayFrequency.GetFloat() ) + player->playerView.AddBloodSpray( g_bloodSprayTime.GetFloat() ); + } +// <---sikk } } @@ -843,6 +853,9 @@ void idProjectile::Explode( const trace_t &collision, idEntity *ignore ) { renderEntity.shaderParms[SHADERPARM_ALPHA] = 1.0f; renderEntity.shaderParms[SHADERPARM_TIMEOFFSET] = -MS2SEC( gameLocal.time ); renderEntity.shaderParms[SHADERPARM_DIVERSITY] = gameLocal.random.CRandomFloat(); + + renderEntity.suppressSurfaceInViewID = -8; // sikk - Depth Render + Show(); removeTime = ( removeTime > 3000 ) ? removeTime : 3000; } @@ -892,10 +905,14 @@ void idProjectile::Explode( const trace_t &collision, idEntity *ignore ) { if ( removeTime < delay * 1000 ) { removeTime = ( delay + 0.10 ) * 1000; } - PostEventSec( &EV_RadiusDamage, delay, ignore ); +// sikk---> Entities hit directly by a projectile will no longer be ignored by splash damage +// PostEventSec( &EV_RadiusDamage, delay, ignore ); + PostEventSec( &EV_RadiusDamage, delay, NULL ); } else { - Event_RadiusDamage( ignore ); +// Event_RadiusDamage( ignore ); + Event_RadiusDamage( NULL ); } +// <---sikk } // spawn debris entities diff --git a/game/Pvs.cpp b/game/Pvs.cpp index 4536710..eb0b105 100644 --- a/game/Pvs.cpp +++ b/game/Pvs.cpp @@ -1386,7 +1386,6 @@ void idPVS::DrawCurrentPVS( const pvsHandle_t handle, const idVec3 &source ) con } #if ASYNC_WRITE_PVS - /* =================== idPVS::WritePVS @@ -1419,5 +1418,32 @@ void idPVS::ReadPVS( const pvsHandle_t handle, const idBitMsg &msg ) { common->Printf( "\n" ); } } - #endif + +// sikk---> Portal Sky Box +/* +================ +idPVS::CheckAreasForPortalSky +================ +*/ +bool idPVS::CheckAreasForPortalSky( const pvsHandle_t handle, const idVec3 &origin ) { + int sourceArea; + + if ( handle.i < 0 || handle.i >= MAX_CURRENT_PVS || handle.h != currentPVS[ handle.i ].handle.h ) + return false; + + sourceArea = gameRenderWorld->PointInArea( origin ); + + if ( sourceArea == -1 ) + return false; + + for ( int i = 0; i < numAreas; i++ ) { + if ( !( currentPVS[ handle.i ].pvs[ i >> 3 ] & ( 1 << ( i & 7 ) ) ) ) + continue; + if ( gameRenderWorld->CheckAreaForPortalSky( i ) ) + return true; + } + + return false; +} +// <---sikk diff --git a/game/Pvs.h b/game/Pvs.h index 963b178..56a9048 100644 --- a/game/Pvs.h +++ b/game/Pvs.h @@ -97,6 +97,8 @@ public: void ReadPVS( const pvsHandle_t handle, const idBitMsg &msg ); #endif + bool CheckAreasForPortalSky( const pvsHandle_t handle, const idVec3 &origin ); // sikk - Portal Sky Box + private: int numAreas; int numPortals; diff --git a/game/SmokeParticles.cpp b/game/SmokeParticles.cpp index b0867a7..19ab775 100644 --- a/game/SmokeParticles.cpp +++ b/game/SmokeParticles.cpp @@ -81,6 +81,8 @@ void idSmokeParticles::Init( void ) { renderEntity.hModel = renderModelManager->AllocModel(); renderEntity.hModel->InitEmpty( smokeParticle_SnapshotName ); + renderEntity.suppressSurfaceInViewID = -8; // sikk - Depth Render + // we certainly don't want particle shadows renderEntity.noShadow = 1; diff --git a/game/Weapon.cpp b/game/Weapon.cpp index 727e061..0520a9c 100644 --- a/game/Weapon.cpp +++ b/game/Weapon.cpp @@ -376,6 +376,7 @@ void idWeapon::Save( idSaveGame *savefile ) const { savefile->WriteBool( allowDrop ); savefile->WriteObject( projectileEnt ); + savefile->WriteFloat( wh_hide_distance ); // sikk - Weapon Handling System } /* @@ -541,6 +542,8 @@ void idWeapon::Restore( idRestoreGame *savefile ) { savefile->ReadBool( allowDrop ); savefile->ReadObject( reinterpret_cast( projectileEnt ) ); + + savefile->ReadFloat( wh_hide_distance ); // sikk - Weapon Handling System } /*********************************************************************** @@ -721,6 +724,8 @@ void idWeapon::Clear( void ) { projectileEnt = NULL; isFiring = false; + + wh_hide_distance = -15; // sikk - Weapon Handling System } /* @@ -796,7 +801,7 @@ void idWeapon::GetWeaponDef( const char *objectname, int ammoinclip ) { ammoType = GetAmmoNumForName( weaponDef->dict.GetString( "ammoType" ) ); ammoRequired = weaponDef->dict.GetInt( "ammoRequired" ); - clipSize = weaponDef->dict.GetInt( "clipSize" ); + clipSize = g_ammoCapacityType.GetBool() ? weaponDef->dict.GetInt( "custom_clipSize" ) : weaponDef->dict.GetInt( "clipSize" ); // sikk---> Ammo Management: Ammo Capacity Type lowAmmo = weaponDef->dict.GetInt( "lowAmmo" ); icon = weaponDef->dict.GetString( "icon" ); @@ -811,6 +816,8 @@ void idWeapon::GetWeaponDef( const char *objectname, int ammoinclip ) { hideTime = SEC2MS( weaponDef->dict.GetFloat( "hide_time", "0.3" ) ); hideDistance = weaponDef->dict.GetFloat( "hide_distance", "-15" ); + wh_hide_distance = weaponDef->dict.GetFloat( "wh_hide_distance", "-15" ); // sikk - Weapon Handling System + // muzzle smoke smokeName = weaponDef->dict.GetString( "smoke_muzzle" ); if ( *smokeName != '\0' ) { @@ -1303,7 +1310,7 @@ idWeapon::LowerWeapon void idWeapon::LowerWeapon( void ) { if ( !hide ) { hideStart = 0.0f; - hideEnd = hideDistance; + hideEnd = ( owner->GetWeaponHandling() && !owner->OnLadder() ) ? wh_hide_distance : hideDistance; // sikk - Weapon Handling System if ( gameLocal.time - hideStartTime < hideTime ) { hideStartTime = gameLocal.time - ( hideTime - ( gameLocal.time - hideStartTime ) ); } else { @@ -1322,7 +1329,7 @@ void idWeapon::RaiseWeapon( void ) { Show(); if ( hide ) { - hideStart = hideDistance; + hideStart = ( owner->GetWeaponHandling() && !owner->OnLadder() ) ? wh_hide_distance : hideDistance; // sikk - Weapon Handling System; hideEnd = 0.0f; if ( gameLocal.time - hideStartTime < hideTime ) { hideStartTime = gameLocal.time - ( hideTime - ( gameLocal.time - hideStartTime ) ); @@ -2895,14 +2902,18 @@ void idWeapon::Event_LaunchProjectiles( int num_projectiles, float spread, float kick_endtime = gameLocal.realClientTime + muzzle_kick_maxtime; } - if ( gameLocal.isClient ) { +// sikk---> Zoom Spread Reduction + if ( g_weaponHandlingType.GetBool() ) + spread = spawnArgs.GetFloat( "wh_spread", "0" ); +// <---sikk + if ( gameLocal.isClient ) { // predict instant hit projectiles if ( projectileDict.GetBool( "net_instanthit" ) ) { float spreadRad = DEG2RAD( spread ); muzzle_pos = muzzleOrigin + playerViewAxis[ 0 ] * 2.0f; for( i = 0; i < num_projectiles; i++ ) { - ang = idMath::Sin( spreadRad * gameLocal.random.RandomFloat() ); + ang = idMath::Sin( spreadRad * gameLocal.random.RandomFloat() * ( ( owner->bIsZoomed && g_weaponHandlingType.GetBool() ) ? ( ( GetEntityDefName() == "weapon_shotgun" ) ? 0.5 : 0.25f ) : 1.0f ) ); // sikk - Weapon Handling System: Zoom Spread Reduction spin = (float)DEG2RAD( 360.0f ) * gameLocal.random.RandomFloat(); dir = playerViewAxis[ 0 ] + playerViewAxis[ 2 ] * ( ang * idMath::Sin( spin ) ) - playerViewAxis[ 1 ] * ( ang * idMath::Cos( spin ) ); dir.Normalize(); @@ -2912,16 +2923,14 @@ void idWeapon::Event_LaunchProjectiles( int num_projectiles, float spread, float } } } - } else { - ownerBounds = owner->GetPhysics()->GetAbsBounds(); owner->AddProjectilesFired( num_projectiles ); float spreadRad = DEG2RAD( spread ); for( i = 0; i < num_projectiles; i++ ) { - ang = idMath::Sin( spreadRad * gameLocal.random.RandomFloat() ); + ang = idMath::Sin( spreadRad * gameLocal.random.RandomFloat() * ( ( owner->bIsZoomed && g_weaponHandlingType.GetBool() ) ? 0.25f : 1.0f ) ); // sikk - Weapon Handling System: Zoom Spread Reduction spin = (float)DEG2RAD( 360.0f ) * gameLocal.random.RandomFloat(); dir = playerViewAxis[ 0 ] + playerViewAxis[ 2 ] * ( ang * idMath::Sin( spin ) ) - playerViewAxis[ 1 ] * ( ang * idMath::Cos( spin ) ); dir.Normalize(); @@ -3098,6 +3107,14 @@ void idWeapon::Event_Melee( void ) { idThread::ReturnInt( hit ); owner->WeaponFireFeedback( &weaponDef->dict ); + +// sikk---> Blood Spray Screen Effect + if ( g_showBloodSpray.GetBool() ) { + if ( GetOwner()->GetCurrentWeapon() == 10 && gameLocal.random.RandomFloat() < g_bloodSprayFrequency.GetFloat() && hit ) + GetOwner()->playerView.AddBloodSpray( g_bloodSprayTime.GetFloat() ); + } +// <---sikk + return; } @@ -3190,4 +3207,4 @@ idWeapon::ClientPredictionThink */ void idWeapon::ClientPredictionThink( void ) { UpdateAnimation(); -} +} \ No newline at end of file diff --git a/game/Weapon.h b/game/Weapon.h index 4f8b374..63b15bb 100644 --- a/game/Weapon.h +++ b/game/Weapon.h @@ -158,6 +158,24 @@ public: virtual void ClientPredictionThink( void ); + float wh_hide_distance; // sikk - Weapon Handling System + + idEntityPtr* GetWorldModel( void ) { return &worldModel; }; // sikk - Depth Render + +// sikk---> Crosshair Positioning + idVec3 GetMuzzleOrigin( void ) { return muzzleOrigin; }; + idMat3 GetMuzzleAxis( void ) { return muzzleAxis; }; + jointHandle_t GetBarrelJointView( void ) { return barrelJointView; }; + idDict GetProjectileDict( void ) { return projectileDict; }; +// <---sikk + +// sikk---> Soft Shadows PostProcess + renderLight_t* GetMuzzleFlash( void ) { return &muzzleFlash; }; + renderLight_t* GetWorldMuzzleFlash( void ) { return &worldMuzzleFlash; }; + int GetMuzzleFlashHandle( void ) { return muzzleFlashHandle; }; + int GetWorldMuzzleFlashHandle( void ) { return worldMuzzleFlashHandle; }; +// <---sikk + private: // script control idScriptBool WEAPON_ATTACK; @@ -288,7 +306,7 @@ private: // nozzle effects bool nozzleFx; // does this use nozzle effects ( parm5 at rest, parm6 firing ) - // this also assumes a nozzle light atm + // this also assumes a nozzle light atm int nozzleFxFade; // time it takes to fade between the effects int lastAttack; // last time an attack occured renderLight_t nozzleGlow; // nozzle light diff --git a/game/ai/AAS.cpp b/game/ai/AAS.cpp index 10ab9c2..c0ddde6 100644 --- a/game/ai/AAS.cpp +++ b/game/ai/AAS.cpp @@ -274,3 +274,17 @@ void idAASLocal::GetEdge( int edgeNum, idVec3 &start, idVec3 &end ) const { start = file->GetVertex( v[INTSIGNBITSET(edgeNum)] ); end = file->GetVertex( v[INTSIGNBITNOTSET(edgeNum)] ); } + +// sikk---> Random Encounters System +/* +============ +idAASLocal::GetNumAreas +============ +*/ +int idAASLocal::GetNumAreas( int aasNum ) const { + if ( !file ) { + return -1; + } + return file->GetNumAreas(); +} +// <---sikk \ No newline at end of file diff --git a/game/ai/AAS.h b/game/ai/AAS.h index 08ab9c0..5647cd4 100644 --- a/game/ai/AAS.h +++ b/game/ai/AAS.h @@ -138,6 +138,9 @@ public: virtual void ShowFlyPath( const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin ) const = 0; // Find the nearest goal which satisfies the callback. virtual bool FindNearestGoal( aasGoal_t &goal, int areaNum, const idVec3 origin, const idVec3 &target, int travelFlags, aasObstacle_t *obstacles, int numObstacles, idAASCallback &callback ) const = 0; + + // Returns the number of areas in the current aas file. + virtual int GetNumAreas( int aasNum ) const = 0; // sikk - Random Encounters System }; #endif /* !__AAS_H__ */ diff --git a/game/ai/AAS_local.h b/game/ai/AAS_local.h index 6d32c2e..28cd2de 100644 --- a/game/ai/AAS_local.h +++ b/game/ai/AAS_local.h @@ -118,6 +118,8 @@ public: virtual void ShowFlyPath( const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin ) const; virtual bool FindNearestGoal( aasGoal_t &goal, int areaNum, const idVec3 origin, const idVec3 &target, int travelFlags, aasObstacle_t *obstacles, int numObstacles, idAASCallback &callback ) const; + virtual int GetNumAreas( int aasNum ) const; // sikk - Random Encounters System + private: idAASFile * file; idStr name; diff --git a/game/ai/AI.cpp b/game/ai/AI.cpp index 2ac9948..e2ab54a 100644 --- a/game/ai/AI.cpp +++ b/game/ai/AI.cpp @@ -384,6 +384,11 @@ idAI::idAI() { eyeFocusRate = 0.0f; headFocusRate = 0.0f; focusAlignTime = 0; + +// sikk---> Random Encounters System + dormantTime = 0; + isRandom = false; +// <---sikk } /* @@ -531,6 +536,8 @@ void idAI::Save( idSaveGame *savefile ) const { savefile->WriteJoint( flyTiltJoint ); savefile->WriteBool( GetPhysics() == static_cast(&physicsObj) ); + + savefile->WriteBool( isRandom ); // sikk - Random Encounters System } /* @@ -680,6 +687,8 @@ void idAI::Restore( idRestoreGame *savefile ) { savefile->ReadBool( restorePhysics ); + savefile->ReadBool( isRandom ); // sikk - Random Encounters System + // Set the AAS if the character has the correct gravity vector idVec3 gravity = spawnArgs.GetVector( "gravityDir", "0 0 -1" ); gravity *= g_gravity.GetFloat(); @@ -719,6 +728,8 @@ void idAI::Spawn( void ) { return; } + spawnArgs.GetBool( "isRandom", "0", isRandom ); // sikk - Random Encounters System + spawnArgs.GetInt( "team", "1", team ); spawnArgs.GetInt( "rank", "0", rank ); spawnArgs.GetInt( "fly_offset", "0", fly_offset ); @@ -915,6 +926,20 @@ void idAI::Spawn( void ) { StartSound( "snd_ambient", SND_CHANNEL_AMBIENT, 0, false, NULL ); } +// sikk - Monster Burn Away Delay (this doesn't effect zombies or other non-burning monsters) + if ( g_burnAwayDelay.GetFloat() > 0.0 && spawnArgs.GetFloat( "burnaway" ) > 0.0 ) + spawnArgs.SetFloat( "burnaway", g_burnAwayDelay.GetFloat() ); +// <---sikk + +// sikk---> Enemy Health Management (also modifies friendlies but it doesn't make any difference) + health *= g_enemyHealthScale.GetFloat(); + + if ( g_enemyHealthType.GetBool() ) + health = ( health * 0.5f ) + ( health * gameLocal.random.RandomFloat() ); + + health = ( health <= 0 ) ? 1 : health; +// <---sikk + if ( health <= 0 ) { gameLocal.Warning( "entity '%s' doesn't have health set", name.c_str() ); health = 1; @@ -1018,6 +1043,13 @@ void idAI::DormantBegin( void ) { // remove ourselves from the enemy's enemylist enemyNode.Remove(); } + + +// sikk---> Random Encounters System + if ( isRandom ) + dormantTime = gameLocal.time; +// <---sikk + idActor::DormantBegin(); } @@ -1040,6 +1072,11 @@ void idAI::DormantEnd( void ) { } } +// sikk---> Random Encounters System + if ( spawnArgs.GetInt( "isRandom" ) ) + dormantTime = 0; +// <---sikk + idActor::DormantEnd(); } @@ -1153,6 +1190,11 @@ void idAI::Think( void ) { Present(); UpdateDamageEffects(); LinkCombat(); + +// sikk---> Random Encounters System + if ( isRandom && ( AI_DEST_UNREACHABLE || ( dormantTime && gameLocal.time > ( dormantTime + g_randomEncountersDormantTime.GetInteger() * 1000 ) ) ) ) + Damage( gameLocal.world, gameLocal.world, idVec3( 0, 0, 1 ), "damage_moverCrush", 999999, INVALID_JOINT ); +// <---sikk } /*********************************************************************** @@ -3189,7 +3231,7 @@ int idAI::ReactionTo( const idEntity *ent ) { } // monsters will fight when attacked by lower ranked monsters. rank 0 never fights back. - if ( rank && ( actor->rank < rank ) ) { + if ( rank && ( actor->rank < rank + g_interRankAggression.GetInteger() ) ) { // sikk - Inter Rank Aggression return ATTACK_ON_DAMAGE; } @@ -3328,6 +3370,18 @@ void idAI::Killed( idEntity *inflictor, idEntity *attacker, int damage, const id return; } +// sikk---> Random Encounters System + int i = gameLocal.GetEnemyNumFromName( spawnArgs.GetString( "classname" ) ); + if ( i ) { + if ( isRandom ) { + gameLocal.randomEnemyTally--; + gameLocal.randomEnemyTally = ( gameLocal.randomEnemyTally < 0 ) ? 0 : gameLocal.randomEnemyTally; + } else { + gameLocal.randomEnemyList.Append( i ); + } + } +// <---sikk + // stop all voice sounds StopSound( SND_CHANNEL_VOICE, false ); if ( head.GetEntity() ) { diff --git a/game/ai/AI.h b/game/ai/AI.h index b038ba4..860ffb3 100644 --- a/game/ai/AI.h +++ b/game/ai/AI.h @@ -277,6 +277,13 @@ public: // Finds the best collision free trajectory for a clip model. static bool PredictTrajectory( const idVec3 &firePos, const idVec3 &target, float projectileSpeed, const idVec3 &projGravity, const idClipModel *clip, int clipmask, float max_height, const idEntity *ignore, const idEntity *targetEntity, int drawtime, idVec3 &aimDir ); + int IsDead( void ) { return AI_DEAD; }; + +// sikk---> Random Encounters System + int dormantTime; // holds the time when a random enemy goes dormant + bool isRandom; // holds whether the entity was a random spawn or not +// <---sikk + protected: // navigation idAAS * aas; diff --git a/game/gamesys/SysCvar.cpp b/game/gamesys/SysCvar.cpp index e2d64e7..e68a9be 100644 --- a/game/gamesys/SysCvar.cpp +++ b/game/gamesys/SysCvar.cpp @@ -130,8 +130,6 @@ idCVar g_healthTakeTime( "g_healthTakeTime", "5", CVAR_GAME | CVAR_INTEGER idCVar g_healthTakeAmt( "g_healthTakeAmt", "5", CVAR_GAME | CVAR_INTEGER | CVAR_ARCHIVE, "how much health to take in nightmare mode" ); idCVar g_healthTakeLimit( "g_healthTakeLimit", "25", CVAR_GAME | CVAR_INTEGER | CVAR_ARCHIVE, "how low can health get taken in nightmare mode" ); - - idCVar g_showPVS( "g_showPVS", "0", CVAR_GAME | CVAR_INTEGER, "", 0, 2 ); idCVar g_showTargets( "g_showTargets", "0", CVAR_GAME | CVAR_BOOL, "draws entities and their targets. hidden entities are drawn grey." ); idCVar g_showTriggers( "g_showTriggers", "0", CVAR_GAME | CVAR_BOOL, "draws trigger entities (orange) and their targets (green). disabled triggers are drawn grey." ); @@ -261,6 +259,7 @@ idCVar pm_runroll( "pm_runroll", "0.005", CVAR_GAME | CVAR_NETWORKSYNC | idCVar pm_bobup( "pm_bobup", "0.005", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT, "" ); idCVar pm_bobpitch( "pm_bobpitch", "0.002", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT, "" ); idCVar pm_bobroll( "pm_bobroll", "0.002", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT, "" ); + idCVar pm_thirdPersonRange( "pm_thirdPersonRange", "80", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT, "camera distance from player in 3rd person" ); idCVar pm_thirdPersonHeight( "pm_thirdPersonHeight", "0", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT, "height of camera from normal view height in 3rd person" ); idCVar pm_thirdPersonAngle( "pm_thirdPersonAngle", "0", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT, "direction of camera from player in 3rd person in degrees (0 = behind player, 180 = in front)" ); @@ -335,3 +334,239 @@ idCVar mod_validSkins( "mod_validSkins", "skins/characters/player/marine_mp idCVar net_serverDownload( "net_serverDownload", "0", CVAR_GAME | CVAR_INTEGER | CVAR_ARCHIVE, "enable server download redirects. 0: off 1: redirect to si_serverURL 2: use builtin download. see net_serverDl cvars for configuration" ); idCVar net_serverDlBaseURL( "net_serverDlBaseURL", "", CVAR_GAME | CVAR_ARCHIVE, "base URL for the download redirection" ); idCVar net_serverDlTable( "net_serverDlTable", "", CVAR_GAME | CVAR_ARCHIVE, "pak names for which download is provided, separated by ;" ); + + +// sikk - New Cvars - +// sikk---> Crosshair Cvar +idCVar g_crosshair( "g_crosshair", "1", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "0 = crosshair off, 1 = crosshair on, 2 = crosshair on only when zoomed or npc has focus" ); +idCVar g_crosshairType( "g_crosshairType", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "toggle between static and precise crosshair positioning" ); +idCVar g_crosshairLerp( "g_crosshairLerp", "0.5", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "smoothness for the movement of the crosshair when g_crosshairType = 1" ); +// <---sikk + +// sikk---> Dynamic Hud system +idCVar g_useDynamicHud( "g_useDynamicHud", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "enables dynamic hud" ); +idCVar g_dynamicHudTime( "g_dynamicHudTime", "10.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "time (in sec) before the hud fades out" ); +// <---sikk + +// sikk---> Blood Spray Screen Effect +idCVar g_showBloodSpray( "g_showBloodSpray", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "show blood spray effect on screen when inflicting damage up close" ); +idCVar g_bloodSprayTime( "g_bloodSprayTime", "5.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "how long blood spray effect lasts (in seconds)" ); +idCVar g_bloodSprayDistance( "g_bloodSprayDistance", "96", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "how close you have to be for blood spray effect to \"hit the camera\". Not relevant for chainsaw." ); +idCVar g_bloodSprayFrequency( "g_bloodSprayFrequency", "0.5", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "how often the blood spray effect can occur. Value Range: 0.0 (never) - 1.0 (always)" ); +// <---sikk + +// sikk---> Explosion FX +idCVar g_useExplosionFX( "g_useExplosionFX", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "enables explosion screen effects" ); +idCVar g_explosionFXTime( "g_explosionFXTime", "2.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "time (in secs) the effect lasts" ); +idCVar g_explosionFXScale( "g_explosionFXScale", "16.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "explosion effect scale" ); +// <---sikk + +// sikk---> Screen Frost +idCVar g_screenFrostTime( "g_screenFrostTime", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "time (in secs) for frost to fully build on the screen. 0 = disables effect" ); +// <---sikk + +// sikk---> Portal Sky Box +idCVar g_enablePortalSky( "g_enablePortalSky", "1", CVAR_GAME | CVAR_BOOL, "enables portal sky box support" ); +// <---sikk + +// sikk---> Monster Burn Away Delay +idCVar g_burnAwayDelay( "g_burnAwayDelay", "0.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "enemy burn away delay. 0.0 = use default value" ); +// <---sikk + +// sikk---> Enemy Health Management +idCVar g_enemyHealthType( "g_enemyHealthType", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "sets enemy health type: 0 = normal; 1 = random" ); +idCVar g_enemyHealthScale( "g_enemyHealthScale", "1.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "sets the health scale for enemies" ); +// <---sikk + +// sikk---> Inter Rank Aggression +idCVar g_interRankAggression( "g_interRankAggression", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "sets whether enemies of the same rank will fight each other" ); +// <---sikk + +// sikk---> Cyberdemon Damage Type +idCVar g_cyberdemonDamageType( "g_cyberdemonDamageType", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "sets how the Cyberdemon can be damaged: 0 = Soul Cube only; 1 = All weapons" ); +// <---sikk + +// sikk---> Zombie Resurrection +idCVar g_zombieResurrectionLimit( "g_zombieResurrectionLimit", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "sets the total number of times a zombie can resurrect. The chance for a zombie to resurrect is still randomized. 0 = Off" ); +// <---sikk + +// sikk---> Random Encounters System +idCVar g_useRandomEncounters( "g_useRandomEncounters", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "enables random encounters" ); +idCVar g_randomEncountersMaxSpawns( "g_randomEncountersMaxSpawns", "5", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "number of random enemies that can be alive at one time" ); +idCVar g_randomEncountersMinTime( "g_randomEncountersMinTime", "30", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "minimum time (in secs) to wait before spawning another random enemy" ); +idCVar g_randomEncountersMaxTime( "g_randomEncountersMaxTime", "60", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "maximum time (in secs) to wait before spawning another random enemy" ); +idCVar g_randomEncountersDormantTime( "g_randomEncountersDormantTime", "10", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "maximum time (in secs) a random enemy can be dormant before it is removed" ); +// <---sikk + +// sikk---> Health Management System +idCVar g_healthManagementType( "g_healthManagementType", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "selects which health management system to use. 0 = default; 1 = carriable health pack; 2 = regenerating health" ); +idCVar g_healthPackTotal( "g_healthPackTotal", "100", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "total amount of health reserve in the health pack" ); +idCVar g_healthPackUses( "g_healthPackUses", "1", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "number of uses in the health pack. g_healthPackTotal divided by this is how much health is given per use." ); +idCVar g_healthPackTime( "g_healthPackTime", "3", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "maximum time it takes to heal yourself. " ); +idCVar g_healthRegenTime( "g_healthRegenTime", "1", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "how often to regenerate health when using regenerative health system" ); +idCVar g_healthRegenDelay( "g_healthRegenDelay", "5", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "delay (in seconds) before health starts to regenerate after taking damage when using regenerative health system" ); +idCVar g_healthRegenAmt( "g_healthRegenAmt", "1", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "how much health to regenerate per g_healthRegenTime when using regenerative health system" ); +idCVar g_healthRegenLimit( "g_healthRegenLimit", "100", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "total amount of health that can be regenerated when using regenerative health system" ); +idCVar g_healthRegenSteps( "g_healthRegenSteps", "4", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "splits g_healthRegenLimit into n number of steps. Value of 1 or less will turn steps off.\nexample1: if g_healthRegenLimit == 100 && g_healthRegenSteps == 4, health regeneration will stop at 25/50/75/100\nexample2: if g_healthRegenLimit == 50 && g_healthRegenSteps == 5, health regeneration will stop at 10/20/30/40/50" ); +idCVar g_healthRegenFeedback( "g_healthRegenFeedback", "50", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "how low must health reach before feedback is drawn when using regenerative health system" ); +// <---sikk + +// sikk---> Item Management +idCVar g_itemPickupType( "g_itemPickupType", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "toggles whether items need to be picked up manually with the 'Use' key." ); +idCVar g_itemRemovalFactor( "g_itemRemovalFactor", "0.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "sets the factor for which items are randomly removed from the map. Value Range: 0.0 (no items are removed) - 1.0 (all items are removed)" ); +idCVar g_itemValueFactor( "g_itemValueFactor", "0.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "sets the factor for which the value for items are randomly set. Value Range: 0.0 (items have full value) - 1.0 (items have anywhere from one to full value)" ); +idCVar g_itemHelmetFactor( "g_itemHelmetFactor", "0.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "sets the factor for which security armor is randomly replaced with a marine helmet. Value Range: 0.0 (no replacement) - 1.0 (full replacement)" ); +idCVar g_itemSearchFactor( "g_itemSearchFactor", "0.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "sets the factor for which items can be found on dead bodies. Value Range: 0.0 (dead bodies contain no items) - 1.0 (dead bodies always contain items)" ); +// <---sikk + +// sikk---> Ammo Management +idCVar g_ammoDamageType( "g_ammoDamageType", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "toggles between the use of normal or custom damage values" ); +idCVar g_ammoCapacityType( "g_ammoCapacityType", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "toggles between the use of normal or custom max ammo/clip size values" ); +idCVar g_ammoUsageType( "g_ammoUsageType", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "enables realistic ammo usage when reloading and collecting ammo" ); +// <---sikk + +// sikk---> Weapon Handling System +idCVar g_weaponHandlingType( "g_weaponHandlingType", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "toggles between normal and realistic weapon handling" ); +// <---sikk + +// sikk---> Tracer Frequency +idCVar g_tracerFrequency( "g_tracerFrequency", "0.5", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "how frequent a fired shot will be a tracer. Value Range: 0.0 (no tracers) - 1.0 (all tracers)" ); +// <---sikk + +// sikk---> First Person Body +idCVar g_grabMode( "g_grabMode", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "enables the ability to grab moveable objects" ); +// <---sikk + +// sikk---> IR Goggles/Headlight Mod +idCVar g_goggleType( "g_goggleType", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "sets the goggle's type: 0 = Infrared; 1 = Thermal" ); +idCVar g_batteryLife( "g_batteryLife", "60", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "how long the battery lasts (in seconds) for ir goggles/headlight" ); +idCVar g_batteryRechargeRate( "g_batteryRechargeRate", "120", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "how long it takes the battery to fully recharge (in seconds) for ir goggles/headlight" ); +// <---sikk + +// sikk---> Global Ambient Light +idCVar g_useAmbientLight( "g_useAmbientLight", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "enable a global ambient light bound to player" ); +idCVar g_ambientLightRadius( "g_ambientLightRadius", "1024 1024 1024", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE, "sets the ambient light's radius (XYZ = 0 to 65536)" ); +idCVar g_ambientLightColor( "g_ambientLightColor", "0.03125 0.03125 0.03125", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE, "sets the ambient light's color (RGB = 0.0 to 1.0)" ); +// <---sikk + +// sikk---> First Person Body +idCVar g_showFirstPersonBody( "g_showFirstPersonBody", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "draws the player body in first person view mode" ); +// <---sikk + +// sikk---> Thirdperson Camera +idCVar pm_thirdPersonOffest( "pm_thirdPersonOffset", "0", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT, "camera offest from player in 3rd person (-n = left, +n = right)" ); +// <---sikk + +// sikk---> PostProcess Effects +idCVar r_useSoftShadows( "r_useSoftShadows", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "Enable Soft Shadows postprocessing effect" ); +idCVar r_softShadowsBlurFilter( "r_softShadowsBlurFilter", "1", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "Blur method used for the shadow mask:\n0 = No Filter\n1 = Box Filter\n2 = Poisson Filter\n3 = Gaussian Filter" ); +idCVar r_softShadowsBlurScale( "r_softShadowsBlurScale", "1.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Sample offset scale for the blur filter" ); +idCVar r_softShadowsBlurEpsilon( "r_softShadowsBlurEpsilon", "4.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "Set the blur depth difference factor for the blur filter" ); + +idCVar r_useEdgeAA( "r_useEdgeAA", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "Enable edge anti-aliasing" ); +idCVar r_edgeAASampleScale( "r_edgeAASampleScale", "1.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Set the sample offset scale for edge detection" ); +idCVar r_edgeAAFilterScale( "r_edgeAAFilterScale", "1.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Set the filter offset scale for blurring" ); + +idCVar r_useHDR( "r_useHDR", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "Enable High Dynamic Range lighting" ); +idCVar r_hdrToneMapper( "r_hdrToneMapper", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "Tone mapping method:\n0 = Reinhard (RGB)\n1 = Reinhard (Yxy)\n2 = Exponential\n3 = Filmic (simple)\n4 = Filmic (complex)" ); +idCVar r_hdrAdaptationRate( "r_hdrAdaptationRate", "60.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Eye adaptation rate" ); +idCVar r_hdrMiddleGray( "r_hdrMiddleGray", "0.18", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Middle gray value used in HDR tone mapping" ); +idCVar r_hdrWhitePoint( "r_hdrWhitePoint", "1.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Smallest luminance value that will be mapped to white" ); +idCVar r_hdrBlueShiftFactor( "r_hdrBlueShiftFactor", "0.25", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Blue shift blend factor" ); +idCVar r_hdrDither( "r_hdrDither", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "Enable dithering" ); +idCVar r_hdrDitherSize( "r_hdrDitherSize", "1.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Sets the size of the dither threshold map" ); +idCVar r_hdrLumThresholdMax( "r_hdrLumThresholdMax", "0.3", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Minimum luminance value threshold" ); +idCVar r_hdrLumThresholdMin( "r_hdrLumThresholdMin", "0.1", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Maximum luminance value threshold" ); +idCVar r_hdrBloomToneMapper( "r_hdrBloomToneMapper", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "Tone mapping method, specific to bloom:\n0 = Reinhard (RGB)\n1 = Reinhard (Yxy)\n2 = Exponential\n3 = Filmic (simple)\n4 = Filmic (complex)" ); +idCVar r_hdrBloomMiddleGray( "r_hdrBloomMiddleGray", "0.18", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Middle gray value used in HDR tone mapping, specific to bloom" ); +idCVar r_hdrBloomWhitePoint( "r_hdrBloomWhitePoint", "1.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Smallest luminance value that will be mapped to white, specific to bloom" ); +idCVar r_hdrBloomThreshold( "r_hdrBloomThreshold", "1.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Bloom luminance threshold" ); +idCVar r_hdrBloomOffset( "r_hdrBloomOffset", "3.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Bloom luminance offset" ); +idCVar r_hdrBloomScale( "r_hdrBloomScale", "1.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Intensity scale amount for bloom effect" ); +idCVar r_hdrBloomSize( "r_hdrBloomSize", "1.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Size of the bloom effect" ); +idCVar r_hdrFlareGamma( "r_hdrFlareGamma", "2.2", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Gamma curve for the flare texture" ); +idCVar r_hdrFlareScale( "r_hdrFlareScale", "1.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Intensity scale amount for lens flare effect. 0 = Off" ); +idCVar r_hdrFlareSize( "r_hdrFlareSize", "1.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Size of the lens flare effect" ); +idCVar r_hdrGlareStyle( "r_hdrGlareStyle", "1", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "Glare style to use with HDR lighting. Value range: 0 - 11\n0 = Off\n1 = Natural\n2 = Star\n3 = Cross\n4 = Snow Cross\n5 = Horizontal\n6 = Vertical\n7 = Star (Spectral)\n8 = Cross (Spectral)\n9 = Snow Cross (Spectral)\n10 = Horizontal (Spectral)\n11 = Vertical (Spectral)" ); +idCVar r_hdrGlareScale( "r_hdrGlareScale", "1.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Intensity scale amount for glare effect" ); +idCVar r_hdrGlareSize( "r_hdrGlareSize", "1.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Size of the glare effect" ); + +idCVar r_useBloom( "r_useBloom", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "Enable bloom postprocessing effect" ); +idCVar r_bloomBufferSize( "r_bloomBufferSize", "3", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "Bloom render target size:\n0 = 32x32\n1 = 64x64\n2 = 128x128\n3 = 256x256\n4 = 512x512\n5 = 1024x1024" ); +idCVar r_bloomBlurIterations( "r_bloomBlurIterations", "1", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "Number of times the blur filter is applied" ); +idCVar r_bloomBlurScaleX( "r_bloomBlurScaleX", "1.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Amount to scale the X axis sample offsets" ); +idCVar r_bloomBlurScaleY( "r_bloomBlurScaleY", "1.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Amount to scale the Y axis sample offsets" ); +idCVar r_bloomScale( "r_bloomScale", "1.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Amount to scale the intensity of the bloom effect" ); +idCVar r_bloomGamma( "r_bloomGamma", "1.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Gamma curve for the bloom texture" ); + +idCVar r_useSSIL( "r_useSSIL", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "Enable Screen-Space Indirect Lighting postprocessing effect" ); +idCVar r_ssilRadius( "r_ssilRadius", "128", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Set the sample radius for ssil" ); +idCVar r_ssilAmount( "r_ssilAmount", "1.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Set the contribution factor for ssil" ); +idCVar r_ssilBlurMethod( "r_ssilBlurMethod", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "Blur method used for the ssil buffer:\n0 = Gaussian\n1 = Bilateral" ); +idCVar r_ssilBlurScale( "r_ssilBlurScale", "1.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Set the blur scale for the ssil buffer" ); +idCVar r_ssilBlurQuality( "r_ssilBlurQuality", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "Set the blur quality for the ssil buffer" ); +idCVar r_ssilBlurEpsilon( "r_ssilBlurEpsilon", "4", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "Set the blur depth difference factor for the ssil buffer" ); + +idCVar r_useSSAO( "r_useSSAO", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "Enable Screen-Space Ambient Occlusion postprocessing effect" ); +idCVar r_ssaoMethod( "r_ssaoMethod", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "Set the ssao method:\n0 = Crytek\n1 = HDAO\n2 = ABAO\n3 = PBAO\n4 = HBAO (low)\n5 = HBAO (medium)\n6 = HBAO (high)\n7 = Ray Marching\n8 = Volumetric Obscurance" ); +idCVar r_ssaoRadius( "r_ssaoRadius", "16", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Set the sample radius for ssao" ); +idCVar r_ssaoBias( "r_ssaoBias", "0.075", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Set the angle bias for ssao (darkening factor for Crytek's)" ); +idCVar r_ssaoAmount( "r_ssaoAmount", "1.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Set the contribution factor for ssao" ); +idCVar r_ssaoBlurMethod( "r_ssaoBlurMethod", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "Blur method used for the ssao buffer:\n0 = Crytek\n1 = Box\n2 = Gaussian\n3 = Bilateral" ); +idCVar r_ssaoBlurScale( "r_ssaoBlurScale", "1.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Set the blur scale for the ssao buffer" ); +idCVar r_ssaoBlurQuality( "r_ssaoBlurQuality", "1", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "Set the blur quality for the ssao buffer" ); +idCVar r_ssaoBlurEpsilon( "r_ssaoBlurEpsilon", "16", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "Set the blur depth difference factor for the ssao buffer" ); +idCVar r_ssaoBlendPower( "r_ssaoBlendPower", "2.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Set the blend exponent for the ssao to scene final combine" ); +idCVar r_ssaoBlendScale( "r_ssaoBlendScale", "2.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Set the blend scale for the ssao to scene final combine" ); + +idCVar r_useSunShafts( "r_useSunShafts", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "Enable Screen-Space Volumetric Lighting (Sun Shafts) postprocessing effect" ); +idCVar r_sunShaftsSize( "r_sunShaftsSize", "8.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Set the sun shafts size" ); +idCVar r_sunShaftsStrength( "r_sunShaftsStrength", "0.5", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Set the sun shafts strength" ); +idCVar r_sunShaftsMaskStrength( "r_sunShaftsMaskStrength", "0.5", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Set the sun shafts mask strength" ); +idCVar r_sunShaftsQuality( "r_sunShaftsQuality", "4", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "Set the sun shafts quality" ); +idCVar r_sunOriginX( "r_sunOriginX", "0.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Set the sun's origin along the X axis (used for sun shafts & lens flare)" ); +idCVar r_sunOriginY( "r_sunOriginY", "0.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Set the sun's origin along the Y axis (used for sun shafts & lens flare)" ); +idCVar r_sunOriginZ( "r_sunOriginZ", "0.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Set the sun's origin along the Z axis (used for sun shafts & lens flare)" ); +idCVar r_useLensFlare( "r_useLensFlare", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "Enable lens flare postprocessing effect" ); +idCVar r_lensFlareStrength( "r_lensFlareStrength", "1.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Set the lens flare strength" ); + +idCVar r_useDepthOfField( "r_useDepthOfField", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "Enable depth of field postprocessing effect. Value range: 0 - 2 \n0 = Off\n1 = Automatic Focus\n2 = Manual Focus" ); +idCVar r_dofBlurScale( "r_dofBlurScale", "1.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Set the blur scale for depth of field postprocessing effect" ); +idCVar r_dofBlurQuality( "r_dofBlurQuality", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "Set the blur quality for depth of field postprocessing effect:\n0 = Box Filter\n1 = Poisson Filter\n2 = Gaussian Filter\n3 = Bokeh!" ); +idCVar r_dofNear( "r_dofNear", "-128", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "Set the near distance for depth of field postprocessing effect (r_useDepthOfField = 2 only)" ); +idCVar r_dofFar( "r_dofFar", "1024", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "Set the far distance for depth of field postprocessing effect (r_useDepthOfField = 2 only)" ); +idCVar r_dofFocus( "r_dofFocus", "128", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "Set the focus distance for depth of field postprocessing effect (r_useDepthOfField = 2 only)" ); +idCVar r_dofConditionAlways( "r_dofConditionAlways", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "Depth of field condition: Always on" ); +idCVar r_dofConditionCinematic( "r_dofConditionCinematic", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "Depth of field condition: Cinematics" ); +idCVar r_dofConditionGUI( "r_dofConditionGUI", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "Depth of field condition: GUI Active" ); +idCVar r_dofConditionReload( "r_dofConditionReload", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "Depth of field condition: Reloading" ); +idCVar r_dofConditionTalk( "r_dofConditionTalk", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "Depth of field condition: Talking" ); +idCVar r_dofConditionZoom( "r_dofConditionZoom", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "Depth of field condition: Weapon Zoom" ); + +idCVar r_useMotionBlur( "r_useMotionBlur", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "Enable motion blur postprocessing effect.\n0 = off\n1 = Camera\n2 = Accumulation\n3 = Camera + Accumulation" ); +idCVar r_motionBlurScale( "r_motionBlurScale", "0.1", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Set the motion blur scale. Works similar to shutter speed. Higher values == stronger blurring" ); +idCVar r_motionBlurMaskDistance( "r_motionBlurMaskDistance", "32", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "Don't do motion blur if framerate is below this value" ); +idCVar r_motionBlurFPSThreshold( "r_motionBlurFPSThreshold", "20", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "Set the motion blur mask distance. Used to mask the view weapon." ); +idCVar r_motionBlurMinThreshold( "r_motionBlurMinThreshold", "10", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "Set the motion blur min sensitivity threshold. Screen won't blur until threshold is passed. Lower values == higher sensitivity" ); +idCVar r_motionBlurMaxThreshold( "r_motionBlurMaxThreshold", "45", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "Set the motion blur max sensitivity threshold. Blur strength won't pass threshold." ); +idCVar r_motionBlurFactor( "r_motionBlurFactor", "1.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Set the motion blur blend factor" ); +idCVar r_motionBlurLerp( "r_motionBlurLerp", "0.5", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Set the motion blur blend lerp factor" ); +idCVar r_motionBlurQuality( "r_motionBlurQuality", "1", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "Set the motion blur quality. Value range: 1 - 4\n1 = 8 samples\n2 = 64 samples (virtual)\n3 = 512 samples (virtual)\n4 = 4096 samples (virtual)" ); + +idCVar r_useColorGrading( "r_useColorGrading", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "Enable color grading postprocessing effect. Parameters need to be set manually in the material." ); +idCVar r_colorGradingParm( "r_colorGradingParm", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "Parameter to allow specific color grading stage to be used in the material" ); +idCVar r_colorGradingType( "r_colorGradingType", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "Color grading type:\n0 = math\n1 = lut" ); +idCVar r_colorGradingSharpness( "r_colorGradingSharpness", "1.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Sharpness level when color grading is enabled" ); + +idCVar r_useCelShading( "r_useCelShading", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "Enable cel shading postprocessing effect" ); +idCVar r_celShadingMethod( "r_celShadingMethod", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "Set the cel shading edge detection method. Value range: 0 - 2 \n0 = RGB\n1 = Luminance\n2 = Depth(incomplete)" ); +idCVar r_celShadingScale( "r_celShadingScale", "1.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Set the cel shading scale. Higher values == thicker outline" ); +idCVar r_celShadingThreshold( "r_celShadingThreshold", "1.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Set the cel shading threshold" ); + +idCVar r_useFilmgrain( "r_useFilmgrain", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "Enable filmgrain postprocessing effect" ); +idCVar r_filmgrainBlendMode( "r_filmgrainBlendMode", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_INTEGER, "Set the grain blending mode. Value range: 0 - 3\n0 = gl_one, gl_one\n1 = gl_zero, gl_one_minus_src_color\n2 = gl_dst_color, gl_one\n3 = gl_one_minus_dst_color, gl_one" ); +idCVar r_filmgrainScale( "r_filmgrainScale", "1.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Set the grain scale" ); +idCVar r_filmgrainStrength( "r_filmgrainStrength", "1.0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_FLOAT, "Set the grain strength. Value range: 0.0 - 1.0" ); + +idCVar r_useVignetting( "r_useVignetting", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_ARCHIVE | CVAR_BOOL, "Enable vignetting postprocessing effect" ); +// <---sikk diff --git a/game/gamesys/SysCvar.h b/game/gamesys/SysCvar.h index da8e26e..658d241 100644 --- a/game/gamesys/SysCvar.h +++ b/game/gamesys/SysCvar.h @@ -254,4 +254,219 @@ extern const char *si_gameTypeArgs[]; extern const char *ui_skinArgs[]; +// sikk - New Cvars - +// sikk---> Crosshair Cvars +extern idCVar g_crosshair; +extern idCVar g_crosshairType; +extern idCVar g_crosshairLerp; +// <---sikk + +// sikk---> Dynamic Hud system +extern idCVar g_useDynamicHud; +extern idCVar g_dynamicHudTime; +// <---sikk + +// sikk---> Blood Spray Screen Effect +extern idCVar g_showBloodSpray; +extern idCVar g_bloodSprayTime; +extern idCVar g_bloodSprayDistance; +extern idCVar g_bloodSprayFrequency; +// <---sikk + +// sikk---> Explosion FX +extern idCVar g_useExplosionFX; +extern idCVar g_explosionFXTime; +extern idCVar g_explosionFXScale; +// <---sikk + +extern idCVar g_screenFrostTime; // sikk - Screen Frost + +extern idCVar g_enablePortalSky; // sikk - Portal Sky Box + + +extern idCVar g_burnAwayDelay; // sikk - Monster Burn Away Delay + +// sikk---> Enemy Health Management +extern idCVar g_enemyHealthType; +extern idCVar g_enemyHealthScale; +// <---sikk + +extern idCVar g_interRankAggression; // sikk - Inter Rank Aggression + +extern idCVar g_cyberdemonDamageType; // sikk - Cyberdemon Damage Type + +extern idCVar g_zombieResurrectionLimit; // sikk - Zombie Resurrection + +// sikk---> Random Encounters System +extern idCVar g_useRandomEncounters; +extern idCVar g_randomEncountersMaxSpawns; +extern idCVar g_randomEncountersMinTime; +extern idCVar g_randomEncountersMaxTime; +extern idCVar g_randomEncountersDormantTime; +// <---sikk + + +// sikk---> Health Management System +extern idCVar g_healthManagementType; +extern idCVar g_healthPackTotal; +extern idCVar g_healthPackUses; +extern idCVar g_healthPackTime; +extern idCVar g_healthRegenTime; +extern idCVar g_healthRegenDelay; +extern idCVar g_healthRegenAmt; +extern idCVar g_healthRegenLimit; +extern idCVar g_healthRegenSteps; +extern idCVar g_healthRegenFeedback; +// <---sikk + +// sikk---> Item Management +extern idCVar g_itemPickupType; +extern idCVar g_itemRemovalFactor; +extern idCVar g_itemValueFactor; +extern idCVar g_itemHelmetFactor; +extern idCVar g_itemSearchFactor; +// <---sikk + +// sikk---> Ammo Management +extern idCVar g_ammoDamageType; +extern idCVar g_ammoCapacityType; +extern idCVar g_ammoUsageType; +// <---sikk + +extern idCVar g_weaponHandlingType; // sikk - Weapon Handling + +extern idCVar g_tracerFrequency; // sikk - Tracer Frequency + +extern idCVar g_grabMode; // sikk - Object Manipulation + +// sikk---> IR Goggles/Headlight Mod +extern idCVar g_goggleType; +extern idCVar g_batteryLife; +extern idCVar g_batteryRechargeRate; +// <---sikk + +// sikk---> Global Ambient Light +extern idCVar g_useAmbientLight; +extern idCVar g_ambientLightRadius; +extern idCVar g_ambientLightColor; +// <---sikk + +extern idCVar g_showFirstPersonBody; // sikk - First Person Body + +extern idCVar pm_thirdPersonOffest; // sikk - Thirdpesron Camera + +// sikk---> PostProcess Effects +extern idCVar r_useSoftShadows; +extern idCVar r_softShadowsBlurFilter; +extern idCVar r_softShadowsBlurScale; +extern idCVar r_softShadowsBlurEpsilon; + +extern idCVar r_useEdgeAA; +extern idCVar r_edgeAASampleScale; +extern idCVar r_edgeAAFilterScale; + +extern idCVar r_useHDR; +extern idCVar r_hdrToneMapper; +extern idCVar r_hdrAdaptationRate; +extern idCVar r_hdrMiddleGray; +extern idCVar r_hdrWhitePoint; +extern idCVar r_hdrBlueShiftFactor; +extern idCVar r_hdrDither; +extern idCVar r_hdrDitherSize; +extern idCVar r_hdrLumThresholdMax; +extern idCVar r_hdrLumThresholdMin; +extern idCVar r_hdrBloomToneMapper; +extern idCVar r_hdrBloomMiddleGray; +extern idCVar r_hdrBloomWhitePoint; +extern idCVar r_hdrBloomThreshold; +extern idCVar r_hdrBloomOffset; +extern idCVar r_hdrBloomScale; +extern idCVar r_hdrBloomSize; +extern idCVar r_hdrFlareGamma; +extern idCVar r_hdrFlareScale; +extern idCVar r_hdrFlareSize; +extern idCVar r_hdrGlareStyle; +extern idCVar r_hdrGlareScale; +extern idCVar r_hdrGlareSize; + +extern idCVar r_useBloom; +extern idCVar r_bloomBufferSize; +extern idCVar r_bloomBlurIterations; +extern idCVar r_bloomBlurScaleX; +extern idCVar r_bloomBlurScaleY; +extern idCVar r_bloomScale; +extern idCVar r_bloomGamma; + +extern idCVar r_useSSIL; +extern idCVar r_ssilRadius; +extern idCVar r_ssilAmount; +extern idCVar r_ssilBlurMethod; +extern idCVar r_ssilBlurScale; +extern idCVar r_ssilBlurQuality; +extern idCVar r_ssilBlurEpsilon; + +extern idCVar r_useSSAO; +extern idCVar r_ssaoMethod; +extern idCVar r_ssaoRadius; +extern idCVar r_ssaoAmount; +extern idCVar r_ssaoBias; +extern idCVar r_ssaoBlurMethod; +extern idCVar r_ssaoBlurScale; +extern idCVar r_ssaoBlurQuality; +extern idCVar r_ssaoBlurEpsilon; +extern idCVar r_ssaoBlendPower; +extern idCVar r_ssaoBlendScale; + +extern idCVar r_useSunShafts; +extern idCVar r_sunShaftsSize; +extern idCVar r_sunShaftsStrength; +extern idCVar r_sunShaftsMaskStrength; +extern idCVar r_sunShaftsQuality; +extern idCVar r_sunOriginX; +extern idCVar r_sunOriginY; +extern idCVar r_sunOriginZ; +extern idCVar r_useLensFlare; +extern idCVar r_lensFlareStrength; + +extern idCVar r_useMotionBlur; +extern idCVar r_motionBlurScale; +extern idCVar r_motionBlurMaskDistance; +extern idCVar r_motionBlurFPSThreshold; +extern idCVar r_motionBlurMinThreshold; +extern idCVar r_motionBlurMaxThreshold; +extern idCVar r_motionBlurFactor; +extern idCVar r_motionBlurLerp; +extern idCVar r_motionBlurQuality; + +extern idCVar r_useDepthOfField; +extern idCVar r_dofBlurScale; +extern idCVar r_dofBlurQuality; +extern idCVar r_dofNear; +extern idCVar r_dofFar; +extern idCVar r_dofFocus; +extern idCVar r_dofConditionAlways; +extern idCVar r_dofConditionCinematic; +extern idCVar r_dofConditionGUI; +extern idCVar r_dofConditionTalk; +extern idCVar r_dofConditionReload; +extern idCVar r_dofConditionZoom; + +extern idCVar r_useColorGrading; +extern idCVar r_colorGradingParm; +extern idCVar r_colorGradingType; +extern idCVar r_colorGradingSharpness; + +extern idCVar r_useCelShading; +extern idCVar r_celShadingMethod; +extern idCVar r_celShadingScale; +extern idCVar r_celShadingThreshold; + +extern idCVar r_useFilmgrain; +extern idCVar r_filmgrainBlendMode; +extern idCVar r_filmgrainScale; +extern idCVar r_filmgrainStrength; + +extern idCVar r_useVignetting; +// <---sikk + #endif /* !__SYS_CVAR_H__ */ diff --git a/game/physics/Force_Grab.cpp b/game/physics/Force_Grab.cpp new file mode 100644 index 0000000..e023082 --- /dev/null +++ b/game/physics/Force_Grab.cpp @@ -0,0 +1,153 @@ +// sikk---> Object Manipulation + +#include "../../idlib/precompiled.h" +#pragma hdrstop + +#include "../Game_local.h" + +CLASS_DECLARATION( idForce, idForce_Grab ) +END_CLASS + + +/* +================ +idForce_Grab::Save +================ +*/ +void idForce_Grab::Save( idSaveGame *savefile ) const { + savefile->WriteFloat( damping ); + savefile->WriteVec3( goalPosition ); + savefile->WriteFloat( distanceToGoal ); + savefile->WriteInt( id ); +} + +/* +================ +idForce_Grab::Restore +================ +*/ +void idForce_Grab::Restore( idRestoreGame *savefile ) { + //Note: Owner needs to call set physics + savefile->ReadFloat( damping ); + savefile->ReadVec3( goalPosition ); + savefile->ReadFloat( distanceToGoal ); + savefile->ReadInt( id ); +} + +/* +================ +idForce_Grab::idForce_Grab +================ +*/ +idForce_Grab::idForce_Grab( void ) { + damping = 0.5f; + physics = NULL; + id = 0; +} + +/* +================ +idForce_Grab::~idForce_Grab +================ +*/ +idForce_Grab::~idForce_Grab( void ) { +} + +/* +================ +idForce_Grab::Init +================ +*/ +void idForce_Grab::Init( float damping ) { + if ( damping >= 0.0f && damping < 1.0f ) { + this->damping = damping; + } +} + +/* +================ +idForce_Grab::SetPhysics +================ +*/ +void idForce_Grab::SetPhysics( idPhysics *phys, int id, const idVec3 &goal ) { + this->physics = phys; + this->id = id; + this->goalPosition = goal; +} + +/* +================ +idForce_Grab::SetGoalPosition +================ +*/ +void idForce_Grab::SetGoalPosition( const idVec3 &goal ) { + this->goalPosition = goal; +} + +/* +================= +idForce_Grab::GetDistanceToGoal +================= +*/ +float idForce_Grab::GetDistanceToGoal( void ) { + return distanceToGoal; +} + +/* +================ +idForce_Grab::Evaluate +================ +*/ +void idForce_Grab::Evaluate( int time ) { + if ( !physics ) + return; + + idVec3 forceDir, v, objectCenter; + float forceAmt; + float mass = physics->GetMass( id ); + + objectCenter = physics->GetAbsBounds( id ).GetCenter(); + + forceDir = goalPosition - objectCenter; + distanceToGoal = forceDir.Normalize(); + + float temp = distanceToGoal; + if ( temp > 12.0f && temp < 32.0f ) { + temp = 32.0f; + } + forceAmt = ( 1000.0f * mass ) + ( 500.0f * temp * mass ); + + if ( forceAmt / mass > 120000.0f ) { + forceAmt = 120000.0f * mass; + } + physics->AddForce( id, objectCenter, forceDir * forceAmt ); + + if ( distanceToGoal < 128.0f ) { + v = physics->GetLinearVelocity( id ); + if ( distanceToGoal <= 1.0f ) + physics->SetLinearVelocity( vec3_origin, id ); + else + physics->SetLinearVelocity( v * damping, id ); + } + + physics->SetAngularVelocity( vec3_origin, id ); + //if ( distanceToGoal < 16.0f ) { + // v = physics->GetAngularVelocity( id ); + // if ( v.LengthSqr() > Square( 8 ) ) { + // physics->SetAngularVelocity( v * 0.99999f, id ); + // } + //} +} + +/* +================ +idForce_Grab::RemovePhysics +================ +*/ +void idForce_Grab::RemovePhysics( const idPhysics *phys ) { + if ( physics == phys ) { + physics = NULL; + } +} + +// <---sikk \ No newline at end of file diff --git a/game/physics/Force_Grab.h b/game/physics/Force_Grab.h new file mode 100644 index 0000000..35fb17b --- /dev/null +++ b/game/physics/Force_Grab.h @@ -0,0 +1,54 @@ +// sikk---> Object Manipulation + +#ifndef __FORCE_GRAB_H__ +#define __FORCE_GRAB_H__ + +/* +=============================================================================== + + Drag force + +=============================================================================== +*/ + +class idForce_Grab : public idForce { + +public: + CLASS_PROTOTYPE( idForce_Grab ); + + void Save( idSaveGame *savefile ) const; + void Restore( idRestoreGame *savefile ); + + idForce_Grab( void ); + virtual ~idForce_Grab( void ); + // initialize the drag force + void Init( float damping ); + // set physics object being dragged + void SetPhysics( idPhysics *physics, int id, const idVec3 &goal ); + // update the goal position + void SetGoalPosition( const idVec3 &goal ); + + +public: // common force interface + virtual void Evaluate( int time ); + virtual void RemovePhysics( const idPhysics *phys ); + + // Get the distance from object to goal position + float GetDistanceToGoal( void ); + +private: + + // properties + float damping; + idVec3 goalPosition; + + float distanceToGoal; + + // positioning + idPhysics * physics; // physics object + int id; // clip model id of physics object +}; + +#endif /* !__FORCE_GRAB_H__ */ + +// <---sikk \ No newline at end of file