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 m = "You are now on: ";
115 m = strcat(m, "^1Red Team");
116 else if (targ.team == 14)
117 m = strcat(m, "^4Blue Team");
118 else if (targ.team == 10)
119 m = strcat(m, "^6Pink Team");
120 else if (targ.team == 13)
121 m = strcat(m, "^3Yellow Team");
122 centerprint(targ, m);
124 else if (deathtype == DEATH_AUTOTEAMCHANGE)
126 m = "You have been moved into a different team to improve team balance\nYou are now on: ";
128 m = strcat(m, "^1Red Team");
129 else if (targ.team == 14)
130 m = strcat(m, "^4Blue Team");
131 else if (targ.team == 10)
132 m = strcat(m, "^6Pink Team");
133 else if (targ.team == 13)
134 m = strcat(m, "^3Yellow Team");
135 centerprint(targ, m);
138 else if (deathtype == DEATH_CAMP)
139 centerprint(targ, "^1Die camper!\n\n\n");
140 else if (deathtype == DEATH_NOAMMO)
141 centerprint(targ, "^1You were killed for running out of ammo...\n\n\n");
142 else if (deathtype == DEATH_ROT)
143 centerprint(targ, "^1You grew too old without taking your medicine\n\n\n");
144 else if (deathtype == DEATH_MIRRORDAMAGE)
145 centerprint(targ, "^1Don't shoot your team mates!\n\n\n");
147 centerprint(targ, "^1You killed your own dumb self!\n\n\n");
149 if (deathtype == IT_GRENADE_LAUNCHER)
150 bprint ("^1",s, "^1 detonated\n");
151 else if (deathtype == IT_ELECTRO)
152 bprint ("^1",s, "^1 played with plasma\n");
153 else if (deathtype == IT_ROCKET_LAUNCHER)
154 bprint ("^1",s, "^1 exploded\n");
155 else if (deathtype == DEATH_KILL)
156 bprint ("^1",s, "^1 couldn't take it anymore\n");
157 else if (deathtype == DEATH_ROT)
158 bprint ("^1",s, "^1 died\n");
159 else if (deathtype == DEATH_NOAMMO)
161 bprint ("^7",s, " ^7committed suicide. What's the point of living without ammo?\n");
162 //sound (self, CHAN_BODY, "minstagib/mockery.wav", 1, ATTN_NONE);
164 else if (deathtype == DEATH_CAMP)
165 bprint ("^1",s, "^1 thought he found a nice camping ground\n");
166 else if (deathtype == DEATH_MIRRORDAMAGE)
167 bprint ("^1",s, "^1 didn't become friends with the Lord of Teamplay\n");
168 else if (deathtype != DEATH_TEAMCHANGE)
169 bprint ("^1",s, "^1 couldn't resist the urge to self-destruct\n");
171 if(deathtype != DEATH_TEAMCHANGE)
173 LogDeath("suicide", deathtype, targ, targ);
174 GiveFrags(attacker, targ, -1);
176 if (targ.killcount > 2)
177 bprint ("^1",s,"^1 ended it all with a ",ftos(targ.killcount)," kill spree\n");
179 else if (attacker.classname == "player" || attacker.classname == "gib")
181 if(teamplay && attacker.team == targ.team)
183 centerprint(attacker, "^1Moron! You fragged a teammate!\n\n\n");
184 bprint ("^1", a, "^1 mows down a teammate\n");
185 GiveFrags(attacker, targ, -1);
186 if (targ.killcount > 2)
187 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," kill spree was ended by a teammate!\n");
188 if (attacker.killcount > 2)
189 bprint ("^1",a,"^1 ended a ",ftos(attacker.killcount)," kill spree by killing a teammate\n");
190 attacker.killcount = 0;
192 LogDeath("tk", deathtype, attacker, targ);
196 if (!checkrules_firstblood)
198 checkrules_firstblood = TRUE;
199 //sound(world, CHAN_AUTO, "announcer/firstblood.wav", 1, ATTN_NONE);
200 //if (cvar("g_minstagib"))
201 //sound(world, CHAN_AUTO, "announce/male/mapkill1.wav", 1, ATTN_NONE);
202 bprint("^1",a, "^1 drew first blood", "\n");
205 centerprint(attacker, strcat("^4You fragged ^7", s, "\n\n\n"));
206 centerprint(targ, strcat("^1You were fragged by ^7", a, "\n\n\n"));
208 if (deathtype == IT_LASER)
209 bprint ("^1",s, "^1 was blasted by ", a, "\n");
210 else if (deathtype == IT_UZI)
211 bprint ("^1",s, "^1 was riddled full of holes by ", a, "\n");
212 else if (deathtype == IT_SHOTGUN)
213 bprint ("^1",s, "^1 was gunned by ", a, "\n");
214 else if (deathtype == IT_GRENADE_LAUNCHER)
215 bprint ("^1", s, "^1 was blasted by ", a, "\n");
216 else if (deathtype == IT_ELECTRO)
217 bprint ("^1",s, "^1 was blasted by ", a, "\n");
218 else if (deathtype == IT_CRYLINK)
219 bprint ("^1",s, "^1 was blasted by ", a, "\n");
220 else if (deathtype == IT_NEX)
221 bprint ("^1",s, "^1 has been vaporized by ", a, "\n");
222 else if (deathtype == IT_HAGAR)
223 bprint ("^1",s, "^1 was pummeled by ", a, "\n");
224 else if (deathtype == IT_ROCKET_LAUNCHER)
225 bprint ("^1",s, "^1 was blasted by ", a, "\n");
226 else if (deathtype == DEATH_TELEFRAG)
227 bprint ("^1",s, "^1 was telefragged by ", a, "\n");
228 else if (deathtype == DEATH_DROWN)
229 bprint ("^1",s, "^1 was drowned by ", a, "\n");
230 else if (deathtype == DEATH_SLIME)
231 bprint ("^1",s, "^1 was slimed by ", a, "\n");
232 else if (deathtype == DEATH_LAVA)
233 bprint ("^1",s, "^1 was cooked by ", a, "\n");
234 else if (deathtype == DEATH_FALL)
235 bprint ("^1",s, "^1 was grounded by ", a, "\n");
236 else if (deathtype == DEATH_SHOOTING_STAR)
237 bprint ("^1",s, "^1 was shot into space by ", a, "\n");
238 else if (deathtype == DEATH_SWAMP)
239 bprint ("^1",s, "^1 was conserved by ", a, "\n");
240 else if (deathtype == DEATH_HURTTRIGGER)
241 bprint ("^1",s, "^1 was thrown into a world of hurt by ", a, "\n");
243 bprint ("^1",s, "^1 was fragged by ", a, "\n");
245 GiveFrags(attacker, targ, 1);
246 if (targ.killcount > 2)
247 bprint ("^1",s,"'s ^1", ftos(targ.killcount), " kill spree was ended by ", a, "\n");
248 attacker.killcount = attacker.killcount + 1;
249 if (attacker.killcount > 2)
250 bprint ("^1",a,"^1 has ",ftos(attacker.killcount)," frags in a row\n");
252 LogDeath("frag", deathtype, attacker, targ);
254 if (attacker.killcount == 3)
256 bprint (a,"^7 made a ^1TRIPLE FRAG\n");
257 play2(attacker, "announcer/male/03kills.ogg");
259 else if (attacker.killcount == 5)
261 bprint (a,"^7 made a ^1FIVE FRAG COMBO\n");
262 play2(attacker, "announcer/male/05kills.ogg");
264 else if (attacker.killcount == 10)
266 bprint (a,"^7 is on a ^1RAGE\n");
267 play2(attacker, "announcer/male/10kills.ogg");
269 else if (attacker.killcount == 15)
271 bprint (a,"^7 has done a ^1MASSACRE!\n");
272 play2(attacker, "announcer/male/15kills.ogg");
274 else if (attacker.killcount == 20)
276 bprint (a,"^7 is ^1UNHUMAN!\n");
277 play2(attacker, "announcer/male/20kills.ogg");
279 else if (attacker.killcount == 25)
281 bprint (a,"^7 is a ^1DEATH INCARNATION!\n");
282 play2(attacker, "announcer/male/25kills.ogg");
284 else if (attacker.killcount == 30)
286 bprint (a,"^7 is maybe a ^1AIMBOTTER?!\n");
287 play2(attacker, "announcer/male/30kills.ogg");
293 centerprint(targ, "^1Watch your step!\n\n\n");
294 if (deathtype == DEATH_HURTTRIGGER && attacker.message != "")
295 bprint ("^1",s, "^1 ", attacker.message, "\n");
296 else if (deathtype == DEATH_DROWN)
297 bprint ("^1",s, "^1 drowned\n");
298 else if (deathtype == DEATH_SLIME)
299 bprint ("^1",s, "^1 was slimed\n");
300 else if (deathtype == DEATH_LAVA)
301 bprint ("^1",s, "^1 turned into hot slag\n");
302 else if (deathtype == DEATH_FALL)
303 bprint ("^1",s, "^1 hit the ground with a crunch\n");
304 else if (deathtype == DEATH_SHOOTING_STAR)
305 bprint ("^1",s, "^1 became a shooting star\n");
306 else if (deathtype == DEATH_SWAMP)
307 bprint ("^1",s, "^1 is now conserved for centuries to come\n");
309 bprint ("^1",s, "^1 died\n");
310 GiveFrags(targ, targ, -1);
311 if(targ.frags == -5) {
312 play2(targ, "announcer/male/botlike.ogg");
315 if (targ.killcount > 2)
316 bprint ("^1",s,"^1 died with a ",ftos(targ.killcount)," kill spree\n");
318 LogDeath("accident", deathtype, targ, targ);
320 targ.death_origin = targ.origin;
322 targ.killer_origin = attacker.origin;
323 // FIXME: this should go in PutClientInServer
329 // these are updated by each Damage call for use in button triggering and such
331 entity damage_inflictor;
332 entity damage_attacker;
334 void Damage (entity targ, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
338 entity attacker_save;
342 if (gameover || targ.killcount == -666)
345 local entity oldself;
349 damage_inflictor = inflictor;
350 damage_attacker = attacker;
351 attacker_save = attacker;
353 if (targ.classname == "player")
354 if (attacker.classname == "player")
357 damage = damage * bound(0.1, (skill + 5) * 0.1, 1);
359 // nullify damage if teamplay is on
360 if(deathtype != DEATH_TELEFRAG)
364 if(attacker.team == targ.team)
369 if(attacker.team == targ.team)
373 if(attacker.team == targ.team)
374 if(attacker.classname == "player")
375 if((targ.classname == "player") && (targ.health > 0))
377 mirrordamage = cvar("g_mirrordamage") * damage;
378 mirrorforce = cvar("g_mirrordamage") * vlen(force);
379 if(cvar("g_minstagib"))
381 if(cvar("g_friendlyfire") == 0)
385 damage = cvar("g_friendlyfire") * damage;
386 // mirrordamage will be used LATER
391 if(targ.classname == "player")
392 if(attacker.classname == "player")
395 targ.lms_traveled_distance = cvar("g_lms_campcheck_distance");
396 attacker.lms_traveled_distance = cvar("g_lms_campcheck_distance");
402 if(targ.classname == "player")
404 attacker.hitsound += 1;
406 if (cvar("g_minstagib"))
408 if ((deathtype == DEATH_FALL) ||
409 (deathtype == DEATH_DROWN) ||
410 (deathtype == DEATH_SLIME) ||
411 (deathtype == DEATH_LAVA))
413 if (targ.armorvalue && (deathtype == IT_NEX) && damage)
415 targ.armorvalue -= 1;
416 centerprint(targ, strcat("^3Remaining extra lives: ",ftos(targ.armorvalue),"\n"));
420 else if (deathtype == IT_NEX && targ.items & IT_STRENGTH)
422 if(clienttype(attacker) == CLIENTTYPE_REAL) play2(attacker, "announcer/male/yoda.ogg");
424 if (deathtype == IT_LASER)
427 if (targ != attacker)
429 if (targ.classname == "player")
430 centerprint(attacker, "Secondary fire inflicts no damage!\n");
439 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)
441 if(clienttype(attacker) == CLIENTTYPE_REAL) play2(attacker, "announcer/male/yoda.ogg");
445 // apply strength multiplier
446 if (attacker.items & IT_STRENGTH && !cvar("g_minstagib"))
448 damage = damage * cvar("g_balance_powerup_strength_damage");
449 force = force * cvar("g_balance_powerup_strength_force");
451 // apply invincibility multiplier
452 if (targ.items & IT_INVINCIBLE && !cvar("g_minstagib"))
453 damage = damage * cvar("g_balance_powerup_invincible_takedamage");
456 if(cvar("g_runematch"))
458 // apply strength rune
459 if (attacker.runes & RUNE_STRENGTH)
461 if(attacker.runes & CURSE_WEAK) // have both curse & rune
463 damage = damage * cvar("g_balance_rune_strength_combo_damage");
464 force = force * cvar("g_balance_rune_strength_combo_force");
468 damage = damage * cvar("g_balance_rune_strength_damage");
469 force = force * cvar("g_balance_rune_strength_force");
472 else if (attacker.runes & CURSE_WEAK)
474 damage = damage * cvar("g_balance_curse_weak_damage");
475 force = force * cvar("g_balance_curse_weak_force");
478 // apply defense rune
479 if (targ.runes & RUNE_DEFENSE)
481 if (targ.runes & CURSE_VULNER) // have both curse & rune
482 damage = damage * cvar("g_balance_rune_defense_combo_takedamage");
484 damage = damage * cvar("g_balance_rune_defense_takedamage");
486 else if (targ.runes & CURSE_VULNER)
487 damage = damage * cvar("g_balance_curse_vulner_takedamage");
491 if (self.damageforcescale)
493 self.velocity = self.velocity + self.damageforcescale * force;
494 self.flags = self.flags - (self.flags & FL_ONGROUND);
497 if (self.event_damage)
498 self.event_damage (inflictor, attacker, damage, deathtype, hitloc, force);
501 if(targ.classname == "player" && attacker.classname == "player" && attacker != targ && attacker.health > 2)
503 // Savage: vampire mode
504 if(cvar("g_vampire") && !cvar("g_minstagib"))
506 attacker.health += damage;
508 if(cvar("g_runematch"))
510 if (attacker.runes & RUNE_VAMPIRE)
512 // apply vampire rune
513 if (attacker.runes & CURSE_EMPATHY) // have the curse too
515 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb");
516 attacker.health = bound(
517 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 40
518 attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb"),
519 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
523 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_absorb");
524 attacker.health = bound(
525 attacker.health, // LA: was 3, but changed so that you can't lose health
526 // empathy won't let you gain health in the same way...
527 attacker.health + damage * cvar("g_balance_rune_vampire_absorb"),
528 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
531 // apply empathy curse
532 else if (attacker.runes & CURSE_EMPATHY)
534 attacker.health = bound(
535 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 20
536 attacker.health + damage * cvar("g_balance_curse_empathy_takedamage"),
542 // apply mirror damage if any
543 if(mirrordamage > 0 || mirrorforce > 0)
545 attacker = attacker_save;
546 if(cvar("g_minstagib"))
549 // just lose extra LIVES, don't kill the player for mirror damage
550 if(attacker.armorvalue > 0)
552 attacker.armorvalue = attacker.armorvalue - 1;
553 centerprint(attacker, strcat("^3Remaining extra lives: ",ftos(attacker.armorvalue),"\n"));
554 attacker.hitsound += 1;
558 force = normalize(attacker.origin + attacker.view_ofs - hitloc) * mirrorforce;
559 Damage(attacker, inflictor, attacker, mirrordamage, DEATH_MIRRORDAMAGE, attacker.origin, force);
563 void RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype)
576 blastorigin = (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5);
578 targ = findradius (blastorigin, rad);
581 if (targ != inflictor)
584 // LordHavoc: measure distance to nearest point on target (not origin)
585 // (this guarentees 100% damage on a touch impact)
586 nearest = blastorigin;
587 m1 = targ.origin + targ.mins;
588 m2 = targ.origin + targ.maxs;
589 if (nearest_x < m1_x) nearest_x = m1_x;
590 if (nearest_y < m1_y) nearest_y = m1_y;
591 if (nearest_z < m1_z) nearest_z = m1_z;
592 if (nearest_x > m2_x) nearest_x = m2_x;
593 if (nearest_y > m2_y) nearest_y = m2_y;
594 if (nearest_z > m2_z) nearest_z = m2_z;
595 diff = nearest - blastorigin;
596 // round up a little on the damage to ensure full damage on impacts
597 // and turn the distance into a fraction of the radius
598 power = 1 - ((vlen (diff) - 2) / rad);
600 //bprint(ftos(power));
605 finaldmg = coredamage * power + edgedamage * (1 - power);
608 center = (m1 + m2) * 0.5;
609 // if it's a player, use the view origin as reference
610 if (targ.classname == "player")
611 center = targ.origin + targ.view_ofs;
612 force = normalize(center - blastorigin) * (finaldmg / coredamage) * forceintensity;
613 if (targ == attacker)
614 finaldmg = finaldmg * cvar("g_balance_selfdamagepercent"); // Partial damage if the attacker hits himself
615 // test line of sight to multiple positions on box,
616 // and do damage if any of them hit
618 c = ceil(finaldmg / 10);
624 traceline(blastorigin, nearest, TRUE, inflictor);
625 if (trace_fraction == 1 || trace_ent == targ
626 || cvar("g_throughfloor"))
628 Damage (targ, inflictor, attacker, finaldmg, deathtype, nearest, force);
631 nearest_x = m1_x + random() * targ.size_x;
632 nearest_y = m1_y + random() * targ.size_y;
633 nearest_z = m1_z + random() * targ.size_z;
647 void ClearMultiDamage (void)
651 multi_force = '0 0 0';
654 void ApplyMultiDamage (void)
659 Damage (self, multi_ent.origin, multi_ent, 0, multi_damage, multi_force);
662 void AddMultiDamage (entity hit, float damage, vector force)
667 if (hit != multi_ent)
673 multi_damage = multi_damage + damage;
674 multi_force = multi_force + force;
677 void FireBullets (float shotcount, vector dir, vector spread, float deathtype)
684 makevectors (self.v_angle);
686 source = self.origin + v_forward * 10; // FIXME
687 source_x = self.absmin_z + self.size_z * 0.7; // ??? whaddabout view_ofs
689 // LordHavoc: better to use normal damage
690 //ClearMultiDamage ();
691 while (shotcount > 0)
693 direction = dir + crandom () * spread_x * v_right + crandom () * spread_y * v_up;
695 traceline (source, source + direction * 2048, FALSE, self);
696 if (trace_fraction != 1.0)
698 vel = normalize (direction + v_up * crandom () + v_right * crandom ());
699 vel = vel + 2 * trace_plane_normal;
702 org = trace_endpos - direction * 4;
704 if (!trace_ent.takedamage)
706 // LordHavoc: better to use normal damage
707 //AddMultiDamage (trace_ent, 4, direction * 4);
708 Damage (trace_ent, self, self, 4, deathtype, trace_endpos, direction * 4);
711 shotcount = shotcount + 1;
714 // LordHavoc: better to use normal damage
715 //ApplyMultiDamage ();