From d484a57426446e6147d045f717bb9d9fdd148c4b Mon Sep 17 00:00:00 2001 From: FruitieX Date: Sat, 5 Jun 2010 20:05:58 +0300 Subject: [PATCH 1/1] initial work on notify panel, some centerprints now will be different depending on cl_gentle :) --- qcsrc/client/Main.qc | 18 +++++++++++++++ qcsrc/client/hud.qc | 47 +++++++++++++++++++++++++++++++++++++++ qcsrc/common/constants.qh | 4 ++++ qcsrc/server/g_damage.qc | 36 ++++++++++++++++++++++++++++-- 4 files changed, 103 insertions(+), 2 deletions(-) diff --git a/qcsrc/client/Main.qc b/qcsrc/client/Main.qc index de74def181..a48c2c57c9 100644 --- a/qcsrc/client/Main.qc +++ b/qcsrc/client/Main.qc @@ -1243,6 +1243,20 @@ void Net_VoteDialogReset() { vote_active = 0; } +void Net_Notify() { + float type; + type = ReadByte(); + + if(type == CSQC_KILLNOTIFY) + { + HUD_KillNotify(ReadString(), ReadString(), ReadByte()); + } + else if(type == CSQC_CENTERPRINT) + { + HUD_Centerprint(ReadString(), ReadByte()); + } +} + // CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer. // You must ALWAYS first acquire the temporary ID, which is sent as a byte. // Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event. @@ -1309,6 +1323,10 @@ float CSQC_Parse_TempEntity() announce_snd = strzone(ReadString()); bHandled = true; break; + case TE_CSQC_NOTIFY: + Net_Notify(); + bHandled = true; + break; default: // No special logic for this temporary entity; return 0 so the engine can handle it bHandled = false; diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 4e7628f3fd..161aa30ae1 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -1979,6 +1979,51 @@ void HUD_HealthArmor(void) // ___TODO___ !!! // Notification area (#4) // + +void HUD_KillNotify(string s1, string s2, float deathtype) +{ + + +} + +#define DAMAGE_CENTERPRINT_SPACER NEWLINES + +void HUD_Centerprint(string s1, float deathtype) +{ + if (deathtype == DEATH_TEAMCHANGE) { + centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1)); + } else if (deathtype == DEATH_AUTOTEAMCHANGE) { + centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1)); + } else if (deathtype == DEATH_CAMP) { + if(cvar("cl_gentle")) + centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!")); + else + centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!")); + } else if (deathtype == DEATH_NOAMMO) { + if(cvar("cl_gentle")) + centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo...")); + else + centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo...")); + } else if (deathtype == DEATH_ROT) { + if(cvar("cl_gentle")) + centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health")); + else + centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine")); + } else if (deathtype == DEATH_MIRRORDAMAGE) { + if(cvar("cl_gentle")) + centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!")); + else + centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!")); + } else if (deathtype == DEATH_QUIET) { + // do nothing + } else { + if(cvar("cl_gentle")) + centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!")); + else + centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!")); + } +} + void HUD_Notify (void) { float id = 4; @@ -1995,6 +2040,7 @@ void HUD_Notify (void) mySize -= '2 2 0' * padding; } + /* This will come later. string s; entity tm; if(spectatee_status && !intermission) @@ -2110,6 +2156,7 @@ void HUD_Notify (void) } } } + */ } // Timer (#5) diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh index a717e4c9d8..783d2a2394 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -57,6 +57,7 @@ const float TE_CSQC_VOTE = 108; const float TE_CSQC_VOTERESET = 109; const float TE_CSQC_ANNOUNCE = 110; const float TE_CSQC_TARGET_MUSIC = 111; +const float TE_CSQC_NOTIFY = 112; const float RACE_NET_CHECKPOINT_HIT_QUALIFYING = 0; // byte checkpoint, short time, short recordtime, string recordholder const float RACE_NET_CHECKPOINT_CLEAR = 1; @@ -73,6 +74,9 @@ const float RACE_NET_SERVER_RANKINGS = 11; const float RACE_NET_SERVER_STATUS = 12; const float RANKINGS_CNT = 15; +const float CSQC_KILLNOTIFY = 0; +const float CSQC_CENTERPRINT = 1; + const float ENT_CLIENT = 0; const float ENT_CLIENT_DEAD = 1; const float ENT_CLIENT_ENTCS = 2; diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index 505b2e7688..e84106c39c 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -245,9 +245,31 @@ void LogDeath(string mode, float deathtype, entity killer, entity killed) GameLogEcho(s); } +void Send_KillNotification (string s1, string s2, float deathtype) +{ + WriteByte(MSG_ALL, SVC_TEMPENTITY); + WriteByte(MSG_ALL, TE_CSQC_NOTIFY); + WriteByte(MSG_ALL, CSQC_KILLNOTIFY); + WriteString(MSG_ALL, s1); + WriteString(MSG_ALL, s2); + WriteByte(MSG_ALL, deathtype); +} + +// TODO: writespectatable? +// Function is used to send a generic centerprint whose content CSQC gets to decide (gentle version or not in the below cases) +void Send_CSQC_Centerprint(entity e, string s1, float deathtype) +{ + msg_entity = e; + WriteByte(MSG_ONE, SVC_TEMPENTITY); + WriteByte(MSG_ONE, TE_CSQC_NOTIFY); + WriteByte(MSG_ONE, CSQC_CENTERPRINT); + WriteString(MSG_ONE, s1); + WriteByte(MSG_ONE, deathtype); +} + void Obituary (entity attacker, entity inflictor, entity targ, float deathtype) { - string s, a; + string s, a, msg; float p, w; if (targ.classname == "player" || targ.classname == "corpse") @@ -259,8 +281,11 @@ void Obituary (entity attacker, entity inflictor, entity targ, float deathtype) a = attacker.netname; - if (targ == attacker) + if (targ == attacker) // suicides { + if (deathtype == DEATH_TEAMCHANGE || deathtype == DEATH_AUTOTEAMCHANGE) + msg = ColoredTeamName(targ.team); // TODO: check if needed? + /* if (deathtype == DEATH_TEAMCHANGE) { centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", ColoredTeamName(targ.team))); } else if (deathtype == DEATH_AUTOTEAMCHANGE) { @@ -294,6 +319,11 @@ void Obituary (entity attacker, entity inflictor, entity targ, float deathtype) else centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!")); } + */ + Send_CSQC_Centerprint(targ, msg, deathtype); + + // TODO: message + /* if(sv_gentle) { if (deathtype == DEATH_CAMP) bprint ("^1",s, "^1 thought they found a nice camping ground\n"); @@ -343,6 +373,8 @@ void Obituary (entity attacker, entity inflictor, entity targ, float deathtype) if (targ.killcount > 2) bprint ("^1",s,"^1 ended it all after a ",ftos(targ.killcount)," kill spree\n"); } + */ + Send_KillNotification(s, msg, deathtype); } else if (attacker.classname == "player" || attacker.classname == "gib") { -- 2.39.2