1 float checkrules_firstblood;
5 float damage_gooddamage;
8 .float teamkill_complain;
12 float IsDifferentTeam(entity a, entity b)
27 float IsFlying(entity a)
29 if(a.flags & FL_ONGROUND)
33 traceline(a.origin, a.origin - '0 0 48', MOVE_NORMAL, a);
34 if(trace_fraction < 1)
39 void UpdateFrags(entity player, float f)
41 PlayerTeamScore_AddScore(player, f);
44 // NOTE: f=0 means still count as a (positive) kill, but count no frags for it
45 void GiveFrags (entity attacker, entity targ, float f)
47 // TODO route through PlayerScores instead
55 PlayerScore_Add(attacker, SP_SUICIDES, 1);
60 PlayerScore_Add(attacker, SP_KILLS, -1); // or maybe add a teamkills field?
66 PlayerScore_Add(attacker, SP_KILLS, 1);
69 PlayerScore_Add(targ, SP_DEATHS, 1);
72 if(cvar("g_arena_roundbased"))
75 // FIXME fix the mess this is (we have REAL points now!)
78 f = RunematchHandleFrags(attacker, targ, f);
82 f = kh_HandleFrags(attacker, targ, f);
88 tl = PlayerScore_Add(targ, SP_LMS_LIVES, -1);
89 if(tl < lms_lowest_lives)
90 lms_lowest_lives = tl;
94 lms_next_place = player_count;
95 PlayerScore_Add(targ, SP_LMS_RANK, lms_next_place); // won't ever spawn again
102 if(g_ctf_ignore_frags)
106 attacker.totalfrags += f;
109 UpdateFrags(attacker, f);
112 string AppendItemcodes(string s, entity player)
117 // w = player.switchweapon;
119 w = player.cnt; // previous weapon!
120 s = strcat(s, ftos(w));
121 if(time < player.strength_finished)
123 if(time < player.invincible_finished)
125 if(player.flagcarried != world)
127 if(player.BUTTON_CHAT)
132 s = strcat(s, "|", ftos(player.runes));
136 void LogDeath(string mode, float deathtype, entity killer, entity killed)
139 if(!cvar("sv_eventlog"))
141 s = strcat(":kill:", mode);
142 s = strcat(s, ":", ftos(killer.playerid));
143 s = strcat(s, ":", ftos(killed.playerid));
144 s = strcat(s, ":type=", ftos(deathtype));
145 s = strcat(s, ":items=");
146 s = AppendItemcodes(s, killer);
149 s = strcat(s, ":victimitems=");
150 s = AppendItemcodes(s, killed);
155 void Obituary (entity attacker, entity inflictor, entity targ, float deathtype)
160 if (targ.classname == "player" || targ.classname == "corpse")
162 if (targ.classname == "corpse")
166 a = attacker.netname;
168 if (targ == attacker)
170 if (deathtype == DEATH_TEAMCHANGE) {
171 centerprint(targ, strcat("You are now on: ", ColoredTeamName(targ.team)));
172 } else if (deathtype == DEATH_AUTOTEAMCHANGE) {
173 centerprint(targ, strcat("You have been moved into a different team to improve team balance\nYou are now on: ", ColoredTeamName(targ.team)));
175 } else if (deathtype == DEATH_CAMP) {
177 centerprint(targ, "^1Reconsider your tactics, camper!\n\n\n");
179 centerprint(targ, "^1Die camper!\n\n\n");
180 } else if (deathtype == DEATH_NOAMMO) {
182 centerprint(targ, "^1You are reinserted into the game for running out of ammo...\n\n\n");
184 centerprint(targ, "^1You were killed for running out of ammo...\n\n\n");
185 } else if (deathtype == DEATH_ROT) {
187 centerprint(targ, "^1You need to preserve your health\n\n\n");
189 centerprint(targ, "^1You grew too old without taking your medicine\n\n\n");
190 } else if (deathtype == DEATH_MIRRORDAMAGE) {
192 centerprint(targ, "^1Don't go against team mates!\n\n\n");
194 centerprint(targ, "^1Don't shoot your team mates!\n\n\n");
197 centerprint(targ, "^1You need to be more careful!\n\n\n");
199 centerprint(targ, "^1You killed your own dumb self!\n\n\n");
203 if (deathtype == DEATH_CAMP)
204 bprint ("^1",s, "^1 thought he found a nice camping ground\n");
205 else if (deathtype == DEATH_MIRRORDAMAGE)
206 bprint ("^1",s, "^1 didn't become friends with the Lord of Teamplay\n");
208 bprint ("^1",s, "^1 will be reinserted into the game due to his own actions\n");
210 if(deathtype != DEATH_TEAMCHANGE)
212 LogDeath("suicide", deathtype, targ, targ);
213 GiveFrags(attacker, targ, -1);
215 if (targ.killcount > 2)
216 bprint ("^1",s,"^1 ended it all with a ",ftos(targ.killcount)," scoring spree\n");
218 if(deathtype < DEATH_SPECIAL_START && deathtype & DEATH_WEAPONMASK >= WEP_FIRST && deathtype & DEATH_WEAPONMASK <= WEP_LAST)
220 w_deathtypestring = "couldn't resist the urge to self-destruct";
221 w_deathtype = deathtype;
222 weapon_action(deathtype & DEATH_WEAPONMASK, WR_SUICIDEMESSAGE);
223 bprint("^1", s, "^1 ", w_deathtypestring, "\n");
225 else if (deathtype == DEATH_KILL)
226 bprint ("^1",s, "^1 couldn't take it anymore\n");
227 else if (deathtype == DEATH_ROT)
228 bprint ("^1",s, "^1 died\n");
229 else if (deathtype == DEATH_NOAMMO)
231 bprint ("^7",s, " ^7committed suicide. What's the point of living without ammo?\n");
233 else if (deathtype == DEATH_CAMP)
234 bprint ("^1",s, "^1 thought he found a nice camping ground\n");
235 else if (deathtype == DEATH_MIRRORDAMAGE)
236 bprint ("^1",s, "^1 didn't become friends with the Lord of Teamplay\n");
237 else if (deathtype != DEATH_TEAMCHANGE)
238 bprint ("^1",s, "^1 couldn't resist the urge to self-destruct\n");
240 if(deathtype != DEATH_TEAMCHANGE)
242 LogDeath("suicide", deathtype, targ, targ);
243 GiveFrags(attacker, targ, -1);
245 if (targ.killcount > 2)
246 bprint ("^1",s,"^1 ended it all with a ",ftos(targ.killcount)," kill spree\n");
249 else if (attacker.classname == "player" || attacker.classname == "gib")
251 if(teamplay && attacker.team == targ.team)
254 centerprint(attacker, "^1Moron! You went against a teammate!\n\n\n");
255 bprint ("^1", a, "^1 took action against a teammate\n");
257 centerprint(attacker, "^1Moron! You fragged a teammate!\n\n\n");
258 bprint ("^1", a, "^1 mows down a teammate\n");
260 GiveFrags(attacker, targ, -1);
261 if (targ.killcount > 2) {
263 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," scoring spree was ended by a teammate!\n");
265 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," kill spree was ended by a teammate!\n");
267 if (attacker.killcount > 2) {
269 bprint ("^1",a,"^1 ended a ",ftos(attacker.killcount)," scoring spree by going against a teammate\n");
271 bprint ("^1",a,"^1 ended a ",ftos(attacker.killcount)," kill spree by killing a teammate\n");
273 attacker.killcount = 0;
275 LogDeath("tk", deathtype, attacker, targ);
279 if (!checkrules_firstblood)
281 checkrules_firstblood = TRUE;
283 bprint("^1",a, "^1 was the first to score", "\n");
285 bprint("^1",a, "^1 drew first blood", "\n");
289 centerprint(attacker, strcat("^4You scored against ^7", s, "\n\n\n"));
290 centerprint(targ, strcat(a,"^1 scored against you ^7\n\n\n"));
292 centerprint(attacker, strcat("^4You fragged ^7", s, "\n\n\n"));
293 centerprint(targ, strcat("^1You were fragged by ^7", a, "\n\n\n"));
297 bprint ("^1",s, "^1 needs a restart thanks to ", a, "\n");
299 if(deathtype < DEATH_SPECIAL_START && deathtype & DEATH_WEAPONMASK >= WEP_FIRST && deathtype & DEATH_WEAPONMASK <= WEP_LAST)
301 w_deathtypestring = "was blasted by";
302 w_deathtype = deathtype;
303 weapon_action(deathtype & DEATH_WEAPONMASK, WR_KILLMESSAGE);
304 p = strstrofs(w_deathtypestring, "#", 0);
306 bprint("^1", s, "^1 ", w_deathtypestring, " ", a, "\n");
308 bprint("^1", s, "^1 ", substring(w_deathtypestring, 0, p), a, "^1", substring(w_deathtypestring, p+1, strlen(w_deathtypestring) - (p+1)), "\n");
310 else if (deathtype == DEATH_TELEFRAG)
311 bprint ("^1",s, "^1 was telefragged by ", a, "\n");
312 else if (deathtype == DEATH_DROWN)
313 bprint ("^1",s, "^1 was drowned by ", a, "\n");
314 else if (deathtype == DEATH_SLIME)
315 bprint ("^1",s, "^1 was slimed by ", a, "\n");
316 else if (deathtype == DEATH_LAVA)
317 bprint ("^1",s, "^1 was cooked by ", a, "\n");
318 else if (deathtype == DEATH_FALL)
319 bprint ("^1",s, "^1 was grounded by ", a, "\n");
320 else if (deathtype == DEATH_SHOOTING_STAR)
321 bprint ("^1",s, "^1 was shot into space by ", a, "\n");
322 else if (deathtype == DEATH_SWAMP)
323 bprint ("^1",s, "^1 was conserved by ", a, "\n");
324 else if (deathtype == DEATH_HURTTRIGGER && attacker.message2 != "")
326 p = strstrofs(inflictor.message2, "#", 0);
328 bprint("^1", s, "^1 ", inflictor.message2, " ", a, "\n");
330 bprint("^1", s, "^1 ", substring(inflictor.message2, 0, p), a, "^1", substring(inflictor.message2, p+1, strlen(inflictor.message2) - (p+1)), "\n");
332 else if(deathtype == DEATH_TURRET)
333 bprint ("^1",s, "^1 was pushed into the line of fire by ^1", a, "\n");
335 bprint ("^1",s, "^1 was fragged by ", a, "\n");
337 if(g_ctf && targ.flagcarried)
339 UpdateFrags(attacker, ctf_score_value("score_kill"));
340 PlayerScore_Add(attacker, SP_CTF_FCKILLS, 1);
341 GiveFrags(attacker, targ, 0); // for logging
344 GiveFrags(attacker, targ, 1);
345 if (targ.killcount > 2) {
347 bprint ("^1",s,"'s ^1", ftos(targ.killcount), " scoring spree was ended by ", a, "\n");
349 bprint ("^1",s,"'s ^1", ftos(targ.killcount), " kill spree was ended by ", a, "\n");
351 attacker.killcount = attacker.killcount + 1;
352 if (attacker.killcount > 2) {
354 bprint ("^1",a,"^1 made ",ftos(attacker.killcount)," scores in a row\n");
356 bprint ("^1",a,"^1 has ",ftos(attacker.killcount)," frags in a row\n");
359 LogDeath("frag", deathtype, attacker, targ);
361 if (attacker.killcount == 3)
364 bprint (a,"^7 made a ^1TRIPLE SCORE\n");
366 bprint (a,"^7 made a ^1TRIPLE FRAG\n");
367 announce(attacker, "announcer/male/03kills.ogg");
370 else if (attacker.killcount == 5)
373 bprint (a,"^7 unleashes ^1SCORING RAGE\n");
375 bprint (a,"^7 unleashes ^1RAGE\n");
376 announce(attacker, "announcer/male/05kills.ogg");
379 else if (attacker.killcount == 10)
382 bprint (a,"^7 made ^1TEN SCORES IN A ROW!\n");
384 bprint (a,"^7 starts the ^1MASSACRE!\n");
385 announce(attacker, "announcer/male/10kills.ogg");
388 else if (attacker.killcount == 15)
391 bprint (a,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
393 bprint (a,"^7 executes ^1MAYHEM!\n");
394 announce(attacker, "announcer/male/15kills.ogg");
397 else if (attacker.killcount == 20)
400 bprint (a,"^7 made ^1TWENTY SCORES IN A ROW!\n");
402 bprint (a,"^7 is a ^1BERSERKER!\n");
403 announce(attacker, "announcer/male/20kills.ogg");
406 else if (attacker.killcount == 25)
409 bprint (a,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
411 bprint (a,"^7 inflicts ^1CARNAGE!\n");
412 announce(attacker, "announcer/male/25kills.ogg");
415 else if (attacker.killcount == 30)
418 bprint (a,"^7 made ^1THIRTY SCORES IN A ROW!\n");
420 bprint (a,"^7 unleashes ^1ARMAGEDDON!\n");
421 announce(attacker, "announcer/male/30kills.ogg");
428 centerprint(targ, "^1Watch your step!\n\n\n");
429 if (deathtype == DEATH_HURTTRIGGER && attacker.message != "")
430 bprint ("^1",s, "^1 ", attacker.message, "\n");
431 else if (deathtype == DEATH_DROWN)
433 bprint ("^1",s, "^1 was in the water for too long\n");
435 bprint ("^1",s, "^1 drowned\n");
436 else if (deathtype == DEATH_SLIME)
437 bprint ("^1",s, "^1 was slimed\n");
438 else if (deathtype == DEATH_LAVA)
440 bprint ("^1",s, "^1 found a hot place\n");
442 bprint ("^1",s, "^1 turned into hot slag\n");
443 else if (deathtype == DEATH_FALL)
445 bprint ("^1",s, "^1 tested gravity (and it worked)\n");
447 bprint ("^1",s, "^1 hit the ground with a crunch\n");
448 else if (deathtype == DEATH_SHOOTING_STAR)
449 bprint ("^1",s, "^1 became a shooting star\n");
450 else if (deathtype == DEATH_SWAMP)
452 bprint ("^1",s, "^1 discovered a swamp\n");
454 bprint ("^1",s, "^1 is now conserved for centuries to come\n");
455 else if(deathtype == DEATH_TURRET)
456 bprint ("^1",s, "^1 was mowed down by a turret \n");
459 bprint ("^1",s, "^1 needs a restart\n");
461 bprint ("^1",s, "^1 died\n");
462 GiveFrags(targ, targ, -1);
463 if(PlayerScore_Add(targ, SP_SCORE, 0) == -5) {
464 announce(targ, "announcer/male/botlike.ogg");
467 if (targ.killcount > 2)
469 bprint ("^1",s,"^1 needs a restart after a ",ftos(targ.killcount)," scoring spree\n");
471 bprint ("^1",s,"^1 died with a ",ftos(targ.killcount)," kill spree\n");
473 LogDeath("accident", deathtype, targ, targ);
475 targ.death_origin = targ.origin;
477 targ.killer_origin = attacker.origin;
478 // FIXME: this should go in PutClientInServer
484 // these are updated by each Damage call for use in button triggering and such
486 entity damage_inflictor;
487 entity damage_attacker;
489 void Damage (entity targ, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
493 entity attacker_save;
497 if (gameover || targ.killcount == -666)
500 local entity oldself;
504 damage_inflictor = inflictor;
505 damage_attacker = attacker;
506 attacker_save = attacker;
508 if(deathtype == DEATH_KILL || deathtype == DEATH_TEAMCHANGE || deathtype == DEATH_AUTOTEAMCHANGE)
510 // These are ALWAYS lethal
511 // No damage modification here
512 // Instead, prepare the victim for his death...
514 targ.spawnshieldtime = 0;
515 targ.health = 0.9; // this is < 1
516 targ.flags -= targ.flags & FL_GODMODE;
519 else if(deathtype == DEATH_MIRRORDAMAGE || deathtype == DEATH_NOAMMO)
525 if (targ.classname == "player")
526 if (attacker.classname == "player")
529 damage = damage * bound(0.1, (skill + 5) * 0.1, 1);
531 // nullify damage if teamplay is on
532 if(deathtype != DEATH_TELEFRAG)
533 if(attacker.classname == "player")
535 if(targ.classname == "player" && targ != attacker && (IS_INDEPENDENT_PLAYER(attacker) || IS_INDEPENDENT_PLAYER(targ)))
540 else if(attacker.team == targ.team)
544 else if(attacker != targ)
548 else if(teamplay == 4)
550 if(targ.classname == "player" && targ.deadflag == DEAD_NO)
552 mirrordamage = cvar("g_mirrordamage") * damage;
553 mirrorforce = cvar("g_mirrordamage") * vlen(force);
556 if(cvar("g_friendlyfire") == 0)
560 damage = cvar("g_friendlyfire") * damage;
561 // mirrordamage will be used LATER
570 if(targ.classname == "player")
571 if(attacker.classname == "player")
574 targ.lms_traveled_distance = cvar("g_lms_campcheck_distance");
575 attacker.lms_traveled_distance = cvar("g_lms_campcheck_distance");
580 if ((deathtype == DEATH_FALL) ||
581 (deathtype == DEATH_DROWN) ||
582 (deathtype == DEATH_SLIME) ||
583 (deathtype == DEATH_LAVA))
588 if (targ.armorvalue && (deathtype == WEP_MINSTANEX) && damage)
590 targ.armorvalue -= 1;
591 centerprint(targ, strcat("^3Remaining extra lives: ",ftos(targ.armorvalue),"\n"));
595 if (deathtype == WEP_LASER)
598 if (targ != attacker)
600 if (targ.classname == "player")
601 centerprint(attacker, "Secondary fire inflicts no damage!\n");
611 // apply strength multiplier
612 if (attacker.items & IT_STRENGTH && !g_minstagib)
616 damage = damage * cvar("g_balance_powerup_strength_selfdamage");
617 force = force * cvar("g_balance_powerup_strength_selfforce");
621 damage = damage * cvar("g_balance_powerup_strength_damage");
622 force = force * cvar("g_balance_powerup_strength_force");
626 // apply invincibility multiplier
627 if (targ.items & IT_INVINCIBLE && !g_minstagib)
628 damage = damage * cvar("g_balance_powerup_invincible_takedamage");
630 if (targ == attacker)
631 damage = damage * cvar("g_balance_selfdamagepercent"); // Partial damage if the attacker hits himself
633 // CTF: reduce damage/force
638 damage = damage * cvar("g_ctf_flagcarrier_selfdamage");
639 force = force * cvar("g_ctf_flagcarrier_selfforce");
644 // apply strength rune
645 if (attacker.runes & RUNE_STRENGTH)
647 if(attacker.runes & CURSE_WEAK) // have both curse & rune
649 damage = damage * cvar("g_balance_rune_strength_combo_damage");
650 force = force * cvar("g_balance_rune_strength_combo_force");
654 damage = damage * cvar("g_balance_rune_strength_damage");
655 force = force * cvar("g_balance_rune_strength_force");
658 else if (attacker.runes & CURSE_WEAK)
660 damage = damage * cvar("g_balance_curse_weak_damage");
661 force = force * cvar("g_balance_curse_weak_force");
664 // apply defense rune
665 if (targ.runes & RUNE_DEFENSE)
667 if (targ.runes & CURSE_VULNER) // have both curse & rune
668 damage = damage * cvar("g_balance_rune_defense_combo_takedamage");
670 damage = damage * cvar("g_balance_rune_defense_takedamage");
672 else if (targ.runes & CURSE_VULNER)
673 damage = damage * cvar("g_balance_curse_vulner_takedamage");
679 if(targ.takedamage == DAMAGE_AIM)
681 if(targ.classname == "player")
683 if(IsDifferentTeam(targ, attacker))
688 attacker.typehitsound += 1;
690 attacker.hitsound += 1;
692 damage_goodhits += 1;
693 damage_gooddamage += damage;
700 if(targ.items & IT_STRENGTH)
704 // find height of hit on player axis
705 // if above view_ofs and below maxs, and also in the middle half of the bbox, it is head shot
706 vector headmins, headmaxs, org;
707 org = antilag_takebackorigin(targ, time - ANTILAG_LATENCY(attacker));
708 headmins = org + '0.5 0 0' * targ.mins_x + '0 0.5 0' * targ.mins_y + '0 0 1' * targ.view_ofs_z;
709 headmaxs = org + '0.5 0 0' * targ.maxs_x + '0 0.5 0' * targ.maxs_y + '0 0 1' * targ.maxs_z;
710 if(trace_hits_box(railgun_start, railgun_end, headmins, headmaxs))
716 attacker.typehitsound += 1; // TODO possibly trigger teamkill complain sound!
717 if(time > attacker.teamkill_complain)
721 // note: here, self is actually targ!
722 oldpusher = self.pusher; self.pusher = attacker;
723 VoiceMessage("teamshoot_auto");
724 self.pusher = oldpusher;
726 attacker.teamkill_complain = time + 5;
733 if (self.damageforcescale)
736 self.velocity = self.velocity + self.damageforcescale * force;
737 self.flags = self.flags - (self.flags & FL_ONGROUND);
741 if (self.event_damage)
742 self.event_damage (inflictor, attacker, damage, deathtype, hitloc, force);
745 if(targ.classname == "player" && attacker.classname == "player" && attacker != targ && attacker.health > 2)
747 // Savage: vampire mode
750 if (time > self.spawnshieldtime)
752 attacker.health += damage;
756 if (attacker.runes & RUNE_VAMPIRE)
758 // apply vampire rune
759 if (attacker.runes & CURSE_EMPATHY) // have the curse too
761 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb");
762 attacker.health = bound(
763 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 40
764 attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb"),
765 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
769 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_absorb");
770 attacker.health = bound(
771 attacker.health, // LA: was 3, but changed so that you can't lose health
772 // empathy won't let you gain health in the same way...
773 attacker.health + damage * cvar("g_balance_rune_vampire_absorb"),
774 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
777 // apply empathy curse
778 else if (attacker.runes & CURSE_EMPATHY)
780 attacker.health = bound(
781 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 20
782 attacker.health + damage * cvar("g_balance_curse_empathy_takedamage"),
788 // apply mirror damage if any
789 if(mirrordamage > 0 || mirrorforce > 0)
791 attacker = attacker_save;
795 // just lose extra LIVES, don't kill the player for mirror damage
796 if(attacker.armorvalue > 0)
798 attacker.armorvalue = attacker.armorvalue - 1;
799 centerprint(attacker, strcat("^3Remaining extra lives: ",ftos(attacker.armorvalue),"\n"));
800 attacker.hitsound += 1;
804 force = normalize(attacker.origin + attacker.view_ofs - hitloc) * mirrorforce;
805 Damage(attacker, inflictor, attacker, mirrordamage, DEATH_MIRRORDAMAGE, attacker.origin, force);
809 vector NearestPointOnBox(entity box, vector org)
811 vector m1, m2, nearest;
813 m1 = box.mins + box.origin;
814 m2 = box.maxs + box.origin;
816 nearest_x = bound(m1_x, org_x, m2_x);
817 nearest_y = bound(m1_y, org_y, m2_y);
818 nearest_z = bound(m1_z, org_z, m2_z);
823 float RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype, entity directhitentity)
824 // Returns total damage applies to creatures
834 float total_damage_to_creatures;
836 blastorigin = (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5);
837 total_damage_to_creatures = 0;
839 targ = findradius (blastorigin, rad);
842 if (targ != inflictor)
845 // LordHavoc: measure distance to nearest point on target (not origin)
846 // (this guarentees 100% damage on a touch impact)
847 nearest = NearestPointOnBox(targ, blastorigin);
848 diff = nearest - blastorigin;
849 // round up a little on the damage to ensure full damage on impacts
850 // and turn the distance into a fraction of the radius
851 power = 1 - ((vlen (diff) - 2) / rad);
853 //bprint(ftos(power));
858 finaldmg = coredamage * power + edgedamage * (1 - power);
861 center = targ.origin + (targ.mins + targ.maxs) * 0.5;
862 // if it's a player, use the view origin as reference
863 if (targ.classname == "player")
864 center = targ.origin + targ.view_ofs;
865 force = normalize(center - blastorigin) * (finaldmg / coredamage) * forceintensity;
866 // test line of sight to multiple positions on box,
867 // and do damage if any of them hit
869 c = ceil(finaldmg / 10);
875 traceline(blastorigin, nearest, TRUE, inflictor);
876 if (trace_fraction == 1 || trace_ent == targ
877 || cvar("g_throughfloor"))
880 total_damage_to_creatures += finaldmg;
881 if(targ == directhitentity)
882 Damage (targ, inflictor, attacker, finaldmg, deathtype, nearest, force);
884 Damage (targ, inflictor, attacker, finaldmg, deathtype | HITTYPE_SPLASH, nearest, force);
887 nearest_x = targ.mins_x + random() * targ.size_x;
888 nearest_y = targ.mins_y + random() * targ.size_y;
889 nearest_z = targ.mins_z + random() * targ.size_z;
897 return total_damage_to_creatures;