From fe4e5fe2dec190c6605e355442e47a968e84224a Mon Sep 17 00:00:00 2001 From: Professor Fartsalot Date: Mon, 21 Jul 2025 18:52:28 -0400 Subject: [PATCH] v8.2.0b Continued work on Wave Null + Added wipe mechanic, player deaths - Removed old method of checking if we're in a wave + Added the ability to get the core data directly within the plugin + Separated the default configs per game mode and automatically reset all values when the game mode changes --- scripting/FartsysAss.sp | 14 ++++-- scripting/include/fartsy/ass_bosshandler.inc | 6 +-- scripting/include/fartsy/ass_enhancer.inc | 4 +- scripting/include/fartsy/ass_helper.inc | 51 +++++++++++++++++--- scripting/include/fartsy/ass_sudo.inc | 1 + 5 files changed, 57 insertions(+), 19 deletions(-) diff --git a/scripting/FartsysAss.sp b/scripting/FartsysAss.sp index f24a37b..f78e416 100644 --- a/scripting/FartsysAss.sp +++ b/scripting/FartsysAss.sp @@ -21,13 +21,16 @@ #pragma newdecls required #pragma semicolon 1 -Database Get_Ass_Database(){ +Database Get_Ass_Database() { return Ass_Database; } -BOSSHANDLER Get_Boss_Handler(){ +COREDATA GetCoreData() { + return core; +} +BOSSHANDLER Get_Boss_Handler() { return BossHandler; } -int GetGameMode(){ +int GetGameMode() { return core.gamemode; } @@ -43,7 +46,8 @@ public void OnPluginStart() { AssLogger(LOGLVL_INFO, "####### STARTUP SEQUENCE INITIATED... PREPARE FOR THE END TIMES #######"); RegisterAndPrecacheAllFiles(); RegisterAllCommands(); - SetupCoreData(); + UpdateGamemode(); + if (core.gamemode == 0) SetupCoreData(); UpdateAllHealers(); CreateTimer(1.0, UpdateMedicHealing); CPrintToChatAll("{darkred}Plugin Reloaded. If you do not hear music, please do !sounds and configure your preferences."); @@ -61,10 +65,10 @@ public void OnFastFire2Ready(){ //Process ticks and requests in real time public void OnGameFrame() { - if (Enhancer_IsWave != core.isWave) Enhancer_IsWave = core.isWave; if(WeatherManager.TornadoWarning) WeatherManager.TickSiren(); if (AudioManager.shouldTick) AudioManager.TickBGM(); if (BossHandler.shouldTick) BossHandler.Tick(); if (BossHandler.tickBusterNuclear) BossHandler.TickBusterNuclear(); + if (core.gamemode == 2 && core.isWave) TickBodyCheck(); WeatherManager.TickFog(); } \ No newline at end of file diff --git a/scripting/include/fartsy/ass_bosshandler.inc b/scripting/include/fartsy/ass_bosshandler.inc index a307edf..f755ae4 100644 --- a/scripting/include/fartsy/ass_bosshandler.inc +++ b/scripting/include/fartsy/ass_bosshandler.inc @@ -160,7 +160,7 @@ enum struct BOSSHANDLER { int eCount = 0; for (int i = 1; i <= MaxClients; i++) { if (!IsClientInGame(i)) continue; - if (GetClientTeam(i) == TFTeam_Red && TF2_GetPlayerClass(i) == TFClass_Engineer) eCount++; + if (GetClientTeam(i) == 2 && TF2_GetPlayerClass(i) == TFClass_Engineer) eCount++; } int sCount = 0; int ent = -1 @@ -170,7 +170,7 @@ enum struct BOSSHANDLER { SetEntProp(ent, Prop_Send, "m_iTeamNum", TFTeam_Blue); SetEntPropEnt(ent, Prop_Data, "m_hOwnerEntity", 0); } - if (GetEntProp(ent, Prop_Send, "m_iTeamNum") == TFTeam_Red) { + if (GetEntProp(ent, Prop_Send, "m_iTeamNum") == 2) { sCount++; PrintToChatAll("Found %i sentry guns. I'm watching your ass...", sCount); if (sCount > eCount * 7){ @@ -274,7 +274,7 @@ enum struct BOSSHANDLER { CreateTimer(7.0, ResetTickBuster); } } - //Tank buster thing + // Tank buster - Potato cannon edition! void TickBusterNuclear(){ float cPos[3]; //Client's Position float pPos[3]; //Ground Particle Target Position diff --git a/scripting/include/fartsy/ass_enhancer.inc b/scripting/include/fartsy/ass_enhancer.inc index 2c09c80..413adcd 100644 --- a/scripting/include/fartsy/ass_enhancer.inc +++ b/scripting/include/fartsy/ass_enhancer.inc @@ -1,6 +1,4 @@ //Fartsy's Scene Enhancer v1.0.0 (Inspired by Mrbt0907/Weather2Remastered) - -bool Enhancer_IsWave; //All background music enum struct BGM { char realPath[64]; @@ -327,7 +325,7 @@ enum struct WEATHERMANAGER { this.fogTarget = this.defFogDensity; g_PowerOutage = false; this.hasTornado = false; - if(Enhancer_IsWave){ + if(GetCoreData().isWave){ this.mIntensity = 5; this.intensity = 7; } else { diff --git a/scripting/include/fartsy/ass_helper.inc b/scripting/include/fartsy/ass_helper.inc index e3bba02..5dbfc83 100644 --- a/scripting/include/fartsy/ass_helper.inc +++ b/scripting/include/fartsy/ass_helper.inc @@ -65,6 +65,9 @@ enum struct COREDATA { bool tickMusic; bool tickBGMOffset; char cachedPath[64]; + char configDefault[72]; + char configTacoBell[72]; + char configWaveNull[72]; char songName[64]; float HWNMin; float HWNMax; @@ -96,7 +99,6 @@ enum struct COREDATA { } } COREDATA core; - Database Ass_Database; int attemptSpawn = 0; bool isGoobbue = false; @@ -407,6 +409,9 @@ BULKFIRE crusaderAtk[64]; //Configure all variables void SetupCoreData(){ AssLogger(LOGLVL_INFO, "Setting up core data..."); + strcopy(core.configDefault, sizeof(core.configDefault),"addons/sourcemod/configs/FartsysAss/Core/WaveDefaults.ini"); + strcopy(core.configTacoBell, sizeof(core.configTacoBell),"addons/sourcemod/configs/FartsysAss/Core/WaveDefaults_TacoBell.ini"); + strcopy(core.configWaveNull, sizeof(core.configWaveNull),"addons/sourcemod/configs/FartsysAss/Core/WaveDefaults_WaveNull.ini"); ass[0].name = "[10] Bath Salts"; ass[1].name = "[20] Summon Goobbue or Kirby"; ass[2].name = "[30] Robot Trap (Wave Fail-safe)"; @@ -741,7 +746,7 @@ void SetupCoreData(){ if (IsEndOfFile(confCoreData)) break; } AssLogger(1, "[CORE] Setting up Wave Defaults..."); - confCoreData = OpenFile("addons/sourcemod/configs/FartsysAss/Core/WaveDefaults.ini", "rt", false); + confCoreData = OpenFile(OVERRIDE_AND_GET_COREDATA(), "rt", false); int defIndexHW, defIndexTornado, defIndexBGM, defIndexBS, defIndexBSM, defIndexSPM; // Start at 0 because we don't have a wave 0 if(confCoreData == INVALID_HANDLE) return; while (ReadFileLine(confCoreData, bufCoreData, sizeof(bufCoreData))){ @@ -786,16 +791,19 @@ void SetupCoreData(){ HookEventEx("player_hurt", Event_PlayerHurt, EventHookMode_Pre); AssLogger(1, "Core data setup complete!"); } - +// Checks if the gamemode has changed, if it has, reinitialise all core data. void UpdateGamemode(){ - char logdata[256]; - char popfile[128]; + char logdata[192], popfile[128]; int ent = FindEntityByClassname(-1, "tf_objective_resource"); if (ent == -1) return; GetEntPropString(ent, Prop_Send, "m_iszMvMPopfileName", popfile, sizeof(popfile)); - core.gamemode = (StrContains(popfile, "tacobell") != -1 ? 1 : (StrContains(popfile, "wavenull") != -1) ? 2 : 0); - Format(logdata, sizeof(logdata), "Testing if popfile contains tacobell or wavenull, result %i", core.gamemode); - AssLogger(LOGLVL_DEBUG, logdata); + int gamemode = (StrContains(popfile, "tacobell") != -1 ? 1 : (StrContains(popfile, "wavenull") != -1) ? 2 : 0); + if(core.gamemode != gamemode) { + Format(logdata, sizeof(logdata), "Current gamemode %i does not match detected gamemode %i! Someone must have changed the gamemode! Setting up core data immediately!!!", core.gamemode, gamemode); + AssLogger(LOGLVL_DEBUG, logdata); + core.gamemode = gamemode; + SetupCoreData(); + } } //Messages to be printed when the fail safe has been triggered. char failsafe[][256] = { @@ -1746,4 +1754,31 @@ void SendHudTextAll(int channel, const char[] text, float posX, float posY, floa ShowHudText(i, channel, text); } } +} +// WIPE MECHANIC - If all players die, the wave fails. +void TickBodyCheck() { + int alive = 0; + for (int i = 1; i <= MaxClients; i++) if (IsPlayerAlive(i) && GetClientTeam(i) == 2) alive++; + if (alive == 0) { + CPrintToChatAll("{red}You've all died! Are you happy?"); + FastFire2("bots_win", "roundwin", "", 0.0, false); + } +} +//Gets config file based on the game mode, we use the struct because returning differing array sizes is impossible otherwise. +char[] OVERRIDE_AND_GET_COREDATA() { + switch (core.gamemode) { + case 0: { + return core.configDefault; + } + case 1: { + return core.configTacoBell; + } + case 2: { + return core.configWaveNull; + } + default: { + LogError("Gamemode %i out of bounds. Reverting to defaults.", core.gamemode); + return core.configDefault; + } + } } \ No newline at end of file diff --git a/scripting/include/fartsy/ass_sudo.inc b/scripting/include/fartsy/ass_sudo.inc index 216a0dd..b3c9405 100644 --- a/scripting/include/fartsy/ass_sudo.inc +++ b/scripting/include/fartsy/ass_sudo.inc @@ -23,6 +23,7 @@ void sudo(int task) { float hwn = GetRandomFloat(core.HWNMin, core.HWNMax); CreateTimer(hwn, HWBosses); AudioManager.ChangeBGM(core.tacobell ? tacoBellBGMIndex[core.curWave] : DefaultsArray[core.curWave].defBGMIndex); + PrintToChatAll("WARNING, AUDIOMANAGER'S CHANGEBGM FUNCTION IS DEPRECATED IN FAVOR OF THE NEW CONFIGS. FIX THIS IMMEDIATELY."); return; } //Force Tornado