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
27 attacker.frags = attacker.frags + f;
30 void LogDeath(string mode, float deathtype, entity killer, entity killed)
34 if(!cvar("sv_logspam_console"))
36 s = strcat(":kill:", mode);
37 s = strcat(s, ":", ftos(killer.playerid));
38 s = strcat(s, ":", ftos(killed.playerid));
39 s = strcat(s, ":type=", ftos(deathtype));
40 s = strcat(s, ":items=");
43 w = killer.switchweapon;
44 s = strcat(s, ftos(weapon_translateindextoflag(w)));
45 if(time < killer.strength_finished)
47 if(time < killer.invincible_finished)
49 if(killer.flagcarried != world)
51 s = strcat(s, ":victimitems=");
54 w = killed.switchweapon;
55 s = strcat(s, ftos(weapon_translateindextoflag(w)));
56 if(time < killed.strength_finished)
58 if(time < killed.invincible_finished)
60 if(killed.flagcarried != world)
65 void Obituary (entity attacker, entity targ, float deathtype)
69 if (targ.classname == "player" || targ.classname == "corpse")
71 if (targ.classname == "corpse")
78 if (deathtype == DEATH_NOAMMO)
79 centerprint(targ, strcat("^1You were killed for running out of ammo...\n\n\n"));
80 if (deathtype == DEATH_TEAMCHANGE)
82 m = "You are now on: ";
84 m = strcat(m, "^1Red Team");
85 else if (targ.team == 14)
86 m = strcat(m, "^4Blue Team");
87 else if (targ.team == 10)
88 m = strcat(m, "^6Pink Team");
89 else if (targ.team == 13)
90 m = strcat(m, "^3Yellow Team");
93 else if (deathtype == DEATH_AUTOTEAMCHANGE)
95 m = "You have been moved into a different team to improve team balance\nYou are now on: ";
97 m = strcat(m, "^1Red Team");
98 else if (targ.team == 14)
99 m = strcat(m, "^4Blue Team");
100 else if (targ.team == 10)
101 m = strcat(m, "^6Pink Team");
102 else if (targ.team == 13)
103 m = strcat(m, "^3Yellow Team");
104 centerprint(targ, m);
107 else if (deathtype == DEATH_CAMP)
108 centerprint(targ, strcat("^1Die camper!\n\n\n"));
110 centerprint(targ, strcat("^1You killed your own dumb self!\n\n\n"));
112 if (deathtype == IT_GRENADE_LAUNCHER)
113 bprint ("^1",s, "^1 detonated\n");
114 else if (deathtype == IT_ELECTRO)
115 bprint ("^1",s, "^1 played with plasma\n");
116 else if (deathtype == IT_ROCKET_LAUNCHER)
117 bprint ("^1",s, "^1 exploded\n");
118 else if (deathtype == DEATH_KILL)
119 bprint ("^1",s, "^1 couldn't take it anymore\n");
120 else if (deathtype == DEATH_NOAMMO)
122 bprint ("^7",s, " ^7committed suicide. What's the point of living without ammo?\n");
123 //sound (self, CHAN_BODY, "minstagib/mockery.ogg", 1, ATTN_NONE);
125 else if (deathtype == DEATH_CAMP)
126 bprint ("^1",s, "^1 thought he found a nice camping ground\n");
127 else if (deathtype != DEATH_TEAMCHANGE)
128 bprint ("^1",s, "^1 couldn't resist the urge to self-destruct\n");
130 if(deathtype != DEATH_TEAMCHANGE)
131 LogDeath("suicide", deathtype, targ, targ);
133 GiveFrags(attacker, targ, -1);
134 //targ.frags = targ.frags - 1;
135 if (targ.killcount > 2)
136 bprint ("^1",s,"^1 ended it all with a ",ftos(targ.killcount)," kill spree\n");
138 else if (teamplay && attacker.team == targ.team)
140 centerprint(attacker, strcat("^1Moron! You fragged a teammate!\n\n\n"));
141 bprint ("^1", attacker.netname, "^1 mows down a teammate\n");
142 GiveFrags(attacker, targ, -1);
143 //attacker.frags = attacker.frags - 1;
144 if (targ.killcount > 2)
145 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," kill spree was endeded by a teammate!\n");
146 if (attacker.killcount > 2)
147 bprint ("^1",attacker.netname,"^1 ended a ",ftos(attacker.killcount)," kill spree by killing a teammate\n");
148 attacker.killcount = 0;
150 LogDeath("tk", deathtype, attacker, targ);
152 else if (attacker.classname == "player" || attacker.classname == "gib")
154 if (!checkrules_firstblood)
156 checkrules_firstblood = TRUE;
157 //sound(world, CHAN_AUTO, "announcer/firstblood.wav", 1, ATTN_NONE);
158 //if (cvar("g_minstagib"))
159 //sound(world, CHAN_AUTO, "announce/male/mapkill1.ogg", 1, ATTN_NONE);
160 bprint("^1",attacker.netname, "^1 drew first blood", "\n");
163 centerprint(attacker, strcat("^4You fragged ^7", s, "\n\n\n"));
164 centerprint(targ, strcat("^1You were fragged by ^7", attacker.netname, "\n\n\n"));
166 if (deathtype == IT_LASER)
167 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
168 else if (deathtype == IT_UZI)
169 bprint ("^1",s, "^1 was riddled full of holes by ", attacker.netname, "\n");
170 else if (deathtype == IT_SHOTGUN)
171 bprint ("^1",s, "^1 was gunned by ", attacker.netname, "\n");
172 else if (deathtype == IT_GRENADE_LAUNCHER)
173 bprint ("^1", s, "^1 was blasted by ", attacker.netname, "\n");
174 else if (deathtype == IT_ELECTRO)
175 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
176 else if (deathtype == IT_CRYLINK)
177 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
178 else if (deathtype == IT_NEX)
179 bprint ("^1",s, "^1 has been vaporized by ", attacker.netname, "\n");
180 else if (deathtype == IT_HAGAR)
181 bprint ("^1",s, "^1 was pummeled by ", attacker.netname, "\n");
182 else if (deathtype == IT_ROCKET_LAUNCHER)
183 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
184 else if (deathtype == DEATH_TELEFRAG)
185 bprint ("^1",s, "^1 was telefragged by ", attacker.netname, "\n");
186 else if (deathtype == DEATH_DROWN)
187 bprint ("^1",s, "^1 was drowned by ", attacker.netname, "\n");
188 else if (deathtype == DEATH_SLIME)
189 bprint ("^1",s, "^1 was slimed by ", attacker.netname, "\n");
190 else if (deathtype == DEATH_LAVA)
191 bprint ("^1",s, "^1 was cooked by ", attacker.netname, "\n");
192 else if (deathtype == DEATH_FALL)
193 bprint ("^1",s, "^1 was grounded by ", attacker.netname, "\n");
194 else if (deathtype == DEATH_SWAMP)
195 bprint ("^1",s, "^1 was conserved by ", attacker.netname, "\n");
196 else if (deathtype == DEATH_HURTTRIGGER)
197 bprint ("^1",s, "^1 was thrown into a world of hurt by ", attacker.netname, "\n");
199 bprint ("^1",s, "^1 was fragged by ", attacker.netname, "\n");
201 GiveFrags(attacker, targ, 1);
202 //attacker.frags = attacker.frags + 1;
203 if (targ.killcount > 2)
204 bprint ("^1",s,"'s ^1", ftos(targ.killcount), " kill spree was ended by ", attacker.netname, "\n");
205 attacker.killcount = attacker.killcount + 1;
206 if (attacker.killcount > 2)
207 bprint ("^1",attacker.netname,"^1 has ",ftos(attacker.killcount)," frags in a row\n");
209 LogDeath("frag", deathtype, attacker, targ);
211 if (attacker.killcount == 3)
213 bprint (attacker.netname,"^7 made a ^1TRIPLE FRAG\n");
214 stuffcmd(attacker, "play2 announcer/male/03kills.ogg\n");
216 else if (attacker.killcount == 5)
218 bprint (attacker.netname,"^7 made a ^1FIVE FRAG COMBO\n");
219 stuffcmd(attacker, "play2 announcer/male/05kills.ogg\n");
221 else if (attacker.killcount == 10)
223 bprint (attacker.netname,"^7 is on a ^1RAGE\n");
224 stuffcmd(attacker, "play2 announcer/male/10kills.ogg\n");
226 else if (attacker.killcount == 15)
228 bprint (attacker.netname,"^7 has done a ^1MASSACRE!\n");
229 stuffcmd(attacker, "play2 announcer/male/15kills.ogg\n");
231 else if (attacker.killcount == 20)
233 bprint (attacker.netname,"^7 is ^1UNHUMAN!\n");
234 stuffcmd(attacker, "play2 announcer/male/20kills.ogg\n");
236 else if (attacker.killcount == 25)
238 bprint (attacker.netname,"^7 is a ^1DEATH INCARNATION!\n");
239 stuffcmd(attacker, "play2 announcer/male/25kills.ogg\n");
241 else if (attacker.killcount == 30)
243 bprint (attacker.netname,"^7 is maybe a ^1AIMBOTTER?!\n");
244 stuffcmd(attacker, "play2 announcer/male/30kills.ogg\n");
249 centerprint(targ, strcat("^1Watch your step!\n\n\n"));
250 if (deathtype == DEATH_HURTTRIGGER && attacker.message != "")
251 bprint ("^1",s, "^1 ", attacker.message, "\n");
252 else if (deathtype == DEATH_DROWN)
253 bprint ("^1",s, "^1 drowned\n");
254 else if (deathtype == DEATH_SLIME)
255 bprint ("^1",s, "^1 was slimed\n");
256 else if (deathtype == DEATH_LAVA)
257 bprint ("^1",s, "^1 turned into hot slag\n");
258 else if (deathtype == DEATH_FALL)
259 bprint ("^1",s, "^1 hit the ground with a crunch\n");
260 else if (deathtype == DEATH_SWAMP)
261 bprint ("^1",s, "^1 is now conserved for centuries to come\n");
263 bprint ("^1",s, "^1 died\n");
264 GiveFrags(targ, targ, -1);
265 if(targ.frags == -5) {
266 stuffcmd(targ, "play2 announcer/male/botlike.ogg\n");
269 //targ.frags = targ.frags - 1;
270 if (targ.killcount > 2)
271 bprint ("^1",s,"^1 died with a ",ftos(targ.killcount)," kill spree\n");
273 LogDeath("accident", deathtype, targ, targ);
275 // FIXME: this should go in PutClientInServer
281 // these are updated by each Damage call for use in button triggering and such
283 entity damage_inflictor;
284 entity damage_attacker;
286 void Damage (entity targ, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
288 if (gameover || targ.killcount == -666)
291 local entity oldself;
295 damage_inflictor = inflictor;
296 damage_attacker = attacker;
297 // nullify damage if teamplay is on
300 if (attacker.team == targ.team)
301 if ((teamplay == 1 || teamplay == 3) && attacker != targ)
305 if(targ.classname == "player")
306 if(attacker.classname == "player")
309 targ.lms_traveled_distance = cvar("g_lms_campcheck_distance");
310 attacker.lms_traveled_distance = cvar("g_lms_campcheck_distance");
313 if(damage > 0 && targ != attacker && clienttype(attacker) == CLIENTTYPE_REAL && targ.classname == "player")
314 stuffcmd(attacker, "play2 misc/hit.wav\n");
316 if (cvar("g_minstagib"))
318 if ((deathtype == DEATH_FALL) ||
319 (deathtype == DEATH_DROWN) ||
320 (deathtype == DEATH_SLIME) ||
321 (deathtype == DEATH_LAVA))
323 if (targ.extralives && (deathtype == IT_NEX) && damage)
325 targ.extralives -= 1;
326 centerprint(targ, strcat("^3Remaining extra lives: ",ftos(targ.extralives),"\n"));
328 targ.armorvalue = targ.extralives;
329 if(clienttype(targ) == CLIENTTYPE_REAL) stuffcmd(targ, "play2 misc/hit.wav\n");
330 //stuffcmd(attacker, "play2 misc/hit.wav\n");
332 else if (deathtype == IT_NEX && targ.items & IT_STRENGTH)
334 if(clienttype(attacker) == CLIENTTYPE_REAL) stuffcmd(attacker, "play2 announcer/male/yoda.ogg\n");
336 if (deathtype == IT_LASER)
339 if (targ != attacker)
341 if (targ.classname == "player")
342 centerprint(attacker, "Secondary fire inflicts no damage!\n");
349 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)
351 if(clienttype(attacker) == CLIENTTYPE_REAL) stuffcmd(attacker, "play2 announcer/male/yoda.ogg\n");
355 // apply strength multiplier
356 if (attacker.items & IT_STRENGTH && !cvar("g_minstagib"))
358 damage = damage * cvar("g_balance_powerup_strength_damage");
359 force = force * cvar("g_balance_powerup_strength_force");
361 // apply invincibility multiplier
362 if (targ.items & IT_INVINCIBLE && !cvar("g_minstagib"))
363 damage = damage * cvar("g_balance_powerup_invincible_takedamage");
366 if(cvar("g_runematch"))
368 // apply strength rune
369 if (attacker.runes & RUNE_STRENGTH)
371 if(attacker.runes & CURSE_WEAK) // have both curse & rune
373 damage = damage * cvar("g_balance_rune_strength_combo_damage");
374 force = force * cvar("g_balance_rune_strength_combo_force");
378 damage = damage * cvar("g_balance_rune_strength_damage");
379 force = force * cvar("g_balance_rune_strength_force");
382 else if (attacker.runes & CURSE_WEAK)
384 damage = damage * cvar("g_balance_curse_weak_damage");
385 force = force * cvar("g_balance_curse_weak_force");
388 // apply defense rune
389 if (targ.runes & RUNE_DEFENSE)
391 if (targ.runes & CURSE_VULNER) // have both curse & rune
392 damage = damage * cvar("g_balance_rune_defense_combo_takedamage");
394 damage = damage * cvar("g_balance_rune_defense_takedamage");
396 else if (targ.runes & CURSE_VULNER)
397 damage = damage * cvar("g_balance_curse_vulner_takedamage");
401 if (self.damageforcescale)
403 self.velocity = self.velocity + self.damageforcescale * force;
404 self.flags = self.flags - (self.flags & FL_ONGROUND);
407 if (self.event_damage)
408 self.event_damage (inflictor, attacker, damage, deathtype, hitloc, force);
411 if(targ.classname == "player" && attacker.classname == "player" && attacker != targ && attacker.health > 2)
413 // Savage: vampire mode
414 if(cvar("g_vampire") && !cvar("g_minstagib"))
416 attacker.health += damage;
418 if(cvar("g_runematch"))
420 if (attacker.runes & RUNE_VAMPIRE)
422 // apply vampire rune
423 if (attacker.runes & CURSE_EMPATHY) // have the curse too
425 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb");
426 attacker.health = bound(
427 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 40
428 attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb"),
429 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
433 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_absorb");
434 attacker.health = bound(
435 attacker.health, // LA: was 3, but changed so that you can't lose health
436 // empathy won't let you gain health in the same way...
437 attacker.health + damage * cvar("g_balance_rune_vampire_absorb"),
438 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
441 // apply empathy curse
442 else if (attacker.runes & CURSE_EMPATHY)
444 attacker.health = bound(
445 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 20
446 attacker.health + damage * cvar("g_balance_curse_empathy_takedamage"),
453 void RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype)
465 blastorigin = (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5);
467 targ = findradius (blastorigin, rad);
470 if (targ != inflictor)
473 // LordHavoc: measure distance to nearest point on target (not origin)
474 // (this guarentees 100% damage on a touch impact)
475 nearest = blastorigin;
476 m1 = targ.origin + targ.mins;
477 m2 = targ.origin + targ.maxs;
478 if (nearest_x < m1_x) nearest_x = m1_x;
479 if (nearest_y < m1_y) nearest_y = m1_y;
480 if (nearest_z < m1_z) nearest_z = m1_z;
481 if (nearest_x > m2_x) nearest_x = m2_x;
482 if (nearest_y > m2_y) nearest_y = m2_y;
483 if (nearest_z > m2_z) nearest_z = m2_z;
484 diff = nearest - blastorigin;
485 // round up a little on the damage to ensure full damage on impacts
486 // and turn the distance into a fraction of the radius
487 power = 1 - ((vlen (diff) - 2) / rad);
489 //bprint(ftos(power));
494 finaldmg = coredamage * power + edgedamage * (1 - power);
497 force = normalize((m1 + m2) * 0.5 - blastorigin) * (finaldmg / coredamage) * forceintensity;
498 if (targ == attacker)
499 finaldmg = finaldmg * cvar("g_balance_selfdamagepercent"); // Partial damage if the attacker hits himself
500 Damage (targ, inflictor, attacker, finaldmg, deathtype, nearest, force);
513 void ClearMultiDamage (void)
517 multi_force = '0 0 0';
520 void ApplyMultiDamage (void)
525 Damage (self, multi_ent.origin, multi_ent, 0, multi_damage, multi_force);
528 void AddMultiDamage (entity hit, float damage, vector force)
533 if (hit != multi_ent)
539 multi_damage = multi_damage + damage;
540 multi_force = multi_force + force;
543 void FireBullets (float shotcount, vector dir, vector spread, float deathtype)
550 makevectors (self.v_angle);
552 source = self.origin + v_forward * 10; // FIXME
553 source_x = self.absmin_z + self.size_z * 0.7; // ??? whaddabout view_ofs
555 // LordHavoc: better to use normal damage
556 //ClearMultiDamage ();
557 while (shotcount > 0)
559 direction = dir + crandom () * spread_x * v_right + crandom () * spread_y * v_up;
561 traceline (source, source + direction * 2048, FALSE, self);
562 if (trace_fraction != 1.0)
564 vel = normalize (direction + v_up * crandom () + v_right * crandom ());
565 vel = vel + 2 * trace_plane_normal;
568 org = trace_endpos - direction * 4;
570 if (!trace_ent.takedamage)
572 // LordHavoc: better to use normal damage
573 //AddMultiDamage (trace_ent, 4, direction * 4);
574 Damage (trace_ent, self, self, 4, deathtype, trace_endpos, direction * 4);
577 shotcount = shotcount + 1;
580 // LordHavoc: better to use normal damage
581 //ApplyMultiDamage ();