2 REGISTER_WEAPON(CRYLINK, w_crylink, IT_CELLS, 6, WEP_FLAG_NORMAL | WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "crylink", "crylink", "Crylink");
10 // force projectile to explode
11 void W_Crylink_LinkExplode (entity e, entity e2)
14 a = bound(0, 1 - (time - e.fade_time) * e.fade_rate, 1);
16 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);
19 W_Crylink_LinkExplode(e.queuenext, e2);
23 // adjust towards center
24 // returns the origin where they will meet... and the time till the meeting is
25 // stored in w_crylink_linkjoin_time.
26 // could possibly network this origin and time, and display a special particle
27 // effect when projectiles meet there :P
28 float w_crylink_linkjoin_time;
29 vector W_Crylink_LinkJoin(entity e, float joinspeed)
31 vector avg_origin, avg_velocity;
36 avg_origin = e.origin;
37 avg_velocity = e.velocity;
39 for(p = e; (p = p.queuenext) != e; )
41 avg_origin += p.origin;
42 avg_velocity += p.velocity;
45 avg_origin *= (1.0 / n);
46 avg_velocity *= (1.0 / n);
48 // yes, mathematically we can do this in ONE step, but beware of 32bit floats...
49 avg_dist = pow(vlen(e.origin - avg_origin), 2);
50 for(p = e; (p = p.queuenext) != e; )
51 avg_dist += pow(vlen(e.origin - avg_origin), 2);
52 avg_dist *= (1.0 / n);
54 w_crylink_linkjoin_time = 0;
56 return avg_origin; // no change needed
60 e.velocity = avg_velocity;
61 UpdateCSQCProjectile(e);
62 for(p = e; (p = p.queuenext) != e; )
64 p.velocity = avg_velocity;
65 UpdateCSQCProjectile(p);
70 w_crylink_linkjoin_time = avg_dist / joinspeed;
71 targ_origin = avg_origin + w_crylink_linkjoin_time * avg_velocity;
73 e.velocity = (targ_origin - e.origin) * (joinspeed / avg_dist);
74 UpdateCSQCProjectile(e);
75 for(p = e; (p = p.queuenext) != e; )
77 p.velocity = (targ_origin - p.origin) * (joinspeed / avg_dist);
78 UpdateCSQCProjectile(p);
82 // joinspeed -> +infinity:
83 // w_crylink_linkjoin_time -> +0
84 // targ_origin -> avg_origin
85 // p->velocity -> HUEG towards center
87 // w_crylink_linkjoin_time -> +/- infinity
88 // targ_origin -> avg_velocity * +/- infinity
89 // p->velocity -> avg_velocity
90 // joinspeed -> -infinity:
91 // w_crylink_linkjoin_time -> -0
92 // targ_origin -> avg_origin
93 // p->velocity -> HUEG away from center
99 // NO bounce protection, as bounces are limited!
100 void W_Crylink_Touch (void)
105 local entity savenext, saveprev;
106 savenext = self.queuenext;
107 saveprev = self.queueprev;
108 if(WarpZone_Projectile_Touch())
112 savenext.queueprev = saveprev;
113 saveprev.queuenext = savenext;
119 a = bound(0, 1 - (time - self.fade_time) * self.fade_rate, 1);
121 finalhit = ((self.cnt <= 0) || (other.takedamage != DAMAGE_NO));
125 f = cvar("g_balance_crylink_primary_bouncedamagefactor");
128 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) || finalhit)
130 W_Crylink_LinkExplode(self.queuenext, self);
134 self.cnt = self.cnt - 1;
135 self.angles = vectoangles(self.velocity);
137 self.projectiledeathtype |= HITTYPE_BOUNCE;
138 // commented out as it causes a little hitch...
140 // CSQCProjectile(proj, TRUE, PROJECTILE_CRYLINK, TRUE);
143 void W_Crylink_Touch2 (void)
148 local entity savenext, saveprev;
149 savenext = self.queuenext;
150 saveprev = self.queueprev;
151 if(WarpZone_Projectile_Touch())
155 savenext.queueprev = saveprev;
156 saveprev.queuenext = savenext;
162 a = 1 - (time - self.fade_time) * self.fade_rate;
164 finalhit = ((self.cnt <= 0) || (other.takedamage != DAMAGE_NO));
168 f = cvar("g_balance_crylink_secondary_bouncedamagefactor");
171 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))
173 W_Crylink_LinkExplode(self.queuenext, self);
180 self.queuenext.queueprev = self.queueprev;
181 self.queueprev.queuenext = self.queuenext;
185 self.cnt = self.cnt - 1;
186 self.angles = vectoangles(self.velocity);
188 self.projectiledeathtype |= HITTYPE_BOUNCE;
189 // commented out as it causes a little hitch...
191 // CSQCProjectile(proj, TRUE, PROJECTILE_CRYLINK, TRUE);
194 void W_Crylink_Fadethink (void)
196 self.queuenext.queueprev = self.queueprev;
197 self.queueprev.queuenext = self.queuenext;
201 void W_Crylink_Attack (void)
203 local float counter, shots;
204 local entity proj, prevproj, firstproj;
206 vector forward, right, up;
208 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
209 self.ammo_cells = self.ammo_cells - cvar("g_balance_crylink_primary_ammo");
211 W_SetupShot (self, FALSE, 2, "weapons/crylink_fire.wav", (cvar("g_balance_crylink_primary_damage")*cvar("g_balance_crylink_primary_shots")));
216 shots = cvar("g_balance_crylink_primary_shots");
217 pointparticles(particleeffectnum("crylink_muzzleflash"), w_shotorg, w_shotdir * 1000, shots);
218 while (counter < shots)
221 proj.realowner = proj.owner = self;
222 proj.classname = "spike";
223 proj.bot_dodge = TRUE;
224 proj.bot_dodgerating = cvar("g_balance_crylink_primary_damage");
225 if(counter == 0) { // first projectile, store in firstproj for now
228 else if(counter == shots - 1) { // last projectile, link up with first projectile
229 prevproj.queuenext = proj;
230 firstproj.queueprev = proj;
231 proj.queuenext = firstproj;
232 proj.queueprev = prevproj;
234 else { // else link up with previous projectile
235 prevproj.queuenext = proj;
236 proj.queueprev = prevproj;
241 proj.movetype = MOVETYPE_BOUNCEMISSILE;
242 PROJECTILE_MAKETRIGGER(proj);
243 proj.projectiledeathtype = WEP_CRYLINK;
244 //proj.gravity = 0.001;
246 setorigin (proj, w_shotorg);
247 setsize(proj, '0 0 0', '0 0 0');
255 makevectors('0 360 0' * (0.75 + (counter - 0.5) / (shots - 1)));
259 s = s * cvar("g_balance_crylink_primary_spread") * g_weaponspreadfactor;
260 W_SetupProjectileVelocityEx(proj, w_shotdir + right * s_y + up * s_z, v_up, cvar("g_balance_crylink_primary_speed"), 0, 0, 0);
261 proj.touch = W_Crylink_Touch;
263 proj.think = W_Crylink_Fadethink;
266 proj.fade_time = time + cvar("g_balance_crylink_primary_middle_lifetime");
267 self.fade_rate = 1 / cvar("g_balance_crylink_primary_middle_fadetime");
268 proj.nextthink = time + cvar("g_balance_crylink_primary_middle_lifetime") + cvar("g_balance_crylink_primary_middle_fadetime");
270 else if(counter <= 3)
272 proj.fade_time = time + cvar("g_balance_crylink_primary_star_lifetime");
273 self.fade_rate = 1 / cvar("g_balance_crylink_primary_star_fadetime");
274 proj.nextthink = time + cvar("g_balance_crylink_primary_star_lifetime") + cvar("g_balance_crylink_primary_star_fadetime");
278 proj.fade_time = time + cvar("g_balance_crylink_primary_other_lifetime");
279 self.fade_rate = 1 / cvar("g_balance_crylink_primary_other_fadetime");
280 proj.nextthink = time + cvar("g_balance_crylink_primary_other_lifetime") + cvar("g_balance_crylink_primary_other_fadetime");
282 proj.cnt = cvar("g_balance_crylink_primary_bounces");
283 //proj.scale = 1 + 1 * proj.cnt;
285 proj.angles = vectoangles (proj.velocity);
287 //proj.glow_size = 20;
289 proj.flags = FL_PROJECTILE;
291 CSQCProjectile(proj, TRUE, (proj.cnt ? PROJECTILE_CRYLINK_BOUNCING : PROJECTILE_CRYLINK), TRUE);
293 other = proj; MUTATOR_CALLHOOK(EditProjectile);
295 counter = counter + 1;
299 void W_Crylink_Attack2 (void)
301 local float counter, shots;
302 local entity proj, prevproj, firstproj;
304 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
305 self.ammo_cells = self.ammo_cells - cvar("g_balance_crylink_secondary_ammo");
307 W_SetupShot (self, FALSE, 2, "weapons/crylink_fire2.wav", (cvar("g_balance_crylink_secondary_damage")*cvar("g_balance_crylink_secondary_shots")));
309 shots = cvar("g_balance_crylink_secondary_shots");
310 pointparticles(particleeffectnum("crylink_muzzleflash"), w_shotorg, w_shotdir * 1000, shots);
311 while (counter < shots)
314 proj.realowner = proj.owner = self;
315 proj.classname = "spike";
316 proj.bot_dodge = TRUE;
317 proj.bot_dodgerating = cvar("g_balance_crylink_secondary_damage");
318 if(counter == 0) { // first projectile, store in firstproj for now
321 else if(counter == shots - 1) { // last projectile, link up with first projectile
322 prevproj.queuenext = proj;
323 firstproj.queueprev = proj;
324 proj.queuenext = firstproj;
325 proj.queueprev = prevproj;
327 else { // else link up with previous projectile
328 prevproj.queuenext = proj;
329 proj.queueprev = prevproj;
334 proj.movetype = MOVETYPE_BOUNCEMISSILE;
335 PROJECTILE_MAKETRIGGER(proj);
336 proj.projectiledeathtype = WEP_CRYLINK | HITTYPE_SECONDARY;
337 //proj.gravity = 0.001;
339 setorigin (proj, w_shotorg);
340 setsize(proj, '0 0 0', '0 0 0');
342 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);
343 proj.touch = W_Crylink_Touch2;
344 proj.think = W_Crylink_Fadethink;
345 if(counter == (shots - 1) / 2)
347 proj.fade_time = time + cvar("g_balance_crylink_secondary_middle_lifetime");
348 self.fade_rate = 1 / cvar("g_balance_crylink_secondary_middle_fadetime");
349 proj.nextthink = time + cvar("g_balance_crylink_secondary_middle_lifetime") + cvar("g_balance_crylink_secondary_middle_fadetime");
353 proj.fade_time = time + cvar("g_balance_crylink_secondary_line_lifetime");
354 self.fade_rate = 1 / cvar("g_balance_crylink_secondary_line_fadetime");
355 proj.nextthink = time + cvar("g_balance_crylink_secondary_line_lifetime") + cvar("g_balance_crylink_secondary_line_fadetime");
357 proj.cnt = cvar("g_balance_crylink_secondary_bounces");
358 //proj.scale = 1 + 1 * proj.cnt;
360 proj.angles = vectoangles (proj.velocity);
362 //proj.glow_size = 20;
364 proj.flags = FL_PROJECTILE;
366 CSQCProjectile(proj, TRUE, (proj.cnt ? PROJECTILE_CRYLINK_BOUNCING : PROJECTILE_CRYLINK), TRUE);
368 other = proj; MUTATOR_CALLHOOK(EditProjectile);
370 counter = counter + 1;
374 void spawnfunc_weapon_crylink (void)
376 weapon_defaultspawnfunc(WEP_CRYLINK);
379 float w_crylink(float req)
384 self.BUTTON_ATCK = bot_aim(cvar("g_balance_crylink_primary_speed"), 0, cvar("g_balance_crylink_primary_middle_lifetime"), FALSE);
386 self.BUTTON_ATCK2 = bot_aim(cvar("g_balance_crylink_secondary_speed"), 0, cvar("g_balance_crylink_secondary_middle_lifetime"), FALSE);
388 else if (req == WR_THINK)
390 if (self.BUTTON_ATCK)
391 if (weapon_prepareattack(0, cvar("g_balance_crylink_primary_refire")))
394 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_crylink_primary_animtime"), w_ready);
396 if (self.BUTTON_ATCK2 && cvar("g_balance_crylink_secondary"))
397 if (weapon_prepareattack(1, cvar("g_balance_crylink_secondary_refire")))
400 weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_crylink_secondary_animtime"), w_ready);
403 else if (req == WR_PRECACHE)
405 precache_model ("models/weapons/g_crylink.md3");
406 precache_model ("models/weapons/v_crylink.md3");
407 precache_model ("models/weapons/h_crylink.iqm");
408 precache_sound ("weapons/crylink_fire.wav");
409 precache_sound ("weapons/crylink_fire2.wav");
411 else if (req == WR_SETUP)
412 weapon_setup(WEP_CRYLINK);
413 else if (req == WR_CHECKAMMO1)
414 return self.ammo_cells >= cvar("g_balance_crylink_primary_ammo");
415 else if (req == WR_CHECKAMMO2)
416 return self.ammo_cells >= cvar("g_balance_crylink_secondary_ammo");
421 float w_crylink(float req)
423 if(req == WR_IMPACTEFFECT)
426 org2 = w_org + w_backoff * 2;
427 if(w_deathtype & HITTYPE_SECONDARY)
429 pointparticles(particleeffectnum("crylink_impact"), org2, '0 0 0', 1);
431 sound(self, CHAN_PROJECTILE, "weapons/crylink_impact2.wav", VOL_BASE, ATTN_NORM);
435 pointparticles(particleeffectnum("crylink_impactbig"), org2, '0 0 0', 1);
437 sound(self, CHAN_PROJECTILE, "weapons/crylink_impact.wav", VOL_BASE, ATTN_NORM);
440 else if(req == WR_PRECACHE)
442 precache_sound("weapons/crylink_impact2.wav");
443 precache_sound("weapons/crylink_impact.wav");
445 else if (req == WR_SUICIDEMESSAGE)
447 w_deathtypestring = "%s succeeded at self-destructing themself with the Crylink";
449 else if (req == WR_KILLMESSAGE)
451 if(w_deathtype & HITTYPE_BOUNCE)
452 w_deathtypestring = "%s could not hide from %s's Crylink"; // unchecked: SPLASH (SECONDARY can't be)
453 else if(w_deathtype & HITTYPE_SPLASH)
454 w_deathtypestring = "%s was too close to %s's Crylink"; // unchecked: SECONDARY
456 w_deathtypestring = "%s took a close look at %s's Crylink"; // unchecked: SECONDARY