2 float checkrules_firstblood;
4 void GiveFrags (entity attacker, entity targ, float f)
9 if(cvar("g_arena_roundbased"))
12 if(cvar("g_domination"))
14 if(cvar("g_domination_disable_frags"))
18 else if(cvar("g_runematch"))
21 f = RunematchHandleFrags(attacker, targ, f);
23 else if(cvar("g_lms"))
25 // count remaining lives, not frags in lms
27 // keep track of the worst players lives
28 if(targ.frags < lms_lowest_lives)
29 lms_lowest_lives = targ.frags;
30 // player has no more lives left
34 lms_next_place = player_count;
35 targ.frags = -lms_next_place;
42 attacker.frags = attacker.frags + f;
45 string AppendItemcodes(string s, entity player)
50 // w = player.switchweapon;
52 w = player.cnt; // previous weapon!
53 s = strcat(s, ftos(W_ItemCode(w)));
54 if(time < player.strength_finished)
56 if(time < player.invincible_finished)
58 if(player.flagcarried != world)
63 s = strcat(s, "|", ftos(player.runes));
67 void LogDeath(string mode, float deathtype, entity killer, entity killed)
70 if(!cvar("sv_eventlog"))
72 s = strcat(":kill:", mode);
73 s = strcat(s, ":", ftos(killer.playerid));
74 s = strcat(s, ":", ftos(killed.playerid));
75 s = strcat(s, ":type=", ftos(deathtype));
76 s = strcat(s, ":items=");
77 s = AppendItemcodes(s, killer);
80 s = strcat(s, ":victimitems=");
81 s = AppendItemcodes(s, killed);
83 GameLogEcho(s, FALSE);
86 void Obituary (entity attacker, entity targ, float deathtype)
90 if (targ.classname == "player" || targ.classname == "corpse")
92 if (targ.classname == "corpse")
99 if (deathtype == DEATH_TEAMCHANGE)
101 m = "You are now on: ";
103 m = strcat(m, "^1Red Team");
104 else if (targ.team == 14)
105 m = strcat(m, "^4Blue Team");
106 else if (targ.team == 10)
107 m = strcat(m, "^6Pink Team");
108 else if (targ.team == 13)
109 m = strcat(m, "^3Yellow Team");
110 centerprint(targ, m);
112 else if (deathtype == DEATH_AUTOTEAMCHANGE)
114 m = "You have been moved into a different team to improve team balance\nYou are now on: ";
116 m = strcat(m, "^1Red Team");
117 else if (targ.team == 14)
118 m = strcat(m, "^4Blue Team");
119 else if (targ.team == 10)
120 m = strcat(m, "^6Pink Team");
121 else if (targ.team == 13)
122 m = strcat(m, "^3Yellow Team");
123 centerprint(targ, m);
126 else if (deathtype == DEATH_CAMP)
127 centerprint(targ, strcat("^1Die camper!\n\n\n"));
128 else if (deathtype == DEATH_NOAMMO)
129 centerprint(targ, strcat("^1You were killed for running out of ammo...\n\n\n"));
130 else if (deathtype == DEATH_ROT)
131 centerprint(targ, strcat("^1You grew too old without taking your medicine\n\n\n"));
132 else if (deathtype == DEATH_MIRRORDAMAGE)
133 centerprint(targ, strcat("^1Don't shoot your team mates!\n\n\n"));
135 centerprint(targ, strcat("^1You killed your own dumb self!\n\n\n"));
137 if (deathtype == IT_GRENADE_LAUNCHER)
138 bprint ("^1",s, "^1 detonated\n");
139 else if (deathtype == IT_ELECTRO)
140 bprint ("^1",s, "^1 played with plasma\n");
141 else if (deathtype == IT_ROCKET_LAUNCHER)
142 bprint ("^1",s, "^1 exploded\n");
143 else if (deathtype == DEATH_KILL)
144 bprint ("^1",s, "^1 couldn't take it anymore\n");
145 else if (deathtype == DEATH_ROT)
146 bprint ("^1",s, "^1 died\n");
147 else if (deathtype == DEATH_NOAMMO)
149 bprint ("^7",s, " ^7committed suicide. What's the point of living without ammo?\n");
150 //sound (self, CHAN_BODY, "minstagib/mockery.ogg", 1, ATTN_NONE);
152 else if (deathtype == DEATH_CAMP)
153 bprint ("^1",s, "^1 thought he found a nice camping ground\n");
154 else if (deathtype == DEATH_MIRRORDAMAGE)
155 bprint ("^1",s, "^1 didn't become friends with the Lord of Teamplay\n");
156 else if (deathtype != DEATH_TEAMCHANGE)
157 bprint ("^1",s, "^1 couldn't resist the urge to self-destruct\n");
159 if(deathtype != DEATH_TEAMCHANGE)
161 LogDeath("suicide", deathtype, targ, targ);
162 GiveFrags(attacker, targ, -1);
164 //targ.frags = targ.frags - 1;
165 if (targ.killcount > 2)
166 bprint ("^1",s,"^1 ended it all with a ",ftos(targ.killcount)," kill spree\n");
168 else if (teamplay && attacker.team == targ.team)
170 centerprint(attacker, strcat("^1Moron! You fragged a teammate!\n\n\n"));
171 bprint ("^1", attacker.netname, "^1 mows down a teammate\n");
172 GiveFrags(attacker, targ, -1);
173 //attacker.frags = attacker.frags - 1;
174 if (targ.killcount > 2)
175 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," kill spree was ended by a teammate!\n");
176 if (attacker.killcount > 2)
177 bprint ("^1",attacker.netname,"^1 ended a ",ftos(attacker.killcount)," kill spree by killing a teammate\n");
178 attacker.killcount = 0;
180 LogDeath("tk", deathtype, attacker, targ);
182 else if (attacker.classname == "player" || attacker.classname == "gib")
184 if (!checkrules_firstblood)
186 checkrules_firstblood = TRUE;
187 //sound(world, CHAN_AUTO, "announcer/firstblood.wav", 1, ATTN_NONE);
188 //if (cvar("g_minstagib"))
189 //sound(world, CHAN_AUTO, "announce/male/mapkill1.ogg", 1, ATTN_NONE);
190 bprint("^1",attacker.netname, "^1 drew first blood", "\n");
193 centerprint(attacker, strcat("^4You fragged ^7", s, "\n\n\n"));
194 centerprint(targ, strcat("^1You were fragged by ^7", attacker.netname, "\n\n\n"));
196 if (deathtype == IT_LASER)
197 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
198 else if (deathtype == IT_UZI)
199 bprint ("^1",s, "^1 was riddled full of holes by ", attacker.netname, "\n");
200 else if (deathtype == IT_SHOTGUN)
201 bprint ("^1",s, "^1 was gunned by ", attacker.netname, "\n");
202 else if (deathtype == IT_GRENADE_LAUNCHER)
203 bprint ("^1", s, "^1 was blasted by ", attacker.netname, "\n");
204 else if (deathtype == IT_ELECTRO)
205 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
206 else if (deathtype == IT_CRYLINK)
207 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
208 else if (deathtype == IT_NEX)
209 bprint ("^1",s, "^1 has been vaporized by ", attacker.netname, "\n");
210 else if (deathtype == IT_HAGAR)
211 bprint ("^1",s, "^1 was pummeled by ", attacker.netname, "\n");
212 else if (deathtype == IT_ROCKET_LAUNCHER)
213 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
214 else if (deathtype == DEATH_TELEFRAG)
215 bprint ("^1",s, "^1 was telefragged by ", attacker.netname, "\n");
216 else if (deathtype == DEATH_DROWN)
217 bprint ("^1",s, "^1 was drowned by ", attacker.netname, "\n");
218 else if (deathtype == DEATH_SLIME)
219 bprint ("^1",s, "^1 was slimed by ", attacker.netname, "\n");
220 else if (deathtype == DEATH_LAVA)
221 bprint ("^1",s, "^1 was cooked by ", attacker.netname, "\n");
222 else if (deathtype == DEATH_FALL)
223 bprint ("^1",s, "^1 was grounded by ", attacker.netname, "\n");
224 else if (deathtype == DEATH_SHOOTING_STAR)
225 bprint ("^1",s, "^1 was shot into space by ", attacker.netname, "\n");
226 else if (deathtype == DEATH_SWAMP)
227 bprint ("^1",s, "^1 was conserved by ", attacker.netname, "\n");
228 else if (deathtype == DEATH_HURTTRIGGER)
229 bprint ("^1",s, "^1 was thrown into a world of hurt by ", attacker.netname, "\n");
231 bprint ("^1",s, "^1 was fragged by ", attacker.netname, "\n");
233 GiveFrags(attacker, targ, 1);
234 //attacker.frags = attacker.frags + 1;
235 if (targ.killcount > 2)
236 bprint ("^1",s,"'s ^1", ftos(targ.killcount), " kill spree was ended by ", attacker.netname, "\n");
237 attacker.killcount = attacker.killcount + 1;
238 if (attacker.killcount > 2)
239 bprint ("^1",attacker.netname,"^1 has ",ftos(attacker.killcount)," frags in a row\n");
241 LogDeath("frag", deathtype, attacker, targ);
243 if (attacker.killcount == 3)
245 bprint (attacker.netname,"^7 made a ^1TRIPLE FRAG\n");
246 stuffcmd(attacker, "play2 announcer/male/03kills.ogg\n");
248 else if (attacker.killcount == 5)
250 bprint (attacker.netname,"^7 made a ^1FIVE FRAG COMBO\n");
251 stuffcmd(attacker, "play2 announcer/male/05kills.ogg\n");
253 else if (attacker.killcount == 10)
255 bprint (attacker.netname,"^7 is on a ^1RAGE\n");
256 stuffcmd(attacker, "play2 announcer/male/10kills.ogg\n");
258 else if (attacker.killcount == 15)
260 bprint (attacker.netname,"^7 has done a ^1MASSACRE!\n");
261 stuffcmd(attacker, "play2 announcer/male/15kills.ogg\n");
263 else if (attacker.killcount == 20)
265 bprint (attacker.netname,"^7 is ^1UNHUMAN!\n");
266 stuffcmd(attacker, "play2 announcer/male/20kills.ogg\n");
268 else if (attacker.killcount == 25)
270 bprint (attacker.netname,"^7 is a ^1DEATH INCARNATION!\n");
271 stuffcmd(attacker, "play2 announcer/male/25kills.ogg\n");
273 else if (attacker.killcount == 30)
275 bprint (attacker.netname,"^7 is maybe a ^1AIMBOTTER?!\n");
276 stuffcmd(attacker, "play2 announcer/male/30kills.ogg\n");
281 centerprint(targ, strcat("^1Watch your step!\n\n\n"));
282 if (deathtype == DEATH_HURTTRIGGER && attacker.message != "")
283 bprint ("^1",s, "^1 ", attacker.message, "\n");
284 else if (deathtype == DEATH_DROWN)
285 bprint ("^1",s, "^1 drowned\n");
286 else if (deathtype == DEATH_SLIME)
287 bprint ("^1",s, "^1 was slimed\n");
288 else if (deathtype == DEATH_LAVA)
289 bprint ("^1",s, "^1 turned into hot slag\n");
290 else if (deathtype == DEATH_FALL)
291 bprint ("^1",s, "^1 hit the ground with a crunch\n");
292 else if (deathtype == DEATH_SHOOTING_STAR)
293 bprint ("^1",s, "^1 became a shooting star\n");
294 else if (deathtype == DEATH_SWAMP)
295 bprint ("^1",s, "^1 is now conserved for centuries to come\n");
297 bprint ("^1",s, "^1 died\n");
298 GiveFrags(targ, targ, -1);
299 if(targ.frags == -5) {
300 stuffcmd(targ, "play2 announcer/male/botlike.ogg\n");
303 //targ.frags = targ.frags - 1;
304 if (targ.killcount > 2)
305 bprint ("^1",s,"^1 died with a ",ftos(targ.killcount)," kill spree\n");
307 LogDeath("accident", deathtype, targ, targ);
309 targ.death_origin = targ.origin;
311 targ.killer_origin = attacker.origin;
312 // FIXME: this should go in PutClientInServer
318 // these are updated by each Damage call for use in button triggering and such
320 entity damage_inflictor;
321 entity damage_attacker;
323 void Damage (entity targ, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
327 entity attacker_save;
331 if (gameover || targ.killcount == -666)
334 local entity oldself;
338 damage_inflictor = inflictor;
339 damage_attacker = attacker;
340 attacker_save = attacker;
342 if (targ.classname == "player")
343 if (attacker.classname == "player")
346 damage = damage * bound(0.1, (skill + 5) * 0.1, 1);
348 // nullify damage if teamplay is on
349 if(deathtype != DEATH_TELEFRAG)
353 if(attacker.team == targ.team)
358 if(attacker.team == targ.team)
362 if(attacker.team == targ.team)
363 if(attacker.classname == "player")
364 if(targ.classname == "player")
366 mirrordamage = cvar("g_mirrordamage") * damage;
367 mirrorforce = cvar("g_mirrordamage") * vlen(force);
368 if(cvar("g_minstagib"))
370 if(cvar("g_friendlyfire") == 0)
374 damage = cvar("g_friendlyfire") * damage;
375 // mirrordamage will be used LATER
380 if(targ.classname == "player")
381 if(attacker.classname == "player")
384 targ.lms_traveled_distance = cvar("g_lms_campcheck_distance");
385 attacker.lms_traveled_distance = cvar("g_lms_campcheck_distance");
391 if(clienttype(attacker) == CLIENTTYPE_REAL)
392 if(targ.classname == "player")
393 stuffcmd(attacker, "play2 misc/hit.wav\n");
395 if (cvar("g_minstagib"))
397 if ((deathtype == DEATH_FALL) ||
398 (deathtype == DEATH_DROWN) ||
399 (deathtype == DEATH_SLIME) ||
400 (deathtype == DEATH_LAVA))
402 if (targ.armorvalue && (deathtype == IT_NEX) && damage)
404 targ.armorvalue -= 1;
405 centerprint(targ, strcat("^3Remaining extra lives: ",ftos(targ.armorvalue),"\n"));
407 if(clienttype(targ) == CLIENTTYPE_REAL) stuffcmd(targ, "play2 misc/hit.wav\n");
408 //stuffcmd(attacker, "play2 misc/hit.wav\n");
410 else if (deathtype == IT_NEX && targ.items & IT_STRENGTH)
412 if(clienttype(attacker) == CLIENTTYPE_REAL) stuffcmd(attacker, "play2 announcer/male/yoda.ogg\n");
414 if (deathtype == IT_LASER)
417 if (targ != attacker)
419 if (targ.classname == "player")
420 centerprint(attacker, "Secondary fire inflicts no damage!\n");
429 if (deathtype == IT_NEX && !targ.deadflag && !(attacker.flags & FL_ONGROUND) && !(targ.flags & FL_ONGROUND) && attacker.waterlevel < 2 && targ.waterlevel < 2 && attacker.killcount != 3 && attacker.killcount != 5 && attacker.killcount != 10 && attacker.killcount != 15 && attacker.killcount != 20 && attacker.killcount != 25 && attacker.killcount != 30)
431 if(clienttype(attacker) == CLIENTTYPE_REAL) stuffcmd(attacker, "play2 announcer/male/yoda.ogg\n");
435 // apply strength multiplier
436 if (attacker.items & IT_STRENGTH && !cvar("g_minstagib"))
438 damage = damage * cvar("g_balance_powerup_strength_damage");
439 force = force * cvar("g_balance_powerup_strength_force");
441 // apply invincibility multiplier
442 if (targ.items & IT_INVINCIBLE && !cvar("g_minstagib"))
443 damage = damage * cvar("g_balance_powerup_invincible_takedamage");
446 if(cvar("g_runematch"))
448 // apply strength rune
449 if (attacker.runes & RUNE_STRENGTH)
451 if(attacker.runes & CURSE_WEAK) // have both curse & rune
453 damage = damage * cvar("g_balance_rune_strength_combo_damage");
454 force = force * cvar("g_balance_rune_strength_combo_force");
458 damage = damage * cvar("g_balance_rune_strength_damage");
459 force = force * cvar("g_balance_rune_strength_force");
462 else if (attacker.runes & CURSE_WEAK)
464 damage = damage * cvar("g_balance_curse_weak_damage");
465 force = force * cvar("g_balance_curse_weak_force");
468 // apply defense rune
469 if (targ.runes & RUNE_DEFENSE)
471 if (targ.runes & CURSE_VULNER) // have both curse & rune
472 damage = damage * cvar("g_balance_rune_defense_combo_takedamage");
474 damage = damage * cvar("g_balance_rune_defense_takedamage");
476 else if (targ.runes & CURSE_VULNER)
477 damage = damage * cvar("g_balance_curse_vulner_takedamage");
481 if (self.damageforcescale)
483 self.velocity = self.velocity + self.damageforcescale * force;
484 self.flags = self.flags - (self.flags & FL_ONGROUND);
487 if (self.event_damage)
488 self.event_damage (inflictor, attacker, damage, deathtype, hitloc, force);
491 if(targ.classname == "player" && attacker.classname == "player" && attacker != targ && attacker.health > 2)
493 // Savage: vampire mode
494 if(cvar("g_vampire") && !cvar("g_minstagib"))
496 attacker.health += damage;
498 if(cvar("g_runematch"))
500 if (attacker.runes & RUNE_VAMPIRE)
502 // apply vampire rune
503 if (attacker.runes & CURSE_EMPATHY) // have the curse too
505 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb");
506 attacker.health = bound(
507 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 40
508 attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb"),
509 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
513 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_absorb");
514 attacker.health = bound(
515 attacker.health, // LA: was 3, but changed so that you can't lose health
516 // empathy won't let you gain health in the same way...
517 attacker.health + damage * cvar("g_balance_rune_vampire_absorb"),
518 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
521 // apply empathy curse
522 else if (attacker.runes & CURSE_EMPATHY)
524 attacker.health = bound(
525 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 20
526 attacker.health + damage * cvar("g_balance_curse_empathy_takedamage"),
532 // apply mirror damage if any
533 if(mirrordamage > 0 || mirrorforce > 0)
535 attacker = attacker_save;
536 if(cvar("g_minstagib"))
539 // just lose extra LIVES, don't kill the player for mirror damage
540 if(attacker.armorvalue > 0)
542 attacker.armorvalue = attacker.armorvalue - 1;
543 centerprint(attacker, strcat("^3Remaining extra lives: ",ftos(attacker.armorvalue),"\n"));
544 if(clienttype(attacker) == CLIENTTYPE_REAL) stuffcmd(attacker, "play2 misc/hit.wav\n");
548 force = normalize(attacker.origin + attacker.view_ofs - hitloc) * mirrorforce;
549 Damage(attacker, inflictor, attacker, mirrordamage, DEATH_MIRRORDAMAGE, attacker.origin, force);
553 void RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype)
565 blastorigin = (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5);
567 targ = findradius (blastorigin, rad);
570 if (targ != inflictor)
573 // LordHavoc: measure distance to nearest point on target (not origin)
574 // (this guarentees 100% damage on a touch impact)
575 nearest = blastorigin;
576 m1 = targ.origin + targ.mins;
577 m2 = targ.origin + targ.maxs;
578 if (nearest_x < m1_x) nearest_x = m1_x;
579 if (nearest_y < m1_y) nearest_y = m1_y;
580 if (nearest_z < m1_z) nearest_z = m1_z;
581 if (nearest_x > m2_x) nearest_x = m2_x;
582 if (nearest_y > m2_y) nearest_y = m2_y;
583 if (nearest_z > m2_z) nearest_z = m2_z;
584 diff = nearest - blastorigin;
585 // round up a little on the damage to ensure full damage on impacts
586 // and turn the distance into a fraction of the radius
587 power = 1 - ((vlen (diff) - 2) / rad);
589 //bprint(ftos(power));
594 finaldmg = coredamage * power + edgedamage * (1 - power);
597 force = normalize((m1 + m2) * 0.5 - blastorigin) * (finaldmg / coredamage) * forceintensity;
598 if (targ == attacker)
599 finaldmg = finaldmg * cvar("g_balance_selfdamagepercent"); // Partial damage if the attacker hits himself
600 // test line of sight to multiple positions on box,
601 // and do damage if any of them hit
603 c = ceil(finaldmg / 10);
609 traceline(blastorigin, nearest, TRUE, inflictor);
610 if (trace_fraction == 1 || trace_ent == targ
611 || cvar("g_throughfloor"))
613 Damage (targ, inflictor, attacker, finaldmg, deathtype, nearest, force);
616 nearest_x = m1_x + random() * targ.size_x;
617 nearest_y = m1_y + random() * targ.size_y;
618 nearest_z = m1_z + random() * targ.size_z;
632 void ClearMultiDamage (void)
636 multi_force = '0 0 0';
639 void ApplyMultiDamage (void)
644 Damage (self, multi_ent.origin, multi_ent, 0, multi_damage, multi_force);
647 void AddMultiDamage (entity hit, float damage, vector force)
652 if (hit != multi_ent)
658 multi_damage = multi_damage + damage;
659 multi_force = multi_force + force;
662 void FireBullets (float shotcount, vector dir, vector spread, float deathtype)
669 makevectors (self.v_angle);
671 source = self.origin + v_forward * 10; // FIXME
672 source_x = self.absmin_z + self.size_z * 0.7; // ??? whaddabout view_ofs
674 // LordHavoc: better to use normal damage
675 //ClearMultiDamage ();
676 while (shotcount > 0)
678 direction = dir + crandom () * spread_x * v_right + crandom () * spread_y * v_up;
680 traceline (source, source + direction * 2048, FALSE, self);
681 if (trace_fraction != 1.0)
683 vel = normalize (direction + v_up * crandom () + v_right * crandom ());
684 vel = vel + 2 * trace_plane_normal;
687 org = trace_endpos - direction * 4;
689 if (!trace_ent.takedamage)
691 // LordHavoc: better to use normal damage
692 //AddMultiDamage (trace_ent, 4, direction * 4);
693 Damage (trace_ent, self, self, 4, deathtype, trace_endpos, direction * 4);
696 shotcount = shotcount + 1;
699 // LordHavoc: better to use normal damage
700 //ApplyMultiDamage ();