Plugins: Added hooks for InitEnts and cleaned up some plugins that would benefit from it.
This commit is contained in:
parent
431c6131f5
commit
f1954cdb33
8 changed files with 76 additions and 23 deletions
|
@ -1,5 +1,3 @@
|
|||
CC=fteqcc
|
||||
|
||||
all:
|
||||
make menu
|
||||
make games
|
||||
|
@ -31,6 +29,5 @@ mods:
|
|||
cd client/hunger && $(MAKE)
|
||||
cd server/hunger && $(MAKE)
|
||||
|
||||
|
||||
plugins:
|
||||
$(CC) plugins/chatsounds.src
|
||||
cd plugins && $(MAKE)
|
||||
|
|
6
src/plugins/Makefile
Normal file
6
src/plugins/Makefile
Normal file
|
@ -0,0 +1,6 @@
|
|||
CC=fteqcc
|
||||
|
||||
all:
|
||||
$(CC) chatsounds.src
|
||||
$(CC) connectsounds.src
|
||||
$(CC) voxannouncer.src
|
|
@ -33,10 +33,6 @@ ChatPlay(int id)
|
|||
{
|
||||
int r, count, flags;
|
||||
|
||||
if (!emitter) {
|
||||
emitter = spawn();
|
||||
}
|
||||
|
||||
count = tokenizebyseparator(g_table[id].sample, ";");
|
||||
r = random(0, count);
|
||||
flags = SOUNDFLAG_NOREVERB; /* this should be enough for now */
|
||||
|
@ -85,11 +81,11 @@ FMX_Init(void)
|
|||
filestream chatfile;
|
||||
searchhandle list;
|
||||
|
||||
/*list = search_begin("plugins/chatsounds/*.txt", TRUE, TRUE);
|
||||
list = search_begin("plugins/chatsounds/*.txt", TRUE, TRUE);
|
||||
for (int i = 0; i < search_getsize(list); i++) {
|
||||
print(sprintf("Found %s\n", search_getfilename(list, i)));
|
||||
}
|
||||
search_end(list);*/
|
||||
search_end(list);
|
||||
|
||||
chatfile = fopen("chatsounds.txt", FILE_READ);
|
||||
|
||||
|
@ -125,3 +121,12 @@ FMX_Init(void)
|
|||
}
|
||||
fclose(chatfile);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FMX_InitEnts(void)
|
||||
{
|
||||
if (!emitter && g_sounds > 0) {
|
||||
emitter = spawn();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,13 +20,7 @@ int
|
|||
FMX_PlayerConnect(entity cl)
|
||||
{
|
||||
string strIP;
|
||||
|
||||
if (!g_cnspk) {
|
||||
g_cnspk = spawn();
|
||||
}
|
||||
|
||||
sound(g_cnspk, CHAN_VOICE, "sound/buttons/bell1.wav", 1.0f, ATTN_NONE);
|
||||
|
||||
strIP = infokey(cl, INFOKEY_P_IP);
|
||||
bprint(PRINT_CHAT, sprintf("%s joined (%s)\n", cl.netname, strIP));
|
||||
return TRUE;
|
||||
|
@ -36,13 +30,7 @@ int
|
|||
FMX_PlayerDisconnect(entity cl)
|
||||
{
|
||||
string strIP;
|
||||
|
||||
if (!g_cnspk) {
|
||||
g_cnspk = spawn();
|
||||
}
|
||||
|
||||
sound(g_cnspk, CHAN_VOICE, "sound/buttons/blip1.wav", 1.0f, ATTN_NONE);
|
||||
|
||||
strIP = infokey(cl, INFOKEY_P_IP);
|
||||
bprint(PRINT_CHAT, sprintf("%s left (%s)\n", cl.netname, strIP));
|
||||
return TRUE;
|
||||
|
@ -54,3 +42,12 @@ FMX_Init(void)
|
|||
precache_sound("sound/buttons/blip1.wav");
|
||||
precache_sound("sound/buttons/bell1.wav");
|
||||
}
|
||||
|
||||
void
|
||||
FMX_InitEnts(void)
|
||||
{
|
||||
if (!g_cnspk) {
|
||||
g_cnspk = spawn();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ VoxFunc(string strMessage)
|
|||
|
||||
void
|
||||
FMX_PlayerObituary(entity attk, entity targ, int weapon, int body, int dmg)
|
||||
|
||||
{
|
||||
/* silly announcer */
|
||||
if (attk != world && attk != targ) {
|
||||
int r = floor(random(0,18));
|
||||
|
|
|
@ -76,13 +76,57 @@ Plugin_Init(void)
|
|||
print(sprintf("^1Plugins^7: Initialized %i plugins\n", g_plugincount));
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Plugin_Shutdown
|
||||
|
||||
Allows every plugin to properly free and unallocate whatever it is they've done
|
||||
=================
|
||||
*/
|
||||
void
|
||||
Plugin_Shutdown(void)
|
||||
{
|
||||
void(void) vFunc;
|
||||
|
||||
if (g_plugincount <= 0)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < g_plugincount; i++) {
|
||||
vFunc = externvalue(g_plugindb[i].m_flProgsID, "FMX_Shutdown");
|
||||
|
||||
if (vFunc) {
|
||||
vFunc();
|
||||
}
|
||||
}
|
||||
|
||||
memfree(g_plugindb);
|
||||
g_plugincount = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Plugin_InitEnts
|
||||
|
||||
Called once entity slots are available for use.
|
||||
=================
|
||||
*/
|
||||
void
|
||||
Plugin_InitEnts(void)
|
||||
{
|
||||
void(void) vFunc;
|
||||
|
||||
if (g_plugins_enabled == 0)
|
||||
return FALSE;
|
||||
|
||||
for (int i = 0; i < g_plugincount; i++) {
|
||||
vFunc = externvalue(g_plugindb[i].m_flProgsID, "FMX_InitEnts");
|
||||
|
||||
if (vFunc) {
|
||||
vFunc();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Plugin_RunClientCommand
|
||||
|
|
|
@ -19,6 +19,8 @@ var int autocvar_sv_plugins = 1;
|
|||
|
||||
void Plugin_Init(void);
|
||||
void Plugin_Shutdown(void);
|
||||
|
||||
void Plugin_InitEnts(void);
|
||||
int Plugin_RunClientCommand(void);
|
||||
int Plugin_ParseClientCommand(string);
|
||||
int Plugin_PlayerConnect(entity);
|
||||
|
|
|
@ -595,6 +595,8 @@ void monster_scientist::Death(int iHitBody)
|
|||
if (g_dmg_eAttacker.flags & FL_CLIENT)
|
||||
rules.ScientistKill((player)g_dmg_eAttacker, (entity)this);
|
||||
|
||||
Plugin_PlayerObituary(g_dmg_eAttacker, this, g_dmg_iWeapon, g_dmg_iHitBody, g_dmg_iDamage);
|
||||
|
||||
int r;
|
||||
r = floor(random(0,sci_snddie.length));
|
||||
Speak(sci_snddie[r]);
|
||||
|
|
Loading…
Reference in a new issue