2 float checkrules_firstblood;
6 void announce(entity player, string msg)
8 if(time > player.announcetime)
9 if(clienttype(player) == CLIENTTYPE_REAL)
11 player.announcetime = time + 0.3;
16 float IsDifferentTeam(entity a, entity b)
24 float IsFlying(entity a)
26 if(a.flags & FL_ONGROUND)
30 traceline(a.origin, a.origin - '0 0 48', MOVE_NORMAL, a);
31 if(trace_fraction < 1)
36 void(entity player, float f) UpdateFrags =
39 player.totalfrags += f;
42 void GiveFrags (entity attacker, entity targ, float f)
47 if(cvar("g_arena_roundbased"))
52 if(cvar("g_domination_disable_frags"))
59 f = RunematchHandleFrags(attacker, targ, f);
63 f = kh_HandleFrags(attacker, targ, f);
67 // count remaining lives, not frags in lms
69 // keep track of the worst players lives
70 if(targ.frags < lms_lowest_lives)
71 lms_lowest_lives = targ.frags;
72 // player has no more lives left
76 lms_next_place = player_count;
77 targ.frags = -lms_next_place;
84 UpdateFrags(attacker, f);
87 string AppendItemcodes(string s, entity player)
92 // w = player.switchweapon;
94 w = player.cnt; // previous weapon!
95 s = strcat(s, ftos(W_ItemCode(w)));
96 if(time < player.strength_finished)
98 if(time < player.invincible_finished)
100 if(player.flagcarried != world)
102 if(player.buttonchat)
107 s = strcat(s, "|", ftos(player.runes));
111 void LogDeath(string mode, float deathtype, entity killer, entity killed)
114 if(!cvar("sv_eventlog"))
116 s = strcat(":kill:", mode);
117 s = strcat(s, ":", ftos(killer.playerid));
118 s = strcat(s, ":", ftos(killed.playerid));
119 s = strcat(s, ":type=", ftos(deathtype));
120 s = strcat(s, ":items=");
121 s = AppendItemcodes(s, killer);
124 s = strcat(s, ":victimitems=");
125 s = AppendItemcodes(s, killed);
127 GameLogEcho(s, FALSE);
130 void Obituary (entity attacker, entity targ, float deathtype)
134 if (targ.classname == "player" || targ.classname == "corpse")
136 if (targ.classname == "corpse")
140 a = attacker.netname;
142 if (targ == attacker)
144 if (deathtype == DEATH_TEAMCHANGE)
146 centerprint(targ, strcat("You are now on: ", ColoredTeamName(targ.team)));
148 else if (deathtype == DEATH_AUTOTEAMCHANGE)
150 centerprint(targ, strcat("You have been moved into a different team to improve team balance\nYou are now on: ", ColoredTeamName(targ.team)));
153 else if (deathtype == DEATH_CAMP)
154 centerprint(targ, "^1Die camper!\n\n\n");
155 else if (deathtype == DEATH_NOAMMO)
156 centerprint(targ, "^1You were killed for running out of ammo...\n\n\n");
157 else if (deathtype == DEATH_ROT)
158 centerprint(targ, "^1You grew too old without taking your medicine\n\n\n");
159 else if (deathtype == DEATH_MIRRORDAMAGE)
160 centerprint(targ, "^1Don't shoot your team mates!\n\n\n");
162 centerprint(targ, "^1You killed your own dumb self!\n\n\n");
164 if (deathtype == IT_GRENADE_LAUNCHER)
165 bprint ("^1",s, "^1 detonated\n");
166 else if (deathtype == IT_ELECTRO)
167 bprint ("^1",s, "^1 played with plasma\n");
168 else if (deathtype == IT_ROCKET_LAUNCHER)
169 bprint ("^1",s, "^1 exploded\n");
170 else if (deathtype == DEATH_KILL)
171 bprint ("^1",s, "^1 couldn't take it anymore\n");
172 else if (deathtype == DEATH_ROT)
173 bprint ("^1",s, "^1 died\n");
174 else if (deathtype == DEATH_NOAMMO)
176 bprint ("^7",s, " ^7committed suicide. What's the point of living without ammo?\n");
177 //sound (self, CHAN_BODY, "minstagib/mockery.wav", 1, ATTN_NONE);
179 else if (deathtype == DEATH_CAMP)
180 bprint ("^1",s, "^1 thought he found a nice camping ground\n");
181 else if (deathtype == DEATH_MIRRORDAMAGE)
182 bprint ("^1",s, "^1 didn't become friends with the Lord of Teamplay\n");
183 else if (deathtype != DEATH_TEAMCHANGE)
184 bprint ("^1",s, "^1 couldn't resist the urge to self-destruct\n");
186 if(deathtype != DEATH_TEAMCHANGE)
188 LogDeath("suicide", deathtype, targ, targ);
189 GiveFrags(attacker, targ, -1);
191 if (targ.killcount > 2)
192 bprint ("^1",s,"^1 ended it all with a ",ftos(targ.killcount)," kill spree\n");
194 else if (attacker.classname == "player" || attacker.classname == "gib")
196 if(teamplay && attacker.team == targ.team)
198 centerprint(attacker, "^1Moron! You fragged a teammate!\n\n\n");
199 bprint ("^1", a, "^1 mows down a teammate\n");
200 GiveFrags(attacker, targ, -1);
201 if (targ.killcount > 2)
202 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," kill spree was ended by a teammate!\n");
203 if (attacker.killcount > 2)
204 bprint ("^1",a,"^1 ended a ",ftos(attacker.killcount)," kill spree by killing a teammate\n");
205 attacker.killcount = 0;
207 LogDeath("tk", deathtype, attacker, targ);
211 if (!checkrules_firstblood)
213 checkrules_firstblood = TRUE;
214 //sound(world, CHAN_AUTO, "announcer/firstblood.wav", 1, ATTN_NONE);
216 //sound(world, CHAN_AUTO, "announce/male/mapkill1.wav", 1, ATTN_NONE);
217 bprint("^1",a, "^1 drew first blood", "\n");
220 centerprint(attacker, strcat("^4You fragged ^7", s, "\n\n\n"));
221 centerprint(targ, strcat("^1You were fragged by ^7", a, "\n\n\n"));
223 if (deathtype == IT_LASER)
224 bprint ("^1",s, "^1 was blasted by ", a, "\n");
225 else if (deathtype == IT_UZI)
226 bprint ("^1",s, "^1 was riddled full of holes by ", a, "\n");
227 else if (deathtype == IT_SHOTGUN)
228 bprint ("^1",s, "^1 was gunned by ", a, "\n");
229 else if (deathtype == IT_GRENADE_LAUNCHER)
230 bprint ("^1", s, "^1 was blasted by ", a, "\n");
231 else if (deathtype == IT_ELECTRO)
232 bprint ("^1",s, "^1 was blasted by ", a, "\n");
233 else if (deathtype == IT_CRYLINK)
234 bprint ("^1",s, "^1 was blasted by ", a, "\n");
235 else if (deathtype == IT_NEX)
236 bprint ("^1",s, "^1 has been vaporized by ", a, "\n");
237 else if (deathtype == IT_HAGAR)
238 bprint ("^1",s, "^1 was pummeled by ", a, "\n");
239 else if (deathtype == IT_ROCKET_LAUNCHER)
240 bprint ("^1",s, "^1 was blasted by ", a, "\n");
241 else if (deathtype == DEATH_TELEFRAG)
242 bprint ("^1",s, "^1 was telefragged by ", a, "\n");
243 else if (deathtype == DEATH_DROWN)
244 bprint ("^1",s, "^1 was drowned by ", a, "\n");
245 else if (deathtype == DEATH_SLIME)
246 bprint ("^1",s, "^1 was slimed by ", a, "\n");
247 else if (deathtype == DEATH_LAVA)
248 bprint ("^1",s, "^1 was cooked by ", a, "\n");
249 else if (deathtype == DEATH_FALL)
250 bprint ("^1",s, "^1 was grounded by ", a, "\n");
251 else if (deathtype == DEATH_SHOOTING_STAR)
252 bprint ("^1",s, "^1 was shot into space by ", a, "\n");
253 else if (deathtype == DEATH_SWAMP)
254 bprint ("^1",s, "^1 was conserved by ", a, "\n");
255 else if (deathtype == DEATH_HURTTRIGGER)
256 bprint ("^1",s, "^1 was thrown into a world of hurt by ", a, "\n");
258 bprint ("^1",s, "^1 was fragged by ", a, "\n");
260 GiveFrags(attacker, targ, 1);
261 if (targ.killcount > 2)
262 bprint ("^1",s,"'s ^1", ftos(targ.killcount), " kill spree was ended by ", a, "\n");
263 attacker.killcount = attacker.killcount + 1;
264 if (attacker.killcount > 2)
265 bprint ("^1",a,"^1 has ",ftos(attacker.killcount)," frags in a row\n");
267 LogDeath("frag", deathtype, attacker, targ);
269 if (attacker.killcount == 3)
271 bprint (a,"^7 made a ^1TRIPLE FRAG\n");
272 announce(attacker, "announcer/male/03kills.ogg");
274 else if (attacker.killcount == 5)
276 bprint (a,"^7 made a ^1FIVE FRAG COMBO\n");
277 announce(attacker, "announcer/male/05kills.ogg");
279 else if (attacker.killcount == 10)
281 bprint (a,"^7 is on a ^1RAGE\n");
282 announce(attacker, "announcer/male/10kills.ogg");
284 else if (attacker.killcount == 15)
286 bprint (a,"^7 has done a ^1MASSACRE!\n");
287 announce(attacker, "announcer/male/15kills.ogg");
289 else if (attacker.killcount == 20)
291 bprint (a,"^7 is ^1UNHUMAN!\n");
292 announce(attacker, "announcer/male/20kills.ogg");
294 else if (attacker.killcount == 25)
296 bprint (a,"^7 is a ^1DEATH INCARNATION!\n");
297 announce(attacker, "announcer/male/25kills.ogg");
299 else if (attacker.killcount == 30)
301 bprint (a,"^7 is maybe a ^1AIMBOTTER?!\n");
302 announce(attacker, "announcer/male/30kills.ogg");
308 centerprint(targ, "^1Watch your step!\n\n\n");
309 if (deathtype == DEATH_HURTTRIGGER && attacker.message != "")
310 bprint ("^1",s, "^1 ", attacker.message, "\n");
311 else if (deathtype == DEATH_DROWN)
312 bprint ("^1",s, "^1 drowned\n");
313 else if (deathtype == DEATH_SLIME)
314 bprint ("^1",s, "^1 was slimed\n");
315 else if (deathtype == DEATH_LAVA)
316 bprint ("^1",s, "^1 turned into hot slag\n");
317 else if (deathtype == DEATH_FALL)
318 bprint ("^1",s, "^1 hit the ground with a crunch\n");
319 else if (deathtype == DEATH_SHOOTING_STAR)
320 bprint ("^1",s, "^1 became a shooting star\n");
321 else if (deathtype == DEATH_SWAMP)
322 bprint ("^1",s, "^1 is now conserved for centuries to come\n");
324 bprint ("^1",s, "^1 died\n");
325 GiveFrags(targ, targ, -1);
326 if(targ.frags == -5) {
327 announce(targ, "announcer/male/botlike.ogg");
330 if (targ.killcount > 2)
331 bprint ("^1",s,"^1 died with a ",ftos(targ.killcount)," kill spree\n");
333 LogDeath("accident", deathtype, targ, targ);
335 targ.death_origin = targ.origin;
337 targ.killer_origin = attacker.origin;
338 // FIXME: this should go in PutClientInServer
344 // these are updated by each Damage call for use in button triggering and such
346 entity damage_inflictor;
347 entity damage_attacker;
349 void Damage (entity targ, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
353 entity attacker_save;
357 if (gameover || targ.killcount == -666)
360 local entity oldself;
364 damage_inflictor = inflictor;
365 damage_attacker = attacker;
366 attacker_save = attacker;
368 if(deathtype == DEATH_KILL || deathtype == DEATH_TEAMCHANGE || deathtype == DEATH_AUTOTEAMCHANGE)
370 // These are ALWAYS lethal
371 // No damage modification here
372 // Instead, prepare the victim for his death...
374 targ.spawnshieldtime = 0;
376 targ.flags -= targ.flags & FL_GODMODE;
381 if (targ.classname == "player")
382 if (attacker.classname == "player")
385 damage = damage * bound(0.1, (skill + 5) * 0.1, 1);
387 // nullify damage if teamplay is on
388 if(deathtype != DEATH_TELEFRAG)
389 if(attacker.team == targ.team)
390 if(attacker.classname == "player")
394 else if(attacker != targ)
398 else if(teamplay == 4)
400 if(targ.classname == "player" && targ.deadflag == DEAD_NO)
402 mirrordamage = cvar("g_mirrordamage") * damage;
403 mirrorforce = cvar("g_mirrordamage") * vlen(force);
406 if(cvar("g_friendlyfire") == 0)
410 damage = cvar("g_friendlyfire") * damage;
411 // mirrordamage will be used LATER
420 if(targ.classname == "player")
421 if(attacker.classname == "player")
424 targ.lms_traveled_distance = cvar("g_lms_campcheck_distance");
425 attacker.lms_traveled_distance = cvar("g_lms_campcheck_distance");
431 if(targ.classname == "player")
433 attacker.hitsound += 1;
437 if ((deathtype == DEATH_FALL) ||
438 (deathtype == DEATH_DROWN) ||
439 (deathtype == DEATH_SLIME) ||
440 (deathtype == DEATH_LAVA))
442 if (targ.armorvalue && (deathtype == IT_NEX) && damage)
444 targ.armorvalue -= 1;
445 centerprint(targ, strcat("^3Remaining extra lives: ",ftos(targ.armorvalue),"\n"));
449 else if (deathtype == IT_NEX && targ.items & IT_STRENGTH)
451 if(clienttype(attacker) == CLIENTTYPE_REAL)
452 if(IsDifferentTeam(self, attacker))
455 if (deathtype == IT_LASER)
458 if (targ != attacker)
460 if (targ.classname == "player")
461 centerprint(attacker, "Secondary fire inflicts no damage!\n");
471 if(targ.takedamage == DAMAGE_AIM)
473 if(IsDifferentTeam(self, targ))
477 // apply strength multiplier
478 if (attacker.items & IT_STRENGTH && !g_minstagib)
480 damage = damage * cvar("g_balance_powerup_strength_damage");
481 force = force * cvar("g_balance_powerup_strength_force");
483 // apply invincibility multiplier
484 if (targ.items & IT_INVINCIBLE && !g_minstagib)
485 damage = damage * cvar("g_balance_powerup_invincible_takedamage");
490 // apply strength rune
491 if (attacker.runes & RUNE_STRENGTH)
493 if(attacker.runes & CURSE_WEAK) // have both curse & rune
495 damage = damage * cvar("g_balance_rune_strength_combo_damage");
496 force = force * cvar("g_balance_rune_strength_combo_force");
500 damage = damage * cvar("g_balance_rune_strength_damage");
501 force = force * cvar("g_balance_rune_strength_force");
504 else if (attacker.runes & CURSE_WEAK)
506 damage = damage * cvar("g_balance_curse_weak_damage");
507 force = force * cvar("g_balance_curse_weak_force");
510 // apply defense rune
511 if (targ.runes & RUNE_DEFENSE)
513 if (targ.runes & CURSE_VULNER) // have both curse & rune
514 damage = damage * cvar("g_balance_rune_defense_combo_takedamage");
516 damage = damage * cvar("g_balance_rune_defense_takedamage");
518 else if (targ.runes & CURSE_VULNER)
519 damage = damage * cvar("g_balance_curse_vulner_takedamage");
524 if (self.damageforcescale)
526 self.velocity = self.velocity + self.damageforcescale * force;
527 self.flags = self.flags - (self.flags & FL_ONGROUND);
530 if (self.event_damage)
531 self.event_damage (inflictor, attacker, damage, deathtype, hitloc, force);
534 if(targ.classname == "player" && attacker.classname == "player" && attacker != targ && attacker.health > 2)
536 // Savage: vampire mode
537 if(g_vampire && !g_minstagib)
539 attacker.health += damage;
543 if (attacker.runes & RUNE_VAMPIRE)
545 // apply vampire rune
546 if (attacker.runes & CURSE_EMPATHY) // have the curse too
548 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb");
549 attacker.health = bound(
550 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 40
551 attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb"),
552 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
556 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_absorb");
557 attacker.health = bound(
558 attacker.health, // LA: was 3, but changed so that you can't lose health
559 // empathy won't let you gain health in the same way...
560 attacker.health + damage * cvar("g_balance_rune_vampire_absorb"),
561 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
564 // apply empathy curse
565 else if (attacker.runes & CURSE_EMPATHY)
567 attacker.health = bound(
568 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 20
569 attacker.health + damage * cvar("g_balance_curse_empathy_takedamage"),
575 // apply mirror damage if any
576 if(mirrordamage > 0 || mirrorforce > 0)
578 attacker = attacker_save;
582 // just lose extra LIVES, don't kill the player for mirror damage
583 if(attacker.armorvalue > 0)
585 attacker.armorvalue = attacker.armorvalue - 1;
586 centerprint(attacker, strcat("^3Remaining extra lives: ",ftos(attacker.armorvalue),"\n"));
587 attacker.hitsound += 1;
591 force = normalize(attacker.origin + attacker.view_ofs - hitloc) * mirrorforce;
592 Damage(attacker, inflictor, attacker, mirrordamage, DEATH_MIRRORDAMAGE, attacker.origin, force);
596 float RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype)
597 // Returns total damage applies to creatures
609 float total_damage_to_creatures;
611 blastorigin = (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5);
612 total_damage_to_creatures = 0;
614 targ = findradius (blastorigin, rad);
617 if (targ != inflictor)
620 // LordHavoc: measure distance to nearest point on target (not origin)
621 // (this guarentees 100% damage on a touch impact)
622 nearest = blastorigin;
623 m1 = targ.origin + targ.mins;
624 m2 = targ.origin + targ.maxs;
625 if (nearest_x < m1_x) nearest_x = m1_x;
626 if (nearest_y < m1_y) nearest_y = m1_y;
627 if (nearest_z < m1_z) nearest_z = m1_z;
628 if (nearest_x > m2_x) nearest_x = m2_x;
629 if (nearest_y > m2_y) nearest_y = m2_y;
630 if (nearest_z > m2_z) nearest_z = m2_z;
631 diff = nearest - blastorigin;
632 // round up a little on the damage to ensure full damage on impacts
633 // and turn the distance into a fraction of the radius
634 power = 1 - ((vlen (diff) - 2) / rad);
636 //bprint(ftos(power));
641 finaldmg = coredamage * power + edgedamage * (1 - power);
644 center = (m1 + m2) * 0.5;
645 // if it's a player, use the view origin as reference
646 if (targ.classname == "player")
647 center = targ.origin + targ.view_ofs;
648 force = normalize(center - blastorigin) * (finaldmg / coredamage) * forceintensity;
649 if (targ == attacker)
650 finaldmg = finaldmg * cvar("g_balance_selfdamagepercent"); // Partial damage if the attacker hits himself
651 // test line of sight to multiple positions on box,
652 // and do damage if any of them hit
654 c = ceil(finaldmg / 10);
660 traceline(blastorigin, nearest, TRUE, inflictor);
661 if (trace_fraction == 1 || trace_ent == targ
662 || cvar("g_throughfloor"))
665 total_damage_to_creatures += finaldmg;
666 Damage (targ, inflictor, attacker, finaldmg, deathtype, nearest, force);
669 nearest_x = m1_x + random() * targ.size_x;
670 nearest_y = m1_y + random() * targ.size_y;
671 nearest_z = m1_z + random() * targ.size_z;
679 return total_damage_to_creatures;