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");
73 centerprint(targ, strcat("^1You killed your own dumb self!\n\n\n"));
75 if (deathtype == IT_GRENADE_LAUNCHER)
76 bprint ("^1",s, "^1 detonated\n");
77 else if (deathtype == IT_ELECTRO)
78 bprint ("^1",s, "^1 played with plasma\n");
79 else if (deathtype == IT_ROCKET_LAUNCHER)
80 bprint ("^1",s, "^1 exploded\n");
81 else if (deathtype == DEATH_KILL)
82 bprint ("^1",s, "^1 couldn't take it anymore\n");
83 else if (deathtype == DEATH_NOAMMO)
85 bprint ("^7",s, " ^7committed suicide. What's the point of living without ammo?\n");
86 //sound (self, CHAN_BODY, "minstagib/mockery.ogg", 1, ATTN_NONE);
88 else if (deathtype != DEATH_TEAMCHANGE)
89 bprint ("^1",s, "^1 couldn't resist the urge to self-destruct\n");
90 GiveFrags(attacker, targ, -1);
91 //targ.frags = targ.frags - 1;
92 if (targ.killcount > 2)
93 bprint ("^1",s,"^1 ended it all with a ",ftos(targ.killcount)," kill spree\n");
95 else if (teamplay && attacker.team == targ.team)
97 centerprint(attacker, strcat("^1Moron! You fragged a teammate!\n\n\n"));
98 bprint ("^1", attacker.netname, "^1 mows down a teammate\n");
99 GiveFrags(attacker, targ, -1);
100 //attacker.frags = attacker.frags - 1;
101 if (targ.killcount > 2)
102 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," kill spree was endeded by a teammate!\n");
103 if (attacker.killcount > 2)
104 bprint ("^1",attacker.netname,"^1 ended a ",ftos(attacker.killcount)," kill spree by killing a teammate\n");
105 attacker.killcount = 0;
107 else if (attacker.classname == "player" || attacker.classname == "gib")
109 if (!checkrules_firstblood)
111 checkrules_firstblood = TRUE;
112 //sound(world, CHAN_AUTO, "announcer/firstblood.wav", 1, ATTN_NONE);
113 //if (cvar("g_minstagib"))
114 //sound(world, CHAN_AUTO, "announce/male/mapkill1.ogg", 1, ATTN_NONE);
115 bprint("^1",attacker.netname, "^1 drew first blood", "\n");
118 centerprint(attacker, strcat("^4You fragged ^7", s, "\n\n\n"));
119 centerprint(targ, strcat("^1You were fragged by ^7", attacker.netname, "\n\n\n"));
121 if (deathtype == IT_LASER)
122 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
123 else if (deathtype == IT_UZI)
124 bprint ("^1",s, "^1 was riddled full of holes by ", attacker.netname, "\n");
125 else if (deathtype == IT_SHOTGUN)
126 bprint ("^1",s, "^1 was gunned by ", attacker.netname, "\n");
127 else if (deathtype == IT_GRENADE_LAUNCHER)
128 bprint ("^1", s, "^1 was blasted by ", attacker.netname, "\n");
129 else if (deathtype == IT_ELECTRO)
130 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
131 else if (deathtype == IT_CRYLINK)
132 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
133 else if (deathtype == IT_NEX)
134 bprint ("^1",s, "^1 has been vaporized by ", attacker.netname, "\n");
135 else if (deathtype == IT_HAGAR)
136 bprint ("^1",s, "^1 was pummeled by ", attacker.netname, "\n");
137 else if (deathtype == IT_ROCKET_LAUNCHER)
138 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
139 else if (deathtype == DEATH_TELEFRAG)
140 bprint ("^1",s, "^1 was telefragged by ", attacker.netname, "\n");
141 else if (deathtype == DEATH_DROWN)
142 bprint ("^1",s, "^1 was drowned by ", attacker.netname, "\n");
143 else if (deathtype == DEATH_SLIME)
144 bprint ("^1",s, "^1 was slimed by ", attacker.netname, "\n");
145 else if (deathtype == DEATH_LAVA)
146 bprint ("^1",s, "^1 was cooked by ", attacker.netname, "\n");
147 else if (deathtype == DEATH_FALL)
148 bprint ("^1",s, "^1 was grounded by ", attacker.netname, "\n");
149 else if (deathtype == DEATH_SWAMP)
150 bprint ("^1",s, "^1 was conserved by ", attacker.netname, "\n");
151 else if (deathtype == DEATH_HURTTRIGGER)
152 bprint ("^1",s, "^1 was thrown into a world of hurt by ", attacker.netname, "\n");
154 bprint ("^1",s, "^1 was fragged by ", attacker.netname, "\n");
156 GiveFrags(attacker, targ, 1);
157 //attacker.frags = attacker.frags + 1;
158 if (targ.killcount > 2)
159 bprint ("^1",s,"'s ^1", ftos(targ.killcount), " kill spree was ended by ", attacker.netname, "\n");
160 attacker.killcount = attacker.killcount + 1;
161 if (attacker.killcount > 2)
162 bprint ("^1",attacker.netname,"^1 has ",ftos(attacker.killcount)," frags in a row\n");
164 if (attacker.killcount == 3)
166 bprint (attacker.netname,"^7 made a ^1TRIPLE FRAG\n");
167 stuffcmd(attacker, "play2 announcer/male/03kills.ogg\n");
169 else if (attacker.killcount == 5)
171 bprint (attacker.netname,"^7 made a ^1FIVE FRAG COMBO\n");
172 stuffcmd(attacker, "play2 announcer/male/05kills.ogg\n");
174 else if (attacker.killcount == 10)
176 bprint (attacker.netname,"^7 is on a ^1RAGE\n");
177 stuffcmd(attacker, "play2 announcer/male/10kills.ogg\n");
179 else if (attacker.killcount == 15)
181 bprint (attacker.netname,"^7 has done a ^1MASSACRE!\n");
182 stuffcmd(attacker, "play2 announcer/male/15kills.ogg\n");
184 else if (attacker.killcount == 20)
186 bprint (attacker.netname,"^7 is ^1UNHUMAN!\n");
187 stuffcmd(attacker, "play2 announcer/male/20kills.ogg\n");
189 else if (attacker.killcount == 25)
191 bprint (attacker.netname,"^7 is a ^1DEATH INCARNATION!\n");
192 stuffcmd(attacker, "play2 announcer/male/25kills.ogg\n");
194 else if (attacker.killcount == 30)
196 bprint (attacker.netname,"^7 is maybe a ^1AIMBOTTER?!\n");
197 stuffcmd(attacker, "play2 announcer/male/30kills.ogg\n");
202 centerprint(targ, strcat("^1Watch your step!\n\n\n"));
203 if (deathtype == DEATH_HURTTRIGGER && attacker.message != "")
204 bprint ("^1",s, "^1 ", attacker.message, "\n");
205 else if (deathtype == DEATH_DROWN)
206 bprint ("^1",s, "^1 drowned\n");
207 else if (deathtype == DEATH_SLIME)
208 bprint ("^1",s, "^1 was slimed\n");
209 else if (deathtype == DEATH_LAVA)
210 bprint ("^1",s, "^1 turned into hot slag\n");
211 else if (deathtype == DEATH_FALL)
212 bprint ("^1",s, "^1 hit the ground with a crunch\n");
213 else if (deathtype == DEATH_SWAMP)
214 bprint ("^1",s, "^1 is now conserved for centuries to come\n");
216 bprint ("^1",s, "^1 died\n");
217 GiveFrags(targ, targ, -1);
218 if(targ.frags == -5) {
219 stuffcmd(targ, "play2 announcer/male/botlike.ogg\n");
222 //targ.frags = targ.frags - 1;
223 if (targ.killcount > 2)
224 bprint ("^1",s,"^1 died with a ",ftos(targ.killcount)," kill spree\n");
226 // FIXME: this should go in PutClientInServer
232 // these are updated by each Damage call for use in button triggering and such
234 entity damage_inflictor;
235 entity damage_attacker;
237 void Damage (entity targ, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
239 if (gameover || targ.killcount == -666)
242 local entity oldself;
246 damage_inflictor = inflictor;
247 damage_attacker = attacker;
248 // nullify damage if teamplay is on
251 if (attacker.team == targ.team)
252 if ((teamplay == 1 || teamplay == 3) && attacker != targ)
255 if(damage > 0 && targ != attacker && clienttype(attacker) == CLIENTTYPE_REAL && targ.classname == "player")
256 stuffcmd(attacker, "play2 misc/hit.wav\n");
258 if (cvar("g_minstagib"))
260 if ((deathtype == DEATH_FALL) ||
261 (deathtype == DEATH_DROWN) ||
262 (deathtype == DEATH_SLIME) ||
263 (deathtype == DEATH_LAVA))
265 if (targ.extralives && (deathtype == IT_NEX) && damage)
267 targ.extralives -= 1;
268 centerprint(targ, strcat("^3Remaining extra lives: ",ftos(targ.extralives),"\n"));
270 targ.armorvalue = targ.extralives;
271 if(clienttype(targ) == CLIENTTYPE_REAL) stuffcmd(targ, "play2 misc/hit.wav\n");
272 //stuffcmd(attacker, "play2 misc/hit.wav\n");
274 else if (deathtype == IT_NEX && targ.items & IT_STRENGTH)
276 if(clienttype(attacker) == CLIENTTYPE_REAL) stuffcmd(attacker, "play2 announcer/male/yoda.ogg\n");
278 if (deathtype == IT_LASER)
281 if (targ != attacker)
283 if (targ.classname == "player")
284 centerprint(attacker, "Secondary fire inflicts no damage!\n");
291 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)
293 if(clienttype(attacker) == CLIENTTYPE_REAL) stuffcmd(attacker, "play2 announcer/male/yoda.ogg\n");
297 // midair gamemode: damage only while in the air
299 && self.classname == "player" // e.g. grenades take damage
300 && self.flags & FL_ONGROUND) {
304 // apply strength multiplier
305 if (attacker.items & IT_STRENGTH && !cvar("g_minstagib"))
307 damage = damage * cvar("g_balance_powerup_strength_damage");
308 force = force * cvar("g_balance_powerup_strength_force");
310 // apply invincibility multiplier
311 if (targ.items & IT_INVINCIBLE && !cvar("g_minstagib"))
312 damage = damage * cvar("g_balance_powerup_invincible_takedamage");
315 if(cvar("g_runematch"))
317 // apply strength rune
318 if (attacker.runes & RUNE_STRENGTH)
320 if(attacker.runes & CURSE_WEAK) // have both curse & rune
322 damage = damage * cvar("g_balance_rune_strength_combo_damage");
323 force = force * cvar("g_balance_rune_strength_combo_force");
327 damage = damage * cvar("g_balance_rune_strength_damage");
328 force = force * cvar("g_balance_rune_strength_force");
331 else if (attacker.runes & CURSE_WEAK)
333 damage = damage * cvar("g_balance_curse_weak_damage");
334 force = force * cvar("g_balance_curse_weak_force");
337 // apply defense rune
338 if (targ.runes & RUNE_DEFENSE)
340 if (targ.runes & CURSE_VULNER) // have both curse & rune
341 damage = damage * cvar("g_balance_rune_defense_combo_takedamage");
343 damage = damage * cvar("g_balance_rune_defense_takedamage");
345 else if (targ.runes & CURSE_VULNER)
346 damage = damage * cvar("g_balance_curse_vulner_takedamage");
350 if (self.damageforcescale)
352 self.velocity = self.velocity + self.damageforcescale * force;
353 self.flags = self.flags - (self.flags & FL_ONGROUND);
356 if (self.event_damage)
357 self.event_damage (inflictor, attacker, damage, deathtype, hitloc, force);
360 if(targ.classname == "player" && attacker.classname == "player" && attacker != targ && attacker.health > 2)
362 // Savage: vampire mode
363 if(cvar("g_vampire") && !cvar("g_minstagib"))
365 attacker.health += damage;
367 if(cvar("g_runematch"))
369 if (attacker.runes & RUNE_VAMPIRE)
371 // apply vampire rune
372 if (attacker.runes & CURSE_EMPATHY) // have the curse too
374 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb");
375 attacker.health = bound(
376 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 40
377 attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb"),
378 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
382 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_absorb");
383 attacker.health = bound(
384 attacker.health, // LA: was 3, but changed so that you can't lose health
385 // empathy won't let you gain health in the same way...
386 attacker.health + damage * cvar("g_balance_rune_vampire_absorb"),
387 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
390 // apply empathy curse
391 else if (attacker.runes & CURSE_EMPATHY)
393 attacker.health = bound(
394 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 20
395 attacker.health + damage * cvar("g_balance_curse_empathy_takedamage"),
402 void RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype)
414 blastorigin = (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5);
416 targ = findradius (blastorigin, rad);
419 if (targ != inflictor)
422 // LordHavoc: measure distance to nearest point on target (not origin)
423 // (this guarentees 100% damage on a touch impact)
424 nearest = blastorigin;
425 m1 = targ.origin + targ.mins;
426 m2 = targ.origin + targ.maxs;
427 if (nearest_x < m1_x) nearest_x = m1_x;
428 if (nearest_y < m1_y) nearest_y = m1_y;
429 if (nearest_z < m1_z) nearest_z = m1_z;
430 if (nearest_x > m2_x) nearest_x = m2_x;
431 if (nearest_y > m2_y) nearest_y = m2_y;
432 if (nearest_z > m2_z) nearest_z = m2_z;
433 diff = nearest - blastorigin;
434 // round up a little on the damage to ensure full damage on impacts
435 // and turn the distance into a fraction of the radius
436 power = 1 - ((vlen (diff) - 2) / rad);
438 //bprint(ftos(power));
443 finaldmg = coredamage * power + edgedamage * (1 - power);
446 force = normalize((m1 + m2) * 0.5 - blastorigin) * (finaldmg / coredamage) * forceintensity;
447 if (targ == attacker)
448 finaldmg = finaldmg * cvar("g_balance_selfdamagepercent"); // Partial damage if the attacker hits himself
449 Damage (targ, inflictor, attacker, finaldmg, deathtype, inflictor.origin, force);
462 void ClearMultiDamage (void)
466 multi_force = '0 0 0';
469 void ApplyMultiDamage (void)
474 Damage (self, multi_ent.origin, multi_ent, 0, multi_damage, multi_force);
477 void AddMultiDamage (entity hit, float damage, vector force)
482 if (hit != multi_ent)
488 multi_damage = multi_damage + damage;
489 multi_force = multi_force + force;
492 void FireBullets (float shotcount, vector dir, vector spread, float deathtype)
499 makevectors (self.v_angle);
501 source = self.origin + v_forward * 10; // FIXME
502 source_x = self.absmin_z + self.size_z * 0.7; // ??? whaddabout view_ofs
504 // LordHavoc: better to use normal damage
505 //ClearMultiDamage ();
506 while (shotcount > 0)
508 direction = dir + crandom () * spread_x * v_right + crandom () * spread_y * v_up;
510 traceline (source, source + direction * 2048, FALSE, self);
511 if (trace_fraction != 1.0)
513 vel = normalize (direction + v_up * crandom () + v_right * crandom ());
514 vel = vel + 2 * trace_plane_normal;
517 org = trace_endpos - direction * 4;
519 if (!trace_ent.takedamage)
521 // LordHavoc: better to use normal damage
522 //AddMultiDamage (trace_ent, 4, direction * 4);
523 Damage (trace_ent, self, self, 4, deathtype, trace_endpos, direction * 4);
526 shotcount = shotcount + 1;
529 // LordHavoc: better to use normal damage
530 //ApplyMultiDamage ();