2 float checkrules_firstblood;
4 void GiveFrags (entity attacker, entity targ, float f)
9 if(cvar("g_arena_roundbased"))
12 if(cvar("g_domination"))
14 if(cvar("g_domination_disable_frags"))
18 else if(cvar("g_runematch"))
21 f = RunematchHandleFrags(attacker, targ, f);
23 else if(cvar("g_lms"))
25 // count remaining lives, not frags in lms
27 // keep track of the worst players lives
28 if(targ.frags < lms_lowest_lives)
29 lms_lowest_lives = targ.frags;
30 // player has no more lives left
35 lms_next_place = player_count;
36 targ.frags = -lms_next_place;
43 attacker.frags = attacker.frags + f;
46 string AppendItemcodes(string s, entity player)
51 // w = player.switchweapon;
53 w = player.cnt; // previous weapon!
54 s = strcat(s, ftos(weapon_translateindextoflag(w)));
55 if(time < player.strength_finished)
57 if(time < player.invincible_finished)
59 if(player.flagcarried != world)
62 s = strcat(s, "|", ftos(player.runes));
66 void LogDeath(string mode, float deathtype, entity killer, entity killed)
69 if(!cvar("sv_eventlog"))
71 s = strcat(":kill:", mode);
72 s = strcat(s, ":", ftos(killer.playerid));
73 s = strcat(s, ":", ftos(killed.playerid));
74 s = strcat(s, ":type=", ftos(deathtype));
75 s = strcat(s, ":items=");
76 s = AppendItemcodes(s, killer);
79 s = strcat(s, ":victimitems=");
80 s = AppendItemcodes(s, killed);
82 GameLogEcho(s, FALSE);
85 void Obituary (entity attacker, entity targ, float deathtype)
89 if (targ.classname == "player" || targ.classname == "corpse")
91 if (targ.classname == "corpse")
98 if (deathtype == DEATH_TEAMCHANGE)
100 m = "You are now on: ";
102 m = strcat(m, "^1Red Team");
103 else if (targ.team == 14)
104 m = strcat(m, "^4Blue Team");
105 else if (targ.team == 10)
106 m = strcat(m, "^6Pink Team");
107 else if (targ.team == 13)
108 m = strcat(m, "^3Yellow Team");
109 centermsg_setfor(targ, CENTERMSG_TEAMCHANGE, m);
111 else if (deathtype == DEATH_AUTOTEAMCHANGE)
113 centermsg_setfor(targ, CENTERMSG_TEAMCHANGE, "You have been moved into a different team to improve team balance");
114 m = "You are now on: ";
116 m = strcat(m, "^1Red Team");
117 else if (targ.team == 14)
118 m = strcat(m, "^4Blue Team");
119 else if (targ.team == 10)
120 m = strcat(m, "^6Pink Team");
121 else if (targ.team == 13)
122 m = strcat(m, "^3Yellow Team");
123 centermsg_setfor(targ, CENTERMSG_TEAMCHANGE2, m);
126 else if (deathtype == DEATH_CAMP)
127 centermsg_setfor(targ, CENTERMSG_DEATH, "^1Die camper!");
128 else if (deathtype == DEATH_NOAMMO)
129 centermsg_setfor(targ, CENTERMSG_DEATH, "^1You were killed for running out of ammo...");
130 else if (deathtype == DEATH_ROT)
131 centermsg_setfor(targ, CENTERMSG_DEATH, "^1You grew too old without taking your medcine");
133 centermsg_setfor(targ, CENTERMSG_DEATH, "^1You killed your own dumb self!");
135 if (deathtype == IT_GRENADE_LAUNCHER)
136 bprint ("^1",s, "^1 detonated\n");
137 else if (deathtype == IT_ELECTRO)
138 bprint ("^1",s, "^1 played with plasma\n");
139 else if (deathtype == IT_ROCKET_LAUNCHER)
140 bprint ("^1",s, "^1 exploded\n");
141 else if (deathtype == DEATH_KILL)
142 bprint ("^1",s, "^1 couldn't take it anymore\n");
143 else if (deathtype == DEATH_ROT)
144 bprint ("^1",s, "^1 died\n");
145 else if (deathtype == DEATH_NOAMMO)
147 bprint ("^7",s, " ^7committed suicide. What's the point of living without ammo?\n");
148 //sound (self, CHAN_BODY, "minstagib/mockery.ogg", 1, ATTN_NONE);
150 else if (deathtype == DEATH_CAMP)
151 bprint ("^1",s, "^1 thought he found a nice camping ground\n");
152 else if (deathtype != DEATH_TEAMCHANGE)
153 bprint ("^1",s, "^1 couldn't resist the urge to self-destruct\n");
155 if(deathtype != DEATH_TEAMCHANGE)
156 LogDeath("suicide", deathtype, targ, targ);
158 GiveFrags(attacker, targ, -1);
159 //targ.frags = targ.frags - 1;
160 if (targ.killcount > 2)
161 bprint ("^1",s,"^1 ended it all with a ",ftos(targ.killcount)," kill spree\n");
163 else if (teamplay && attacker.team == targ.team)
165 centermsg_setfor(attacker, CENTERMSG_DEATH, "^1Moron! You fragged a teammate!");
166 bprint ("^1", attacker.netname, "^1 mows down a teammate\n");
167 GiveFrags(attacker, targ, -1);
168 //attacker.frags = attacker.frags - 1;
169 if (targ.killcount > 2)
170 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," kill spree was endeded by a teammate!\n");
171 if (attacker.killcount > 2)
172 bprint ("^1",attacker.netname,"^1 ended a ",ftos(attacker.killcount)," kill spree by killing a teammate\n");
173 attacker.killcount = 0;
175 LogDeath("tk", deathtype, attacker, targ);
177 else if (attacker.classname == "player" || attacker.classname == "gib")
179 if (!checkrules_firstblood)
181 checkrules_firstblood = TRUE;
182 //sound(world, CHAN_AUTO, "announcer/firstblood.wav", 1, ATTN_NONE);
183 //if (cvar("g_minstagib"))
184 //sound(world, CHAN_AUTO, "announce/male/mapkill1.ogg", 1, ATTN_NONE);
185 bprint("^1",attacker.netname, "^1 drew first blood", "\n");
188 centermsg_setfor(attacker, CENTERMSG_KILL, strcat("^4You fragged ^7", s));
189 centermsg_setfor(targ, CENTERMSG_DEATH, strcat("^1You were fragged by ^7", attacker.netname));
191 if (deathtype == IT_LASER)
192 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
193 else if (deathtype == IT_UZI)
194 bprint ("^1",s, "^1 was riddled full of holes by ", attacker.netname, "\n");
195 else if (deathtype == IT_SHOTGUN)
196 bprint ("^1",s, "^1 was gunned by ", attacker.netname, "\n");
197 else if (deathtype == IT_GRENADE_LAUNCHER)
198 bprint ("^1", s, "^1 was blasted by ", attacker.netname, "\n");
199 else if (deathtype == IT_ELECTRO)
200 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
201 else if (deathtype == IT_CRYLINK)
202 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
203 else if (deathtype == IT_NEX)
204 bprint ("^1",s, "^1 has been vaporized by ", attacker.netname, "\n");
205 else if (deathtype == IT_HAGAR)
206 bprint ("^1",s, "^1 was pummeled by ", attacker.netname, "\n");
207 else if (deathtype == IT_ROCKET_LAUNCHER)
208 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
209 else if (deathtype == DEATH_TELEFRAG)
210 bprint ("^1",s, "^1 was telefragged by ", attacker.netname, "\n");
211 else if (deathtype == DEATH_DROWN)
212 bprint ("^1",s, "^1 was drowned by ", attacker.netname, "\n");
213 else if (deathtype == DEATH_SLIME)
214 bprint ("^1",s, "^1 was slimed by ", attacker.netname, "\n");
215 else if (deathtype == DEATH_LAVA)
216 bprint ("^1",s, "^1 was cooked by ", attacker.netname, "\n");
217 else if (deathtype == DEATH_FALL)
218 bprint ("^1",s, "^1 was grounded by ", attacker.netname, "\n");
219 else if (deathtype == DEATH_SHOOTING_STAR)
220 bprint ("^1",s, "^1 was shot into space by ", attacker.netname, "\n");
221 else if (deathtype == DEATH_SWAMP)
222 bprint ("^1",s, "^1 was conserved by ", attacker.netname, "\n");
223 else if (deathtype == DEATH_HURTTRIGGER)
224 bprint ("^1",s, "^1 was thrown into a world of hurt by ", attacker.netname, "\n");
226 bprint ("^1",s, "^1 was fragged by ", attacker.netname, "\n");
228 GiveFrags(attacker, targ, 1);
229 //attacker.frags = attacker.frags + 1;
230 if (targ.killcount > 2)
231 bprint ("^1",s,"'s ^1", ftos(targ.killcount), " kill spree was ended by ", attacker.netname, "\n");
232 attacker.killcount = attacker.killcount + 1;
233 if (attacker.killcount > 2)
234 bprint ("^1",attacker.netname,"^1 has ",ftos(attacker.killcount)," frags in a row\n");
236 LogDeath("frag", deathtype, attacker, targ);
238 if (attacker.killcount == 3)
240 bprint (attacker.netname,"^7 made a ^1TRIPLE FRAG\n");
241 stuffcmd(attacker, "play2 announcer/male/03kills.ogg\n");
243 else if (attacker.killcount == 5)
245 bprint (attacker.netname,"^7 made a ^1FIVE FRAG COMBO\n");
246 stuffcmd(attacker, "play2 announcer/male/05kills.ogg\n");
248 else if (attacker.killcount == 10)
250 bprint (attacker.netname,"^7 is on a ^1RAGE\n");
251 stuffcmd(attacker, "play2 announcer/male/10kills.ogg\n");
253 else if (attacker.killcount == 15)
255 bprint (attacker.netname,"^7 has done a ^1MASSACRE!\n");
256 stuffcmd(attacker, "play2 announcer/male/15kills.ogg\n");
258 else if (attacker.killcount == 20)
260 bprint (attacker.netname,"^7 is ^1UNHUMAN!\n");
261 stuffcmd(attacker, "play2 announcer/male/20kills.ogg\n");
263 else if (attacker.killcount == 25)
265 bprint (attacker.netname,"^7 is a ^1DEATH INCARNATION!\n");
266 stuffcmd(attacker, "play2 announcer/male/25kills.ogg\n");
268 else if (attacker.killcount == 30)
270 bprint (attacker.netname,"^7 is maybe a ^1AIMBOTTER?!\n");
271 stuffcmd(attacker, "play2 announcer/male/30kills.ogg\n");
276 centermsg_setfor(targ, CENTERMSG_DEATH, "^1Watch your step!");
277 if (deathtype == DEATH_HURTTRIGGER && attacker.message != "")
278 bprint ("^1",s, "^1 ", attacker.message, "\n");
279 else if (deathtype == DEATH_DROWN)
280 bprint ("^1",s, "^1 drowned\n");
281 else if (deathtype == DEATH_SLIME)
282 bprint ("^1",s, "^1 was slimed\n");
283 else if (deathtype == DEATH_LAVA)
284 bprint ("^1",s, "^1 turned into hot slag\n");
285 else if (deathtype == DEATH_FALL)
286 bprint ("^1",s, "^1 hit the ground with a crunch\n");
287 else if (deathtype == DEATH_SHOOTING_STAR)
288 bprint ("^1",s, "^1 became a shooting star\n");
289 else if (deathtype == DEATH_SWAMP)
290 bprint ("^1",s, "^1 is now conserved for centuries to come\n");
292 bprint ("^1",s, "^1 died\n");
293 GiveFrags(targ, targ, -1);
294 if(targ.frags == -5) {
295 stuffcmd(targ, "play2 announcer/male/botlike.ogg\n");
298 //targ.frags = targ.frags - 1;
299 if (targ.killcount > 2)
300 bprint ("^1",s,"^1 died with a ",ftos(targ.killcount)," kill spree\n");
302 LogDeath("accident", deathtype, targ, targ);
304 targ.death_origin = targ.origin;
306 targ.killer_origin = attacker.origin;
307 // FIXME: this should go in PutClientInServer
313 // these are updated by each Damage call for use in button triggering and such
315 entity damage_inflictor;
316 entity damage_attacker;
318 void Damage (entity targ, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
320 if (gameover || targ.killcount == -666)
323 local entity oldself;
327 damage_inflictor = inflictor;
328 damage_attacker = attacker;
329 // nullify damage if teamplay is on
332 if (attacker.team == targ.team)
333 if (teamplay == 1 || (teamplay == 3 && attacker != targ))
336 if (targ.classname == "player")
337 if (attacker.classname == "player")
340 damage = damage * bound(0.1, (skill + 5) * 0.1, 1);
343 if(targ.classname == "player")
344 if(attacker.classname == "player")
347 targ.lms_traveled_distance = cvar("g_lms_campcheck_distance");
348 attacker.lms_traveled_distance = cvar("g_lms_campcheck_distance");
354 if(clienttype(attacker) == CLIENTTYPE_REAL)
355 if(targ.classname == "player")
356 stuffcmd(attacker, "play2 misc/hit.wav\n");
358 if (cvar("g_minstagib"))
360 if ((deathtype == DEATH_FALL) ||
361 (deathtype == DEATH_DROWN) ||
362 (deathtype == DEATH_SLIME) ||
363 (deathtype == DEATH_LAVA))
365 if (targ.extralives && (deathtype == IT_NEX) && damage)
367 targ.extralives -= 1;
368 centermsg_setfor(targ, CENTERMSG_MINSTAGIB, strcat("^3Remaining extra lives: ",ftos(targ.extralives)));
370 targ.armorvalue = targ.extralives;
371 if(clienttype(targ) == CLIENTTYPE_REAL) stuffcmd(targ, "play2 misc/hit.wav\n");
372 //stuffcmd(attacker, "play2 misc/hit.wav\n");
374 else if (deathtype == IT_NEX && targ.items & IT_STRENGTH)
376 if(clienttype(attacker) == CLIENTTYPE_REAL) stuffcmd(attacker, "play2 announcer/male/yoda.ogg\n");
378 if (deathtype == IT_LASER)
381 if (targ != attacker)
383 if (targ.classname == "player")
384 centermsg_setfor(attacker, CENTERMSG_MINSTAGIB, "Secondary fire inflicts no damage!\n");
391 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)
393 if(clienttype(attacker) == CLIENTTYPE_REAL) stuffcmd(attacker, "play2 announcer/male/yoda.ogg\n");
397 // apply strength multiplier
398 if (attacker.items & IT_STRENGTH && !cvar("g_minstagib"))
400 damage = damage * cvar("g_balance_powerup_strength_damage");
401 force = force * cvar("g_balance_powerup_strength_force");
403 // apply invincibility multiplier
404 if (targ.items & IT_INVINCIBLE && !cvar("g_minstagib"))
405 damage = damage * cvar("g_balance_powerup_invincible_takedamage");
408 if(cvar("g_runematch"))
410 // apply strength rune
411 if (attacker.runes & RUNE_STRENGTH)
413 if(attacker.runes & CURSE_WEAK) // have both curse & rune
415 damage = damage * cvar("g_balance_rune_strength_combo_damage");
416 force = force * cvar("g_balance_rune_strength_combo_force");
420 damage = damage * cvar("g_balance_rune_strength_damage");
421 force = force * cvar("g_balance_rune_strength_force");
424 else if (attacker.runes & CURSE_WEAK)
426 damage = damage * cvar("g_balance_curse_weak_damage");
427 force = force * cvar("g_balance_curse_weak_force");
430 // apply defense rune
431 if (targ.runes & RUNE_DEFENSE)
433 if (targ.runes & CURSE_VULNER) // have both curse & rune
434 damage = damage * cvar("g_balance_rune_defense_combo_takedamage");
436 damage = damage * cvar("g_balance_rune_defense_takedamage");
438 else if (targ.runes & CURSE_VULNER)
439 damage = damage * cvar("g_balance_curse_vulner_takedamage");
443 if (self.damageforcescale)
445 self.velocity = self.velocity + self.damageforcescale * force;
446 self.flags = self.flags - (self.flags & FL_ONGROUND);
449 if (self.event_damage)
450 self.event_damage (inflictor, attacker, damage, deathtype, hitloc, force);
453 if(targ.classname == "player" && attacker.classname == "player" && attacker != targ && attacker.health > 2)
455 // Savage: vampire mode
456 if(cvar("g_vampire") && !cvar("g_minstagib"))
458 attacker.health += damage;
460 if(cvar("g_runematch"))
462 if (attacker.runes & RUNE_VAMPIRE)
464 // apply vampire rune
465 if (attacker.runes & CURSE_EMPATHY) // have the curse too
467 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb");
468 attacker.health = bound(
469 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 40
470 attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb"),
471 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
475 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_absorb");
476 attacker.health = bound(
477 attacker.health, // LA: was 3, but changed so that you can't lose health
478 // empathy won't let you gain health in the same way...
479 attacker.health + damage * cvar("g_balance_rune_vampire_absorb"),
480 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
483 // apply empathy curse
484 else if (attacker.runes & CURSE_EMPATHY)
486 attacker.health = bound(
487 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 20
488 attacker.health + damage * cvar("g_balance_curse_empathy_takedamage"),
495 void RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype)
507 blastorigin = (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5);
509 targ = findradius (blastorigin, rad);
512 if (targ != inflictor)
515 // LordHavoc: measure distance to nearest point on target (not origin)
516 // (this guarentees 100% damage on a touch impact)
517 nearest = blastorigin;
518 m1 = targ.origin + targ.mins;
519 m2 = targ.origin + targ.maxs;
520 if (nearest_x < m1_x) nearest_x = m1_x;
521 if (nearest_y < m1_y) nearest_y = m1_y;
522 if (nearest_z < m1_z) nearest_z = m1_z;
523 if (nearest_x > m2_x) nearest_x = m2_x;
524 if (nearest_y > m2_y) nearest_y = m2_y;
525 if (nearest_z > m2_z) nearest_z = m2_z;
526 diff = nearest - blastorigin;
527 // round up a little on the damage to ensure full damage on impacts
528 // and turn the distance into a fraction of the radius
529 power = 1 - ((vlen (diff) - 2) / rad);
531 //bprint(ftos(power));
536 finaldmg = coredamage * power + edgedamage * (1 - power);
539 force = normalize((m1 + m2) * 0.5 - blastorigin) * (finaldmg / coredamage) * forceintensity;
540 if (targ == attacker)
541 finaldmg = finaldmg * cvar("g_balance_selfdamagepercent"); // Partial damage if the attacker hits himself
542 // test line of sight to multiple positions on box,
543 // and do damage if any of them hit
545 c = ceil(finaldmg / 10);
551 traceline(blastorigin, nearest, TRUE, inflictor);
552 if (trace_fraction == 1 || trace_ent == targ
553 || cvar("g_throughfloor"))
555 Damage (targ, inflictor, attacker, finaldmg, deathtype, nearest, force);
558 nearest_x = m1_x + random() * targ.size_x;
559 nearest_y = m1_y + random() * targ.size_y;
560 nearest_z = m1_z + random() * targ.size_z;
574 void ClearMultiDamage (void)
578 multi_force = '0 0 0';
581 void ApplyMultiDamage (void)
586 Damage (self, multi_ent.origin, multi_ent, 0, multi_damage, multi_force);
589 void AddMultiDamage (entity hit, float damage, vector force)
594 if (hit != multi_ent)
600 multi_damage = multi_damage + damage;
601 multi_force = multi_force + force;
604 void FireBullets (float shotcount, vector dir, vector spread, float deathtype)
611 makevectors (self.v_angle);
613 source = self.origin + v_forward * 10; // FIXME
614 source_x = self.absmin_z + self.size_z * 0.7; // ??? whaddabout view_ofs
616 // LordHavoc: better to use normal damage
617 //ClearMultiDamage ();
618 while (shotcount > 0)
620 direction = dir + crandom () * spread_x * v_right + crandom () * spread_y * v_up;
622 traceline (source, source + direction * 2048, FALSE, self);
623 if (trace_fraction != 1.0)
625 vel = normalize (direction + v_up * crandom () + v_right * crandom ());
626 vel = vel + 2 * trace_plane_normal;
629 org = trace_endpos - direction * 4;
631 if (!trace_ent.takedamage)
633 // LordHavoc: better to use normal damage
634 //AddMultiDamage (trace_ent, 4, direction * 4);
635 Damage (trace_ent, self, self, 4, deathtype, trace_endpos, direction * 4);
638 shotcount = shotcount + 1;
641 // LordHavoc: better to use normal damage
642 //ApplyMultiDamage ();