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"))
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)
53 s = strcat(s, ":victimitems=");
56 w = killed.switchweapon;
57 s = strcat(s, ftos(weapon_translateindextoflag(w)));
58 if(time < killed.strength_finished)
60 if(time < killed.invincible_finished)
62 if(killed.flagcarried != world)
65 GameLogEcho(s, FALSE);
68 void Obituary (entity attacker, entity targ, float deathtype)
72 if (targ.classname == "player" || targ.classname == "corpse")
74 if (targ.classname == "corpse")
81 if (deathtype == DEATH_NOAMMO)
82 centerprint(targ, strcat("^1You were killed for running out of ammo...\n\n\n"));
83 if (deathtype == DEATH_TEAMCHANGE)
85 m = "You are now on: ";
87 m = strcat(m, "^1Red Team");
88 else if (targ.team == 14)
89 m = strcat(m, "^4Blue Team");
90 else if (targ.team == 10)
91 m = strcat(m, "^6Pink Team");
92 else if (targ.team == 13)
93 m = strcat(m, "^3Yellow Team");
96 else if (deathtype == DEATH_AUTOTEAMCHANGE)
98 m = "You have been moved into a different team to improve team balance\nYou are now on: ";
100 m = strcat(m, "^1Red Team");
101 else if (targ.team == 14)
102 m = strcat(m, "^4Blue Team");
103 else if (targ.team == 10)
104 m = strcat(m, "^6Pink Team");
105 else if (targ.team == 13)
106 m = strcat(m, "^3Yellow Team");
107 centerprint(targ, m);
110 else if (deathtype == DEATH_CAMP)
111 centerprint(targ, strcat("^1Die camper!\n\n\n"));
113 centerprint(targ, strcat("^1You killed your own dumb self!\n\n\n"));
115 if (deathtype == IT_GRENADE_LAUNCHER)
116 bprint ("^1",s, "^1 detonated\n");
117 else if (deathtype == IT_ELECTRO)
118 bprint ("^1",s, "^1 played with plasma\n");
119 else if (deathtype == IT_ROCKET_LAUNCHER)
120 bprint ("^1",s, "^1 exploded\n");
121 else if (deathtype == DEATH_KILL)
122 bprint ("^1",s, "^1 couldn't take it anymore\n");
123 else if (deathtype == DEATH_NOAMMO)
125 bprint ("^7",s, " ^7committed suicide. What's the point of living without ammo?\n");
126 //sound (self, CHAN_BODY, "minstagib/mockery.ogg", 1, ATTN_NONE);
128 else if (deathtype == DEATH_CAMP)
129 bprint ("^1",s, "^1 thought he found a nice camping ground\n");
130 else if (deathtype != DEATH_TEAMCHANGE)
131 bprint ("^1",s, "^1 couldn't resist the urge to self-destruct\n");
133 if(deathtype != DEATH_TEAMCHANGE)
134 LogDeath("suicide", deathtype, targ, targ);
136 GiveFrags(attacker, targ, -1);
137 //targ.frags = targ.frags - 1;
138 if (targ.killcount > 2)
139 bprint ("^1",s,"^1 ended it all with a ",ftos(targ.killcount)," kill spree\n");
141 else if (teamplay && attacker.team == targ.team)
143 centerprint(attacker, strcat("^1Moron! You fragged a teammate!\n\n\n"));
144 bprint ("^1", attacker.netname, "^1 mows down a teammate\n");
145 GiveFrags(attacker, targ, -1);
146 //attacker.frags = attacker.frags - 1;
147 if (targ.killcount > 2)
148 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," kill spree was endeded by a teammate!\n");
149 if (attacker.killcount > 2)
150 bprint ("^1",attacker.netname,"^1 ended a ",ftos(attacker.killcount)," kill spree by killing a teammate\n");
151 attacker.killcount = 0;
153 LogDeath("tk", deathtype, attacker, targ);
155 else if (attacker.classname == "player" || attacker.classname == "gib")
157 if (!checkrules_firstblood)
159 checkrules_firstblood = TRUE;
160 //sound(world, CHAN_AUTO, "announcer/firstblood.wav", 1, ATTN_NONE);
161 //if (cvar("g_minstagib"))
162 //sound(world, CHAN_AUTO, "announce/male/mapkill1.ogg", 1, ATTN_NONE);
163 bprint("^1",attacker.netname, "^1 drew first blood", "\n");
166 centerprint(attacker, strcat("^4You fragged ^7", s, "\n\n\n"));
167 centerprint(targ, strcat("^1You were fragged by ^7", attacker.netname, "\n\n\n"));
169 if (deathtype == IT_LASER)
170 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
171 else if (deathtype == IT_UZI)
172 bprint ("^1",s, "^1 was riddled full of holes by ", attacker.netname, "\n");
173 else if (deathtype == IT_SHOTGUN)
174 bprint ("^1",s, "^1 was gunned by ", attacker.netname, "\n");
175 else if (deathtype == IT_GRENADE_LAUNCHER)
176 bprint ("^1", s, "^1 was blasted by ", attacker.netname, "\n");
177 else if (deathtype == IT_ELECTRO)
178 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
179 else if (deathtype == IT_CRYLINK)
180 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
181 else if (deathtype == IT_NEX)
182 bprint ("^1",s, "^1 has been vaporized by ", attacker.netname, "\n");
183 else if (deathtype == IT_HAGAR)
184 bprint ("^1",s, "^1 was pummeled by ", attacker.netname, "\n");
185 else if (deathtype == IT_ROCKET_LAUNCHER)
186 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
187 else if (deathtype == DEATH_TELEFRAG)
188 bprint ("^1",s, "^1 was telefragged by ", attacker.netname, "\n");
189 else if (deathtype == DEATH_DROWN)
190 bprint ("^1",s, "^1 was drowned by ", attacker.netname, "\n");
191 else if (deathtype == DEATH_SLIME)
192 bprint ("^1",s, "^1 was slimed by ", attacker.netname, "\n");
193 else if (deathtype == DEATH_LAVA)
194 bprint ("^1",s, "^1 was cooked by ", attacker.netname, "\n");
195 else if (deathtype == DEATH_FALL)
196 bprint ("^1",s, "^1 was grounded by ", attacker.netname, "\n");
197 else if (deathtype == DEATH_SWAMP)
198 bprint ("^1",s, "^1 was conserved by ", attacker.netname, "\n");
199 else if (deathtype == DEATH_HURTTRIGGER)
200 bprint ("^1",s, "^1 was thrown into a world of hurt by ", attacker.netname, "\n");
202 bprint ("^1",s, "^1 was fragged by ", attacker.netname, "\n");
204 GiveFrags(attacker, targ, 1);
205 //attacker.frags = attacker.frags + 1;
206 if (targ.killcount > 2)
207 bprint ("^1",s,"'s ^1", ftos(targ.killcount), " kill spree was ended by ", attacker.netname, "\n");
208 attacker.killcount = attacker.killcount + 1;
209 if (attacker.killcount > 2)
210 bprint ("^1",attacker.netname,"^1 has ",ftos(attacker.killcount)," frags in a row\n");
212 LogDeath("frag", deathtype, attacker, targ);
214 if (attacker.killcount == 3)
216 bprint (attacker.netname,"^7 made a ^1TRIPLE FRAG\n");
217 stuffcmd(attacker, "play2 announcer/male/03kills.ogg\n");
219 else if (attacker.killcount == 5)
221 bprint (attacker.netname,"^7 made a ^1FIVE FRAG COMBO\n");
222 stuffcmd(attacker, "play2 announcer/male/05kills.ogg\n");
224 else if (attacker.killcount == 10)
226 bprint (attacker.netname,"^7 is on a ^1RAGE\n");
227 stuffcmd(attacker, "play2 announcer/male/10kills.ogg\n");
229 else if (attacker.killcount == 15)
231 bprint (attacker.netname,"^7 has done a ^1MASSACRE!\n");
232 stuffcmd(attacker, "play2 announcer/male/15kills.ogg\n");
234 else if (attacker.killcount == 20)
236 bprint (attacker.netname,"^7 is ^1UNHUMAN!\n");
237 stuffcmd(attacker, "play2 announcer/male/20kills.ogg\n");
239 else if (attacker.killcount == 25)
241 bprint (attacker.netname,"^7 is a ^1DEATH INCARNATION!\n");
242 stuffcmd(attacker, "play2 announcer/male/25kills.ogg\n");
244 else if (attacker.killcount == 30)
246 bprint (attacker.netname,"^7 is maybe a ^1AIMBOTTER?!\n");
247 stuffcmd(attacker, "play2 announcer/male/30kills.ogg\n");
252 centerprint(targ, strcat("^1Watch your step!\n\n\n"));
253 if (deathtype == DEATH_HURTTRIGGER && attacker.message != "")
254 bprint ("^1",s, "^1 ", attacker.message, "\n");
255 else if (deathtype == DEATH_DROWN)
256 bprint ("^1",s, "^1 drowned\n");
257 else if (deathtype == DEATH_SLIME)
258 bprint ("^1",s, "^1 was slimed\n");
259 else if (deathtype == DEATH_LAVA)
260 bprint ("^1",s, "^1 turned into hot slag\n");
261 else if (deathtype == DEATH_FALL)
262 bprint ("^1",s, "^1 hit the ground with a crunch\n");
263 else if (deathtype == DEATH_SWAMP)
264 bprint ("^1",s, "^1 is now conserved for centuries to come\n");
266 bprint ("^1",s, "^1 died\n");
267 GiveFrags(targ, targ, -1);
268 if(targ.frags == -5) {
269 stuffcmd(targ, "play2 announcer/male/botlike.ogg\n");
272 //targ.frags = targ.frags - 1;
273 if (targ.killcount > 2)
274 bprint ("^1",s,"^1 died with a ",ftos(targ.killcount)," kill spree\n");
276 LogDeath("accident", deathtype, targ, targ);
278 // FIXME: this should go in PutClientInServer
284 // these are updated by each Damage call for use in button triggering and such
286 entity damage_inflictor;
287 entity damage_attacker;
289 void Damage (entity targ, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
291 if (gameover || targ.killcount == -666)
294 local entity oldself;
298 damage_inflictor = inflictor;
299 damage_attacker = attacker;
300 // nullify damage if teamplay is on
303 if (attacker.team == targ.team)
304 if ((teamplay == 1 || teamplay == 3) && attacker != targ)
308 if(targ.classname == "player")
309 if(attacker.classname == "player")
312 targ.lms_traveled_distance = cvar("g_lms_campcheck_distance");
313 attacker.lms_traveled_distance = cvar("g_lms_campcheck_distance");
316 if(damage > 0 && targ != attacker && clienttype(attacker) == CLIENTTYPE_REAL && targ.classname == "player")
317 stuffcmd(attacker, "play2 misc/hit.wav\n");
319 if (cvar("g_minstagib"))
321 if ((deathtype == DEATH_FALL) ||
322 (deathtype == DEATH_DROWN) ||
323 (deathtype == DEATH_SLIME) ||
324 (deathtype == DEATH_LAVA))
326 if (targ.extralives && (deathtype == IT_NEX) && damage)
328 targ.extralives -= 1;
329 centerprint(targ, strcat("^3Remaining extra lives: ",ftos(targ.extralives),"\n"));
331 targ.armorvalue = targ.extralives;
332 if(clienttype(targ) == CLIENTTYPE_REAL) stuffcmd(targ, "play2 misc/hit.wav\n");
333 //stuffcmd(attacker, "play2 misc/hit.wav\n");
335 else if (deathtype == IT_NEX && targ.items & IT_STRENGTH)
337 if(clienttype(attacker) == CLIENTTYPE_REAL) stuffcmd(attacker, "play2 announcer/male/yoda.ogg\n");
339 if (deathtype == IT_LASER)
342 if (targ != attacker)
344 if (targ.classname == "player")
345 centerprint(attacker, "Secondary fire inflicts no damage!\n");
352 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)
354 if(clienttype(attacker) == CLIENTTYPE_REAL) stuffcmd(attacker, "play2 announcer/male/yoda.ogg\n");
358 // apply strength multiplier
359 if (attacker.items & IT_STRENGTH && !cvar("g_minstagib"))
361 damage = damage * cvar("g_balance_powerup_strength_damage");
362 force = force * cvar("g_balance_powerup_strength_force");
364 // apply invincibility multiplier
365 if (targ.items & IT_INVINCIBLE && !cvar("g_minstagib"))
366 damage = damage * cvar("g_balance_powerup_invincible_takedamage");
369 if(cvar("g_runematch"))
371 // apply strength rune
372 if (attacker.runes & RUNE_STRENGTH)
374 if(attacker.runes & CURSE_WEAK) // have both curse & rune
376 damage = damage * cvar("g_balance_rune_strength_combo_damage");
377 force = force * cvar("g_balance_rune_strength_combo_force");
381 damage = damage * cvar("g_balance_rune_strength_damage");
382 force = force * cvar("g_balance_rune_strength_force");
385 else if (attacker.runes & CURSE_WEAK)
387 damage = damage * cvar("g_balance_curse_weak_damage");
388 force = force * cvar("g_balance_curse_weak_force");
391 // apply defense rune
392 if (targ.runes & RUNE_DEFENSE)
394 if (targ.runes & CURSE_VULNER) // have both curse & rune
395 damage = damage * cvar("g_balance_rune_defense_combo_takedamage");
397 damage = damage * cvar("g_balance_rune_defense_takedamage");
399 else if (targ.runes & CURSE_VULNER)
400 damage = damage * cvar("g_balance_curse_vulner_takedamage");
404 if (self.damageforcescale)
406 self.velocity = self.velocity + self.damageforcescale * force;
407 self.flags = self.flags - (self.flags & FL_ONGROUND);
410 if (self.event_damage)
411 self.event_damage (inflictor, attacker, damage, deathtype, hitloc, force);
414 if(targ.classname == "player" && attacker.classname == "player" && attacker != targ && attacker.health > 2)
416 // Savage: vampire mode
417 if(cvar("g_vampire") && !cvar("g_minstagib"))
419 attacker.health += damage;
421 if(cvar("g_runematch"))
423 if (attacker.runes & RUNE_VAMPIRE)
425 // apply vampire rune
426 if (attacker.runes & CURSE_EMPATHY) // have the curse too
428 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb");
429 attacker.health = bound(
430 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 40
431 attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb"),
432 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
436 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_absorb");
437 attacker.health = bound(
438 attacker.health, // LA: was 3, but changed so that you can't lose health
439 // empathy won't let you gain health in the same way...
440 attacker.health + damage * cvar("g_balance_rune_vampire_absorb"),
441 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
444 // apply empathy curse
445 else if (attacker.runes & CURSE_EMPATHY)
447 attacker.health = bound(
448 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 20
449 attacker.health + damage * cvar("g_balance_curse_empathy_takedamage"),
456 void RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype)
468 blastorigin = (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5);
470 targ = findradius (blastorigin, rad);
473 if (targ != inflictor)
476 // LordHavoc: measure distance to nearest point on target (not origin)
477 // (this guarentees 100% damage on a touch impact)
478 nearest = blastorigin;
479 m1 = targ.origin + targ.mins;
480 m2 = targ.origin + targ.maxs;
481 if (nearest_x < m1_x) nearest_x = m1_x;
482 if (nearest_y < m1_y) nearest_y = m1_y;
483 if (nearest_z < m1_z) nearest_z = m1_z;
484 if (nearest_x > m2_x) nearest_x = m2_x;
485 if (nearest_y > m2_y) nearest_y = m2_y;
486 if (nearest_z > m2_z) nearest_z = m2_z;
487 diff = nearest - blastorigin;
488 // round up a little on the damage to ensure full damage on impacts
489 // and turn the distance into a fraction of the radius
490 power = 1 - ((vlen (diff) - 2) / rad);
492 //bprint(ftos(power));
497 finaldmg = coredamage * power + edgedamage * (1 - power);
500 force = normalize((m1 + m2) * 0.5 - blastorigin) * (finaldmg / coredamage) * forceintensity;
501 if (targ == attacker)
502 finaldmg = finaldmg * cvar("g_balance_selfdamagepercent"); // Partial damage if the attacker hits himself
503 Damage (targ, inflictor, attacker, finaldmg, deathtype, nearest, force);
516 void ClearMultiDamage (void)
520 multi_force = '0 0 0';
523 void ApplyMultiDamage (void)
528 Damage (self, multi_ent.origin, multi_ent, 0, multi_damage, multi_force);
531 void AddMultiDamage (entity hit, float damage, vector force)
536 if (hit != multi_ent)
542 multi_damage = multi_damage + damage;
543 multi_force = multi_force + force;
546 void FireBullets (float shotcount, vector dir, vector spread, float deathtype)
553 makevectors (self.v_angle);
555 source = self.origin + v_forward * 10; // FIXME
556 source_x = self.absmin_z + self.size_z * 0.7; // ??? whaddabout view_ofs
558 // LordHavoc: better to use normal damage
559 //ClearMultiDamage ();
560 while (shotcount > 0)
562 direction = dir + crandom () * spread_x * v_right + crandom () * spread_y * v_up;
564 traceline (source, source + direction * 2048, FALSE, self);
565 if (trace_fraction != 1.0)
567 vel = normalize (direction + v_up * crandom () + v_right * crandom ());
568 vel = vel + 2 * trace_plane_normal;
571 org = trace_endpos - direction * 4;
573 if (!trace_ent.takedamage)
575 // LordHavoc: better to use normal damage
576 //AddMultiDamage (trace_ent, 4, direction * 4);
577 Damage (trace_ent, self, self, 4, deathtype, trace_endpos, direction * 4);
580 shotcount = shotcount + 1;
583 // LordHavoc: better to use normal damage
584 //ApplyMultiDamage ();