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