From 904edb259442f952dc0ad35a782495168013088f Mon Sep 17 00:00:00 2001 From: Greyscale Date: Fri, 21 Aug 2009 12:47:32 -0700 Subject: [PATCH] Added the core of the modifying alltalk feature. WARNING: Untested (but compiles), the cvars to disable it have no effect, and it may be incomplete depending on some questions I have. --- src/zr/cvars.inc | 6 +++ src/zr/event.inc | 8 ++-- src/zr/infect.inc | 3 ++ src/zr/soundeffects/soundeffects.inc | 16 ++++++- src/zr/{ => soundeffects}/voice.inc | 70 ++++++++++++++++++++++++++++ 5 files changed, 98 insertions(+), 5 deletions(-) rename src/zr/{ => soundeffects}/voice.inc (51%) diff --git a/src/zr/cvars.inc b/src/zr/cvars.inc index ac2ea5f..48fb863 100644 --- a/src/zr/cvars.inc +++ b/src/zr/cvars.inc @@ -118,6 +118,8 @@ enum CvarsList Handle:CVAR_VEFFECTS_RAGDOLL_REMOVE, Handle:CVAR_VEFFECTS_RAGDOLL_DISSOLVE, Handle:CVAR_VEFFECTS_RAGDOLL_DELAY, + Handle:CVAR_VOICE, + Handle:CVAR_VOICE_ZOMBIES_MUTE, Handle:CVAR_SEFFECTS_MOAN, Handle:CVAR_SEFFECTS_GROAN, Handle:CVAR_SEFFECTS_DEATH, @@ -376,6 +378,10 @@ CvarsCreate() // Sound Effects (module) // =========================== + // Voice + g_hCvarsList[CVAR_VOICE] = CreateConVar("zr_voice", "1", "Modify sv_alltalk to obey zombie/human teams instead of t/ct."); + g_hCvarsList[CVAR_VOICE_ZOMBIES_MUTE] = CreateConVar("zr_voice_zombies_mute", "0", "Only allow humans to communicate, block verbal zombie communication."); + // Zombie Sounds g_hCvarsList[CVAR_SEFFECTS_MOAN] = CreateConVar("zr_seffects_moan", "30.0", "Time between emission of a moan sound from a zombie."); g_hCvarsList[CVAR_SEFFECTS_GROAN] = CreateConVar("zr_seffects_groan", "5", "The probability that a groan sound will be emitted from a zombie when shot. ['100' = 1% chance | '50' = 2% chance | '1' = 100% chance]"); diff --git a/src/zr/event.inc b/src/zr/event.inc index 2c72c56..8e38db6 100644 --- a/src/zr/event.inc +++ b/src/zr/event.inc @@ -91,7 +91,7 @@ public Action:EventRoundStart(Handle:event, const String:name[], bool:dontBroadc VolOnRoundStart(); // Fire post round_start event. - CreateTimer(0.0, EventRoundStartPost); + //CreateTimer(0.0, EventRoundStartPost); } /** @@ -102,10 +102,10 @@ public Action:EventRoundStart(Handle:event, const String:name[], bool:dontBroadc * @param name Name of the event. * @dontBroadcast If true, event is broadcasted to all clients, false if not. */ -public Action:EventRoundStartPost(Handle:timer) -{ +//public Action:EventRoundStartPost(Handle:timer) +//{ // Forward event to modules. -} +//} /** * Event callback (round_freeze_end) diff --git a/src/zr/infect.inc b/src/zr/infect.inc index 4096877..b4db2f4 100644 --- a/src/zr/infect.inc +++ b/src/zr/infect.inc @@ -723,6 +723,9 @@ InfectZombieToHuman(client, bool:respawn = false, bool:protect = false) { SpawnProtectStart(client); } + + // Forward event to modules. + SEffectsOnClientHuman(client); } /** diff --git a/src/zr/soundeffects/soundeffects.inc b/src/zr/soundeffects/soundeffects.inc index 53c4ec5..14f8da0 100644 --- a/src/zr/soundeffects/soundeffects.inc +++ b/src/zr/soundeffects/soundeffects.inc @@ -35,6 +35,7 @@ */ #define SOUND_AMBIENT_CHANNEL 8 +#include "zr/soundeffects/voice" #include "zr/soundeffects/ambientsounds" #include "zr/soundeffects/zombiesounds" @@ -94,6 +95,7 @@ SEffectsOnRoundEnd() SEffectsOnClientSpawn(client) { // Forward event to sub-modules. + VoiceOnClientSpawn(client); ZombieSoundsOnClientSpawn(client); } @@ -138,9 +140,21 @@ SEffectsOnClientHurt(client) SEffectsOnClientInfected(client) { // Forward event to sub-modules. + VoiceOnClientInfected(client); ZombieSoundsOnClientInfected(client); } - + +/** + * Client has been turned back human. + * + * @param client The client index. + */ +SEffectsOnClientHuman(client) +{ + // Forward event to sub-modules. + VoiceOnClientHuman(client); +} + /** * Emits an ambient sound * diff --git a/src/zr/voice.inc b/src/zr/soundeffects/voice.inc similarity index 51% rename from src/zr/voice.inc rename to src/zr/soundeffects/voice.inc index 2d030cf..37e684c 100644 --- a/src/zr/voice.inc +++ b/src/zr/soundeffects/voice.inc @@ -25,6 +25,39 @@ * ============================================================================ */ +/** + * Client is spawning into the game. + * + * @param client The client index. + */ +VoiceOnClientSpawn(client) +{ + // Give client proper verbal permissions. + VoiceUpdateClient(client); +} + +/** + * Client has been infected. + * + * @param client The client index. + */ +VoiceOnClientInfected(client) +{ + // Give client proper verbal permissions. + VoiceUpdateClient(client); +} + +/** + * Client has been turned back human. + * + * @param client The client index. + */ +VoiceOnClientHuman(client) +{ + // Give client proper verbal permissions. + VoiceUpdateClient(client); +} + /** * Allow all clients to listen and speak with each other. */ @@ -58,4 +91,41 @@ stock VoiceAllTalk() SetClientListening(x, y, true); } } +} + +/** + * Set which team the client is allowed to listen/speak with. + * + * @param client The client index. + * @param zombie True to permit verbal communication to zombies only, false for humans only. + */ +stock VoiceSetClientTeam(client, bool:zombie) +{ + // x = Client index. + for (new x = 1; x <= MaxClients; x++) + { + // If sender isn't in-game, then stop. + if (!IsClientInGame(x)) + { + continue; + } + + // Client can only listen/speak if the sender is on their team. + new bool:canlisten = (zombie == InfectIsClientInfected(x)); + + // (Dis)allow clients to listen/speak with each other. + SetClientListening(client, x, canlisten); + SetClientListening(x, client, canlisten); + } +} + +/** + * Update a client's listening/speaking status. + * + * @param client The client index. + */ +stock VoiceUpdateClient(client) +{ + // Set the client's listening/speaking status to their current team. + VoiceSetClientTeam(client, InfectIsClientInfected(client)); } \ No newline at end of file