Half-Life: Moved the silly Vox announcer for MP games into its own little plugin
This commit is contained in:
parent
0c1ba0978e
commit
a79ead4197
5 changed files with 106 additions and 41 deletions
67
src/plugins/voxannouncer.c
Normal file
67
src/plugins/voxannouncer.c
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2020 Marco Hladik <marco@icculus.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
void
|
||||
VoxFunc(string strMessage)
|
||||
{
|
||||
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
|
||||
WriteByte(MSG_MULTICAST, 27);
|
||||
WriteString(MSG_MULTICAST, strMessage);
|
||||
msg_entity = world;
|
||||
multicast([0,0,0], MULTICAST_ALL);
|
||||
}
|
||||
|
||||
void
|
||||
FMX_PlayerObituary(entity attk, entity targ, int weapon, int body, int dmg)
|
||||
{
|
||||
/* silly announcer */
|
||||
if (attk != world && attk != targ) {
|
||||
int r = rint(random(0,10));
|
||||
|
||||
switch (r) {
|
||||
case 0:
|
||||
VoxFunc("buzwarn go go go");
|
||||
break;
|
||||
case 1:
|
||||
VoxFunc("buzwarn goodbye");
|
||||
break;
|
||||
case 2:
|
||||
VoxFunc("buzwarn kill one out");
|
||||
break;
|
||||
case 3:
|
||||
VoxFunc("buzwarn woop woop");
|
||||
break;
|
||||
case 4:
|
||||
VoxFunc("buzwarn terminated");
|
||||
break;
|
||||
case 5:
|
||||
VoxFunc("buzwarn slow soldier");
|
||||
break;
|
||||
case 6:
|
||||
VoxFunc("buzwarn that is hot");
|
||||
break;
|
||||
case 7:
|
||||
VoxFunc("buzwarn great kill");
|
||||
break;
|
||||
case 8:
|
||||
VoxFunc("buzwarn good kill");
|
||||
break;
|
||||
default:
|
||||
VoxFunc("buzwarn exterminate exterminate");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
8
src/plugins/voxannouncer.src
Executable file
8
src/plugins/voxannouncer.src
Executable file
|
@ -0,0 +1,8 @@
|
|||
#pragma target fte
|
||||
#pragma PROGS_DAT "../../valve/data.pk3dir/p_voxannouncer.dat"
|
||||
#define QWSSQC
|
||||
|
||||
#includelist
|
||||
../shared/fteextensions.qc
|
||||
voxannouncer.c
|
||||
#endlist
|
|
@ -224,3 +224,28 @@ Plugin_PlayerDisconnect(entity cl)
|
|||
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=================
|
||||
Plugin_PlayerObituary
|
||||
|
||||
Deathmessage hook
|
||||
=================
|
||||
*/
|
||||
void
|
||||
Plugin_PlayerObituary(entity attk, entity targ, int weapon, int body, int dmg)
|
||||
{
|
||||
void(entity,entity,int,int,int) vFunc;
|
||||
|
||||
if (g_plugins_enabled == 0)
|
||||
return FALSE;
|
||||
|
||||
for (int i = 0; i < g_plugincount; i++) {
|
||||
vFunc = externvalue(g_plugindb[i].m_flProgsID, "FMX_PlayerObituary");
|
||||
|
||||
if (vFunc) {
|
||||
vFunc(attk, targ, weapon, body, dmg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ var int autocvar_sv_plugins = 1;
|
|||
void Plugin_Init(void);
|
||||
void Plugin_Shutdown(void);
|
||||
int Plugin_RunClientCommand(void);
|
||||
int Plugin_ParseClientCommand(string msg);
|
||||
int Plugin_PlayerConnect(entity cl);
|
||||
int Plugin_PlayerDisconnect(entity cl);
|
||||
int Plugin_ParseClientCommand(string);
|
||||
int Plugin_PlayerConnect(entity);
|
||||
int Plugin_PlayerDisconnect(entity);
|
||||
void Plugin_PlayerObituary(entity, entity, int, int, int);
|
||||
|
|
|
@ -39,6 +39,8 @@ HLMultiplayerRules::PlayerDeath(base_player pl)
|
|||
msg_entity = world;
|
||||
multicast([0,0,0], MULTICAST_ALL);
|
||||
|
||||
Plugin_PlayerObituary(g_dmg_eAttacker, g_dmg_eTarget, g_dmg_iWeapon, g_dmg_iHitBody, g_dmg_iDamage);
|
||||
|
||||
/* death-counter */
|
||||
pl.deaths++;
|
||||
forceinfokey(pl, "*deaths", ftos(pl.deaths));
|
||||
|
@ -69,44 +71,6 @@ HLMultiplayerRules::PlayerDeath(base_player pl)
|
|||
pl.nextthink = time + 4.0f;
|
||||
Sound_Play(pl, CHAN_AUTO, "player.die");
|
||||
|
||||
/* silly announcer */
|
||||
if (g_dmg_eAttacker != world && g_dmg_eAttacker != g_dmg_eTarget) {
|
||||
int r = rint(random(0,10));
|
||||
|
||||
switch (r) {
|
||||
case 0:
|
||||
Vox_Broadcast("buzwarn go go go");
|
||||
break;
|
||||
case 1:
|
||||
Vox_Broadcast("buzwarn goodbye");
|
||||
break;
|
||||
case 2:
|
||||
Vox_Broadcast("buzwarn kill one out");
|
||||
break;
|
||||
case 3:
|
||||
Vox_Broadcast("buzwarn woop woop");
|
||||
break;
|
||||
case 4:
|
||||
Vox_Broadcast("buzwarn terminated");
|
||||
break;
|
||||
case 5:
|
||||
Vox_Broadcast("buzwarn slow soldier");
|
||||
break;
|
||||
case 6:
|
||||
Vox_Broadcast("buzwarn that is hot");
|
||||
break;
|
||||
case 7:
|
||||
Vox_Broadcast("buzwarn great kill");
|
||||
break;
|
||||
case 8:
|
||||
Vox_Broadcast("buzwarn good kill");
|
||||
break;
|
||||
default:
|
||||
Vox_Broadcast("buzwarn exterminate exterminate");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pl.health < -50) {
|
||||
pl.health = 0;
|
||||
FX_GibHuman(pl.origin);
|
||||
|
|
Loading…
Reference in a new issue