From 4930344d29deefa874d5837f3c17ec6493579503 Mon Sep 17 00:00:00 2001 From: Pinsplash <39359267+Pinsplash@users.noreply.github.com> Date: Tue, 30 Apr 2024 07:09:33 -0500 Subject: [PATCH] added effect Changing Pitch and fixed ep2 missing particles --- sourcemods/ep1chaos/cfg/autoexec.cfg | 6 +++ sourcemods/ep2chaos/cfg/autoexec.cfg | 6 +++ .../ep2chaos/particles/particles_manifest.txt | 49 +++++++++++++++++++ sourcemods/hl2chaos/cfg/autoexec.cfg | 6 +++ sp/src/game/server/hl2/chaos.h | 7 +++ sp/src/game/server/hl2/hl2_player.cpp | 22 ++++++++- sp/src/game/server/sceneentity.cpp | 12 +++-- 7 files changed, 103 insertions(+), 5 deletions(-) create mode 100644 sourcemods/ep2chaos/particles/particles_manifest.txt diff --git a/sourcemods/ep1chaos/cfg/autoexec.cfg b/sourcemods/ep1chaos/cfg/autoexec.cfg index d4663d03..78cb0cf4 100644 --- a/sourcemods/ep1chaos/cfg/autoexec.cfg +++ b/sourcemods/ep1chaos/cfg/autoexec.cfg @@ -44,6 +44,9 @@ chaos_time_no_brake 1 //Bumpy Road chaos_time_bumpy 1 +//Changing Pitch +chaos_time_change_pitch 1 + //Color Incorrection chaos_time_random_cc 1 @@ -226,6 +229,9 @@ chaos_prob_no_brake 600 //Bumpy Road chaos_prob_bumpy 600 +//Changing Pitch +chaos_prob_change_pitch 100 + //Color Incorrection chaos_prob_random_cc 100 diff --git a/sourcemods/ep2chaos/cfg/autoexec.cfg b/sourcemods/ep2chaos/cfg/autoexec.cfg index d4663d03..78cb0cf4 100644 --- a/sourcemods/ep2chaos/cfg/autoexec.cfg +++ b/sourcemods/ep2chaos/cfg/autoexec.cfg @@ -44,6 +44,9 @@ chaos_time_no_brake 1 //Bumpy Road chaos_time_bumpy 1 +//Changing Pitch +chaos_time_change_pitch 1 + //Color Incorrection chaos_time_random_cc 1 @@ -226,6 +229,9 @@ chaos_prob_no_brake 600 //Bumpy Road chaos_prob_bumpy 600 +//Changing Pitch +chaos_prob_change_pitch 100 + //Color Incorrection chaos_prob_random_cc 100 diff --git a/sourcemods/ep2chaos/particles/particles_manifest.txt b/sourcemods/ep2chaos/particles/particles_manifest.txt new file mode 100644 index 00000000..af26d764 --- /dev/null +++ b/sourcemods/ep2chaos/particles/particles_manifest.txt @@ -0,0 +1,49 @@ +particles_manifest +{ + "file" "particles/error.pcf" + "file" "particles/explosion.pcf" + "file" "particles/blood_impact.pcf" + "file" "particles/vehicle.pcf" + "file" "particles/dust_bombdrop.pcf" + "file" "particles/building_explosion.pcf" + "file" "particles/antlion_gib_01.pcf" + "file" "particles/antlion_gib_02.pcf" + "file" "particles/stalactite.pcf" + "file" "particles/striderbuster.pcf" + "file" "particles/door_explosion.pcf" + "file" "particles/choreo_launch.pcf" + "file" "particles/water_leaks.pcf" + "file" "particles/antlion_worker.pcf" + "file" "particles/skybox_smoke.pcf" + "file" "particles/waterfall.pcf" + "file" "particles/aurora.pcf" + "file" "particles/rain.pcf" + "file" "particles/warpshield.pcf" + "file" "particles/aurora_sphere2.pcf" + "file" "particles/advisor.pcf" + "file" "particles/fire_01.pcf" + "file" "particles/hunter_shield_impact.pcf" + "file" "particles/water_impact.pcf" + "file" "particles/hunter_intro.pcf" + "file" "particles/dust_rumble.pcf" + "file" "particles/Advisor_FX.pcf" + "file" "particles/hunter_projectile.pcf" + "file" "particles/choreo_dog_v_strider.pcf" + "file" "particles/steampuff.pcf" + "file" "particles/magnusson_burner.pcf" + "file" "particles/combineball.pcf" + "file" "particles/waterdrips.pcf" + "file" "particles/hunter_flechette.pcf" + "file" "particles/choreo_gman.pcf" + "file" "particles/weapon_fx.pcf" + "file" "particles/choreo_extract.pcf" + "file" "particles/Vortigaunt_FX.pcf" + "file" "particles/devtest.pcf" + "file" "particles/electrical_fx.pcf" + "file" "particles/burning_fx.pcf" + "file" "particles/antlion_blood.pcf" + "file" "particles/grub_blood.pcf" + "file" "particles/grenade_fx.pcf" + "file" "particles/rocket_fx.pcf" + "file" "particles/impact_fx.pcf" +} diff --git a/sourcemods/hl2chaos/cfg/autoexec.cfg b/sourcemods/hl2chaos/cfg/autoexec.cfg index cbe89893..95b27a3e 100644 --- a/sourcemods/hl2chaos/cfg/autoexec.cfg +++ b/sourcemods/hl2chaos/cfg/autoexec.cfg @@ -44,6 +44,9 @@ chaos_time_no_brake 1 //Bumpy Road chaos_time_bumpy 1 +//Changing Pitch +chaos_time_change_pitch 1 + //Color Incorrection chaos_time_random_cc 1 @@ -226,6 +229,9 @@ chaos_prob_no_brake 600 //Bumpy Road chaos_prob_bumpy 600 +//Changing Pitch +chaos_prob_change_pitch 100 + //Color Incorrection chaos_prob_random_cc 100 diff --git a/sp/src/game/server/hl2/chaos.h b/sp/src/game/server/hl2/chaos.h index e9c9f171..86200d82 100644 --- a/sp/src/game/server/hl2/chaos.h +++ b/sp/src/game/server/hl2/chaos.h @@ -99,6 +99,7 @@ enum Effect_T EFFECT_NORMAL_VISION, EFFECT_GIVE_ALL_RPG, EFFECT_GRASS_HEAL, + EFFECT_CHANGE_PITCH, //EFFECT_EVIL_ELI, //EFFECT_EVIL_BREEN, @@ -580,4 +581,10 @@ class CEGiveAllRPG : public CChaosEffect public: void StartEffect() override; }; +class CEChangePitch : public CChaosEffect +{ +public: + void MaintainEffect() override; + void StopEffect() override; +}; #endif \ No newline at end of file diff --git a/sp/src/game/server/hl2/hl2_player.cpp b/sp/src/game/server/hl2/hl2_player.cpp index c4cd6e2e..b4c77bd6 100644 --- a/sp/src/game/server/hl2/hl2_player.cpp +++ b/sp/src/game/server/hl2/hl2_player.cpp @@ -5343,6 +5343,7 @@ ConVar chaos_time_yawroll("chaos_time_yawroll", "1"); ConVar chaos_time_zombiespam("chaos_time_zombiespam", "1"); ConVar chaos_time_normalvision("chaos_time_normalvision", "1"); ConVar chaos_time_grass_heal("chaos_time_grass_heal", "1"); +ConVar chaos_time_change_pitch("chaos_time_change_pitch", "1"); ConVar chaos_prob_zerog("chaos_prob_zerog", "100"); ConVar chaos_prob_superg("chaos_prob_superg", "100"); @@ -5428,6 +5429,7 @@ ConVar chaos_prob_yawroll("chaos_prob_yawroll", "100"); ConVar chaos_prob_normalvision("chaos_prob_normalvision", "100"); ConVar chaos_prob_giveallrpg("chaos_prob_giveallrpg", "100"); ConVar chaos_prob_grass_heal("chaos_prob_grass_heal", "100"); +ConVar chaos_prob_change_pitch("chaos_prob_change_pitch", "100"); //ConVar chaos_prob_evil_eli("chaos_prob_evil_eli", "100"); //ConVar chaos_prob_evil_breen("chaos_prob_evil_breen", "100"); #define ERROR_WEIGHT 1 @@ -5518,6 +5520,7 @@ void CHL2_Player::PopulateEffects() CreateEffect<>(EFFECT_NORMAL_VISION, MAKE_STRING("Normal Vision"), EC_NONE, chaos_time_normalvision.GetFloat(), chaos_prob_normalvision.GetInt()); CreateEffect(EFFECT_GIVE_ALL_RPG, MAKE_STRING("Give Everyone RPGs"), EC_NONE, -1, chaos_prob_giveallrpg.GetInt()); CreateEffect(EFFECT_GRASS_HEAL, MAKE_STRING("Touch the Grass"), EC_NONE, chaos_time_grass_heal.GetFloat(), chaos_prob_grass_heal.GetInt()); + CreateEffect(EFFECT_CHANGE_PITCH, MAKE_STRING("Changing Pitch"), EC_NONE, chaos_time_change_pitch.GetFloat(), chaos_prob_change_pitch.GetInt()); //CreateEffect(EFFECT_EVIL_ELI, MAKE_STRING("Evil Eli"), EC_HAS_WEAPON, -1, chaos_prob_evil_eli.GetInt()); //CreateEffect(EFFECT_EVIL_BREEN, MAKE_STRING("Hands-on Dr. Breen"), EC_HAS_WEAPON, -1, chaos_prob_evil_breen.GetInt()); } @@ -6239,10 +6242,14 @@ void CChaosEffect::RestoreEffect() StartEffect(); } -//Do not restore: +//Do not include: //Simple convar changes or any other thing that isn't affected by world state. //Transient things, unless they have an override RestoreEffect. If spawned entities wish to persist through saves they have their own thing. //Effects that can survive on MaintainEffect or FastThink. + +//do include: +//changes variables of existing entities +//makes entities that should persist (but dont use the 'chaos spawned' variable) bool CChaosEffect::DoRestorationAbort() { switch (m_nID) @@ -6278,6 +6285,9 @@ bool CChaosEffect::DoRestorationAbort() //alters triggers case EFFECT_SOLID_TRIGGERS: + //alters scene ents + case EFFECT_CHANGE_PITCH: + //gone forever if not restarted case EFFECT_EARTHQUAKE: @@ -9342,4 +9352,14 @@ void CEGiveAllRPG::StartEffect() pNPC->GiveWeapon(MAKE_STRING("weapon_rpg")); pEnt = gEntList.FindEntityByClassname(pEnt, "npc*"); } +} +void CEChangePitch::MaintainEffect() +{ + //the convar allows us to hit instanced scenes at their moment of creation. + float flPitch = RandomFloat(0.25, 2.5); + engine->ClientCommand(engine->PEntityOfEntIndex(1), "scene_pitch_default %f; ent_fire logic_choreographed_scene pitchshift %f\n", flPitch, flPitch); +} +void CEChangePitch::StopEffect() +{ + engine->ClientCommand(engine->PEntityOfEntIndex(1), "scene_pitch_default 1; ent_fire logic_choreographed_scene pitchshift 1\n"); } \ No newline at end of file diff --git a/sp/src/game/server/sceneentity.cpp b/sp/src/game/server/sceneentity.cpp index 722da801..6a61a4bf 100644 --- a/sp/src/game/server/sceneentity.cpp +++ b/sp/src/game/server/sceneentity.cpp @@ -53,7 +53,7 @@ class CBaseFlex; static ConVar scene_forcecombined( "scene_forcecombined", "0", 0, "When playing back, force use of combined .wav files even in english." ); static ConVar scene_maxcaptionradius( "scene_maxcaptionradius", "1200", 0, "Only show closed captions if recipient is within this many units of speaking actor (0==disabled)." ); - +ConVar scene_pitch_default("scene_pitch_default", "1"); // Assume sound system is 100 msec lagged (only used if we can't find snd_mixahead cvar!) #define SOUND_SYSTEM_LATENCY_DEFAULT ( 0.1f ) @@ -748,7 +748,7 @@ CSceneEntity::CSceneEntity( void ) m_bIsPlayingBack = false; m_bPaused = false; m_bMultiplayer = false; - m_fPitch = 1.0f; + m_fPitch = scene_pitch_default.GetFloat(); m_iszSceneFile = NULL_STRING; m_iszResumeSceneFile = NULL_STRING; m_hWaitingForThisResumeScene = NULL; @@ -1069,7 +1069,7 @@ void CSceneEntity::OnRestore() // Fix saved games that have their pitch set to zero if ( m_fPitch < SCENE_MIN_PITCH || m_fPitch > SCENE_MAX_PITCH ) - m_fPitch = 1.0f; + m_fPitch = scene_pitch_default.GetFloat(); if ( !m_bIsPlayingBack ) return; @@ -2738,7 +2738,10 @@ void CSceneEntity::PitchShiftPlayback( float fPitch ) if ( !m_pScene ) return; - + //this code was leading to voice lines playing twice, once old pitch, once new pitch, and potentially from the wrong actor. + //removing this means the currently spoken line, if any, will not instantly change pitch, which is definitely less confusing. + //the underlying bug appears to be in engine code. + /* for ( int iActor = 0 ; iActor < m_pScene->GetNumActors(); ++iActor ) { CBaseFlex *pTestActor = FindNamedActor( iActor ); @@ -2758,6 +2761,7 @@ void CSceneEntity::PitchShiftPlayback( float fPitch ) pTestActor->EmitSound( filter, pTestActor->entindex(), params ); } } + */ } //-----------------------------------------------------------------------------