2 float checkrules_firstblood;
4 void GiveFrags (entity attacker, entity targ, float f)
6 if(f > 0 && cvar("g_domination") && cvar("g_domination_disable_frags"))
8 else if(f > 0 && cvar("g_runematch"))
9 f = RunematchHandleFrags(attacker, targ, f);
10 else if(cvar("g_lms"))
12 // count remaining lives, not frags in lms
14 // keep track of the worst players lives
15 if(targ.frags < lms_lowest_lives)
16 lms_lowest_lives = targ.frags;
17 // player has no more lives left
24 attacker.frags = attacker.frags + f;
27 void Obituary (entity attacker, entity targ, float deathtype)
31 if (targ.classname == "player" || targ.classname == "corpse")
33 if (targ.classname == "corpse")
40 if (deathtype == DEATH_NOAMMO)
41 centerprint(targ, strcat("^1You were killed for running out of ammo...\n\n\n"));
43 centerprint(targ, strcat("^1You killed your own dumb self!\n\n\n"));
45 if (deathtype == IT_GRENADE_LAUNCHER)
46 bprint ("^1",s, "^1 detonated\n");
47 else if (deathtype == IT_ELECTRO)
48 bprint ("^1",s, "^1 played with plasma\n");
49 else if (deathtype == IT_ROCKET_LAUNCHER)
50 bprint ("^1",s, "^1 exploded\n");
51 else if (deathtype == DEATH_KILL)
52 bprint ("^1",s, "^1 couldn't take it anymore\n");
53 else if (deathtype == DEATH_NOAMMO)
55 bprint ("^7",s, " ^7committed suicide. What's the point of living without ammo?\n");
56 sound (self, CHAN_BODY, "minstagib/mockery.ogg", 1, ATTN_NONE);
59 bprint ("^1",s, "^1 couldn't resist the urge to self-destruct\n");
60 GiveFrags(attacker, targ, -1);
61 //targ.frags = targ.frags - 1;
62 if (targ.killcount > 2)
63 bprint ("^1",s,"^1 ended it all with a ",ftos(targ.killcount)," kill spree\n");
65 else if (teamplay && attacker.team == targ.team)
67 centerprint(attacker, strcat("^1Moron! You killed a teammate!\n\n\n"));
68 bprint ("^1", attacker.netname, "^1 mows down a teammate\n");
69 GiveFrags(attacker, targ, -1);
70 //attacker.frags = attacker.frags - 1;
71 if (targ.killcount > 2)
72 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," kill spree was endeded by a teammate!\n");
73 if (attacker.killcount > 2)
74 bprint ("^1",attacker.netname,"^1 ended a ",ftos(attacker.killcount)," kill spree by killing a teammate\n");
75 attacker.killcount = 0;
77 else if (attacker.classname == "player" || attacker.classname == "gib")
79 if (!checkrules_firstblood)
81 checkrules_firstblood = TRUE;
82 //sound(world, CHAN_AUTO, "announcer/firstblood.wav", 1, ATTN_NONE);
83 if (cvar("g_minstagib"))
84 sound(world, CHAN_AUTO, "announce/male/mapkill1.ogg", 1, ATTN_NONE);
85 bprint("^1",attacker.netname, "^1 drew first blood", "\n");
88 centerprint(attacker, strcat("^4You killed ^7", s, "\n\n\n"));
89 centerprint(targ, strcat("^1You were killed by ^7", attacker.netname, "\n\n\n"));
91 if (deathtype == IT_LASER)
92 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
93 else if (deathtype == IT_UZI)
94 bprint ("^1",s, "^1 was riddled full of holes by ", attacker.netname, "\n");
95 else if (deathtype == IT_SHOTGUN)
96 bprint ("^1",s, "^1 was gunned by ", attacker.netname, "\n");
97 else if (deathtype == IT_GRENADE_LAUNCHER)
98 bprint ("^1", s, "^1 was blasted by ", attacker.netname, "\n");
99 else if (deathtype == IT_ELECTRO)
100 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
101 else if (deathtype == IT_CRYLINK)
102 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
103 else if (deathtype == IT_NEX)
104 bprint ("^1",s, "^1 has been vaporized by ", attacker.netname, "\n");
105 else if (deathtype == IT_HAGAR)
106 bprint ("^1",s, "^1 was pummeled by ", attacker.netname, "\n");
107 else if (deathtype == IT_ROCKET_LAUNCHER)
108 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
109 else if (deathtype == DEATH_TELEFRAG)
110 bprint ("^1",s, "^1 was telefragged by ", attacker.netname, "\n");
111 else if (deathtype == DEATH_DROWN)
112 bprint ("^1",s, "^1 was drowned by ", attacker.netname, "\n");
113 else if (deathtype == DEATH_SLIME)
114 bprint ("^1",s, "^1 was slimed by ", attacker.netname, "\n");
115 else if (deathtype == DEATH_LAVA)
116 bprint ("^1",s, "^1 was cooked by ", attacker.netname, "\n");
117 else if (deathtype == DEATH_FALL)
118 bprint ("^1",s, "^1 was grounded by ", attacker.netname, "\n");
119 else if (deathtype == DEATH_HURTTRIGGER)
120 bprint ("^1",s, "^1 was thrown into a world of hurt by ", attacker.netname, "\n");
122 bprint ("^1",s, "^1 was killed by ", attacker.netname, "\n");
124 GiveFrags(attacker, targ, 1);
125 //attacker.frags = attacker.frags + 1;
126 if (targ.killcount > 2)
127 bprint ("^1",s,"'s ^1", ftos(targ.killcount), " kill spree was ended by ", attacker.netname, "\n");
128 attacker.killcount = attacker.killcount + 1;
129 if (attacker.killcount > 2)
130 bprint ("^1",attacker.netname,"^1 has ",ftos(attacker.killcount)," kills in a row\n");
132 if (attacker.killcount == 3)
134 bprint (attacker.netname,"^7 made a ^1Multikill\n");
135 stuffcmd(attacker, "play2 announce/male/kill3.ogg\n");
137 else if (attacker.killcount == 4)
139 bprint (attacker.netname,"^7 made a ^1Ultrakill\n");
140 stuffcmd(attacker, "play2 announce/male/kill4.ogg\n");
142 else if (attacker.killcount == 5)
144 bprint (attacker.netname,"^7 made a ^1MONSTERKILL\n");
145 stuffcmd(attacker, "play2 announce/male/kill5.ogg\n");
147 else if (attacker.killcount == 6)
149 bprint (attacker.netname,"^7 is on a ^1Killingspree\n");
150 stuffcmd(attacker, "play2 announce/male/kill6.ogg\n");
152 else if (attacker.killcount == 10)
154 bprint (attacker.netname,"^7 is on a ^1Rampage\n");
155 sound(world, CHAN_AUTO, "announce/male/kill10.ogg", 1, ATTN_NONE);
157 else if (attacker.killcount == 15)
159 bprint (attacker.netname,"^7 is ^1Dominating\n");
160 sound(world, CHAN_AUTO, "announce/male/kill15.ogg", 1, ATTN_NONE);
162 else if (attacker.killcount == 20)
164 bprint (attacker.netname,"^7 is ^1Unstoppable\n");
165 sound(world, CHAN_AUTO, "announce/male/kill20.ogg", 1, ATTN_NONE);
167 else if (attacker.killcount == 25)
169 bprint (attacker.netname,"^7 is ^1Godlike\n");
170 sound(world, CHAN_AUTO, "announce/male/kill25.ogg", 1, ATTN_NONE);
172 else if (attacker.killcount >= 30)
174 bprint (attacker.netname,"^7 is ^1Cheating!!!\n");
175 sound(world, CHAN_AUTO, "announce/male/kill30.ogg", 1, ATTN_NONE);
181 centerprint(targ, strcat("^1Watch your step!\n\n\n"));
182 if (deathtype == DEATH_HURTTRIGGER && attacker.message != "")
183 bprint ("^1",s, "^1 ", attacker.message, "\n");
184 else if (deathtype == DEATH_DROWN)
185 bprint ("^1",s, "^1 drowned\n");
186 else if (deathtype == DEATH_SLIME)
187 bprint ("^1",s, "^1 was slimed\n");
188 else if (deathtype == DEATH_LAVA)
189 bprint ("^1",s, "^1 turned into hot slag\n");
190 else if (deathtype == DEATH_FALL)
191 bprint ("^1",s, "^1 hit the ground with a crunch\n");
193 bprint ("^1",s, "^1 died\n");
194 GiveFrags(targ, targ, -1);
195 //targ.frags = targ.frags - 1;
196 if (targ.killcount > 2)
197 bprint ("^1",s,"^1 died with a ",ftos(targ.killcount)," kill spree\n");
199 // FIXME: this should go in PutClientInServer
205 // these are updated by each Damage call for use in button triggering and such
207 entity damage_inflictor;
208 entity damage_attacker;
210 void Damage (entity targ, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
215 local entity oldself;
219 damage_inflictor = inflictor;
220 damage_attacker = attacker;
221 // nullify damage if teamplay is on
224 if (attacker.team == targ.team)
225 if (teamplay == 1 || (teamplay == 3 && attacker != targ))
228 if (cvar("g_minstagib"))
230 if ((deathtype == DEATH_FALL) ||
231 (deathtype == DEATH_DROWN) ||
232 (deathtype == DEATH_SLIME) ||
233 (deathtype == DEATH_LAVA))
235 if (targ.extralives && (deathtype == IT_NEX))
237 targ.extralives = targ.extralives - 1;
238 centerprint(targ, strcat("^3Remaining extra lives: ",ftos(targ.extralives),"\n"));
240 targ.armorvalue = targ.extralives;
241 stuffcmd(targ, "play2 misc/hit.wav\n");
242 stuffcmd(attacker, "play2 misc/hit.wav\n");
244 else if (deathtype == IT_NEX && targ.items & IT_STRENGTH)
246 stuffcmd(attacker, "play2 announce/male/lucky_shot.ogg\n");
248 if (deathtype == IT_LASER)
251 if (targ != attacker)
253 if (targ.classname == "player")
254 centerprint(attacker, "Secondary fire inflicts no damage!\n");
262 // midair gamemode: damage only while in the air
264 && self.classname == "player" // e.g. grenades take damage
265 && self.flags & FL_ONGROUND) {
269 // apply strength multiplier
270 if (attacker.items & IT_STRENGTH && !cvar("g_minstagib"))
272 damage = damage * cvar("g_balance_powerup_strength_damage");
273 force = force * cvar("g_balance_powerup_strength_force");
275 // apply invincibility multiplier
276 if (targ.items & IT_INVINCIBLE && !cvar("g_minstagib"))
277 damage = damage * cvar("g_balance_powerup_invincible_takedamage");
280 if(cvar("g_runematch"))
282 // apply strength rune
283 if (attacker.runes & RUNE_STRENGTH)
285 if(attacker.runes & CURSE_WEAK) // have both curse & rune
287 damage = damage * cvar("g_balance_rune_strength_combo_damage");
288 force = force * cvar("g_balance_rune_strength_combo_force");
292 damage = damage * cvar("g_balance_rune_strength_damage");
293 force = force * cvar("g_balance_rune_strength_force");
296 else if (attacker.runes & CURSE_WEAK)
298 damage = damage * cvar("g_balance_curse_weak_damage");
299 force = force * cvar("g_balance_curse_weak_force");
302 // apply defense rune
303 if (targ.runes & RUNE_DEFENSE)
305 if (targ.runes & CURSE_VULNER) // have both curse & rune
306 damage = damage * cvar("g_balance_rune_defense_combo_takedamage");
308 damage = damage * cvar("g_balance_rune_defense_takedamage");
310 else if (targ.runes & CURSE_VULNER)
311 damage = damage * cvar("g_balance_curse_vulner_takedamage");
315 if (self.damageforcescale)
317 self.velocity = self.velocity + self.damageforcescale * force;
318 self.flags = self.flags - (self.flags & FL_ONGROUND);
321 if (self.event_damage)
322 self.event_damage (inflictor, attacker, damage, deathtype, hitloc, force);
325 if(targ.classname == "player" && attacker.classname == "player" && attacker != targ && attacker.health > 2)
327 // Savage: vampire mode
328 if(cvar("g_vampire") && !cvar("g_minstagib"))
330 attacker.health += damage;
332 if(cvar("g_runematch"))
334 if (attacker.runes & RUNE_VAMPIRE)
336 // apply vampire rune
337 if (attacker.runes & CURSE_EMPATHY) // have the curse too
339 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb");
340 attacker.health = bound(
342 attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb"),
347 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_absorb");
348 attacker.health = bound(
350 attacker.health + damage * cvar("g_balance_rune_vampire_absorb"),
354 // apply empathy curse
355 else if (attacker.runes & CURSE_EMPATHY)
357 attacker.health = bound(
359 attacker.health + damage * cvar("g_balance_curse_empathy_takedamage"),
366 void RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype)
378 blastorigin = (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5);
380 targ = findradius (blastorigin, rad);
383 if (targ != inflictor)
386 // LordHavoc: measure distance to nearest point on target (not origin)
387 // (this guarentees 100% damage on a touch impact)
388 nearest = blastorigin;
389 m1 = targ.origin + targ.mins;
390 m2 = targ.origin + targ.maxs;
391 if (nearest_x < m1_x) nearest_x = m1_x;
392 if (nearest_y < m1_y) nearest_y = m1_y;
393 if (nearest_z < m1_z) nearest_z = m1_z;
394 if (nearest_x > m2_x) nearest_x = m2_x;
395 if (nearest_y > m2_y) nearest_y = m2_y;
396 if (nearest_z > m2_z) nearest_z = m2_z;
397 diff = nearest - blastorigin;
398 // round up a little on the damage to ensure full damage on impacts
399 // and turn the distance into a fraction of the radius
400 power = 1 - ((vlen (diff) - 2) / rad);
402 //bprint(ftos(power));
407 finaldmg = coredamage * power + edgedamage * (1 - power);
410 force = normalize((m1 + m2) * 0.5 - blastorigin) * (finaldmg / coredamage) * forceintensity;
411 if (targ == attacker)
412 finaldmg = finaldmg * cvar("g_balance_selfdamagepercent"); // Partial damage if the attacker hits himself
413 Damage (targ, inflictor, attacker, finaldmg, deathtype, inflictor.origin, force);
426 void ClearMultiDamage (void)
430 multi_force = '0 0 0';
433 void ApplyMultiDamage (void)
438 Damage (self, multi_ent.origin, multi_ent, 0, multi_damage, multi_force);
441 void AddMultiDamage (entity hit, float damage, vector force)
446 if (hit != multi_ent)
452 multi_damage = multi_damage + damage;
453 multi_force = multi_force + force;
456 void FireBullets (float shotcount, vector dir, vector spread, float deathtype)
463 makevectors (self.v_angle);
465 source = self.origin + v_forward * 10; // FIXME
466 source_x = self.absmin_z + self.size_z * 0.7; // ??? whaddabout view_ofs
468 // LordHavoc: better to use normal damage
469 //ClearMultiDamage ();
470 while (shotcount > 0)
472 direction = dir + crandom () * spread_x * v_right + crandom () * spread_y * v_up;
474 traceline (source, source + direction * 2048, FALSE, self);
475 if (trace_fraction != 1.0)
477 vel = normalize (direction + v_up * crandom () + v_right * crandom ());
478 vel = vel + 2 * trace_plane_normal;
481 org = trace_endpos - direction * 4;
483 if (!trace_ent.takedamage)
485 // LordHavoc: better to use normal damage
486 //AddMultiDamage (trace_ent, 4, direction * 4);
487 Damage (trace_ent, self, self, 4, deathtype, trace_endpos, direction * 4);
490 shotcount = shotcount + 1;
493 // LordHavoc: better to use normal damage
494 //ApplyMultiDamage ();