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?
28 e.classname = "damageinfo";
32 e.nextthink = time + 0.2;
33 e.projectiledeathtype = deathtype;
35 e.dmg_edge = edgedamage;
37 e.dmg_force = vlen(force);
40 e.oldorigin_x = compressShortVector(e.velocity);
42 e.SendEntity = Damage_DamageInfo_SendEntity;
45 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
47 float checkrules_firstblood;
50 float damage_goodhits;
51 float damage_gooddamage;
53 float damage_headshotbonus; // bonus multiplier for head shots, set to 0 after use
56 .float teamkill_complain;
57 .float teamkill_soundtime;
58 .entity teamkill_soundsource;
60 .float taunt_soundtime;
63 float IsDifferentTeam(entity a, entity b)
78 float IsFlying(entity a)
80 if(a.flags & FL_ONGROUND)
84 traceline(a.origin, a.origin - '0 0 48', MOVE_NORMAL, a);
85 if(trace_fraction < 1)
90 void UpdateFrags(entity player, float f)
92 PlayerTeamScore_AddScore(player, f);
95 // NOTE: f=0 means still count as a (positive) kill, but count no frags for it
96 void GiveFrags (entity attacker, entity targ, float f)
98 // TODO route through PlayerScores instead
106 PlayerScore_Add(attacker, SP_SUICIDES, 1);
111 PlayerScore_Add(attacker, SP_KILLS, -1); // or maybe add a teamkills field?
117 PlayerScore_Add(attacker, SP_KILLS, 1);
120 PlayerScore_Add(targ, SP_DEATHS, 1);
123 if(cvar("g_arena_roundbased"))
126 // FIXME fix the mess this is (we have REAL points now!)
129 f = RunematchHandleFrags(attacker, targ, f);
133 f = kh_HandleFrags(attacker, targ, f);
139 tl = PlayerScore_Add(targ, SP_LMS_LIVES, -1);
140 if(tl < lms_lowest_lives)
141 lms_lowest_lives = tl;
145 lms_next_place = player_count;
146 PlayerScore_Add(targ, SP_LMS_RANK, lms_next_place); // won't ever spawn again
153 if(g_ctf_ignore_frags)
157 attacker.totalfrags += f;
160 UpdateFrags(attacker, f);
163 string AppendItemcodes(string s, entity player)
168 // w = player.switchweapon;
170 w = player.cnt; // previous weapon!
171 s = strcat(s, ftos(w));
172 if(time < player.strength_finished)
174 if(time < player.invincible_finished)
176 if(player.flagcarried != world)
178 if(player.BUTTON_CHAT)
183 s = strcat(s, "|", ftos(player.runes));
187 void LogDeath(string mode, float deathtype, entity killer, entity killed)
190 if(!cvar("sv_eventlog"))
192 s = strcat(":kill:", mode);
193 s = strcat(s, ":", ftos(killer.playerid));
194 s = strcat(s, ":", ftos(killed.playerid));
195 s = strcat(s, ":type=", ftos(deathtype));
196 s = strcat(s, ":items=");
197 s = AppendItemcodes(s, killer);
200 s = strcat(s, ":victimitems=");
201 s = AppendItemcodes(s, killed);
206 void Obituary (entity attacker, entity inflictor, entity targ, float deathtype)
211 if (targ.classname == "player" || targ.classname == "corpse")
213 if (targ.classname == "corpse")
217 a = attacker.netname;
219 if (targ == attacker)
221 if (deathtype == DEATH_TEAMCHANGE) {
222 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", ColoredTeamName(targ.team)));
223 } else if (deathtype == DEATH_AUTOTEAMCHANGE) {
224 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)));
226 } else if (deathtype == DEATH_CAMP) {
228 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
230 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
231 } else if (deathtype == DEATH_NOAMMO) {
233 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
235 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
236 } else if (deathtype == DEATH_ROT) {
238 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
240 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
241 } else if (deathtype == DEATH_MIRRORDAMAGE) {
243 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
245 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
248 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
250 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
254 if (deathtype == DEATH_CAMP)
255 bprint ("^1",s, "^1 thought he found a nice camping ground\n");
256 else if (deathtype == DEATH_MIRRORDAMAGE)
257 bprint ("^1",s, "^1 didn't become friends with the Lord of Teamplay\n");
259 bprint ("^1",s, "^1 will be reinserted into the game due to his own actions\n");
261 if(deathtype != DEATH_TEAMCHANGE)
263 LogDeath("suicide", deathtype, targ, targ);
264 GiveFrags(attacker, targ, -1);
266 if (targ.killcount > 2)
267 bprint ("^1",s,"^1 faded after a ",ftos(targ.killcount)," point spree\n");
269 w = DEATH_WEAPONOF(deathtype);
272 w_deathtypestring = "couldn't resist the urge to self-destruct";
273 w_deathtype = deathtype;
274 weapon_action(w, WR_SUICIDEMESSAGE);
275 bprint("^1", s, "^1 ", w_deathtypestring, "\n");
277 else if (deathtype == DEATH_KILL)
278 bprint ("^1",s, "^1 couldn't take it anymore\n");
279 else if (deathtype == DEATH_ROT)
280 bprint ("^1",s, "^1 died\n");
281 else if (deathtype == DEATH_NOAMMO)
282 bprint ("^7",s, "^7 committed suicide. What's the point of living without ammo?\n");
283 else if (deathtype == DEATH_CAMP)
284 bprint ("^1",s, "^1 thought he found a nice camping ground\n");
285 else if (deathtype == DEATH_MIRRORDAMAGE)
286 bprint ("^1",s, "^1 didn't become friends with the Lord of Teamplay\n");
287 else if (deathtype != DEATH_TEAMCHANGE)
288 bprint ("^1",s, "^1 couldn't resist the urge to self-destruct\n");
290 if(deathtype != DEATH_TEAMCHANGE)
292 LogDeath("suicide", deathtype, targ, targ);
293 GiveFrags(attacker, targ, -1);
295 if (targ.killcount > 2)
296 bprint ("^1",s,"^1 ended it all after a ",ftos(targ.killcount)," kill spree\n");
299 else if (attacker.classname == "player" || attacker.classname == "gib")
301 if(teamplay && attacker.team == targ.team)
304 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against a team mate!"));
305 bprint ("^1", a, "^1 took action against a team mate\n");
307 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s, ", a team mate!"));
308 bprint ("^1", a, "^1 mows down a team mate\n");
310 GiveFrags(attacker, targ, -1);
311 if (targ.killcount > 2) {
313 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," scoring spree was ended by a team mate!\n");
315 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," kill spree was ended by a team mate!\n");
317 if (attacker.killcount > 2) {
319 bprint ("^1",a,"^1 ended a ",ftos(attacker.killcount)," scoring spree by going against a team mate\n");
321 bprint ("^1",a,"^1 ended a ",ftos(attacker.killcount)," kill spree by killing a team mate\n");
323 attacker.killcount = 0;
325 LogDeath("tk", deathtype, attacker, targ);
329 string blood_message, victim_message;
330 if (!checkrules_firstblood)
332 checkrules_firstblood = TRUE;
335 bprint("^1",a, "^1 was the first to score", "\n");
336 blood_message = "^1First point\n";
337 //victim_message = "^1First victim\n"; // or First casualty
341 bprint("^1",a, "^1 drew first blood", "\n");
342 blood_message = "^1First blood\n";
343 victim_message = "^1First victim\n"; // or First casualty
348 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s));
349 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, a,"^1 scored against you ^7"));
351 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, blood_message, "^4You fragged ^7", s));
352 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, victim_message, "^1You were fragged by ^7", a));
353 attacker.taunt_soundtime = time + 1;
357 bprint ("^1",s, "^1 needs a restart thanks to ", a, "\n");
359 w = DEATH_WEAPONOF(deathtype);
362 w_deathtypestring = "was blasted by";
363 w_deathtype = deathtype;
364 weapon_action(w, WR_KILLMESSAGE);
365 p = strstrofs(w_deathtypestring, "#", 0);
367 bprint("^1", s, "^1 ", w_deathtypestring, " ", a, "\n");
369 bprint("^1", s, "^1 ", substring(w_deathtypestring, 0, p), a, "^1", substring(w_deathtypestring, p+1, strlen(w_deathtypestring) - (p+1)), "\n");
371 else if (deathtype == DEATH_TELEFRAG)
372 bprint ("^1",s, "^1 was telefragged by ", a, "\n");
373 else if (deathtype == DEATH_DROWN)
374 bprint ("^1",s, "^1 was drowned by ", a, "\n");
375 else if (deathtype == DEATH_SLIME)
376 bprint ("^1",s, "^1 was slimed by ", a, "\n");
377 else if (deathtype == DEATH_LAVA)
378 bprint ("^1",s, "^1 was cooked by ", a, "\n");
379 else if (deathtype == DEATH_FALL)
380 bprint ("^1",s, "^1 was grounded by ", a, "\n");
381 else if (deathtype == DEATH_SHOOTING_STAR)
382 bprint ("^1",s, "^1 was shot into space by ", a, "\n");
383 else if (deathtype == DEATH_SWAMP)
384 bprint ("^1",s, "^1 was conserved by ", a, "\n");
385 else if (deathtype == DEATH_HURTTRIGGER && inflictor.message2 != "")
387 p = strstrofs(inflictor.message2, "#", 0);
389 bprint("^1", s, "^1 ", inflictor.message2, " ", a, "\n");
391 bprint("^1", s, "^1 ", substring(inflictor.message2, 0, p), a, "^1", substring(inflictor.message2, p+1, strlen(inflictor.message2) - (p+1)), "\n");
393 else if(deathtype == DEATH_TURRET)
394 bprint ("^1",s, "^1 was pushed into the line of fire by ^1", a, "\n");
395 else if(deathtype == DEATH_TOUCHEXPLODE)
396 bprint ("^1",s, "^1 was pushed into an accident 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");
528 bprint ("^1",s, "^1 needs a restart\n");
530 bprint ("^1",s, "^1 died\n");
531 GiveFrags(targ, targ, -1);
532 if(PlayerScore_Add(targ, SP_SCORE, 0) == -5) {
533 announce(targ, "announcer/male/botlike.wav");
536 if (targ.killcount > 2)
538 bprint ("^1",s,"^1 needs a restart after a ",ftos(targ.killcount)," scoring spree\n");
540 bprint ("^1",s,"^1 died with a ",ftos(targ.killcount)," kill spree\n");
542 LogDeath("accident", deathtype, targ, targ);
544 targ.death_origin = targ.origin;
546 targ.killer_origin = attacker.origin;
547 // FIXME: this should go in PutClientInServer
553 // these are updated by each Damage call for use in button triggering and such
555 entity damage_inflictor;
556 entity damage_attacker;
558 void Damage (entity targ, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
563 entity attacker_save;
567 if (gameover || targ.killcount == -666)
570 local entity oldself;
574 damage_inflictor = inflictor;
575 damage_attacker = attacker;
576 attacker_save = attacker;
578 if(targ.classname == "player")
581 if(targ.hook.aiment == attacker)
582 RemoveGrapplingHook(targ); // STOP THAT, you parasite!
584 // special rule: gravity bomb does not hit team mates (other than for disconnecting the hook)
585 if(DEATH_ISWEAPON(deathtype, WEP_HOOK))
587 if(targ.classname == "player")
588 if not(IsDifferentTeam(targ, attacker))
595 if(deathtype == DEATH_KILL || deathtype == DEATH_TEAMCHANGE || deathtype == DEATH_AUTOTEAMCHANGE)
597 // These are ALWAYS lethal
598 // No damage modification here
599 // Instead, prepare the victim for his death...
601 targ.spawnshieldtime = 0;
602 targ.health = 0.9; // this is < 1
603 targ.flags -= targ.flags & FL_GODMODE;
606 else if(deathtype == DEATH_MIRRORDAMAGE || deathtype == DEATH_NOAMMO)
612 if (targ.classname == "player")
613 if (attacker.classname == "player")
616 damage = damage * bound(0.1, (skill + 5) * 0.1, 1);
618 // nullify damage if teamplay is on
619 if(deathtype != DEATH_TELEFRAG)
620 if(attacker.classname == "player")
622 if(targ.classname == "player" && targ != attacker && (IS_INDEPENDENT_PLAYER(attacker) || IS_INDEPENDENT_PLAYER(targ)))
627 else if(attacker.team == targ.team)
631 else if(attacker != targ)
635 else if(teamplay == 4)
637 if(targ.classname == "player" && targ.deadflag == DEAD_NO)
639 teamdamage0 = max(attacker.dmg_team, cvar("g_teamdamage_threshold"));
640 attacker.dmg_team = attacker.dmg_team + damage;
641 if(attacker.dmg_team > teamdamage0)
642 mirrordamage = cvar("g_mirrordamage") * (attacker.dmg_team - teamdamage0);
643 mirrorforce = cvar("g_mirrordamage") * vlen(force);
646 if(cvar("g_friendlyfire") == 0)
650 damage = cvar("g_friendlyfire") * damage;
651 // mirrordamage will be used LATER
660 if(targ.classname == "player")
661 if(attacker.classname == "player")
664 targ.lms_traveled_distance = cvar("g_lms_campcheck_distance");
665 attacker.lms_traveled_distance = cvar("g_lms_campcheck_distance");
670 if ((deathtype == DEATH_FALL) ||
671 (deathtype == DEATH_DROWN) ||
672 (deathtype == DEATH_SLIME) ||
673 (deathtype == DEATH_LAVA))
678 if (targ.armorvalue && (deathtype == WEP_MINSTANEX) && damage)
680 targ.armorvalue -= 1;
681 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^3Remaining extra lives: ",ftos(targ.armorvalue)));
685 if (DEATH_ISWEAPON(deathtype, WEP_LASER))
688 if (targ != attacker)
690 if (targ.classname == "player")
691 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "Secondary fire inflicts no damage!"));
701 // apply strength multiplier
702 if ((attacker.items & IT_STRENGTH) && !g_minstagib)
706 damage = damage * cvar("g_balance_powerup_strength_selfdamage");
707 force = force * cvar("g_balance_powerup_strength_selfforce");
711 damage = damage * cvar("g_balance_powerup_strength_damage");
712 force = force * cvar("g_balance_powerup_strength_force");
716 // apply invincibility multiplier
717 if (targ.items & IT_INVINCIBLE && !g_minstagib)
718 damage = damage * cvar("g_balance_powerup_invincible_takedamage");
720 if (targ == attacker)
721 damage = damage * cvar("g_balance_selfdamagepercent"); // Partial damage if the attacker hits himself
723 // CTF: reduce damage/force
728 damage = damage * cvar("g_ctf_flagcarrier_selfdamage");
729 force = force * cvar("g_ctf_flagcarrier_selfforce");
734 // apply strength rune
735 if (attacker.runes & RUNE_STRENGTH)
737 if(attacker.runes & CURSE_WEAK) // have both curse & rune
739 damage = damage * cvar("g_balance_rune_strength_combo_damage");
740 force = force * cvar("g_balance_rune_strength_combo_force");
744 damage = damage * cvar("g_balance_rune_strength_damage");
745 force = force * cvar("g_balance_rune_strength_force");
748 else if (attacker.runes & CURSE_WEAK)
750 damage = damage * cvar("g_balance_curse_weak_damage");
751 force = force * cvar("g_balance_curse_weak_force");
754 // apply defense rune
755 if (targ.runes & RUNE_DEFENSE)
757 if (targ.runes & CURSE_VULNER) // have both curse & rune
758 damage = damage * cvar("g_balance_rune_defense_combo_takedamage");
760 damage = damage * cvar("g_balance_rune_defense_takedamage");
762 else if (targ.runes & CURSE_VULNER)
763 damage = damage * cvar("g_balance_curse_vulner_takedamage");
769 if(targ.takedamage == DAMAGE_AIM)
771 if(targ.classname == "player")
773 if(IsDifferentTeam(targ, attacker))
778 attacker.typehitsound += 1;
780 attacker.hitsound += 1;
782 damage_goodhits += 1;
783 damage_gooddamage += damage;
785 if not(DEATH_ISSPECIAL(deathtype))
792 if(targ.items & IT_STRENGTH)
796 // find height of hit on player axis
797 // if above view_ofs and below maxs, and also in the middle half of the bbox, it is head shot
798 vector headmins, headmaxs, org;
799 org = antilag_takebackorigin(targ, time - ANTILAG_LATENCY(attacker));
800 headmins = org + '0.7 0 0' * targ.mins_x + '0 0.7 0' * targ.mins_y + '0 0 1' * targ.view_ofs_z;
801 headmaxs = org + '0.7 0 0' * targ.maxs_x + '0 0.7 0' * targ.maxs_y + '0 0 1' * targ.maxs_z;
802 if(trace_hits_box(railgun_start, railgun_end, headmins, headmaxs))
804 damage *= 1 + damage_headshotbonus;
806 deathtype |= HITTYPE_HEADSHOT;
813 attacker.typehitsound += 1;
815 if(time > attacker.teamkill_complain)
817 attacker.teamkill_complain = time + 5;
818 attacker.teamkill_soundtime = time + 0.4;
819 attacker.teamkill_soundsource = targ;
826 if (self.damageforcescale)
829 self.velocity = self.velocity + self.damageforcescale * force;
830 self.flags = self.flags - (self.flags & FL_ONGROUND);
831 UpdateCSQCProjectile(self);
835 if (self.event_damage)
836 self.event_damage (inflictor, attacker, damage, deathtype, hitloc, force);
839 if(targ.classname == "player" && attacker.classname == "player" && attacker != targ && attacker.health > 2)
841 // Savage: vampire mode
844 if (time > self.spawnshieldtime)
846 attacker.health += damage;
850 if (attacker.runes & RUNE_VAMPIRE)
852 // apply vampire rune
853 if (attacker.runes & CURSE_EMPATHY) // have the curse too
855 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb");
856 attacker.health = bound(
857 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 40
858 attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb"),
859 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
863 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_absorb");
864 attacker.health = bound(
865 attacker.health, // LA: was 3, but changed so that you can't lose health
866 // empathy won't let you gain health in the same way...
867 attacker.health + damage * cvar("g_balance_rune_vampire_absorb"),
868 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
871 // apply empathy curse
872 else if (attacker.runes & CURSE_EMPATHY)
874 attacker.health = bound(
875 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 20
876 attacker.health + damage * cvar("g_balance_curse_empathy_takedamage"),
882 // apply mirror damage if any
883 if(mirrordamage > 0 || mirrorforce > 0)
885 attacker = attacker_save;
889 // just lose extra LIVES, don't kill the player for mirror damage
890 if(attacker.armorvalue > 0)
892 attacker.armorvalue = attacker.armorvalue - 1;
893 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^3Remaining extra lives: ",ftos(attacker.armorvalue)));
894 attacker.hitsound += 1;
898 force = normalize(attacker.origin + attacker.view_ofs - hitloc) * mirrorforce;
899 Damage(attacker, inflictor, attacker, mirrordamage, DEATH_MIRRORDAMAGE, attacker.origin, force);
903 vector NearestPointOnBox(entity box, vector org)
905 vector m1, m2, nearest;
907 m1 = box.mins + box.origin;
908 m2 = box.maxs + box.origin;
910 nearest_x = bound(m1_x, org_x, m2_x);
911 nearest_y = bound(m1_y, org_y, m2_y);
912 nearest_z = bound(m1_z, org_z, m2_z);
917 float RadiusDamage_running;
918 float RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype, entity directhitentity)
919 // Returns total damage applies to creatures
929 float total_damage_to_creatures;
932 if(RadiusDamage_running)
935 print("RadiusDamage called recursively!\n");
936 print("Expect stuff to go HORRIBLY wrong.\n");
937 print("Causing a stack trace...\n");
938 save = cvar_string("prvm_backtraceforwarnings");
939 cvar_set("prvm_backtraceforwarnings", "1");
940 fclose(-1); // calls VM_Warning
941 cvar_set("prvm_backtraceforwarnings", save);
946 RadiusDamage_running = 1;
948 blastorigin = (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5);
949 total_damage_to_creatures = 0;
951 if(deathtype == WEP_HOOK | HITTYPE_SECONDARY | HITTYPE_BOUNCE) // only send gravity bomb damage once
952 Damage_DamageInfo(blastorigin, coredamage, edgedamage, rad, forceintensity * '0 0 1', deathtype);
954 targ = findradius (blastorigin, rad);
958 if (targ != inflictor)
961 // LordHavoc: measure distance to nearest point on target (not origin)
962 // (this guarentees 100% damage on a touch impact)
963 nearest = NearestPointOnBox(targ, blastorigin);
964 diff = nearest - blastorigin;
965 // round up a little on the damage to ensure full damage on impacts
966 // and turn the distance into a fraction of the radius
967 power = 1 - ((vlen (diff) - 2) / rad);
969 //bprint(ftos(power));
974 finaldmg = coredamage * power + edgedamage * (1 - power);
977 center = targ.origin + (targ.mins + targ.maxs) * 0.5;
978 // if it's a player, use the view origin as reference
979 if (targ.classname == "player")
980 center = targ.origin + targ.view_ofs;
981 force = normalize(center - blastorigin) * (finaldmg / coredamage) * forceintensity;
982 // test line of sight to multiple positions on box,
983 // and do damage if any of them hit
985 c = ceil(finaldmg / 10);
991 traceline(blastorigin, nearest, TRUE, inflictor);
992 if (trace_fraction == 1 || trace_ent == targ
993 || cvar("g_throughfloor"))
996 total_damage_to_creatures += finaldmg;
997 if(targ == directhitentity || DEATH_ISSPECIAL(deathtype))
998 Damage (targ, inflictor, attacker, finaldmg, deathtype, nearest, force);
1000 Damage (targ, inflictor, attacker, finaldmg, deathtype | HITTYPE_SPLASH, nearest, force);
1003 nearest_x = targ.mins_x + random() * targ.size_x;
1004 nearest_y = targ.mins_y + random() * targ.size_y;
1005 nearest_z = targ.mins_z + random() * targ.size_z;
1013 RadiusDamage_running = 0;
1015 return total_damage_to_creatures;