return 1;
}
+vector GetHeadshotMins(entity targ)
+{
+ return '0.6 0 0' * targ.mins_x + '0 0.6 0' * targ.mins_y + '0 0 1' * (1.3 * targ.view_ofs_z - 0.3 * targ.maxs_z);
+}
+vector GetHeadshotMaxs(entity targ)
+{
+ return '0.6 0 0' * targ.maxs_x + '0 0.6 0' * targ.maxs_y + '0 0 1' * targ.maxs_z;
+}
+
void UpdateFrags(entity player, float f)
{
PlayerTeamScore_AddScore(player, f);
}
// FIXME fix the mess this is (we have REAL points now!)
+ entity oldself;
+ oldself = self;
+ self = attacker;
frag_attacker = attacker;
frag_target = targ;
frag_score = f;
if(MUTATOR_CALLHOOK(GiveFragsForKill))
{
f = frag_score;
+ self = oldself;
}
- else if(g_runematch)
- {
- f = RunematchHandleFrags(attacker, targ, f);
- }
- else if(g_lms)
+ else
{
- // remove a life
- float tl;
- tl = PlayerScore_Add(targ, SP_LMS_LIVES, -1);
- if(tl < lms_lowest_lives)
- lms_lowest_lives = tl;
- if(tl <= 0)
+ self = oldself;
+ if(g_runematch)
{
- if(!lms_next_place)
- lms_next_place = player_count;
- PlayerScore_Add(targ, SP_LMS_RANK, lms_next_place); // won't ever spawn again
- --lms_next_place;
+ f = RunematchHandleFrags(attacker, targ, f);
}
- f = 0;
- }
- else if(g_ctf)
- {
- if(g_ctf_ignore_frags)
+ else if(g_lms)
+ {
+ // remove a life
+ float tl;
+ tl = PlayerScore_Add(targ, SP_LMS_LIVES, -1);
+ if(tl < lms_lowest_lives)
+ lms_lowest_lives = tl;
+ if(tl <= 0)
+ {
+ if(!lms_next_place)
+ lms_next_place = player_count;
+ PlayerScore_Add(targ, SP_LMS_RANK, lms_next_place); // won't ever spawn again
+ --lms_next_place;
+ }
f = 0;
+ }
+ else if(g_ctf)
+ {
+ if(g_ctf_ignore_frags)
+ f = 0;
+ }
}
attacker.totalfrags += f;
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")
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) {
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");
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")
{
// if above view_ofs and below maxs, and also in the middle half of the bbox, it is head shot
vector headmins, headmaxs, org;
org = antilag_takebackorigin(targ, time - ANTILAG_LATENCY(attacker));
- headmins = org + '0.6 0 0' * targ.mins_x + '0 0.6 0' * targ.mins_y + '0 0 1' * (1.3 * targ.view_ofs_z - 0.3 * targ.maxs_z);
- headmaxs = org + '0.6 0 0' * targ.maxs_x + '0 0.6 0' * targ.maxs_y + '0 0 1' * targ.maxs_z;
+ headmins = org + GetHeadshotMins(targ);
+ headmaxs = org + GetHeadshotMaxs(targ);
if(trace_hits_box(railgun_start, railgun_end, headmins, headmaxs))
{
deathtype |= HITTYPE_HEADSHOT;