]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/gamec/g_damage.c
Fixed g_campaign team balance
[divverent/nexuiz.git] / data / qcsrc / server / gamec / g_damage.c
1
2 float checkrules_firstblood;
3
4 void GiveFrags (entity attacker, entity targ, float f)
5 {
6         if(gameover) return;
7
8         if(cvar("g_arena"))
9                 if(cvar("g_arena_roundbased"))
10                         return;
11
12         if(cvar("g_domination"))
13         {
14                 if(cvar("g_domination_disable_frags"))
15                         if(f > 0)
16                                 return;
17         }
18         else if(cvar("g_runematch"))
19         {
20                 if(f > 0)
21                         f = RunematchHandleFrags(attacker, targ, f);
22         }
23         else if(cvar("g_lms"))
24         {
25                 // count remaining lives, not frags in lms
26                 targ.frags -= 1;
27                 // keep track of the worst players lives
28                 if(targ.frags < lms_lowest_lives)
29                         lms_lowest_lives = targ.frags;
30                 // player has no more lives left
31                 if (!targ.frags)
32                 {
33                         lms_dead_count += 1;
34                         if(!lms_next_place)
35                                 lms_next_place = player_count;
36                         targ.frags = -lms_next_place;
37                         lms_next_place -= 1;
38                 }
39                 return;
40         }
41
42         if(f)
43                 attacker.frags = attacker.frags + f;
44 }
45
46 string AppendItemcodes(string s, entity player)
47 {
48         float w;
49         w = player.weapon;
50         //if(w == 0)
51         //      w = player.switchweapon;
52         if(w == 0)
53                 w = player.cnt; // previous weapon!
54         s = strcat(s, ftos(weapon_translateindextoflag(w)));
55         if(time < player.strength_finished)
56                 s = strcat(s, "S");
57         if(time < player.invincible_finished)
58                 s = strcat(s, "I");
59         if(player.flagcarried != world)
60                 s = strcat(s, "F");
61         if(player.runes)
62                 s = strcat(s, "|", ftos(player.runes));
63         return s;
64 }
65
66 void LogDeath(string mode, float deathtype, entity killer, entity killed)
67 {
68         string s;
69         if(!cvar("sv_eventlog"))
70                 return;
71         s = strcat(":kill:", mode);
72         s = strcat(s, ":", ftos(killer.playerid));
73         s = strcat(s, ":", ftos(killed.playerid));
74         s = strcat(s, ":type=", ftos(deathtype));
75         s = strcat(s, ":items=");
76         s = AppendItemcodes(s, killer);
77         if(killed != killer)
78         {
79                 s = strcat(s, ":victimitems=");
80                 s = AppendItemcodes(s, killed);
81         }
82         GameLogEcho(s, FALSE);
83 }
84
85 void Obituary (entity attacker, entity targ, float deathtype)
86 {
87         string  s, m;
88
89         if (targ.classname == "player" || targ.classname == "corpse")
90         {
91                 if (targ.classname == "corpse")
92                         s = "A corpse";
93                 else
94                         s = targ.netname;
95
96                 if (targ == attacker)
97                 {
98                         if (deathtype == DEATH_NOAMMO)
99                                 centerprint(targ, strcat("^1You were killed for running out of ammo...\n\n\n"));
100                         if (deathtype == DEATH_TEAMCHANGE)
101                         {
102                                 m = "You are now on: ";
103                                 if (targ.team == 5)
104                                         m = strcat(m, "^1Red Team");
105                                 else if (targ.team == 14)
106                                         m = strcat(m, "^4Blue Team");
107                                 else if (targ.team == 10)
108                                         m = strcat(m, "^6Pink Team");
109                                 else if (targ.team == 13)
110                                         m = strcat(m, "^3Yellow Team");
111                                 centerprint(targ, m);
112                         }
113                         else if (deathtype == DEATH_AUTOTEAMCHANGE)
114                         {
115                                 m = "You have been moved into a different team to improve team balance\nYou are now on: ";
116                                 if (targ.team == 5)
117                                         m = strcat(m, "^1Red Team");
118                                 else if (targ.team == 14)
119                                         m = strcat(m, "^4Blue Team");
120                                 else if (targ.team == 10)
121                                         m = strcat(m, "^6Pink Team");
122                                 else if (targ.team == 13)
123                                         m = strcat(m, "^3Yellow Team");
124                                 centerprint(targ, m);
125                                 return;
126                         }
127                         else if (deathtype == DEATH_CAMP)
128                                 centerprint(targ, strcat("^1Die camper!\n\n\n"));
129                         else
130                                 centerprint(targ, strcat("^1You killed your own dumb self!\n\n\n"));
131
132                         if (deathtype == IT_GRENADE_LAUNCHER)
133                                 bprint ("^1",s, "^1 detonated\n");
134                         else if (deathtype == IT_ELECTRO)
135                                 bprint ("^1",s, "^1 played with plasma\n");
136                         else if (deathtype == IT_ROCKET_LAUNCHER)
137                                 bprint ("^1",s, "^1 exploded\n");
138                         else if (deathtype == DEATH_KILL)
139                                 bprint ("^1",s, "^1 couldn't take it anymore\n");
140                         else if (deathtype == DEATH_NOAMMO)
141                         {
142                                 bprint ("^7",s, " ^7committed suicide. What's the point of living without ammo?\n");
143                                 //sound (self, CHAN_BODY, "minstagib/mockery.ogg", 1, ATTN_NONE);
144                         }
145                         else if (deathtype == DEATH_CAMP)
146                                 bprint ("^1",s, "^1 thought he found a nice camping ground\n");
147                         else if (deathtype != DEATH_TEAMCHANGE)
148                                 bprint ("^1",s, "^1 couldn't resist the urge to self-destruct\n");
149
150                         if(deathtype != DEATH_TEAMCHANGE)
151                                 LogDeath("suicide", deathtype, targ, targ);
152
153                         GiveFrags(attacker, targ, -1);
154                         //targ.frags = targ.frags - 1;
155                         if (targ.killcount > 2)
156                                 bprint ("^1",s,"^1 ended it all with a ",ftos(targ.killcount)," kill spree\n");
157                 }
158                 else if (teamplay && attacker.team == targ.team)
159                 {
160                         centerprint(attacker, strcat("^1Moron! You fragged a teammate!\n\n\n"));
161                         bprint ("^1", attacker.netname, "^1 mows down a teammate\n");
162                         GiveFrags(attacker, targ, -1);
163                         //attacker.frags = attacker.frags - 1;
164                         if (targ.killcount > 2)
165                                 bprint ("^1",s,"'s ^1",ftos(targ.killcount)," kill spree was endeded by a teammate!\n");
166                         if (attacker.killcount > 2)
167                                 bprint ("^1",attacker.netname,"^1 ended a ",ftos(attacker.killcount)," kill spree by killing a teammate\n");
168                         attacker.killcount = 0;
169
170                         LogDeath("tk", deathtype, attacker, targ);
171                 }
172                 else if (attacker.classname == "player" || attacker.classname == "gib")
173                 {
174                         if (!checkrules_firstblood)
175                         {
176                                 checkrules_firstblood = TRUE;
177                                 //sound(world, CHAN_AUTO, "announcer/firstblood.wav", 1, ATTN_NONE);
178                                 //if (cvar("g_minstagib"))
179                                         //sound(world, CHAN_AUTO, "announce/male/mapkill1.ogg", 1, ATTN_NONE);
180                                 bprint("^1",attacker.netname, "^1 drew first blood", "\n");
181                         }
182
183                         centerprint(attacker, strcat("^4You fragged ^7", s, "\n\n\n"));
184                         centerprint(targ, strcat("^1You were fragged by ^7", attacker.netname, "\n\n\n"));
185
186                         if (deathtype == IT_LASER)
187                                 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
188                         else if (deathtype == IT_UZI)
189                                 bprint ("^1",s, "^1 was riddled full of holes by ", attacker.netname, "\n");
190                         else if (deathtype == IT_SHOTGUN)
191                                 bprint ("^1",s, "^1 was gunned by ", attacker.netname, "\n");
192                         else if (deathtype == IT_GRENADE_LAUNCHER)
193                                 bprint ("^1", s, "^1 was blasted by ", attacker.netname, "\n");
194                         else if (deathtype == IT_ELECTRO)
195                                 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
196                         else if (deathtype == IT_CRYLINK)
197                                 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
198                         else if (deathtype == IT_NEX)
199                                 bprint ("^1",s, "^1 has been vaporized by ", attacker.netname, "\n");
200                         else if (deathtype == IT_HAGAR)
201                                 bprint ("^1",s, "^1 was pummeled by ", attacker.netname, "\n");
202                         else if (deathtype == IT_ROCKET_LAUNCHER)
203                                 bprint ("^1",s, "^1 was blasted by ", attacker.netname, "\n");
204                         else if (deathtype == DEATH_TELEFRAG)
205                                 bprint ("^1",s, "^1 was telefragged by ", attacker.netname, "\n");
206                         else if (deathtype == DEATH_DROWN)
207                                 bprint ("^1",s, "^1 was drowned by ", attacker.netname, "\n");
208                         else if (deathtype == DEATH_SLIME)
209                                 bprint ("^1",s, "^1 was slimed by ", attacker.netname, "\n");
210                         else if (deathtype == DEATH_LAVA)
211                                 bprint ("^1",s, "^1 was cooked by ", attacker.netname, "\n");
212                         else if (deathtype == DEATH_FALL)
213                                 bprint ("^1",s, "^1 was grounded by ", attacker.netname, "\n");
214                         else if (deathtype == DEATH_SHOOTING_STAR)
215                                 bprint ("^1",s, "^1 was shot into space by ", attacker.netname, "\n");
216                         else if (deathtype == DEATH_SWAMP)
217                                 bprint ("^1",s, "^1 was conserved by ", attacker.netname, "\n");
218                         else if (deathtype == DEATH_HURTTRIGGER)
219                                 bprint ("^1",s, "^1 was thrown into a world of hurt by ", attacker.netname, "\n");
220                         else
221                                 bprint ("^1",s, "^1 was fragged by ", attacker.netname, "\n");
222
223                         GiveFrags(attacker, targ, 1);
224                         //attacker.frags = attacker.frags + 1;
225                         if (targ.killcount > 2)
226                                 bprint ("^1",s,"'s ^1", ftos(targ.killcount), " kill spree was ended by ", attacker.netname, "\n");
227                         attacker.killcount = attacker.killcount + 1;
228                         if (attacker.killcount > 2)
229                                 bprint ("^1",attacker.netname,"^1 has ",ftos(attacker.killcount)," frags in a row\n");
230
231                         LogDeath("frag", deathtype, attacker, targ);
232
233                         if (attacker.killcount == 3)
234                         {
235                                 bprint (attacker.netname,"^7 made a ^1TRIPLE FRAG\n");
236                                 stuffcmd(attacker, "play2 announcer/male/03kills.ogg\n");
237                         }
238                         else if (attacker.killcount == 5)
239                         {
240                                 bprint (attacker.netname,"^7 made a ^1FIVE FRAG COMBO\n");
241                                 stuffcmd(attacker, "play2 announcer/male/05kills.ogg\n");
242                         }
243                         else if (attacker.killcount == 10)
244                         {
245                                 bprint (attacker.netname,"^7 is on a ^1RAGE\n");
246                                 stuffcmd(attacker, "play2 announcer/male/10kills.ogg\n");
247                         }
248                         else if (attacker.killcount == 15)
249                         {
250                                 bprint (attacker.netname,"^7 has done a ^1MASSACRE!\n");
251                                 stuffcmd(attacker, "play2 announcer/male/15kills.ogg\n");
252                         }
253                         else if (attacker.killcount == 20)
254                         {
255                                 bprint (attacker.netname,"^7 is ^1UNHUMAN!\n");
256                                 stuffcmd(attacker, "play2 announcer/male/20kills.ogg\n");
257                         }
258                         else if (attacker.killcount == 25)
259                         {
260                                 bprint (attacker.netname,"^7 is a ^1DEATH INCARNATION!\n");
261                                 stuffcmd(attacker, "play2 announcer/male/25kills.ogg\n");
262                         }
263                         else if (attacker.killcount == 30)
264                         {
265                                 bprint (attacker.netname,"^7 is maybe a ^1AIMBOTTER?!\n");
266                                 stuffcmd(attacker, "play2 announcer/male/30kills.ogg\n");
267                         }
268                 }
269                 else
270                 {
271                         centerprint(targ, strcat("^1Watch your step!\n\n\n"));
272                         if (deathtype == DEATH_HURTTRIGGER && attacker.message != "")
273                                 bprint ("^1",s, "^1 ", attacker.message, "\n");
274                         else if (deathtype == DEATH_DROWN)
275                                 bprint ("^1",s, "^1 drowned\n");
276                         else if (deathtype == DEATH_SLIME)
277                                 bprint ("^1",s, "^1 was slimed\n");
278                         else if (deathtype == DEATH_LAVA)
279                                 bprint ("^1",s, "^1 turned into hot slag\n");
280                         else if (deathtype == DEATH_FALL)
281                                 bprint ("^1",s, "^1 hit the ground with a crunch\n");
282                         else if (deathtype == DEATH_SHOOTING_STAR)
283                                 bprint ("^1",s, "^1 became a shooting star\n");
284                         else if (deathtype == DEATH_SWAMP)
285                                 bprint ("^1",s, "^1 is now conserved for centuries to come\n");
286                         else
287                                 bprint ("^1",s, "^1 died\n");
288                         GiveFrags(targ, targ, -1);
289                         if(targ.frags == -5) {
290                                 stuffcmd(targ, "play2 announcer/male/botlike.ogg\n");
291                         }
292
293                         //targ.frags = targ.frags - 1;
294                         if (targ.killcount > 2)
295                                 bprint ("^1",s,"^1 died with a ",ftos(targ.killcount)," kill spree\n");
296
297                         LogDeath("accident", deathtype, targ, targ);
298                 }
299                 targ.death_origin = targ.origin;
300                 if(targ != attacker)
301                         targ.killer_origin = attacker.origin;
302                 // FIXME: this should go in PutClientInServer
303                 if (targ.killcount)
304                         targ.killcount = 0;
305         }
306 }
307
308 // these are updated by each Damage call for use in button triggering and such
309 entity damage_targ;
310 entity damage_inflictor;
311 entity damage_attacker;
312
313 void Damage (entity targ, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
314 {
315         if (gameover || targ.killcount == -666)
316                 return;
317
318         local entity oldself;
319         oldself = self;
320         self = targ;
321         damage_targ = targ;
322         damage_inflictor = inflictor;
323         damage_attacker = attacker;
324         // nullify damage if teamplay is on
325         if (teamplay)
326         if (attacker.team)
327         if (attacker.team == targ.team)
328         if ((teamplay == 1 || teamplay == 3) && attacker != targ)
329                 damage = 0;
330
331         if(cvar("g_lms"))
332         if(targ.classname == "player")
333         if(attacker.classname == "player")
334         if(attacker != targ)
335         {
336                 targ.lms_traveled_distance = cvar("g_lms_campcheck_distance");
337                 attacker.lms_traveled_distance = cvar("g_lms_campcheck_distance");
338         }
339
340         if(damage > 0 && targ != attacker && clienttype(attacker) == CLIENTTYPE_REAL && targ.classname == "player")
341                 stuffcmd(attacker, "play2 misc/hit.wav\n");
342
343         if (cvar("g_minstagib"))
344         {
345                 if ((deathtype == DEATH_FALL)  ||
346                     (deathtype == DEATH_DROWN) ||
347                     (deathtype == DEATH_SLIME) ||
348                     (deathtype == DEATH_LAVA))
349                         return;
350                 if (targ.extralives && (deathtype == IT_NEX) && damage)
351                 {
352                         targ.extralives -= 1;
353                         centerprint(targ, strcat("^3Remaining extra lives: ",ftos(targ.extralives),"\n"));
354                         damage = 0;
355                         targ.armorvalue = targ.extralives;
356                         if(clienttype(targ) == CLIENTTYPE_REAL) stuffcmd(targ, "play2 misc/hit.wav\n");
357                         //stuffcmd(attacker, "play2 misc/hit.wav\n");
358                 }
359                 else if (deathtype == IT_NEX && targ.items & IT_STRENGTH)
360                 {
361                         if(clienttype(attacker) == CLIENTTYPE_REAL) stuffcmd(attacker, "play2 announcer/male/yoda.ogg\n");
362                 }
363                 if (deathtype == IT_LASER)
364                 {
365                         damage = 0;
366                         if (targ != attacker)
367                         {
368                                 if (targ.classname == "player")
369                                         centerprint(attacker, "Secondary fire inflicts no damage!\n");
370                                 damage = 0;
371                                 force = '0 0 0';
372                                 attacker = targ;
373                         }
374                 }
375         } else {
376                 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)
377                 {
378                         if(clienttype(attacker) == CLIENTTYPE_REAL)  stuffcmd(attacker, "play2 announcer/male/yoda.ogg\n");
379                 }
380         }
381
382         // apply strength multiplier
383         if (attacker.items & IT_STRENGTH && !cvar("g_minstagib"))
384         {
385                 damage = damage * cvar("g_balance_powerup_strength_damage");
386                 force = force * cvar("g_balance_powerup_strength_force");
387         }
388         // apply invincibility multiplier
389         if (targ.items & IT_INVINCIBLE && !cvar("g_minstagib"))
390                 damage = damage * cvar("g_balance_powerup_invincible_takedamage");
391
392
393         if(cvar("g_runematch"))
394         {
395                 // apply strength rune
396                 if (attacker.runes & RUNE_STRENGTH)
397                 {
398                         if(attacker.runes & CURSE_WEAK) // have both curse & rune
399                         {
400                                 damage = damage * cvar("g_balance_rune_strength_combo_damage");
401                                 force = force * cvar("g_balance_rune_strength_combo_force");
402                         }
403                         else
404                         {
405                                 damage = damage * cvar("g_balance_rune_strength_damage");
406                                 force = force * cvar("g_balance_rune_strength_force");
407                         }
408                 }
409                 else if (attacker.runes & CURSE_WEAK)
410                 {
411                         damage = damage * cvar("g_balance_curse_weak_damage");
412                         force = force * cvar("g_balance_curse_weak_force");
413                 }
414
415                 // apply defense rune
416                 if (targ.runes & RUNE_DEFENSE)
417                 {
418                         if (targ.runes & CURSE_VULNER) // have both curse & rune
419                                 damage = damage * cvar("g_balance_rune_defense_combo_takedamage");
420                         else
421                                 damage = damage * cvar("g_balance_rune_defense_takedamage");
422                 }
423                 else if (targ.runes & CURSE_VULNER)
424                         damage = damage * cvar("g_balance_curse_vulner_takedamage");
425         }
426
427         // apply push
428         if (self.damageforcescale)
429         {
430                 self.velocity = self.velocity + self.damageforcescale * force;
431                 self.flags = self.flags - (self.flags & FL_ONGROUND);
432         }
433         // apply damage
434         if (self.event_damage)
435                 self.event_damage (inflictor, attacker, damage, deathtype, hitloc, force);
436         self = oldself;
437
438         if(targ.classname == "player" && attacker.classname == "player" && attacker != targ && attacker.health > 2)
439         {
440                 // Savage: vampire mode
441                 if(cvar("g_vampire") && !cvar("g_minstagib"))
442                 {
443                         attacker.health += damage;
444                 }
445                 if(cvar("g_runematch"))
446                 {
447                         if (attacker.runes & RUNE_VAMPIRE)
448                         {
449                         // apply vampire rune
450                                 if (attacker.runes & CURSE_EMPATHY) // have the curse too
451                                 {
452                                         //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb");
453                                         attacker.health = bound(
454                                                 cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 40
455                                                 attacker.health + damage * cvar("g_balance_rune_vampire_combo_absorb"),
456                                                 cvar("g_balance_rune_vampire_maxhealth"));      // LA: was 1000, now 500
457                                 }
458                                 else
459                                 {
460                                         //attacker.health = attacker.health + damage * cvar("g_balance_rune_vampire_absorb");
461                                         attacker.health = bound(
462                                                 attacker.health,        // LA: was 3, but changed so that you can't lose health
463                                                                                         // empathy won't let you gain health in the same way...
464                                                 attacker.health + damage * cvar("g_balance_rune_vampire_absorb"),
465                                                 cvar("g_balance_rune_vampire_maxhealth"));      // LA: was 1000, now 500
466                                         }
467                         }
468                         // apply empathy curse
469                         else if (attacker.runes & CURSE_EMPATHY)
470                         {
471                                 attacker.health = bound(
472                                         cvar("g_balance_curse_empathy_minhealth"), // LA: was 3, now 20
473                                         attacker.health + damage * cvar("g_balance_curse_empathy_takedamage"),
474                                         attacker.health);
475                         }
476                 }
477         }
478 }
479
480 void RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype)
481 {
482         entity  targ;
483         float   finaldmg;
484         float   power;
485         vector  blastorigin;
486         vector  force;
487         vector  m1;
488         vector  m2;
489         vector  nearest;
490         vector  diff;
491
492         blastorigin = (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5);
493
494         targ = findradius (blastorigin, rad);
495         while (targ)
496         {
497                 if (targ != inflictor)
498                         if (ignore != targ)
499                         {
500                                 // LordHavoc: measure distance to nearest point on target (not origin)
501                                 // (this guarentees 100% damage on a touch impact)
502                                 nearest = blastorigin;
503                                 m1 = targ.origin + targ.mins;
504                                 m2 = targ.origin + targ.maxs;
505                                 if (nearest_x < m1_x) nearest_x = m1_x;
506                                 if (nearest_y < m1_y) nearest_y = m1_y;
507                                 if (nearest_z < m1_z) nearest_z = m1_z;
508                                 if (nearest_x > m2_x) nearest_x = m2_x;
509                                 if (nearest_y > m2_y) nearest_y = m2_y;
510                                 if (nearest_z > m2_z) nearest_z = m2_z;
511                                 diff = nearest - blastorigin;
512                                 // round up a little on the damage to ensure full damage on impacts
513                                 // and turn the distance into a fraction of the radius
514                                 power = 1 - ((vlen (diff) - 2) / rad);
515                                 //bprint(" ");
516                                 //bprint(ftos(power));
517                                 if (power > 0)
518                                 {
519                                         if (power > 1)
520                                                 power = 1;
521                                         finaldmg = coredamage * power + edgedamage * (1 - power);
522                                         if (finaldmg > 0)
523                                         {
524                                                 force = normalize((m1 + m2) * 0.5 - blastorigin) * (finaldmg / coredamage) * forceintensity;
525                                                 if (targ == attacker)
526                                                         finaldmg = finaldmg * cvar("g_balance_selfdamagepercent");      // Partial damage if the attacker hits himself
527                                                 Damage (targ, inflictor, attacker, finaldmg, deathtype, nearest, force);
528                                         }
529                                 }
530                         }
531                 targ = targ.chain;
532         }
533 }
534
535 /*
536 entity  multi_ent;
537 float   multi_damage;
538 vector  multi_force;
539
540 void ClearMultiDamage (void)
541 {
542         multi_ent = world;
543         multi_damage = 0;
544         multi_force = '0 0 0';
545 }
546
547 void ApplyMultiDamage (void)
548 {
549         if (!multi_ent)
550                 return;
551
552         Damage (self, multi_ent.origin, multi_ent, 0, multi_damage, multi_force);
553 }
554
555 void AddMultiDamage (entity hit, float damage, vector force)
556 {
557         if (!hit)
558                 return;
559
560         if (hit != multi_ent)
561         {
562                 ApplyMultiDamage ();
563                 ClearMultiDamage ();
564                 multi_ent = hit;
565         }
566         multi_damage = multi_damage + damage;
567         multi_force = multi_force + force;
568 }
569
570 void FireBullets (float shotcount, vector dir, vector spread, float deathtype)
571 {
572         vector  direction;
573         vector  source;
574         vector  vel;
575         vector  org;
576
577         makevectors (self.v_angle);
578
579         source = self.origin + v_forward * 10;  // FIXME
580         source_x = self.absmin_z + self.size_z * 0.7;   // ??? whaddabout view_ofs
581
582         // LordHavoc: better to use normal damage
583         //ClearMultiDamage ();
584         while (shotcount > 0)
585         {
586                 direction = dir + crandom () * spread_x * v_right + crandom () * spread_y * v_up;
587
588                 traceline (source, source + direction * 2048, FALSE, self);
589                 if (trace_fraction != 1.0)
590                 {
591                         vel = normalize (direction + v_up * crandom () + v_right * crandom ());
592                         vel = vel + 2 * trace_plane_normal;
593                         vel = vel * 200;
594
595                         org = trace_endpos - direction * 4;
596
597                         if (!trace_ent.takedamage)
598                                 te_gunshot (org);
599                         // LordHavoc: better to use normal damage
600                         //AddMultiDamage (trace_ent, 4, direction * 4);
601                         Damage (trace_ent, self, self, 4, deathtype, trace_endpos, direction * 4);
602                 }
603
604                 shotcount = shotcount + 1;
605         }
606
607         // LordHavoc: better to use normal damage
608         //ApplyMultiDamage ();
609 }
610 */
611
612
613