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)
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?
29 e.projectiledeathtype = deathtype;
31 e.dmg_edge = edgedamage;
33 e.dmg_force = vlen(force);
36 e.oldorigin_x = compressShortVector(e.velocity);
38 Net_LinkEntity(e, FALSE, 0.2, Damage_DamageInfo_SendEntity);
41 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
43 float checkrules_firstblood;
46 float damage_goodhits;
47 float damage_gooddamage;
49 float damage_headshotbonus; // bonus multiplier for head shots, set to 0 after use
52 .float teamkill_complain;
53 .float teamkill_soundtime;
54 .entity teamkill_soundsource;
56 .float taunt_soundtime;
59 float IsDifferentTeam(entity a, entity b)
74 float IsFlying(entity a)
76 if(a.flags & FL_ONGROUND)
80 traceline(a.origin, a.origin - '0 0 48', MOVE_NORMAL, a);
81 if(trace_fraction < 1)
86 void UpdateFrags(entity player, float f)
88 PlayerTeamScore_AddScore(player, f);
91 // NOTE: f=0 means still count as a (positive) kill, but count no frags for it
92 void GiveFrags (entity attacker, entity targ, float f)
94 // TODO route through PlayerScores instead
102 PlayerScore_Add(attacker, SP_SUICIDES, 1);
107 PlayerScore_Add(attacker, SP_KILLS, -1); // or maybe add a teamkills field?
113 PlayerScore_Add(attacker, SP_KILLS, 1);
116 PlayerScore_Add(targ, SP_DEATHS, 1);
119 if(cvar("g_arena_roundbased"))
122 // FIXME fix the mess this is (we have REAL points now!)
125 f = RunematchHandleFrags(attacker, targ, f);
129 f = kh_HandleFrags(attacker, targ, f);
135 tl = PlayerScore_Add(targ, SP_LMS_LIVES, -1);
136 if(tl < lms_lowest_lives)
137 lms_lowest_lives = tl;
141 lms_next_place = player_count;
142 PlayerScore_Add(targ, SP_LMS_RANK, lms_next_place); // won't ever spawn again
149 if(g_ctf_ignore_frags)
153 attacker.totalfrags += f;
156 UpdateFrags(attacker, f);
159 string AppendItemcodes(string s, entity player)
164 // w = player.switchweapon;
166 w = player.cnt; // previous weapon!
167 s = strcat(s, ftos(w));
168 if(time < player.strength_finished)
170 if(time < player.invincible_finished)
172 if(player.flagcarried != world)
174 if(player.BUTTON_CHAT)
179 s = strcat(s, "|", ftos(player.runes));
183 void LogDeath(string mode, float deathtype, entity killer, entity killed)
186 if(!cvar("sv_eventlog"))
188 s = strcat(":kill:", mode);
189 s = strcat(s, ":", ftos(killer.playerid));
190 s = strcat(s, ":", ftos(killed.playerid));
191 s = strcat(s, ":type=", ftos(deathtype));
192 s = strcat(s, ":items=");
193 s = AppendItemcodes(s, killer);
196 s = strcat(s, ":victimitems=");
197 s = AppendItemcodes(s, killed);
202 void Obituary (entity attacker, entity inflictor, entity targ, float deathtype)
207 if (targ.classname == "player" || targ.classname == "corpse")
209 if (targ.classname == "corpse")
213 a = attacker.netname;
215 if (targ == attacker)
217 if (deathtype == DEATH_TEAMCHANGE) {
218 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", ColoredTeamName(targ.team)));
219 } else if (deathtype == DEATH_AUTOTEAMCHANGE) {
220 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)));
222 } else if (deathtype == DEATH_CAMP) {
224 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
226 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
227 } else if (deathtype == DEATH_NOAMMO) {
229 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
231 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
232 } else if (deathtype == DEATH_ROT) {
234 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
236 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
237 } else if (deathtype == DEATH_MIRRORDAMAGE) {
239 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
241 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
244 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
246 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
250 if (deathtype == DEATH_CAMP)
251 bprint ("^1",s, "^1 thought he found a nice camping ground\n");
252 else if (deathtype == DEATH_MIRRORDAMAGE)
253 bprint ("^1",s, "^1 didn't become friends with the Lord of Teamplay\n");
255 bprint ("^1",s, "^1 will be reinserted into the game due to his own actions\n");
257 if(deathtype != DEATH_TEAMCHANGE)
259 LogDeath("suicide", deathtype, targ, targ);
260 GiveFrags(attacker, targ, -1);
262 if (targ.killcount > 2)
263 bprint ("^1",s,"^1 faded after a ",ftos(targ.killcount)," point spree\n");
265 w = DEATH_WEAPONOF(deathtype);
268 w_deathtypestring = "couldn't resist the urge to self-destruct";
269 w_deathtype = deathtype;
270 weapon_action(w, WR_SUICIDEMESSAGE);
271 bprint("^1", s, "^1 ", w_deathtypestring, "\n");
273 else if (deathtype == DEATH_KILL)
274 bprint ("^1",s, "^1 couldn't take it anymore\n");
275 else if (deathtype == DEATH_ROT)
276 bprint ("^1",s, "^1 died\n");
277 else if (deathtype == DEATH_NOAMMO)
278 bprint ("^7",s, "^7 committed suicide. What's the point of living without ammo?\n");
279 else if (deathtype == DEATH_CAMP)
280 bprint ("^1",s, "^1 thought he found a nice camping ground\n");
281 else if (deathtype == DEATH_MIRRORDAMAGE)
282 bprint ("^1",s, "^1 didn't become friends with the Lord of Teamplay\n");
283 else if (deathtype == DEATH_CHEAT)
284 bprint ("^1",s, "^1 unfairly eliminated himself\n");
285 else if (deathtype != DEATH_TEAMCHANGE)
286 bprint ("^1",s, "^1 couldn't resist the urge to self-destruct\n");
288 if(deathtype != DEATH_TEAMCHANGE)
290 LogDeath("suicide", deathtype, targ, targ);
291 GiveFrags(attacker, targ, -1);
293 if (targ.killcount > 2)
294 bprint ("^1",s,"^1 ended it all after a ",ftos(targ.killcount)," kill spree\n");
297 else if (attacker.classname == "player" || attacker.classname == "gib")
299 if(teamplay && attacker.team == targ.team)
302 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against a team mate!"));
303 bprint ("^1", a, "^1 took action against a team mate\n");
305 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s, ", a team mate!"));
306 bprint ("^1", a, "^1 mows down a team mate\n");
308 GiveFrags(attacker, targ, -1);
309 if (targ.killcount > 2) {
311 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," scoring spree was ended by a team mate!\n");
313 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," kill spree was ended by a team mate!\n");
315 if (attacker.killcount > 2) {
317 bprint ("^1",a,"^1 ended a ",ftos(attacker.killcount)," scoring spree by going against a team mate\n");
319 bprint ("^1",a,"^1 ended a ",ftos(attacker.killcount)," kill spree by killing a team mate\n");
321 attacker.killcount = 0;
323 LogDeath("tk", deathtype, attacker, targ);
327 string blood_message, victim_message;
328 if (!checkrules_firstblood)
330 checkrules_firstblood = TRUE;
333 bprint("^1",a, "^1 was the first to score", "\n");
334 blood_message = "^1First point\n";
335 //victim_message = "^1First victim\n"; // or First casualty
339 bprint("^1",a, "^1 drew first blood", "\n");
340 blood_message = "^1First blood\n";
341 victim_message = "^1First victim\n"; // or First casualty
346 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s));
347 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, a,"^1 scored against you ^7"));
349 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, blood_message, "^4You fragged ^7", s));
350 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, victim_message, "^1You were fragged by ^7", a));
351 attacker.taunt_soundtime = time + 1;
355 bprint ("^1",s, "^1 needs a restart thanks to ", a, "\n");
357 w = DEATH_WEAPONOF(deathtype);
360 w_deathtypestring = "was blasted by";
361 w_deathtype = deathtype;
362 weapon_action(w, WR_KILLMESSAGE);
363 p = strstrofs(w_deathtypestring, "#", 0);
365 bprint("^1", s, "^1 ", w_deathtypestring, " ", a, "\n");
367 bprint("^1", s, "^1 ", substring(w_deathtypestring, 0, p), a, "^1", substring(w_deathtypestring, p+1, strlen(w_deathtypestring) - (p+1)), "\n");
369 else if (deathtype == DEATH_TELEFRAG)
370 bprint ("^1",s, "^1 was telefragged by ", a, "\n");
371 else if (deathtype == DEATH_DROWN)
372 bprint ("^1",s, "^1 was drowned by ", a, "\n");
373 else if (deathtype == DEATH_SLIME)
374 bprint ("^1",s, "^1 was slimed by ", a, "\n");
375 else if (deathtype == DEATH_LAVA)
376 bprint ("^1",s, "^1 was cooked by ", a, "\n");
377 else if (deathtype == DEATH_FALL)
378 bprint ("^1",s, "^1 was grounded by ", a, "\n");
379 else if (deathtype == DEATH_SHOOTING_STAR)
380 bprint ("^1",s, "^1 was shot into space by ", a, "\n");
381 else if (deathtype == DEATH_SWAMP)
382 bprint ("^1",s, "^1 was conserved by ", a, "\n");
383 else if (deathtype == DEATH_HURTTRIGGER && inflictor.message2 != "")
385 p = strstrofs(inflictor.message2, "#", 0);
387 bprint("^1", s, "^1 ", inflictor.message2, " ", a, "\n");
389 bprint("^1", s, "^1 ", substring(inflictor.message2, 0, p), a, "^1", substring(inflictor.message2, p+1, strlen(inflictor.message2) - (p+1)), "\n");
391 else if(deathtype == DEATH_TURRET)
392 bprint ("^1",s, "^1 was pushed into the line of fire by ^1", a, "\n");
393 else if(deathtype == DEATH_TOUCHEXPLODE)
394 bprint ("^1",s, "^1 was pushed into an accident by ^1", a, "\n");
395 else if(deathtype == DEATH_CHEAT)
396 bprint ("^1",s, "^1 was unfairly eliminated by ^1", a, "\n");
398 bprint ("^1",s, "^1 was fragged by ", a, "\n");
401 if(g_ctf && targ.flagcarried)
403 UpdateFrags(attacker, ctf_score_value("score_kill"));
404 PlayerScore_Add(attacker, SP_CTF_FCKILLS, 1);
405 GiveFrags(attacker, targ, 0); // for logging
408 GiveFrags(attacker, targ, 1);
410 if (targ.killcount > 2) {
412 bprint ("^1",s,"'s ^1", ftos(targ.killcount), " scoring spree was ended by ", a, "\n");
414 bprint ("^1",s,"'s ^1", ftos(targ.killcount), " kill spree was ended by ", a, "\n");
417 attacker.killcount = attacker.killcount + 1;
419 if (attacker.killcount > 2) {
421 bprint ("^1",a,"^1 made ",ftos(attacker.killcount)," scores in a row\n");
423 bprint ("^1",a,"^1 has ",ftos(attacker.killcount)," frags in a row\n");
426 LogDeath("frag", deathtype, attacker, targ);
428 if (attacker.killcount == 3)
431 bprint (a,"^7 made a ^1TRIPLE SCORE\n");
433 bprint (a,"^7 made a ^1TRIPLE FRAG\n");
434 announce(attacker, "announcer/male/03kills.wav");
437 else if (attacker.killcount == 5)
440 bprint (a,"^7 unleashes ^1SCORING RAGE\n");
442 bprint (a,"^7 unleashes ^1RAGE\n");
443 announce(attacker, "announcer/male/05kills.wav");
446 else if (attacker.killcount == 10)
449 bprint (a,"^7 made ^1TEN SCORES IN A ROW!\n");
451 bprint (a,"^7 starts the ^1MASSACRE!\n");
452 announce(attacker, "announcer/male/10kills.wav");
455 else if (attacker.killcount == 15)
458 bprint (a,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
460 bprint (a,"^7 executes ^1MAYHEM!\n");
461 announce(attacker, "announcer/male/15kills.wav");
464 else if (attacker.killcount == 20)
467 bprint (a,"^7 made ^1TWENTY SCORES IN A ROW!\n");
469 bprint (a,"^7 is a ^1BERSERKER!\n");
470 announce(attacker, "announcer/male/20kills.wav");
473 else if (attacker.killcount == 25)
476 bprint (a,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
478 bprint (a,"^7 inflicts ^1CARNAGE!\n");
479 announce(attacker, "announcer/male/25kills.wav");
482 else if (attacker.killcount == 30)
485 bprint (a,"^7 made ^1THIRTY SCORES IN A ROW!\n");
487 bprint (a,"^7 unleashes ^1ARMAGEDDON!\n");
488 announce(attacker, "announcer/male/30kills.wav");
495 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
496 if (deathtype == DEATH_HURTTRIGGER && inflictor.message != "")
497 bprint ("^1",s, "^1 ", inflictor.message, "\n");
498 else if (deathtype == DEATH_DROWN)
500 bprint ("^1",s, "^1 was in the water for too long\n");
502 bprint ("^1",s, "^1 drowned\n");
503 else if (deathtype == DEATH_SLIME)
504 bprint ("^1",s, "^1 was slimed\n");
505 else if (deathtype == DEATH_LAVA)
507 bprint ("^1",s, "^1 found a hot place\n");
509 bprint ("^1",s, "^1 turned into hot slag\n");
510 else if (deathtype == DEATH_FALL)
512 bprint ("^1",s, "^1 tested gravity (and it worked)\n");
514 bprint ("^1",s, "^1 hit the ground with a crunch\n");
515 else if (deathtype == DEATH_SHOOTING_STAR)
516 bprint ("^1",s, "^1 became a shooting star\n");
517 else if (deathtype == DEATH_SWAMP)
519 bprint ("^1",s, "^1 discovered a swamp\n");
521 bprint ("^1",s, "^1 is now conserved for centuries to come\n");
522 else if(deathtype == DEATH_TURRET)
523 bprint ("^1",s, "^1 was mowed down by a turret \n");
524 else if(deathtype == DEATH_TOUCHEXPLODE)
525 bprint ("^1",s, "^1 died in an accident\n");
526 else if(deathtype == DEATH_CHEAT)
527 bprint ("^1",s, "^1 was unfairly eliminated\n");
530 bprint ("^1",s, "^1 needs a restart\n");
532 bprint ("^1",s, "^1 died\n");
533 GiveFrags(targ, targ, -1);
534 if(PlayerScore_Add(targ, SP_SCORE, 0) == -5) {
535 announce(targ, "announcer/male/botlike.wav");
538 if (targ.killcount > 2)
540 bprint ("^1",s,"^1 needs a restart after a ",ftos(targ.killcount)," scoring spree\n");
542 bprint ("^1",s,"^1 died with a ",ftos(targ.killcount)," kill spree\n");
544 LogDeath("accident", deathtype, targ, targ);
546 targ.death_origin = targ.origin;
548 targ.killer_origin = attacker.origin;
549 // FIXME: this should go in PutClientInServer
555 // these are updated by each Damage call for use in button triggering and such
557 entity damage_inflictor;
558 entity damage_attacker;
560 void Damage (entity targ, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
565 entity attacker_save;
569 if (gameover || targ.killcount == -666)
572 local entity oldself;
576 damage_inflictor = inflictor;
577 damage_attacker = attacker;
578 attacker_save = attacker;
580 if(targ.classname == "player")
583 if(targ.hook.aiment == attacker)
584 RemoveGrapplingHook(targ); // STOP THAT, you parasite!
586 // special rule: gravity bomb does not hit team mates (other than for disconnecting the hook)
587 if(DEATH_ISWEAPON(deathtype, WEP_HOOK))
589 if(targ.classname == "player")
590 if not(IsDifferentTeam(targ, attacker))
597 if(deathtype == DEATH_KILL || deathtype == DEATH_TEAMCHANGE || deathtype == DEATH_AUTOTEAMCHANGE)
599 // These are ALWAYS lethal
600 // No damage modification here
601 // Instead, prepare the victim for his death...
603 targ.spawnshieldtime = 0;
604 targ.health = 0.9; // this is < 1
605 targ.flags -= targ.flags & FL_GODMODE;
608 else if(deathtype == DEATH_MIRRORDAMAGE || deathtype == DEATH_NOAMMO)
614 if (targ.classname == "player")
615 if (attacker.classname == "player")
618 damage = damage * bound(0.1, (skill + 5) * 0.1, 1);
620 // nullify damage if teamplay is on
621 if(deathtype != DEATH_TELEFRAG)
622 if(attacker.classname == "player")
624 if(targ.classname == "player" && targ != attacker && (IS_INDEPENDENT_PLAYER(attacker) || IS_INDEPENDENT_PLAYER(targ)))
629 else if(attacker.team == targ.team)
633 else if(attacker != targ)
637 else if(teamplay == 4)
639 if(targ.classname == "player" && targ.deadflag == DEAD_NO)
641 teamdamage0 = max(attacker.dmg_team, cvar("g_teamdamage_threshold"));
642 attacker.dmg_team = attacker.dmg_team + damage;
643 if(attacker.dmg_team > teamdamage0)
644 mirrordamage = cvar("g_mirrordamage") * (attacker.dmg_team - teamdamage0);
645 mirrorforce = cvar("g_mirrordamage") * vlen(force);
648 if(cvar("g_friendlyfire") == 0)
652 damage = cvar("g_friendlyfire") * damage;
653 // mirrordamage will be used LATER
662 if(targ.classname == "player")
663 if(attacker.classname == "player")
666 targ.lms_traveled_distance = cvar("g_lms_campcheck_distance");
667 attacker.lms_traveled_distance = cvar("g_lms_campcheck_distance");
670 if(targ.classname == "player")
673 if ((deathtype == DEATH_FALL) ||
674 (deathtype == DEATH_DROWN) ||
675 (deathtype == DEATH_SLIME) ||
676 (deathtype == DEATH_LAVA))
681 if (targ.armorvalue && (deathtype == WEP_MINSTANEX) && damage)
683 targ.armorvalue -= 1;
684 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^3Remaining extra lives: ",ftos(targ.armorvalue)));
688 if (DEATH_ISWEAPON(deathtype, WEP_LASER))
691 if (targ != attacker)
693 if (targ.classname == "player")
694 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "Secondary fire inflicts no damage!"));
704 // apply strength multiplier
705 if ((attacker.items & IT_STRENGTH) && !g_minstagib)
709 damage = damage * cvar("g_balance_powerup_strength_selfdamage");
710 force = force * cvar("g_balance_powerup_strength_selfforce");
714 damage = damage * cvar("g_balance_powerup_strength_damage");
715 force = force * cvar("g_balance_powerup_strength_force");
719 // apply invincibility multiplier
720 if (targ.items & IT_INVINCIBLE && !g_minstagib)
721 damage = damage * cvar("g_balance_powerup_invincible_takedamage");
723 if (targ == attacker)
724 damage = damage * cvar("g_balance_selfdamagepercent"); // Partial damage if the attacker hits himself
726 // CTF: reduce damage/force
731 damage = damage * cvar("g_ctf_flagcarrier_selfdamage");
732 force = force * cvar("g_ctf_flagcarrier_selfforce");
737 // apply strength rune
738 if (attacker.runes & RUNE_STRENGTH)
740 if(attacker.runes & CURSE_WEAK) // have both curse & rune
742 damage = damage * cvar("g_balance_rune_strength_combo_damage");
743 force = force * cvar("g_balance_rune_strength_combo_force");
747 damage = damage * cvar("g_balance_rune_strength_damage");
748 force = force * cvar("g_balance_rune_strength_force");
751 else if (attacker.runes & CURSE_WEAK)
753 damage = damage * cvar("g_balance_curse_weak_damage");
754 force = force * cvar("g_balance_curse_weak_force");
757 // apply defense rune
758 if (targ.runes & RUNE_DEFENSE)
760 if (targ.runes & CURSE_VULNER) // have both curse & rune
761 damage = damage * cvar("g_balance_rune_defense_combo_takedamage");
763 damage = damage * cvar("g_balance_rune_defense_takedamage");
765 else if (targ.runes & CURSE_VULNER)
766 damage = damage * cvar("g_balance_curse_vulner_takedamage");
772 if(targ.takedamage == DAMAGE_AIM)
774 if(targ.classname == "player")
776 if(IsDifferentTeam(targ, attacker))
781 attacker.typehitsound += 1;
783 attacker.hitsound += 1;
785 damage_goodhits += 1;
786 damage_gooddamage += damage;
788 if not(DEATH_ISSPECIAL(deathtype))
795 if(targ.items & IT_STRENGTH)
799 // find height of hit on player axis
800 // if above view_ofs and below maxs, and also in the middle half of the bbox, it is head shot
801 vector headmins, headmaxs, org;
802 org = antilag_takebackorigin(targ, time - ANTILAG_LATENCY(attacker));
803 headmins = org + '0.7 0 0' * targ.mins_x + '0 0.7 0' * targ.mins_y + '0 0 1' * targ.view_ofs_z;
804 headmaxs = org + '0.7 0 0' * targ.maxs_x + '0 0.7 0' * targ.maxs_y + '0 0 1' * targ.maxs_z;
805 if(trace_hits_box(railgun_start, railgun_end, headmins, headmaxs))
807 damage *= 1 + damage_headshotbonus;
809 deathtype |= HITTYPE_HEADSHOT;
816 attacker.typehitsound += 1;
818 if(time > attacker.teamkill_complain)
820 attacker.teamkill_complain = time + 5;
821 attacker.teamkill_soundtime = time + 0.4;
822 attacker.teamkill_soundsource = targ;
829 if (self.damageforcescale)
832 self.velocity = self.velocity + self.damageforcescale * force;
833 self.flags &~= FL_ONGROUND;
834 UpdateCSQCProjectile(self);
838 if (self.event_damage)
839 self.event_damage (inflictor, attacker, damage, deathtype, hitloc, force);
842 if(targ.classname == "player" && attacker.classname == "player" && attacker != targ && attacker.health > 2)
844 // Savage: vampire mode
847 if (time > self.spawnshieldtime)
849 attacker.health += damage;
853 if (attacker.runes & RUNE_VAMPIRE)
855 // apply vampire rune
856 if (attacker.runes & CURSE_EMPATHY) // have the curse too
858 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb");
859 attacker.health = bound(
860 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 40
861 attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb"),
862 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
866 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_absorb");
867 attacker.health = bound(
868 attacker.health, // LA: was 3, but changed so that you can't lose health
869 // empathy won't let you gain health in the same way...
870 attacker.health + damage * cvar("g_balance_rune_vampire_absorb"),
871 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
874 // apply empathy curse
875 else if (attacker.runes & CURSE_EMPATHY)
877 attacker.health = bound(
878 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 20
879 attacker.health + damage * cvar("g_balance_curse_empathy_takedamage"),
885 // apply mirror damage if any
886 if(mirrordamage > 0 || mirrorforce > 0)
888 attacker = attacker_save;
892 // just lose extra LIVES, don't kill the player for mirror damage
893 if(attacker.armorvalue > 0)
895 attacker.armorvalue = attacker.armorvalue - 1;
896 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^3Remaining extra lives: ",ftos(attacker.armorvalue)));
897 attacker.hitsound += 1;
901 force = normalize(attacker.origin + attacker.view_ofs - hitloc) * mirrorforce;
902 Damage(attacker, inflictor, attacker, mirrordamage, DEATH_MIRRORDAMAGE, attacker.origin, force);
906 vector NearestPointOnBox(entity box, vector org)
908 vector m1, m2, nearest;
910 m1 = box.mins + box.origin;
911 m2 = box.maxs + box.origin;
913 nearest_x = bound(m1_x, org_x, m2_x);
914 nearest_y = bound(m1_y, org_y, m2_y);
915 nearest_z = bound(m1_z, org_z, m2_z);
920 float RadiusDamage_running;
921 float RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype, entity directhitentity)
922 // Returns total damage applies to creatures
932 float total_damage_to_creatures;
935 if(RadiusDamage_running)
938 print("RadiusDamage called recursively!\n");
939 print("Expect stuff to go HORRIBLY wrong.\n");
940 print("Causing a stack trace...\n");
941 save = cvar_string("prvm_backtraceforwarnings");
942 cvar_set("prvm_backtraceforwarnings", "1");
943 fclose(-1); // calls VM_Warning
944 cvar_set("prvm_backtraceforwarnings", save);
949 RadiusDamage_running = 1;
951 blastorigin = (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5);
952 total_damage_to_creatures = 0;
954 if(deathtype != (WEP_HOOK | HITTYPE_SECONDARY | HITTYPE_BOUNCE)) // only send gravity bomb damage once
956 force = inflictor.velocity;
960 force = normalize(force);
961 if(forceintensity >= 0)
962 Damage_DamageInfo(blastorigin, coredamage, edgedamage, rad, forceintensity * force, deathtype);
964 Damage_DamageInfo(blastorigin, coredamage, edgedamage, -rad, (-forceintensity) * force, deathtype);
967 targ = findradius (blastorigin, rad);
971 if (targ != inflictor)
974 // LordHavoc: measure distance to nearest point on target (not origin)
975 // (this guarentees 100% damage on a touch impact)
976 nearest = NearestPointOnBox(targ, blastorigin);
977 diff = nearest - blastorigin;
978 // round up a little on the damage to ensure full damage on impacts
979 // and turn the distance into a fraction of the radius
980 power = 1 - ((vlen (diff) - 2) / rad);
982 //bprint(ftos(power));
987 finaldmg = coredamage * power + edgedamage * (1 - power);
990 center = targ.origin + (targ.mins + targ.maxs) * 0.5;
991 // if it's a player, use the view origin as reference
992 if (targ.classname == "player")
993 center = targ.origin + targ.view_ofs;
994 force = normalize(center - blastorigin) * (finaldmg / coredamage) * forceintensity;
995 // test line of sight to multiple positions on box,
996 // and do damage if any of them hit
998 c = ceil(finaldmg / 10);
1004 traceline(blastorigin, nearest, TRUE, inflictor);
1005 if (trace_fraction == 1 || trace_ent == targ
1006 || cvar("g_throughfloor"))
1009 total_damage_to_creatures += finaldmg;
1010 if(targ == directhitentity || DEATH_ISSPECIAL(deathtype))
1011 Damage (targ, inflictor, attacker, finaldmg, deathtype, nearest, force);
1013 Damage (targ, inflictor, attacker, finaldmg, deathtype | HITTYPE_SPLASH, nearest, force);
1016 nearest_x = targ.mins_x + random() * targ.size_x;
1017 nearest_y = targ.mins_y + random() * targ.size_y;
1018 nearest_z = targ.mins_z + random() * targ.size_z;
1026 RadiusDamage_running = 0;
1028 return total_damage_to_creatures;