2 float checkrules_firstblood;
4 void(entity player, float f) UpdateFrags =
7 player.totalfrags += f;
10 void GiveFrags (entity attacker, entity targ, float f)
15 if(cvar("g_arena_roundbased"))
18 if(cvar("g_domination"))
20 if(cvar("g_domination_disable_frags"))
24 else if(cvar("g_runematch"))
27 f = RunematchHandleFrags(attacker, targ, f);
29 else if(cvar("g_keyhunt"))
32 f = kh_HandleFrags(attacker, targ, f);
34 else if(cvar("g_lms"))
36 // count remaining lives, not frags in lms
38 // keep track of the worst players lives
39 if(targ.frags < lms_lowest_lives)
40 lms_lowest_lives = targ.frags;
41 // player has no more lives left
45 lms_next_place = player_count;
46 targ.frags = -lms_next_place;
53 UpdateFrags(attacker, f);
56 string AppendItemcodes(string s, entity player)
61 // w = player.switchweapon;
63 w = player.cnt; // previous weapon!
64 s = strcat(s, ftos(W_ItemCode(w)));
65 if(time < player.strength_finished)
67 if(time < player.invincible_finished)
69 if(player.flagcarried != world)
74 s = strcat(s, "|", ftos(player.runes));
78 void LogDeath(string mode, float deathtype, entity killer, entity killed)
81 if(!cvar("sv_eventlog"))
83 s = strcat(":kill:", mode);
84 s = strcat(s, ":", ftos(killer.playerid));
85 s = strcat(s, ":", ftos(killed.playerid));
86 s = strcat(s, ":type=", ftos(deathtype));
87 s = strcat(s, ":items=");
88 s = AppendItemcodes(s, killer);
91 s = strcat(s, ":victimitems=");
92 s = AppendItemcodes(s, killed);
94 GameLogEcho(s, FALSE);
97 void Obituary (entity attacker, entity targ, float deathtype)
101 if (targ.classname == "player" || targ.classname == "corpse")
103 if (targ.classname == "corpse")
107 a = attacker.netname;
109 if (targ == attacker)
111 if (deathtype == DEATH_TEAMCHANGE)
113 centerprint(targ, strcat("You are now on: ", ColoredTeamName(targ.team)));
115 else if (deathtype == DEATH_AUTOTEAMCHANGE)
117 centerprint(targ, strcat("You have been moved into a different team to improve team balance\nYou are now on: ", ColoredTeamName(targ.team)));
120 else if (deathtype == DEATH_CAMP)
121 centerprint(targ, "^1Die camper!\n\n\n");
122 else if (deathtype == DEATH_NOAMMO)
123 centerprint(targ, "^1You were killed for running out of ammo...\n\n\n");
124 else if (deathtype == DEATH_ROT)
125 centerprint(targ, "^1You grew too old without taking your medicine\n\n\n");
126 else if (deathtype == DEATH_MIRRORDAMAGE)
127 centerprint(targ, "^1Don't shoot your team mates!\n\n\n");
129 centerprint(targ, "^1You killed your own dumb self!\n\n\n");
131 if (deathtype == IT_GRENADE_LAUNCHER)
132 bprint ("^1",s, "^1 detonated\n");
133 else if (deathtype == IT_ELECTRO)
134 bprint ("^1",s, "^1 played with plasma\n");
135 else if (deathtype == IT_ROCKET_LAUNCHER)
136 bprint ("^1",s, "^1 exploded\n");
137 else if (deathtype == DEATH_KILL)
138 bprint ("^1",s, "^1 couldn't take it anymore\n");
139 else if (deathtype == DEATH_ROT)
140 bprint ("^1",s, "^1 died\n");
141 else if (deathtype == DEATH_NOAMMO)
143 bprint ("^7",s, " ^7committed suicide. What's the point of living without ammo?\n");
144 //sound (self, CHAN_BODY, "minstagib/mockery.wav", 1, ATTN_NONE);
146 else if (deathtype == DEATH_CAMP)
147 bprint ("^1",s, "^1 thought he found a nice camping ground\n");
148 else if (deathtype == DEATH_MIRRORDAMAGE)
149 bprint ("^1",s, "^1 didn't become friends with the Lord of Teamplay\n");
150 else if (deathtype != DEATH_TEAMCHANGE)
151 bprint ("^1",s, "^1 couldn't resist the urge to self-destruct\n");
153 if(deathtype != DEATH_TEAMCHANGE)
155 LogDeath("suicide", deathtype, targ, targ);
156 GiveFrags(attacker, targ, -1);
158 if (targ.killcount > 2)
159 bprint ("^1",s,"^1 ended it all with a ",ftos(targ.killcount)," kill spree\n");
161 else if (attacker.classname == "player" || attacker.classname == "gib")
163 if(teamplay && attacker.team == targ.team)
165 centerprint(attacker, "^1Moron! You fragged a teammate!\n\n\n");
166 bprint ("^1", a, "^1 mows down a teammate\n");
167 GiveFrags(attacker, targ, -1);
168 if (targ.killcount > 2)
169 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," kill spree was ended by a teammate!\n");
170 if (attacker.killcount > 2)
171 bprint ("^1",a,"^1 ended a ",ftos(attacker.killcount)," kill spree by killing a teammate\n");
172 attacker.killcount = 0;
174 LogDeath("tk", deathtype, attacker, targ);
178 if (!checkrules_firstblood)
180 checkrules_firstblood = TRUE;
181 //sound(world, CHAN_AUTO, "announcer/firstblood.wav", 1, ATTN_NONE);
182 //if (cvar("g_minstagib"))
183 //sound(world, CHAN_AUTO, "announce/male/mapkill1.wav", 1, ATTN_NONE);
184 bprint("^1",a, "^1 drew first blood", "\n");
187 centerprint(attacker, strcat("^4You fragged ^7", s, "\n\n\n"));
188 centerprint(targ, strcat("^1You were fragged by ^7", a, "\n\n\n"));
190 if (deathtype == IT_LASER)
191 bprint ("^1",s, "^1 was blasted by ", a, "\n");
192 else if (deathtype == IT_UZI)
193 bprint ("^1",s, "^1 was riddled full of holes by ", a, "\n");
194 else if (deathtype == IT_SHOTGUN)
195 bprint ("^1",s, "^1 was gunned by ", a, "\n");
196 else if (deathtype == IT_GRENADE_LAUNCHER)
197 bprint ("^1", s, "^1 was blasted by ", a, "\n");
198 else if (deathtype == IT_ELECTRO)
199 bprint ("^1",s, "^1 was blasted by ", a, "\n");
200 else if (deathtype == IT_CRYLINK)
201 bprint ("^1",s, "^1 was blasted by ", a, "\n");
202 else if (deathtype == IT_NEX)
203 bprint ("^1",s, "^1 has been vaporized by ", a, "\n");
204 else if (deathtype == IT_HAGAR)
205 bprint ("^1",s, "^1 was pummeled by ", a, "\n");
206 else if (deathtype == IT_ROCKET_LAUNCHER)
207 bprint ("^1",s, "^1 was blasted by ", a, "\n");
208 else if (deathtype == DEATH_TELEFRAG)
209 bprint ("^1",s, "^1 was telefragged by ", a, "\n");
210 else if (deathtype == DEATH_DROWN)
211 bprint ("^1",s, "^1 was drowned by ", a, "\n");
212 else if (deathtype == DEATH_SLIME)
213 bprint ("^1",s, "^1 was slimed by ", a, "\n");
214 else if (deathtype == DEATH_LAVA)
215 bprint ("^1",s, "^1 was cooked by ", a, "\n");
216 else if (deathtype == DEATH_FALL)
217 bprint ("^1",s, "^1 was grounded by ", a, "\n");
218 else if (deathtype == DEATH_SHOOTING_STAR)
219 bprint ("^1",s, "^1 was shot into space by ", a, "\n");
220 else if (deathtype == DEATH_SWAMP)
221 bprint ("^1",s, "^1 was conserved by ", a, "\n");
222 else if (deathtype == DEATH_HURTTRIGGER)
223 bprint ("^1",s, "^1 was thrown into a world of hurt by ", a, "\n");
225 bprint ("^1",s, "^1 was fragged by ", a, "\n");
227 GiveFrags(attacker, targ, 1);
228 if (targ.killcount > 2)
229 bprint ("^1",s,"'s ^1", ftos(targ.killcount), " kill spree was ended by ", a, "\n");
230 attacker.killcount = attacker.killcount + 1;
231 if (attacker.killcount > 2)
232 bprint ("^1",a,"^1 has ",ftos(attacker.killcount)," frags in a row\n");
234 LogDeath("frag", deathtype, attacker, targ);
236 if (attacker.killcount == 3)
238 bprint (a,"^7 made a ^1TRIPLE FRAG\n");
239 play2(attacker, "announcer/male/03kills.ogg");
241 else if (attacker.killcount == 5)
243 bprint (a,"^7 made a ^1FIVE FRAG COMBO\n");
244 play2(attacker, "announcer/male/05kills.ogg");
246 else if (attacker.killcount == 10)
248 bprint (a,"^7 is on a ^1RAGE\n");
249 play2(attacker, "announcer/male/10kills.ogg");
251 else if (attacker.killcount == 15)
253 bprint (a,"^7 has done a ^1MASSACRE!\n");
254 play2(attacker, "announcer/male/15kills.ogg");
256 else if (attacker.killcount == 20)
258 bprint (a,"^7 is ^1UNHUMAN!\n");
259 play2(attacker, "announcer/male/20kills.ogg");
261 else if (attacker.killcount == 25)
263 bprint (a,"^7 is a ^1DEATH INCARNATION!\n");
264 play2(attacker, "announcer/male/25kills.ogg");
266 else if (attacker.killcount == 30)
268 bprint (a,"^7 is maybe a ^1AIMBOTTER?!\n");
269 play2(attacker, "announcer/male/30kills.ogg");
275 centerprint(targ, "^1Watch your step!\n\n\n");
276 if (deathtype == DEATH_HURTTRIGGER && attacker.message != "")
277 bprint ("^1",s, "^1 ", attacker.message, "\n");
278 else if (deathtype == DEATH_DROWN)
279 bprint ("^1",s, "^1 drowned\n");
280 else if (deathtype == DEATH_SLIME)
281 bprint ("^1",s, "^1 was slimed\n");
282 else if (deathtype == DEATH_LAVA)
283 bprint ("^1",s, "^1 turned into hot slag\n");
284 else if (deathtype == DEATH_FALL)
285 bprint ("^1",s, "^1 hit the ground with a crunch\n");
286 else if (deathtype == DEATH_SHOOTING_STAR)
287 bprint ("^1",s, "^1 became a shooting star\n");
288 else if (deathtype == DEATH_SWAMP)
289 bprint ("^1",s, "^1 is now conserved for centuries to come\n");
291 bprint ("^1",s, "^1 died\n");
292 GiveFrags(targ, targ, -1);
293 if(targ.frags == -5) {
294 play2(targ, "announcer/male/botlike.ogg");
297 if (targ.killcount > 2)
298 bprint ("^1",s,"^1 died with a ",ftos(targ.killcount)," kill spree\n");
300 LogDeath("accident", deathtype, targ, targ);
302 targ.death_origin = targ.origin;
304 targ.killer_origin = attacker.origin;
305 // FIXME: this should go in PutClientInServer
311 // these are updated by each Damage call for use in button triggering and such
313 entity damage_inflictor;
314 entity damage_attacker;
316 void Damage (entity targ, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
320 entity attacker_save;
324 if (gameover || targ.killcount == -666)
327 local entity oldself;
331 damage_inflictor = inflictor;
332 damage_attacker = attacker;
333 attacker_save = attacker;
335 if (targ.classname == "player")
336 if (attacker.classname == "player")
339 damage = damage * bound(0.1, (skill + 5) * 0.1, 1);
341 // nullify damage if teamplay is on
342 if(deathtype != DEATH_TELEFRAG)
346 if(attacker.team == targ.team)
351 if(attacker.team == targ.team)
355 if(attacker.team == targ.team)
356 if(attacker.classname == "player")
357 if((targ.classname == "player") && (targ.health > 0))
359 mirrordamage = cvar("g_mirrordamage") * damage;
360 mirrorforce = cvar("g_mirrordamage") * vlen(force);
361 if(cvar("g_minstagib"))
363 if(cvar("g_friendlyfire") == 0)
367 damage = cvar("g_friendlyfire") * damage;
368 // mirrordamage will be used LATER
373 if(targ.classname == "player")
374 if(attacker.classname == "player")
377 targ.lms_traveled_distance = cvar("g_lms_campcheck_distance");
378 attacker.lms_traveled_distance = cvar("g_lms_campcheck_distance");
384 if(targ.classname == "player")
386 attacker.hitsound += 1;
388 if (cvar("g_minstagib"))
390 if ((deathtype == DEATH_FALL) ||
391 (deathtype == DEATH_DROWN) ||
392 (deathtype == DEATH_SLIME) ||
393 (deathtype == DEATH_LAVA))
395 if (targ.armorvalue && (deathtype == IT_NEX) && damage)
397 targ.armorvalue -= 1;
398 centerprint(targ, strcat("^3Remaining extra lives: ",ftos(targ.armorvalue),"\n"));
402 else if (deathtype == IT_NEX && targ.items & IT_STRENGTH)
404 if(clienttype(attacker) == CLIENTTYPE_REAL) play2(attacker, "announcer/male/yoda.ogg");
406 if (deathtype == IT_LASER)
409 if (targ != attacker)
411 if (targ.classname == "player")
412 centerprint(attacker, "Secondary fire inflicts no damage!\n");
421 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)
423 if(clienttype(attacker) == CLIENTTYPE_REAL) play2(attacker, "announcer/male/yoda.ogg");
427 // apply strength multiplier
428 if (attacker.items & IT_STRENGTH && !cvar("g_minstagib"))
430 damage = damage * cvar("g_balance_powerup_strength_damage");
431 force = force * cvar("g_balance_powerup_strength_force");
433 // apply invincibility multiplier
434 if (targ.items & IT_INVINCIBLE && !cvar("g_minstagib"))
435 damage = damage * cvar("g_balance_powerup_invincible_takedamage");
438 if(cvar("g_runematch"))
440 // apply strength rune
441 if (attacker.runes & RUNE_STRENGTH)
443 if(attacker.runes & CURSE_WEAK) // have both curse & rune
445 damage = damage * cvar("g_balance_rune_strength_combo_damage");
446 force = force * cvar("g_balance_rune_strength_combo_force");
450 damage = damage * cvar("g_balance_rune_strength_damage");
451 force = force * cvar("g_balance_rune_strength_force");
454 else if (attacker.runes & CURSE_WEAK)
456 damage = damage * cvar("g_balance_curse_weak_damage");
457 force = force * cvar("g_balance_curse_weak_force");
460 // apply defense rune
461 if (targ.runes & RUNE_DEFENSE)
463 if (targ.runes & CURSE_VULNER) // have both curse & rune
464 damage = damage * cvar("g_balance_rune_defense_combo_takedamage");
466 damage = damage * cvar("g_balance_rune_defense_takedamage");
468 else if (targ.runes & CURSE_VULNER)
469 damage = damage * cvar("g_balance_curse_vulner_takedamage");
473 if (self.damageforcescale)
475 self.velocity = self.velocity + self.damageforcescale * force;
476 self.flags = self.flags - (self.flags & FL_ONGROUND);
479 if (self.event_damage)
480 self.event_damage (inflictor, attacker, damage, deathtype, hitloc, force);
483 if(targ.classname == "player" && attacker.classname == "player" && attacker != targ && attacker.health > 2)
485 // Savage: vampire mode
486 if(cvar("g_vampire") && !cvar("g_minstagib"))
488 attacker.health += damage;
490 if(cvar("g_runematch"))
492 if (attacker.runes & RUNE_VAMPIRE)
494 // apply vampire rune
495 if (attacker.runes & CURSE_EMPATHY) // have the curse too
497 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb");
498 attacker.health = bound(
499 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 40
500 attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb"),
501 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
505 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_absorb");
506 attacker.health = bound(
507 attacker.health, // LA: was 3, but changed so that you can't lose health
508 // empathy won't let you gain health in the same way...
509 attacker.health + damage * cvar("g_balance_rune_vampire_absorb"),
510 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
513 // apply empathy curse
514 else if (attacker.runes & CURSE_EMPATHY)
516 attacker.health = bound(
517 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 20
518 attacker.health + damage * cvar("g_balance_curse_empathy_takedamage"),
524 // apply mirror damage if any
525 if(mirrordamage > 0 || mirrorforce > 0)
527 attacker = attacker_save;
528 if(cvar("g_minstagib"))
531 // just lose extra LIVES, don't kill the player for mirror damage
532 if(attacker.armorvalue > 0)
534 attacker.armorvalue = attacker.armorvalue - 1;
535 centerprint(attacker, strcat("^3Remaining extra lives: ",ftos(attacker.armorvalue),"\n"));
536 attacker.hitsound += 1;
540 force = normalize(attacker.origin + attacker.view_ofs - hitloc) * mirrorforce;
541 Damage(attacker, inflictor, attacker, mirrordamage, DEATH_MIRRORDAMAGE, attacker.origin, force);
545 void RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype)
558 blastorigin = (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5);
560 targ = findradius (blastorigin, rad);
563 if (targ != inflictor)
566 // LordHavoc: measure distance to nearest point on target (not origin)
567 // (this guarentees 100% damage on a touch impact)
568 nearest = blastorigin;
569 m1 = targ.origin + targ.mins;
570 m2 = targ.origin + targ.maxs;
571 if (nearest_x < m1_x) nearest_x = m1_x;
572 if (nearest_y < m1_y) nearest_y = m1_y;
573 if (nearest_z < m1_z) nearest_z = m1_z;
574 if (nearest_x > m2_x) nearest_x = m2_x;
575 if (nearest_y > m2_y) nearest_y = m2_y;
576 if (nearest_z > m2_z) nearest_z = m2_z;
577 diff = nearest - blastorigin;
578 // round up a little on the damage to ensure full damage on impacts
579 // and turn the distance into a fraction of the radius
580 power = 1 - ((vlen (diff) - 2) / rad);
582 //bprint(ftos(power));
587 finaldmg = coredamage * power + edgedamage * (1 - power);
590 center = (m1 + m2) * 0.5;
591 // if it's a player, use the view origin as reference
592 if (targ.classname == "player")
593 center = targ.origin + targ.view_ofs;
594 force = normalize(center - blastorigin) * (finaldmg / coredamage) * forceintensity;
595 if (targ == attacker)
596 finaldmg = finaldmg * cvar("g_balance_selfdamagepercent"); // Partial damage if the attacker hits himself
597 // test line of sight to multiple positions on box,
598 // and do damage if any of them hit
600 c = ceil(finaldmg / 10);
606 traceline(blastorigin, nearest, TRUE, inflictor);
607 if (trace_fraction == 1 || trace_ent == targ
608 || cvar("g_throughfloor"))
610 Damage (targ, inflictor, attacker, finaldmg, deathtype, nearest, force);
613 nearest_x = m1_x + random() * targ.size_x;
614 nearest_y = m1_y + random() * targ.size_y;
615 nearest_z = m1_z + random() * targ.size_z;
629 void ClearMultiDamage (void)
633 multi_force = '0 0 0';
636 void ApplyMultiDamage (void)
641 Damage (self, multi_ent.origin, multi_ent, 0, multi_damage, multi_force);
644 void AddMultiDamage (entity hit, float damage, vector force)
649 if (hit != multi_ent)
655 multi_damage = multi_damage + damage;
656 multi_force = multi_force + force;
659 void FireBullets (float shotcount, vector dir, vector spread, float deathtype)
666 makevectors (self.v_angle);
668 source = self.origin + v_forward * 10; // FIXME
669 source_x = self.absmin_z + self.size_z * 0.7; // ??? whaddabout view_ofs
671 // LordHavoc: better to use normal damage
672 //ClearMultiDamage ();
673 while (shotcount > 0)
675 direction = dir + crandom () * spread_x * v_right + crandom () * spread_y * v_up;
677 traceline (source, source + direction * 2048, FALSE, self);
678 if (trace_fraction != 1.0)
680 vel = normalize (direction + v_up * crandom () + v_right * crandom ());
681 vel = vel + 2 * trace_plane_normal;
684 org = trace_endpos - direction * 4;
686 if (!trace_ent.takedamage)
688 // LordHavoc: better to use normal damage
689 //AddMultiDamage (trace_ent, 4, direction * 4);
690 Damage (trace_ent, self, self, 4, deathtype, trace_endpos, direction * 4);
693 shotcount = shotcount + 1;
696 // LordHavoc: better to use normal damage
697 //ApplyMultiDamage ();