1 float checkrules_firstblood;
5 float damage_gooddamage;
8 .float teamkill_complain;
9 .float teamkill_soundtime;
10 .entity teamkill_soundsource;
14 float IsDifferentTeam(entity a, entity b)
29 float IsFlying(entity a)
31 if(a.flags & FL_ONGROUND)
35 traceline(a.origin, a.origin - '0 0 48', MOVE_NORMAL, a);
36 if(trace_fraction < 1)
41 void UpdateFrags(entity player, float f)
43 PlayerTeamScore_AddScore(player, f);
46 // NOTE: f=0 means still count as a (positive) kill, but count no frags for it
47 void GiveFrags (entity attacker, entity targ, float f)
49 // TODO route through PlayerScores instead
57 PlayerScore_Add(attacker, SP_SUICIDES, 1);
62 PlayerScore_Add(attacker, SP_KILLS, -1); // or maybe add a teamkills field?
68 PlayerScore_Add(attacker, SP_KILLS, 1);
71 PlayerScore_Add(targ, SP_DEATHS, 1);
74 if(cvar("g_arena_roundbased"))
77 // FIXME fix the mess this is (we have REAL points now!)
80 f = RunematchHandleFrags(attacker, targ, f);
84 f = kh_HandleFrags(attacker, targ, f);
90 tl = PlayerScore_Add(targ, SP_LMS_LIVES, -1);
91 if(tl < lms_lowest_lives)
92 lms_lowest_lives = tl;
96 lms_next_place = player_count;
97 PlayerScore_Add(targ, SP_LMS_RANK, lms_next_place); // won't ever spawn again
104 if(g_ctf_ignore_frags)
108 attacker.totalfrags += f;
111 UpdateFrags(attacker, f);
114 string AppendItemcodes(string s, entity player)
119 // w = player.switchweapon;
121 w = player.cnt; // previous weapon!
122 s = strcat(s, ftos(w));
123 if(time < player.strength_finished)
125 if(time < player.invincible_finished)
127 if(player.flagcarried != world)
129 if(player.BUTTON_CHAT)
134 s = strcat(s, "|", ftos(player.runes));
138 void LogDeath(string mode, float deathtype, entity killer, entity killed)
141 if(!cvar("sv_eventlog"))
143 s = strcat(":kill:", mode);
144 s = strcat(s, ":", ftos(killer.playerid));
145 s = strcat(s, ":", ftos(killed.playerid));
146 s = strcat(s, ":type=", ftos(deathtype));
147 s = strcat(s, ":items=");
148 s = AppendItemcodes(s, killer);
151 s = strcat(s, ":victimitems=");
152 s = AppendItemcodes(s, killed);
157 void Obituary (entity attacker, entity inflictor, entity targ, float deathtype)
162 if (targ.classname == "player" || targ.classname == "corpse")
164 if (targ.classname == "corpse")
168 a = attacker.netname;
170 if (targ == attacker)
172 if (deathtype == DEATH_TEAMCHANGE) {
173 centerprint(targ, strcat("You are now on: ", ColoredTeamName(targ.team)));
174 } else if (deathtype == DEATH_AUTOTEAMCHANGE) {
175 centerprint(targ, strcat("You have been moved into a different team to improve team balance\nYou are now on: ", ColoredTeamName(targ.team)));
177 } else if (deathtype == DEATH_CAMP) {
179 centerprint(targ, "^1Reconsider your tactics, camper!\n\n\n");
181 centerprint(targ, "^1Die camper!\n\n\n");
182 } else if (deathtype == DEATH_NOAMMO) {
184 centerprint(targ, "^1You are reinserted into the game for running out of ammo...\n\n\n");
186 centerprint(targ, "^1You were killed for running out of ammo...\n\n\n");
187 } else if (deathtype == DEATH_ROT) {
189 centerprint(targ, "^1You need to preserve your health\n\n\n");
191 centerprint(targ, "^1You grew too old without taking your medicine\n\n\n");
192 } else if (deathtype == DEATH_MIRRORDAMAGE) {
194 centerprint(targ, "^1Don't go against team mates!\n\n\n");
196 centerprint(targ, "^1Don't shoot your team mates!\n\n\n");
199 centerprint(targ, "^1You need to be more careful!\n\n\n");
201 centerprint(targ, "^1You killed your own dumb self!\n\n\n");
205 if (deathtype == DEATH_CAMP)
206 bprint ("^1",s, "^1 thought he found a nice camping ground\n");
207 else if (deathtype == DEATH_MIRRORDAMAGE)
208 bprint ("^1",s, "^1 didn't become friends with the Lord of Teamplay\n");
210 bprint ("^1",s, "^1 will be reinserted into the game due to his own actions\n");
212 if(deathtype != DEATH_TEAMCHANGE)
214 LogDeath("suicide", deathtype, targ, targ);
215 GiveFrags(attacker, targ, -1);
217 if (targ.killcount > 2)
218 bprint ("^1",s,"^1 ended it all with a ",ftos(targ.killcount)," scoring spree\n");
220 w = DEATH_WEAPONOF(deathtype);
223 w_deathtypestring = "couldn't resist the urge to self-destruct";
224 w_deathtype = deathtype;
225 weapon_action(w, WR_SUICIDEMESSAGE);
226 bprint("^1", s, "^1 ", w_deathtypestring, "\n");
228 else if (deathtype == DEATH_KILL)
229 bprint ("^1",s, "^1 couldn't take it anymore\n");
230 else if (deathtype == DEATH_ROT)
231 bprint ("^1",s, "^1 died\n");
232 else if (deathtype == DEATH_NOAMMO)
234 bprint ("^7",s, " ^7committed suicide. What's the point of living without ammo?\n");
236 else if (deathtype == DEATH_CAMP)
237 bprint ("^1",s, "^1 thought he found a nice camping ground\n");
238 else if (deathtype == DEATH_MIRRORDAMAGE)
239 bprint ("^1",s, "^1 didn't become friends with the Lord of Teamplay\n");
240 else if (deathtype != DEATH_TEAMCHANGE)
241 bprint ("^1",s, "^1 couldn't resist the urge to self-destruct\n");
243 if(deathtype != DEATH_TEAMCHANGE)
245 LogDeath("suicide", deathtype, targ, targ);
246 GiveFrags(attacker, targ, -1);
248 if (targ.killcount > 2)
249 bprint ("^1",s,"^1 ended it all with a ",ftos(targ.killcount)," kill spree\n");
252 else if (attacker.classname == "player" || attacker.classname == "gib")
254 if(teamplay && attacker.team == targ.team)
257 centerprint(attacker, "^1Moron! You went against a teammate!\n\n\n");
258 bprint ("^1", a, "^1 took action against a teammate\n");
260 centerprint(attacker, "^1Moron! You fragged a teammate!\n\n\n");
261 bprint ("^1", a, "^1 mows down a teammate\n");
263 GiveFrags(attacker, targ, -1);
264 if (targ.killcount > 2) {
266 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," scoring spree was ended by a teammate!\n");
268 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," kill spree was ended by a teammate!\n");
270 if (attacker.killcount > 2) {
272 bprint ("^1",a,"^1 ended a ",ftos(attacker.killcount)," scoring spree by going against a teammate\n");
274 bprint ("^1",a,"^1 ended a ",ftos(attacker.killcount)," kill spree by killing a teammate\n");
276 attacker.killcount = 0;
278 LogDeath("tk", deathtype, attacker, targ);
282 if (!checkrules_firstblood)
284 checkrules_firstblood = TRUE;
286 bprint("^1",a, "^1 was the first to score", "\n");
288 bprint("^1",a, "^1 drew first blood", "\n");
292 centerprint(attacker, strcat("^4You scored against ^7", s, "\n\n\n"));
293 centerprint(targ, strcat(a,"^1 scored against you ^7\n\n\n"));
295 centerprint(attacker, strcat("^4You fragged ^7", s, "\n\n\n"));
296 centerprint(targ, strcat("^1You were fragged by ^7", a, "\n\n\n"));
300 bprint ("^1",s, "^1 needs a restart thanks to ", a, "\n");
302 w = DEATH_WEAPONOF(deathtype);
305 w_deathtypestring = "was blasted by";
306 w_deathtype = deathtype;
307 weapon_action(w, WR_KILLMESSAGE);
308 p = strstrofs(w_deathtypestring, "#", 0);
310 bprint("^1", s, "^1 ", w_deathtypestring, " ", a, "\n");
312 bprint("^1", s, "^1 ", substring(w_deathtypestring, 0, p), a, "^1", substring(w_deathtypestring, p+1, strlen(w_deathtypestring) - (p+1)), "\n");
314 else if (deathtype == DEATH_TELEFRAG)
315 bprint ("^1",s, "^1 was telefragged by ", a, "\n");
316 else if (deathtype == DEATH_DROWN)
317 bprint ("^1",s, "^1 was drowned by ", a, "\n");
318 else if (deathtype == DEATH_SLIME)
319 bprint ("^1",s, "^1 was slimed by ", a, "\n");
320 else if (deathtype == DEATH_LAVA)
321 bprint ("^1",s, "^1 was cooked by ", a, "\n");
322 else if (deathtype == DEATH_FALL)
323 bprint ("^1",s, "^1 was grounded by ", a, "\n");
324 else if (deathtype == DEATH_SHOOTING_STAR)
325 bprint ("^1",s, "^1 was shot into space by ", a, "\n");
326 else if (deathtype == DEATH_SWAMP)
327 bprint ("^1",s, "^1 was conserved by ", a, "\n");
328 else if (deathtype == DEATH_HURTTRIGGER && inflictor.message2 != "")
330 p = strstrofs(inflictor.message2, "#", 0);
332 bprint("^1", s, "^1 ", inflictor.message2, " ", a, "\n");
334 bprint("^1", s, "^1 ", substring(inflictor.message2, 0, p), a, "^1", substring(inflictor.message2, p+1, strlen(inflictor.message2) - (p+1)), "\n");
336 else if(deathtype == DEATH_TURRET)
337 bprint ("^1",s, "^1 was pushed into the line of fire by ^1", a, "\n");
338 else if(deathtype == DEATH_TOUCHEXPLODE)
339 bprint ("^1",s, "^1 was pushed into an accident by ^1", a, "\n");
341 bprint ("^1",s, "^1 was fragged by ", a, "\n");
343 if(g_ctf && targ.flagcarried)
345 UpdateFrags(attacker, ctf_score_value("score_kill"));
346 PlayerScore_Add(attacker, SP_CTF_FCKILLS, 1);
347 GiveFrags(attacker, targ, 0); // for logging
350 GiveFrags(attacker, targ, 1);
351 if (targ.killcount > 2) {
353 bprint ("^1",s,"'s ^1", ftos(targ.killcount), " scoring spree was ended by ", a, "\n");
355 bprint ("^1",s,"'s ^1", ftos(targ.killcount), " kill spree was ended by ", a, "\n");
357 attacker.killcount = attacker.killcount + 1;
358 if (attacker.killcount > 2) {
360 bprint ("^1",a,"^1 made ",ftos(attacker.killcount)," scores in a row\n");
362 bprint ("^1",a,"^1 has ",ftos(attacker.killcount)," frags in a row\n");
365 LogDeath("frag", deathtype, attacker, targ);
367 if (attacker.killcount == 3)
370 bprint (a,"^7 made a ^1TRIPLE SCORE\n");
372 bprint (a,"^7 made a ^1TRIPLE FRAG\n");
373 announce(attacker, "announcer/male/03kills.wav");
376 else if (attacker.killcount == 5)
379 bprint (a,"^7 unleashes ^1SCORING RAGE\n");
381 bprint (a,"^7 unleashes ^1RAGE\n");
382 announce(attacker, "announcer/male/05kills.wav");
385 else if (attacker.killcount == 10)
388 bprint (a,"^7 made ^1TEN SCORES IN A ROW!\n");
390 bprint (a,"^7 starts the ^1MASSACRE!\n");
391 announce(attacker, "announcer/male/10kills.wav");
394 else if (attacker.killcount == 15)
397 bprint (a,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
399 bprint (a,"^7 executes ^1MAYHEM!\n");
400 announce(attacker, "announcer/male/15kills.wav");
403 else if (attacker.killcount == 20)
406 bprint (a,"^7 made ^1TWENTY SCORES IN A ROW!\n");
408 bprint (a,"^7 is a ^1BERSERKER!\n");
409 announce(attacker, "announcer/male/20kills.wav");
412 else if (attacker.killcount == 25)
415 bprint (a,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
417 bprint (a,"^7 inflicts ^1CARNAGE!\n");
418 announce(attacker, "announcer/male/25kills.wav");
421 else if (attacker.killcount == 30)
424 bprint (a,"^7 made ^1THIRTY SCORES IN A ROW!\n");
426 bprint (a,"^7 unleashes ^1ARMAGEDDON!\n");
427 announce(attacker, "announcer/male/30kills.wav");
434 centerprint(targ, "^1Watch your step!\n\n\n");
435 if (deathtype == DEATH_HURTTRIGGER && inflictor.message != "")
436 bprint ("^1",s, "^1 ", inflictor.message, "\n");
437 else if (deathtype == DEATH_DROWN)
439 bprint ("^1",s, "^1 was in the water for too long\n");
441 bprint ("^1",s, "^1 drowned\n");
442 else if (deathtype == DEATH_SLIME)
443 bprint ("^1",s, "^1 was slimed\n");
444 else if (deathtype == DEATH_LAVA)
446 bprint ("^1",s, "^1 found a hot place\n");
448 bprint ("^1",s, "^1 turned into hot slag\n");
449 else if (deathtype == DEATH_FALL)
451 bprint ("^1",s, "^1 tested gravity (and it worked)\n");
453 bprint ("^1",s, "^1 hit the ground with a crunch\n");
454 else if (deathtype == DEATH_SHOOTING_STAR)
455 bprint ("^1",s, "^1 became a shooting star\n");
456 else if (deathtype == DEATH_SWAMP)
458 bprint ("^1",s, "^1 discovered a swamp\n");
460 bprint ("^1",s, "^1 is now conserved for centuries to come\n");
461 else if(deathtype == DEATH_TURRET)
462 bprint ("^1",s, "^1 was mowed down by a turret \n");
463 else if(deathtype == DEATH_TOUCHEXPLODE)
464 bprint ("^1",s, "^1 died in an accident\n");
467 bprint ("^1",s, "^1 needs a restart\n");
469 bprint ("^1",s, "^1 died\n");
470 GiveFrags(targ, targ, -1);
471 if(PlayerScore_Add(targ, SP_SCORE, 0) == -5) {
472 announce(targ, "announcer/male/botlike.wav");
475 if (targ.killcount > 2)
477 bprint ("^1",s,"^1 needs a restart after a ",ftos(targ.killcount)," scoring spree\n");
479 bprint ("^1",s,"^1 died with a ",ftos(targ.killcount)," kill spree\n");
481 LogDeath("accident", deathtype, targ, targ);
483 targ.death_origin = targ.origin;
485 targ.killer_origin = attacker.origin;
486 // FIXME: this should go in PutClientInServer
492 // these are updated by each Damage call for use in button triggering and such
494 entity damage_inflictor;
495 entity damage_attacker;
497 void Damage (entity targ, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
501 entity attacker_save;
505 if (gameover || targ.killcount == -666)
508 local entity oldself;
512 damage_inflictor = inflictor;
513 damage_attacker = attacker;
514 attacker_save = attacker;
516 if(targ.classname == "player")
519 if(targ.hook.aiment == attacker)
520 RemoveGrapplingHook(targ); // STOP THAT, you parasite!
522 // special rule: gravity bomb does not hit team mates (other than for disconnecting the hook)
523 if(DEATH_ISWEAPON(deathtype, WEP_HOOK))
525 if(targ.classname == "player")
526 if not(IsDifferentTeam(targ, attacker))
533 if(deathtype == DEATH_KILL || deathtype == DEATH_TEAMCHANGE || deathtype == DEATH_AUTOTEAMCHANGE)
535 // These are ALWAYS lethal
536 // No damage modification here
537 // Instead, prepare the victim for his death...
539 targ.spawnshieldtime = 0;
540 targ.health = 0.9; // this is < 1
541 targ.flags -= targ.flags & FL_GODMODE;
544 else if(deathtype == DEATH_MIRRORDAMAGE || deathtype == DEATH_NOAMMO)
550 if (targ.classname == "player")
551 if (attacker.classname == "player")
554 damage = damage * bound(0.1, (skill + 5) * 0.1, 1);
556 // nullify damage if teamplay is on
557 if(deathtype != DEATH_TELEFRAG)
558 if(attacker.classname == "player")
560 if(targ.classname == "player" && targ != attacker && (IS_INDEPENDENT_PLAYER(attacker) || IS_INDEPENDENT_PLAYER(targ)))
565 else if(attacker.team == targ.team)
569 else if(attacker != targ)
573 else if(teamplay == 4)
575 if(targ.classname == "player" && targ.deadflag == DEAD_NO)
577 mirrordamage = cvar("g_mirrordamage") * damage;
578 mirrorforce = cvar("g_mirrordamage") * vlen(force);
581 if(cvar("g_friendlyfire") == 0)
585 damage = cvar("g_friendlyfire") * damage;
586 // mirrordamage will be used LATER
595 if(targ.classname == "player")
596 if(attacker.classname == "player")
599 targ.lms_traveled_distance = cvar("g_lms_campcheck_distance");
600 attacker.lms_traveled_distance = cvar("g_lms_campcheck_distance");
605 if ((deathtype == DEATH_FALL) ||
606 (deathtype == DEATH_DROWN) ||
607 (deathtype == DEATH_SLIME) ||
608 (deathtype == DEATH_LAVA))
613 if (targ.armorvalue && (deathtype == WEP_MINSTANEX) && damage)
615 targ.armorvalue -= 1;
616 centerprint(targ, strcat("^3Remaining extra lives: ",ftos(targ.armorvalue),"\n"));
620 if (DEATH_ISWEAPON(deathtype, WEP_LASER))
623 if (targ != attacker)
625 if (targ.classname == "player")
626 centerprint(attacker, "Secondary fire inflicts no damage!\n");
636 // apply strength multiplier
637 if ((attacker.items & IT_STRENGTH) && !g_minstagib)
641 damage = damage * cvar("g_balance_powerup_strength_selfdamage");
642 force = force * cvar("g_balance_powerup_strength_selfforce");
646 damage = damage * cvar("g_balance_powerup_strength_damage");
647 force = force * cvar("g_balance_powerup_strength_force");
651 // apply invincibility multiplier
652 if (targ.items & IT_INVINCIBLE && !g_minstagib)
653 damage = damage * cvar("g_balance_powerup_invincible_takedamage");
655 if (targ == attacker)
656 damage = damage * cvar("g_balance_selfdamagepercent"); // Partial damage if the attacker hits himself
658 // CTF: reduce damage/force
663 damage = damage * cvar("g_ctf_flagcarrier_selfdamage");
664 force = force * cvar("g_ctf_flagcarrier_selfforce");
669 // apply strength rune
670 if (attacker.runes & RUNE_STRENGTH)
672 if(attacker.runes & CURSE_WEAK) // have both curse & rune
674 damage = damage * cvar("g_balance_rune_strength_combo_damage");
675 force = force * cvar("g_balance_rune_strength_combo_force");
679 damage = damage * cvar("g_balance_rune_strength_damage");
680 force = force * cvar("g_balance_rune_strength_force");
683 else if (attacker.runes & CURSE_WEAK)
685 damage = damage * cvar("g_balance_curse_weak_damage");
686 force = force * cvar("g_balance_curse_weak_force");
689 // apply defense rune
690 if (targ.runes & RUNE_DEFENSE)
692 if (targ.runes & CURSE_VULNER) // have both curse & rune
693 damage = damage * cvar("g_balance_rune_defense_combo_takedamage");
695 damage = damage * cvar("g_balance_rune_defense_takedamage");
697 else if (targ.runes & CURSE_VULNER)
698 damage = damage * cvar("g_balance_curse_vulner_takedamage");
704 if(targ.takedamage == DAMAGE_AIM)
706 if(targ.classname == "player")
708 if(IsDifferentTeam(targ, attacker))
713 attacker.typehitsound += 1;
715 attacker.hitsound += 1;
717 damage_goodhits += 1;
718 damage_gooddamage += damage;
725 if(targ.items & IT_STRENGTH)
729 // find height of hit on player axis
730 // if above view_ofs and below maxs, and also in the middle half of the bbox, it is head shot
731 vector headmins, headmaxs, org;
732 org = antilag_takebackorigin(targ, time - ANTILAG_LATENCY(attacker));
733 headmins = org + '0.5 0 0' * targ.mins_x + '0 0.5 0' * targ.mins_y + '0 0 1' * targ.view_ofs_z;
734 headmaxs = org + '0.5 0 0' * targ.maxs_x + '0 0.5 0' * targ.maxs_y + '0 0 1' * targ.maxs_z;
735 if(trace_hits_box(railgun_start, railgun_end, headmins, headmaxs))
741 attacker.typehitsound += 1; // TODO possibly trigger teamkill complain sound!
742 if(time > attacker.teamkill_complain)
744 attacker.teamkill_complain = time + 5;
745 attacker.teamkill_soundtime = time + 0.4;
746 attacker.teamkill_soundsource = targ;
753 if (self.damageforcescale)
756 self.velocity = self.velocity + self.damageforcescale * force;
757 self.flags = self.flags - (self.flags & FL_ONGROUND);
761 if (self.event_damage)
762 self.event_damage (inflictor, attacker, damage, deathtype, hitloc, force);
765 if(targ.classname == "player" && attacker.classname == "player" && attacker != targ && attacker.health > 2)
767 // Savage: vampire mode
770 if (time > self.spawnshieldtime)
772 attacker.health += damage;
776 if (attacker.runes & RUNE_VAMPIRE)
778 // apply vampire rune
779 if (attacker.runes & CURSE_EMPATHY) // have the curse too
781 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb");
782 attacker.health = bound(
783 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 40
784 attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb"),
785 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
789 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_absorb");
790 attacker.health = bound(
791 attacker.health, // LA: was 3, but changed so that you can't lose health
792 // empathy won't let you gain health in the same way...
793 attacker.health + damage * cvar("g_balance_rune_vampire_absorb"),
794 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
797 // apply empathy curse
798 else if (attacker.runes & CURSE_EMPATHY)
800 attacker.health = bound(
801 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 20
802 attacker.health + damage * cvar("g_balance_curse_empathy_takedamage"),
808 // apply mirror damage if any
809 if(mirrordamage > 0 || mirrorforce > 0)
811 attacker = attacker_save;
815 // just lose extra LIVES, don't kill the player for mirror damage
816 if(attacker.armorvalue > 0)
818 attacker.armorvalue = attacker.armorvalue - 1;
819 centerprint(attacker, strcat("^3Remaining extra lives: ",ftos(attacker.armorvalue),"\n"));
820 attacker.hitsound += 1;
824 force = normalize(attacker.origin + attacker.view_ofs - hitloc) * mirrorforce;
825 Damage(attacker, inflictor, attacker, mirrordamage, DEATH_MIRRORDAMAGE, attacker.origin, force);
829 vector NearestPointOnBox(entity box, vector org)
831 vector m1, m2, nearest;
833 m1 = box.mins + box.origin;
834 m2 = box.maxs + box.origin;
836 nearest_x = bound(m1_x, org_x, m2_x);
837 nearest_y = bound(m1_y, org_y, m2_y);
838 nearest_z = bound(m1_z, org_z, m2_z);
843 float RadiusDamage_running;
844 float RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype, entity directhitentity)
845 // Returns total damage applies to creatures
855 float total_damage_to_creatures;
858 if(RadiusDamage_running)
861 print("RadiusDamage called recursively!\n");
862 print("Expect stuff to go HORRIBLY wrong.\n");
863 print("Causing a stack trace...\n");
864 save = cvar_string("prvm_backtraceforwarnings");
865 cvar_set("prvm_backtraceforwarnings", "1");
866 fclose(-1); // calls VM_Warning
867 cvar_set("prvm_backtraceforwarnings", save);
871 RadiusDamage_running = 1;
873 blastorigin = (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5);
874 total_damage_to_creatures = 0;
876 targ = findradius (blastorigin, rad);
880 if (targ != inflictor)
883 // LordHavoc: measure distance to nearest point on target (not origin)
884 // (this guarentees 100% damage on a touch impact)
885 nearest = NearestPointOnBox(targ, blastorigin);
886 diff = nearest - blastorigin;
887 // round up a little on the damage to ensure full damage on impacts
888 // and turn the distance into a fraction of the radius
889 power = 1 - ((vlen (diff) - 2) / rad);
891 //bprint(ftos(power));
896 finaldmg = coredamage * power + edgedamage * (1 - power);
899 center = targ.origin + (targ.mins + targ.maxs) * 0.5;
900 // if it's a player, use the view origin as reference
901 if (targ.classname == "player")
902 center = targ.origin + targ.view_ofs;
903 force = normalize(center - blastorigin) * (finaldmg / coredamage) * forceintensity;
904 // test line of sight to multiple positions on box,
905 // and do damage if any of them hit
907 c = ceil(finaldmg / 10);
913 traceline(blastorigin, nearest, TRUE, inflictor);
914 if (trace_fraction == 1 || trace_ent == targ
915 || cvar("g_throughfloor"))
918 total_damage_to_creatures += finaldmg;
919 if(targ == directhitentity || DEATH_ISSPECIAL(deathtype))
920 Damage (targ, inflictor, attacker, finaldmg, deathtype, nearest, force);
922 Damage (targ, inflictor, attacker, finaldmg, deathtype | HITTYPE_SPLASH, nearest, force);
925 nearest_x = targ.mins_x + random() * targ.size_x;
926 nearest_y = targ.mins_y + random() * targ.size_y;
927 nearest_z = targ.mins_z + random() * targ.size_z;
935 RadiusDamage_running = 0;
937 return total_damage_to_creatures;