6 float Damage_DamageInfo_SendEntity(entity to, float sf)
8 WriteByte(MSG_ENTITY, ENT_CLIENT_DAMAGEINFO);
9 WriteShort(MSG_ENTITY, self.projectiledeathtype);
10 WriteCoord(MSG_ENTITY, floor(self.origin_x));
11 WriteCoord(MSG_ENTITY, floor(self.origin_y));
12 WriteCoord(MSG_ENTITY, floor(self.origin_z));
13 WriteByte(MSG_ENTITY, bound(1, self.dmg, 255));
14 WriteByte(MSG_ENTITY, bound(0, self.dmg_radius, 255));
15 WriteByte(MSG_ENTITY, bound(1, self.dmg_edge, 255));
16 WriteShort(MSG_ENTITY, self.oldorigin_x);
20 void Damage_DamageInfo(vector org, float coredamage, float edgedamage, float rad, vector force, float deathtype, entity dmgowner)
22 // TODO maybe call this from non-edgedamage too?
23 // TODO maybe make the client do the particle effects for the weapons and the impact sounds using this info?
27 if(!sound_allowed(MSG_BROADCAST, dmgowner))
32 e.projectiledeathtype = deathtype;
34 e.dmg_edge = edgedamage;
36 e.dmg_force = vlen(force);
39 e.oldorigin_x = compressShortVector(e.velocity);
41 Net_LinkEntity(e, FALSE, 0.2, Damage_DamageInfo_SendEntity);
44 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
46 float checkrules_firstblood;
49 float damage_goodhits;
50 float damage_gooddamage;
52 float damage_headshotbonus; // bonus multiplier for head shots, set to 0 after use
55 .float teamkill_complain;
56 .float teamkill_soundtime;
57 .entity teamkill_soundsource;
59 .float taunt_soundtime;
62 float IsDifferentTeam(entity a, entity b)
77 float IsFlying(entity a)
79 if(a.flags & FL_ONGROUND)
81 if(a.waterlevel >= WATERLEVEL_SWIMMING)
83 traceline(a.origin, a.origin - '0 0 48', MOVE_NORMAL, a);
84 if(trace_fraction < 1)
89 void UpdateFrags(entity player, float f)
91 PlayerTeamScore_AddScore(player, f);
94 // NOTE: f=0 means still count as a (positive) kill, but count no frags for it
95 void GiveFrags (entity attacker, entity targ, float f)
97 // TODO route through PlayerScores instead
105 PlayerScore_Add(attacker, SP_SUICIDES, 1);
110 PlayerScore_Add(attacker, SP_KILLS, -1); // or maybe add a teamkills field?
116 PlayerScore_Add(attacker, SP_KILLS, 1);
119 PlayerScore_Add(targ, SP_DEATHS, 1);
122 if(cvar("g_arena_roundbased"))
125 // FIXME fix the mess this is (we have REAL points now!)
128 f = RunematchHandleFrags(attacker, targ, f);
132 f = kh_HandleFrags(attacker, targ, f);
138 tl = PlayerScore_Add(targ, SP_LMS_LIVES, -1);
139 if(tl < lms_lowest_lives)
140 lms_lowest_lives = tl;
144 lms_next_place = player_count;
145 PlayerScore_Add(targ, SP_LMS_RANK, lms_next_place); // won't ever spawn again
152 if(g_ctf_ignore_frags)
156 attacker.totalfrags += f;
159 UpdateFrags(attacker, f);
162 string AppendItemcodes(string s, entity player)
167 // w = player.switchweapon;
169 w = player.cnt; // previous weapon!
170 s = strcat(s, ftos(w));
171 if(time < player.strength_finished)
173 if(time < player.invincible_finished)
175 if(player.flagcarried != world)
177 if(player.BUTTON_CHAT)
182 s = strcat(s, "|", ftos(player.runes));
186 void LogDeath(string mode, float deathtype, entity killer, entity killed)
189 if(!cvar("sv_eventlog"))
191 s = strcat(":kill:", mode);
192 s = strcat(s, ":", ftos(killer.playerid));
193 s = strcat(s, ":", ftos(killed.playerid));
194 s = strcat(s, ":type=", ftos(deathtype));
195 s = strcat(s, ":items=");
196 s = AppendItemcodes(s, killer);
199 s = strcat(s, ":victimitems=");
200 s = AppendItemcodes(s, killed);
205 void Obituary (entity attacker, entity inflictor, entity targ, float deathtype)
210 if (targ.classname == "player" || targ.classname == "corpse")
212 if (targ.classname == "corpse")
216 a = attacker.netname;
218 if (targ == attacker)
220 if (deathtype == DEATH_TEAMCHANGE) {
221 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", ColoredTeamName(targ.team)));
222 } else if (deathtype == DEATH_AUTOTEAMCHANGE) {
223 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)));
225 } else if (deathtype == DEATH_CAMP) {
227 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
229 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
230 } else if (deathtype == DEATH_NOAMMO) {
232 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
234 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
235 } else if (deathtype == DEATH_ROT) {
237 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
239 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
240 } else if (deathtype == DEATH_MIRRORDAMAGE) {
242 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
244 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
247 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
249 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
253 if (deathtype == DEATH_CAMP)
254 bprint ("^1",s, "^1 thought he found a nice camping ground\n");
255 else if (deathtype == DEATH_MIRRORDAMAGE)
256 bprint ("^1",s, "^1 didn't become friends with the Lord of Teamplay\n");
258 bprint ("^1",s, "^1 will be reinserted into the game due to his own actions\n");
260 if(deathtype != DEATH_TEAMCHANGE)
262 LogDeath("suicide", deathtype, targ, targ);
263 GiveFrags(attacker, targ, -1);
265 if (targ.killcount > 2)
266 bprint ("^1",s,"^1 faded after a ",ftos(targ.killcount)," point spree\n");
268 w = DEATH_WEAPONOF(deathtype);
271 w_deathtypestring = "couldn't resist the urge to self-destruct";
272 w_deathtype = deathtype;
273 weapon_action(w, WR_SUICIDEMESSAGE);
274 bprint("^1", s, "^1 ", w_deathtypestring, "\n");
276 else if (deathtype == DEATH_KILL)
277 bprint ("^1",s, "^1 couldn't take it anymore\n");
278 else if (deathtype == DEATH_ROT)
279 bprint ("^1",s, "^1 died\n");
280 else if (deathtype == DEATH_NOAMMO)
281 bprint ("^7",s, "^7 committed suicide. What's the point of living without ammo?\n");
282 else if (deathtype == DEATH_CAMP)
283 bprint ("^1",s, "^1 thought he found a nice camping ground\n");
284 else if (deathtype == DEATH_MIRRORDAMAGE)
285 bprint ("^1",s, "^1 didn't become friends with the Lord of Teamplay\n");
286 else if (deathtype == DEATH_CHEAT)
287 bprint ("^1",s, "^1 unfairly eliminated himself\n");
288 else if (deathtype != DEATH_TEAMCHANGE)
289 bprint ("^1",s, "^1 couldn't resist the urge to self-destruct\n");
291 if(deathtype != DEATH_TEAMCHANGE)
293 LogDeath("suicide", deathtype, targ, targ);
294 GiveFrags(attacker, targ, -1);
296 if (targ.killcount > 2)
297 bprint ("^1",s,"^1 ended it all after a ",ftos(targ.killcount)," kill spree\n");
300 else if (attacker.classname == "player" || attacker.classname == "gib")
302 if(teams_matter && attacker.team == targ.team)
305 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against a team mate!"));
306 bprint ("^1", a, "^1 took action against a team mate\n");
308 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s, ", a team mate!"));
309 bprint ("^1", a, "^1 mows down a team mate\n");
311 GiveFrags(attacker, targ, -1);
312 if (targ.killcount > 2) {
314 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," scoring spree was ended by a team mate!\n");
316 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," kill spree was ended by a team mate!\n");
318 if (attacker.killcount > 2) {
320 bprint ("^1",a,"^1 ended a ",ftos(attacker.killcount)," scoring spree by going against a team mate\n");
322 bprint ("^1",a,"^1 ended a ",ftos(attacker.killcount)," kill spree by killing a team mate\n");
324 attacker.killcount = 0;
326 LogDeath("tk", deathtype, attacker, targ);
330 string blood_message, victim_message;
331 if (!checkrules_firstblood)
333 checkrules_firstblood = TRUE;
336 bprint("^1",a, "^1 was the first to score", "\n");
337 blood_message = "^1First point\n";
338 //victim_message = "^1First victim\n"; // or First casualty
342 bprint("^1",a, "^1 drew first blood", "\n");
343 blood_message = "^1First blood\n";
344 victim_message = "^1First victim\n"; // or First casualty
349 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s));
350 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, a,"^1 scored against you ^7"));
352 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, blood_message, "^4You fragged ^7", s));
353 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, victim_message, "^1You were fragged by ^7", a));
354 attacker.taunt_soundtime = time + 1;
358 bprint ("^1",s, "^1 needs a restart thanks to ", a, "\n");
360 w = DEATH_WEAPONOF(deathtype);
363 w_deathtypestring = "was blasted by";
364 w_deathtype = deathtype;
365 weapon_action(w, WR_KILLMESSAGE);
366 p = strstrofs(w_deathtypestring, "#", 0);
368 bprint("^1", s, "^1 ", w_deathtypestring, " ", a, "\n");
370 bprint("^1", s, "^1 ", substring(w_deathtypestring, 0, p), a, "^1", substring(w_deathtypestring, p+1, strlen(w_deathtypestring) - (p+1)), "\n");
372 else if (deathtype == DEATH_TELEFRAG)
373 bprint ("^1",s, "^1 was telefragged by ", a, "\n");
374 else if (deathtype == DEATH_DROWN)
375 bprint ("^1",s, "^1 was drowned by ", a, "\n");
376 else if (deathtype == DEATH_SLIME)
377 bprint ("^1",s, "^1 was slimed by ", a, "\n");
378 else if (deathtype == DEATH_LAVA)
379 bprint ("^1",s, "^1 was cooked by ", a, "\n");
380 else if (deathtype == DEATH_FALL)
381 bprint ("^1",s, "^1 was grounded by ", a, "\n");
382 else if (deathtype == DEATH_SHOOTING_STAR)
383 bprint ("^1",s, "^1 was shot into space by ", a, "\n");
384 else if (deathtype == DEATH_SWAMP)
385 bprint ("^1",s, "^1 was conserved by ", a, "\n");
386 else if (deathtype == DEATH_HURTTRIGGER && inflictor.message2 != "")
388 p = strstrofs(inflictor.message2, "#", 0);
390 bprint("^1", s, "^1 ", inflictor.message2, " ", a, "\n");
392 bprint("^1", s, "^1 ", substring(inflictor.message2, 0, p), a, "^1", substring(inflictor.message2, p+1, strlen(inflictor.message2) - (p+1)), "\n");
394 else if(deathtype == DEATH_TURRET)
395 bprint ("^1",s, "^1 was pushed into the line of fire by ^1", a, "\n");
396 else if(deathtype == DEATH_TOUCHEXPLODE)
397 bprint ("^1",s, "^1 was pushed into an accident by ^1", a, "\n");
398 else if(deathtype == DEATH_CHEAT)
399 bprint ("^1",s, "^1 was unfairly eliminated by ^1", a, "\n");
401 bprint ("^1",s, "^1 was fragged by ", a, "\n");
404 if(g_ctf && targ.flagcarried)
406 UpdateFrags(attacker, ctf_score_value("score_kill"));
407 PlayerScore_Add(attacker, SP_CTF_FCKILLS, 1);
408 GiveFrags(attacker, targ, 0); // for logging
411 GiveFrags(attacker, targ, 1);
413 if (targ.killcount > 2) {
415 bprint ("^1",s,"'s ^1", ftos(targ.killcount), " scoring spree was ended by ", a, "\n");
417 bprint ("^1",s,"'s ^1", ftos(targ.killcount), " kill spree was ended by ", a, "\n");
420 attacker.killcount = attacker.killcount + 1;
422 if (attacker.killcount > 2) {
424 bprint ("^1",a,"^1 made ",ftos(attacker.killcount)," scores in a row\n");
426 bprint ("^1",a,"^1 has ",ftos(attacker.killcount)," frags in a row\n");
429 LogDeath("frag", deathtype, attacker, targ);
431 if (attacker.killcount == 3)
434 bprint (a,"^7 made a ^1TRIPLE SCORE\n");
436 bprint (a,"^7 made a ^1TRIPLE FRAG\n");
437 announce(attacker, "announcer/male/03kills.wav");
440 else if (attacker.killcount == 5)
443 bprint (a,"^7 unleashes ^1SCORING RAGE\n");
445 bprint (a,"^7 unleashes ^1RAGE\n");
446 announce(attacker, "announcer/male/05kills.wav");
449 else if (attacker.killcount == 10)
452 bprint (a,"^7 made ^1TEN SCORES IN A ROW!\n");
454 bprint (a,"^7 starts the ^1MASSACRE!\n");
455 announce(attacker, "announcer/male/10kills.wav");
458 else if (attacker.killcount == 15)
461 bprint (a,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
463 bprint (a,"^7 executes ^1MAYHEM!\n");
464 announce(attacker, "announcer/male/15kills.wav");
467 else if (attacker.killcount == 20)
470 bprint (a,"^7 made ^1TWENTY SCORES IN A ROW!\n");
472 bprint (a,"^7 is a ^1BERSERKER!\n");
473 announce(attacker, "announcer/male/20kills.wav");
476 else if (attacker.killcount == 25)
479 bprint (a,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
481 bprint (a,"^7 inflicts ^1CARNAGE!\n");
482 announce(attacker, "announcer/male/25kills.wav");
485 else if (attacker.killcount == 30)
488 bprint (a,"^7 made ^1THIRTY SCORES IN A ROW!\n");
490 bprint (a,"^7 unleashes ^1ARMAGEDDON!\n");
491 announce(attacker, "announcer/male/30kills.wav");
498 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
499 if (deathtype == DEATH_HURTTRIGGER && inflictor.message != "")
500 bprint ("^1",s, "^1 ", inflictor.message, "\n");
501 else if (deathtype == DEATH_DROWN)
503 bprint ("^1",s, "^1 was in the water for too long\n");
505 bprint ("^1",s, "^1 drowned\n");
506 else if (deathtype == DEATH_SLIME)
507 bprint ("^1",s, "^1 was slimed\n");
508 else if (deathtype == DEATH_LAVA)
510 bprint ("^1",s, "^1 found a hot place\n");
512 bprint ("^1",s, "^1 turned into hot slag\n");
513 else if (deathtype == DEATH_FALL)
515 bprint ("^1",s, "^1 tested gravity (and it worked)\n");
517 bprint ("^1",s, "^1 hit the ground with a crunch\n");
518 else if (deathtype == DEATH_SHOOTING_STAR)
519 bprint ("^1",s, "^1 became a shooting star\n");
520 else if (deathtype == DEATH_SWAMP)
522 bprint ("^1",s, "^1 discovered a swamp\n");
524 bprint ("^1",s, "^1 is now conserved for centuries to come\n");
525 else if(deathtype == DEATH_TURRET)
526 bprint ("^1",s, "^1 was mowed down by a turret \n");
527 else if(deathtype == DEATH_TOUCHEXPLODE)
528 bprint ("^1",s, "^1 died in an accident\n");
529 else if(deathtype == DEATH_CHEAT)
530 bprint ("^1",s, "^1 was unfairly eliminated\n");
533 bprint ("^1",s, "^1 needs a restart\n");
535 bprint ("^1",s, "^1 died\n");
536 GiveFrags(targ, targ, -1);
537 if(PlayerScore_Add(targ, SP_SCORE, 0) == -5) {
538 announce(targ, "announcer/male/botlike.wav");
541 if (targ.killcount > 2)
543 bprint ("^1",s,"^1 needs a restart after a ",ftos(targ.killcount)," scoring spree\n");
545 bprint ("^1",s,"^1 died with a ",ftos(targ.killcount)," kill spree\n");
547 LogDeath("accident", deathtype, targ, targ);
549 targ.death_origin = targ.origin;
551 targ.killer_origin = attacker.origin;
552 // FIXME: this should go in PutClientInServer
558 // these are updated by each Damage call for use in button triggering and such
560 entity damage_inflictor;
561 entity damage_attacker;
563 void Damage (entity targ, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
568 entity attacker_save;
572 if (gameover || targ.killcount == -666)
575 local entity oldself;
579 damage_inflictor = inflictor;
580 damage_attacker = attacker;
581 attacker_save = attacker;
583 if(targ.classname == "player")
586 if(targ.hook.aiment == attacker)
587 RemoveGrapplingHook(targ); // STOP THAT, you parasite!
589 // special rule: gravity bomb does not hit team mates (other than for disconnecting the hook)
590 if(DEATH_ISWEAPON(deathtype, WEP_HOOK) || DEATH_ISWEAPON(deathtype, WEP_TUBA))
592 if(targ.classname == "player")
593 if not(IsDifferentTeam(targ, attacker))
600 if(deathtype == DEATH_KILL || deathtype == DEATH_TEAMCHANGE || deathtype == DEATH_AUTOTEAMCHANGE)
602 // These are ALWAYS lethal
603 // No damage modification here
604 // Instead, prepare the victim for his death...
606 targ.spawnshieldtime = 0;
607 targ.health = 0.9; // this is < 1
608 targ.flags -= targ.flags & FL_GODMODE;
611 else if(deathtype == DEATH_MIRRORDAMAGE || deathtype == DEATH_NOAMMO)
617 if (targ.classname == "player")
618 if (attacker.classname == "player")
621 damage = damage * bound(0.1, (skill + 5) * 0.1, 1);
623 // nullify damage if teamplay is on
624 if(deathtype != DEATH_TELEFRAG)
625 if(attacker.classname == "player")
627 if(targ.classname == "player" && targ != attacker && (IS_INDEPENDENT_PLAYER(attacker) || IS_INDEPENDENT_PLAYER(targ)))
632 else if(attacker.team == targ.team)
636 else if(attacker != targ)
640 else if(teamplay == 4)
642 if(targ.classname == "player" && targ.deadflag == DEAD_NO)
644 teamdamage0 = max(attacker.dmg_team, cvar("g_teamdamage_threshold"));
645 attacker.dmg_team = attacker.dmg_team + damage;
646 if(attacker.dmg_team > teamdamage0)
647 mirrordamage = cvar("g_mirrordamage") * (attacker.dmg_team - teamdamage0);
648 mirrorforce = cvar("g_mirrordamage") * vlen(force);
651 if(cvar("g_friendlyfire") == 0)
655 damage = cvar("g_friendlyfire") * damage;
656 // mirrordamage will be used LATER
665 if(targ.classname == "player")
666 if(attacker.classname == "player")
669 targ.lms_traveled_distance = cvar("g_lms_campcheck_distance");
670 attacker.lms_traveled_distance = cvar("g_lms_campcheck_distance");
673 if(targ.classname == "player")
676 if ((deathtype == DEATH_FALL) ||
677 (deathtype == DEATH_DROWN) ||
678 (deathtype == DEATH_SLIME) ||
679 (deathtype == DEATH_LAVA))
684 if (targ.armorvalue && (deathtype == WEP_MINSTANEX) && damage)
686 targ.armorvalue -= 1;
687 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^3Remaining extra lives: ",ftos(targ.armorvalue)));
690 attacker.hitsound += 1; // TODO change this to a future specific hitsound for armor hit
692 if (DEATH_ISWEAPON(deathtype, WEP_LASER))
695 if (targ != attacker)
697 if (targ.classname == "player")
698 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "Secondary fire inflicts no damage!"));
708 if not(DEATH_ISSPECIAL(deathtype))
709 damage *= g_weapondamagefactor;
711 // apply strength multiplier
712 if ((attacker.items & IT_STRENGTH) && !g_minstagib)
716 damage = damage * cvar("g_balance_powerup_strength_selfdamage");
717 force = force * cvar("g_balance_powerup_strength_selfforce");
721 damage = damage * cvar("g_balance_powerup_strength_damage");
722 force = force * cvar("g_balance_powerup_strength_force");
726 // apply invincibility multiplier
727 if (targ.items & IT_INVINCIBLE && !g_minstagib)
728 damage = damage * cvar("g_balance_powerup_invincible_takedamage");
730 if (targ == attacker)
731 damage = damage * cvar("g_balance_selfdamagepercent"); // Partial damage if the attacker hits himself
733 // CTF: reduce damage/force
738 damage = damage * cvar("g_ctf_flagcarrier_selfdamage");
739 force = force * cvar("g_ctf_flagcarrier_selfforce");
744 // apply strength rune
745 if (attacker.runes & RUNE_STRENGTH)
747 if(attacker.runes & CURSE_WEAK) // have both curse & rune
749 damage = damage * cvar("g_balance_rune_strength_combo_damage");
750 force = force * cvar("g_balance_rune_strength_combo_force");
754 damage = damage * cvar("g_balance_rune_strength_damage");
755 force = force * cvar("g_balance_rune_strength_force");
758 else if (attacker.runes & CURSE_WEAK)
760 damage = damage * cvar("g_balance_curse_weak_damage");
761 force = force * cvar("g_balance_curse_weak_force");
764 // apply defense rune
765 if (targ.runes & RUNE_DEFENSE)
767 if (targ.runes & CURSE_VULNER) // have both curse & rune
768 damage = damage * cvar("g_balance_rune_defense_combo_takedamage");
770 damage = damage * cvar("g_balance_rune_defense_takedamage");
772 else if (targ.runes & CURSE_VULNER)
773 damage = damage * cvar("g_balance_curse_vulner_takedamage");
779 if(targ.takedamage == DAMAGE_AIM)
781 if(targ.classname == "player")
783 if(IsDifferentTeam(targ, attacker))
788 attacker.typehitsound += 1;
790 attacker.hitsound += 1;
792 damage_goodhits += 1;
793 damage_gooddamage += damage;
795 if not(DEATH_ISSPECIAL(deathtype))
802 if(targ.items & IT_STRENGTH)
806 // find height of hit on player axis
807 // if above view_ofs and below maxs, and also in the middle half of the bbox, it is head shot
808 vector headmins, headmaxs, org;
809 org = antilag_takebackorigin(targ, time - ANTILAG_LATENCY(attacker));
810 headmins = org + '0.7 0 0' * targ.mins_x + '0 0.7 0' * targ.mins_y + '0 0 1' * (1.5 * targ.view_ofs_z - 0.5 * targ.maxs_z);
811 headmaxs = org + '0.7 0 0' * targ.maxs_x + '0 0.7 0' * targ.maxs_y + '0 0 1' * targ.maxs_z;
812 if(trace_hits_box(railgun_start, railgun_end, headmins, headmaxs))
814 damage *= 1 + damage_headshotbonus;
816 deathtype |= HITTYPE_HEADSHOT;
823 attacker.typehitsound += 1;
825 if(time > attacker.teamkill_complain)
827 attacker.teamkill_complain = time + 5;
828 attacker.teamkill_soundtime = time + 0.4;
829 attacker.teamkill_soundsource = targ;
836 if (self.damageforcescale)
839 self.velocity = self.velocity + self.damageforcescale * force;
840 self.flags &~= FL_ONGROUND;
841 UpdateCSQCProjectile(self);
844 if (damage != 0 || (self.damageforcescale && vlen(force)))
845 if (self.event_damage)
846 self.event_damage (inflictor, attacker, damage, deathtype, hitloc, force);
849 if(targ.classname == "player" && attacker.classname == "player" && attacker != targ && attacker.health > 2)
851 // Savage: vampire mode
854 if (time > self.spawnshieldtime)
856 attacker.health += damage;
860 if (attacker.runes & RUNE_VAMPIRE)
862 // apply vampire rune
863 if (attacker.runes & CURSE_EMPATHY) // have the curse too
865 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb");
866 attacker.health = bound(
867 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 40
868 attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb"),
869 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
873 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_absorb");
874 attacker.health = bound(
875 attacker.health, // LA: was 3, but changed so that you can't lose health
876 // empathy won't let you gain health in the same way...
877 attacker.health + damage * cvar("g_balance_rune_vampire_absorb"),
878 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
881 // apply empathy curse
882 else if (attacker.runes & CURSE_EMPATHY)
884 attacker.health = bound(
885 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 20
886 attacker.health + damage * cvar("g_balance_curse_empathy_takedamage"),
892 // apply mirror damage if any
893 if(mirrordamage > 0 || mirrorforce > 0)
895 attacker = attacker_save;
899 // just lose extra LIVES, don't kill the player for mirror damage
900 if(attacker.armorvalue > 0)
902 attacker.armorvalue = attacker.armorvalue - 1;
903 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^3Remaining extra lives: ",ftos(attacker.armorvalue)));
904 attacker.hitsound += 1;
908 force = normalize(attacker.origin + attacker.view_ofs - hitloc) * mirrorforce;
909 Damage(attacker, inflictor, attacker, mirrordamage, DEATH_MIRRORDAMAGE, attacker.origin, force);
913 vector NearestPointOnBox(entity box, vector org)
915 vector m1, m2, nearest;
917 m1 = box.mins + box.origin;
918 m2 = box.maxs + box.origin;
920 nearest_x = bound(m1_x, org_x, m2_x);
921 nearest_y = bound(m1_y, org_y, m2_y);
922 nearest_z = bound(m1_z, org_z, m2_z);
927 .float actual_damage[WEP_COUNT]; //amount of damage done
928 .float max_damage[WEP_COUNT]; //the maximum damage of the weapon
930 FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(actual_damage);
931 FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(max_damage);
934 float RadiusDamage_running;
935 float RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype, entity directhitentity)
936 // Returns total damage applies to creatures
946 float total_damage_to_creatures;
950 float stat_damagedone;
951 float stat_maxdamage;
953 if(RadiusDamage_running)
956 print("RadiusDamage called recursively!\n");
957 print("Expect stuff to go HORRIBLY wrong.\n");
958 print("Causing a stack trace...\n");
959 save = cvar_string("prvm_backtraceforwarnings");
960 cvar_set("prvm_backtraceforwarnings", "1");
961 fclose(-1); // calls VM_Warning
962 cvar_set("prvm_backtraceforwarnings", save);
967 RadiusDamage_running = 1;
969 blastorigin = (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5);
970 total_damage_to_creatures = 0;
972 if(deathtype != (WEP_HOOK | HITTYPE_SECONDARY | HITTYPE_BOUNCE)) // only send gravity bomb damage once
974 force = inflictor.velocity;
978 force = normalize(force);
979 if(forceintensity >= 0)
980 Damage_DamageInfo(blastorigin, coredamage, edgedamage, rad, forceintensity * force, deathtype, attacker);
982 Damage_DamageInfo(blastorigin, coredamage, edgedamage, -rad, (-forceintensity) * force, deathtype, attacker);
988 targ = findradius (blastorigin, rad);
992 if (targ != inflictor)
995 // LordHavoc: measure distance to nearest point on target (not origin)
996 // (this guarentees 100% damage on a touch impact)
997 nearest = NearestPointOnBox(targ, blastorigin);
998 diff = nearest - blastorigin;
999 // round up a little on the damage to ensure full damage on impacts
1000 // and turn the distance into a fraction of the radius
1001 power = 1 - ((vlen (diff) - 2) / rad);
1003 //bprint(ftos(power));
1008 finaldmg = coredamage * power + edgedamage * (1 - power);
1011 center = targ.origin + (targ.mins + targ.maxs) * 0.5;
1012 // if it's a player, use the view origin as reference
1013 if (targ.classname == "player")
1014 center = targ.origin + targ.view_ofs;
1015 force = normalize(center - blastorigin) * (finaldmg / coredamage) * forceintensity;
1016 // test line of sight to multiple positions on box,
1017 // and do damage if any of them hit
1019 c = ceil(finaldmg / 10);
1025 traceline(blastorigin, nearest, TRUE, inflictor);
1026 if (trace_fraction == 1 || trace_ent == targ
1027 || cvar("g_throughfloor"))
1031 total_damage_to_creatures += finaldmg;
1033 if(targ.flags & FL_CLIENT)
1034 if(targ.deadflag == DEAD_NO)
1035 if(targ != attacker)
1036 if(!teamplay || targ.team != attacker.team)
1038 stat_damagedone += finaldmg;
1039 stat_maxdamage += coredamage;
1043 if(targ == directhitentity || DEATH_ISSPECIAL(deathtype))
1044 Damage (targ, inflictor, attacker, finaldmg, deathtype, nearest, force);
1046 Damage (targ, inflictor, attacker, finaldmg, deathtype | HITTYPE_SPLASH, nearest, force);
1049 nearest_x = targ.mins_x + random() * targ.size_x;
1050 nearest_y = targ.mins_y + random() * targ.size_y;
1051 nearest_z = targ.mins_z + random() * targ.size_z;
1059 RadiusDamage_running = 0;
1061 weaponid = DEATH_WEAPONOF(deathtype);
1063 // Calculates stats for all RadiusDamage weapons
1064 if not(inWarmupStage)
1066 if(clienttype(attacker) == CLIENTTYPE_REAL)
1068 // Track damage done and update the stat to be sent later in g_world.qc
1069 float f = min(stat_maxdamage, stat_damagedone);
1070 attacker.actual_damage[weaponid] += f; // value temporarily stored in f due to a ftqecc bug
1071 attacker.damage_hits = weaponid + 64 * rint(attacker.actual_damage[weaponid]);
1074 return total_damage_to_creatures;