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);
39 e.effects = EF_NODEPTHTEST; // needs to be, sorry
41 e.oldorigin_x = compressShortVector(e.velocity);
43 e.SendEntity = Damage_DamageInfo_SendEntity;
46 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
48 float checkrules_firstblood;
51 float damage_goodhits;
52 float damage_gooddamage;
54 float damage_headshotbonus; // bonus multiplier for head shots, set to 0 after use
57 .float teamkill_complain;
58 .float teamkill_soundtime;
59 .entity teamkill_soundsource;
61 .float taunt_soundtime;
64 float IsDifferentTeam(entity a, entity b)
79 float IsFlying(entity a)
81 if(a.flags & FL_ONGROUND)
85 traceline(a.origin, a.origin - '0 0 48', MOVE_NORMAL, a);
86 if(trace_fraction < 1)
91 void UpdateFrags(entity player, float f)
93 PlayerTeamScore_AddScore(player, f);
96 // NOTE: f=0 means still count as a (positive) kill, but count no frags for it
97 void GiveFrags (entity attacker, entity targ, float f)
99 // TODO route through PlayerScores instead
107 PlayerScore_Add(attacker, SP_SUICIDES, 1);
112 PlayerScore_Add(attacker, SP_KILLS, -1); // or maybe add a teamkills field?
118 PlayerScore_Add(attacker, SP_KILLS, 1);
121 PlayerScore_Add(targ, SP_DEATHS, 1);
124 if(cvar("g_arena_roundbased"))
127 // FIXME fix the mess this is (we have REAL points now!)
130 f = RunematchHandleFrags(attacker, targ, f);
134 f = kh_HandleFrags(attacker, targ, f);
140 tl = PlayerScore_Add(targ, SP_LMS_LIVES, -1);
141 if(tl < lms_lowest_lives)
142 lms_lowest_lives = tl;
146 lms_next_place = player_count;
147 PlayerScore_Add(targ, SP_LMS_RANK, lms_next_place); // won't ever spawn again
154 if(g_ctf_ignore_frags)
158 attacker.totalfrags += f;
161 UpdateFrags(attacker, f);
164 string AppendItemcodes(string s, entity player)
169 // w = player.switchweapon;
171 w = player.cnt; // previous weapon!
172 s = strcat(s, ftos(w));
173 if(time < player.strength_finished)
175 if(time < player.invincible_finished)
177 if(player.flagcarried != world)
179 if(player.BUTTON_CHAT)
184 s = strcat(s, "|", ftos(player.runes));
188 void LogDeath(string mode, float deathtype, entity killer, entity killed)
191 if(!cvar("sv_eventlog"))
193 s = strcat(":kill:", mode);
194 s = strcat(s, ":", ftos(killer.playerid));
195 s = strcat(s, ":", ftos(killed.playerid));
196 s = strcat(s, ":type=", ftos(deathtype));
197 s = strcat(s, ":items=");
198 s = AppendItemcodes(s, killer);
201 s = strcat(s, ":victimitems=");
202 s = AppendItemcodes(s, killed);
207 void Obituary (entity attacker, entity inflictor, entity targ, float deathtype)
212 if (targ.classname == "player" || targ.classname == "corpse")
214 if (targ.classname == "corpse")
218 a = attacker.netname;
220 if (targ == attacker)
222 if (deathtype == DEATH_TEAMCHANGE) {
223 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", ColoredTeamName(targ.team)));
224 } else if (deathtype == DEATH_AUTOTEAMCHANGE) {
225 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)));
227 } else if (deathtype == DEATH_CAMP) {
229 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
231 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
232 } else if (deathtype == DEATH_NOAMMO) {
234 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
236 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
237 } else if (deathtype == DEATH_ROT) {
239 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
241 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
242 } else if (deathtype == DEATH_MIRRORDAMAGE) {
244 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
246 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
249 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
251 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
255 if (deathtype == DEATH_CAMP)
256 bprint ("^1",s, "^1 thought he found a nice camping ground\n");
257 else if (deathtype == DEATH_MIRRORDAMAGE)
258 bprint ("^1",s, "^1 didn't become friends with the Lord of Teamplay\n");
260 bprint ("^1",s, "^1 will be reinserted into the game due to his own actions\n");
262 if(deathtype != DEATH_TEAMCHANGE)
264 LogDeath("suicide", deathtype, targ, targ);
265 GiveFrags(attacker, targ, -1);
267 if (targ.killcount > 2)
268 bprint ("^1",s,"^1 faded after a ",ftos(targ.killcount)," point spree\n");
270 w = DEATH_WEAPONOF(deathtype);
273 w_deathtypestring = "couldn't resist the urge to self-destruct";
274 w_deathtype = deathtype;
275 weapon_action(w, WR_SUICIDEMESSAGE);
276 bprint("^1", s, "^1 ", w_deathtypestring, "\n");
278 else if (deathtype == DEATH_KILL)
279 bprint ("^1",s, "^1 couldn't take it anymore\n");
280 else if (deathtype == DEATH_ROT)
281 bprint ("^1",s, "^1 died\n");
282 else if (deathtype == DEATH_NOAMMO)
283 bprint ("^7",s, "^7 committed suicide. What's the point of living without ammo?\n");
284 else if (deathtype == DEATH_CAMP)
285 bprint ("^1",s, "^1 thought he found a nice camping ground\n");
286 else if (deathtype == DEATH_MIRRORDAMAGE)
287 bprint ("^1",s, "^1 didn't become friends with the Lord of Teamplay\n");
288 else if (deathtype != DEATH_TEAMCHANGE)
289 bprint ("^1",s, "^1 couldn't resist the urge to self-destruct\n");
291 if(deathtype != DEATH_TEAMCHANGE)
293 LogDeath("suicide", deathtype, targ, targ);
294 GiveFrags(attacker, targ, -1);
296 if (targ.killcount > 2)
297 bprint ("^1",s,"^1 ended it all after a ",ftos(targ.killcount)," kill spree\n");
300 else if (attacker.classname == "player" || attacker.classname == "gib")
302 if(teamplay && attacker.team == targ.team)
305 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against a team mate!"));
306 bprint ("^1", a, "^1 took action against a team mate\n");
308 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s, ", a team mate!"));
309 bprint ("^1", a, "^1 mows down a team mate\n");
311 GiveFrags(attacker, targ, -1);
312 if (targ.killcount > 2) {
314 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," scoring spree was ended by a team mate!\n");
316 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," kill spree was ended by a team mate!\n");
318 if (attacker.killcount > 2) {
320 bprint ("^1",a,"^1 ended a ",ftos(attacker.killcount)," scoring spree by going against a team mate\n");
322 bprint ("^1",a,"^1 ended a ",ftos(attacker.killcount)," kill spree by killing a team mate\n");
324 attacker.killcount = 0;
326 LogDeath("tk", deathtype, attacker, targ);
330 string blood_message, victim_message;
331 if (!checkrules_firstblood)
333 checkrules_firstblood = TRUE;
336 bprint("^1",a, "^1 was the first to score", "\n");
337 blood_message = "^1First point\n";
338 //victim_message = "^1First victim\n"; // or First casualty
342 bprint("^1",a, "^1 drew first blood", "\n");
343 blood_message = "^1First blood\n";
344 victim_message = "^1First victim\n"; // or First casualty
349 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s));
350 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, a,"^1 scored against you ^7"));
352 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, blood_message, "^4You fragged ^7", s));
353 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, victim_message, "^1You were fragged by ^7", a));
354 attacker.taunt_soundtime = time + 1;
358 bprint ("^1",s, "^1 needs a restart thanks to ", a, "\n");
360 w = DEATH_WEAPONOF(deathtype);
363 w_deathtypestring = "was blasted by";
364 w_deathtype = deathtype;
365 weapon_action(w, WR_KILLMESSAGE);
366 p = strstrofs(w_deathtypestring, "#", 0);
368 bprint("^1", s, "^1 ", w_deathtypestring, " ", a, "\n");
370 bprint("^1", s, "^1 ", substring(w_deathtypestring, 0, p), a, "^1", substring(w_deathtypestring, p+1, strlen(w_deathtypestring) - (p+1)), "\n");
372 else if (deathtype == DEATH_TELEFRAG)
373 bprint ("^1",s, "^1 was telefragged by ", a, "\n");
374 else if (deathtype == DEATH_DROWN)
375 bprint ("^1",s, "^1 was drowned by ", a, "\n");
376 else if (deathtype == DEATH_SLIME)
377 bprint ("^1",s, "^1 was slimed by ", a, "\n");
378 else if (deathtype == DEATH_LAVA)
379 bprint ("^1",s, "^1 was cooked by ", a, "\n");
380 else if (deathtype == DEATH_FALL)
381 bprint ("^1",s, "^1 was grounded by ", a, "\n");
382 else if (deathtype == DEATH_SHOOTING_STAR)
383 bprint ("^1",s, "^1 was shot into space by ", a, "\n");
384 else if (deathtype == DEATH_SWAMP)
385 bprint ("^1",s, "^1 was conserved by ", a, "\n");
386 else if (deathtype == DEATH_HURTTRIGGER && inflictor.message2 != "")
388 p = strstrofs(inflictor.message2, "#", 0);
390 bprint("^1", s, "^1 ", inflictor.message2, " ", a, "\n");
392 bprint("^1", s, "^1 ", substring(inflictor.message2, 0, p), a, "^1", substring(inflictor.message2, p+1, strlen(inflictor.message2) - (p+1)), "\n");
394 else if(deathtype == DEATH_TURRET)
395 bprint ("^1",s, "^1 was pushed into the line of fire by ^1", a, "\n");
396 else if(deathtype == DEATH_TOUCHEXPLODE)
397 bprint ("^1",s, "^1 was pushed into an accident by ^1", a, "\n");
399 bprint ("^1",s, "^1 was fragged by ", a, "\n");
402 if(g_ctf && targ.flagcarried)
404 UpdateFrags(attacker, ctf_score_value("score_kill"));
405 PlayerScore_Add(attacker, SP_CTF_FCKILLS, 1);
406 GiveFrags(attacker, targ, 0); // for logging
409 GiveFrags(attacker, targ, 1);
411 if (targ.killcount > 2) {
413 bprint ("^1",s,"'s ^1", ftos(targ.killcount), " scoring spree was ended by ", a, "\n");
415 bprint ("^1",s,"'s ^1", ftos(targ.killcount), " kill spree was ended by ", a, "\n");
418 attacker.killcount = attacker.killcount + 1;
420 if (attacker.killcount > 2) {
422 bprint ("^1",a,"^1 made ",ftos(attacker.killcount)," scores in a row\n");
424 bprint ("^1",a,"^1 has ",ftos(attacker.killcount)," frags in a row\n");
427 LogDeath("frag", deathtype, attacker, targ);
429 if (attacker.killcount == 3)
432 bprint (a,"^7 made a ^1TRIPLE SCORE\n");
434 bprint (a,"^7 made a ^1TRIPLE FRAG\n");
435 announce(attacker, "announcer/male/03kills.wav");
438 else if (attacker.killcount == 5)
441 bprint (a,"^7 unleashes ^1SCORING RAGE\n");
443 bprint (a,"^7 unleashes ^1RAGE\n");
444 announce(attacker, "announcer/male/05kills.wav");
447 else if (attacker.killcount == 10)
450 bprint (a,"^7 made ^1TEN SCORES IN A ROW!\n");
452 bprint (a,"^7 starts the ^1MASSACRE!\n");
453 announce(attacker, "announcer/male/10kills.wav");
456 else if (attacker.killcount == 15)
459 bprint (a,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
461 bprint (a,"^7 executes ^1MAYHEM!\n");
462 announce(attacker, "announcer/male/15kills.wav");
465 else if (attacker.killcount == 20)
468 bprint (a,"^7 made ^1TWENTY SCORES IN A ROW!\n");
470 bprint (a,"^7 is a ^1BERSERKER!\n");
471 announce(attacker, "announcer/male/20kills.wav");
474 else if (attacker.killcount == 25)
477 bprint (a,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
479 bprint (a,"^7 inflicts ^1CARNAGE!\n");
480 announce(attacker, "announcer/male/25kills.wav");
483 else if (attacker.killcount == 30)
486 bprint (a,"^7 made ^1THIRTY SCORES IN A ROW!\n");
488 bprint (a,"^7 unleashes ^1ARMAGEDDON!\n");
489 announce(attacker, "announcer/male/30kills.wav");
496 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Watch your step!"));
497 if (deathtype == DEATH_HURTTRIGGER && inflictor.message != "")
498 bprint ("^1",s, "^1 ", inflictor.message, "\n");
499 else if (deathtype == DEATH_DROWN)
501 bprint ("^1",s, "^1 was in the water for too long\n");
503 bprint ("^1",s, "^1 drowned\n");
504 else if (deathtype == DEATH_SLIME)
505 bprint ("^1",s, "^1 was slimed\n");
506 else if (deathtype == DEATH_LAVA)
508 bprint ("^1",s, "^1 found a hot place\n");
510 bprint ("^1",s, "^1 turned into hot slag\n");
511 else if (deathtype == DEATH_FALL)
513 bprint ("^1",s, "^1 tested gravity (and it worked)\n");
515 bprint ("^1",s, "^1 hit the ground with a crunch\n");
516 else if (deathtype == DEATH_SHOOTING_STAR)
517 bprint ("^1",s, "^1 became a shooting star\n");
518 else if (deathtype == DEATH_SWAMP)
520 bprint ("^1",s, "^1 discovered a swamp\n");
522 bprint ("^1",s, "^1 is now conserved for centuries to come\n");
523 else if(deathtype == DEATH_TURRET)
524 bprint ("^1",s, "^1 was mowed down by a turret \n");
525 else if(deathtype == DEATH_TOUCHEXPLODE)
526 bprint ("^1",s, "^1 died in an accident\n");
529 bprint ("^1",s, "^1 needs a restart\n");
531 bprint ("^1",s, "^1 died\n");
532 GiveFrags(targ, targ, -1);
533 if(PlayerScore_Add(targ, SP_SCORE, 0) == -5) {
534 announce(targ, "announcer/male/botlike.wav");
537 if (targ.killcount > 2)
539 bprint ("^1",s,"^1 needs a restart after a ",ftos(targ.killcount)," scoring spree\n");
541 bprint ("^1",s,"^1 died with a ",ftos(targ.killcount)," kill spree\n");
543 LogDeath("accident", deathtype, targ, targ);
545 targ.death_origin = targ.origin;
547 targ.killer_origin = attacker.origin;
548 // FIXME: this should go in PutClientInServer
554 // these are updated by each Damage call for use in button triggering and such
556 entity damage_inflictor;
557 entity damage_attacker;
559 void Damage (entity targ, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
564 entity attacker_save;
568 if (gameover || targ.killcount == -666)
571 local entity oldself;
575 damage_inflictor = inflictor;
576 damage_attacker = attacker;
577 attacker_save = attacker;
579 if(targ.classname == "player")
582 if(targ.hook.aiment == attacker)
583 RemoveGrapplingHook(targ); // STOP THAT, you parasite!
585 // special rule: gravity bomb does not hit team mates (other than for disconnecting the hook)
586 if(DEATH_ISWEAPON(deathtype, WEP_HOOK))
588 if(targ.classname == "player")
589 if not(IsDifferentTeam(targ, attacker))
596 if(deathtype == DEATH_KILL || deathtype == DEATH_TEAMCHANGE || deathtype == DEATH_AUTOTEAMCHANGE)
598 // These are ALWAYS lethal
599 // No damage modification here
600 // Instead, prepare the victim for his death...
602 targ.spawnshieldtime = 0;
603 targ.health = 0.9; // this is < 1
604 targ.flags -= targ.flags & FL_GODMODE;
607 else if(deathtype == DEATH_MIRRORDAMAGE || deathtype == DEATH_NOAMMO)
613 if (targ.classname == "player")
614 if (attacker.classname == "player")
617 damage = damage * bound(0.1, (skill + 5) * 0.1, 1);
619 // nullify damage if teamplay is on
620 if(deathtype != DEATH_TELEFRAG)
621 if(attacker.classname == "player")
623 if(targ.classname == "player" && targ != attacker && (IS_INDEPENDENT_PLAYER(attacker) || IS_INDEPENDENT_PLAYER(targ)))
628 else if(attacker.team == targ.team)
632 else if(attacker != targ)
636 else if(teamplay == 4)
638 if(targ.classname == "player" && targ.deadflag == DEAD_NO)
640 teamdamage0 = max(attacker.dmg_team, cvar("g_teamdamage_threshold"));
641 attacker.dmg_team = attacker.dmg_team + damage;
642 if(attacker.dmg_team > teamdamage0)
643 mirrordamage = cvar("g_mirrordamage") * (attacker.dmg_team - teamdamage0);
644 mirrorforce = cvar("g_mirrordamage") * vlen(force);
647 if(cvar("g_friendlyfire") == 0)
651 damage = cvar("g_friendlyfire") * damage;
652 // mirrordamage will be used LATER
661 if(targ.classname == "player")
662 if(attacker.classname == "player")
665 targ.lms_traveled_distance = cvar("g_lms_campcheck_distance");
666 attacker.lms_traveled_distance = cvar("g_lms_campcheck_distance");
671 if ((deathtype == DEATH_FALL) ||
672 (deathtype == DEATH_DROWN) ||
673 (deathtype == DEATH_SLIME) ||
674 (deathtype == DEATH_LAVA))
679 if (targ.armorvalue && (deathtype == WEP_MINSTANEX) && damage)
681 targ.armorvalue -= 1;
682 centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^3Remaining extra lives: ",ftos(targ.armorvalue)));
686 if (DEATH_ISWEAPON(deathtype, WEP_LASER))
689 if (targ != attacker)
691 if (targ.classname == "player")
692 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "Secondary fire inflicts no damage!"));
702 // apply strength multiplier
703 if ((attacker.items & IT_STRENGTH) && !g_minstagib)
707 damage = damage * cvar("g_balance_powerup_strength_selfdamage");
708 force = force * cvar("g_balance_powerup_strength_selfforce");
712 damage = damage * cvar("g_balance_powerup_strength_damage");
713 force = force * cvar("g_balance_powerup_strength_force");
717 // apply invincibility multiplier
718 if (targ.items & IT_INVINCIBLE && !g_minstagib)
719 damage = damage * cvar("g_balance_powerup_invincible_takedamage");
721 if (targ == attacker)
722 damage = damage * cvar("g_balance_selfdamagepercent"); // Partial damage if the attacker hits himself
724 // CTF: reduce damage/force
729 damage = damage * cvar("g_ctf_flagcarrier_selfdamage");
730 force = force * cvar("g_ctf_flagcarrier_selfforce");
735 // apply strength rune
736 if (attacker.runes & RUNE_STRENGTH)
738 if(attacker.runes & CURSE_WEAK) // have both curse & rune
740 damage = damage * cvar("g_balance_rune_strength_combo_damage");
741 force = force * cvar("g_balance_rune_strength_combo_force");
745 damage = damage * cvar("g_balance_rune_strength_damage");
746 force = force * cvar("g_balance_rune_strength_force");
749 else if (attacker.runes & CURSE_WEAK)
751 damage = damage * cvar("g_balance_curse_weak_damage");
752 force = force * cvar("g_balance_curse_weak_force");
755 // apply defense rune
756 if (targ.runes & RUNE_DEFENSE)
758 if (targ.runes & CURSE_VULNER) // have both curse & rune
759 damage = damage * cvar("g_balance_rune_defense_combo_takedamage");
761 damage = damage * cvar("g_balance_rune_defense_takedamage");
763 else if (targ.runes & CURSE_VULNER)
764 damage = damage * cvar("g_balance_curse_vulner_takedamage");
770 if(targ.takedamage == DAMAGE_AIM)
772 if(targ.classname == "player")
774 if(IsDifferentTeam(targ, attacker))
779 attacker.typehitsound += 1;
781 attacker.hitsound += 1;
783 damage_goodhits += 1;
784 damage_gooddamage += damage;
786 if not(DEATH_ISSPECIAL(deathtype))
793 if(targ.items & IT_STRENGTH)
797 // find height of hit on player axis
798 // if above view_ofs and below maxs, and also in the middle half of the bbox, it is head shot
799 vector headmins, headmaxs, org;
800 org = antilag_takebackorigin(targ, time - ANTILAG_LATENCY(attacker));
801 headmins = org + '0.7 0 0' * targ.mins_x + '0 0.7 0' * targ.mins_y + '0 0 1' * targ.view_ofs_z;
802 headmaxs = org + '0.7 0 0' * targ.maxs_x + '0 0.7 0' * targ.maxs_y + '0 0 1' * targ.maxs_z;
803 if(trace_hits_box(railgun_start, railgun_end, headmins, headmaxs))
805 damage *= 1 + damage_headshotbonus;
807 deathtype |= HITTYPE_HEADSHOT;
814 attacker.typehitsound += 1;
816 if(time > attacker.teamkill_complain)
818 attacker.teamkill_complain = time + 5;
819 attacker.teamkill_soundtime = time + 0.4;
820 attacker.teamkill_soundsource = targ;
827 if (self.damageforcescale)
830 self.velocity = self.velocity + self.damageforcescale * force;
831 self.flags = self.flags - (self.flags & FL_ONGROUND);
832 UpdateCSQCProjectile(self);
836 if (self.event_damage)
837 self.event_damage (inflictor, attacker, damage, deathtype, hitloc, force);
840 if(targ.classname == "player" && attacker.classname == "player" && attacker != targ && attacker.health > 2)
842 // Savage: vampire mode
845 if (time > self.spawnshieldtime)
847 attacker.health += damage;
851 if (attacker.runes & RUNE_VAMPIRE)
853 // apply vampire rune
854 if (attacker.runes & CURSE_EMPATHY) // have the curse too
856 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb");
857 attacker.health = bound(
858 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 40
859 attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb"),
860 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
864 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_absorb");
865 attacker.health = bound(
866 attacker.health, // LA: was 3, but changed so that you can't lose health
867 // empathy won't let you gain health in the same way...
868 attacker.health + damage * cvar("g_balance_rune_vampire_absorb"),
869 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
872 // apply empathy curse
873 else if (attacker.runes & CURSE_EMPATHY)
875 attacker.health = bound(
876 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 20
877 attacker.health + damage * cvar("g_balance_curse_empathy_takedamage"),
883 // apply mirror damage if any
884 if(mirrordamage > 0 || mirrorforce > 0)
886 attacker = attacker_save;
890 // just lose extra LIVES, don't kill the player for mirror damage
891 if(attacker.armorvalue > 0)
893 attacker.armorvalue = attacker.armorvalue - 1;
894 centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^3Remaining extra lives: ",ftos(attacker.armorvalue)));
895 attacker.hitsound += 1;
899 force = normalize(attacker.origin + attacker.view_ofs - hitloc) * mirrorforce;
900 Damage(attacker, inflictor, attacker, mirrordamage, DEATH_MIRRORDAMAGE, attacker.origin, force);
904 vector NearestPointOnBox(entity box, vector org)
906 vector m1, m2, nearest;
908 m1 = box.mins + box.origin;
909 m2 = box.maxs + box.origin;
911 nearest_x = bound(m1_x, org_x, m2_x);
912 nearest_y = bound(m1_y, org_y, m2_y);
913 nearest_z = bound(m1_z, org_z, m2_z);
918 float RadiusDamage_running;
919 float RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype, entity directhitentity)
920 // Returns total damage applies to creatures
930 float total_damage_to_creatures;
933 if(RadiusDamage_running)
936 print("RadiusDamage called recursively!\n");
937 print("Expect stuff to go HORRIBLY wrong.\n");
938 print("Causing a stack trace...\n");
939 save = cvar_string("prvm_backtraceforwarnings");
940 cvar_set("prvm_backtraceforwarnings", "1");
941 fclose(-1); // calls VM_Warning
942 cvar_set("prvm_backtraceforwarnings", save);
947 RadiusDamage_running = 1;
949 blastorigin = (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5);
950 total_damage_to_creatures = 0;
952 if(deathtype != (WEP_HOOK | HITTYPE_SECONDARY | HITTYPE_BOUNCE)) // only send gravity bomb damage once
954 force = inflictor.velocity;
958 force = normalize(force);
959 Damage_DamageInfo(blastorigin, coredamage, edgedamage, rad, forceintensity * force, deathtype);
962 targ = findradius (blastorigin, rad);
966 if (targ != inflictor)
969 // LordHavoc: measure distance to nearest point on target (not origin)
970 // (this guarentees 100% damage on a touch impact)
971 nearest = NearestPointOnBox(targ, blastorigin);
972 diff = nearest - blastorigin;
973 // round up a little on the damage to ensure full damage on impacts
974 // and turn the distance into a fraction of the radius
975 power = 1 - ((vlen (diff) - 2) / rad);
977 //bprint(ftos(power));
982 finaldmg = coredamage * power + edgedamage * (1 - power);
985 center = targ.origin + (targ.mins + targ.maxs) * 0.5;
986 // if it's a player, use the view origin as reference
987 if (targ.classname == "player")
988 center = targ.origin + targ.view_ofs;
989 force = normalize(center - blastorigin) * (finaldmg / coredamage) * forceintensity;
990 // test line of sight to multiple positions on box,
991 // and do damage if any of them hit
993 c = ceil(finaldmg / 10);
999 traceline(blastorigin, nearest, TRUE, inflictor);
1000 if (trace_fraction == 1 || trace_ent == targ
1001 || cvar("g_throughfloor"))
1004 total_damage_to_creatures += finaldmg;
1005 if(targ == directhitentity || DEATH_ISSPECIAL(deathtype))
1006 Damage (targ, inflictor, attacker, finaldmg, deathtype, nearest, force);
1008 Damage (targ, inflictor, attacker, finaldmg, deathtype | HITTYPE_SPLASH, nearest, force);
1011 nearest_x = targ.mins_x + random() * targ.size_x;
1012 nearest_y = targ.mins_y + random() * targ.size_y;
1013 nearest_z = targ.mins_z + random() * targ.size_z;
1021 RadiusDamage_running = 0;
1023 return total_damage_to_creatures;