1 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
3 float checkrules_firstblood;
7 float damage_gooddamage;
9 float damage_headshotbonus; // bonus multiplier for head shots, set to 0 after use
12 .float teamkill_complain;
13 .float teamkill_soundtime;
14 .entity teamkill_soundsource;
16 .float taunt_soundtime;
19 float IsDifferentTeam(entity a, entity b)
34 float IsFlying(entity a)
36 if(a.flags & FL_ONGROUND)
40 traceline(a.origin, a.origin - '0 0 48', MOVE_NORMAL, a);
41 if(trace_fraction < 1)
46 void UpdateFrags(entity player, float f)
48 PlayerTeamScore_AddScore(player, f);
51 // NOTE: f=0 means still count as a (positive) kill, but count no frags for it
52 void GiveFrags (entity attacker, entity targ, float f)
54 // TODO route through PlayerScores instead
62 PlayerScore_Add(attacker, SP_SUICIDES, 1);
67 PlayerScore_Add(attacker, SP_KILLS, -1); // or maybe add a teamkills field?
73 PlayerScore_Add(attacker, SP_KILLS, 1);
76 PlayerScore_Add(targ, SP_DEATHS, 1);
79 if(cvar("g_arena_roundbased"))
82 // FIXME fix the mess this is (we have REAL points now!)
85 f = RunematchHandleFrags(attacker, targ, f);
89 f = kh_HandleFrags(attacker, targ, f);
95 tl = PlayerScore_Add(targ, SP_LMS_LIVES, -1);
96 if(tl < lms_lowest_lives)
97 lms_lowest_lives = tl;
101 lms_next_place = player_count;
102 PlayerScore_Add(targ, SP_LMS_RANK, lms_next_place); // won't ever spawn again
109 if(g_ctf_ignore_frags)
113 attacker.totalfrags += f;
116 UpdateFrags(attacker, f);
119 string AppendItemcodes(string s, entity player)
124 // w = player.switchweapon;
126 w = player.cnt; // previous weapon!
127 s = strcat(s, ftos(w));
128 if(time < player.strength_finished)
130 if(time < player.invincible_finished)
132 if(player.flagcarried != world)
134 if(player.BUTTON_CHAT)
139 s = strcat(s, "|", ftos(player.runes));
143 void LogDeath(string mode, float deathtype, entity killer, entity killed)
146 if(!cvar("sv_eventlog"))
148 s = strcat(":kill:", mode);
149 s = strcat(s, ":", ftos(killer.playerid));
150 s = strcat(s, ":", ftos(killed.playerid));
151 s = strcat(s, ":type=", ftos(deathtype));
152 s = strcat(s, ":items=");
153 s = AppendItemcodes(s, killer);
156 s = strcat(s, ":victimitems=");
157 s = AppendItemcodes(s, killed);
162 void Obituary (entity attacker, entity inflictor, entity targ, float deathtype)
167 if (targ.classname == "player" || targ.classname == "corpse")
169 if (targ.classname == "corpse")
173 a = attacker.netname;
175 if (targ == attacker)
177 if (deathtype == DEATH_TEAMCHANGE) {
178 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", ColoredTeamName(targ.team)));
179 } else if (deathtype == DEATH_AUTOTEAMCHANGE) {
180 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)));
182 } else if (deathtype == DEATH_CAMP) {
184 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
186 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
187 } else if (deathtype == DEATH_NOAMMO) {
189 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
191 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
192 } else if (deathtype == DEATH_ROT) {
194 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
196 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
197 } else if (deathtype == DEATH_MIRRORDAMAGE) {
199 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
201 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
204 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
206 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
210 if (deathtype == DEATH_CAMP)
211 bprint ("^1",s, "^1 thought he found a nice camping ground\n");
212 else if (deathtype == DEATH_MIRRORDAMAGE)
213 bprint ("^1",s, "^1 didn't become friends with the Lord of Teamplay\n");
215 bprint ("^1",s, "^1 will be reinserted into the game due to his own actions\n");
217 if(deathtype != DEATH_TEAMCHANGE)
219 LogDeath("suicide", deathtype, targ, targ);
220 GiveFrags(attacker, targ, -1);
222 if (targ.killcount > 2)
223 bprint ("^1",s,"^1 faded after a ",ftos(targ.killcount)," point spree\n");
225 w = DEATH_WEAPONOF(deathtype);
228 w_deathtypestring = "couldn't resist the urge to self-destruct";
229 w_deathtype = deathtype;
230 weapon_action(w, WR_SUICIDEMESSAGE);
231 bprint("^1", s, "^1 ", w_deathtypestring, "\n");
233 else if (deathtype == DEATH_KILL)
234 bprint ("^1",s, "^1 couldn't take it anymore\n");
235 else if (deathtype == DEATH_ROT)
236 bprint ("^1",s, "^1 died\n");
237 else if (deathtype == DEATH_NOAMMO)
238 bprint ("^7",s, "^7 committed suicide. What's the point of living without ammo?\n");
239 else if (deathtype == DEATH_CAMP)
240 bprint ("^1",s, "^1 thought he found a nice camping ground\n");
241 else if (deathtype == DEATH_MIRRORDAMAGE)
242 bprint ("^1",s, "^1 didn't become friends with the Lord of Teamplay\n");
243 else if (deathtype != DEATH_TEAMCHANGE)
244 bprint ("^1",s, "^1 couldn't resist the urge to self-destruct\n");
246 if(deathtype != DEATH_TEAMCHANGE)
248 LogDeath("suicide", deathtype, targ, targ);
249 GiveFrags(attacker, targ, -1);
251 if (targ.killcount > 2)
252 bprint ("^1",s,"^1 ended it all after a ",ftos(targ.killcount)," kill spree\n");
255 else if (attacker.classname == "player" || attacker.classname == "gib")
257 if(teamplay && attacker.team == targ.team)
260 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against a team mate!"));
261 bprint ("^1", a, "^1 took action against a team mate\n");
263 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s, ", a team mate!"));
264 bprint ("^1", a, "^1 mows down a team mate\n");
266 GiveFrags(attacker, targ, -1);
267 if (targ.killcount > 2) {
269 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," scoring spree was ended by a team mate!\n");
271 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," kill spree was ended by a team mate!\n");
273 if (attacker.killcount > 2) {
275 bprint ("^1",a,"^1 ended a ",ftos(attacker.killcount)," scoring spree by going against a team mate\n");
277 bprint ("^1",a,"^1 ended a ",ftos(attacker.killcount)," kill spree by killing a team mate\n");
279 attacker.killcount = 0;
281 LogDeath("tk", deathtype, attacker, targ);
285 string blood_message, victim_message;
286 if (!checkrules_firstblood)
288 checkrules_firstblood = TRUE;
291 bprint("^1",a, "^1 was the first to score", "\n");
292 blood_message = "^1First point\n";
293 //victim_message = "^1First victim\n"; // or First casualty
297 bprint("^1",a, "^1 drew first blood", "\n");
298 blood_message = "^1First blood\n";
299 victim_message = "^1First victim\n"; // or First casualty
304 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s));
305 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, a,"^1 scored against you ^7"));
307 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, blood_message, "^4You fragged ^7", s));
308 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, victim_message, "^1You were fragged by ^7", a));
309 attacker.taunt_soundtime = time + 1;
313 bprint ("^1",s, "^1 needs a restart thanks to ", a, "\n");
315 w = DEATH_WEAPONOF(deathtype);
318 w_deathtypestring = "was blasted by";
319 w_deathtype = deathtype;
320 weapon_action(w, WR_KILLMESSAGE);
321 p = strstrofs(w_deathtypestring, "#", 0);
323 bprint("^1", s, "^1 ", w_deathtypestring, " ", a, "\n");
325 bprint("^1", s, "^1 ", substring(w_deathtypestring, 0, p), a, "^1", substring(w_deathtypestring, p+1, strlen(w_deathtypestring) - (p+1)), "\n");
327 else if (deathtype == DEATH_TELEFRAG)
328 bprint ("^1",s, "^1 was telefragged by ", a, "\n");
329 else if (deathtype == DEATH_DROWN)
330 bprint ("^1",s, "^1 was drowned by ", a, "\n");
331 else if (deathtype == DEATH_SLIME)
332 bprint ("^1",s, "^1 was slimed by ", a, "\n");
333 else if (deathtype == DEATH_LAVA)
334 bprint ("^1",s, "^1 was cooked by ", a, "\n");
335 else if (deathtype == DEATH_FALL)
336 bprint ("^1",s, "^1 was grounded by ", a, "\n");
337 else if (deathtype == DEATH_SHOOTING_STAR)
338 bprint ("^1",s, "^1 was shot into space by ", a, "\n");
339 else if (deathtype == DEATH_SWAMP)
340 bprint ("^1",s, "^1 was conserved by ", a, "\n");
341 else if (deathtype == DEATH_HURTTRIGGER && inflictor.message2 != "")
343 p = strstrofs(inflictor.message2, "#", 0);
345 bprint("^1", s, "^1 ", inflictor.message2, " ", a, "\n");
347 bprint("^1", s, "^1 ", substring(inflictor.message2, 0, p), a, "^1", substring(inflictor.message2, p+1, strlen(inflictor.message2) - (p+1)), "\n");
349 else if(deathtype == DEATH_TURRET)
350 bprint ("^1",s, "^1 was pushed into the line of fire by ^1", a, "\n");
351 else if(deathtype == DEATH_TOUCHEXPLODE)
352 bprint ("^1",s, "^1 was pushed into an accident by ^1", a, "\n");
354 bprint ("^1",s, "^1 was fragged by ", a, "\n");
357 if(g_ctf && targ.flagcarried)
359 UpdateFrags(attacker, ctf_score_value("score_kill"));
360 PlayerScore_Add(attacker, SP_CTF_FCKILLS, 1);
361 GiveFrags(attacker, targ, 0); // for logging
364 GiveFrags(attacker, targ, 1);
366 if (targ.killcount > 2) {
368 bprint ("^1",s,"'s ^1", ftos(targ.killcount), " scoring spree was ended by ", a, "\n");
370 bprint ("^1",s,"'s ^1", ftos(targ.killcount), " kill spree was ended by ", a, "\n");
373 attacker.killcount = attacker.killcount + 1;
375 if (attacker.killcount > 2) {
377 bprint ("^1",a,"^1 made ",ftos(attacker.killcount)," scores in a row\n");
379 bprint ("^1",a,"^1 has ",ftos(attacker.killcount)," frags in a row\n");
382 LogDeath("frag", deathtype, attacker, targ);
384 if (attacker.killcount == 3)
387 bprint (a,"^7 made a ^1TRIPLE SCORE\n");
389 bprint (a,"^7 made a ^1TRIPLE FRAG\n");
390 announce(attacker, "announcer/male/03kills.wav");
393 else if (attacker.killcount == 5)
396 bprint (a,"^7 unleashes ^1SCORING RAGE\n");
398 bprint (a,"^7 unleashes ^1RAGE\n");
399 announce(attacker, "announcer/male/05kills.wav");
402 else if (attacker.killcount == 10)
405 bprint (a,"^7 made ^1TEN SCORES IN A ROW!\n");
407 bprint (a,"^7 starts the ^1MASSACRE!\n");
408 announce(attacker, "announcer/male/10kills.wav");
411 else if (attacker.killcount == 15)
414 bprint (a,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
416 bprint (a,"^7 executes ^1MAYHEM!\n");
417 announce(attacker, "announcer/male/15kills.wav");
420 else if (attacker.killcount == 20)
423 bprint (a,"^7 made ^1TWENTY SCORES IN A ROW!\n");
425 bprint (a,"^7 is a ^1BERSERKER!\n");
426 announce(attacker, "announcer/male/20kills.wav");
429 else if (attacker.killcount == 25)
432 bprint (a,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
434 bprint (a,"^7 inflicts ^1CARNAGE!\n");
435 announce(attacker, "announcer/male/25kills.wav");
438 else if (attacker.killcount == 30)
441 bprint (a,"^7 made ^1THIRTY SCORES IN A ROW!\n");
443 bprint (a,"^7 unleashes ^1ARMAGEDDON!\n");
444 announce(attacker, "announcer/male/30kills.wav");
451 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
452 if (deathtype == DEATH_HURTTRIGGER && inflictor.message != "")
453 bprint ("^1",s, "^1 ", inflictor.message, "\n");
454 else if (deathtype == DEATH_DROWN)
456 bprint ("^1",s, "^1 was in the water for too long\n");
458 bprint ("^1",s, "^1 drowned\n");
459 else if (deathtype == DEATH_SLIME)
460 bprint ("^1",s, "^1 was slimed\n");
461 else if (deathtype == DEATH_LAVA)
463 bprint ("^1",s, "^1 found a hot place\n");
465 bprint ("^1",s, "^1 turned into hot slag\n");
466 else if (deathtype == DEATH_FALL)
468 bprint ("^1",s, "^1 tested gravity (and it worked)\n");
470 bprint ("^1",s, "^1 hit the ground with a crunch\n");
471 else if (deathtype == DEATH_SHOOTING_STAR)
472 bprint ("^1",s, "^1 became a shooting star\n");
473 else if (deathtype == DEATH_SWAMP)
475 bprint ("^1",s, "^1 discovered a swamp\n");
477 bprint ("^1",s, "^1 is now conserved for centuries to come\n");
478 else if(deathtype == DEATH_TURRET)
479 bprint ("^1",s, "^1 was mowed down by a turret \n");
480 else if(deathtype == DEATH_TOUCHEXPLODE)
481 bprint ("^1",s, "^1 died in an accident\n");
484 bprint ("^1",s, "^1 needs a restart\n");
486 bprint ("^1",s, "^1 died\n");
487 GiveFrags(targ, targ, -1);
488 if(PlayerScore_Add(targ, SP_SCORE, 0) == -5) {
489 announce(targ, "announcer/male/botlike.wav");
492 if (targ.killcount > 2)
494 bprint ("^1",s,"^1 needs a restart after a ",ftos(targ.killcount)," scoring spree\n");
496 bprint ("^1",s,"^1 died with a ",ftos(targ.killcount)," kill spree\n");
498 LogDeath("accident", deathtype, targ, targ);
500 targ.death_origin = targ.origin;
502 targ.killer_origin = attacker.origin;
503 // FIXME: this should go in PutClientInServer
509 // these are updated by each Damage call for use in button triggering and such
511 entity damage_inflictor;
512 entity damage_attacker;
514 void Damage (entity targ, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
519 entity attacker_save;
523 if (gameover || targ.killcount == -666)
526 local entity oldself;
530 damage_inflictor = inflictor;
531 damage_attacker = attacker;
532 attacker_save = attacker;
534 if(targ.classname == "player")
537 if(targ.hook.aiment == attacker)
538 RemoveGrapplingHook(targ); // STOP THAT, you parasite!
540 // special rule: gravity bomb does not hit team mates (other than for disconnecting the hook)
541 if(DEATH_ISWEAPON(deathtype, WEP_HOOK))
543 if(targ.classname == "player")
544 if not(IsDifferentTeam(targ, attacker))
551 if(deathtype == DEATH_KILL || deathtype == DEATH_TEAMCHANGE || deathtype == DEATH_AUTOTEAMCHANGE)
553 // These are ALWAYS lethal
554 // No damage modification here
555 // Instead, prepare the victim for his death...
557 targ.spawnshieldtime = 0;
558 targ.health = 0.9; // this is < 1
559 targ.flags -= targ.flags & FL_GODMODE;
562 else if(deathtype == DEATH_MIRRORDAMAGE || deathtype == DEATH_NOAMMO)
568 if (targ.classname == "player")
569 if (attacker.classname == "player")
572 damage = damage * bound(0.1, (skill + 5) * 0.1, 1);
574 // nullify damage if teamplay is on
575 if(deathtype != DEATH_TELEFRAG)
576 if(attacker.classname == "player")
578 if(targ.classname == "player" && targ != attacker && (IS_INDEPENDENT_PLAYER(attacker) || IS_INDEPENDENT_PLAYER(targ)))
583 else if(attacker.team == targ.team)
587 else if(attacker != targ)
591 else if(teamplay == 4)
593 if(targ.classname == "player" && targ.deadflag == DEAD_NO)
595 teamdamage0 = max(attacker.dmg_team, cvar("g_teamdamage_threshold"));
596 attacker.dmg_team = attacker.dmg_team + damage;
597 if(attacker.dmg_team > teamdamage0)
598 mirrordamage = cvar("g_mirrordamage") * (attacker.dmg_team - teamdamage0);
599 mirrorforce = cvar("g_mirrordamage") * vlen(force);
602 if(cvar("g_friendlyfire") == 0)
606 damage = cvar("g_friendlyfire") * damage;
607 // mirrordamage will be used LATER
616 if(targ.classname == "player")
617 if(attacker.classname == "player")
620 targ.lms_traveled_distance = cvar("g_lms_campcheck_distance");
621 attacker.lms_traveled_distance = cvar("g_lms_campcheck_distance");
626 if ((deathtype == DEATH_FALL) ||
627 (deathtype == DEATH_DROWN) ||
628 (deathtype == DEATH_SLIME) ||
629 (deathtype == DEATH_LAVA))
634 if (targ.armorvalue && (deathtype == WEP_MINSTANEX) && damage)
636 targ.armorvalue -= 1;
637 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^3Remaining extra lives: ",ftos(targ.armorvalue)));
641 if (DEATH_ISWEAPON(deathtype, WEP_LASER))
644 if (targ != attacker)
646 if (targ.classname == "player")
647 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "Secondary fire inflicts no damage!"));
657 // apply strength multiplier
658 if ((attacker.items & IT_STRENGTH) && !g_minstagib)
662 damage = damage * cvar("g_balance_powerup_strength_selfdamage");
663 force = force * cvar("g_balance_powerup_strength_selfforce");
667 damage = damage * cvar("g_balance_powerup_strength_damage");
668 force = force * cvar("g_balance_powerup_strength_force");
672 // apply invincibility multiplier
673 if (targ.items & IT_INVINCIBLE && !g_minstagib)
674 damage = damage * cvar("g_balance_powerup_invincible_takedamage");
676 if (targ == attacker)
677 damage = damage * cvar("g_balance_selfdamagepercent"); // Partial damage if the attacker hits himself
679 // CTF: reduce damage/force
684 damage = damage * cvar("g_ctf_flagcarrier_selfdamage");
685 force = force * cvar("g_ctf_flagcarrier_selfforce");
690 // apply strength rune
691 if (attacker.runes & RUNE_STRENGTH)
693 if(attacker.runes & CURSE_WEAK) // have both curse & rune
695 damage = damage * cvar("g_balance_rune_strength_combo_damage");
696 force = force * cvar("g_balance_rune_strength_combo_force");
700 damage = damage * cvar("g_balance_rune_strength_damage");
701 force = force * cvar("g_balance_rune_strength_force");
704 else if (attacker.runes & CURSE_WEAK)
706 damage = damage * cvar("g_balance_curse_weak_damage");
707 force = force * cvar("g_balance_curse_weak_force");
710 // apply defense rune
711 if (targ.runes & RUNE_DEFENSE)
713 if (targ.runes & CURSE_VULNER) // have both curse & rune
714 damage = damage * cvar("g_balance_rune_defense_combo_takedamage");
716 damage = damage * cvar("g_balance_rune_defense_takedamage");
718 else if (targ.runes & CURSE_VULNER)
719 damage = damage * cvar("g_balance_curse_vulner_takedamage");
725 if(targ.takedamage == DAMAGE_AIM)
727 if(targ.classname == "player")
729 if(IsDifferentTeam(targ, attacker))
734 attacker.typehitsound += 1;
736 attacker.hitsound += 1;
738 damage_goodhits += 1;
739 damage_gooddamage += damage;
741 if not(DEATH_ISSPECIAL(deathtype))
748 if(targ.items & IT_STRENGTH)
752 // find height of hit on player axis
753 // if above view_ofs and below maxs, and also in the middle half of the bbox, it is head shot
754 vector headmins, headmaxs, org;
755 org = antilag_takebackorigin(targ, time - ANTILAG_LATENCY(attacker));
756 headmins = org + '0.7 0 0' * targ.mins_x + '0 0.7 0' * targ.mins_y + '0 0 1' * targ.view_ofs_z;
757 headmaxs = org + '0.7 0 0' * targ.maxs_x + '0 0.7 0' * targ.maxs_y + '0 0 1' * targ.maxs_z;
758 if(trace_hits_box(railgun_start, railgun_end, headmins, headmaxs))
760 damage *= 1 + damage_headshotbonus;
762 deathtype |= HITTYPE_HEADSHOT;
769 attacker.typehitsound += 1;
771 if(time > attacker.teamkill_complain)
773 attacker.teamkill_complain = time + 5;
774 attacker.teamkill_soundtime = time + 0.4;
775 attacker.teamkill_soundsource = targ;
782 if (self.damageforcescale)
785 self.velocity = self.velocity + self.damageforcescale * force;
786 self.flags = self.flags - (self.flags & FL_ONGROUND);
787 UpdateCSQCProjectile(self);
791 if (self.event_damage)
792 self.event_damage (inflictor, attacker, damage, deathtype, hitloc, force);
795 if(targ.classname == "player" && attacker.classname == "player" && attacker != targ && attacker.health > 2)
797 // Savage: vampire mode
800 if (time > self.spawnshieldtime)
802 attacker.health += damage;
806 if (attacker.runes & RUNE_VAMPIRE)
808 // apply vampire rune
809 if (attacker.runes & CURSE_EMPATHY) // have the curse too
811 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb");
812 attacker.health = bound(
813 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 40
814 attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb"),
815 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
819 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_absorb");
820 attacker.health = bound(
821 attacker.health, // LA: was 3, but changed so that you can't lose health
822 // empathy won't let you gain health in the same way...
823 attacker.health + damage * cvar("g_balance_rune_vampire_absorb"),
824 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
827 // apply empathy curse
828 else if (attacker.runes & CURSE_EMPATHY)
830 attacker.health = bound(
831 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 20
832 attacker.health + damage * cvar("g_balance_curse_empathy_takedamage"),
838 // apply mirror damage if any
839 if(mirrordamage > 0 || mirrorforce > 0)
841 attacker = attacker_save;
845 // just lose extra LIVES, don't kill the player for mirror damage
846 if(attacker.armorvalue > 0)
848 attacker.armorvalue = attacker.armorvalue - 1;
849 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^3Remaining extra lives: ",ftos(attacker.armorvalue)));
850 attacker.hitsound += 1;
854 force = normalize(attacker.origin + attacker.view_ofs - hitloc) * mirrorforce;
855 Damage(attacker, inflictor, attacker, mirrordamage, DEATH_MIRRORDAMAGE, attacker.origin, force);
859 vector NearestPointOnBox(entity box, vector org)
861 vector m1, m2, nearest;
863 m1 = box.mins + box.origin;
864 m2 = box.maxs + box.origin;
866 nearest_x = bound(m1_x, org_x, m2_x);
867 nearest_y = bound(m1_y, org_y, m2_y);
868 nearest_z = bound(m1_z, org_z, m2_z);
873 float RadiusDamage_running;
874 float RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype, entity directhitentity)
875 // Returns total damage applies to creatures
885 float total_damage_to_creatures;
888 if(RadiusDamage_running)
891 print("RadiusDamage called recursively!\n");
892 print("Expect stuff to go HORRIBLY wrong.\n");
893 print("Causing a stack trace...\n");
894 save = cvar_string("prvm_backtraceforwarnings");
895 cvar_set("prvm_backtraceforwarnings", "1");
896 fclose(-1); // calls VM_Warning
897 cvar_set("prvm_backtraceforwarnings", save);
901 RadiusDamage_running = 1;
903 blastorigin = (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5);
904 total_damage_to_creatures = 0;
906 targ = findradius (blastorigin, rad);
910 if (targ != inflictor)
913 // LordHavoc: measure distance to nearest point on target (not origin)
914 // (this guarentees 100% damage on a touch impact)
915 nearest = NearestPointOnBox(targ, blastorigin);
916 diff = nearest - blastorigin;
917 // round up a little on the damage to ensure full damage on impacts
918 // and turn the distance into a fraction of the radius
919 power = 1 - ((vlen (diff) - 2) / rad);
921 //bprint(ftos(power));
926 finaldmg = coredamage * power + edgedamage * (1 - power);
929 center = targ.origin + (targ.mins + targ.maxs) * 0.5;
930 // if it's a player, use the view origin as reference
931 if (targ.classname == "player")
932 center = targ.origin + targ.view_ofs;
933 force = normalize(center - blastorigin) * (finaldmg / coredamage) * forceintensity;
934 // test line of sight to multiple positions on box,
935 // and do damage if any of them hit
937 c = ceil(finaldmg / 10);
943 traceline(blastorigin, nearest, TRUE, inflictor);
944 if (trace_fraction == 1 || trace_ent == targ
945 || cvar("g_throughfloor"))
948 total_damage_to_creatures += finaldmg;
949 if(targ == directhitentity || DEATH_ISSPECIAL(deathtype))
950 Damage (targ, inflictor, attacker, finaldmg, deathtype, nearest, force);
952 Damage (targ, inflictor, attacker, finaldmg, deathtype | HITTYPE_SPLASH, nearest, force);
955 nearest_x = targ.mins_x + random() * targ.size_x;
956 nearest_y = targ.mins_y + random() * targ.size_y;
957 nearest_z = targ.mins_z + random() * targ.size_z;
965 RadiusDamage_running = 0;
967 return total_damage_to_creatures;