2 float checkrules_firstblood;
4 void GiveFrags (entity attacker, entity targ, float f)
9 if(f > 0 && cvar("g_domination") && cvar("g_domination_disable_frags"))
11 else if(f > 0 && cvar("g_runematch"))
12 f = RunematchHandleFrags(attacker, targ, f);
13 else if(cvar("g_lms"))
15 // count remaining lives, not frags in lms
17 // keep track of the worst players lives
18 if(targ.frags < lms_lowest_lives)
19 lms_lowest_lives = targ.frags;
20 // player has no more lives left
25 lms_next_place = player_count;
26 targ.frags = -lms_next_place;
33 attacker.frags = attacker.frags + f;
36 string AppendItemcodes(string s, entity player)
41 // w = player.switchweapon;
43 w = player.cnt; // previous weapon!
44 s = strcat(s, ftos(weapon_translateindextoflag(w)));
45 if(time < player.strength_finished)
47 if(time < player.invincible_finished)
49 if(player.flagcarried != world)
52 s = strcat(s, "|", ftos(player.runes));
56 void LogDeath(string mode, float deathtype, entity killer, entity killed)
59 if(!cvar("sv_eventlog"))
61 s = strcat(":kill:", mode);
62 s = strcat(s, ":", ftos(killer.playerid));
63 s = strcat(s, ":", ftos(killed.playerid));
64 s = strcat(s, ":type=", ftos(deathtype));
65 s = strcat(s, ":items=");
66 s = AppendItemcodes(s, killer);
69 s = strcat(s, ":victimitems=");
70 s = AppendItemcodes(s, killed);
72 GameLogEcho(s, FALSE);
75 void Obituary (entity attacker, entity targ, float deathtype)
79 if (targ.classname == "player" || targ.classname == "corpse")
81 if (targ.classname == "corpse")
88 if (deathtype == DEATH_NOAMMO)
89 centerprint(targ, strcat("^1You were killed for running out of ammo...\n\n\n"));
90 if (deathtype == DEATH_TEAMCHANGE)
92 m = "You are now on: ";
94 m = strcat(m, "^1Red Team");
95 else if (targ.team == 14)
96 m = strcat(m, "^4Blue Team");
97 else if (targ.team == 10)
98 m = strcat(m, "^6Pink Team");
99 else if (targ.team == 13)
100 m = strcat(m, "^3Yellow Team");
101 centerprint(targ, m);
103 else if (deathtype == DEATH_AUTOTEAMCHANGE)
105 m = "You have been moved into a different team to improve team balance\nYou are now on: ";
107 m = strcat(m, "^1Red Team");
108 else if (targ.team == 14)
109 m = strcat(m, "^4Blue Team");
110 else if (targ.team == 10)
111 m = strcat(m, "^6Pink Team");
112 else if (targ.team == 13)
113 m = strcat(m, "^3Yellow Team");
114 centerprint(targ, m);
117 else if (deathtype == DEATH_CAMP)
118 centerprint(targ, strcat("^1Die camper!\n\n\n"));
120 centerprint(targ, strcat("^1You killed your own dumb self!\n\n\n"));
122 if (deathtype == IT_GRENADE_LAUNCHER)
123 bprint ("^1",s, "^1 detonated\n");
124 else if (deathtype == IT_ELECTRO)
125 bprint ("^1",s, "^1 played with plasma\n");
126 else if (deathtype == IT_ROCKET_LAUNCHER)
127 bprint ("^1",s, "^1 exploded\n");
128 else if (deathtype == DEATH_KILL)
129 bprint ("^1",s, "^1 couldn't take it anymore\n");
130 else if (deathtype == DEATH_NOAMMO)
132 bprint ("^7",s, " ^7committed suicide. What's the point of living without ammo?\n");
133 //sound (self, CHAN_BODY, "minstagib/mockery.ogg", 1, ATTN_NONE);
135 else if (deathtype == DEATH_CAMP)
136 bprint ("^1",s, "^1 thought he found a nice camping ground\n");
137 else if (deathtype != DEATH_TEAMCHANGE)
138 bprint ("^1",s, "^1 couldn't resist the urge to self-destruct\n");
140 if(deathtype != DEATH_TEAMCHANGE)
141 LogDeath("suicide", deathtype, targ, targ);
143 GiveFrags(attacker, targ, -1);
144 //targ.frags = targ.frags - 1;
145 if (targ.killcount > 2)
146 bprint ("^1",s,"^1 ended it all with a ",ftos(targ.killcount)," kill spree\n");
148 else if (teamplay && attacker.team == targ.team)
150 centerprint(attacker, strcat("^1Moron! You fragged a teammate!\n\n\n"));
151 bprint ("^1", attacker.netname, "^1 mows down a teammate\n");
152 GiveFrags(attacker, targ, -1);
153 //attacker.frags = attacker.frags - 1;
154 if (targ.killcount > 2)
155 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," kill spree was endeded by a teammate!\n");
156 if (attacker.killcount > 2)
157 bprint ("^1",attacker.netname,"^1 ended a ",ftos(attacker.killcount)," kill spree by killing a teammate\n");
158 attacker.killcount = 0;
160 LogDeath("tk", deathtype, attacker, targ);
162 else if (attacker.classname == "player" || attacker.classname == "gib")
164 if (!checkrules_firstblood)
166 checkrules_firstblood = TRUE;
167 //sound(world, CHAN_AUTO, "announcer/firstblood.wav", 1, ATTN_NONE);
168 //if (cvar("g_minstagib"))
169 //sound(world, CHAN_AUTO, "announce/male/mapkill1.ogg", 1, ATTN_NONE);
170 bprint("^1",attacker.netname, "^1 drew first blood", "\n");
173 centerprint(attacker, strcat("^4You fragged ^7", s, "\n\n\n"));
174 centerprint(targ, strcat("^1You were fragged by ^7", attacker.netname, "\n\n\n"));
176 if (deathtype == IT_LASER)
177 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
178 else if (deathtype == IT_UZI)
179 bprint ("^1",s, "^1 was riddled full of holes by ", attacker.netname, "\n");
180 else if (deathtype == IT_SHOTGUN)
181 bprint ("^1",s, "^1 was gunned by ", attacker.netname, "\n");
182 else if (deathtype == IT_GRENADE_LAUNCHER)
183 bprint ("^1", s, "^1 was blasted by ", attacker.netname, "\n");
184 else if (deathtype == IT_ELECTRO)
185 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
186 else if (deathtype == IT_CRYLINK)
187 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
188 else if (deathtype == IT_NEX)
189 bprint ("^1",s, "^1 has been vaporized by ", attacker.netname, "\n");
190 else if (deathtype == IT_HAGAR)
191 bprint ("^1",s, "^1 was pummeled by ", attacker.netname, "\n");
192 else if (deathtype == IT_ROCKET_LAUNCHER)
193 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
194 else if (deathtype == DEATH_TELEFRAG)
195 bprint ("^1",s, "^1 was telefragged by ", attacker.netname, "\n");
196 else if (deathtype == DEATH_DROWN)
197 bprint ("^1",s, "^1 was drowned by ", attacker.netname, "\n");
198 else if (deathtype == DEATH_SLIME)
199 bprint ("^1",s, "^1 was slimed by ", attacker.netname, "\n");
200 else if (deathtype == DEATH_LAVA)
201 bprint ("^1",s, "^1 was cooked by ", attacker.netname, "\n");
202 else if (deathtype == DEATH_FALL)
203 bprint ("^1",s, "^1 was grounded by ", attacker.netname, "\n");
204 else if (deathtype == DEATH_SHOOTING_STAR)
205 bprint ("^1",s, "^1 was shot into space by ", attacker.netname, "\n");
206 else if (deathtype == DEATH_SWAMP)
207 bprint ("^1",s, "^1 was conserved by ", attacker.netname, "\n");
208 else if (deathtype == DEATH_HURTTRIGGER)
209 bprint ("^1",s, "^1 was thrown into a world of hurt by ", attacker.netname, "\n");
211 bprint ("^1",s, "^1 was fragged by ", attacker.netname, "\n");
213 GiveFrags(attacker, targ, 1);
214 //attacker.frags = attacker.frags + 1;
215 if (targ.killcount > 2)
216 bprint ("^1",s,"'s ^1", ftos(targ.killcount), " kill spree was ended by ", attacker.netname, "\n");
217 attacker.killcount = attacker.killcount + 1;
218 if (attacker.killcount > 2)
219 bprint ("^1",attacker.netname,"^1 has ",ftos(attacker.killcount)," frags in a row\n");
221 LogDeath("frag", deathtype, attacker, targ);
223 if (attacker.killcount == 3)
225 bprint (attacker.netname,"^7 made a ^1TRIPLE FRAG\n");
226 stuffcmd(attacker, "play2 announcer/male/03kills.ogg\n");
228 else if (attacker.killcount == 5)
230 bprint (attacker.netname,"^7 made a ^1FIVE FRAG COMBO\n");
231 stuffcmd(attacker, "play2 announcer/male/05kills.ogg\n");
233 else if (attacker.killcount == 10)
235 bprint (attacker.netname,"^7 is on a ^1RAGE\n");
236 stuffcmd(attacker, "play2 announcer/male/10kills.ogg\n");
238 else if (attacker.killcount == 15)
240 bprint (attacker.netname,"^7 has done a ^1MASSACRE!\n");
241 stuffcmd(attacker, "play2 announcer/male/15kills.ogg\n");
243 else if (attacker.killcount == 20)
245 bprint (attacker.netname,"^7 is ^1UNHUMAN!\n");
246 stuffcmd(attacker, "play2 announcer/male/20kills.ogg\n");
248 else if (attacker.killcount == 25)
250 bprint (attacker.netname,"^7 is a ^1DEATH INCARNATION!\n");
251 stuffcmd(attacker, "play2 announcer/male/25kills.ogg\n");
253 else if (attacker.killcount == 30)
255 bprint (attacker.netname,"^7 is maybe a ^1AIMBOTTER?!\n");
256 stuffcmd(attacker, "play2 announcer/male/30kills.ogg\n");
261 centerprint(targ, strcat("^1Watch your step!\n\n\n"));
262 if (deathtype == DEATH_HURTTRIGGER && attacker.message != "")
263 bprint ("^1",s, "^1 ", attacker.message, "\n");
264 else if (deathtype == DEATH_DROWN)
265 bprint ("^1",s, "^1 drowned\n");
266 else if (deathtype == DEATH_SLIME)
267 bprint ("^1",s, "^1 was slimed\n");
268 else if (deathtype == DEATH_LAVA)
269 bprint ("^1",s, "^1 turned into hot slag\n");
270 else if (deathtype == DEATH_FALL)
271 bprint ("^1",s, "^1 hit the ground with a crunch\n");
272 else if (deathtype == DEATH_SHOOTING_STAR)
273 bprint ("^1",s, "^1 became a shooting star\n");
274 else if (deathtype == DEATH_SWAMP)
275 bprint ("^1",s, "^1 is now conserved for centuries to come\n");
277 bprint ("^1",s, "^1 died\n");
278 GiveFrags(targ, targ, -1);
279 if(targ.frags == -5) {
280 stuffcmd(targ, "play2 announcer/male/botlike.ogg\n");
283 //targ.frags = targ.frags - 1;
284 if (targ.killcount > 2)
285 bprint ("^1",s,"^1 died with a ",ftos(targ.killcount)," kill spree\n");
287 LogDeath("accident", deathtype, targ, targ);
289 targ.death_origin = targ.origin;
291 targ.killer_origin = attacker.origin;
292 // FIXME: this should go in PutClientInServer
298 // these are updated by each Damage call for use in button triggering and such
300 entity damage_inflictor;
301 entity damage_attacker;
303 void Damage (entity targ, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
305 if (gameover || targ.killcount == -666)
308 local entity oldself;
312 damage_inflictor = inflictor;
313 damage_attacker = attacker;
314 // nullify damage if teamplay is on
317 if (attacker.team == targ.team)
318 if ((teamplay == 1 || teamplay == 3) && attacker != targ)
322 if(targ.classname == "player")
323 if(attacker.classname == "player")
326 targ.lms_traveled_distance = cvar("g_lms_campcheck_distance");
327 attacker.lms_traveled_distance = cvar("g_lms_campcheck_distance");
330 if(damage > 0 && targ != attacker && clienttype(attacker) == CLIENTTYPE_REAL && targ.classname == "player")
331 stuffcmd(attacker, "play2 misc/hit.wav\n");
333 if (cvar("g_minstagib"))
335 if ((deathtype == DEATH_FALL) ||
336 (deathtype == DEATH_DROWN) ||
337 (deathtype == DEATH_SLIME) ||
338 (deathtype == DEATH_LAVA))
340 if (targ.extralives && (deathtype == IT_NEX) && damage)
342 targ.extralives -= 1;
343 centerprint(targ, strcat("^3Remaining extra lives: ",ftos(targ.extralives),"\n"));
345 targ.armorvalue = targ.extralives;
346 if(clienttype(targ) == CLIENTTYPE_REAL) stuffcmd(targ, "play2 misc/hit.wav\n");
347 //stuffcmd(attacker, "play2 misc/hit.wav\n");
349 else if (deathtype == IT_NEX && targ.items & IT_STRENGTH)
351 if(clienttype(attacker) == CLIENTTYPE_REAL) stuffcmd(attacker, "play2 announcer/male/yoda.ogg\n");
353 if (deathtype == IT_LASER)
356 if (targ != attacker)
358 if (targ.classname == "player")
359 centerprint(attacker, "Secondary fire inflicts no damage!\n");
366 if (deathtype == IT_NEX && !(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)
368 if(clienttype(attacker) == CLIENTTYPE_REAL) stuffcmd(attacker, "play2 announcer/male/yoda.ogg\n");
372 // apply strength multiplier
373 if (attacker.items & IT_STRENGTH && !cvar("g_minstagib"))
375 damage = damage * cvar("g_balance_powerup_strength_damage");
376 force = force * cvar("g_balance_powerup_strength_force");
378 // apply invincibility multiplier
379 if (targ.items & IT_INVINCIBLE && !cvar("g_minstagib"))
380 damage = damage * cvar("g_balance_powerup_invincible_takedamage");
383 if(cvar("g_runematch"))
385 // apply strength rune
386 if (attacker.runes & RUNE_STRENGTH)
388 if(attacker.runes & CURSE_WEAK) // have both curse & rune
390 damage = damage * cvar("g_balance_rune_strength_combo_damage");
391 force = force * cvar("g_balance_rune_strength_combo_force");
395 damage = damage * cvar("g_balance_rune_strength_damage");
396 force = force * cvar("g_balance_rune_strength_force");
399 else if (attacker.runes & CURSE_WEAK)
401 damage = damage * cvar("g_balance_curse_weak_damage");
402 force = force * cvar("g_balance_curse_weak_force");
405 // apply defense rune
406 if (targ.runes & RUNE_DEFENSE)
408 if (targ.runes & CURSE_VULNER) // have both curse & rune
409 damage = damage * cvar("g_balance_rune_defense_combo_takedamage");
411 damage = damage * cvar("g_balance_rune_defense_takedamage");
413 else if (targ.runes & CURSE_VULNER)
414 damage = damage * cvar("g_balance_curse_vulner_takedamage");
418 if (self.damageforcescale)
420 self.velocity = self.velocity + self.damageforcescale * force;
421 self.flags = self.flags - (self.flags & FL_ONGROUND);
424 if (self.event_damage)
425 self.event_damage (inflictor, attacker, damage, deathtype, hitloc, force);
428 if(targ.classname == "player" && attacker.classname == "player" && attacker != targ && attacker.health > 2)
430 // Savage: vampire mode
431 if(cvar("g_vampire") && !cvar("g_minstagib"))
433 attacker.health += damage;
435 if(cvar("g_runematch"))
437 if (attacker.runes & RUNE_VAMPIRE)
439 // apply vampire rune
440 if (attacker.runes & CURSE_EMPATHY) // have the curse too
442 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb");
443 attacker.health = bound(
444 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 40
445 attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb"),
446 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
450 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_absorb");
451 attacker.health = bound(
452 attacker.health, // LA: was 3, but changed so that you can't lose health
453 // empathy won't let you gain health in the same way...
454 attacker.health + damage * cvar("g_balance_rune_vampire_absorb"),
455 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
458 // apply empathy curse
459 else if (attacker.runes & CURSE_EMPATHY)
461 attacker.health = bound(
462 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 20
463 attacker.health + damage * cvar("g_balance_curse_empathy_takedamage"),
470 void RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype)
482 blastorigin = (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5);
484 targ = findradius (blastorigin, rad);
487 if (targ != inflictor)
490 // LordHavoc: measure distance to nearest point on target (not origin)
491 // (this guarentees 100% damage on a touch impact)
492 nearest = blastorigin;
493 m1 = targ.origin + targ.mins;
494 m2 = targ.origin + targ.maxs;
495 if (nearest_x < m1_x) nearest_x = m1_x;
496 if (nearest_y < m1_y) nearest_y = m1_y;
497 if (nearest_z < m1_z) nearest_z = m1_z;
498 if (nearest_x > m2_x) nearest_x = m2_x;
499 if (nearest_y > m2_y) nearest_y = m2_y;
500 if (nearest_z > m2_z) nearest_z = m2_z;
501 diff = nearest - blastorigin;
502 // round up a little on the damage to ensure full damage on impacts
503 // and turn the distance into a fraction of the radius
504 power = 1 - ((vlen (diff) - 2) / rad);
506 //bprint(ftos(power));
511 finaldmg = coredamage * power + edgedamage * (1 - power);
514 force = normalize((m1 + m2) * 0.5 - blastorigin) * (finaldmg / coredamage) * forceintensity;
515 if (targ == attacker)
516 finaldmg = finaldmg * cvar("g_balance_selfdamagepercent"); // Partial damage if the attacker hits himself
517 Damage (targ, inflictor, attacker, finaldmg, deathtype, nearest, force);
530 void ClearMultiDamage (void)
534 multi_force = '0 0 0';
537 void ApplyMultiDamage (void)
542 Damage (self, multi_ent.origin, multi_ent, 0, multi_damage, multi_force);
545 void AddMultiDamage (entity hit, float damage, vector force)
550 if (hit != multi_ent)
556 multi_damage = multi_damage + damage;
557 multi_force = multi_force + force;
560 void FireBullets (float shotcount, vector dir, vector spread, float deathtype)
567 makevectors (self.v_angle);
569 source = self.origin + v_forward * 10; // FIXME
570 source_x = self.absmin_z + self.size_z * 0.7; // ??? whaddabout view_ofs
572 // LordHavoc: better to use normal damage
573 //ClearMultiDamage ();
574 while (shotcount > 0)
576 direction = dir + crandom () * spread_x * v_right + crandom () * spread_y * v_up;
578 traceline (source, source + direction * 2048, FALSE, self);
579 if (trace_fraction != 1.0)
581 vel = normalize (direction + v_up * crandom () + v_right * crandom ());
582 vel = vel + 2 * trace_plane_normal;
585 org = trace_endpos - direction * 4;
587 if (!trace_ent.takedamage)
589 // LordHavoc: better to use normal damage
590 //AddMultiDamage (trace_ent, 4, direction * 4);
591 Damage (trace_ent, self, self, 4, deathtype, trace_endpos, direction * 4);
594 shotcount = shotcount + 1;
597 // LordHavoc: better to use normal damage
598 //ApplyMultiDamage ();