2 REGISTER_WEAPON(SEEKER, w_seeker, IT_ROCKETS, 8, WEP_FLAG_NORMAL | WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "seeker", "seeker", _("T.A.G. Seeker"))
5 //.float proxytime; = autoswitch
8 void W_Seeker_SetAmmoCounter()
10 // set clip_load to the weapon we have switched to, if the gun uses reloading
11 if(!autocvar_g_balance_seeker_reload_ammo)
12 self.clip_load = 0; // also keeps crosshair ammo from displaying
15 self.clip_load = self.seeker_load;
16 self.clip_size = autocvar_g_balance_seeker_reload_ammo; // for the crosshair ammo display
20 void W_Seeker_ReloadedAndReady()
24 // now do the ammo transfer
25 self.clip_load = self.old_clip_load; // restore the ammo counter, in case we still had ammo in the weapon before reloading
26 while(self.clip_load < autocvar_g_balance_seeker_reload_ammo && self.ammo_rockets) // make sure we don't add more ammo than we have
29 self.ammo_rockets -= 1;
31 self.seeker_load = self.clip_load;
33 t = ATTACK_FINISHED(self) - autocvar_g_balance_seeker_reload_time - 1;
34 ATTACK_FINISHED(self) = t;
38 void W_Seeker_Reload()
40 // return if reloading is disabled for this weapon
41 if(!autocvar_g_balance_seeker_reload_ammo)
44 if(!W_ReloadCheck(self.ammo_rockets, min(autocvar_g_balance_seeker_missile_ammo, autocvar_g_balance_seeker_tag_ammo)))
49 sound (self, CHAN_WEAPON2, "weapons/reload.wav", VOL_BASE, ATTN_NORM);
51 t = max(time, ATTACK_FINISHED(self)) + autocvar_g_balance_seeker_reload_time + 1;
52 ATTACK_FINISHED(self) = t;
54 weapon_thinkf(WFRAME_RELOAD, autocvar_g_balance_seeker_reload_time, W_Seeker_ReloadedAndReady);
56 self.old_clip_load = self.clip_load;
60 void Seeker_Missile_Explode ()
62 self.event_damage = SUB_Null;
63 RadiusDamage (self, self.owner, autocvar_g_balance_seeker_missile_damage, autocvar_g_balance_seeker_missile_edgedamage, autocvar_g_balance_seeker_missile_radius, world, autocvar_g_balance_seeker_missile_force, self.projectiledeathtype, other);
68 void Seeker_Missile_Touch()
72 Seeker_Missile_Explode();
75 void Seeker_Missile_Think()
78 vector desireddir, olddir, newdir, eorg;
85 self.projectiledeathtype |= HITTYPE_SPLASH;
86 Seeker_Missile_Explode();
89 spd = vlen(self.velocity);
91 spd - autocvar_g_balance_seeker_missile_decel * frametime,
92 autocvar_g_balance_seeker_missile_speed_max,
93 spd + autocvar_g_balance_seeker_missile_accel * frametime
96 if (self.enemy != world)
97 if (self.enemy.takedamage != DAMAGE_AIM || self.enemy.deadflag != DEAD_NO)
100 if (self.enemy != world)
103 eorg = 0.5 * (e.absmin + e.absmax);
104 turnrate = autocvar_g_balance_seeker_missile_turnrate; // how fast to turn
105 desireddir = normalize(eorg - self.origin);
106 olddir = normalize(self.velocity); // get my current direction
107 dist = vlen(eorg - self.origin);
109 // Do evasive maneuvers for world objects? ( this should be a cpu hog. :P )
110 if (autocvar_g_balance_seeker_missile_smart && (dist > autocvar_g_balance_seeker_missile_smart_mindist))
112 // Is it a better idea (shorter distance) to trace to the target itself?
113 if ( vlen(self.origin + olddir * self.wait) < dist)
114 traceline(self.origin, self.origin + olddir * self.wait, FALSE, self);
116 traceline(self.origin, eorg, FALSE, self);
118 // Setup adaptive tracelength
119 self.wait = bound(autocvar_g_balance_seeker_missile_smart_trace_min, vlen(self.origin - trace_endpos), self.wait = autocvar_g_balance_seeker_missile_smart_trace_max);
121 // Calc how important it is that we turn and add this to the desierd (enemy) dir.
122 desireddir = normalize(((trace_plane_normal * (1 - trace_fraction)) + (desireddir * trace_fraction)) * 0.5);
125 newdir = normalize(olddir + desireddir * turnrate); // take the average of the 2 directions; not the best method but simple & easy
126 self.velocity = newdir * spd; // make me fly in the new direction at my flight speed
130 if (autocvar_g_balance_seeker_missile_proxy)
132 if ( dist <= autocvar_g_balance_seeker_missile_proxy_maxrange)
134 if (self.autoswitch == 0)
136 self.autoswitch = time + autocvar_g_balance_seeker_missile_proxy_delay;
140 if (self.autoswitch <= time)
142 Seeker_Missile_Explode();
149 if (self.autoswitch != 0)
155 if (self.enemy.deadflag != DEAD_NO)
158 self.cnt = time + 1 + (random() * 4);
159 self.nextthink = self.cnt;
163 //self.angles = vectoangles(self.velocity); // turn model in the new flight direction
164 self.nextthink = time;// + 0.05; // csqc projectiles
165 UpdateCSQCProjectile(self);
170 void Seeker_Missile_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
172 if (self.health <= 0)
175 if (self.owner == attacker)
176 self.health = self.health - (damage * 0.25);
178 self.health = self.health - damage;
180 if (self.health <= 0)
181 W_PrepareExplosionByDamage(attacker, Seeker_Missile_Explode);
185 void Seeker_Missile_Animate()
187 self.frame = self.frame +1;
188 self.nextthink = time + 0.05;
190 if (self.enemy != world)
191 if (self.enemy.takedamage != DAMAGE_AIM || self.enemy.deadflag != DEAD_NO)
196 self.think = Seeker_Missile_Think;
197 self.nextthink = time;// + cvar("g_balance_seeker_missile_activate_delay"); // cant dealy with csqc projectiles
199 if (autocvar_g_balance_seeker_missile_proxy)
200 self.movetype = MOVETYPE_BOUNCEMISSILE;
202 self.movetype = MOVETYPE_FLYMISSILE;
205 UpdateCSQCProjectile(self);
209 void Seeker_Fire_Missile(vector f_diff)
211 local entity missile;
213 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
214 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
216 if(autocvar_g_balance_seeker_reload_ammo)
218 self.clip_load -= autocvar_g_balance_seeker_missile_ammo;
219 self.seeker_load = self.clip_load;
222 self.ammo_rockets -= autocvar_g_balance_seeker_missile_ammo;
225 makevectors(self.v_angle);
226 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/seeker_fire.wav", CHAN_WEAPON, 0);
228 pointparticles(particleeffectnum("seeker_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
230 //self.detornator = FALSE;
233 missile.owner = self;
234 missile.classname = "seeker_missile";
235 missile.bot_dodge = TRUE;
236 missile.bot_dodgerating = autocvar_g_balance_seeker_missile_damage;
238 missile.think = Seeker_Missile_Think;
239 missile.touch = Seeker_Missile_Touch;
240 missile.event_damage = Seeker_Missile_Damage;
241 missile.nextthink = time;// + 0.2;// + cvar("g_balance_seeker_missile_activate_delay");
242 missile.cnt = time + autocvar_g_balance_seeker_missile_lifetime;
243 missile.enemy = self.enemy;
244 missile.solid = SOLID_BBOX;
246 missile.takedamage = DAMAGE_YES;
247 missile.health = autocvar_g_balance_seeker_missile_health;
248 missile.damageforcescale = autocvar_g_balance_seeker_missile_damageforcescale;
249 missile.projectiledeathtype = WEP_SEEKER;
250 //missile.think = Seeker_Missile_Animate; // csqc projectiles.
253 setorigin (missile, w_shotorg);
254 setsize (missile, '-4 -4 -4', '4 4 4');
255 missile.movetype = MOVETYPE_FLYMISSILE;
256 missile.flags = FL_PROJECTILE;
257 W_SETUPPROJECTILEVELOCITY_UP(missile, g_balance_seeker_missile);
259 missile.angles = vectoangles (missile.velocity);
261 CSQCProjectile(missile, FALSE, PROJECTILE_SEEKER, TRUE);
263 other = missile; MUTATOR_CALLHOOK(EditProjectile);
266 void Seeker_Vollycontroler_Think()
269 entity oldself,oldenemy;
270 self.cnt = self.cnt - 1;
272 if((!(self.owner.items & IT_UNLIMITED_AMMO) && self.owner.ammo_rockets < autocvar_g_balance_seeker_missile_ammo) || (self.cnt <= -1) || (self.owner.deadflag != DEAD_NO) || (self.owner.switchweapon != WEP_SEEKER))
278 self.nextthink = time + autocvar_g_balance_seeker_missile_delay;
283 oldenemy = self.enemy;
284 self.enemy = oldself.enemy;
286 c = mod(oldself.cnt, 4);
290 Seeker_Fire_Missile('-1.25 -3.75 0');
293 Seeker_Fire_Missile('+1.25 -3.75 0');
296 Seeker_Fire_Missile('-1.25 +3.75 0');
300 Seeker_Fire_Missile('+1.25 +3.75 0');
304 self.enemy = oldenemy;
308 void Seeker_Tag_Explode ()
310 //if(other==self.owner)
312 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_BOUNCE, self);
317 void Seeker_Tag_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
319 if (self.health <= 0)
321 self.health = self.health - damage;
322 if (self.health <= 0)
323 Seeker_Tag_Explode();
327 void Seeker_Tag_Touch()
333 dir = normalize (self.owner.origin - self.origin);
334 org2 = findbetterlocation (self.origin, 8);
336 te_knightspike(org2);
338 self.event_damage = SUB_Null;
339 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_HEADSHOT, self);
341 if (other.takedamage == DAMAGE_AIM && other.deadflag == DEAD_NO)
344 e.cnt = autocvar_g_balance_seeker_missile_count;
345 e.owner = self.owner;
347 e.think = Seeker_Vollycontroler_Think;
355 void Seeker_Fire_Tag()
357 local entity missile;
358 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
359 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
361 if(autocvar_g_balance_seeker_reload_ammo)
363 self.clip_load -= autocvar_g_balance_seeker_tag_ammo;
364 self.seeker_load = self.clip_load;
367 self.ammo_rockets -= autocvar_g_balance_seeker_tag_ammo;
370 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/tag_fire.wav", CHAN_WEAPON, autocvar_g_balance_seeker_missile_damage * autocvar_g_balance_seeker_missile_count);
373 missile.owner = self;
374 missile.classname = "seeker_tag";
375 missile.bot_dodge = TRUE;
376 missile.bot_dodgerating = 50;
377 missile.touch = Seeker_Tag_Touch;
378 missile.think = SUB_Remove;
379 missile.nextthink = time + autocvar_g_balance_seeker_tag_lifetime;
380 missile.movetype = MOVETYPE_FLY;
381 missile.solid = SOLID_BBOX;
382 missile.owner = self;
384 missile.takedamage = DAMAGE_YES;
385 missile.event_damage = Seeker_Tag_Explode;
386 missile.health = autocvar_g_balance_seeker_tag_health;
387 missile.damageforcescale = autocvar_g_balance_seeker_tag_damageforcescale;
389 setorigin (missile, w_shotorg);
390 setsize (missile, '-2 -2 -2', '2 2 2');
392 missile.flags = FL_PROJECTILE;
394 missile.movetype = MOVETYPE_FLY;
395 W_SETUPPROJECTILEVELOCITY(missile, g_balance_seeker_tag);
396 missile.angles = vectoangles (missile.velocity);
398 CSQCProjectile(missile, TRUE, PROJECTILE_TAG, FALSE); // has sound
400 other = missile; MUTATOR_CALLHOOK(EditProjectile);
404 void Seeker_Flac_Explode ()
406 self.event_damage = SUB_Null;
408 RadiusDamage (self, self.owner, autocvar_g_balance_seeker_flac_damage, autocvar_g_balance_seeker_flac_edgedamage, autocvar_g_balance_seeker_flac_radius, world, autocvar_g_balance_seeker_flac_force, self.projectiledeathtype, other);
413 void Seeker_Flac_Touch()
417 Seeker_Flac_Explode();
420 void Seeker_Fire_Flac()
422 local entity missile;
426 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
427 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
429 if(autocvar_g_balance_seeker_reload_ammo)
431 self.clip_load -= autocvar_g_balance_seeker_flac_ammo;
432 self.seeker_load = self.clip_load;
435 self.ammo_rockets -= autocvar_g_balance_seeker_flac_ammo;
438 c = mod(self.bulletcounter, 4);
442 f_diff = '-1.25 -3.75 0';
445 f_diff = '+1.25 -3.75 0';
448 f_diff = '-1.25 +3.75 0';
452 f_diff = '+1.25 +3.75 0';
455 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/flac_fire.wav", CHAN_WEAPON, autocvar_g_balance_seeker_flac_damage);
458 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
461 missile.owner = missile.realowner = self;
462 missile.classname = "missile";
463 missile.bot_dodge = TRUE;
464 missile.bot_dodgerating = autocvar_g_balance_seeker_flac_damage;
465 missile.touch = Seeker_Flac_Explode;
466 missile.use = Seeker_Flac_Explode;
467 missile.think = adaptor_think2use_hittype_splash;
468 missile.nextthink = time + autocvar_g_balance_seeker_flac_lifetime + autocvar_g_balance_seeker_flac_lifetime_rand;
469 missile.solid = SOLID_BBOX;
470 missile.movetype = MOVETYPE_FLY;
471 missile.projectiledeathtype = WEP_SEEKER;
472 missile.projectiledeathtype = WEP_SEEKER | HITTYPE_SECONDARY;
473 missile.flags = FL_PROJECTILE;
476 //missile.angles = vectoangles (missile.velocity);
477 //missile.scale = 0.4; // BUG: the model is too big
479 setorigin (missile, w_shotorg);
480 setsize (missile, '-2 -2 -2', '2 2 2');
482 W_SETUPPROJECTILEVELOCITY_UP(missile, g_balance_seeker_flac);
483 CSQCProjectile(missile, TRUE, PROJECTILE_FLAC, TRUE);
485 other = missile; MUTATOR_CALLHOOK(EditProjectile);
488 void spawnfunc_weapon_seeker (void)
490 weapon_defaultspawnfunc(WEP_SEEKER);
493 float w_seeker(float req)
496 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_seeker_tag_speed, 0, 20, FALSE);
498 else if (req == WR_THINK)
500 if(autocvar_g_balance_seeker_reload_ammo && self.clip_load < min(autocvar_g_balance_seeker_missile_ammo, autocvar_g_balance_seeker_tag_ammo)) // forced reload
503 else if (self.BUTTON_ATCK)
505 if (weapon_prepareattack(0, autocvar_g_balance_seeker_tag_refire))
508 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_seeker_tag_animtime, w_ready);
512 else if (self.BUTTON_ATCK2)
514 if (weapon_prepareattack(1, autocvar_g_balance_seeker_flac_refire))
517 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_seeker_flac_animtime, w_ready);
523 if(self.switchweapon == self.weapon)
525 if(self.weaponentity.state == WS_READY)
527 self.wish_reload = 0;
533 else if (req == WR_PRECACHE)
535 precache_model ("models/weapons/g_seeker.md3");
536 precache_model ("models/weapons/v_seeker.md3");
537 precache_model ("models/weapons/h_seeker.iqm");
538 precache_sound ("weapons/tag_fire.wav");
539 precache_sound ("weapons/flac_fire.wav");
540 precache_sound ("weapons/seeker_fire.wav");
541 precache_sound ("weapons/reload.wav");
543 else if (req == WR_SETUP)
545 weapon_setup(WEP_SEEKER);
546 W_Seeker_SetAmmoCounter();
548 else if (req == WR_CHECKAMMO1)
550 if(autocvar_g_balance_seeker_reload_ammo)
551 return self.clip_load >= autocvar_g_balance_seeker_tag_ammo + autocvar_g_balance_seeker_missile_ammo;
553 return self.ammo_rockets >= autocvar_g_balance_seeker_tag_ammo + autocvar_g_balance_seeker_missile_ammo;
555 else if (req == WR_CHECKAMMO2)
557 if(autocvar_g_balance_seeker_reload_ammo)
558 return self.clip_load >= autocvar_g_balance_seeker_flac_ammo;
560 return self.ammo_rockets >= autocvar_g_balance_seeker_flac_ammo;
562 else if (req == WR_RELOAD)
570 float w_seeker(float req)
572 if(req == WR_IMPACTEFFECT)
575 org2 = w_org + w_backoff * 6;
576 if(w_deathtype & HITTYPE_SECONDARY)
578 pointparticles(particleeffectnum("flac_explode"), org2, '0 0 0', 1);
582 sound(self, CHAN_PROJECTILE, "weapons/flacexp1.wav", 1, ATTN_NORM);
583 else if (w_random<0.7)
584 sound(self, CHAN_PROJECTILE, "weapons/flacexp2.wav", 1, ATTN_NORM);
586 sound(self, CHAN_PROJECTILE, "weapons/flacexp3.wav", 1, ATTN_NORM);
591 if(w_deathtype & HITTYPE_BOUNCE)
593 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
597 sound(self, CHAN_PROJECTILE, "weapons/tagexp1.wav", 1, ATTN_NORM);
598 else if (w_random<0.7)
599 sound(self, CHAN_PROJECTILE, "weapons/tagexp2.wav", 1, ATTN_NORM);
601 sound(self, CHAN_PROJECTILE, "weapons/tagexp3.wav", 1, ATTN_NORM);
604 else if(w_deathtype & HITTYPE_HEADSHOT)
607 sound(self, CHAN_PROJECTILE, "weapons/tag_impact.wav", 1, ATTN_NORM);
611 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
615 sound(self, CHAN_PROJECTILE, "weapons/seekerexp1.wav", 1, ATTN_NORM);
616 else if (w_random<0.7)
617 sound(self, CHAN_PROJECTILE, "weapons/seekerexp2.wav", 1, ATTN_NORM);
619 sound(self, CHAN_PROJECTILE, "weapons/seekerexp3.wav", 1, ATTN_NORM);
624 else if(req == WR_PRECACHE)
626 precache_sound("weapons/flacexp1.wav");
627 precache_sound("weapons/flacexp2.wav");
628 precache_sound("weapons/flacexp3.wav");
629 precache_sound("weapons/seekerexp1.wav");
630 precache_sound("weapons/seekerexp2.wav");
631 precache_sound("weapons/seekerexp3.wav");
632 precache_sound("weapons/tagexp1.wav");
633 precache_sound("weapons/tagexp2.wav");
634 precache_sound("weapons/tagexp3.wav");
635 precache_sound("weapons/tag_impact.wav");
637 else if (req == WR_SUICIDEMESSAGE)
638 w_deathtypestring = "%s played with tiny rockets";
639 else if (req == WR_KILLMESSAGE)
641 if(w_deathtype & HITTYPE_SECONDARY)
642 w_deathtypestring = "%s ran into %s's flac";
644 w_deathtypestring = "%s was tagged by %s";