2 float checkrules_firstblood;
4 void GiveFrags (entity attacker, entity targ, float f)
10 if(cvar("g_arena_roundbased"))
13 if(cvar("g_domination"))
14 if(cvar("g_domination_disable_frags"))
17 else if(f > 0 && cvar("g_runematch"))
18 f = RunematchHandleFrags(attacker, targ, f);
19 else if(cvar("g_lms"))
21 // count remaining lives, not frags in lms
23 // keep track of the worst players lives
24 if(targ.frags < lms_lowest_lives)
25 lms_lowest_lives = targ.frags;
26 // player has no more lives left
31 lms_next_place = player_count;
32 targ.frags = -lms_next_place;
39 attacker.frags = attacker.frags + f;
42 string AppendItemcodes(string s, entity player)
47 // w = player.switchweapon;
49 w = player.cnt; // previous weapon!
50 s = strcat(s, ftos(weapon_translateindextoflag(w)));
51 if(time < player.strength_finished)
53 if(time < player.invincible_finished)
55 if(player.flagcarried != world)
58 s = strcat(s, "|", ftos(player.runes));
62 void LogDeath(string mode, float deathtype, entity killer, entity killed)
65 if(!cvar("sv_eventlog"))
67 s = strcat(":kill:", mode);
68 s = strcat(s, ":", ftos(killer.playerid));
69 s = strcat(s, ":", ftos(killed.playerid));
70 s = strcat(s, ":type=", ftos(deathtype));
71 s = strcat(s, ":items=");
72 s = AppendItemcodes(s, killer);
75 s = strcat(s, ":victimitems=");
76 s = AppendItemcodes(s, killed);
78 GameLogEcho(s, FALSE);
81 void Obituary (entity attacker, entity targ, float deathtype)
85 if (targ.classname == "player" || targ.classname == "corpse")
87 if (targ.classname == "corpse")
94 if (deathtype == DEATH_NOAMMO)
95 centerprint(targ, strcat("^1You were killed for running out of ammo...\n\n\n"));
96 if (deathtype == DEATH_TEAMCHANGE)
98 m = "You 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);
109 else if (deathtype == DEATH_AUTOTEAMCHANGE)
111 m = "You have been moved into a different team to improve team balance\nYou are now on: ";
113 m = strcat(m, "^1Red Team");
114 else if (targ.team == 14)
115 m = strcat(m, "^4Blue Team");
116 else if (targ.team == 10)
117 m = strcat(m, "^6Pink Team");
118 else if (targ.team == 13)
119 m = strcat(m, "^3Yellow Team");
120 centerprint(targ, m);
123 else if (deathtype == DEATH_CAMP)
124 centerprint(targ, strcat("^1Die camper!\n\n\n"));
126 centerprint(targ, strcat("^1You killed your own dumb self!\n\n\n"));
128 if (deathtype == IT_GRENADE_LAUNCHER)
129 bprint ("^1",s, "^1 detonated\n");
130 else if (deathtype == IT_ELECTRO)
131 bprint ("^1",s, "^1 played with plasma\n");
132 else if (deathtype == IT_ROCKET_LAUNCHER)
133 bprint ("^1",s, "^1 exploded\n");
134 else if (deathtype == DEATH_KILL)
135 bprint ("^1",s, "^1 couldn't take it anymore\n");
136 else if (deathtype == DEATH_NOAMMO)
138 bprint ("^7",s, " ^7committed suicide. What's the point of living without ammo?\n");
139 //sound (self, CHAN_BODY, "minstagib/mockery.ogg", 1, ATTN_NONE);
141 else if (deathtype == DEATH_CAMP)
142 bprint ("^1",s, "^1 thought he found a nice camping ground\n");
143 else if (deathtype != DEATH_TEAMCHANGE)
144 bprint ("^1",s, "^1 couldn't resist the urge to self-destruct\n");
146 if(deathtype != DEATH_TEAMCHANGE)
147 LogDeath("suicide", deathtype, targ, targ);
149 GiveFrags(attacker, targ, -1);
150 //targ.frags = targ.frags - 1;
151 if (targ.killcount > 2)
152 bprint ("^1",s,"^1 ended it all with a ",ftos(targ.killcount)," kill spree\n");
154 else if (teamplay && attacker.team == targ.team)
156 centerprint(attacker, strcat("^1Moron! You fragged a teammate!\n\n\n"));
157 bprint ("^1", attacker.netname, "^1 mows down a teammate\n");
158 GiveFrags(attacker, targ, -1);
159 //attacker.frags = attacker.frags - 1;
160 if (targ.killcount > 2)
161 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," kill spree was endeded by a teammate!\n");
162 if (attacker.killcount > 2)
163 bprint ("^1",attacker.netname,"^1 ended a ",ftos(attacker.killcount)," kill spree by killing a teammate\n");
164 attacker.killcount = 0;
166 LogDeath("tk", deathtype, attacker, targ);
168 else if (attacker.classname == "player" || attacker.classname == "gib")
170 if (!checkrules_firstblood)
172 checkrules_firstblood = TRUE;
173 //sound(world, CHAN_AUTO, "announcer/firstblood.wav", 1, ATTN_NONE);
174 //if (cvar("g_minstagib"))
175 //sound(world, CHAN_AUTO, "announce/male/mapkill1.ogg", 1, ATTN_NONE);
176 bprint("^1",attacker.netname, "^1 drew first blood", "\n");
179 centerprint(attacker, strcat("^4You fragged ^7", s, "\n\n\n"));
180 centerprint(targ, strcat("^1You were fragged by ^7", attacker.netname, "\n\n\n"));
182 if (deathtype == IT_LASER)
183 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
184 else if (deathtype == IT_UZI)
185 bprint ("^1",s, "^1 was riddled full of holes by ", attacker.netname, "\n");
186 else if (deathtype == IT_SHOTGUN)
187 bprint ("^1",s, "^1 was gunned by ", attacker.netname, "\n");
188 else if (deathtype == IT_GRENADE_LAUNCHER)
189 bprint ("^1", s, "^1 was blasted by ", attacker.netname, "\n");
190 else if (deathtype == IT_ELECTRO)
191 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
192 else if (deathtype == IT_CRYLINK)
193 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
194 else if (deathtype == IT_NEX)
195 bprint ("^1",s, "^1 has been vaporized by ", attacker.netname, "\n");
196 else if (deathtype == IT_HAGAR)
197 bprint ("^1",s, "^1 was pummeled by ", attacker.netname, "\n");
198 else if (deathtype == IT_ROCKET_LAUNCHER)
199 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
200 else if (deathtype == DEATH_TELEFRAG)
201 bprint ("^1",s, "^1 was telefragged by ", attacker.netname, "\n");
202 else if (deathtype == DEATH_DROWN)
203 bprint ("^1",s, "^1 was drowned by ", attacker.netname, "\n");
204 else if (deathtype == DEATH_SLIME)
205 bprint ("^1",s, "^1 was slimed by ", attacker.netname, "\n");
206 else if (deathtype == DEATH_LAVA)
207 bprint ("^1",s, "^1 was cooked by ", attacker.netname, "\n");
208 else if (deathtype == DEATH_FALL)
209 bprint ("^1",s, "^1 was grounded by ", attacker.netname, "\n");
210 else if (deathtype == DEATH_SHOOTING_STAR)
211 bprint ("^1",s, "^1 was shot into space by ", attacker.netname, "\n");
212 else if (deathtype == DEATH_SWAMP)
213 bprint ("^1",s, "^1 was conserved by ", attacker.netname, "\n");
214 else if (deathtype == DEATH_HURTTRIGGER)
215 bprint ("^1",s, "^1 was thrown into a world of hurt by ", attacker.netname, "\n");
217 bprint ("^1",s, "^1 was fragged by ", attacker.netname, "\n");
219 GiveFrags(attacker, targ, 1);
220 //attacker.frags = attacker.frags + 1;
221 if (targ.killcount > 2)
222 bprint ("^1",s,"'s ^1", ftos(targ.killcount), " kill spree was ended by ", attacker.netname, "\n");
223 attacker.killcount = attacker.killcount + 1;
224 if (attacker.killcount > 2)
225 bprint ("^1",attacker.netname,"^1 has ",ftos(attacker.killcount)," frags in a row\n");
227 LogDeath("frag", deathtype, attacker, targ);
229 if (attacker.killcount == 3)
231 bprint (attacker.netname,"^7 made a ^1TRIPLE FRAG\n");
232 stuffcmd(attacker, "play2 announcer/male/03kills.ogg\n");
234 else if (attacker.killcount == 5)
236 bprint (attacker.netname,"^7 made a ^1FIVE FRAG COMBO\n");
237 stuffcmd(attacker, "play2 announcer/male/05kills.ogg\n");
239 else if (attacker.killcount == 10)
241 bprint (attacker.netname,"^7 is on a ^1RAGE\n");
242 stuffcmd(attacker, "play2 announcer/male/10kills.ogg\n");
244 else if (attacker.killcount == 15)
246 bprint (attacker.netname,"^7 has done a ^1MASSACRE!\n");
247 stuffcmd(attacker, "play2 announcer/male/15kills.ogg\n");
249 else if (attacker.killcount == 20)
251 bprint (attacker.netname,"^7 is ^1UNHUMAN!\n");
252 stuffcmd(attacker, "play2 announcer/male/20kills.ogg\n");
254 else if (attacker.killcount == 25)
256 bprint (attacker.netname,"^7 is a ^1DEATH INCARNATION!\n");
257 stuffcmd(attacker, "play2 announcer/male/25kills.ogg\n");
259 else if (attacker.killcount == 30)
261 bprint (attacker.netname,"^7 is maybe a ^1AIMBOTTER?!\n");
262 stuffcmd(attacker, "play2 announcer/male/30kills.ogg\n");
267 centerprint(targ, strcat("^1Watch your step!\n\n\n"));
268 if (deathtype == DEATH_HURTTRIGGER && attacker.message != "")
269 bprint ("^1",s, "^1 ", attacker.message, "\n");
270 else if (deathtype == DEATH_DROWN)
271 bprint ("^1",s, "^1 drowned\n");
272 else if (deathtype == DEATH_SLIME)
273 bprint ("^1",s, "^1 was slimed\n");
274 else if (deathtype == DEATH_LAVA)
275 bprint ("^1",s, "^1 turned into hot slag\n");
276 else if (deathtype == DEATH_FALL)
277 bprint ("^1",s, "^1 hit the ground with a crunch\n");
278 else if (deathtype == DEATH_SHOOTING_STAR)
279 bprint ("^1",s, "^1 became a shooting star\n");
280 else if (deathtype == DEATH_SWAMP)
281 bprint ("^1",s, "^1 is now conserved for centuries to come\n");
283 bprint ("^1",s, "^1 died\n");
284 GiveFrags(targ, targ, -1);
285 if(targ.frags == -5) {
286 stuffcmd(targ, "play2 announcer/male/botlike.ogg\n");
289 //targ.frags = targ.frags - 1;
290 if (targ.killcount > 2)
291 bprint ("^1",s,"^1 died with a ",ftos(targ.killcount)," kill spree\n");
293 LogDeath("accident", deathtype, targ, targ);
295 targ.death_origin = targ.origin;
297 targ.killer_origin = attacker.origin;
298 // FIXME: this should go in PutClientInServer
304 // these are updated by each Damage call for use in button triggering and such
306 entity damage_inflictor;
307 entity damage_attacker;
309 void Damage (entity targ, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
311 if (gameover || targ.killcount == -666)
314 local entity oldself;
318 damage_inflictor = inflictor;
319 damage_attacker = attacker;
320 // nullify damage if teamplay is on
323 if (attacker.team == targ.team)
324 if ((teamplay == 1 || teamplay == 3) && attacker != targ)
328 if(targ.classname == "player")
329 if(attacker.classname == "player")
332 targ.lms_traveled_distance = cvar("g_lms_campcheck_distance");
333 attacker.lms_traveled_distance = cvar("g_lms_campcheck_distance");
336 if(damage > 0 && targ != attacker && clienttype(attacker) == CLIENTTYPE_REAL && targ.classname == "player")
337 stuffcmd(attacker, "play2 misc/hit.wav\n");
339 if (cvar("g_minstagib"))
341 if ((deathtype == DEATH_FALL) ||
342 (deathtype == DEATH_DROWN) ||
343 (deathtype == DEATH_SLIME) ||
344 (deathtype == DEATH_LAVA))
346 if (targ.extralives && (deathtype == IT_NEX) && damage)
348 targ.extralives -= 1;
349 centerprint(targ, strcat("^3Remaining extra lives: ",ftos(targ.extralives),"\n"));
351 targ.armorvalue = targ.extralives;
352 if(clienttype(targ) == CLIENTTYPE_REAL) stuffcmd(targ, "play2 misc/hit.wav\n");
353 //stuffcmd(attacker, "play2 misc/hit.wav\n");
355 else if (deathtype == IT_NEX && targ.items & IT_STRENGTH)
357 if(clienttype(attacker) == CLIENTTYPE_REAL) stuffcmd(attacker, "play2 announcer/male/yoda.ogg\n");
359 if (deathtype == IT_LASER)
362 if (targ != attacker)
364 if (targ.classname == "player")
365 centerprint(attacker, "Secondary fire inflicts no damage!\n");
372 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)
374 if(clienttype(attacker) == CLIENTTYPE_REAL) stuffcmd(attacker, "play2 announcer/male/yoda.ogg\n");
378 // apply strength multiplier
379 if (attacker.items & IT_STRENGTH && !cvar("g_minstagib"))
381 damage = damage * cvar("g_balance_powerup_strength_damage");
382 force = force * cvar("g_balance_powerup_strength_force");
384 // apply invincibility multiplier
385 if (targ.items & IT_INVINCIBLE && !cvar("g_minstagib"))
386 damage = damage * cvar("g_balance_powerup_invincible_takedamage");
389 if(cvar("g_runematch"))
391 // apply strength rune
392 if (attacker.runes & RUNE_STRENGTH)
394 if(attacker.runes & CURSE_WEAK) // have both curse & rune
396 damage = damage * cvar("g_balance_rune_strength_combo_damage");
397 force = force * cvar("g_balance_rune_strength_combo_force");
401 damage = damage * cvar("g_balance_rune_strength_damage");
402 force = force * cvar("g_balance_rune_strength_force");
405 else if (attacker.runes & CURSE_WEAK)
407 damage = damage * cvar("g_balance_curse_weak_damage");
408 force = force * cvar("g_balance_curse_weak_force");
411 // apply defense rune
412 if (targ.runes & RUNE_DEFENSE)
414 if (targ.runes & CURSE_VULNER) // have both curse & rune
415 damage = damage * cvar("g_balance_rune_defense_combo_takedamage");
417 damage = damage * cvar("g_balance_rune_defense_takedamage");
419 else if (targ.runes & CURSE_VULNER)
420 damage = damage * cvar("g_balance_curse_vulner_takedamage");
424 if (self.damageforcescale)
426 self.velocity = self.velocity + self.damageforcescale * force;
427 self.flags = self.flags - (self.flags & FL_ONGROUND);
430 if (self.event_damage)
431 self.event_damage (inflictor, attacker, damage, deathtype, hitloc, force);
434 if(targ.classname == "player" && attacker.classname == "player" && attacker != targ && attacker.health > 2)
436 // Savage: vampire mode
437 if(cvar("g_vampire") && !cvar("g_minstagib"))
439 attacker.health += damage;
441 if(cvar("g_runematch"))
443 if (attacker.runes & RUNE_VAMPIRE)
445 // apply vampire rune
446 if (attacker.runes & CURSE_EMPATHY) // have the curse too
448 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb");
449 attacker.health = bound(
450 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 40
451 attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb"),
452 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
456 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_absorb");
457 attacker.health = bound(
458 attacker.health, // LA: was 3, but changed so that you can't lose health
459 // empathy won't let you gain health in the same way...
460 attacker.health + damage * cvar("g_balance_rune_vampire_absorb"),
461 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
464 // apply empathy curse
465 else if (attacker.runes & CURSE_EMPATHY)
467 attacker.health = bound(
468 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 20
469 attacker.health + damage * cvar("g_balance_curse_empathy_takedamage"),
476 void RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype)
488 blastorigin = (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5);
490 targ = findradius (blastorigin, rad);
493 if (targ != inflictor)
496 // LordHavoc: measure distance to nearest point on target (not origin)
497 // (this guarentees 100% damage on a touch impact)
498 nearest = blastorigin;
499 m1 = targ.origin + targ.mins;
500 m2 = targ.origin + targ.maxs;
501 if (nearest_x < m1_x) nearest_x = m1_x;
502 if (nearest_y < m1_y) nearest_y = m1_y;
503 if (nearest_z < m1_z) nearest_z = m1_z;
504 if (nearest_x > m2_x) nearest_x = m2_x;
505 if (nearest_y > m2_y) nearest_y = m2_y;
506 if (nearest_z > m2_z) nearest_z = m2_z;
507 diff = nearest - blastorigin;
508 // round up a little on the damage to ensure full damage on impacts
509 // and turn the distance into a fraction of the radius
510 power = 1 - ((vlen (diff) - 2) / rad);
512 //bprint(ftos(power));
517 finaldmg = coredamage * power + edgedamage * (1 - power);
520 force = normalize((m1 + m2) * 0.5 - blastorigin) * (finaldmg / coredamage) * forceintensity;
521 if (targ == attacker)
522 finaldmg = finaldmg * cvar("g_balance_selfdamagepercent"); // Partial damage if the attacker hits himself
523 Damage (targ, inflictor, attacker, finaldmg, deathtype, nearest, force);
536 void ClearMultiDamage (void)
540 multi_force = '0 0 0';
543 void ApplyMultiDamage (void)
548 Damage (self, multi_ent.origin, multi_ent, 0, multi_damage, multi_force);
551 void AddMultiDamage (entity hit, float damage, vector force)
556 if (hit != multi_ent)
562 multi_damage = multi_damage + damage;
563 multi_force = multi_force + force;
566 void FireBullets (float shotcount, vector dir, vector spread, float deathtype)
573 makevectors (self.v_angle);
575 source = self.origin + v_forward * 10; // FIXME
576 source_x = self.absmin_z + self.size_z * 0.7; // ??? whaddabout view_ofs
578 // LordHavoc: better to use normal damage
579 //ClearMultiDamage ();
580 while (shotcount > 0)
582 direction = dir + crandom () * spread_x * v_right + crandom () * spread_y * v_up;
584 traceline (source, source + direction * 2048, FALSE, self);
585 if (trace_fraction != 1.0)
587 vel = normalize (direction + v_up * crandom () + v_right * crandom ());
588 vel = vel + 2 * trace_plane_normal;
591 org = trace_endpos - direction * 4;
593 if (!trace_ent.takedamage)
595 // LordHavoc: better to use normal damage
596 //AddMultiDamage (trace_ent, 4, direction * 4);
597 Damage (trace_ent, self, self, 4, deathtype, trace_endpos, direction * 4);
600 shotcount = shotcount + 1;
603 // LordHavoc: better to use normal damage
604 //ApplyMultiDamage ();