make weapon death messages translatable
[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_CheckLinks(entity e)
13 {
14         float i;
15         entity p;
16
17         if(e == world)
18                 error("W_Crylink_CheckLinks: entity is world");
19
20         p = e;
21         for(i = 0; i < 1000; ++i)
22         {
23                 if(p.queuenext.queueprev != p || p.queueprev.queuenext != p)
24                         error("W_Crylink_CheckLinks: queue is inconsistent");
25                 p = p.queuenext;
26                 if(p == e)
27                         break;
28         }
29         if(i >= 1000)
30                 error("W_Crylink_CheckLinks: infinite chain");
31 }
32
33 void W_Crylink_Dequeue_Raw(entity own, entity prev, entity me, entity next)
34 {
35         if(me == own.crylink_lastgroup)
36                 own.crylink_lastgroup = ((me == next) ? world : next);
37         prev.queuenext = next;
38         next.queueprev = prev;
39 }
40
41 void W_Crylink_Dequeue(entity e)
42 {
43         W_Crylink_Dequeue_Raw(e.realowner, e.queueprev, e, e.queuenext);
44 }
45
46 // force projectile to explode
47 void W_Crylink_LinkExplode (entity e, entity e2)
48 {
49         float a;
50         a = bound(0, 1 - (time - e.fade_time) * e.fade_rate, 1);
51
52         if(e == e.realowner.crylink_lastgroup)
53                 e.realowner.crylink_lastgroup = world;
54
55         RadiusDamage (e, e.realowner, autocvar_g_balance_crylink_primary_damage * a, autocvar_g_balance_crylink_primary_edgedamage * a, autocvar_g_balance_crylink_primary_radius, world, autocvar_g_balance_crylink_primary_force * a, e.projectiledeathtype, other);
56
57         if(e.queuenext != e2)
58                 W_Crylink_LinkExplode(e.queuenext, e2);
59
60         remove (e);
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(autocvar_g_balance_crylink_secondary_joinexplode)
178                                 {
179                                         n = n / autocvar_g_balance_crylink_secondary_shots;
180                                         RadiusDamage (e, e.realowner, autocvar_g_balance_crylink_secondary_joinexplode_damage * n,
181                                                                         autocvar_g_balance_crylink_secondary_joinexplode_edgedamage * n,
182                                                                         autocvar_g_balance_crylink_secondary_joinexplode_radius * n, e.realowner,
183                                                                         autocvar_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(autocvar_g_balance_crylink_primary_joinexplode)
191                                 {
192                                         n = n / autocvar_g_balance_crylink_primary_shots;
193                                         RadiusDamage (e, e.realowner, autocvar_g_balance_crylink_primary_joinexplode_damage * n,
194                                                                         autocvar_g_balance_crylink_primary_joinexplode_edgedamage * n,
195                                                                         autocvar_g_balance_crylink_primary_joinexplode_radius * n, e.realowner,
196                                                                         autocvar_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 = autocvar_g_balance_crylink_primary_bouncedamagefactor;
232         if(a)
233                 f *= a;
234         if (RadiusDamage (self, self.realowner, autocvar_g_balance_crylink_primary_damage * f, autocvar_g_balance_crylink_primary_edgedamage * f, autocvar_g_balance_crylink_primary_radius, world, autocvar_g_balance_crylink_primary_force * f, self.projectiledeathtype, other) && autocvar_g_balance_crylink_primary_linkexplode)
235         {
236                 if(self == self.realowner.crylink_lastgroup)
237                         self.realowner.crylink_lastgroup = world;
238                 W_Crylink_LinkExplode(self.queuenext, self);
239                 remove (self);
240                 return;
241         }
242         else if(finalhit)
243         {
244                 // just unlink
245                 W_Crylink_Dequeue(self);
246                 remove(self);
247                 return;
248         }
249         self.cnt = self.cnt - 1;
250         self.angles = vectoangles(self.velocity);
251         self.owner = world;
252         self.projectiledeathtype |= HITTYPE_BOUNCE;
253         // commented out as it causes a little hitch...
254         //if(proj.cnt == 0)
255         //      CSQCProjectile(proj, TRUE, PROJECTILE_CRYLINK, TRUE);
256 }
257
258 void W_Crylink_Touch2 (void)
259 {
260         float finalhit;
261         float f;
262         //PROJECTILE_TOUCH;
263         local entity savenext, saveprev, saveown;
264         savenext = self.queuenext;
265         saveprev = self.queueprev;
266         saveown = self.realowner;
267         if(WarpZone_Projectile_Touch())
268         {
269                 if(wasfreed(self))
270                         W_Crylink_Dequeue_Raw(saveown, saveprev, self, savenext);
271                 return;
272         }
273
274         float a;
275         a = 1 - (time - self.fade_time) * self.fade_rate;
276
277         finalhit = ((self.cnt <= 0) || (other.takedamage != DAMAGE_NO));
278         if(finalhit)
279                 f = 1;
280         else
281                 f = autocvar_g_balance_crylink_secondary_bouncedamagefactor;
282         if(a)
283                 f *= a;
284         if (RadiusDamage (self, self.realowner, autocvar_g_balance_crylink_secondary_damage * f, autocvar_g_balance_crylink_secondary_edgedamage * f, autocvar_g_balance_crylink_secondary_radius, world, autocvar_g_balance_crylink_secondary_force * f, self.projectiledeathtype, other) && autocvar_g_balance_crylink_secondary_linkexplode)
285         {
286                 if(self == self.realowner.crylink_lastgroup)
287                         self.realowner.crylink_lastgroup = world;
288                 W_Crylink_LinkExplode(self.queuenext, self);
289                 remove (self);
290                 return;
291         }
292         else if(finalhit)
293         {
294                 // just unlink
295                 W_Crylink_Dequeue(self);
296                 remove(self);
297                 return;
298         }
299         self.cnt = self.cnt - 1;
300         self.angles = vectoangles(self.velocity);
301         self.owner = world;
302         self.projectiledeathtype |= HITTYPE_BOUNCE;
303         // commented out as it causes a little hitch...
304         //if(proj.cnt == 0)
305         //      CSQCProjectile(proj, TRUE, PROJECTILE_CRYLINK, TRUE);
306 }
307
308 void W_Crylink_Fadethink (void)
309 {
310         W_Crylink_Dequeue(self);
311         remove(self);
312 }
313
314 void W_Crylink_Attack (void)
315 {
316         local float counter, shots;
317         local entity proj, prevproj, firstproj;
318         local vector s;
319         vector forward, right, up;
320         float maxdmg;
321
322         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
323                 self.ammo_cells = self.ammo_cells - autocvar_g_balance_crylink_primary_ammo;
324
325         maxdmg = autocvar_g_balance_crylink_primary_damage*autocvar_g_balance_crylink_primary_shots;
326         maxdmg *= 1 + autocvar_g_balance_crylink_primary_bouncedamagefactor * autocvar_g_balance_crylink_primary_bounces;
327         if(autocvar_g_balance_crylink_primary_joinexplode)
328                 maxdmg += autocvar_g_balance_crylink_primary_joinexplode_damage;
329
330         W_SetupShot (self, FALSE, 2, "weapons/crylink_fire.wav", CHAN_WEAPON, maxdmg);
331         forward = v_forward;
332         right = v_right;
333         up = v_up;
334
335         shots = autocvar_g_balance_crylink_primary_shots;
336         pointparticles(particleeffectnum("crylink_muzzleflash"), w_shotorg, w_shotdir * 1000, shots);
337         proj = world;
338         while (counter < shots)
339         {
340                 proj = spawn ();
341                 proj.realowner = proj.owner = self;
342                 proj.classname = "spike";
343                 proj.bot_dodge = TRUE;
344                 proj.bot_dodgerating = autocvar_g_balance_crylink_primary_damage;
345                 if(shots == 1) {
346                         proj.queuenext = proj;
347                         proj.queueprev = proj;
348                 }
349                 else if(counter == 0) { // first projectile, store in firstproj for now
350                         firstproj = proj;
351                 }
352                 else if(counter == shots - 1) { // last projectile, link up with first projectile
353                         prevproj.queuenext = proj;
354                         firstproj.queueprev = proj;
355                         proj.queuenext = firstproj;
356                         proj.queueprev = prevproj;
357                 }
358                 else { // else link up with previous projectile
359                         prevproj.queuenext = proj;
360                         proj.queueprev = prevproj;
361                 }
362
363                 prevproj = proj;
364
365                 proj.movetype = MOVETYPE_BOUNCEMISSILE;
366                 PROJECTILE_MAKETRIGGER(proj);
367                 proj.projectiledeathtype = WEP_CRYLINK;
368                 //proj.gravity = 0.001;
369
370                 setorigin (proj, w_shotorg);
371                 setsize(proj, '0 0 0', '0 0 0');
372
373
374                 s = '0 0 0';
375                 if (counter == 0)
376                         s = '0 0 0';
377                 else
378                 {
379                         makevectors('0 360 0' * (0.75 + (counter - 0.5) / (shots - 1)));
380                         s_y = v_forward_x;
381                         s_z = v_forward_y;
382                 }
383                 s = s * autocvar_g_balance_crylink_primary_spread * g_weaponspreadfactor;
384                 W_SetupProjectileVelocityEx(proj, w_shotdir + right * s_y + up * s_z, v_up, autocvar_g_balance_crylink_primary_speed, 0, 0, 0, FALSE);
385                 proj.touch = W_Crylink_Touch;
386
387                 proj.think = W_Crylink_Fadethink;
388                 if(counter == 0)
389                 {
390                         proj.fade_time = time + autocvar_g_balance_crylink_primary_middle_lifetime;
391                         proj.fade_rate = 1 / autocvar_g_balance_crylink_primary_middle_fadetime;
392                         proj.nextthink = time + autocvar_g_balance_crylink_primary_middle_lifetime + autocvar_g_balance_crylink_primary_middle_fadetime;
393                 }
394                 else
395                 {
396                         proj.fade_time = time + autocvar_g_balance_crylink_primary_other_lifetime;
397                         proj.fade_rate = 1 / autocvar_g_balance_crylink_primary_other_fadetime;
398                         proj.nextthink = time + autocvar_g_balance_crylink_primary_other_lifetime + autocvar_g_balance_crylink_primary_other_fadetime;
399                 }
400                 proj.teleport_time = time + autocvar_g_balance_crylink_primary_joindelay;
401                 proj.cnt = autocvar_g_balance_crylink_primary_bounces;
402                 //proj.scale = 1 + 1 * proj.cnt;
403
404                 proj.angles = vectoangles (proj.velocity);
405
406                 //proj.glow_size = 20;
407
408                 proj.flags = FL_PROJECTILE;
409
410                 CSQCProjectile(proj, TRUE, (proj.cnt ? PROJECTILE_CRYLINK_BOUNCING : PROJECTILE_CRYLINK), TRUE);
411
412                 other = proj; MUTATOR_CALLHOOK(EditProjectile);
413
414                 counter = counter + 1;
415         }
416         self.crylink_lastgroup = proj;
417 }
418
419 void W_Crylink_Attack2 (void)
420 {
421         local float counter, shots;
422         local entity proj, prevproj, firstproj;
423         float maxdmg;
424
425         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
426                 self.ammo_cells = self.ammo_cells - autocvar_g_balance_crylink_secondary_ammo;
427
428         maxdmg = autocvar_g_balance_crylink_secondary_damage*autocvar_g_balance_crylink_secondary_shots;
429         maxdmg *= 1 + autocvar_g_balance_crylink_secondary_bouncedamagefactor * autocvar_g_balance_crylink_secondary_bounces;
430         if(autocvar_g_balance_crylink_secondary_joinexplode)
431                 maxdmg += autocvar_g_balance_crylink_secondary_joinexplode_damage;
432
433         W_SetupShot (self, FALSE, 2, "weapons/crylink_fire2.wav", CHAN_WEAPON, maxdmg);
434
435         shots = autocvar_g_balance_crylink_secondary_shots;
436         pointparticles(particleeffectnum("crylink_muzzleflash"), w_shotorg, w_shotdir * 1000, shots);
437         proj = world;
438         while (counter < shots)
439         {
440                 proj = spawn ();
441                 proj.realowner = proj.owner = self;
442                 proj.classname = "spike";
443                 proj.bot_dodge = TRUE;
444                 proj.bot_dodgerating = autocvar_g_balance_crylink_secondary_damage;
445                 if(shots == 1) {
446                         proj.queuenext = proj;
447                         proj.queueprev = proj;
448                 }
449                 else if(counter == 0) { // first projectile, store in firstproj for now
450                         firstproj = proj;
451                 }
452                 else if(counter == shots - 1) { // last projectile, link up with first projectile
453                         prevproj.queuenext = proj;
454                         firstproj.queueprev = proj;
455                         proj.queuenext = firstproj;
456                         proj.queueprev = prevproj;
457                 }
458                 else { // else link up with previous projectile
459                         prevproj.queuenext = proj;
460                         proj.queueprev = prevproj;
461                 }
462
463                 prevproj = proj;
464
465                 proj.movetype = MOVETYPE_BOUNCEMISSILE;
466                 PROJECTILE_MAKETRIGGER(proj);
467                 proj.projectiledeathtype = WEP_CRYLINK | HITTYPE_SECONDARY;
468                 //proj.gravity = 0.001;
469
470                 setorigin (proj, w_shotorg);
471                 setsize(proj, '0 0 0', '0 0 0');
472
473                 W_SetupProjectileVelocityEx(proj, (w_shotdir + (((counter + 0.5) / shots) * 2 - 1) * v_right * autocvar_g_balance_crylink_secondary_spread * g_weaponspreadfactor), v_up, autocvar_g_balance_crylink_secondary_speed, 0, 0, 0, FALSE);
474                 proj.touch = W_Crylink_Touch2;
475                 proj.think = W_Crylink_Fadethink;
476                 if(counter == (shots - 1) / 2)
477                 {
478                         proj.fade_time = time + autocvar_g_balance_crylink_secondary_middle_lifetime;
479                         proj.fade_rate = 1 / autocvar_g_balance_crylink_secondary_middle_fadetime;
480                         proj.nextthink = time + autocvar_g_balance_crylink_secondary_middle_lifetime + autocvar_g_balance_crylink_secondary_middle_fadetime;
481                 }
482                 else
483                 {
484                         proj.fade_time = time + autocvar_g_balance_crylink_secondary_line_lifetime;
485                         proj.fade_rate = 1 / autocvar_g_balance_crylink_secondary_line_fadetime;
486                         proj.nextthink = time + autocvar_g_balance_crylink_secondary_line_lifetime + autocvar_g_balance_crylink_secondary_line_fadetime;
487                 }
488                 proj.teleport_time = time + autocvar_g_balance_crylink_secondary_joindelay;
489                 proj.cnt = autocvar_g_balance_crylink_secondary_bounces;
490                 //proj.scale = 1 + 1 * proj.cnt;
491
492                 proj.angles = vectoangles (proj.velocity);
493
494                 //proj.glow_size = 20;
495
496                 proj.flags = FL_PROJECTILE;
497
498                 CSQCProjectile(proj, TRUE, (proj.cnt ? PROJECTILE_CRYLINK_BOUNCING : PROJECTILE_CRYLINK), TRUE);
499
500                 other = proj; MUTATOR_CALLHOOK(EditProjectile);
501
502                 counter = counter + 1;
503         }
504         self.crylink_lastgroup = proj;
505 }
506
507 void spawnfunc_weapon_crylink (void)
508 {
509         weapon_defaultspawnfunc(WEP_CRYLINK);
510 }
511
512 float w_crylink(float req)
513 {
514         if (req == WR_AIM)
515         {
516                 if (random() < 0.10)
517                         self.BUTTON_ATCK = bot_aim(autocvar_g_balance_crylink_primary_speed, 0, autocvar_g_balance_crylink_primary_middle_lifetime, FALSE);
518                 else
519                         self.BUTTON_ATCK2 = bot_aim(autocvar_g_balance_crylink_secondary_speed, 0, autocvar_g_balance_crylink_secondary_middle_lifetime, FALSE);
520         }
521         else if (req == WR_THINK)
522         {
523                 if (self.BUTTON_ATCK)
524                 {
525                         if (!self.crylink_waitrelease)
526                         if (weapon_prepareattack(0, autocvar_g_balance_crylink_primary_refire))
527                         {
528                                 W_Crylink_Attack();
529                                 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_crylink_primary_animtime, w_ready);
530                                 if(autocvar_g_balance_crylink_primary_joinspread != 0 || autocvar_g_balance_crylink_primary_jointime != 0)
531                                         self.crylink_waitrelease = 1;
532                         }
533                 }
534                 else if(self.BUTTON_ATCK2 && autocvar_g_balance_crylink_secondary)
535                 {
536                         if (!self.crylink_waitrelease)
537                         if (weapon_prepareattack(1, autocvar_g_balance_crylink_secondary_refire))
538                         {
539                                 W_Crylink_Attack2();
540                                 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_crylink_secondary_animtime, w_ready);
541                                 if(autocvar_g_balance_crylink_secondary_joinspread != 0 || autocvar_g_balance_crylink_secondary_jointime != 0)
542                                         self.crylink_waitrelease = 2;
543                         }
544                 }
545                 else
546                 {
547                         if (self.crylink_waitrelease && (!self.crylink_lastgroup || time > self.crylink_lastgroup.teleport_time))
548                         {
549                                 // fired and released now!
550                                 if(self.crylink_lastgroup)
551                                 {
552                                         vector pos;
553                                         entity linkjoineffect;
554
555                                         if(self.crylink_waitrelease == 1)
556                                         {
557                                                 pos = W_Crylink_LinkJoin(self.crylink_lastgroup, autocvar_g_balance_crylink_primary_joinspread * autocvar_g_balance_crylink_primary_speed, autocvar_g_balance_crylink_primary_jointime);
558
559                                         }
560                                         else
561                                         {
562                                                 pos = W_Crylink_LinkJoin(self.crylink_lastgroup, autocvar_g_balance_crylink_secondary_joinspread * autocvar_g_balance_crylink_secondary_speed, autocvar_g_balance_crylink_secondary_jointime);
563                                         }
564
565                                         linkjoineffect = spawn();
566                                         linkjoineffect.think = W_Crylink_LinkJoinEffect_Think;
567                                         linkjoineffect.classname = "linkjoineffect";
568                                         linkjoineffect.nextthink = time + w_crylink_linkjoin_time;
569                                         linkjoineffect.owner = self;
570                                         setorigin(linkjoineffect, pos);
571                                 }
572                                 self.crylink_waitrelease = 0;
573                                 if(!w_crylink(WR_CHECKAMMO1) && !w_crylink(WR_CHECKAMMO2))
574                                 {
575                                         // ran out of ammo!
576                                         self.cnt = WEP_CRYLINK;
577                                         self.switchweapon = w_getbestweapon(self);
578                                 }
579                         }
580                 }
581         }
582         else if (req == WR_PRECACHE)
583         {
584                 precache_model ("models/weapons/g_crylink.md3");
585                 precache_model ("models/weapons/v_crylink.md3");
586                 precache_model ("models/weapons/h_crylink.iqm");
587                 precache_sound ("weapons/crylink_fire.wav");
588                 precache_sound ("weapons/crylink_fire2.wav");
589                 precache_sound ("weapons/crylink_linkjoin.wav");
590         }
591         else if (req == WR_SETUP)
592                 weapon_setup(WEP_CRYLINK);
593         else if (req == WR_CHECKAMMO1)
594         {
595                 // don't "run out of ammo" and switch weapons while waiting for release
596                 if(self.crylink_lastgroup && self.crylink_waitrelease)
597                         return TRUE;
598                 return self.ammo_cells >= autocvar_g_balance_crylink_primary_ammo;
599         }
600         else if (req == WR_CHECKAMMO2)
601         {
602                 // don't "run out of ammo" and switch weapons while waiting for release
603                 if(self.crylink_lastgroup && self.crylink_waitrelease)
604                         return TRUE;
605                 return self.ammo_cells >= autocvar_g_balance_crylink_secondary_ammo;
606         }
607         return TRUE;
608 };
609 #endif
610 #ifdef CSQC
611 float w_crylink(float req)
612 {
613         if(req == WR_IMPACTEFFECT)
614         {
615                 vector org2;
616                 org2 = w_org + w_backoff * 2;
617                 if(w_deathtype & HITTYPE_SECONDARY)
618                 {
619                         pointparticles(particleeffectnum("crylink_impact"), org2, '0 0 0', 1);
620                         if(!w_issilent)
621                                 sound(self, CHAN_PROJECTILE, "weapons/crylink_impact2.wav", VOL_BASE, ATTN_NORM);
622                 }
623                 else
624                 {
625                         pointparticles(particleeffectnum("crylink_impactbig"), org2, '0 0 0', 1);
626                         if(!w_issilent)
627                                 sound(self, CHAN_PROJECTILE, "weapons/crylink_impact.wav", VOL_BASE, ATTN_NORM);
628                 }
629         }
630         else if(req == WR_PRECACHE)
631         {
632                 precache_sound("weapons/crylink_impact2.wav");
633                 precache_sound("weapons/crylink_impact.wav");
634         }
635         else if (req == WR_SUICIDEMESSAGE)
636         {
637                 w_deathtypestring = _("%s succeeded at self-destructing themself with the Crylink");
638         }
639         else if (req == WR_KILLMESSAGE)
640         {
641                 if(w_deathtype & HITTYPE_BOUNCE)
642                         w_deathtypestring = _("%s could not hide from %s's Crylink"); // unchecked: SPLASH (SECONDARY can't be)
643                 else if(w_deathtype & HITTYPE_SPLASH)
644                         w_deathtypestring = _("%s was too close to %s's Crylink"); // unchecked: SECONDARY
645                 else
646                         w_deathtypestring = _("%s took a close look at %s's Crylink"); // unchecked: SECONDARY
647         }
648         return TRUE;
649 }
650 #endif
651 #endif