6 float Damage_DamageInfo_SendEntity(entity to, float sf)
\r
8 WriteByte(MSG_ENTITY, ENT_CLIENT_DAMAGEINFO);
\r
9 WriteShort(MSG_ENTITY, self.projectiledeathtype);
\r
10 WriteCoord(MSG_ENTITY, floor(self.origin_x));
\r
11 WriteCoord(MSG_ENTITY, floor(self.origin_y));
\r
12 WriteCoord(MSG_ENTITY, floor(self.origin_z));
\r
13 WriteByte(MSG_ENTITY, bound(1, self.dmg, 255));
\r
14 WriteByte(MSG_ENTITY, bound(0, self.dmg_radius, 255));
\r
15 WriteByte(MSG_ENTITY, bound(1, self.dmg_edge, 255));
\r
16 WriteShort(MSG_ENTITY, self.oldorigin_x);
\r
20 void Damage_DamageInfo(vector org, float coredamage, float edgedamage, float rad, vector force, float deathtype, entity dmgowner)
\r
22 // TODO maybe call this from non-edgedamage too?
\r
23 // TODO maybe make the client do the particle effects for the weapons and the impact sounds using this info?
\r
27 if(!sound_allowed(MSG_BROADCAST, dmgowner))
\r
28 deathtype |= 0x8000;
\r
32 e.projectiledeathtype = deathtype;
\r
34 e.dmg_edge = edgedamage;
\r
36 e.dmg_force = vlen(force);
\r
39 e.oldorigin_x = compressShortVector(e.velocity);
\r
41 Net_LinkEntity(e, FALSE, 0.2, Damage_DamageInfo_SendEntity);
\r
44 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
\r
46 float checkrules_firstblood;
\r
49 float damage_goodhits;
\r
50 float damage_gooddamage;
\r
52 float damage_headshotbonus; // bonus multiplier for head shots, set to 0 after use
\r
55 .float teamkill_complain;
\r
56 .float teamkill_soundtime;
\r
57 .entity teamkill_soundsource;
\r
59 .float taunt_soundtime;
\r
60 .float taunt_soundtype;
\r
63 float IsDifferentTeam(entity a, entity b)
\r
67 if(a.team == b.team)
\r
78 float IsFlying(entity a)
\r
80 if(a.flags & FL_ONGROUND)
\r
82 if(a.waterlevel >= WATERLEVEL_SWIMMING)
\r
84 traceline(a.origin, a.origin - '0 0 48', MOVE_NORMAL, a);
\r
85 if(trace_fraction < 1)
\r
90 void UpdateFrags(entity player, float f)
\r
92 PlayerTeamScore_AddScore(player, f);
\r
95 // NOTE: f=0 means still count as a (positive) kill, but count no frags for it
\r
96 void W_SwitchWeapon_Force(entity e, float w);
\r
97 void GiveFrags (entity attacker, entity targ, float f)
\r
99 // TODO route through PlayerScores instead
\r
100 if(gameover) return;
\r
104 if(targ == attacker)
\r
107 PlayerScore_Add(attacker, SP_SUICIDES, 1);
\r
112 PlayerScore_Add(attacker, SP_KILLS, -1); // or maybe add a teamkills field?
\r
118 PlayerScore_Add(attacker, SP_KILLS, 1);
\r
121 PlayerScore_Add(targ, SP_DEATHS, 1);
\r
123 if(g_arena || g_ca)
\r
124 if(cvar("g_arena_roundbased"))
\r
127 // FIXME fix the mess this is (we have REAL points now!)
\r
130 f = kh_HandleFrags(attacker, targ, f);
\r
136 tl = PlayerScore_Add(targ, SP_LMS_LIVES, -1);
\r
137 if(tl < lms_lowest_lives)
\r
138 lms_lowest_lives = tl;
\r
141 if(!lms_next_place)
\r
142 lms_next_place = player_count;
\r
143 PlayerScore_Add(targ, SP_LMS_RANK, lms_next_place); // won't ever spawn again
\r
150 if(g_ctf_ignore_frags)
\r
154 attacker.totalfrags += f;
\r
157 UpdateFrags(attacker, f);
\r
160 string AppendItemcodes(string s, entity player)
\r
165 // w = player.switchweapon;
\r
167 w = player.cnt; // previous weapon!
\r
168 s = strcat(s, ftos(w));
\r
169 if(time < player.strength_finished)
\r
170 s = strcat(s, "S");
\r
171 if(time < player.invincible_finished)
\r
172 s = strcat(s, "I");
\r
173 if(player.flagcarried != world)
\r
174 s = strcat(s, "F");
\r
175 if(player.BUTTON_CHAT)
\r
176 s = strcat(s, "T");
\r
178 s = strcat(s, "K");
\r
182 void LogDeath(string mode, float deathtype, entity killer, entity killed)
\r
185 if(!cvar("sv_eventlog"))
\r
187 s = strcat(":kill:", mode);
\r
188 s = strcat(s, ":", ftos(killer.playerid));
\r
189 s = strcat(s, ":", ftos(killed.playerid));
\r
190 s = strcat(s, ":type=", ftos(deathtype));
\r
191 s = strcat(s, ":items=");
\r
192 s = AppendItemcodes(s, killer);
\r
193 if(killed != killer)
\r
195 s = strcat(s, ":victimitems=");
\r
196 s = AppendItemcodes(s, killed);
\r
201 void Obituary (entity attacker, entity inflictor, entity targ, float deathtype)
\r
206 if (targ.classname == "player" || targ.classname == "corpse")
\r
208 if (targ.classname == "corpse")
\r
213 a = attacker.netname;
\r
215 if (targ == attacker)
\r
217 if (deathtype == DEATH_TEAMCHANGE) {
\r
218 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", ColoredTeamName(targ.team)));
\r
219 } else if (deathtype == DEATH_AUTOTEAMCHANGE) {
\r
220 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", ColoredTeamName(targ.team)));
\r
222 } else if (deathtype == DEATH_CAMP) {
\r
224 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
\r
226 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
\r
227 } else if (deathtype == DEATH_NOAMMO) {
\r
229 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
\r
231 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
\r
232 } else if (deathtype == DEATH_ROT) {
\r
234 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
\r
236 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
\r
237 } else if (deathtype == DEATH_MIRRORDAMAGE) {
\r
239 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
\r
241 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
\r
242 } else if (deathtype == DEATH_QUIET) {
\r
246 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
\r
248 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
\r
251 if (deathtype == DEATH_CAMP)
\r
252 bprint ("^1",s, "^1 thought they found a nice camping ground\n");
\r
253 else if (deathtype == DEATH_MIRRORDAMAGE)
\r
254 bprint ("^1",s, "^1 didn't become friends with the Lord of Teamplay\n");
\r
256 bprint ("^1",s, "^1 will be reinserted into the game due to their own actions\n");
\r
258 if(deathtype != DEATH_TEAMCHANGE && deathtype != DEATH_QUIET)
\r
260 LogDeath("suicide", deathtype, targ, targ);
\r
261 GiveFrags(attacker, targ, -1);
\r
263 if (targ.killcount > 2)
\r
264 bprint ("^1",s,"^1 faded after a ",ftos(targ.killcount)," point spree\n");
\r
266 w = DEATH_WEAPONOF(deathtype);
\r
269 w_deathtypestring = "couldn't resist the urge to self-destruct";
\r
270 w_deathtype = deathtype;
\r
271 weapon_action(w, WR_SUICIDEMESSAGE);
\r
272 bprint("^1", s, "^1 ", w_deathtypestring, "\n");
\r
274 else if (deathtype == DEATH_KILL)
\r
275 bprint ("^1",s, "^1 couldn't take it anymore\n");
\r
276 else if (deathtype == DEATH_ROT)
\r
277 bprint ("^1",s, "^1 died\n");
\r
278 else if (deathtype == DEATH_NOAMMO)
\r
279 bprint ("^7",s, "^7 committed suicide. What's the point of living without ammo?\n");
\r
280 else if (deathtype == DEATH_CAMP)
\r
281 bprint ("^1",s, "^1 thought they found a nice camping ground\n");
\r
282 else if (deathtype == DEATH_MIRRORDAMAGE)
\r
283 bprint ("^1",s, "^1 didn't become friends with the Lord of Teamplay\n");
\r
284 else if (deathtype == DEATH_CHEAT)
\r
285 bprint ("^1",s, "^1 unfairly eliminated themself\n");
\r
286 else if (deathtype == DEATH_FIRE)
\r
287 bprint ("^1",s, "^1 burned to death\n");
\r
288 else if (deathtype == DEATH_DIGESTION)
\r
289 bprint ("^1",s, "^1 was digested\n");
\r
290 else if (deathtype == DEATH_STOMACHKICK)
\r
291 bprint ("^1",s, "^1 was ripped apart from the inside\n");
\r
292 else if (deathtype != DEATH_TEAMCHANGE && deathtype != DEATH_QUIET)
\r
293 bprint ("^1",s, "^1 couldn't resist the urge to self-destruct\n");
\r
295 if(deathtype != DEATH_TEAMCHANGE && deathtype != DEATH_QUIET)
\r
297 LogDeath("suicide", deathtype, targ, targ);
\r
298 GiveFrags(attacker, targ, -1);
\r
300 if (targ.killcount > 2)
\r
301 bprint ("^1",s,"^1 ended it all after a ",ftos(targ.killcount)," kill spree\n");
\r
304 else if (attacker.classname == "player" || attacker.classname == "gib")
\r
306 if(teams_matter && attacker.team == targ.team)
\r
308 if (deathtype == DEATH_DIGESTION)
\r
311 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Furfag! You made a meal out of a team mate!"));
\r
312 bprint ("^1", a, "^1 took action against a team mate\n");
\r
314 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Furfag! You ate ", s, ", a team mate!"));
\r
315 bprint ("^1", a, "^1 mows down a team mate\n");
\r
321 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Furfag! You went against a team mate!"));
\r
322 bprint ("^1", a, "^1 took action against a team mate\n");
\r
324 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Furfag! You killed ", s, ", a team mate!"));
\r
325 bprint ("^1", a, "^1 murders a team mate\n");
\r
328 GiveFrags(attacker, targ, -1);
\r
329 if (targ.killcount > 2) {
\r
331 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," scoring spree was ended by a team mate!\n");
\r
333 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," kill spree was ended by a team mate!\n");
\r
335 if (attacker.killcount > 2) {
\r
337 bprint ("^1",a,"^1 ended a ",ftos(attacker.killcount)," scoring spree by going against a team mate\n");
\r
339 bprint ("^1",a,"^1 ended a ",ftos(attacker.killcount)," kill spree by killing a team mate\n");
\r
341 attacker.killcount = 0;
\r
343 LogDeath("tk", deathtype, attacker, targ);
\r
347 string blood_message, victim_message;
\r
348 if (!checkrules_firstblood)
\r
350 checkrules_firstblood = TRUE;
\r
353 bprint("^1",a, "^1 was the first to score", "\n");
\r
354 blood_message = "^1First point\n";
\r
355 //victim_message = "^1First victim\n"; // or First casualty
\r
359 bprint("^1",a, "^1 drew first blood", "\n");
\r
360 blood_message = "^1First blood\n";
\r
361 victim_message = "^1First victim\n"; // or First casualty
\r
364 if (deathtype == DEATH_DIGESTION)
\r
366 if(sv_gentle > 0) {
\r
367 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, blood_message, "^4You made ^7", s, GetAdvancedDeathReports(targ), " ^4your meal"));
\r
368 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, a,"^1 made you their meal ^7", GetAdvancedDeathReports(attacker)));
\r
370 if((cvar("sv_fragmessage_information_typefrag")) && (targ.BUTTON_CHAT)) {
\r
371 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, blood_message, "^1You type-ate ^7", s, GetAdvancedDeathReports(targ)));
\r
372 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, victim_message, "^1You were type-eaten by ^7", a, GetAdvancedDeathReports(attacker)));
\r
374 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, blood_message, "^4You ate ^7", s, GetAdvancedDeathReports(targ)));
\r
375 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, victim_message, "^1You were eaten by ^7", a, GetAdvancedDeathReports(attacker)));
\r
377 attacker.taunt_soundtime = time + 1;
\r
378 attacker.taunt_soundtype = TAUNTTYPE_DEATH;
\r
383 if(sv_gentle > 0) {
\r
384 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, blood_message, "^4You scored against ^7", s, GetAdvancedDeathReports(targ)));
\r
385 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, a,"^1 scored against you ^7", GetAdvancedDeathReports(attacker)));
\r
387 if((cvar("sv_fragmessage_information_typefrag")) && (targ.BUTTON_CHAT)) {
\r
388 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, blood_message, "^1You type-ate ^7", s, GetAdvancedDeathReports(targ)));
\r
389 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, victim_message, "^1You were type-eaten by ^7", a, GetAdvancedDeathReports(attacker)));
\r
391 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, blood_message, "^4You killed ^7", s, GetAdvancedDeathReports(targ)));
\r
392 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, victim_message, "^1You were killed by ^7", a, GetAdvancedDeathReports(attacker)));
\r
394 attacker.taunt_soundtime = time + 1;
\r
395 attacker.taunt_soundtype = TAUNTTYPE_DEATH;
\r
400 bprint ("^1",s, "^1 needs a restart thanks to ", a, "\n");
\r
402 w = DEATH_WEAPONOF(deathtype);
\r
405 w_deathtypestring = "was blasted by";
\r
406 w_deathtype = deathtype;
\r
407 weapon_action(w, WR_KILLMESSAGE);
\r
408 p = strstrofs(w_deathtypestring, "#", 0);
\r
410 bprint("^1", s, "^1 ", w_deathtypestring, " ", a, "\n");
\r
412 bprint("^1", s, "^1 ", substring(w_deathtypestring, 0, p), a, "^1", substring(w_deathtypestring, p+1, strlen(w_deathtypestring) - (p+1)), "\n");
\r
414 else if (deathtype == DEATH_TELEFRAG)
\r
415 bprint ("^1",s, "^1 was telefragged by ", a, "\n");
\r
416 else if (deathtype == DEATH_DROWN)
\r
417 bprint ("^1",s, "^1 was drowned by ", a, "\n");
\r
418 else if (deathtype == DEATH_SLIME)
\r
419 bprint ("^1",s, "^1 was slimed by ", a, "\n");
\r
420 else if (deathtype == DEATH_LAVA)
\r
421 bprint ("^1",s, "^1 was cooked by ", a, "\n");
\r
422 else if (deathtype == DEATH_FALL)
\r
423 bprint ("^1",s, "^1 was grounded by ", a, "\n");
\r
424 else if (deathtype == DEATH_SHOOTING_STAR)
\r
425 bprint ("^1",s, "^1 was shot into space by ", a, "\n");
\r
426 else if (deathtype == DEATH_SWAMP)
\r
427 bprint ("^1",s, "^1 was conserved by ", a, "\n");
\r
428 else if (deathtype == DEATH_HURTTRIGGER && inflictor.message2 != "")
\r
430 p = strstrofs(inflictor.message2, "#", 0);
\r
432 bprint("^1", s, "^1 ", inflictor.message2, " ", a, "\n");
\r
434 bprint("^1", s, "^1 ", substring(inflictor.message2, 0, p), a, "^1", substring(inflictor.message2, p+1, strlen(inflictor.message2) - (p+1)), "\n");
\r
436 else if(deathtype == DEATH_SBCRUSH)
\r
437 bprint ("^1",s, "^1 was crushed by ^1", a, "\n");
\r
438 else if(deathtype == DEATH_SBMINIGUN)
\r
439 bprint ("^1",s, "^1 got shredded by ^1", a, "\n");
\r
440 else if(deathtype == DEATH_SBROCKET)
\r
441 bprint ("^1",s, "^1 was blased to bits by ^1", a, "\n");
\r
442 else if(deathtype == DEATH_SBBLOWUP)
\r
443 bprint ("^1",s, "^1 got cought in the destruction of ^1", a, "'s vehicle\n");
\r
445 else if(deathtype == DEATH_WAKIGUN)
\r
446 bprint ("^1",s, "^1 was bolted down by ^1", a, "\n");
\r
447 else if(deathtype == DEATH_WAKIROCKET)
\r
448 bprint ("^1",s, "^1 could find no shelter from ^1", a, "'s rockets\n");
\r
449 else if(deathtype == DEATH_WAKIBLOWUP)
\r
450 bprint ("^1",s, "^1 dies when ^1", a, "'s wakizashi dies.\n");
\r
452 else if(deathtype == DEATH_TURRET)
\r
453 bprint ("^1",s, "^1 was pushed into the line of fire by ^1", a, "\n");
\r
454 else if(deathtype == DEATH_TOUCHEXPLODE)
\r
455 bprint ("^1",s, "^1 was pushed into an accident by ^1", a, "\n");
\r
456 else if(deathtype == DEATH_CHEAT)
\r
457 bprint ("^1",s, "^1 was unfairly eliminated by ^1", a, "\n");
\r
458 else if (deathtype == DEATH_FIRE)
\r
459 bprint ("^1",s, "^1 was burnt to death by ^1", a, "\n");
\r
460 else if (deathtype == DEATH_DIGESTION)
\r
461 bprint ("^1",s, "^1 was digested by ^1", a, "\n");
\r
462 else if (deathtype == DEATH_STOMACHKICK)
\r
463 bprint ("^1",s, "^1 was ripped apart from the inside by ^1", a, "\n");
\r
464 else if (deathtype == DEATH_CUSTOM)
\r
465 bprint ("^1",s, "^1 ", deathmessage, " by ^1", a, "\n");
\r
467 bprint ("^1",s, "^1 was fragged by ", a, "\n");
\r
470 if(g_ctf && targ.flagcarried)
\r
472 UpdateFrags(attacker, ctf_score_value("score_kill"));
\r
473 PlayerScore_Add(attacker, SP_CTF_FCKILLS, 1);
\r
474 GiveFrags(attacker, targ, 0); // for logging
\r
478 if(cvar("g_vore_reversescoring") && deathtype == DEATH_DIGESTION) // reversed vore scoring
\r
479 GiveFrags(targ, attacker, 1);
\r
481 GiveFrags(attacker, targ, 1);
\r
484 if (targ.killcount > 2) {
\r
486 bprint ("^1",s,"'s ^1", ftos(targ.killcount), " scoring spree was ended by ", a, "\n");
\r
488 bprint ("^1",s,"'s ^1", ftos(targ.killcount), " kill spree was ended by ", a, "\n");
\r
491 attacker.killcount = attacker.killcount + 1;
\r
493 if (attacker.killcount > 2) {
\r
495 bprint ("^1",a,"^1 made ",ftos(attacker.killcount)," scores in a row\n");
\r
497 bprint ("^1",a,"^1 has ",ftos(attacker.killcount)," frags in a row\n");
\r
500 LogDeath("frag", deathtype, attacker, targ);
\r
502 if (attacker.killcount == 3)
\r
505 bprint (a,"^7 made a ^1TRIPLE SCORE\n");
\r
507 bprint (a,"^7 made a ^1TRIPLE FRAG\n");
\r
508 AnnounceTo(attacker, "03kills");
\r
511 else if (attacker.killcount == 5)
\r
514 bprint (a,"^7 unleashes ^1SCORING RAGE\n");
\r
516 bprint (a,"^7 unleashes ^1RAGE\n");
\r
517 AnnounceTo(attacker, "05kills");
\r
520 else if (attacker.killcount == 10)
\r
523 bprint (a,"^7 made ^1TEN SCORES IN A ROW!\n");
\r
525 bprint (a,"^7 starts the ^1MASSACRE!\n");
\r
526 AnnounceTo(attacker, "10kills");
\r
529 else if (attacker.killcount == 15)
\r
532 bprint (a,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
\r
534 bprint (a,"^7 executes ^1MAYHEM!\n");
\r
535 AnnounceTo(attacker, "15kills");
\r
538 else if (attacker.killcount == 20)
\r
541 bprint (a,"^7 made ^1TWENTY SCORES IN A ROW!\n");
\r
543 bprint (a,"^7 is a ^1BERSERKER!\n");
\r
544 AnnounceTo(attacker, "20kills");
\r
547 else if (attacker.killcount == 25)
\r
550 bprint (a,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
\r
552 bprint (a,"^7 inflicts ^1CARNAGE!\n");
\r
553 AnnounceTo(attacker, "25kills");
\r
556 else if (attacker.killcount == 30)
\r
559 bprint (a,"^7 made ^1THIRTY SCORES IN A ROW!\n");
\r
561 bprint (a,"^7 unleashes ^1ARMAGEDDON!\n");
\r
562 AnnounceTo(attacker, "30kills");
\r
569 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
\r
570 if (deathtype == DEATH_HURTTRIGGER && inflictor.message != "")
\r
571 bprint ("^1",s, "^1 ", inflictor.message, "\n");
\r
572 else if (deathtype == DEATH_DROWN)
\r
574 bprint ("^1",s, "^1 was in the water for too long\n");
\r
576 bprint ("^1",s, "^1 drowned\n");
\r
577 else if (deathtype == DEATH_SLIME)
\r
578 bprint ("^1",s, "^1 was slimed\n");
\r
579 else if (deathtype == DEATH_LAVA)
\r
581 bprint ("^1",s, "^1 found a hot place\n");
\r
583 bprint ("^1",s, "^1 turned into hot slag\n");
\r
584 else if (deathtype == DEATH_FALL)
\r
586 bprint ("^1",s, "^1 tested gravity (and it worked)\n");
\r
588 bprint ("^1",s, "^1 hit the ground with a crunch\n");
\r
589 else if (deathtype == DEATH_SHOOTING_STAR)
\r
590 bprint ("^1",s, "^1 became a shooting star\n");
\r
591 else if (deathtype == DEATH_SWAMP)
\r
593 bprint ("^1",s, "^1 discovered a swamp\n");
\r
595 bprint ("^1",s, "^1 is now conserved for centuries to come\n");
\r
596 else if(deathtype == DEATH_TURRET)
\r
597 bprint ("^1",s, "^1 was mowed down by a turret \n");
\r
598 else if (deathtype == DEATH_CUSTOM)
\r
599 bprint ("^1",s, "^1 ", deathmessage, "\n");
\r
600 else if(deathtype == DEATH_TOUCHEXPLODE)
\r
601 bprint ("^1",s, "^1 died in an accident\n");
\r
602 else if(deathtype == DEATH_CHEAT)
\r
603 bprint ("^1",s, "^1 was unfairly eliminated\n");
\r
604 else if(deathtype == DEATH_FIRE)
\r
606 bprint ("^1",s, "^1 felt a little hot\n");
\r
608 bprint ("^1",s, "^1 burnt to death\n");
\r
611 bprint ("^1",s, "^1 needs a restart\n");
\r
613 bprint ("^1",s, "^1 died\n");
\r
614 GiveFrags(targ, targ, -1);
\r
615 if(PlayerScore_Add(targ, SP_SCORE, 0) == -5) {
\r
616 AnnounceTo(targ, "botlike");
\r
619 if (targ.killcount > 2)
\r
621 bprint ("^1",s,"^1 needs a restart after a ",ftos(targ.killcount)," scoring spree\n");
\r
623 bprint ("^1",s,"^1 died with a ",ftos(targ.killcount)," kill spree\n");
\r
625 LogDeath("accident", deathtype, targ, targ);
\r
628 targ.death_origin = targ.origin;
\r
629 if(targ != attacker)
\r
630 targ.killer_origin = attacker.origin;
\r
632 // FIXME: this should go in PutClientInServer
\r
633 if (targ.killcount)
\r
634 targ.killcount = 0;
\r
638 // these are updated by each Damage call for use in button triggering and such
\r
639 entity damage_targ;
\r
640 entity damage_inflictor;
\r
641 entity damage_attacker;
\r
643 void Damage (entity targ, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
\r
645 float mirrordamage;
\r
648 entity attacker_save;
\r
652 if (gameover || targ.killcount == -666)
\r
655 local entity oldself;
\r
658 damage_targ = targ;
\r
659 damage_inflictor = inflictor;
\r
660 damage_attacker = attacker;
\r
661 attacker_save = attacker;
\r
663 if(targ.classname == "player")
\r
665 if(targ.grabber.aiment)
\r
666 if(targ.grabber.aiment == attacker)
\r
667 RemoveGrabber(targ); // STOP THAT, you parasite!
\r
669 if(deathtype == DEATH_KILL || deathtype == DEATH_TEAMCHANGE || deathtype == DEATH_AUTOTEAMCHANGE || deathtype == DEATH_QUIET)
\r
671 // These are ALWAYS lethal
\r
672 // No damage modification here
\r
673 // Instead, prepare the victim for his death...
\r
674 targ.armorvalue = 0;
\r
675 targ.spawnshieldtime = 0;
\r
676 targ.health = 0.9; // this is < 1
\r
677 targ.flags -= targ.flags & FL_GODMODE;
\r
680 else if(deathtype == DEATH_MIRRORDAMAGE || deathtype == DEATH_NOAMMO)
\r
686 if (targ.classname == "player")
\r
687 if (attacker.classname == "player")
\r
689 if (attacker.isbot)
\r
690 damage = damage * bound(0.1, (skill + 5) * 0.1, 1);
\r
692 // nullify damage if teamplay is on
\r
693 if(deathtype != DEATH_TELEFRAG)
\r
694 if(attacker.classname == "player")
\r
696 if(targ.classname == "player" && targ != attacker && (IS_INDEPENDENT_PLAYER(attacker) || IS_INDEPENDENT_PLAYER(targ)))
\r
701 else if(attacker.team == targ.team)
\r
705 else if(attacker != targ)
\r
709 else if(teamplay == 4)
\r
711 if(targ.classname == "player" && targ.deadflag == DEAD_NO)
\r
713 teamdamage0 = max(attacker.dmg_team, cvar("g_teamdamage_threshold"));
\r
714 attacker.dmg_team = attacker.dmg_team + damage;
\r
715 if(attacker.dmg_team > teamdamage0 && !g_ca)
\r
716 mirrordamage = cvar("g_mirrordamage") * (attacker.dmg_team - teamdamage0);
\r
717 mirrorforce = cvar("g_mirrordamage") * vlen(force);
\r
721 damage = cvar("g_friendlyfire") * damage;
\r
722 // mirrordamage will be used LATER
\r
731 if(targ.classname == "player")
\r
732 if(attacker.classname == "player")
\r
733 if(attacker != targ)
\r
735 targ.lms_traveled_distance = cvar("g_lms_campcheck_distance");
\r
736 attacker.lms_traveled_distance = cvar("g_lms_campcheck_distance");
\r
739 if not(DEATH_ISSPECIAL(deathtype))
\r
741 damage *= g_weapondamagefactor;
\r
742 mirrordamage *= g_weapondamagefactor;
\r
743 force = force * g_weaponforcefactor;
\r
744 mirrorforce *= g_weaponforcefactor;
\r
747 // apply strength multiplier
\r
748 if ((attacker.items & IT_STRENGTH))
\r
750 if(targ == attacker)
\r
752 damage = damage * cvar("g_balance_powerup_strength_selfdamage");
\r
753 force = force * cvar("g_balance_powerup_strength_selfforce");
\r
757 damage = damage * cvar("g_balance_powerup_strength_damage");
\r
758 force = force * cvar("g_balance_powerup_strength_force");
\r
762 // apply invincibility multiplier
\r
763 if (targ.items & IT_INVINCIBLE)
\r
764 damage = damage * cvar("g_balance_powerup_invincible_takedamage");
\r
766 if (targ == attacker)
\r
768 if(g_ca || (g_cts && !cvar("g_cts_selfdamage")))
\r
771 damage = damage * cvar("g_balance_selfdamagepercent"); // Partial damage if the attacker hits himself
\r
774 // CTF: reduce damage/force
\r
776 if(targ == attacker)
\r
777 if(targ.flagcarried)
\r
779 damage = damage * cvar("g_ctf_flagcarrier_selfdamage");
\r
780 force = force * cvar("g_ctf_flagcarrier_selfforce");
\r
783 // count the damage
\r
786 if(targ.takedamage == DAMAGE_AIM)
\r
787 if(targ != attacker)
\r
789 if(targ.classname == "player")
\r
792 // find height of hit on player axis
\r
793 // if above view_ofs and below maxs, and also in the middle half of the bbox, it is head shot
\r
794 vector headmins, headmaxs, org;
\r
795 org = antilag_takebackorigin(targ, time - ANTILAG_LATENCY(attacker));
\r
796 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);
\r
797 headmaxs = org + '0.6 0 0' * targ.maxs_x + '0 0.6 0' * targ.maxs_y + '0 0 1' * targ.maxs_z;
\r
798 if(trace_hits_box(railgun_start, railgun_end, headmins, headmaxs))
\r
800 deathtype |= HITTYPE_HEADSHOT;
\r
803 else if(targ.classname == "turret_head")
\r
805 deathtype |= HITTYPE_HEADSHOT;
\r
807 if(deathtype & HITTYPE_HEADSHOT)
\r
808 damage *= 1 + damage_headshotbonus;
\r
810 if(targ.classname == "player")
\r
812 if(IsDifferentTeam(targ, attacker))
\r
816 if(targ.BUTTON_CHAT)
\r
817 attacker.typehitsound += 1;
\r
819 attacker.hitsound += 1;
\r
821 damage_goodhits += 1;
\r
822 damage_gooddamage += damage;
\r
824 if not(DEATH_ISSPECIAL(deathtype))
\r
829 if(deathtype & HITTYPE_HEADSHOT)
\r
836 if(deathtype != DEATH_FIRE)
\r
837 attacker.typehitsound += 1;
\r
838 if(time > attacker.teamkill_complain)
\r
840 attacker.teamkill_complain = time + 5;
\r
841 attacker.teamkill_soundtime = time + 0.4;
\r
842 attacker.teamkill_soundsource = targ;
\r
850 if (self.damageforcescale)
\r
852 if (self.classname != "player" || time >= self.spawnshieldtime || g_midair)
\r
854 self.velocity = self.velocity + self.damageforcescale * force;
\r
855 self.flags &~= FL_ONGROUND;
\r
856 UpdateCSQCProjectile(self);
\r
859 if (damage != 0 || (self.damageforcescale && vlen(force)))
\r
860 if (self.event_damage)
\r
861 self.event_damage (inflictor, attacker, damage, deathtype, hitloc, force);
\r
864 if(targ.classname == "player" && attacker.classname == "player" && attacker != targ && attacker.health > 2)
\r
866 // Savage: vampire mode
\r
868 if (time >= self.spawnshieldtime)
\r
869 if (deathtype != DEATH_DIGESTION) // a different vampire system is used for this
\r
871 attacker.health += damage;
\r
875 // apply mirror damage if any
\r
876 if(mirrordamage > 0 || mirrorforce > 0)
\r
878 attacker = attacker_save;
\r
879 force = normalize(attacker.origin + attacker.view_ofs - hitloc) * mirrorforce;
\r
880 Damage(attacker, inflictor, attacker, mirrordamage, DEATH_MIRRORDAMAGE, attacker.origin, force);
\r
884 vector NearestPointOnBox(entity box, vector org)
\r
886 vector m1, m2, nearest;
\r
888 m1 = box.mins + box.origin;
\r
889 m2 = box.maxs + box.origin;
\r
891 nearest_x = bound(m1_x, org_x, m2_x);
\r
892 nearest_y = bound(m1_y, org_y, m2_y);
\r
893 nearest_z = bound(m1_z, org_z, m2_z);
\r
898 void Damage_RecordDamage(entity attacker, float deathtype, float damage)
\r
901 weaponid = DEATH_WEAPONOF(deathtype);
\r
903 if not(inWarmupStage)
\r
905 if ((clienttype(attacker) == CLIENTTYPE_REAL) | (clienttype(attacker) == CLIENTTYPE_BOT)) {
\r
906 attacker.stats_hit[weaponid - 1] += damage;
\r
907 attacker.stat_hit = weaponid + 64 * floor(attacker.stats_hit[weaponid - 1]);
\r
911 float RadiusDamage_running;
\r
912 float RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype, entity directhitentity)
\r
913 // Returns total damage applies to creatures
\r
918 vector blastorigin;
\r
923 float total_damage_to_creatures;
\r
928 float stat_damagedone;
\r
929 float stat_maxdamage;
\r
931 if(RadiusDamage_running)
\r
934 print("RadiusDamage called recursively!\n");
\r
935 print("Expect stuff to go HORRIBLY wrong.\n");
\r
936 print("Causing a stack trace...\n");
\r
937 save = cvar_string("prvm_backtraceforwarnings");
\r
938 cvar_set("prvm_backtraceforwarnings", "1");
\r
939 fclose(-1); // calls VM_Warning
\r
940 cvar_set("prvm_backtraceforwarnings", save);
\r
944 RadiusDamage_running = 1;
\r
946 tfloordmg = cvar("g_throughfloor_damage");
\r
947 tfloorforce = cvar("g_throughfloor_force");
\r
949 blastorigin = (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5);
\r
950 total_damage_to_creatures = 0;
\r
952 if(deathtype != (WEP_GRABBER | HITTYPE_SECONDARY | HITTYPE_BOUNCE))
\r
954 force = inflictor.velocity;
\r
955 if(vlen(force) == 0)
\r
958 force = normalize(force);
\r
959 if(forceintensity >= 0)
\r
960 Damage_DamageInfo(blastorigin, coredamage, edgedamage, rad, forceintensity * force, deathtype, attacker);
\r
962 Damage_DamageInfo(blastorigin, coredamage, edgedamage, -rad, (-forceintensity) * force, deathtype, attacker);
\r
965 stat_damagedone = 0;
\r
966 stat_maxdamage = 0;
\r
968 targ = WarpZone_FindRadius (blastorigin, rad, FALSE);
\r
972 if (targ != inflictor)
\r
973 if (ignore != targ) if(targ.takedamage)
\r
975 // LordHavoc: measure distance to nearest point on target (not origin)
\r
976 // (this guarentees 100% damage on a touch impact)
\r
977 nearest = targ.WarpZone_findradius_nearest;
\r
978 diff = targ.WarpZone_findradius_dist;
\r
979 // round up a little on the damage to ensure full damage on impacts
\r
980 // and turn the distance into a fraction of the radius
\r
981 power = 1 - ((vlen (diff) - 2) / rad);
\r
983 //bprint(ftos(power));
\r
984 //if (targ == attacker)
\r
985 // print(ftos(power), "\n");
\r
990 finaldmg = coredamage * power + edgedamage * (1 - power);
\r
997 local float hitratio;
\r
998 local vector hitloc;
\r
999 local vector myblastorigin;
\r
1000 myblastorigin = WarpZone_TransformOrigin(targ, blastorigin);
\r
1001 center = targ.origin + (targ.mins + targ.maxs) * 0.5;
\r
1002 // if it's a player, use the view origin as reference
\r
1003 if (targ.classname == "player")
\r
1004 center = targ.origin + targ.view_ofs;
\r
1005 force = normalize(center - myblastorigin);
\r
1006 force = force * (finaldmg / coredamage) * forceintensity;
\r
1007 // test line of sight to multiple positions on box,
\r
1008 // and do damage if any of them hit
\r
1010 if (targ.classname == "player")
\r
1011 total = ceil(bound(1, finaldmg, 50));
\r
1013 total = ceil(bound(1, finaldmg/10, 5));
\r
1018 //traceline(targ.WarpZone_findradius_findorigin, nearest, MOVE_NOMONSTERS, inflictor);
\r
1019 WarpZone_TraceLine(blastorigin, WarpZone_UnTransformOrigin(targ, nearest), MOVE_NOMONSTERS, inflictor);
\r
1020 if (trace_fraction == 1 || trace_ent == targ)
\r
1024 hitloc = hitloc + nearest;
\r
1028 nearest_x = targ.origin_x + targ.mins_x + random() * targ.size_x;
\r
1029 nearest_y = targ.origin_y + targ.mins_y + random() * targ.size_y;
\r
1030 nearest_z = targ.origin_z + targ.mins_z + random() * targ.size_z;
\r
1033 nearest = hitloc * (1 / max(1, hits));
\r
1034 hitratio = (hits / total);
\r
1035 a = bound(0, tfloordmg + (1-tfloordmg) * hitratio, 1);
\r
1036 finaldmg = finaldmg * a;
\r
1037 a = bound(0, tfloorforce + (1-tfloorforce) * hitratio, 1);
\r
1038 force = force * a;
\r
1039 //if (targ == attacker)
\r
1041 // print("hits ", ftos(hits), " / ", ftos(total));
\r
1042 // print(" finaldmg ", ftos(finaldmg), " force ", vtos(force));
\r
1043 // print(" (", ftos(a), ")\n");
\r
1045 if(hits || tfloordmg || tfloorforce)
\r
1047 if(targ.iscreature)
\r
1049 total_damage_to_creatures += finaldmg;
\r
1051 if(targ.flags & FL_CLIENT)
\r
1052 if(targ.deadflag == DEAD_NO)
\r
1053 if(targ != attacker)
\r
1054 if(!teamplay || targ.team != attacker.team)
\r
1056 stat_damagedone += finaldmg;
\r
1057 stat_maxdamage += coredamage;
\r
1061 if(targ == directhitentity || DEATH_ISSPECIAL(deathtype))
\r
1062 Damage (targ, inflictor, attacker, finaldmg, deathtype, nearest, force);
\r
1064 Damage (targ, inflictor, attacker, finaldmg, deathtype | HITTYPE_SPLASH, nearest, force);
\r
1072 RadiusDamage_running = 0;
\r
1074 Damage_RecordDamage(attacker, deathtype, min(stat_maxdamage, stat_damagedone));
\r
1076 return total_damage_to_creatures;
\r
1079 .float fire_damagepersec;
\r
1080 .float fire_endtime;
\r
1081 .float fire_deathtype;
\r
1082 .entity fire_owner;
\r
1083 .float fire_hitsound;
\r
1084 .entity fire_burner;
\r
1086 void fireburner_think();
\r
1088 float Fire_IsBurning(entity e)
\r
1090 return (time < e.fire_endtime);
\r
1093 float Fire_AddDamage(entity e, entity o, float d, float t, float dt)
\r
1096 float maxtime, mintime, maxdamage, mindamage, maxdps, mindps, totaldamage, totaltime;
\r
1098 if(e.classname == "player")
\r
1105 if(!e.fire_burner)
\r
1107 // print("adding a fire burner to ", e.classname, "\n");
\r
1108 e.fire_burner = spawn();
\r
1109 e.fire_burner.classname = "fireburner";
\r
1110 e.fire_burner.think = fireburner_think;
\r
1111 e.fire_burner.nextthink = time;
\r
1112 e.fire_burner.owner = e;
\r
1118 if(Fire_IsBurning(e))
\r
1120 mintime = e.fire_endtime - time;
\r
1121 maxtime = max(mintime, t);
\r
1123 mindps = e.fire_damagepersec;
\r
1124 maxdps = max(mindps, dps);
\r
1126 if(maxtime > mintime || maxdps > mindps)
\r
1128 mindamage = mindps * mintime;
\r
1129 maxdamage = mindamage + d;
\r
1131 // interval [mintime, maxtime] * [mindps, maxdps]
\r
1132 // intersected with
\r
1133 // [mindamage, maxdamage]
\r
1134 // maximum of this!
\r
1136 if(maxdamage >= maxtime * maxdps)
\r
1138 totaltime = maxtime;
\r
1139 totaldamage = maxtime * maxdps;
\r
1141 // this branch increases totaldamage if either t > mintime, or dps > mindps
\r
1145 // maxdamage is inside the interval!
\r
1146 // first, try to use mindps; only if this fails, increase dps as needed
\r
1147 totaltime = min(maxdamage / mindps, maxtime); // maxdamage / mindps >= mindamage / mindps = mintime
\r
1148 totaldamage = maxdamage;
\r
1149 // can totaldamage / totaltime be >= maxdps?
\r
1150 // max(mindps, maxdamage / maxtime) >= maxdps?
\r
1151 // we know maxdamage < maxtime * maxdps
\r
1152 // so it cannot be
\r
1154 // this branch ALWAYS increases totaldamage, but requires maxdamage < maxtime * maxdps
\r
1157 // total conditions for increasing:
\r
1158 // maxtime > mintime OR maxdps > mindps OR maxtime * maxdps > maxdamage
\r
1160 // if maxtime = mintime, maxdps = mindps
\r
1162 // maxdamage = mindamage + d
\r
1163 // mindamage = mindps * mintime = maxdps * maxtime < maxdamage!
\r
1164 // so the last condition is not needed
\r
1166 e.fire_damagepersec = totaldamage / totaltime;
\r
1167 e.fire_endtime = time + totaltime;
\r
1168 if(totaldamage > 1.2 * mindamage)
\r
1170 e.fire_deathtype = dt;
\r
1171 if(e.fire_owner != o)
\r
1174 e.fire_hitsound = FALSE;
\r
1177 return max(0, totaldamage - mindamage); // can never be negative, but to make sure
\r
1184 e.fire_damagepersec = dps;
\r
1185 e.fire_endtime = time + t;
\r
1186 e.fire_deathtype = dt;
\r
1188 e.fire_hitsound = FALSE;
\r
1193 void Fire_ApplyDamage(entity e)
\r
1195 float t, d, hi, ty;
\r
1198 if not(Fire_IsBurning(e))
\r
1204 if(clienttype(o) == CLIENTTYPE_NOTACLIENT)
\r
1207 // water and slime stop fire
\r
1209 if(e.watertype != CONTENT_LAVA)
\r
1210 e.fire_endtime = 0;
\r
1212 t = min(frametime, e.fire_endtime - time);
\r
1213 d = e.fire_damagepersec * t;
\r
1215 hi = e.fire_owner.hitsound;
\r
1216 ty = e.fire_owner.typehitsound;
\r
1217 Damage(e, e, e.fire_owner, d, e.fire_deathtype, e.origin, '0 0 0');
\r
1218 if(e.fire_hitsound && e.fire_owner)
\r
1220 e.fire_owner.hitsound = hi;
\r
1221 e.fire_owner.typehitsound = ty;
\r
1223 e.fire_hitsound = TRUE;
\r
1225 Damage_RecordDamage(e.fire_owner, e.fire_deathtype, d);
\r
1227 if not(IS_INDEPENDENT_PLAYER(e))
\r
1228 FOR_EACH_PLAYER(other) if(e != other)
\r
1230 if(other.classname == "player")
\r
1231 if(other.deadflag == DEAD_NO)
\r
1232 if not(IS_INDEPENDENT_PLAYER(other))
\r
1233 if(boxesoverlap(e.absmin, e.absmax, other.absmin, other.absmax))
\r
1235 t = cvar("g_balance_firetransfer_time") * (e.fire_endtime - time);
\r
1236 d = cvar("g_balance_firetransfer_damage") * e.fire_damagepersec * t;
\r
1237 Fire_AddDamage(other, o, d, t, DEATH_FIRE);
\r
1242 void Fire_ApplyEffect(entity e)
\r
1244 if(Fire_IsBurning(e))
\r
1245 e.effects |= EF_FLAME;
\r
1247 e.effects &~= EF_FLAME;
\r
1250 void fireburner_think()
\r
1252 // for players, this is done in the regular loop
\r
1253 if(wasfreed(self.owner))
\r
1258 Fire_ApplyEffect(self.owner);
\r
1259 if(!Fire_IsBurning(self.owner))
\r
1261 self.owner.fire_burner = world;
\r
1265 Fire_ApplyDamage(self.owner);
\r
1266 self.nextthink = time;
\r