Merge pull request #5 from ProfessorFartsalot/mvm-expand-audio-functionality
Fix up bugs from recent pull request
This commit is contained in:
@@ -80,12 +80,17 @@ enum struct AUDIOMANAGER {
|
||||
void ChangeBGM(int bgm, bool instant) {
|
||||
this.indexBGM = this.VIPBGM > 0 ? this.VIPBGM : bgm == 0 ? g_indexBGM : bgm;
|
||||
PrintToChatAll("%i = %i > 0 ? %i : %i == 0 ? %i : %i", this.indexBGM, this.VIPBGM, this.VIPBGM, bgm, g_indexBGM, bgm);
|
||||
if (instant) { this.timeSeconds = GetEngineTime() - this.loopSeconds; }
|
||||
PrintToServer("Set %i for %N", this.indexBGM, this.Client);
|
||||
if (instant) {
|
||||
this.timeSeconds = 0.0;
|
||||
CreateTimer(1.0, SyncMusic, this.Client);
|
||||
}
|
||||
PrintToServer("%f",GetEngineTime());
|
||||
this.shouldTick = true;
|
||||
this.hasTimeOffset = BGMArray[this.indexBGM].introSeconds > 0 ? true : false;
|
||||
this.stopBGM = !StrEqual(this.cachedPath, BGMArray[this.indexBGM].realPath) && !this.EventMode ? true : false;
|
||||
PrintToServer(!StrEqual(this.cachedPath, BGMArray[this.indexBGM].realPath) && !this.EventMode ? "true" : "false");
|
||||
this.bgmPlaying = true;
|
||||
CreateTimer(1.0, SyncMusic, this.Client);
|
||||
//if (this.indexBGM >= 20) for (int i = 0; i < MaxClients; i++) for (int s = 19; s < bgm; s++) StopSound(i, this.chanBGM, BGMArray[s].realPath); //Very quick, very dirty, very suboptimal, but gets the job done... This stops all boss music.
|
||||
}
|
||||
void EnterEventMode(int bgm) {
|
||||
@@ -147,9 +152,11 @@ enum struct AUDIOMANAGER {
|
||||
}
|
||||
if (this.indexBGM == 0) this.indexBGM = g_indexBGM;
|
||||
if (this.engineSecondsAdjusted() > this.timeSeconds + this.loopSeconds) {
|
||||
PrintToServer("Playing %i for %N", this.indexBGM, this.Client);
|
||||
this.timeSeconds = GetEngineTime();
|
||||
this.loops++;
|
||||
if (this.stopBGM) {
|
||||
PrintToServer("Stopping %s", this.cachedPath);
|
||||
StopSound(this.Client, g_chanBGM, this.cachedPath);
|
||||
this.loops = 0;
|
||||
}
|
||||
@@ -158,16 +165,21 @@ enum struct AUDIOMANAGER {
|
||||
strcopy(this.songName, sizeof(this.songName), BGMArray[this.indexBGM].songName);
|
||||
this.introSeconds = this.loops >= 1 ? BGMArray[this.indexBGM].introSeconds : 0.0;
|
||||
this.loopSeconds = BGMArray[this.indexBGM].loopSeconds;
|
||||
CreateTimer(1.0, SyncMusic, this.Client);
|
||||
}
|
||||
}
|
||||
/**When a client joins the server, set this audio manager to theirs */
|
||||
void OnClientConnected(int client) {
|
||||
if (!IsValidClient(client) || IsFakeClient(client)) {
|
||||
PrintToServer("Invalid client %N", client);
|
||||
return;
|
||||
}
|
||||
this.Client = client;
|
||||
this.clientIsFresh = true;
|
||||
}
|
||||
/**When a client respawns */
|
||||
void OnClientRespawned() {
|
||||
if (this.clientIsFresh) {
|
||||
if (this.clientIsFresh && IsValidClient(this.Client)) {
|
||||
if (soundPreference[this.Client] == 1 || soundPreference[this.Client] == 3) CPrintToChat(this.Client, "[AudioManager v%s] Welcome! We are listening to %s", FSE_VER, BGMArray[g_indexBGM].songName);
|
||||
this.ChangeBGM(g_indexBGM, true);
|
||||
this.clientIsFresh = false;
|
||||
@@ -183,7 +195,7 @@ enum struct AUDIOCONTROLLER {
|
||||
void init() {
|
||||
AssLogger(LOGLVL_INFO, "Initializing Global Audio...");
|
||||
g_chanBGM = 6;
|
||||
for (int i = 0; i < MaxClients; ++i) {
|
||||
for (int i = 1; i < MaxClients; ++i) {
|
||||
AudioManager[i].bgmPlaying = false;
|
||||
AudioManager[i].stopBGM = false;
|
||||
AudioManager[i].shouldTick = false;
|
||||
@@ -208,7 +220,10 @@ enum struct AUDIOCONTROLLER {
|
||||
}
|
||||
void setBGM(int bgm, bool instant){
|
||||
g_indexBGM = bgm == 0 ? GetRandomInt(1,4) : bgm;
|
||||
for (int i = 0; i < MaxClients; ++i) AudioManager[i].ChangeBGM(bgm, instant);
|
||||
for (int i = 0; i < MaxClients; ++i) if(IsValidClient(i)) {
|
||||
AudioManager[i].ChangeBGM(bgm, instant);
|
||||
PrintToServer("Setting %N's BGM to %i", i, bgm);
|
||||
}
|
||||
}
|
||||
void Stop() {
|
||||
for (int i = 0; i < MaxClients; ++i) AudioManager[i].Stop();
|
||||
@@ -218,10 +233,15 @@ enum struct AUDIOCONTROLLER {
|
||||
}
|
||||
/** Sets EVERYONE'S BGM in sync! Unless they're in an event... */
|
||||
void UpdateBGM() {
|
||||
for (int i = 0; i < MaxClients; ++i) if (IsValidClient(i)) {
|
||||
if (AudioManager[i].isEventMode() || !IsValidClient(i)) continue;
|
||||
AudioManager[i].ChangeBGM(this.VIPBGM > 0 ? this.VIPBGM : AudioManager[i].indexBGM == 0 ? g_indexBGM : AudioManager[i].indexBGM, true);
|
||||
AudioManager[i].shouldTick = true;
|
||||
for (int i = 0; i < MaxClients; ++i) {
|
||||
if (IsValidClient(i)) {
|
||||
if (AudioManager[i].isEventMode() || !IsValidClient(i)) {
|
||||
PrintToServer("Client %N valid? %s Event Mode? %s", i, IsValidClient(i) ? "true" : "false", AudioManager[i].isEventMode() ? "true" : "false");
|
||||
continue;
|
||||
}
|
||||
AudioManager[i].ChangeBGM(this.VIPBGM > 0 ? this.VIPBGM : AudioManager[i].indexBGM == 0 ? g_indexBGM : AudioManager[i].indexBGM, true);
|
||||
AudioManager[i].shouldTick = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
46
scripting/include/fartsy/ass_entityhooks.inc
Normal file
46
scripting/include/fartsy/ass_entityhooks.inc
Normal file
@@ -0,0 +1,46 @@
|
||||
enum struct HOOKS {
|
||||
int ent;
|
||||
char output[64];
|
||||
EntityOutput callback;
|
||||
}
|
||||
HOOKS g_HookedEntities[128];
|
||||
int g_HookedCount = 0;
|
||||
|
||||
// Hooks an entity by its index
|
||||
void HookSingleEntity(int ent, const char[] output, EntityOutput callback)
|
||||
{
|
||||
if (!IsValidEntity(ent) || g_HookedCount >= sizeof(g_HookedEntities)) return;
|
||||
for (int i = 0; i < g_HookedCount; i++) if (g_HookedEntities[i].ent == ent && StrEqual(g_HookedEntities[i].output, output)) return; // Avoid duplicates (same ent + output)
|
||||
HookSingleEntityOutput(ent, output, callback);
|
||||
g_HookedEntities[g_HookedCount].ent = ent;
|
||||
strcopy(g_HookedEntities[g_HookedCount].output, sizeof(g_HookedEntities[g_HookedCount].output), output);
|
||||
g_HookedEntities[g_HookedCount].callback = callback;
|
||||
PrintToServer("Hooking entity %i with output %s", ent, g_HookedEntities[g_HookedCount].output);
|
||||
g_HookedCount++;
|
||||
}
|
||||
|
||||
public void OnEntityDestroyed(int ent){
|
||||
for (int i = g_HookedCount - 1; i >= 0; i--)
|
||||
{
|
||||
if (g_HookedEntities[i].ent == ent)
|
||||
{
|
||||
UnhookSingleEntityOutput(ent, g_HookedEntities[i].output, g_HookedEntities[i].callback);
|
||||
|
||||
// Remove entry by shifting left
|
||||
for (int j = i; j < g_HookedCount - 1; j++)
|
||||
{
|
||||
g_HookedEntities[j] = g_HookedEntities[j + 1];
|
||||
}
|
||||
g_HookedCount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Hook necessary entities for this plugin's operation
|
||||
void HookAllEntities() {
|
||||
//PrintToServer("HOOKING ALL THE ENTITIES.");
|
||||
//HookSingleEntity(FindEntityByTargetname("Operator", "point_servercommand"), "Command", ass_relay_user1);
|
||||
}
|
||||
|
||||
public void ass_relay_user1(const char[] output, int caller, int activator, float delay){
|
||||
//PrintToServer("Got output %s", output);
|
||||
}
|
@@ -80,6 +80,7 @@ enum struct COREDATA {
|
||||
int failsafeCount;
|
||||
int gamemode;
|
||||
int lastAdmin;
|
||||
int nullIndex;
|
||||
int refireTime;
|
||||
int sacPoints;
|
||||
int sacPointsMax;
|
||||
@@ -634,6 +635,7 @@ void SetupCoreData(){
|
||||
core.curWave = 0;
|
||||
core.failsafeCount = 0;
|
||||
core.lastAdmin = 0;
|
||||
core.nullIndex = 0;
|
||||
core.sacPoints = 0;
|
||||
core.sacPointsMax = 60;
|
||||
core.VIPIndex = 0;
|
||||
@@ -1110,8 +1112,8 @@ void RegisterAndPrecacheAllFiles(){
|
||||
//Used to keep StopSound from stopping the music we're trying to play - now with support for loop offsets!
|
||||
public Action SyncMusic(Handle timer, int client) {
|
||||
int index = AudioManager[client].indexBGM;
|
||||
AudioManager[client].cachedPath = BGMArray[index].realPath;
|
||||
AudioManager[client].songName = BGMArray[index].songName;
|
||||
StrCopy(AudioManager[client].cachedPath, sizeof(AudioManager[client].cachedPath), BGMArray[index].realPath);
|
||||
StrCopy(AudioManager[client].songName, sizeof(AudioManager[client].songName), BGMArray[index].songName);
|
||||
AssLogger(LOGLVL_INFO, "[AudioManager for %N]: We are on wave %i, now playing: %s (from %s) for %f seconds. It will start looping at %f seconds after the first cycle.", client, core.curWave, AudioManager[client].songName, AudioManager[client].cachedPath, AudioManager[client].loopSeconds, BGMArray[index].introSeconds);
|
||||
return Plugin_Stop;
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
public char PLUGIN_VERSION[8] = "8.4.1";
|
||||
public char PLUGIN_VERSION[8] = "8.4.2";
|
||||
void sudo(int task) {
|
||||
AssLogger(LOGLVL_DEBUG, "Calling sudo with %i", task);
|
||||
switch (task) {
|
||||
@@ -28,7 +28,6 @@ void sudo(int task) {
|
||||
float hwn = GetRandomFloat(core.HWNMin, core.HWNMax);
|
||||
CreateTimer(hwn, HWBosses);
|
||||
GlobalAudio.setBGM(core.tacobell ? tacoBellBGMIndex[core.curWave] : DefaultsArray[core.curWave].defBGMIndex, true);
|
||||
PrintToChatAll("WARNING, AUDIOMANAGER'S CHANGEBGM FUNCTION IS DEPRECATED IN FAVOR OF THE NEW CONFIGS. FIX THIS IMMEDIATELY.");
|
||||
return;
|
||||
}
|
||||
//Force Tornado
|
||||
@@ -191,9 +190,38 @@ void sudo(int task) {
|
||||
else bombState[0].state += 2;
|
||||
return;
|
||||
}
|
||||
//Tank deployed its bomb
|
||||
//Tank deployed its bomb or boss reached hatch
|
||||
case 16: {
|
||||
CPrintToChatAll("{darkviolet}[{forestgreen}CORE{darkviolet}] {white}A tank has deployed its bomb! ({limegreen}+1 pt{white})");
|
||||
sudo(18);
|
||||
CPrintToChatAll("{darkviolet}[{fartsyred}CORE{darkviolet}] {white}A tank has deployed its bomb!");
|
||||
return;
|
||||
}
|
||||
case 17 : {
|
||||
sudo(18);
|
||||
CPrintToChatAll("{darkviolet}[{fartsyred}CORE{darkviolet}] {white}A robot has deployed its bomb!");
|
||||
return;
|
||||
}
|
||||
case 18: {
|
||||
if(!core.isWave) {
|
||||
CPrintToChatAll("{fartsyred} PLEASE DO NOT ATTEMPT TO USE OPERATOR 18 WITHOUT A WAVE.");
|
||||
return;
|
||||
}
|
||||
FastFire2("bots_win", "RoundWin", "", 1.0, false);
|
||||
FastFire2("hatch_magnet_pit", "Enable", "", 1.0, false);
|
||||
FastFire2("hatch_explo_kill_players", "Enable", "", 1.0, false);
|
||||
FastFire2("cap_hatch_destroy_animated_prop", "Enable", "", 1.0, false);
|
||||
FastFire2("cap_hatch_destroy_delete_prop", "Kill", "", 1.0, false);
|
||||
FastFire2("end_pit_destroy_particle", "Start", "", 1.0, false);
|
||||
FastFire2("trigger_hurt_hatch_fire", "Enable", "", 1.0, false);
|
||||
FastFire2("cap_hatch_glasswindow", "Break", "", 1.0, false);
|
||||
FastFire2("hatch_explo_kill_players", "Disable", "", 1.50, false);
|
||||
FastFire2("hatch_magnet_pit", "Disable", "", 5.0, false);
|
||||
FastFire2("cap_hatch_destroy_animated_prop", "SetAnimation", "explode", 1.0, false);
|
||||
FastFire2("tank_boss", "DestroyIfAtCapturePoint", "1", 1.0, false);
|
||||
FastFire2("tank_boss", "DestroyIfAtCapturePoint", "2", 1.0, false);
|
||||
FastFire2("tank_boss", "DestroyIfAtCapturePoint", "3", 1.0, false);
|
||||
EmitSoundToAll("MVM.BombExplodes");
|
||||
return;
|
||||
}
|
||||
//Shark Enable & notify bomb push began
|
||||
case 20: {
|
||||
@@ -632,20 +660,34 @@ void sudo(int task) {
|
||||
EmitSoundToAll(BGMArray[6].realPath, _, g_chanBGM, BGMArray[6].SNDLVL, SND_CHANGEVOL, 1.0, _, _, _, _, _, _);
|
||||
}
|
||||
case 420:{ // Init/Reset Wave Null.
|
||||
CPrintToChatAll("{red} [CORE] WARNING: Initializing Wave Null... Welcome to a new kind of tension, everything isn't meant to be okay. :')");
|
||||
UpdateGamemode();
|
||||
if (core.gamemode != 2) return;
|
||||
CPrintToChatAll("{fartsyred} [WARNING]: Initializing Wave Null...");
|
||||
CPrintToChatAll("{fartsyred} [WARNING]: YOU HAVE CHOSEN TO LAUNCH WAVE NULL.");
|
||||
CPrintToChatAll("{fartsyred} [WARNING]: SHOULD YOU FAIL THIS WAVE, YOU *WILL* BE RESTARTING FROM THE VERY BEGINNING WITH NO UPGRADES.");
|
||||
CPrintToChatAll("{fartsyred} [WARNING]: THE FATE OF THIS SERVER IS IN YOUR HANDS. DO. NOT. FAIL.");
|
||||
FastFire2("Weather.Sky", "Skin", "3", 0.0, false);
|
||||
WeatherManager.fogDensity = 0.1;
|
||||
}
|
||||
case 421:{
|
||||
UpdateGamemode();
|
||||
if (core.gamemode != 2) return;
|
||||
core.curWave = GetCurWave();
|
||||
PerformWaveSetup();
|
||||
//HandleWaveNull();
|
||||
float hwn = GetRandomFloat(core.HWNMin, core.HWNMax);
|
||||
CreateTimer(hwn, HWBosses);
|
||||
PrintToChatAll("playing sound\\fartsy\\music\\wavenull_intro.mp3, waves should be timed so that the music changes right at the end of this intro.");
|
||||
FastFire2("weather.sky", "Skin", "2", 0.0, false);
|
||||
GlobalAudio.setBGM(28, false);
|
||||
sudo(1001);
|
||||
EmitSoundToAll("sound/fartsy/music/wavenull_intro.mp3");
|
||||
WeatherManager.fogColorRTarget = 95.0;
|
||||
WeatherManager.fogColorGTarget = 35.0;
|
||||
WeatherManager.fogColorBTarget = 35.0;
|
||||
}
|
||||
case 422:{
|
||||
GlobalAudio.setBGM(29, false);
|
||||
GlobalAudio.setBGM(28, true);
|
||||
//GlobalAudio.setBGM(29, false);
|
||||
}
|
||||
case 423:{
|
||||
GlobalAudio.setBGM(30, false);
|
||||
@@ -694,7 +736,7 @@ void sudo(int task) {
|
||||
}
|
||||
//Stop current song
|
||||
case 1001: {
|
||||
for (int i = 1; i <= MaxClients; i++){
|
||||
for (int i = 0; i <= MaxClients; i++) {
|
||||
if (StrEqual(BGMArray[AudioManager[i].indexBGM].realPath, "null")) continue;
|
||||
StopSound(i, g_chanBGM, BGMArray[AudioManager[i].indexBGM].realPath);
|
||||
}
|
||||
@@ -895,32 +937,12 @@ void sudo(int task) {
|
||||
}
|
||||
case 21000:{
|
||||
int i = FindTarget(0, "Professor", true, false);
|
||||
AudioManager[i].EnterEventMode(30);
|
||||
AudioManager[i].EnterEventMode(29);
|
||||
}
|
||||
case 22000:{
|
||||
int i = FindTarget(0, "Professor", true, false);
|
||||
AudioManager[i].ExitEventMode();
|
||||
}
|
||||
// WAVE NULL Init
|
||||
case 40000: {
|
||||
UpdateGamemode();
|
||||
if (core.gamemode != 2) return;
|
||||
CPrintToChatAll("{fartsyred} [WARNING]: YOU HAVE CHOSEN TO LAUNCH WAVE NULL.");
|
||||
CPrintToChatAll("{fartsyred} [WARNING]: SHOULD YOU FAIL THIS WAVE, YOU *WILL* BE RESTARTING FROM THE VERY BEGINNING WITH NO UPGRADES.");
|
||||
CPrintToChatAll("{fartsyred} [WARNING]: THE FATE OF THIS SERVER IS IN YOUR HANDS. DO. NOT. FAIL.");
|
||||
}
|
||||
// WAVE NULL started!
|
||||
case 40001: {
|
||||
UpdateGamemode();
|
||||
if (core.gamemode != 2) return;
|
||||
core.curWave = GetCurWave();
|
||||
PerformWaveSetup();
|
||||
float hwn = GetRandomFloat(core.HWNMin, core.HWNMax);
|
||||
CreateTimer(hwn, HWBosses);
|
||||
GlobalAudio.setBGM(29, true);
|
||||
PrintToChatAll("index 29 should be sound\\fartsy\\music\\wavenull_intro.mp3, waves should be timed so that the music changes right at the end of this intro.");
|
||||
return;
|
||||
}
|
||||
case 42690:{
|
||||
BossHandler.bossID = 69;
|
||||
BossHandler.shouldTick = true;
|
||||
|
Reference in New Issue
Block a user