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"));
46 centerprint(targ, strcat("^1You killed your own dumb self!\n\n\n"));
48 if (deathtype == IT_GRENADE_LAUNCHER)
49 bprint ("^1",s, "^1 detonated\n");
50 else if (deathtype == IT_ELECTRO)
51 bprint ("^1",s, "^1 played with plasma\n");
52 else if (deathtype == IT_ROCKET_LAUNCHER)
53 bprint ("^1",s, "^1 exploded\n");
54 else if (deathtype == DEATH_KILL)
55 bprint ("^1",s, "^1 couldn't take it anymore\n");
56 else if (deathtype == DEATH_NOAMMO)
58 bprint ("^7",s, " ^7committed suicide. What's the point of living without ammo?\n");
59 //sound (self, CHAN_BODY, "minstagib/mockery.ogg", 1, ATTN_NONE);
62 bprint ("^1",s, "^1 couldn't resist the urge to self-destruct\n");
63 GiveFrags(attacker, targ, -1);
64 //targ.frags = targ.frags - 1;
65 if (targ.killcount > 2)
66 bprint ("^1",s,"^1 ended it all with a ",ftos(targ.killcount)," kill spree\n");
68 else if (teamplay && attacker.team == targ.team)
70 centerprint(attacker, strcat("^1Moron! You killed a teammate!\n\n\n"));
71 bprint ("^1", attacker.netname, "^1 mows down a teammate\n");
72 GiveFrags(attacker, targ, -1);
73 //attacker.frags = attacker.frags - 1;
74 if (targ.killcount > 2)
75 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," kill spree was endeded by a teammate!\n");
76 if (attacker.killcount > 2)
77 bprint ("^1",attacker.netname,"^1 ended a ",ftos(attacker.killcount)," kill spree by killing a teammate\n");
78 attacker.killcount = 0;
80 else if (attacker.classname == "player" || attacker.classname == "gib")
82 if (!checkrules_firstblood)
84 checkrules_firstblood = TRUE;
85 //sound(world, CHAN_AUTO, "announcer/firstblood.wav", 1, ATTN_NONE);
86 if (cvar("g_minstagib"))
87 //sound(world, CHAN_AUTO, "announce/male/mapkill1.ogg", 1, ATTN_NONE);
88 bprint("^1",attacker.netname, "^1 drew first blood", "\n");
91 centerprint(attacker, strcat("^4You killed ^7", s, "\n\n\n"));
92 centerprint(targ, strcat("^1You were killed by ^7", attacker.netname, "\n\n\n"));
94 if (deathtype == IT_LASER)
95 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
96 else if (deathtype == IT_UZI)
97 bprint ("^1",s, "^1 was riddled full of holes by ", attacker.netname, "\n");
98 else if (deathtype == IT_SHOTGUN)
99 bprint ("^1",s, "^1 was gunned by ", attacker.netname, "\n");
100 else if (deathtype == IT_GRENADE_LAUNCHER)
101 bprint ("^1", s, "^1 was blasted by ", attacker.netname, "\n");
102 else if (deathtype == IT_ELECTRO)
103 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
104 else if (deathtype == IT_CRYLINK)
105 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
106 else if (deathtype == IT_NEX)
107 bprint ("^1",s, "^1 has been vaporized by ", attacker.netname, "\n");
108 else if (deathtype == IT_HAGAR)
109 bprint ("^1",s, "^1 was pummeled by ", attacker.netname, "\n");
110 else if (deathtype == IT_ROCKET_LAUNCHER)
111 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
112 else if (deathtype == DEATH_TELEFRAG)
113 bprint ("^1",s, "^1 was telefragged by ", attacker.netname, "\n");
114 else if (deathtype == DEATH_DROWN)
115 bprint ("^1",s, "^1 was drowned by ", attacker.netname, "\n");
116 else if (deathtype == DEATH_SLIME)
117 bprint ("^1",s, "^1 was slimed by ", attacker.netname, "\n");
118 else if (deathtype == DEATH_LAVA)
119 bprint ("^1",s, "^1 was cooked by ", attacker.netname, "\n");
120 else if (deathtype == DEATH_FALL)
121 bprint ("^1",s, "^1 was grounded by ", attacker.netname, "\n");
122 else if (deathtype == DEATH_SWAMP)
123 bprint ("^1",s, "^1 was conserved by ", attacker.netname, "\n");
124 else if (deathtype == DEATH_HURTTRIGGER)
125 bprint ("^1",s, "^1 was thrown into a world of hurt by ", attacker.netname, "\n");
127 bprint ("^1",s, "^1 was killed by ", attacker.netname, "\n");
129 GiveFrags(attacker, targ, 1);
130 //attacker.frags = attacker.frags + 1;
131 if (targ.killcount > 2)
132 bprint ("^1",s,"'s ^1", ftos(targ.killcount), " kill spree was ended by ", attacker.netname, "\n");
133 attacker.killcount = attacker.killcount + 1;
134 if (attacker.killcount > 2)
135 bprint ("^1",attacker.netname,"^1 has ",ftos(attacker.killcount)," kills in a row\n");
137 if (attacker.killcount == 3)
139 bprint (attacker.netname,"^7 made a ^1TRIPLE FRAG\n");
140 stuffcmd(attacker, "play2 announcer/male/03kills.ogg\n");
142 else if (attacker.killcount == 5)
144 bprint (attacker.netname,"^7 made a ^1FIVE FRAG COMBO\n");
145 stuffcmd(attacker, "play2 announcer/male/05kills.ogg\n");
147 else if (attacker.killcount == 10)
149 bprint (attacker.netname,"^7 is on a ^1RAGE\n");
150 stuffcmd(attacker, "play2 announcer/male/10kills.ogg\n");
152 else if (attacker.killcount == 15)
154 bprint (attacker.netname,"^7 has done a ^1MASSACRE!\n");
155 stuffcmd(attacker, "play2 announcer/male/15kills.ogg\n");
157 else if (attacker.killcount == 20)
159 bprint (attacker.netname,"^7 is ^1UNHUMAN!\n");
160 stuffcmd(attacker, "play2 announcer/male/20kills.ogg\n");
162 else if (attacker.killcount == 25)
164 bprint (attacker.netname,"^7 is a ^1DEATH INCARNATION!\n");
165 stuffcmd(attacker, "play2 announcer/male/25kills.ogg\n");
167 else if (attacker.killcount == 30)
169 bprint (attacker.netname,"^7 is maybe a ^1AIMBOTTER?!\n");
170 stuffcmd(attacker, "play2 announcer/male/30kills.ogg\n");
175 centerprint(targ, strcat("^1Watch your step!\n\n\n"));
176 if (deathtype == DEATH_HURTTRIGGER && attacker.message != "")
177 bprint ("^1",s, "^1 ", attacker.message, "\n");
178 else if (deathtype == DEATH_DROWN)
179 bprint ("^1",s, "^1 drowned\n");
180 else if (deathtype == DEATH_SLIME)
181 bprint ("^1",s, "^1 was slimed\n");
182 else if (deathtype == DEATH_LAVA)
183 bprint ("^1",s, "^1 turned into hot slag\n");
184 else if (deathtype == DEATH_FALL)
185 bprint ("^1",s, "^1 hit the ground with a crunch\n");
186 else if (deathtype == DEATH_SWAMP)
187 bprint ("^1",s, "^1 is now conserved for centuries to come\n");
189 bprint ("^1",s, "^1 died\n");
190 GiveFrags(targ, targ, -1);
191 if(targ.frags == -5) {
192 stuffcmd(targ, "play2 announcer/male/botlike.ogg\n");
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)
212 if (gameover || targ.killcount == -666)
215 local float attackerIsAPlayer;
216 if(attacker.classname = "player") {
217 attackerIsAPlayer = 1;
219 attackerIsAPlayer = 0;
222 local entity oldself;
226 damage_inflictor = inflictor;
227 damage_attacker = attacker;
228 // nullify damage if teamplay is on
231 if (attacker.team == targ.team)
232 if (teamplay == 1 || (teamplay == 3 && attacker != targ))
235 if(damage > 0 && attackerIsAPlayer)
236 stuffcmd(attacker, "play2 misc/hit.wav\n");
238 if (cvar("g_minstagib"))
240 if ((deathtype == DEATH_FALL) ||
241 (deathtype == DEATH_DROWN) ||
242 (deathtype == DEATH_SLIME) ||
243 (deathtype == DEATH_LAVA))
245 if (targ.extralives && (deathtype == IT_NEX))
247 targ.extralives = targ.extralives - 1;
248 centerprint(targ, strcat("^3Remaining extra lives: ",ftos(targ.extralives),"\n"));
250 targ.armorvalue = targ.extralives;
251 stuffcmd(targ, "play2 misc/hit.wav\n");
252 //stuffcmd(attacker, "play2 misc/hit.wav\n");
254 else if (deathtype == IT_NEX && targ.items & IT_STRENGTH)
256 if(attackerIsAPlayer) stuffcmd(attacker, "play2 announcer/male/yoda.ogg\n");
258 if (deathtype == IT_LASER)
261 if (targ != attacker)
263 if (targ.classname == "player")
264 centerprint(attacker, "Secondary fire inflicts no damage!\n");
271 if (deathtype == IT_NEX && !(attacker.flags & FL_ONGROUND) && !(targ.flags & FL_ONGROUND) && attacker.killcount != 3 && attacker.killcount != 5 && attacker.killcount != 10 && attacker.killcount != 15 && attacker.killcount != 20 && attacker.killcount != 25 && attacker.killcount != 30)
273 if(attackerIsAPlayer) stuffcmd(attacker, "play2 announcer/male/yoda.ogg\n");
277 // midair gamemode: damage only while in the air
279 && self.classname == "player" // e.g. grenades take damage
280 && self.flags & FL_ONGROUND) {
284 // apply strength multiplier
285 if (attacker.items & IT_STRENGTH && !cvar("g_minstagib"))
287 damage = damage * cvar("g_balance_powerup_strength_damage");
288 force = force * cvar("g_balance_powerup_strength_force");
290 // apply invincibility multiplier
291 if (targ.items & IT_INVINCIBLE && !cvar("g_minstagib"))
292 damage = damage * cvar("g_balance_powerup_invincible_takedamage");
295 if(cvar("g_runematch"))
297 // apply strength rune
298 if (attacker.runes & RUNE_STRENGTH)
300 if(attacker.runes & CURSE_WEAK) // have both curse & rune
302 damage = damage * cvar("g_balance_rune_strength_combo_damage");
303 force = force * cvar("g_balance_rune_strength_combo_force");
307 damage = damage * cvar("g_balance_rune_strength_damage");
308 force = force * cvar("g_balance_rune_strength_force");
311 else if (attacker.runes & CURSE_WEAK)
313 damage = damage * cvar("g_balance_curse_weak_damage");
314 force = force * cvar("g_balance_curse_weak_force");
317 // apply defense rune
318 if (targ.runes & RUNE_DEFENSE)
320 if (targ.runes & CURSE_VULNER) // have both curse & rune
321 damage = damage * cvar("g_balance_rune_defense_combo_takedamage");
323 damage = damage * cvar("g_balance_rune_defense_takedamage");
325 else if (targ.runes & CURSE_VULNER)
326 damage = damage * cvar("g_balance_curse_vulner_takedamage");
330 if (self.damageforcescale)
332 self.velocity = self.velocity + self.damageforcescale * force;
333 self.flags = self.flags - (self.flags & FL_ONGROUND);
336 if (self.event_damage)
337 self.event_damage (inflictor, attacker, damage, deathtype, hitloc, force);
340 if(targ.classname == "player" && attacker.classname == "player" && attacker != targ && attacker.health > 2)
342 // Savage: vampire mode
343 if(cvar("g_vampire") && !cvar("g_minstagib"))
345 attacker.health += damage;
347 if(cvar("g_runematch"))
349 if (attacker.runes & RUNE_VAMPIRE)
351 // apply vampire rune
352 if (attacker.runes & CURSE_EMPATHY) // have the curse too
354 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb");
355 attacker.health = bound(
356 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 40
357 attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb"),
358 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
362 //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_absorb");
363 attacker.health = bound(
364 attacker.health, // LA: was 3, but changed so that you can't lose health
365 // empathy won't let you gain health in the same way...
366 attacker.health + damage * cvar("g_balance_rune_vampire_absorb"),
367 cvar("g_balance_rune_vampire_maxhealth")); // LA: was 1000, now 500
370 // apply empathy curse
371 else if (attacker.runes & CURSE_EMPATHY)
373 attacker.health = bound(
374 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 20
375 attacker.health + damage * cvar("g_balance_curse_empathy_takedamage"),
382 void RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype)
394 blastorigin = (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5);
396 targ = findradius (blastorigin, rad);
399 if (targ != inflictor)
402 // LordHavoc: measure distance to nearest point on target (not origin)
403 // (this guarentees 100% damage on a touch impact)
404 nearest = blastorigin;
405 m1 = targ.origin + targ.mins;
406 m2 = targ.origin + targ.maxs;
407 if (nearest_x < m1_x) nearest_x = m1_x;
408 if (nearest_y < m1_y) nearest_y = m1_y;
409 if (nearest_z < m1_z) nearest_z = m1_z;
410 if (nearest_x > m2_x) nearest_x = m2_x;
411 if (nearest_y > m2_y) nearest_y = m2_y;
412 if (nearest_z > m2_z) nearest_z = m2_z;
413 diff = nearest - blastorigin;
414 // round up a little on the damage to ensure full damage on impacts
415 // and turn the distance into a fraction of the radius
416 power = 1 - ((vlen (diff) - 2) / rad);
418 //bprint(ftos(power));
423 finaldmg = coredamage * power + edgedamage * (1 - power);
426 force = normalize((m1 + m2) * 0.5 - blastorigin) * (finaldmg / coredamage) * forceintensity;
427 if (targ == attacker)
428 finaldmg = finaldmg * cvar("g_balance_selfdamagepercent"); // Partial damage if the attacker hits himself
429 Damage (targ, inflictor, attacker, finaldmg, deathtype, inflictor.origin, force);
442 void ClearMultiDamage (void)
446 multi_force = '0 0 0';
449 void ApplyMultiDamage (void)
454 Damage (self, multi_ent.origin, multi_ent, 0, multi_damage, multi_force);
457 void AddMultiDamage (entity hit, float damage, vector force)
462 if (hit != multi_ent)
468 multi_damage = multi_damage + damage;
469 multi_force = multi_force + force;
472 void FireBullets (float shotcount, vector dir, vector spread, float deathtype)
479 makevectors (self.v_angle);
481 source = self.origin + v_forward * 10; // FIXME
482 source_x = self.absmin_z + self.size_z * 0.7; // ??? whaddabout view_ofs
484 // LordHavoc: better to use normal damage
485 //ClearMultiDamage ();
486 while (shotcount > 0)
488 direction = dir + crandom () * spread_x * v_right + crandom () * spread_y * v_up;
490 traceline (source, source + direction * 2048, FALSE, self);
491 if (trace_fraction != 1.0)
493 vel = normalize (direction + v_up * crandom () + v_right * crandom ());
494 vel = vel + 2 * trace_plane_normal;
497 org = trace_endpos - direction * 4;
499 if (!trace_ent.takedamage)
501 // LordHavoc: better to use normal damage
502 //AddMultiDamage (trace_ent, 4, direction * 4);
503 Damage (trace_ent, self, self, 4, deathtype, trace_endpos, direction * 4);
506 shotcount = shotcount + 1;
509 // LordHavoc: better to use normal damage
510 //ApplyMultiDamage ();