]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/w_crylink.qc
crylink: some debugging
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / w_crylink.qc
1 #ifdef REGISTER_WEAPON
2 REGISTER_WEAPON(CRYLINK, w_crylink, IT_CELLS, 6, WEP_FLAG_NORMAL | WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "crylink", "crylink", "Crylink");
3 #else
4 #ifdef SVQC
5 .float gravity;
6 .float crylink_waitrelease;
7 .entity crylink_lastgroup;
8
9 .entity queuenext;
10 .entity queueprev;
11
12 void W_Crylink_Dequeue_Raw(entity own, entity prev, entity me, entity next)
13 {
14         if(me == own.crylink_lastgroup)
15                 own.crylink_lastgroup = ((me == next) ? world : next);
16         prev.queuenext = next;
17         next.queueprev = prev;
18 }
19
20 void W_Crylink_Dequeue(entity e)
21 {
22         W_Crylink_Dequeue_Raw(e.realowner, e.queueprev, e, e.queuenext);
23 }
24
25 // force projectile to explode
26 void W_Crylink_LinkExplode (entity e, entity e2)
27 {
28         float a;
29         a = bound(0, 1 - (time - e.fade_time) * e.fade_rate, 1);
30
31         if(e == e.realowner.crylink_lastgroup)
32                 e.realowner.crylink_lastgroup = world;
33
34         RadiusDamage (e, e.realowner, cvar("g_balance_crylink_primary_damage") * a, cvar("g_balance_crylink_primary_edgedamage") * a, cvar("g_balance_crylink_primary_radius"), world, cvar("g_balance_crylink_primary_force") * a, e.projectiledeathtype, other);
35
36         if(e.queuenext != e2)
37                 W_Crylink_LinkExplode(e.queuenext, e2);
38
39         remove (e);
40 }
41
42 void W_Crylink_CheckLinks(entity e)
43 {
44         float i;
45         entity p;
46
47         if(e == world)
48                 error("W_Crylink_CheckLinks: entity is world");
49
50         p = e;
51         for(i = 0; i < 1000; ++i)
52         {
53                 if(p.queuenext.queueprev != p || p.queueprev.queuenext != p)
54                         error("W_Crylink_CheckLinks: queue is inconsistent");
55                 p = p.queuenext;
56                 if(p == e)
57                         break;
58         }
59         if(i >= 1000)
60                 error("W_Crylink_CheckLinks: infinite chain");
61 }
62
63 // adjust towards center
64 // returns the origin where they will meet... and the time till the meeting is
65 // stored in w_crylink_linkjoin_time.
66 // could possibly network this origin and time, and display a special particle
67 // effect when projectiles meet there :P
68 // jspeed: MINIMUM jing speed
69 // jtime: MAXIMUM jing time (0: none)
70 float w_crylink_linkjoin_time;
71 vector W_Crylink_LinkJoin(entity e, float jspeed, float jtime)
72 {
73         vector avg_origin, avg_velocity;
74         vector targ_origin;
75         float avg_dist, n;
76         entity p;
77
78         // FIXME remove this debug code
79         W_Crylink_CheckLinks(e);
80
81         w_crylink_linkjoin_time = 0;
82
83         avg_origin = e.origin;
84         avg_velocity = e.velocity;
85         n = 1;
86         for(p = e; (p = p.queuenext) != e; )
87         {
88                 avg_origin += WarpZone_RefSys_TransformOrigin(p, e, p.origin);
89                 avg_velocity += WarpZone_RefSys_TransformVelocity(p, e, p.velocity);
90                 ++n;
91         }
92         avg_origin *= (1.0 / n);
93         avg_velocity *= (1.0 / n);
94
95         if(n < 2)
96                 return avg_origin; // nothing to do
97
98         // yes, mathematically we can do this in ONE step, but beware of 32bit floats...
99         avg_dist = pow(vlen(e.origin - avg_origin), 2);
100         for(p = e; (p = p.queuenext) != e; )
101                 avg_dist += pow(vlen(WarpZone_RefSys_TransformOrigin(p, e, p.origin) - avg_origin), 2);
102         avg_dist *= (1.0 / n);
103         avg_dist = sqrt(avg_dist);
104
105         if(avg_dist == 0)
106                 return avg_origin; // no change needed
107
108         if(jspeed == 0 && jtime == 0)
109         {
110                 e.velocity = avg_velocity;
111                 UpdateCSQCProjectile(e);
112                 for(p = e; (p = p.queuenext) != e; )
113                 {
114                         p.velocity = WarpZone_RefSys_TransformVelocity(e, p, avg_velocity);
115                         UpdateCSQCProjectile(p);
116                 }
117         }
118         else
119         {
120                 if(jtime)
121                 {
122                         if(jspeed)
123                                 w_crylink_linkjoin_time = min(jtime, avg_dist / jspeed);
124                         else
125                                 w_crylink_linkjoin_time = jtime;
126                 }
127                 else
128                         w_crylink_linkjoin_time = avg_dist / jspeed;
129                 targ_origin = avg_origin + w_crylink_linkjoin_time * avg_velocity;
130
131                 e.velocity = (targ_origin - e.origin) * (1.0 / w_crylink_linkjoin_time);
132                 UpdateCSQCProjectile(e);
133                 for(p = e; (p = p.queuenext) != e; )
134                 {
135                         p.velocity = WarpZone_RefSys_TransformVelocity(e, p, (targ_origin - WarpZone_RefSys_TransformOrigin(p, e, p.origin)) * (1.0 / w_crylink_linkjoin_time));
136                         UpdateCSQCProjectile(p);
137                 }
138
139                 // analysis:
140                 //   jspeed -> +infinity:
141                 //      w_crylink_linkjoin_time -> +0
142                 //      targ_origin -> avg_origin
143                 //      p->velocity -> HUEG towards center
144                 //   jspeed -> 0:
145                 //      w_crylink_linkjoin_time -> +/- infinity
146                 //      targ_origin -> avg_velocity * +/- infinity
147                 //      p->velocity -> avg_velocity
148                 //   jspeed -> -infinity:
149                 //      w_crylink_linkjoin_time -> -0
150                 //      targ_origin -> avg_origin
151                 //      p->velocity -> HUEG away from center
152         }
153
154         return targ_origin;
155 }
156
157 void W_Crylink_LinkJoinEffect_Think()
158 {
159         // is there at least 2 projectiles very close?
160         entity e, p;
161         float n;
162         e = self.owner.crylink_lastgroup;
163         n = 0;
164         if(e)
165         {
166                 if(vlen(e.origin - self.origin) < vlen(e.velocity) * frametime)
167                         ++n;
168                 for(p = e; (p = p.queuenext) != e; )
169                 {
170                         if(vlen(p.origin - self.origin) < vlen(p.velocity) * frametime)
171                                 ++n;
172                 }
173                 if(n >= 2)
174                 {
175                         if(e.projectiledeathtype & HITTYPE_SECONDARY)
176                         {
177                                 if(cvar("g_balance_crylink_secondary_joinexplode"))
178                                 {
179                                         n = n / cvar("g_balance_crylink_secondary_shots");
180                                         RadiusDamage (e, e.realowner, cvar("g_balance_crylink_secondary_joinexplode_damage") * n, 
181                                                                         cvar("g_balance_crylink_secondary_joinexplode_edgedamage") * n, 
182                                                                         cvar("g_balance_crylink_secondary_joinexplode_radius") * n, e.realowner, 
183                                                                         cvar("g_balance_crylink_secondary_joinexplode_force") * n, e.projectiledeathtype, other);
184
185                                         pointparticles(particleeffectnum("crylink_joinexplode"), self.origin, '0 0 0', n);
186                                 }                               
187                         }
188                         else
189                         {
190                                 if(cvar("g_balance_crylink_primary_joinexplode"))
191                                 {
192                                         n = n / cvar("g_balance_crylink_primary_shots");
193                                         RadiusDamage (e, e.realowner, cvar("g_balance_crylink_primary_joinexplode_damage") * n, 
194                                                                         cvar("g_balance_crylink_primary_joinexplode_edgedamage") * n, 
195                                                                         cvar("g_balance_crylink_primary_joinexplode_radius") * n, e.realowner, 
196                                                                         cvar("g_balance_crylink_primary_joinexplode_force") * n, e.projectiledeathtype, other);
197
198                                         pointparticles(particleeffectnum("crylink_joinexplode"), self.origin, '0 0 0', n);
199                                 }                               
200                         }                       
201                 }
202         }
203         remove(self);
204 }
205
206
207 // NO bounce protection, as bounces are limited!
208 void W_Crylink_Touch (void)
209 {
210         float finalhit;
211         float f;
212         //PROJECTILE_TOUCH;
213         local entity savenext, saveprev, saveown;
214         saveown = self.realowner;
215         savenext = self.queuenext;
216         saveprev = self.queueprev;
217         if(WarpZone_Projectile_Touch())
218         {
219                 if(wasfreed(self))
220                         W_Crylink_Dequeue_Raw(saveown, saveprev, self, savenext);
221                 return;
222         }
223
224         float a;
225         a = bound(0, 1 - (time - self.fade_time) * self.fade_rate, 1);
226
227         finalhit = ((self.cnt <= 0) || (other.takedamage != DAMAGE_NO));
228         if(finalhit)
229                 f = 1;
230         else
231                 f = cvar("g_balance_crylink_primary_bouncedamagefactor");
232         if(a)
233                 f *= a;
234         if (RadiusDamage (self, self.realowner, cvar("g_balance_crylink_primary_damage") * f, cvar("g_balance_crylink_primary_edgedamage") * f, cvar("g_balance_crylink_primary_radius"), world, cvar("g_balance_crylink_primary_force") * f, self.projectiledeathtype, other) && cvar("g_balance_crylink_primary_linkexplode"))
235         {
236                 W_Crylink_LinkExplode(self.queuenext, self);
237                 remove (self);
238                 return;
239         }
240         else if(finalhit)
241         {
242                 // just unlink
243                 W_Crylink_Dequeue(self);
244                 remove(self);
245                 return;
246         }
247         self.cnt = self.cnt - 1;
248         self.angles = vectoangles(self.velocity);
249         self.owner = world;
250         self.projectiledeathtype |= HITTYPE_BOUNCE;
251         // commented out as it causes a little hitch...
252         //if(proj.cnt == 0)
253         //      CSQCProjectile(proj, TRUE, PROJECTILE_CRYLINK, TRUE);
254 }
255
256 void W_Crylink_Touch2 (void)
257 {
258         float finalhit;
259         float f;
260         //PROJECTILE_TOUCH;
261         local entity savenext, saveprev, saveown;
262         savenext = self.queuenext;
263         saveprev = self.queueprev;
264         saveown = self.realowner;
265         if(WarpZone_Projectile_Touch())
266         {
267                 if(wasfreed(self))
268                         W_Crylink_Dequeue_Raw(saveown, saveprev, self, savenext);
269                 return;
270         }
271
272         float a;
273         a = 1 - (time - self.fade_time) * self.fade_rate;
274
275         finalhit = ((self.cnt <= 0) || (other.takedamage != DAMAGE_NO));
276         if(finalhit)
277                 f = 1;
278         else
279                 f = cvar("g_balance_crylink_secondary_bouncedamagefactor");
280         if(a)
281                 f *= a;
282         if (RadiusDamage (self, self.realowner, cvar("g_balance_crylink_secondary_damage") * f, cvar("g_balance_crylink_secondary_edgedamage") * f, cvar("g_balance_crylink_secondary_radius"), world, cvar("g_balance_crylink_secondary_force") * f, self.projectiledeathtype, other) && cvar("g_balance_crylink_secondary_linkexplode"))
283         {
284                 W_Crylink_LinkExplode(self.queuenext, self);
285                 remove (self);
286                 return;
287         }
288         else if(finalhit)
289         {
290                 // just unlink
291                 W_Crylink_Dequeue(self);
292                 remove(self);
293                 return;
294         }
295         self.cnt = self.cnt - 1;
296         self.angles = vectoangles(self.velocity);
297         self.owner = world;
298         self.projectiledeathtype |= HITTYPE_BOUNCE;
299         // commented out as it causes a little hitch...
300         //if(proj.cnt == 0)
301         //      CSQCProjectile(proj, TRUE, PROJECTILE_CRYLINK, TRUE);
302 }
303
304 void W_Crylink_Fadethink (void)
305 {
306         W_Crylink_Dequeue(self);
307         remove(self);
308 }
309
310 void W_Crylink_Attack (void)
311 {
312         local float counter, shots;
313         local entity proj, prevproj, firstproj;
314         local vector s;
315         vector forward, right, up;
316
317         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
318                 self.ammo_cells = self.ammo_cells - cvar("g_balance_crylink_primary_ammo");
319
320         W_SetupShot (self, FALSE, 2, "weapons/crylink_fire.wav", (cvar("g_balance_crylink_primary_damage")*cvar("g_balance_crylink_primary_shots")));
321         forward = v_forward;
322         right = v_right;
323         up = v_up;
324
325         shots = cvar("g_balance_crylink_primary_shots");
326         pointparticles(particleeffectnum("crylink_muzzleflash"), w_shotorg, w_shotdir * 1000, shots);
327         proj = world;
328         while (counter < shots)
329         {
330                 proj = spawn ();
331                 proj.realowner = proj.owner = self;
332                 proj.classname = "spike";
333                 proj.bot_dodge = TRUE;
334                 proj.bot_dodgerating = cvar("g_balance_crylink_primary_damage");
335                 if(shots == 1) {
336                         proj.queuenext = proj;
337                         proj.queueprev = proj;
338                 }
339                 else if(counter == 0) { // first projectile, store in firstproj for now
340                         firstproj = proj;
341                 }
342                 else if(counter == shots - 1) { // last projectile, link up with first projectile
343                         prevproj.queuenext = proj;
344                         firstproj.queueprev = proj;
345                         proj.queuenext = firstproj;
346                         proj.queueprev = prevproj;
347                 }
348                 else { // else link up with previous projectile
349                         prevproj.queuenext = proj;
350                         proj.queueprev = prevproj;
351                 }
352
353                 prevproj = proj;
354
355                 proj.movetype = MOVETYPE_BOUNCEMISSILE;
356                 PROJECTILE_MAKETRIGGER(proj);
357                 proj.projectiledeathtype = WEP_CRYLINK;
358                 //proj.gravity = 0.001;
359
360                 setorigin (proj, w_shotorg);
361                 setsize(proj, '0 0 0', '0 0 0');
362
363
364                 s = '0 0 0';
365                 if (counter == 0)
366                         s = '0 0 0';
367                 else
368                 {
369                         makevectors('0 360 0' * (0.75 + (counter - 0.5) / (shots - 1)));
370                         s_y = v_forward_x;
371                         s_z = v_forward_y;
372                 }
373                 s = s * cvar("g_balance_crylink_primary_spread") * g_weaponspreadfactor;
374                 W_SetupProjectileVelocityEx(proj, w_shotdir + right * s_y + up * s_z, v_up, cvar("g_balance_crylink_primary_speed"), 0, 0, 0, FALSE);
375                 proj.touch = W_Crylink_Touch;
376
377                 proj.think = W_Crylink_Fadethink;
378                 if(counter == 0)
379                 {
380                         proj.fade_time = time + cvar("g_balance_crylink_primary_middle_lifetime");
381                         proj.fade_rate = 1 / cvar("g_balance_crylink_primary_middle_fadetime");
382                         proj.nextthink = time + cvar("g_balance_crylink_primary_middle_lifetime") + cvar("g_balance_crylink_primary_middle_fadetime");
383                 }
384                 else
385                 {
386                         proj.fade_time = time + cvar("g_balance_crylink_primary_other_lifetime");
387                         proj.fade_rate = 1 / cvar("g_balance_crylink_primary_other_fadetime");
388                         proj.nextthink = time + cvar("g_balance_crylink_primary_other_lifetime") + cvar("g_balance_crylink_primary_other_fadetime");
389                 }
390                 proj.cnt = cvar("g_balance_crylink_primary_bounces");
391                 //proj.scale = 1 + 1 * proj.cnt;
392
393                 proj.angles = vectoangles (proj.velocity);
394
395                 //proj.glow_size = 20;
396
397                 proj.flags = FL_PROJECTILE;
398
399                 CSQCProjectile(proj, TRUE, (proj.cnt ? PROJECTILE_CRYLINK_BOUNCING : PROJECTILE_CRYLINK), TRUE);
400
401                 other = proj; MUTATOR_CALLHOOK(EditProjectile);
402
403                 counter = counter + 1;
404         }
405         self.crylink_lastgroup = proj;
406 }
407
408 void W_Crylink_Attack2 (void)
409 {
410         local float counter, shots;
411         local entity proj, prevproj, firstproj;
412
413         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
414                 self.ammo_cells = self.ammo_cells - cvar("g_balance_crylink_secondary_ammo");
415
416         W_SetupShot (self, FALSE, 2, "weapons/crylink_fire2.wav", (cvar("g_balance_crylink_secondary_damage")*cvar("g_balance_crylink_secondary_shots")));
417
418         shots = cvar("g_balance_crylink_secondary_shots");
419         pointparticles(particleeffectnum("crylink_muzzleflash"), w_shotorg, w_shotdir * 1000, shots);
420         proj = world;
421         while (counter < shots)
422         {
423                 proj = spawn ();
424                 proj.realowner = proj.owner = self;
425                 proj.classname = "spike";
426                 proj.bot_dodge = TRUE;
427                 proj.bot_dodgerating = cvar("g_balance_crylink_secondary_damage");
428                 if(shots == 1) {
429                         proj.queuenext = proj;
430                         proj.queueprev = proj;
431                 }
432                 else if(counter == 0) { // first projectile, store in firstproj for now
433                         firstproj = proj;
434                 }
435                 else if(counter == shots - 1) { // last projectile, link up with first projectile
436                         prevproj.queuenext = proj;
437                         firstproj.queueprev = proj;
438                         proj.queuenext = firstproj;
439                         proj.queueprev = prevproj;
440                 }
441                 else { // else link up with previous projectile
442                         prevproj.queuenext = proj;
443                         proj.queueprev = prevproj;
444                 }
445
446                 prevproj = proj;
447
448                 proj.movetype = MOVETYPE_BOUNCEMISSILE;
449                 PROJECTILE_MAKETRIGGER(proj);
450                 proj.projectiledeathtype = WEP_CRYLINK | HITTYPE_SECONDARY;
451                 //proj.gravity = 0.001;
452
453                 setorigin (proj, w_shotorg);
454                 setsize(proj, '0 0 0', '0 0 0');
455
456                 W_SetupProjectileVelocityEx(proj, (w_shotdir + (((counter + 0.5) / shots) * 2 - 1) * v_right * cvar("g_balance_crylink_secondary_spread") * g_weaponspreadfactor), v_up, cvar("g_balance_crylink_secondary_speed"), 0, 0, 0, FALSE);
457                 proj.touch = W_Crylink_Touch2;
458                 proj.think = W_Crylink_Fadethink;
459                 if(counter == (shots - 1) / 2)
460                 {
461                         proj.fade_time = time + cvar("g_balance_crylink_secondary_middle_lifetime");
462                         proj.fade_rate = 1 / cvar("g_balance_crylink_secondary_middle_fadetime");
463                         proj.nextthink = time + cvar("g_balance_crylink_secondary_middle_lifetime") + cvar("g_balance_crylink_secondary_middle_fadetime");
464                 }
465                 else
466                 {
467                         proj.fade_time = time + cvar("g_balance_crylink_secondary_line_lifetime");
468                         proj.fade_rate = 1 / cvar("g_balance_crylink_secondary_line_fadetime");
469                         proj.nextthink = time + cvar("g_balance_crylink_secondary_line_lifetime") + cvar("g_balance_crylink_secondary_line_fadetime");
470                 }
471                 proj.cnt = cvar("g_balance_crylink_secondary_bounces");
472                 //proj.scale = 1 + 1 * proj.cnt;
473
474                 proj.angles = vectoangles (proj.velocity);
475
476                 //proj.glow_size = 20;
477
478                 proj.flags = FL_PROJECTILE;
479
480                 CSQCProjectile(proj, TRUE, (proj.cnt ? PROJECTILE_CRYLINK_BOUNCING : PROJECTILE_CRYLINK), TRUE);
481
482                 other = proj; MUTATOR_CALLHOOK(EditProjectile);
483
484                 counter = counter + 1;
485         }
486         self.crylink_lastgroup = proj;
487 }
488
489 void spawnfunc_weapon_crylink (void)
490 {
491         weapon_defaultspawnfunc(WEP_CRYLINK);
492 }
493
494 float w_crylink(float req)
495 {
496         if (req == WR_AIM)
497         {
498                 if (random() > 0.15)
499                         self.BUTTON_ATCK = bot_aim(cvar("g_balance_crylink_primary_speed"), 0, cvar("g_balance_crylink_primary_middle_lifetime"), FALSE);
500                 else
501                         self.BUTTON_ATCK2 = bot_aim(cvar("g_balance_crylink_secondary_speed"), 0, cvar("g_balance_crylink_secondary_middle_lifetime"), FALSE);
502         }
503         else if (req == WR_THINK)
504         {
505                 if (self.BUTTON_ATCK)
506                 {
507                         if (!self.crylink_waitrelease)
508                         if (weapon_prepareattack(0, cvar("g_balance_crylink_primary_refire")))
509                         {
510                                 W_Crylink_Attack();
511                                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_crylink_primary_animtime"), w_ready);
512                                 if(cvar("g_balance_crylink_primary_joinspread") != 0 || cvar("g_balance_crylink_primary_jointime") != 0)
513                                         self.crylink_waitrelease = 1;
514                         }
515                 }
516                 else if(self.BUTTON_ATCK2 && cvar("g_balance_crylink_secondary"))
517                 {
518                         if (!self.crylink_waitrelease)
519                         if (weapon_prepareattack(1, cvar("g_balance_crylink_secondary_refire")))
520                         {
521                                 W_Crylink_Attack2();
522                                 weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_crylink_secondary_animtime"), w_ready);
523                                 if(cvar("g_balance_crylink_secondary_joinspread") != 0 || cvar("g_balance_crylink_secondary_jointime") != 0)
524                                         self.crylink_waitrelease = 2;
525                         }
526                 }
527                 else
528                 {
529                         if (self.crylink_waitrelease)
530                         {
531                                 // fired and released now!
532                                 if(self.crylink_lastgroup)
533                                 {
534                                         vector pos;
535                                         entity linkjoineffect;
536                                         
537                                         
538                                         if(self.crylink_waitrelease == 1)
539                                         {
540                                                 pos = W_Crylink_LinkJoin(self.crylink_lastgroup, cvar("g_balance_crylink_primary_joinspread") * cvar("g_balance_crylink_primary_speed"), cvar("g_balance_crylink_primary_jointime"));
541                                                 
542                                         }
543                                         else
544                                         {
545                                                 pos = W_Crylink_LinkJoin(self.crylink_lastgroup, cvar("g_balance_crylink_secondary_joinspread") * cvar("g_balance_crylink_secondary_speed"), cvar("g_balance_crylink_secondary_jointime"));
546                                         }
547                                         
548                                         linkjoineffect = spawn();
549                                         linkjoineffect.think = W_Crylink_LinkJoinEffect_Think;
550                                         linkjoineffect.classname = "linkjoineffect";                                    
551                                         linkjoineffect.nextthink = time + w_crylink_linkjoin_time;
552                                         linkjoineffect.owner = self;
553                                         setorigin(linkjoineffect, pos);
554
555
556                                 }
557                                 self.crylink_waitrelease = 0;
558                                 if(!w_crylink(WR_CHECKAMMO1) && !w_crylink(WR_CHECKAMMO2))
559                                 {
560                                         // ran out of ammo!
561                                         self.cnt = WEP_CRYLINK;
562                                         self.switchweapon = w_getbestweapon(self);
563                                 }
564                         }
565                 }
566         }
567         else if (req == WR_PRECACHE)
568         {
569                 precache_model ("models/weapons/g_crylink.md3");
570                 precache_model ("models/weapons/v_crylink.md3");
571                 precache_model ("models/weapons/h_crylink.iqm");
572                 precache_sound ("weapons/crylink_fire.wav");
573                 precache_sound ("weapons/crylink_fire2.wav");
574                 precache_sound ("weapons/crylink_linkjoin.wav");
575         }
576         else if (req == WR_SETUP)
577                 weapon_setup(WEP_CRYLINK);
578         else if (req == WR_CHECKAMMO1)
579         {
580                 // don't "run out of ammo" and switch weapons while waiting for release
581                 if(self.crylink_lastgroup && self.crylink_waitrelease)
582                         return TRUE;
583                 return self.ammo_cells >= cvar("g_balance_crylink_primary_ammo");
584         }
585         else if (req == WR_CHECKAMMO2)
586         {
587                 // don't "run out of ammo" and switch weapons while waiting for release
588                 if(self.crylink_lastgroup && self.crylink_waitrelease)
589                         return TRUE;
590                 return self.ammo_cells >= cvar("g_balance_crylink_secondary_ammo");
591         }
592         return TRUE;
593 };
594 #endif
595 #ifdef CSQC
596 float w_crylink(float req)
597 {
598         if(req == WR_IMPACTEFFECT)
599         {
600                 vector org2;
601                 org2 = w_org + w_backoff * 2;
602                 if(w_deathtype & HITTYPE_SECONDARY)
603                 {
604                         pointparticles(particleeffectnum("crylink_impact"), org2, '0 0 0', 1);
605                         if(!w_issilent)
606                                 sound(self, CHAN_PROJECTILE, "weapons/crylink_impact2.wav", VOL_BASE, ATTN_NORM);
607                 }
608                 else
609                 {
610                         pointparticles(particleeffectnum("crylink_impactbig"), org2, '0 0 0', 1);
611                         if(!w_issilent)
612                                 sound(self, CHAN_PROJECTILE, "weapons/crylink_impact.wav", VOL_BASE, ATTN_NORM);
613                 }
614         }
615         else if(req == WR_PRECACHE)
616         {
617                 precache_sound("weapons/crylink_impact2.wav");
618                 precache_sound("weapons/crylink_impact.wav");
619         }
620         else if (req == WR_SUICIDEMESSAGE)
621         {
622                 w_deathtypestring = "%s succeeded at self-destructing themself with the Crylink";
623         }
624         else if (req == WR_KILLMESSAGE)
625         {
626                 if(w_deathtype & HITTYPE_BOUNCE)
627                         w_deathtypestring = "%s could not hide from %s's Crylink"; // unchecked: SPLASH (SECONDARY can't be)
628                 else if(w_deathtype & HITTYPE_SPLASH)
629                         w_deathtypestring = "%s was too close to %s's Crylink"; // unchecked: SECONDARY
630                 else
631                         w_deathtypestring = "%s took a close look at %s's Crylink"; // unchecked: SECONDARY
632         }
633         return TRUE;
634 }
635 #endif
636 #endif