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.

This commit is contained in:
Greyscale 2009-08-21 12:47:32 -07:00
parent 8016864474
commit 904edb2594
5 changed files with 98 additions and 5 deletions

View File

@ -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]");

View File

@ -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)

View File

@ -723,6 +723,9 @@ InfectZombieToHuman(client, bool:respawn = false, bool:protect = false)
{
SpawnProtectStart(client);
}
// Forward event to modules.
SEffectsOnClientHuman(client);
}
/**

View File

@ -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
*

View File

@ -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));
}