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 Obituary (entity attacker, entity targ, float deathtype)
34 if (targ.classname == "player" || targ.classname == "corpse")
36 if (targ.classname == "corpse")
43 if (deathtype == DEATH_NOAMMO)
44 centerprint(targ, strcat("^1You were killed for running out of ammo...\n\n\n"));
45 if (deathtype == DEATH_TEAMCHANGE)
47 m = "You are now on: ";
49 m = strcat(m, "^1Red Team");
50 else if (targ.team == 14)
51 m = strcat(m, "^4Blue Team");
52 else if (targ.team == 10)
53 m = strcat(m, "^6Pink Team");
54 else if (targ.team == 13)
55 m = strcat(m, "^3Yellow Team");
58 else if (deathtype == DEATH_AUTOTEAMCHANGE)
60 m = "You have been moved into a different team to improve team balance\nYou are now on: ";
62 m = strcat(m, "^1Red Team");
63 else if (targ.team == 14)
64 m = strcat(m, "^4Blue Team");
65 else if (targ.team == 10)
66 m = strcat(m, "^6Pink Team");
67 else if (targ.team == 13)
68 m = strcat(m, "^3Yellow Team");
72 else if (deathtype == DEATH_CAMP)
73 centerprint(targ, strcat("^1Die camper!\n\n\n"));
75 centerprint(targ, strcat("^1You killed your own dumb self!\n\n\n"));
77 if (deathtype == IT_GRENADE_LAUNCHER)
78 bprint ("^1",s, "^1 detonated\n");
79 else if (deathtype == IT_ELECTRO)
80 bprint ("^1",s, "^1 played with plasma\n");
81 else if (deathtype == IT_ROCKET_LAUNCHER)
82 bprint ("^1",s, "^1 exploded\n");
83 else if (deathtype == DEATH_KILL)
84 bprint ("^1",s, "^1 couldn't take it anymore\n");
85 else if (deathtype == DEATH_NOAMMO)
87 bprint ("^7",s, " ^7committed suicide. What's the point of living without ammo?\n");
88 //sound (self, CHAN_BODY, "minstagib/mockery.ogg", 1, ATTN_NONE);
90 else if (deathtype == DEATH_CAMP)
91 bprint ("^1",s, "^1 thought he found a nice camping ground\n");
92 else if (deathtype != DEATH_TEAMCHANGE)
93 bprint ("^1",s, "^1 couldn't resist the urge to self-destruct\n");
94 GiveFrags(attacker, targ, -1);
95 //targ.frags = targ.frags - 1;
96 if (targ.killcount > 2)
97 bprint ("^1",s,"^1 ended it all with a ",ftos(targ.killcount)," kill spree\n");
99 else if (teamplay && attacker.team == targ.team)
101 centerprint(attacker, strcat("^1Moron! You fragged a teammate!\n\n\n"));
102 bprint ("^1", attacker.netname, "^1 mows down a teammate\n");
103 GiveFrags(attacker, targ, -1);
104 //attacker.frags = attacker.frags - 1;
105 if (targ.killcount > 2)
106 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," kill spree was endeded by a teammate!\n");
107 if (attacker.killcount > 2)
108 bprint ("^1",attacker.netname,"^1 ended a ",ftos(attacker.killcount)," kill spree by killing a teammate\n");
109 attacker.killcount = 0;
111 else if (attacker.classname == "player" || attacker.classname == "gib")
113 if (!checkrules_firstblood)
115 checkrules_firstblood = TRUE;
116 //sound(world, CHAN_AUTO, "announcer/firstblood.wav", 1, ATTN_NONE);
117 //if (cvar("g_minstagib"))
118 //sound(world, CHAN_AUTO, "announce/male/mapkill1.ogg", 1, ATTN_NONE);
119 bprint("^1",attacker.netname, "^1 drew first blood", "\n");
122 centerprint(attacker, strcat("^4You fragged ^7", s, "\n\n\n"));
123 centerprint(targ, strcat("^1You were fragged by ^7", attacker.netname, "\n\n\n"));
125 if (deathtype == IT_LASER)
126 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
127 else if (deathtype == IT_UZI)
128 bprint ("^1",s, "^1 was riddled full of holes by ", attacker.netname, "\n");
129 else if (deathtype == IT_SHOTGUN)
130 bprint ("^1",s, "^1 was gunned by ", attacker.netname, "\n");
131 else if (deathtype == IT_GRENADE_LAUNCHER)
132 bprint ("^1", s, "^1 was blasted by ", attacker.netname, "\n");
133 else if (deathtype == IT_ELECTRO)
134 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
135 else if (deathtype == IT_CRYLINK)
136 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
137 else if (deathtype == IT_NEX)
138 bprint ("^1",s, "^1 has been vaporized by ", attacker.netname, "\n");
139 else if (deathtype == IT_HAGAR)
140 bprint ("^1",s, "^1 was pummeled by ", attacker.netname, "\n");
141 else if (deathtype == IT_ROCKET_LAUNCHER)
142 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
143 else if (deathtype == DEATH_TELEFRAG)
144 bprint ("^1",s, "^1 was telefragged by ", attacker.netname, "\n");
145 else if (deathtype == DEATH_DROWN)
146 bprint ("^1",s, "^1 was drowned by ", attacker.netname, "\n");
147 else if (deathtype == DEATH_SLIME)
148 bprint ("^1",s, "^1 was slimed by ", attacker.netname, "\n");
149 else if (deathtype == DEATH_LAVA)
150 bprint ("^1",s, "^1 was cooked by ", attacker.netname, "\n");
151 else if (deathtype == DEATH_FALL)
152 bprint ("^1",s, "^1 was grounded by ", attacker.netname, "\n");
153 else if (deathtype == DEATH_SWAMP)
154 bprint ("^1",s, "^1 was conserved by ", attacker.netname, "\n");
155 else if (deathtype == DEATH_HURTTRIGGER)
156 bprint ("^1",s, "^1 was thrown into a world of hurt by ", attacker.netname, "\n");
158 bprint ("^1",s, "^1 was fragged by ", attacker.netname, "\n");
160 GiveFrags(attacker, targ, 1);
161 //attacker.frags = attacker.frags + 1;
162 if (targ.killcount > 2)
163 bprint ("^1",s,"'s ^1", ftos(targ.killcount), " kill spree was ended by ", attacker.netname, "\n");
164 attacker.killcount = attacker.killcount + 1;
165 if (attacker.killcount > 2)
166 bprint ("^1",attacker.netname,"^1 has ",ftos(attacker.killcount)," frags in a row\n");
168 if (attacker.killcount == 3)
170 bprint (attacker.netname,"^7 made a ^1TRIPLE FRAG\n");
171 stuffcmd(attacker, "play2 announcer/male/03kills.ogg\n");
173 else if (attacker.killcount == 5)
175 bprint (attacker.netname,"^7 made a ^1FIVE FRAG COMBO\n");
176 stuffcmd(attacker, "play2 announcer/male/05kills.ogg\n");
178 else if (attacker.killcount == 10)
180 bprint (attacker.netname,"^7 is on a ^1RAGE\n");
181 stuffcmd(attacker, "play2 announcer/male/10kills.ogg\n");
183 else if (attacker.killcount == 15)
185 bprint (attacker.netname,"^7 has done a ^1MASSACRE!\n");
186 stuffcmd(attacker, "play2 announcer/male/15kills.ogg\n");
188 else if (attacker.killcount == 20)
190 bprint (attacker.netname,"^7 is ^1UNHUMAN!\n");
191 stuffcmd(attacker, "play2 announcer/male/20kills.ogg\n");
193 else if (attacker.killcount == 25)
195 bprint (attacker.netname,"^7 is a ^1DEATH INCARNATION!\n");
196 stuffcmd(attacker, "play2 announcer/male/25kills.ogg\n");
198 else if (attacker.killcount == 30)
200 bprint (attacker.netname,"^7 is maybe a ^1AIMBOTTER?!\n");
201 stuffcmd(attacker, "play2 announcer/male/30kills.ogg\n");
206 centerprint(targ, strcat("^1Watch your step!\n\n\n"));
207 if (deathtype == DEATH_HURTTRIGGER && attacker.message != "")
208 bprint ("^1",s, "^1 ", attacker.message, "\n");
209 else if (deathtype == DEATH_DROWN)
210 bprint ("^1",s, "^1 drowned\n");
211 else if (deathtype == DEATH_SLIME)
212 bprint ("^1",s, "^1 was slimed\n");
213 else if (deathtype == DEATH_LAVA)
214 bprint ("^1",s, "^1 turned into hot slag\n");
215 else if (deathtype == DEATH_FALL)
216 bprint ("^1",s, "^1 hit the ground with a crunch\n");
217 else if (deathtype == DEATH_SWAMP)
218 bprint ("^1",s, "^1 is now conserved for centuries to come\n");
220 bprint ("^1",s, "^1 died\n");
221 GiveFrags(targ, targ, -1);
222 if(targ.frags == -5) {
223 stuffcmd(targ, "play2 announcer/male/botlike.ogg\n");
226 //targ.frags = targ.frags - 1;
227 if (targ.killcount > 2)
228 bprint ("^1",s,"^1 died with a ",ftos(targ.killcount)," kill spree\n");
230 // FIXME: this should go in PutClientInServer
236 // these are updated by each Damage call for use in button triggering and such
238 entity damage_inflictor;
239 entity damage_attacker;
241 void Damage (entity targ, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
243 if (gameover || targ.killcount == -666)
246 local entity oldself;
250 damage_inflictor = inflictor;
251 damage_attacker = attacker;
252 // nullify damage if teamplay is on
255 if (attacker.team == targ.team)
256 if ((teamplay == 1 || teamplay == 3) && attacker != targ)
260 if(targ.classname == "player")
261 if(attacker.classname == "player")
264 targ.lms_traveled_distance = cvar("g_lms_campcheck_distance");
265 attacker.lms_traveled_distance = cvar("g_lms_campcheck_distance");
268 if(damage > 0 && targ != attacker && clienttype(attacker) == CLIENTTYPE_REAL && targ.classname == "player")
269 stuffcmd(attacker, "play2 misc/hit.wav\n");
271 if (cvar("g_minstagib"))
273 if ((deathtype == DEATH_FALL) ||
274 (deathtype == DEATH_DROWN) ||
275 (deathtype == DEATH_SLIME) ||
276 (deathtype == DEATH_LAVA))
278 if (targ.extralives && (deathtype == IT_NEX) && damage)
280 targ.extralives -= 1;
281 centerprint(targ, strcat("^3Remaining extra lives: ",ftos(targ.extralives),"\n"));
283 targ.armorvalue = targ.extralives;
284 if(clienttype(targ) == CLIENTTYPE_REAL) stuffcmd(targ, "play2 misc/hit.wav\n");
285 //stuffcmd(attacker, "play2 misc/hit.wav\n");
287 else if (deathtype == IT_NEX && targ.items & IT_STRENGTH)
289 if(clienttype(attacker) == CLIENTTYPE_REAL) stuffcmd(attacker, "play2 announcer/male/yoda.ogg\n");
291 if (deathtype == IT_LASER)
294 if (targ != attacker)
296 if (targ.classname == "player")
297 centerprint(attacker, "Secondary fire inflicts no damage!\n");
304 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)
306 if(clienttype(attacker) == CLIENTTYPE_REAL) stuffcmd(attacker, "play2 announcer/male/yoda.ogg\n");
310 // apply strength multiplier
311 if (attacker.items & IT_STRENGTH && !cvar("g_minstagib"))
313 damage = damage * cvar("g_balance_powerup_strength_damage");
314 force = force * cvar("g_balance_powerup_strength_force");
316 // apply invincibility multiplier
317 if (targ.items & IT_INVINCIBLE && !cvar("g_minstagib"))
318 damage = damage * cvar("g_balance_powerup_invincible_takedamage");
321 if(cvar("g_runematch"))
323 // apply strength rune
324 if (attacker.runes & RUNE_STRENGTH)
326 if(attacker.runes & CURSE_WEAK) // have both curse & rune
328 damage = damage * cvar("g_balance_rune_strength_combo_damage");
329 force = force * cvar("g_balance_rune_strength_combo_force");
333 damage = damage * cvar("g_balance_rune_strength_damage");
334 force = force * cvar("g_balance_rune_strength_force");
337 else if (attacker.runes & CURSE_WEAK)
339 damage = damage * cvar("g_balance_curse_weak_damage");
340 force = force * cvar("g_balance_curse_weak_force");
343 // apply defense rune
344 if (targ.runes & RUNE_DEFENSE)
346 if (targ.runes & CURSE_VULNER) // have both curse & rune
347 damage = damage * cvar("g_balance_rune_defense_combo_takedamage");
349 damage = damage * cvar("g_balance_rune_defense_takedamage");
351 else if (targ.runes & CURSE_VULNER)
352 damage = damage * cvar("g_balance_curse_vulner_takedamage");
356 if (self.damageforcescale)
358 self.velocity = self.velocity + self.damageforcescale * force;
359 self.flags = self.flags - (self.flags & FL_ONGROUND);
362 if (self.event_damage)
363 self.event_damage (inflictor, attacker, damage, deathtype, hitloc, force);
366 if(targ.classname == "player" && attacker.classname == "player" && attacker != targ && attacker.health > 2)
368 // Savage: vampire mode
369 if(cvar("g_vampire") && !cvar("g_minstagib"))
371 attacker.health += damage;
373 if(cvar("g_runematch"))
375 if (attacker.runes & RUNE_VAMPIRE)
377 // apply vampire rune
378 if (attacker.runes & CURSE_EMPATHY) // have the curse too
380 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb");
381 attacker.health = bound(
382 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 40
383 attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb"),
384 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
388 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_absorb");
389 attacker.health = bound(
390 attacker.health, // LA: was 3, but changed so that you can't lose health
391 // empathy won't let you gain health in the same way...
392 attacker.health + damage * cvar("g_balance_rune_vampire_absorb"),
393 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
396 // apply empathy curse
397 else if (attacker.runes & CURSE_EMPATHY)
399 attacker.health = bound(
400 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 20
401 attacker.health + damage * cvar("g_balance_curse_empathy_takedamage"),
408 void RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype)
420 blastorigin = (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5);
422 targ = findradius (blastorigin, rad);
425 if (targ != inflictor)
428 // LordHavoc: measure distance to nearest point on target (not origin)
429 // (this guarentees 100% damage on a touch impact)
430 nearest = blastorigin;
431 m1 = targ.origin + targ.mins;
432 m2 = targ.origin + targ.maxs;
433 if (nearest_x < m1_x) nearest_x = m1_x;
434 if (nearest_y < m1_y) nearest_y = m1_y;
435 if (nearest_z < m1_z) nearest_z = m1_z;
436 if (nearest_x > m2_x) nearest_x = m2_x;
437 if (nearest_y > m2_y) nearest_y = m2_y;
438 if (nearest_z > m2_z) nearest_z = m2_z;
439 diff = nearest - blastorigin;
440 // round up a little on the damage to ensure full damage on impacts
441 // and turn the distance into a fraction of the radius
442 power = 1 - ((vlen (diff) - 2) / rad);
444 //bprint(ftos(power));
449 finaldmg = coredamage * power + edgedamage * (1 - power);
452 force = normalize((m1 + m2) * 0.5 - blastorigin) * (finaldmg / coredamage) * forceintensity;
453 if (targ == attacker)
454 finaldmg = finaldmg * cvar("g_balance_selfdamagepercent"); // Partial damage if the attacker hits himself
455 Damage (targ, inflictor, attacker, finaldmg, deathtype, nearest, force);
468 void ClearMultiDamage (void)
472 multi_force = '0 0 0';
475 void ApplyMultiDamage (void)
480 Damage (self, multi_ent.origin, multi_ent, 0, multi_damage, multi_force);
483 void AddMultiDamage (entity hit, float damage, vector force)
488 if (hit != multi_ent)
494 multi_damage = multi_damage + damage;
495 multi_force = multi_force + force;
498 void FireBullets (float shotcount, vector dir, vector spread, float deathtype)
505 makevectors (self.v_angle);
507 source = self.origin + v_forward * 10; // FIXME
508 source_x = self.absmin_z + self.size_z * 0.7; // ??? whaddabout view_ofs
510 // LordHavoc: better to use normal damage
511 //ClearMultiDamage ();
512 while (shotcount > 0)
514 direction = dir + crandom () * spread_x * v_right + crandom () * spread_y * v_up;
516 traceline (source, source + direction * 2048, FALSE, self);
517 if (trace_fraction != 1.0)
519 vel = normalize (direction + v_up * crandom () + v_right * crandom ());
520 vel = vel + 2 * trace_plane_normal;
523 org = trace_endpos - direction * 4;
525 if (!trace_ent.takedamage)
527 // LordHavoc: better to use normal damage
528 //AddMultiDamage (trace_ent, 4, direction * 4);
529 Damage (trace_ent, self, self, 4, deathtype, trace_endpos, direction * 4);
532 shotcount = shotcount + 1;
535 // LordHavoc: better to use normal damage
536 //ApplyMultiDamage ();