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))
710 damage *= g_weapondamagefactor;
711 mirrordamage *= g_weapondamagefactor;
712 force = force * g_weaponforcefactor;
713 mirrorforce *= g_weaponforcefactor;
716 // apply strength multiplier
717 if ((attacker.items & IT_STRENGTH) && !g_minstagib)
721 damage = damage * cvar("g_balance_powerup_strength_selfdamage");
722 force = force * cvar("g_balance_powerup_strength_selfforce");
726 damage = damage * cvar("g_balance_powerup_strength_damage");
727 force = force * cvar("g_balance_powerup_strength_force");
731 // apply invincibility multiplier
732 if (targ.items & IT_INVINCIBLE && !g_minstagib)
733 damage = damage * cvar("g_balance_powerup_invincible_takedamage");
735 if (targ == attacker)
736 damage = damage * cvar("g_balance_selfdamagepercent"); // Partial damage if the attacker hits himself
738 // CTF: reduce damage/force
743 damage = damage * cvar("g_ctf_flagcarrier_selfdamage");
744 force = force * cvar("g_ctf_flagcarrier_selfforce");
749 // apply strength rune
750 if (attacker.runes & RUNE_STRENGTH)
752 if(attacker.runes & CURSE_WEAK) // have both curse & rune
754 damage = damage * cvar("g_balance_rune_strength_combo_damage");
755 force = force * cvar("g_balance_rune_strength_combo_force");
759 damage = damage * cvar("g_balance_rune_strength_damage");
760 force = force * cvar("g_balance_rune_strength_force");
763 else if (attacker.runes & CURSE_WEAK)
765 damage = damage * cvar("g_balance_curse_weak_damage");
766 force = force * cvar("g_balance_curse_weak_force");
769 // apply defense rune
770 if (targ.runes & RUNE_DEFENSE)
772 if (targ.runes & CURSE_VULNER) // have both curse & rune
773 damage = damage * cvar("g_balance_rune_defense_combo_takedamage");
775 damage = damage * cvar("g_balance_rune_defense_takedamage");
777 else if (targ.runes & CURSE_VULNER)
778 damage = damage * cvar("g_balance_curse_vulner_takedamage");
784 if(targ.takedamage == DAMAGE_AIM)
786 if(targ.classname == "player")
788 if(IsDifferentTeam(targ, attacker))
793 attacker.typehitsound += 1;
795 attacker.hitsound += 1;
797 damage_goodhits += 1;
798 damage_gooddamage += damage;
800 if not(DEATH_ISSPECIAL(deathtype))
807 if(targ.items & IT_STRENGTH)
811 // find height of hit on player axis
812 // if above view_ofs and below maxs, and also in the middle half of the bbox, it is head shot
813 vector headmins, headmaxs, org;
814 org = antilag_takebackorigin(targ, time - ANTILAG_LATENCY(attacker));
815 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);
816 headmaxs = org + '0.7 0 0' * targ.maxs_x + '0 0.7 0' * targ.maxs_y + '0 0 1' * targ.maxs_z;
817 if(trace_hits_box(railgun_start, railgun_end, headmins, headmaxs))
819 damage *= 1 + damage_headshotbonus;
821 deathtype |= HITTYPE_HEADSHOT;
828 attacker.typehitsound += 1;
830 if(time > attacker.teamkill_complain)
832 attacker.teamkill_complain = time + 5;
833 attacker.teamkill_soundtime = time + 0.4;
834 attacker.teamkill_soundsource = targ;
841 if (self.damageforcescale)
844 self.velocity = self.velocity + self.damageforcescale * force;
845 self.flags &~= FL_ONGROUND;
846 UpdateCSQCProjectile(self);
849 if (damage != 0 || (self.damageforcescale && vlen(force)))
850 if (self.event_damage)
851 self.event_damage (inflictor, attacker, damage, deathtype, hitloc, force);
854 if(targ.classname == "player" && attacker.classname == "player" && attacker != targ && attacker.health > 2)
856 // Savage: vampire mode
859 if (time > self.spawnshieldtime)
861 attacker.health += damage;
865 if (attacker.runes & RUNE_VAMPIRE)
867 // apply vampire rune
868 if (attacker.runes & CURSE_EMPATHY) // have the curse too
870 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb");
871 attacker.health = bound(
872 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 40
873 attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb"),
874 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
878 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_absorb");
879 attacker.health = bound(
880 attacker.health, // LA: was 3, but changed so that you can't lose health
881 // empathy won't let you gain health in the same way...
882 attacker.health + damage * cvar("g_balance_rune_vampire_absorb"),
883 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
886 // apply empathy curse
887 else if (attacker.runes & CURSE_EMPATHY)
889 attacker.health = bound(
890 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 20
891 attacker.health + damage * cvar("g_balance_curse_empathy_takedamage"),
897 // apply mirror damage if any
898 if(mirrordamage > 0 || mirrorforce > 0)
900 attacker = attacker_save;
904 // just lose extra LIVES, don't kill the player for mirror damage
905 if(attacker.armorvalue > 0)
907 attacker.armorvalue = attacker.armorvalue - 1;
908 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^3Remaining extra lives: ",ftos(attacker.armorvalue)));
909 attacker.hitsound += 1;
913 force = normalize(attacker.origin + attacker.view_ofs - hitloc) * mirrorforce;
914 Damage(attacker, inflictor, attacker, mirrordamage, DEATH_MIRRORDAMAGE, attacker.origin, force);
918 vector NearestPointOnBox(entity box, vector org)
920 vector m1, m2, nearest;
922 m1 = box.mins + box.origin;
923 m2 = box.maxs + box.origin;
925 nearest_x = bound(m1_x, org_x, m2_x);
926 nearest_y = bound(m1_y, org_y, m2_y);
927 nearest_z = bound(m1_z, org_z, m2_z);
932 .float actual_damage[WEP_COUNT]; //amount of damage done
933 .float max_damage[WEP_COUNT]; //the maximum damage of the weapon
935 FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(actual_damage);
936 FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(max_damage);
939 float RadiusDamage_running;
940 float RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype, entity directhitentity)
941 // Returns total damage applies to creatures
951 float total_damage_to_creatures;
955 float stat_damagedone;
956 float stat_maxdamage;
958 if(RadiusDamage_running)
961 print("RadiusDamage called recursively!\n");
962 print("Expect stuff to go HORRIBLY wrong.\n");
963 print("Causing a stack trace...\n");
964 save = cvar_string("prvm_backtraceforwarnings");
965 cvar_set("prvm_backtraceforwarnings", "1");
966 fclose(-1); // calls VM_Warning
967 cvar_set("prvm_backtraceforwarnings", save);
972 RadiusDamage_running = 1;
974 blastorigin = (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5);
975 total_damage_to_creatures = 0;
977 if(deathtype != (WEP_HOOK | HITTYPE_SECONDARY | HITTYPE_BOUNCE)) // only send gravity bomb damage once
979 force = inflictor.velocity;
983 force = normalize(force);
984 if(forceintensity >= 0)
985 Damage_DamageInfo(blastorigin, coredamage, edgedamage, rad, forceintensity * force, deathtype, attacker);
987 Damage_DamageInfo(blastorigin, coredamage, edgedamage, -rad, (-forceintensity) * force, deathtype, attacker);
993 targ = findradius (blastorigin, rad);
997 if (targ != inflictor)
1000 // LordHavoc: measure distance to nearest point on target (not origin)
1001 // (this guarentees 100% damage on a touch impact)
1002 nearest = NearestPointOnBox(targ, blastorigin);
1003 diff = nearest - blastorigin;
1004 // round up a little on the damage to ensure full damage on impacts
1005 // and turn the distance into a fraction of the radius
1006 power = 1 - ((vlen (diff) - 2) / rad);
1008 //bprint(ftos(power));
1013 finaldmg = coredamage * power + edgedamage * (1 - power);
1016 center = targ.origin + (targ.mins + targ.maxs) * 0.5;
1017 // if it's a player, use the view origin as reference
1018 if (targ.classname == "player")
1019 center = targ.origin + targ.view_ofs;
1020 force = normalize(center - blastorigin) * (finaldmg / coredamage) * forceintensity;
1021 // test line of sight to multiple positions on box,
1022 // and do damage if any of them hit
1024 c = ceil(finaldmg / 10);
1030 traceline(blastorigin, nearest, TRUE, inflictor);
1031 if (trace_fraction == 1 || trace_ent == targ
1032 || cvar("g_throughfloor"))
1036 total_damage_to_creatures += finaldmg;
1038 if(targ.flags & FL_CLIENT)
1039 if(targ.deadflag == DEAD_NO)
1040 if(targ != attacker)
1041 if(!teamplay || targ.team != attacker.team)
1043 stat_damagedone += finaldmg;
1044 stat_maxdamage += coredamage;
1048 if(targ == directhitentity || DEATH_ISSPECIAL(deathtype))
1049 Damage (targ, inflictor, attacker, finaldmg, deathtype, nearest, force);
1051 Damage (targ, inflictor, attacker, finaldmg, deathtype | HITTYPE_SPLASH, nearest, force);
1054 nearest_x = targ.mins_x + random() * targ.size_x;
1055 nearest_y = targ.mins_y + random() * targ.size_y;
1056 nearest_z = targ.mins_z + random() * targ.size_z;
1064 RadiusDamage_running = 0;
1066 weaponid = DEATH_WEAPONOF(deathtype);
1068 // Calculates stats for all RadiusDamage weapons
1069 if not(inWarmupStage)
1071 if(clienttype(attacker) == CLIENTTYPE_REAL)
1073 // Track damage done and update the stat to be sent later in g_world.qc
1074 float f = min(stat_maxdamage, stat_damagedone);
1075 attacker.actual_damage[weaponid] += f; // value temporarily stored in f due to a ftqecc bug
1076 attacker.damage_hits = weaponid + 64 * rint(attacker.actual_damage[weaponid]);
1079 return total_damage_to_creatures;