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 string AppendItemcodes(string s, entity player)
35 w = player.switchweapon;
37 w = player.cnt; // previous weapon!
38 s = strcat(s, ftos(weapon_translateindextoflag(w)));
39 if(time < player.strength_finished)
41 if(time < player.invincible_finished)
43 if(player.flagcarried != world)
46 s = strcat(s, "|", ftos(player.runes));
50 void LogDeath(string mode, float deathtype, entity killer, entity killed)
53 if(!cvar("sv_eventlog"))
55 s = strcat(":kill:", mode);
56 s = strcat(s, ":", ftos(killer.playerid));
57 s = strcat(s, ":", ftos(killed.playerid));
58 s = strcat(s, ":type=", ftos(deathtype));
59 s = strcat(s, ":items=");
60 s = AppendItemcodes(s, killer);
63 s = strcat(s, ":victimitems=");
64 s = AppendItemcodes(s, killed);
66 GameLogEcho(s, FALSE);
69 void Obituary (entity attacker, entity targ, float deathtype)
73 if (targ.classname == "player" || targ.classname == "corpse")
75 if (targ.classname == "corpse")
82 if (deathtype == DEATH_NOAMMO)
83 centerprint(targ, strcat("^1You were killed for running out of ammo...\n\n\n"));
84 if (deathtype == DEATH_TEAMCHANGE)
86 m = "You are now on: ";
88 m = strcat(m, "^1Red Team");
89 else if (targ.team == 14)
90 m = strcat(m, "^4Blue Team");
91 else if (targ.team == 10)
92 m = strcat(m, "^6Pink Team");
93 else if (targ.team == 13)
94 m = strcat(m, "^3Yellow Team");
97 else if (deathtype == DEATH_AUTOTEAMCHANGE)
99 m = "You have been moved into a different team to improve team balance\nYou are now on: ";
101 m = strcat(m, "^1Red Team");
102 else if (targ.team == 14)
103 m = strcat(m, "^4Blue Team");
104 else if (targ.team == 10)
105 m = strcat(m, "^6Pink Team");
106 else if (targ.team == 13)
107 m = strcat(m, "^3Yellow Team");
108 centerprint(targ, m);
111 else if (deathtype == DEATH_CAMP)
112 centerprint(targ, strcat("^1Die camper!\n\n\n"));
114 centerprint(targ, strcat("^1You killed your own dumb self!\n\n\n"));
116 if (deathtype == IT_GRENADE_LAUNCHER)
117 bprint ("^1",s, "^1 detonated\n");
118 else if (deathtype == IT_ELECTRO)
119 bprint ("^1",s, "^1 played with plasma\n");
120 else if (deathtype == IT_ROCKET_LAUNCHER)
121 bprint ("^1",s, "^1 exploded\n");
122 else if (deathtype == DEATH_KILL)
123 bprint ("^1",s, "^1 couldn't take it anymore\n");
124 else if (deathtype == DEATH_NOAMMO)
126 bprint ("^7",s, " ^7committed suicide. What's the point of living without ammo?\n");
127 //sound (self, CHAN_BODY, "minstagib/mockery.ogg", 1, ATTN_NONE);
129 else if (deathtype == DEATH_CAMP)
130 bprint ("^1",s, "^1 thought he found a nice camping ground\n");
131 else if (deathtype != DEATH_TEAMCHANGE)
132 bprint ("^1",s, "^1 couldn't resist the urge to self-destruct\n");
134 if(deathtype != DEATH_TEAMCHANGE)
135 LogDeath("suicide", deathtype, targ, targ);
137 GiveFrags(attacker, targ, -1);
138 //targ.frags = targ.frags - 1;
139 if (targ.killcount > 2)
140 bprint ("^1",s,"^1 ended it all with a ",ftos(targ.killcount)," kill spree\n");
142 else if (teamplay && attacker.team == targ.team)
144 centerprint(attacker, strcat("^1Moron! You fragged a teammate!\n\n\n"));
145 bprint ("^1", attacker.netname, "^1 mows down a teammate\n");
146 GiveFrags(attacker, targ, -1);
147 //attacker.frags = attacker.frags - 1;
148 if (targ.killcount > 2)
149 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," kill spree was endeded by a teammate!\n");
150 if (attacker.killcount > 2)
151 bprint ("^1",attacker.netname,"^1 ended a ",ftos(attacker.killcount)," kill spree by killing a teammate\n");
152 attacker.killcount = 0;
154 LogDeath("tk", deathtype, attacker, targ);
156 else if (attacker.classname == "player" || attacker.classname == "gib")
158 if (!checkrules_firstblood)
160 checkrules_firstblood = TRUE;
161 //sound(world, CHAN_AUTO, "announcer/firstblood.wav", 1, ATTN_NONE);
162 //if (cvar("g_minstagib"))
163 //sound(world, CHAN_AUTO, "announce/male/mapkill1.ogg", 1, ATTN_NONE);
164 bprint("^1",attacker.netname, "^1 drew first blood", "\n");
167 centerprint(attacker, strcat("^4You fragged ^7", s, "\n\n\n"));
168 centerprint(targ, strcat("^1You were fragged by ^7", attacker.netname, "\n\n\n"));
170 if (deathtype == IT_LASER)
171 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
172 else if (deathtype == IT_UZI)
173 bprint ("^1",s, "^1 was riddled full of holes by ", attacker.netname, "\n");
174 else if (deathtype == IT_SHOTGUN)
175 bprint ("^1",s, "^1 was gunned by ", attacker.netname, "\n");
176 else if (deathtype == IT_GRENADE_LAUNCHER)
177 bprint ("^1", s, "^1 was blasted by ", attacker.netname, "\n");
178 else if (deathtype == IT_ELECTRO)
179 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
180 else if (deathtype == IT_CRYLINK)
181 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
182 else if (deathtype == IT_NEX)
183 bprint ("^1",s, "^1 has been vaporized by ", attacker.netname, "\n");
184 else if (deathtype == IT_HAGAR)
185 bprint ("^1",s, "^1 was pummeled by ", attacker.netname, "\n");
186 else if (deathtype == IT_ROCKET_LAUNCHER)
187 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
188 else if (deathtype == DEATH_TELEFRAG)
189 bprint ("^1",s, "^1 was telefragged by ", attacker.netname, "\n");
190 else if (deathtype == DEATH_DROWN)
191 bprint ("^1",s, "^1 was drowned by ", attacker.netname, "\n");
192 else if (deathtype == DEATH_SLIME)
193 bprint ("^1",s, "^1 was slimed by ", attacker.netname, "\n");
194 else if (deathtype == DEATH_LAVA)
195 bprint ("^1",s, "^1 was cooked by ", attacker.netname, "\n");
196 else if (deathtype == DEATH_FALL)
197 bprint ("^1",s, "^1 was grounded by ", attacker.netname, "\n");
198 else if (deathtype == DEATH_SWAMP)
199 bprint ("^1",s, "^1 was conserved by ", attacker.netname, "\n");
200 else if (deathtype == DEATH_HURTTRIGGER)
201 bprint ("^1",s, "^1 was thrown into a world of hurt by ", attacker.netname, "\n");
203 bprint ("^1",s, "^1 was fragged by ", attacker.netname, "\n");
205 GiveFrags(attacker, targ, 1);
206 //attacker.frags = attacker.frags + 1;
207 if (targ.killcount > 2)
208 bprint ("^1",s,"'s ^1", ftos(targ.killcount), " kill spree was ended by ", attacker.netname, "\n");
209 attacker.killcount = attacker.killcount + 1;
210 if (attacker.killcount > 2)
211 bprint ("^1",attacker.netname,"^1 has ",ftos(attacker.killcount)," frags in a row\n");
213 LogDeath("frag", deathtype, attacker, targ);
215 if (attacker.killcount == 3)
217 bprint (attacker.netname,"^7 made a ^1TRIPLE FRAG\n");
218 stuffcmd(attacker, "play2 announcer/male/03kills.ogg\n");
220 else if (attacker.killcount == 5)
222 bprint (attacker.netname,"^7 made a ^1FIVE FRAG COMBO\n");
223 stuffcmd(attacker, "play2 announcer/male/05kills.ogg\n");
225 else if (attacker.killcount == 10)
227 bprint (attacker.netname,"^7 is on a ^1RAGE\n");
228 stuffcmd(attacker, "play2 announcer/male/10kills.ogg\n");
230 else if (attacker.killcount == 15)
232 bprint (attacker.netname,"^7 has done a ^1MASSACRE!\n");
233 stuffcmd(attacker, "play2 announcer/male/15kills.ogg\n");
235 else if (attacker.killcount == 20)
237 bprint (attacker.netname,"^7 is ^1UNHUMAN!\n");
238 stuffcmd(attacker, "play2 announcer/male/20kills.ogg\n");
240 else if (attacker.killcount == 25)
242 bprint (attacker.netname,"^7 is a ^1DEATH INCARNATION!\n");
243 stuffcmd(attacker, "play2 announcer/male/25kills.ogg\n");
245 else if (attacker.killcount == 30)
247 bprint (attacker.netname,"^7 is maybe a ^1AIMBOTTER?!\n");
248 stuffcmd(attacker, "play2 announcer/male/30kills.ogg\n");
253 centerprint(targ, strcat("^1Watch your step!\n\n\n"));
254 if (deathtype == DEATH_HURTTRIGGER && attacker.message != "")
255 bprint ("^1",s, "^1 ", attacker.message, "\n");
256 else if (deathtype == DEATH_DROWN)
257 bprint ("^1",s, "^1 drowned\n");
258 else if (deathtype == DEATH_SLIME)
259 bprint ("^1",s, "^1 was slimed\n");
260 else if (deathtype == DEATH_LAVA)
261 bprint ("^1",s, "^1 turned into hot slag\n");
262 else if (deathtype == DEATH_FALL)
263 bprint ("^1",s, "^1 hit the ground with a crunch\n");
264 else if (deathtype == DEATH_SWAMP)
265 bprint ("^1",s, "^1 is now conserved for centuries to come\n");
267 bprint ("^1",s, "^1 died\n");
268 GiveFrags(targ, targ, -1);
269 if(targ.frags == -5) {
270 stuffcmd(targ, "play2 announcer/male/botlike.ogg\n");
273 //targ.frags = targ.frags - 1;
274 if (targ.killcount > 2)
275 bprint ("^1",s,"^1 died with a ",ftos(targ.killcount)," kill spree\n");
277 LogDeath("accident", deathtype, targ, targ);
279 // FIXME: this should go in PutClientInServer
285 // these are updated by each Damage call for use in button triggering and such
287 entity damage_inflictor;
288 entity damage_attacker;
290 void Damage (entity targ, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
292 if (gameover || targ.killcount == -666)
295 local entity oldself;
299 damage_inflictor = inflictor;
300 damage_attacker = attacker;
301 // nullify damage if teamplay is on
304 if (attacker.team == targ.team)
305 if ((teamplay == 1 || teamplay == 3) && attacker != targ)
309 if(targ.classname == "player")
310 if(attacker.classname == "player")
313 targ.lms_traveled_distance = cvar("g_lms_campcheck_distance");
314 attacker.lms_traveled_distance = cvar("g_lms_campcheck_distance");
317 if(damage > 0 && targ != attacker && clienttype(attacker) == CLIENTTYPE_REAL && targ.classname == "player")
318 stuffcmd(attacker, "play2 misc/hit.wav\n");
320 if (cvar("g_minstagib"))
322 if ((deathtype == DEATH_FALL) ||
323 (deathtype == DEATH_DROWN) ||
324 (deathtype == DEATH_SLIME) ||
325 (deathtype == DEATH_LAVA))
327 if (targ.extralives && (deathtype == IT_NEX) && damage)
329 targ.extralives -= 1;
330 centerprint(targ, strcat("^3Remaining extra lives: ",ftos(targ.extralives),"\n"));
332 targ.armorvalue = targ.extralives;
333 if(clienttype(targ) == CLIENTTYPE_REAL) stuffcmd(targ, "play2 misc/hit.wav\n");
334 //stuffcmd(attacker, "play2 misc/hit.wav\n");
336 else if (deathtype == IT_NEX && targ.items & IT_STRENGTH)
338 if(clienttype(attacker) == CLIENTTYPE_REAL) stuffcmd(attacker, "play2 announcer/male/yoda.ogg\n");
340 if (deathtype == IT_LASER)
343 if (targ != attacker)
345 if (targ.classname == "player")
346 centerprint(attacker, "Secondary fire inflicts no damage!\n");
353 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)
355 if(clienttype(attacker) == CLIENTTYPE_REAL) stuffcmd(attacker, "play2 announcer/male/yoda.ogg\n");
359 // apply strength multiplier
360 if (attacker.items & IT_STRENGTH && !cvar("g_minstagib"))
362 damage = damage * cvar("g_balance_powerup_strength_damage");
363 force = force * cvar("g_balance_powerup_strength_force");
365 // apply invincibility multiplier
366 if (targ.items & IT_INVINCIBLE && !cvar("g_minstagib"))
367 damage = damage * cvar("g_balance_powerup_invincible_takedamage");
370 if(cvar("g_runematch"))
372 // apply strength rune
373 if (attacker.runes & RUNE_STRENGTH)
375 if(attacker.runes & CURSE_WEAK) // have both curse & rune
377 damage = damage * cvar("g_balance_rune_strength_combo_damage");
378 force = force * cvar("g_balance_rune_strength_combo_force");
382 damage = damage * cvar("g_balance_rune_strength_damage");
383 force = force * cvar("g_balance_rune_strength_force");
386 else if (attacker.runes & CURSE_WEAK)
388 damage = damage * cvar("g_balance_curse_weak_damage");
389 force = force * cvar("g_balance_curse_weak_force");
392 // apply defense rune
393 if (targ.runes & RUNE_DEFENSE)
395 if (targ.runes & CURSE_VULNER) // have both curse & rune
396 damage = damage * cvar("g_balance_rune_defense_combo_takedamage");
398 damage = damage * cvar("g_balance_rune_defense_takedamage");
400 else if (targ.runes & CURSE_VULNER)
401 damage = damage * cvar("g_balance_curse_vulner_takedamage");
405 if (self.damageforcescale)
407 self.velocity = self.velocity + self.damageforcescale * force;
408 self.flags = self.flags - (self.flags & FL_ONGROUND);
411 if (self.event_damage)
412 self.event_damage (inflictor, attacker, damage, deathtype, hitloc, force);
415 if(targ.classname == "player" && attacker.classname == "player" && attacker != targ && attacker.health > 2)
417 // Savage: vampire mode
418 if(cvar("g_vampire") && !cvar("g_minstagib"))
420 attacker.health += damage;
422 if(cvar("g_runematch"))
424 if (attacker.runes & RUNE_VAMPIRE)
426 // apply vampire rune
427 if (attacker.runes & CURSE_EMPATHY) // have the curse too
429 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb");
430 attacker.health = bound(
431 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 40
432 attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb"),
433 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
437 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_absorb");
438 attacker.health = bound(
439 attacker.health, // LA: was 3, but changed so that you can't lose health
440 // empathy won't let you gain health in the same way...
441 attacker.health + damage * cvar("g_balance_rune_vampire_absorb"),
442 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
445 // apply empathy curse
446 else if (attacker.runes & CURSE_EMPATHY)
448 attacker.health = bound(
449 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 20
450 attacker.health + damage * cvar("g_balance_curse_empathy_takedamage"),
457 void RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype)
469 blastorigin = (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5);
471 targ = findradius (blastorigin, rad);
474 if (targ != inflictor)
477 // LordHavoc: measure distance to nearest point on target (not origin)
478 // (this guarentees 100% damage on a touch impact)
479 nearest = blastorigin;
480 m1 = targ.origin + targ.mins;
481 m2 = targ.origin + targ.maxs;
482 if (nearest_x < m1_x) nearest_x = m1_x;
483 if (nearest_y < m1_y) nearest_y = m1_y;
484 if (nearest_z < m1_z) nearest_z = m1_z;
485 if (nearest_x > m2_x) nearest_x = m2_x;
486 if (nearest_y > m2_y) nearest_y = m2_y;
487 if (nearest_z > m2_z) nearest_z = m2_z;
488 diff = nearest - blastorigin;
489 // round up a little on the damage to ensure full damage on impacts
490 // and turn the distance into a fraction of the radius
491 power = 1 - ((vlen (diff) - 2) / rad);
493 //bprint(ftos(power));
498 finaldmg = coredamage * power + edgedamage * (1 - power);
501 force = normalize((m1 + m2) * 0.5 - blastorigin) * (finaldmg / coredamage) * forceintensity;
502 if (targ == attacker)
503 finaldmg = finaldmg * cvar("g_balance_selfdamagepercent"); // Partial damage if the attacker hits himself
504 Damage (targ, inflictor, attacker, finaldmg, deathtype, nearest, force);
517 void ClearMultiDamage (void)
521 multi_force = '0 0 0';
524 void ApplyMultiDamage (void)
529 Damage (self, multi_ent.origin, multi_ent, 0, multi_damage, multi_force);
532 void AddMultiDamage (entity hit, float damage, vector force)
537 if (hit != multi_ent)
543 multi_damage = multi_damage + damage;
544 multi_force = multi_force + force;
547 void FireBullets (float shotcount, vector dir, vector spread, float deathtype)
554 makevectors (self.v_angle);
556 source = self.origin + v_forward * 10; // FIXME
557 source_x = self.absmin_z + self.size_z * 0.7; // ??? whaddabout view_ofs
559 // LordHavoc: better to use normal damage
560 //ClearMultiDamage ();
561 while (shotcount > 0)
563 direction = dir + crandom () * spread_x * v_right + crandom () * spread_y * v_up;
565 traceline (source, source + direction * 2048, FALSE, self);
566 if (trace_fraction != 1.0)
568 vel = normalize (direction + v_up * crandom () + v_right * crandom ());
569 vel = vel + 2 * trace_plane_normal;
572 org = trace_endpos - direction * 4;
574 if (!trace_ent.takedamage)
576 // LordHavoc: better to use normal damage
577 //AddMultiDamage (trace_ent, 4, direction * 4);
578 Damage (trace_ent, self, self, 4, deathtype, trace_endpos, direction * 4);
581 shotcount = shotcount + 1;
584 // LordHavoc: better to use normal damage
585 //ApplyMultiDamage ();