adding custom kill messages support
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@6215 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
// kill messages
|
||||
|
||||
// sets frag and gib messages
|
||||
// they will appear on the HUD (client) and in the logs (server)
|
||||
// e.g. fragmessage 2 "picked off" => set "picked off" as carbine's kill message :
|
||||
// you picked off unarmed
|
||||
|
||||
// WARNING : since this file is used by both client and server
|
||||
// you can't use cubescript here.
|
||||
// But if you really need to, you can use separate files
|
||||
// using -E switch to set another kill messages file in your server command line
|
||||
|
||||
fragmessage 0 busted // pistol
|
||||
fragmessage 2 "picked off" // carbine
|
||||
fragmessage 3 peppered // shotgun
|
||||
fragmessage 4 sprayed // smg
|
||||
fragmessage 5 punctured // sniper
|
||||
fragmessage 6 shredded // assault rifle
|
||||
fragmessage 7 busted // cpistol
|
||||
fragmessage 9 busted // akimbo
|
||||
gibmessage 0 slashed // knife
|
||||
gibmessage 3 splattered // shotgun gib
|
||||
gibmessage 5 headshot // sniper gib
|
||||
gibmessage 8 gibbed // nade gib
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
// -X // server passwords file, default config/serverpwd.cfg
|
||||
// -B // server IP blacklist file, default config/serverblacklist.cfg
|
||||
// -K // server nickname blacklist file, default config/nicknameblacklist.cfg
|
||||
// -E // server kill messages file, default config/killmessages.cfg
|
||||
// -P // voting permission string (read docs/commandline.html)
|
||||
// k kick players
|
||||
// b ban players (and remove bans)
|
||||
|
||||
+42
-85
@@ -341,15 +341,6 @@
|
||||
</arguments>
|
||||
<return token="R" description="The random value" valueNotes="larger or equal 0 and smaller than A"/>
|
||||
</command>
|
||||
|
||||
<command name="rrnd">
|
||||
<description>Ranged random value</description>
|
||||
<arguments>
|
||||
<argument token="A" description="the lowest value to return" valueNotes=""/>
|
||||
<argument token="B" description="the upper limit of the random value" valueNotes=""/>
|
||||
</arguments>
|
||||
<return token="R" description="The random value" valueNotes="larger or equal to A and smaller than B"/>
|
||||
</command>
|
||||
|
||||
<command name="strcmp">
|
||||
<description>Determines if two strings are equal.</description>
|
||||
@@ -1945,42 +1936,10 @@ bind PRINT [ if (strcmp $last_server "") [ remember_server ]
|
||||
<remarks>
|
||||
<remark>You won't see any further game chat or hear any more voice com messages from that player.</remark>
|
||||
</remarks>
|
||||
<references>
|
||||
<identifierReference identifier="clearignored"/>
|
||||
<identifierReference identifier="listignored"/>
|
||||
<identifierReference identifier="ignoreall"/>
|
||||
<identifierReference identifier="unignoreall"/>
|
||||
</references>
|
||||
</command>
|
||||
|
||||
<command name="ignoreall">
|
||||
<description>Ignores all players currently on the server.</description>
|
||||
<references>
|
||||
<identifierReference identifier="ignore"/>
|
||||
<identifierReference identifier="clearignored"/>
|
||||
<identifierReference identifier="listignored"/>
|
||||
<identifierReference identifier="unignoreall"/>
|
||||
</references>
|
||||
</command>
|
||||
|
||||
<command name="unignoreall">
|
||||
<description>Un-ignores all players currently on the server.</description>
|
||||
<references>
|
||||
<identifierReference identifier="ignore"/>
|
||||
<identifierReference identifier="clearignored"/>
|
||||
<identifierReference identifier="listignored"/>
|
||||
<identifierReference identifier="ignoreall"/>
|
||||
</references>
|
||||
</command>
|
||||
|
||||
<command name="listignored">
|
||||
<description>Print a list of all players that you are currently ignoring.</description>
|
||||
<references>
|
||||
<identifierReference identifier="ignore"/>
|
||||
<identifierReference identifier="clearignored"/>
|
||||
<identifierReference identifier="ignoreall"/>
|
||||
<identifierReference identifier="unignoreall"/>
|
||||
</references>
|
||||
</command>
|
||||
|
||||
<command name="clearignored">
|
||||
@@ -2777,18 +2736,18 @@ Output:
|
||||
</remarks>
|
||||
</command>
|
||||
|
||||
<command name="countwalls">
|
||||
<description>Returns the number of solid walls contained into the current selection.</description>
|
||||
<arguments>
|
||||
<argument token="T" description="the integer of type of the walls you want to count" valueNotes=" 0 (solid), 1 (corner), 2 (floor heightfield), 3 (ceil heightfield), 4 (empty cube), 5 (semi solid)" />
|
||||
</arguments>
|
||||
<examples>
|
||||
<example>
|
||||
<code><![CDATA[echo (concat "The selection contains " (countwalls 0) "solid wall(s)")]]></code>
|
||||
<explanation>Output: The selection contains 3 solid wall(s)</explanation>
|
||||
</example>
|
||||
</examples>
|
||||
</command>
|
||||
<command name="countwalls">
|
||||
<description>Returns the number of solid walls contained into the current selection.</description>
|
||||
<arguments>
|
||||
<argument token="T" description="the integer of type of the walls you want to count" valueNotes=" 0 (solid), 1 (corner), 2 (floor heightfield), 3 (ceil heightfield), 4 (empty cube), 5 (semi solid)" />
|
||||
</arguments>
|
||||
<examples>
|
||||
<example>
|
||||
<code><![CDATA[echo (concat "The selection contains " (countwalls 0) "solid wall(s)")]]></code>
|
||||
<explanation>Output: The selection contains 3 solid wall(s)</explanation>
|
||||
</example>
|
||||
</examples>
|
||||
</command>
|
||||
|
||||
<command name="pasteent">
|
||||
<description>Pastes a previously copied entity.</description>
|
||||
@@ -3405,37 +3364,6 @@ Output:
|
||||
<command name="checkmapdependencies">
|
||||
<description>Find what media the map depends on, this is used for mediapack providers.</description>
|
||||
</command>
|
||||
|
||||
<command name="genhex">
|
||||
<description>Randomly generates a valid hexadecimal color value.</description>
|
||||
<examples>
|
||||
<example>
|
||||
<code><![CDATA[fogcolour (genhex)]]></code>
|
||||
<explanation>Example output: Trying hexadecimal color: 0x2FCAF1</explanation>
|
||||
</example>
|
||||
</examples>
|
||||
<references>
|
||||
<identifierReference identifier="fog"/>
|
||||
<identifierReference identifier="fogcolour"/>
|
||||
</references>
|
||||
</command>
|
||||
|
||||
<command name="genwc">
|
||||
<description>Randomly generates a valid watercolour value.</description>
|
||||
<examples>
|
||||
<example>
|
||||
<code><![CDATA[genwc]]></code>
|
||||
<explanation>Example output: Trying water color: 2 17 29</explanation>
|
||||
</example>
|
||||
</examples>
|
||||
<remarks>
|
||||
<remark>You must be in edit-mode for this command to function.</remark>
|
||||
</remarks>
|
||||
<references>
|
||||
<identifierReference identifier="genhex"/>
|
||||
<identifierReference identifier="watercolour"/>
|
||||
</references>
|
||||
</command>
|
||||
|
||||
</identifiers>
|
||||
</section>
|
||||
@@ -4434,6 +4362,36 @@ Output:
|
||||
<description>make dead players instantly pop out of existence, instead of falling over and sinking into the ground.</description>
|
||||
<value token="B" description="BOOL" minValue="0" maxValue="1" defaultValue="0" />
|
||||
</variable>
|
||||
|
||||
<command name="fragmessage">
|
||||
<description>set the frag message corresponding to a weapon (appearing on the hud or in server logs)</description>
|
||||
<arguments>
|
||||
<argument token="G" description="the integer of the gun" valueNotes=" 0 = knife, etc." />
|
||||
<argument token="M" description="the message you want to appear" valueNotes="ex : subgunned" />
|
||||
</arguments>
|
||||
<examples>
|
||||
<example>
|
||||
<code>fragmessage 5 sniped // set "sniped" message for frags with sniper. </code>
|
||||
<explanation>
|
||||
It will display "you sniped unarmed" on the hud when you frag unarmed with sniper.
|
||||
In server logs you will get "[127.0.0.1] killer subgunned unarmed".</explanation>
|
||||
</example>
|
||||
</examples>
|
||||
<remarks>
|
||||
<remark>
|
||||
This command can be read by both client and server, but the server can't read the cfg if it contains anything else than fragmessage or gibmessage calls.
|
||||
</remark>
|
||||
</remarks>
|
||||
</command>
|
||||
|
||||
<command name="gibmessage">
|
||||
<description>set the gib message corresponding to a weapon (appearing on the hud or in server logs)</description>
|
||||
<remarks>
|
||||
<remark>
|
||||
This command is identical to fragmessage (above)
|
||||
</remark>
|
||||
</remarks>
|
||||
</command>
|
||||
|
||||
<variable name="maploaditemlength">
|
||||
<description>change at what position to truncate the map title string</description>
|
||||
@@ -5493,7 +5451,6 @@ Output:
|
||||
<description>Sets the fog and clearing colour.</description>
|
||||
<references>
|
||||
<identifierReference identifier="fog"/>
|
||||
<identifierReference identifier="genhex"/>
|
||||
</references>
|
||||
<arguments>
|
||||
<argument token="C" description="The colour" valueNotes="Hexadecimal colour, default is 0x8099B3"/>
|
||||
|
||||
@@ -695,6 +695,41 @@ void dodamage(int damage, playerent *pl, playerent *actor, int gun, bool gib, bo
|
||||
else audiomgr.playsound(S_PAIN1+rnd(5), pl);
|
||||
}
|
||||
|
||||
void setkillmessage(int gun, bool gib, const char *message)
|
||||
{
|
||||
if(gun < 0 || gun >= NUMGUNS)
|
||||
{
|
||||
conoutf("invalid gun specified");
|
||||
return;
|
||||
}
|
||||
if(strlen(message)==0)
|
||||
{
|
||||
conoutf("invalid message");
|
||||
return;
|
||||
}
|
||||
if(strlen(message)>MAXKILLMSGLEN)
|
||||
{
|
||||
conoutf("message is too long (max len is %i)", MAXKILLMSGLEN);
|
||||
return;
|
||||
}
|
||||
|
||||
if(gib) formatstring(gibmessages[gun])("%s", message);
|
||||
else formatstring(fragmessages[gun])("%s", message);
|
||||
}
|
||||
|
||||
void fragmessage(const char *gun, const char *message)
|
||||
{
|
||||
setkillmessage(atoi(gun), false, message);
|
||||
}
|
||||
|
||||
void gibmessage(const char *gun, const char *message)
|
||||
{
|
||||
setkillmessage(atoi(gun), true, message);
|
||||
}
|
||||
|
||||
COMMAND(fragmessage, ARG_2STR);
|
||||
COMMAND(gibmessage, ARG_2STR);
|
||||
|
||||
void dokill(playerent *pl, playerent *act, bool gib, int gun)
|
||||
{
|
||||
if(pl->state!=CS_ALIVE || intermission) return;
|
||||
@@ -702,7 +737,8 @@ void dokill(playerent *pl, playerent *act, bool gib, int gun)
|
||||
string pname, aname, death;
|
||||
copystring(pname, pl==player1 ? "you" : colorname(pl));
|
||||
copystring(aname, act==player1 ? "you" : colorname(act));
|
||||
copystring(death, gib ? gib_message(gun) : "fragged");
|
||||
copystring(death, killmessage(gun, gib));
|
||||
copystring(death, killmessage(gun, gib));
|
||||
void (*outf)(const char *s, ...) = (pl == player1 || act == player1) ? hudoutf : conoutf;
|
||||
|
||||
if(pl==act)
|
||||
|
||||
+7
-1
@@ -614,6 +614,12 @@ public:
|
||||
enum {MD_FRAGS = 0, MD_DEATHS, END_MDS};
|
||||
struct medalsst {bool assigned; int cn; int item;};
|
||||
|
||||
#define MAXKILLMSGLEN 16
|
||||
extern char fragmessages[NUMGUNS][MAXKILLMSGLEN];
|
||||
extern char gibmessages[NUMGUNS][MAXKILLMSGLEN];
|
||||
extern inline char *killmessage(int gun, bool gib);
|
||||
|
||||
// deprecated ?!
|
||||
inline const char * gib_message(int gun)
|
||||
{
|
||||
switch (gun)
|
||||
@@ -624,4 +630,4 @@ inline const char * gib_message(int gun)
|
||||
case GUN_GRENADE:
|
||||
default: return "gibbed";
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-3
@@ -851,7 +851,7 @@ struct serverconfigfile
|
||||
struct servercommandline
|
||||
{
|
||||
int uprate, serverport, syslogfacility, filethres, syslogthres, maxdemos, maxclients, kickthreshold, banthreshold, verbose, incoming_limit, afk_limit, ban_time, demotimelocal;
|
||||
const char *ip, *master, *logident, *serverpassword, *adminpasswd, *demopath, *maprot, *pwdfile, *blfile, *nbfile, *infopath, *motdpath, *forbidden, *demofilenameformat, *demotimestampformat;
|
||||
const char *ip, *master, *logident, *serverpassword, *adminpasswd, *demopath, *maprot, *pwdfile, *blfile, *nbfile, *infopath, *motdpath, *forbidden, *killmessages, *demofilenameformat, *demotimestampformat;
|
||||
bool logtimestamp, demo_interm;
|
||||
string motd, servdesc_full, servdesc_pre, servdesc_suf, voteperm, mapperm;
|
||||
int clfilenesting;
|
||||
@@ -861,7 +861,7 @@ struct servercommandline
|
||||
maxclients(DEFAULTCLIENTS), kickthreshold(-5), banthreshold(-6), verbose(0), incoming_limit(10), afk_limit(45000), ban_time(20*60*1000), demotimelocal(0),
|
||||
ip(""), master(NULL), logident(""), serverpassword(""), adminpasswd(""), demopath(""),
|
||||
maprot("config/maprot.cfg"), pwdfile("config/serverpwd.cfg"), blfile("config/serverblacklist.cfg"), nbfile("config/nicknameblacklist.cfg"),
|
||||
infopath("config/serverinfo"), motdpath("config/motd"), forbidden("config/forbidden.cfg"),
|
||||
infopath("config/serverinfo"), motdpath("config/motd"), forbidden("config/forbidden.cfg"), killmessages("config/killmessages.cfg"),
|
||||
logtimestamp(false), demo_interm(false),
|
||||
clfilenesting(0)
|
||||
{
|
||||
@@ -878,7 +878,7 @@ struct servercommandline
|
||||
int ai = atoi(a);
|
||||
// client: dtwhzbsave
|
||||
switch(arg[1])
|
||||
{ // todo: gjlqEGHJQUYZ
|
||||
{ // todo: gjlqGHJQUYZ
|
||||
case '-':
|
||||
if(!strncmp(arg, "--demofilenameformat=", 21))
|
||||
{
|
||||
@@ -942,6 +942,7 @@ struct servercommandline
|
||||
case 'X': pwdfile = a; break;
|
||||
case 'B': blfile = a; break;
|
||||
case 'K': nbfile = a; break;
|
||||
case 'E': killmessages = a; break;
|
||||
case 'I': infopath = a; break;
|
||||
case 'o': filterrichtext(motd, a); break;
|
||||
case 'O': motdpath = a; break;
|
||||
|
||||
@@ -19,6 +19,7 @@ servernickblacklist nickblacklist;
|
||||
serverforbiddenlist forbiddenlist;
|
||||
serverpasswords passwords;
|
||||
serverinfofile infofiles;
|
||||
killmessagesfile killmessages;
|
||||
|
||||
// server state
|
||||
bool isdedicated = false;
|
||||
@@ -1461,7 +1462,7 @@ void serverdamage(client *target, client *actor, int damage, int gun, bool gib,
|
||||
target->position.setsize(0);
|
||||
ts.state = CS_DEAD;
|
||||
ts.lastdeath = gamemillis;
|
||||
if(!suic) logline(ACLOG_INFO, "[%s] %s %s%s %s", actor->hostname, actor->name, gib ? gib_message(gun) : "fragged", tk ? " their teammate" : "", target->name);
|
||||
if(!suic) logline(ACLOG_INFO, "[%s] %s %s%s %s", actor->hostname, actor->name, killmessage(gun), tk ? " their teammate" : "", target->name);
|
||||
if(m_flags && targethasflag >= 0)
|
||||
{
|
||||
if(m_ctf)
|
||||
@@ -3560,6 +3561,7 @@ void rereadcfgs(void)
|
||||
nickblacklist.read();
|
||||
forbiddenlist.read();
|
||||
passwords.read();
|
||||
killmessages.read();
|
||||
}
|
||||
|
||||
void loggamestatus(const char *reason)
|
||||
@@ -4069,6 +4071,7 @@ void initserver(bool dedicated, int argc, char **argv)
|
||||
ipblacklist.init(scl.blfile);
|
||||
nickblacklist.init(scl.nbfile);
|
||||
forbiddenlist.init(scl.forbidden);
|
||||
killmessages.init(scl.killmessages);
|
||||
infofiles.init(scl.infopath, scl.motdpath);
|
||||
infofiles.getinfo("en"); // cache 'en' serverinfo
|
||||
logline(ACLOG_VERBOSE, "holding up to %d recorded demos in memory", scl.maxdemos);
|
||||
|
||||
@@ -495,3 +495,13 @@ guninfo guns[NUMGUNS] =
|
||||
const char *teamnames[TEAM_NUM+1] = {"CLA", "RVSF", "CLA-SPECT", "RVSF-SPECT", "SPECTATOR", "void"};
|
||||
const char *teamnames_s[TEAM_NUM+1] = {"CLA", "RVSF", "CSPC", "RSPC", "SPEC", "void"};
|
||||
|
||||
// for both client and server
|
||||
// default messages are hardcoded ! (in case there's a problem with cfgs)
|
||||
char fragmessages[NUMGUNS][MAXKILLMSGLEN] = { "", "busted", "shredded", "peppered", "sprayed", "punctured", "picked off", "busted", "", "busted" };
|
||||
char gibmessages[NUMGUNS][MAXKILLMSGLEN] = { "slashed", "", "", "splattered", "", "headshot", "", "", "gibbed", "" };
|
||||
|
||||
inline char *killmessage(int gun, bool gib = false)
|
||||
{
|
||||
if(gib) return gibmessages[gun];
|
||||
else return fragmessages[gun];
|
||||
}
|
||||
@@ -887,3 +887,85 @@ struct serverinfofile
|
||||
return getinfocache(motdbase, "en");
|
||||
}
|
||||
};
|
||||
|
||||
struct killmessagesfile : serverconfigfile
|
||||
{
|
||||
void init(const char *name) { serverconfigfile::init(name); }
|
||||
void read()
|
||||
{
|
||||
if(getfilesize(filename) == filelen) return;
|
||||
if(!load()) return;
|
||||
|
||||
char *l, *s, *p = buf;
|
||||
const char *sep = " \"";
|
||||
int line = 0;
|
||||
logline(ACLOG_VERBOSE,"reading kill messages file '%s'", filename);
|
||||
while(p < buf + filelen)
|
||||
{
|
||||
l = p; p += strlen(p) + 1;
|
||||
l = strtok(l, sep);
|
||||
|
||||
|
||||
char *message = "";
|
||||
if(l)
|
||||
{
|
||||
s = strtok(NULL, sep);
|
||||
if(s && (!strcmp(l, "fragmessage") || !strcmp(l, "gibmessage")))
|
||||
{
|
||||
int errors = 0;
|
||||
int gun = atoi(s);
|
||||
|
||||
s += strlen(s) + 1;
|
||||
while(s[0] == ' ') s++;
|
||||
int hasquotes = strspn(s, "\"");
|
||||
s += hasquotes;
|
||||
message = s;
|
||||
// TODO : what's following is too much complicated for nothing.
|
||||
// it has to remove ending char (space, or quote if there was a first quote)
|
||||
char endingchar = ' ';
|
||||
char *end;
|
||||
|
||||
if(hasquotes) endingchar = '"';
|
||||
|
||||
end = strchr(message, endingchar);
|
||||
|
||||
if(end) message[end-message] = '\0';
|
||||
else
|
||||
{
|
||||
if(hasquotes)
|
||||
{
|
||||
logline(ACLOG_INFO, " error in line %i, ending quote missing (%s)", line, message);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
|
||||
if(gun < 0 || gun >= NUMGUNS)
|
||||
{
|
||||
logline(ACLOG_INFO, " error in line %i, invalid gun : %i", line, gun);
|
||||
errors++;
|
||||
}
|
||||
if(strlen(message)>MAXKILLMSGLEN)
|
||||
{
|
||||
logline(ACLOG_INFO, " error in line %i, too long message : string length is %i, max allowed i %i", line, strlen(message), MAXKILLMSGLEN);
|
||||
errors++;
|
||||
}
|
||||
if(!errors)
|
||||
{
|
||||
if(!strcmp(l, "fragmessage"))
|
||||
{
|
||||
formatstring(fragmessages[gun])("%s", message);
|
||||
logline(ACLOG_VERBOSE, " added msg '%s' for frags with weapon %i ", message, gun);
|
||||
}
|
||||
else
|
||||
{
|
||||
formatstring(gibmessages[gun])("%s", message);
|
||||
logline(ACLOG_VERBOSE, " added msg '%s' for gibs with weapon %i ", message, gun);
|
||||
}
|
||||
}
|
||||
s = NULL;
|
||||
line++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user