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?
27 org = findbetterlocation(org, 1);
30 e.classname = "damageinfo";
34 e.nextthink = time + 0.2;
35 e.projectiledeathtype = deathtype;
37 e.dmg_edge = edgedamage;
39 e.dmg_force = vlen(force);
42 e.oldorigin_x = compressShortVector(e.velocity);
44 e.SendEntity = Damage_DamageInfo_SendEntity;
47 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
49 float checkrules_firstblood;
52 float damage_goodhits;
53 float damage_gooddamage;
55 float damage_headshotbonus; // bonus multiplier for head shots, set to 0 after use
58 .float teamkill_complain;
59 .float teamkill_soundtime;
60 .entity teamkill_soundsource;
62 .float taunt_soundtime;
65 float IsDifferentTeam(entity a, entity b)
80 float IsFlying(entity a)
82 if(a.flags & FL_ONGROUND)
86 traceline(a.origin, a.origin - '0 0 48', MOVE_NORMAL, a);
87 if(trace_fraction < 1)
92 void UpdateFrags(entity player, float f)
94 PlayerTeamScore_AddScore(player, f);
97 // NOTE: f=0 means still count as a (positive) kill, but count no frags for it
98 void GiveFrags (entity attacker, entity targ, float f)
100 // TODO route through PlayerScores instead
108 PlayerScore_Add(attacker, SP_SUICIDES, 1);
113 PlayerScore_Add(attacker, SP_KILLS, -1); // or maybe add a teamkills field?
119 PlayerScore_Add(attacker, SP_KILLS, 1);
122 PlayerScore_Add(targ, SP_DEATHS, 1);
125 if(cvar("g_arena_roundbased"))
128 // FIXME fix the mess this is (we have REAL points now!)
131 f = RunematchHandleFrags(attacker, targ, f);
135 f = kh_HandleFrags(attacker, targ, f);
141 tl = PlayerScore_Add(targ, SP_LMS_LIVES, -1);
142 if(tl < lms_lowest_lives)
143 lms_lowest_lives = tl;
147 lms_next_place = player_count;
148 PlayerScore_Add(targ, SP_LMS_RANK, lms_next_place); // won't ever spawn again
155 if(g_ctf_ignore_frags)
159 attacker.totalfrags += f;
162 UpdateFrags(attacker, f);
165 string AppendItemcodes(string s, entity player)
170 // w = player.switchweapon;
172 w = player.cnt; // previous weapon!
173 s = strcat(s, ftos(w));
174 if(time < player.strength_finished)
176 if(time < player.invincible_finished)
178 if(player.flagcarried != world)
180 if(player.BUTTON_CHAT)
185 s = strcat(s, "|", ftos(player.runes));
189 void LogDeath(string mode, float deathtype, entity killer, entity killed)
192 if(!cvar("sv_eventlog"))
194 s = strcat(":kill:", mode);
195 s = strcat(s, ":", ftos(killer.playerid));
196 s = strcat(s, ":", ftos(killed.playerid));
197 s = strcat(s, ":type=", ftos(deathtype));
198 s = strcat(s, ":items=");
199 s = AppendItemcodes(s, killer);
202 s = strcat(s, ":victimitems=");
203 s = AppendItemcodes(s, killed);
208 void Obituary (entity attacker, entity inflictor, entity targ, float deathtype)
213 if (targ.classname == "player" || targ.classname == "corpse")
215 if (targ.classname == "corpse")
219 a = attacker.netname;
221 if (targ == attacker)
223 if (deathtype == DEATH_TEAMCHANGE) {
224 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", ColoredTeamName(targ.team)));
225 } else if (deathtype == DEATH_AUTOTEAMCHANGE) {
226 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)));
228 } else if (deathtype == DEATH_CAMP) {
230 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
232 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
233 } else if (deathtype == DEATH_NOAMMO) {
235 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
237 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
238 } else if (deathtype == DEATH_ROT) {
240 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
242 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
243 } else if (deathtype == DEATH_MIRRORDAMAGE) {
245 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
247 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
250 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
252 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
256 if (deathtype == DEATH_CAMP)
257 bprint ("^1",s, "^1 thought he found a nice camping ground\n");
258 else if (deathtype == DEATH_MIRRORDAMAGE)
259 bprint ("^1",s, "^1 didn't become friends with the Lord of Teamplay\n");
261 bprint ("^1",s, "^1 will be reinserted into the game due to his own actions\n");
263 if(deathtype != DEATH_TEAMCHANGE)
265 LogDeath("suicide", deathtype, targ, targ);
266 GiveFrags(attacker, targ, -1);
268 if (targ.killcount > 2)
269 bprint ("^1",s,"^1 faded after a ",ftos(targ.killcount)," point spree\n");
271 w = DEATH_WEAPONOF(deathtype);
274 w_deathtypestring = "couldn't resist the urge to self-destruct";
275 w_deathtype = deathtype;
276 weapon_action(w, WR_SUICIDEMESSAGE);
277 bprint("^1", s, "^1 ", w_deathtypestring, "\n");
279 else if (deathtype == DEATH_KILL)
280 bprint ("^1",s, "^1 couldn't take it anymore\n");
281 else if (deathtype == DEATH_ROT)
282 bprint ("^1",s, "^1 died\n");
283 else if (deathtype == DEATH_NOAMMO)
284 bprint ("^7",s, "^7 committed suicide. What's the point of living without ammo?\n");
285 else if (deathtype == DEATH_CAMP)
286 bprint ("^1",s, "^1 thought he found a nice camping ground\n");
287 else if (deathtype == DEATH_MIRRORDAMAGE)
288 bprint ("^1",s, "^1 didn't become friends with the Lord of Teamplay\n");
289 else if (deathtype != DEATH_TEAMCHANGE)
290 bprint ("^1",s, "^1 couldn't resist the urge to self-destruct\n");
292 if(deathtype != DEATH_TEAMCHANGE)
294 LogDeath("suicide", deathtype, targ, targ);
295 GiveFrags(attacker, targ, -1);
297 if (targ.killcount > 2)
298 bprint ("^1",s,"^1 ended it all after a ",ftos(targ.killcount)," kill spree\n");
301 else if (attacker.classname == "player" || attacker.classname == "gib")
303 if(teamplay && attacker.team == targ.team)
306 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against a team mate!"));
307 bprint ("^1", a, "^1 took action against a team mate\n");
309 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s, ", a team mate!"));
310 bprint ("^1", a, "^1 mows down a team mate\n");
312 GiveFrags(attacker, targ, -1);
313 if (targ.killcount > 2) {
315 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," scoring spree was ended by a team mate!\n");
317 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," kill spree was ended by a team mate!\n");
319 if (attacker.killcount > 2) {
321 bprint ("^1",a,"^1 ended a ",ftos(attacker.killcount)," scoring spree by going against a team mate\n");
323 bprint ("^1",a,"^1 ended a ",ftos(attacker.killcount)," kill spree by killing a team mate\n");
325 attacker.killcount = 0;
327 LogDeath("tk", deathtype, attacker, targ);
331 string blood_message, victim_message;
332 if (!checkrules_firstblood)
334 checkrules_firstblood = TRUE;
337 bprint("^1",a, "^1 was the first to score", "\n");
338 blood_message = "^1First point\n";
339 //victim_message = "^1First victim\n"; // or First casualty
343 bprint("^1",a, "^1 drew first blood", "\n");
344 blood_message = "^1First blood\n";
345 victim_message = "^1First victim\n"; // or First casualty
350 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s));
351 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, a,"^1 scored against you ^7"));
353 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, blood_message, "^4You fragged ^7", s));
354 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, victim_message, "^1You were fragged by ^7", a));
355 attacker.taunt_soundtime = time + 1;
359 bprint ("^1",s, "^1 needs a restart thanks to ", a, "\n");
361 w = DEATH_WEAPONOF(deathtype);
364 w_deathtypestring = "was blasted by";
365 w_deathtype = deathtype;
366 weapon_action(w, WR_KILLMESSAGE);
367 p = strstrofs(w_deathtypestring, "#", 0);
369 bprint("^1", s, "^1 ", w_deathtypestring, " ", a, "\n");
371 bprint("^1", s, "^1 ", substring(w_deathtypestring, 0, p), a, "^1", substring(w_deathtypestring, p+1, strlen(w_deathtypestring) - (p+1)), "\n");
373 else if (deathtype == DEATH_TELEFRAG)
374 bprint ("^1",s, "^1 was telefragged by ", a, "\n");
375 else if (deathtype == DEATH_DROWN)
376 bprint ("^1",s, "^1 was drowned by ", a, "\n");
377 else if (deathtype == DEATH_SLIME)
378 bprint ("^1",s, "^1 was slimed by ", a, "\n");
379 else if (deathtype == DEATH_LAVA)
380 bprint ("^1",s, "^1 was cooked by ", a, "\n");
381 else if (deathtype == DEATH_FALL)
382 bprint ("^1",s, "^1 was grounded by ", a, "\n");
383 else if (deathtype == DEATH_SHOOTING_STAR)
384 bprint ("^1",s, "^1 was shot into space by ", a, "\n");
385 else if (deathtype == DEATH_SWAMP)
386 bprint ("^1",s, "^1 was conserved by ", a, "\n");
387 else if (deathtype == DEATH_HURTTRIGGER && inflictor.message2 != "")
389 p = strstrofs(inflictor.message2, "#", 0);
391 bprint("^1", s, "^1 ", inflictor.message2, " ", a, "\n");
393 bprint("^1", s, "^1 ", substring(inflictor.message2, 0, p), a, "^1", substring(inflictor.message2, p+1, strlen(inflictor.message2) - (p+1)), "\n");
395 else if(deathtype == DEATH_TURRET)
396 bprint ("^1",s, "^1 was pushed into the line of fire by ^1", a, "\n");
397 else if(deathtype == DEATH_TOUCHEXPLODE)
398 bprint ("^1",s, "^1 was pushed into an accident by ^1", a, "\n");
400 bprint ("^1",s, "^1 was fragged by ", a, "\n");
403 if(g_ctf && targ.flagcarried)
405 UpdateFrags(attacker, ctf_score_value("score_kill"));
406 PlayerScore_Add(attacker, SP_CTF_FCKILLS, 1);
407 GiveFrags(attacker, targ, 0); // for logging
410 GiveFrags(attacker, targ, 1);
412 if (targ.killcount > 2) {
414 bprint ("^1",s,"'s ^1", ftos(targ.killcount), " scoring spree was ended by ", a, "\n");
416 bprint ("^1",s,"'s ^1", ftos(targ.killcount), " kill spree was ended by ", a, "\n");
419 attacker.killcount = attacker.killcount + 1;
421 if (attacker.killcount > 2) {
423 bprint ("^1",a,"^1 made ",ftos(attacker.killcount)," scores in a row\n");
425 bprint ("^1",a,"^1 has ",ftos(attacker.killcount)," frags in a row\n");
428 LogDeath("frag", deathtype, attacker, targ);
430 if (attacker.killcount == 3)
433 bprint (a,"^7 made a ^1TRIPLE SCORE\n");
435 bprint (a,"^7 made a ^1TRIPLE FRAG\n");
436 announce(attacker, "announcer/male/03kills.wav");
439 else if (attacker.killcount == 5)
442 bprint (a,"^7 unleashes ^1SCORING RAGE\n");
444 bprint (a,"^7 unleashes ^1RAGE\n");
445 announce(attacker, "announcer/male/05kills.wav");
448 else if (attacker.killcount == 10)
451 bprint (a,"^7 made ^1TEN SCORES IN A ROW!\n");
453 bprint (a,"^7 starts the ^1MASSACRE!\n");
454 announce(attacker, "announcer/male/10kills.wav");
457 else if (attacker.killcount == 15)
460 bprint (a,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
462 bprint (a,"^7 executes ^1MAYHEM!\n");
463 announce(attacker, "announcer/male/15kills.wav");
466 else if (attacker.killcount == 20)
469 bprint (a,"^7 made ^1TWENTY SCORES IN A ROW!\n");
471 bprint (a,"^7 is a ^1BERSERKER!\n");
472 announce(attacker, "announcer/male/20kills.wav");
475 else if (attacker.killcount == 25)
478 bprint (a,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
480 bprint (a,"^7 inflicts ^1CARNAGE!\n");
481 announce(attacker, "announcer/male/25kills.wav");
484 else if (attacker.killcount == 30)
487 bprint (a,"^7 made ^1THIRTY SCORES IN A ROW!\n");
489 bprint (a,"^7 unleashes ^1ARMAGEDDON!\n");
490 announce(attacker, "announcer/male/30kills.wav");
497 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
498 if (deathtype == DEATH_HURTTRIGGER && inflictor.message != "")
499 bprint ("^1",s, "^1 ", inflictor.message, "\n");
500 else if (deathtype == DEATH_DROWN)
502 bprint ("^1",s, "^1 was in the water for too long\n");
504 bprint ("^1",s, "^1 drowned\n");
505 else if (deathtype == DEATH_SLIME)
506 bprint ("^1",s, "^1 was slimed\n");
507 else if (deathtype == DEATH_LAVA)
509 bprint ("^1",s, "^1 found a hot place\n");
511 bprint ("^1",s, "^1 turned into hot slag\n");
512 else if (deathtype == DEATH_FALL)
514 bprint ("^1",s, "^1 tested gravity (and it worked)\n");
516 bprint ("^1",s, "^1 hit the ground with a crunch\n");
517 else if (deathtype == DEATH_SHOOTING_STAR)
518 bprint ("^1",s, "^1 became a shooting star\n");
519 else if (deathtype == DEATH_SWAMP)
521 bprint ("^1",s, "^1 discovered a swamp\n");
523 bprint ("^1",s, "^1 is now conserved for centuries to come\n");
524 else if(deathtype == DEATH_TURRET)
525 bprint ("^1",s, "^1 was mowed down by a turret \n");
526 else if(deathtype == DEATH_TOUCHEXPLODE)
527 bprint ("^1",s, "^1 died in an accident\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");
672 if ((deathtype == DEATH_FALL) ||
673 (deathtype == DEATH_DROWN) ||
674 (deathtype == DEATH_SLIME) ||
675 (deathtype == DEATH_LAVA))
680 if (targ.armorvalue && (deathtype == WEP_MINSTANEX) && damage)
682 targ.armorvalue -= 1;
683 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^3Remaining extra lives: ",ftos(targ.armorvalue)));
687 if (DEATH_ISWEAPON(deathtype, WEP_LASER))
690 if (targ != attacker)
692 if (targ.classname == "player")
693 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "Secondary fire inflicts no damage!"));
703 // apply strength multiplier
704 if ((attacker.items & IT_STRENGTH) && !g_minstagib)
708 damage = damage * cvar("g_balance_powerup_strength_selfdamage");
709 force = force * cvar("g_balance_powerup_strength_selfforce");
713 damage = damage * cvar("g_balance_powerup_strength_damage");
714 force = force * cvar("g_balance_powerup_strength_force");
718 // apply invincibility multiplier
719 if (targ.items & IT_INVINCIBLE && !g_minstagib)
720 damage = damage * cvar("g_balance_powerup_invincible_takedamage");
722 if (targ == attacker)
723 damage = damage * cvar("g_balance_selfdamagepercent"); // Partial damage if the attacker hits himself
725 // CTF: reduce damage/force
730 damage = damage * cvar("g_ctf_flagcarrier_selfdamage");
731 force = force * cvar("g_ctf_flagcarrier_selfforce");
736 // apply strength rune
737 if (attacker.runes & RUNE_STRENGTH)
739 if(attacker.runes & CURSE_WEAK) // have both curse & rune
741 damage = damage * cvar("g_balance_rune_strength_combo_damage");
742 force = force * cvar("g_balance_rune_strength_combo_force");
746 damage = damage * cvar("g_balance_rune_strength_damage");
747 force = force * cvar("g_balance_rune_strength_force");
750 else if (attacker.runes & CURSE_WEAK)
752 damage = damage * cvar("g_balance_curse_weak_damage");
753 force = force * cvar("g_balance_curse_weak_force");
756 // apply defense rune
757 if (targ.runes & RUNE_DEFENSE)
759 if (targ.runes & CURSE_VULNER) // have both curse & rune
760 damage = damage * cvar("g_balance_rune_defense_combo_takedamage");
762 damage = damage * cvar("g_balance_rune_defense_takedamage");
764 else if (targ.runes & CURSE_VULNER)
765 damage = damage * cvar("g_balance_curse_vulner_takedamage");
771 if(targ.takedamage == DAMAGE_AIM)
773 if(targ.classname == "player")
775 if(IsDifferentTeam(targ, attacker))
780 attacker.typehitsound += 1;
782 attacker.hitsound += 1;
784 damage_goodhits += 1;
785 damage_gooddamage += damage;
787 if not(DEATH_ISSPECIAL(deathtype))
794 if(targ.items & IT_STRENGTH)
798 // find height of hit on player axis
799 // if above view_ofs and below maxs, and also in the middle half of the bbox, it is head shot
800 vector headmins, headmaxs, org;
801 org = antilag_takebackorigin(targ, time - ANTILAG_LATENCY(attacker));
802 headmins = org + '0.7 0 0' * targ.mins_x + '0 0.7 0' * targ.mins_y + '0 0 1' * targ.view_ofs_z;
803 headmaxs = org + '0.7 0 0' * targ.maxs_x + '0 0.7 0' * targ.maxs_y + '0 0 1' * targ.maxs_z;
804 if(trace_hits_box(railgun_start, railgun_end, headmins, headmaxs))
806 damage *= 1 + damage_headshotbonus;
808 deathtype |= HITTYPE_HEADSHOT;
815 attacker.typehitsound += 1;
817 if(time > attacker.teamkill_complain)
819 attacker.teamkill_complain = time + 5;
820 attacker.teamkill_soundtime = time + 0.4;
821 attacker.teamkill_soundsource = targ;
828 if (self.damageforcescale)
831 self.velocity = self.velocity + self.damageforcescale * force;
832 self.flags = self.flags - (self.flags & FL_ONGROUND);
833 UpdateCSQCProjectile(self);
837 if (self.event_damage)
838 self.event_damage (inflictor, attacker, damage, deathtype, hitloc, force);
841 if(targ.classname == "player" && attacker.classname == "player" && attacker != targ && attacker.health > 2)
843 // Savage: vampire mode
846 if (time > self.spawnshieldtime)
848 attacker.health += damage;
852 if (attacker.runes & RUNE_VAMPIRE)
854 // apply vampire rune
855 if (attacker.runes & CURSE_EMPATHY) // have the curse too
857 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb");
858 attacker.health = bound(
859 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 40
860 attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb"),
861 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
865 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_absorb");
866 attacker.health = bound(
867 attacker.health, // LA: was 3, but changed so that you can't lose health
868 // empathy won't let you gain health in the same way...
869 attacker.health + damage * cvar("g_balance_rune_vampire_absorb"),
870 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
873 // apply empathy curse
874 else if (attacker.runes & CURSE_EMPATHY)
876 attacker.health = bound(
877 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 20
878 attacker.health + damage * cvar("g_balance_curse_empathy_takedamage"),
884 // apply mirror damage if any
885 if(mirrordamage > 0 || mirrorforce > 0)
887 attacker = attacker_save;
891 // just lose extra LIVES, don't kill the player for mirror damage
892 if(attacker.armorvalue > 0)
894 attacker.armorvalue = attacker.armorvalue - 1;
895 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^3Remaining extra lives: ",ftos(attacker.armorvalue)));
896 attacker.hitsound += 1;
900 force = normalize(attacker.origin + attacker.view_ofs - hitloc) * mirrorforce;
901 Damage(attacker, inflictor, attacker, mirrordamage, DEATH_MIRRORDAMAGE, attacker.origin, force);
905 vector NearestPointOnBox(entity box, vector org)
907 vector m1, m2, nearest;
909 m1 = box.mins + box.origin;
910 m2 = box.maxs + box.origin;
912 nearest_x = bound(m1_x, org_x, m2_x);
913 nearest_y = bound(m1_y, org_y, m2_y);
914 nearest_z = bound(m1_z, org_z, m2_z);
919 float RadiusDamage_running;
920 float RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype, entity directhitentity)
921 // Returns total damage applies to creatures
931 float total_damage_to_creatures;
934 if(RadiusDamage_running)
937 print("RadiusDamage called recursively!\n");
938 print("Expect stuff to go HORRIBLY wrong.\n");
939 print("Causing a stack trace...\n");
940 save = cvar_string("prvm_backtraceforwarnings");
941 cvar_set("prvm_backtraceforwarnings", "1");
942 fclose(-1); // calls VM_Warning
943 cvar_set("prvm_backtraceforwarnings", save);
948 RadiusDamage_running = 1;
950 blastorigin = (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5);
951 total_damage_to_creatures = 0;
953 if(deathtype != (WEP_HOOK | HITTYPE_SECONDARY | HITTYPE_BOUNCE)) // only send gravity bomb damage once
955 force = inflictor.velocity;
959 force = normalize(force);
960 Damage_DamageInfo(blastorigin, coredamage, edgedamage, rad, forceintensity * force, deathtype);
963 targ = findradius (blastorigin, rad);
967 if (targ != inflictor)
970 // LordHavoc: measure distance to nearest point on target (not origin)
971 // (this guarentees 100% damage on a touch impact)
972 nearest = NearestPointOnBox(targ, blastorigin);
973 diff = nearest - blastorigin;
974 // round up a little on the damage to ensure full damage on impacts
975 // and turn the distance into a fraction of the radius
976 power = 1 - ((vlen (diff) - 2) / rad);
978 //bprint(ftos(power));
983 finaldmg = coredamage * power + edgedamage * (1 - power);
986 center = targ.origin + (targ.mins + targ.maxs) * 0.5;
987 // if it's a player, use the view origin as reference
988 if (targ.classname == "player")
989 center = targ.origin + targ.view_ofs;
990 force = normalize(center - blastorigin) * (finaldmg / coredamage) * forceintensity;
991 // test line of sight to multiple positions on box,
992 // and do damage if any of them hit
994 c = ceil(finaldmg / 10);
1000 traceline(blastorigin, nearest, TRUE, inflictor);
1001 if (trace_fraction == 1 || trace_ent == targ
1002 || cvar("g_throughfloor"))
1005 total_damage_to_creatures += finaldmg;
1006 if(targ == directhitentity || DEATH_ISSPECIAL(deathtype))
1007 Damage (targ, inflictor, attacker, finaldmg, deathtype, nearest, force);
1009 Damage (targ, inflictor, attacker, finaldmg, deathtype | HITTYPE_SPLASH, nearest, force);
1012 nearest_x = targ.mins_x + random() * targ.size_x;
1013 nearest_y = targ.mins_y + random() * targ.size_y;
1014 nearest_z = targ.mins_z + random() * targ.size_z;
1022 RadiusDamage_running = 0;
1024 return total_damage_to_creatures;