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 // weapon load persistence, for weapons that support reloading
11 void W_Seeker_SetAmmoCounter()
13 // set clip_load to the weapon we have switched to, if the gun uses reloading
14 if(!autocvar_g_balance_seeker_reload_ammo)
15 self.clip_load = 0; // also keeps crosshair ammo from displaying
18 self.clip_load = self.seeker_load;
19 self.clip_size = autocvar_g_balance_seeker_reload_ammo; // for the crosshair ammo display
23 void W_Seeker_ReloadedAndReady()
27 // now do the ammo transfer
28 self.clip_load = self.old_clip_load; // restore the ammo counter, in case we still had ammo in the weapon before reloading
29 while(self.clip_load < autocvar_g_balance_seeker_reload_ammo && self.ammo_rockets) // make sure we don't add more ammo than we have
32 self.ammo_rockets -= 1;
34 self.seeker_load = self.clip_load;
36 t = ATTACK_FINISHED(self) - autocvar_g_balance_seeker_reload_time - 1;
37 ATTACK_FINISHED(self) = t;
41 void W_Seeker_Reload()
43 // return if reloading is disabled for this weapon
44 if(!autocvar_g_balance_seeker_reload_ammo)
47 if(!W_ReloadCheck(self.ammo_rockets, min(autocvar_g_balance_seeker_missile_ammo, autocvar_g_balance_seeker_tag_ammo)))
52 sound (self, CHAN_WEAPON2, "weapons/reload.wav", VOL_BASE, ATTN_NORM);
54 t = max(time, ATTACK_FINISHED(self)) + autocvar_g_balance_seeker_reload_time + 1;
55 ATTACK_FINISHED(self) = t;
57 weapon_thinkf(WFRAME_RELOAD, autocvar_g_balance_seeker_reload_time, W_Seeker_ReloadedAndReady);
59 self.old_clip_load = self.clip_load;
63 void Seeker_Missile_Explode ()
65 self.event_damage = SUB_Null;
66 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);
71 void Seeker_Missile_Touch()
75 Seeker_Missile_Explode();
78 void Seeker_Missile_Think()
81 vector desireddir, olddir, newdir, eorg;
88 self.projectiledeathtype |= HITTYPE_SPLASH;
89 Seeker_Missile_Explode();
92 spd = vlen(self.velocity);
94 spd - autocvar_g_balance_seeker_missile_decel * frametime,
95 autocvar_g_balance_seeker_missile_speed_max,
96 spd + autocvar_g_balance_seeker_missile_accel * frametime
99 if (self.enemy != world)
100 if (self.enemy.takedamage != DAMAGE_AIM || self.enemy.deadflag != DEAD_NO)
103 if (self.enemy != world)
106 eorg = 0.5 * (e.absmin + e.absmax);
107 turnrate = autocvar_g_balance_seeker_missile_turnrate; // how fast to turn
108 desireddir = normalize(eorg - self.origin);
109 olddir = normalize(self.velocity); // get my current direction
110 dist = vlen(eorg - self.origin);
112 // Do evasive maneuvers for world objects? ( this should be a cpu hog. :P )
113 if (autocvar_g_balance_seeker_missile_smart && (dist > autocvar_g_balance_seeker_missile_smart_mindist))
115 // Is it a better idea (shorter distance) to trace to the target itself?
116 if ( vlen(self.origin + olddir * self.wait) < dist)
117 traceline(self.origin, self.origin + olddir * self.wait, FALSE, self);
119 traceline(self.origin, eorg, FALSE, self);
121 // Setup adaptive tracelength
122 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);
124 // Calc how important it is that we turn and add this to the desierd (enemy) dir.
125 desireddir = normalize(((trace_plane_normal * (1 - trace_fraction)) + (desireddir * trace_fraction)) * 0.5);
128 newdir = normalize(olddir + desireddir * turnrate); // take the average of the 2 directions; not the best method but simple & easy
129 self.velocity = newdir * spd; // make me fly in the new direction at my flight speed
133 if (autocvar_g_balance_seeker_missile_proxy)
135 if ( dist <= autocvar_g_balance_seeker_missile_proxy_maxrange)
137 if (self.autoswitch == 0)
139 self.autoswitch = time + autocvar_g_balance_seeker_missile_proxy_delay;
143 if (self.autoswitch <= time)
145 Seeker_Missile_Explode();
152 if (self.autoswitch != 0)
158 if (self.enemy.deadflag != DEAD_NO)
161 self.cnt = time + 1 + (random() * 4);
162 self.nextthink = self.cnt;
166 //self.angles = vectoangles(self.velocity); // turn model in the new flight direction
167 self.nextthink = time;// + 0.05; // csqc projectiles
168 UpdateCSQCProjectile(self);
173 void Seeker_Missile_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
175 if (self.health <= 0)
178 if (self.owner == attacker)
179 self.health = self.health - (damage * 0.25);
181 self.health = self.health - damage;
183 if (self.health <= 0)
184 W_PrepareExplosionByDamage(attacker, Seeker_Missile_Explode);
188 void Seeker_Missile_Animate()
190 self.frame = self.frame +1;
191 self.nextthink = time + 0.05;
193 if (self.enemy != world)
194 if (self.enemy.takedamage != DAMAGE_AIM || self.enemy.deadflag != DEAD_NO)
199 self.think = Seeker_Missile_Think;
200 self.nextthink = time;// + cvar("g_balance_seeker_missile_activate_delay"); // cant dealy with csqc projectiles
202 if (autocvar_g_balance_seeker_missile_proxy)
203 self.movetype = MOVETYPE_BOUNCEMISSILE;
205 self.movetype = MOVETYPE_FLYMISSILE;
208 UpdateCSQCProjectile(self);
212 void Seeker_Fire_Missile(vector f_diff)
214 local entity missile;
216 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
217 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
219 if(autocvar_g_balance_seeker_reload_ammo)
221 self.clip_load -= autocvar_g_balance_seeker_missile_ammo;
222 self.seeker_load = self.clip_load;
225 self.ammo_rockets -= autocvar_g_balance_seeker_missile_ammo;
228 makevectors(self.v_angle);
229 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/seeker_fire.wav", CHAN_WEAPON, 0);
231 pointparticles(particleeffectnum("seeker_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
233 //self.detornator = FALSE;
236 missile.owner = self;
237 missile.classname = "seeker_missile";
238 missile.bot_dodge = TRUE;
239 missile.bot_dodgerating = autocvar_g_balance_seeker_missile_damage;
241 missile.think = Seeker_Missile_Think;
242 missile.touch = Seeker_Missile_Touch;
243 missile.event_damage = Seeker_Missile_Damage;
244 missile.nextthink = time;// + 0.2;// + cvar("g_balance_seeker_missile_activate_delay");
245 missile.cnt = time + autocvar_g_balance_seeker_missile_lifetime;
246 missile.enemy = self.enemy;
247 missile.solid = SOLID_BBOX;
249 missile.takedamage = DAMAGE_YES;
250 missile.health = autocvar_g_balance_seeker_missile_health;
251 missile.damageforcescale = autocvar_g_balance_seeker_missile_damageforcescale;
252 missile.projectiledeathtype = WEP_SEEKER;
253 //missile.think = Seeker_Missile_Animate; // csqc projectiles.
256 setorigin (missile, w_shotorg);
257 setsize (missile, '-4 -4 -4', '4 4 4');
258 missile.movetype = MOVETYPE_FLYMISSILE;
259 missile.flags = FL_PROJECTILE;
260 W_SETUPPROJECTILEVELOCITY_UP(missile, g_balance_seeker_missile);
262 missile.angles = vectoangles (missile.velocity);
264 CSQCProjectile(missile, FALSE, PROJECTILE_SEEKER, TRUE);
266 other = missile; MUTATOR_CALLHOOK(EditProjectile);
269 void Seeker_Vollycontroler_Think()
272 entity oldself,oldenemy;
273 self.cnt = self.cnt - 1;
275 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))
281 self.nextthink = time + autocvar_g_balance_seeker_missile_delay;
286 oldenemy = self.enemy;
287 self.enemy = oldself.enemy;
289 c = mod(oldself.cnt, 4);
293 Seeker_Fire_Missile('-1.25 -3.75 0');
296 Seeker_Fire_Missile('+1.25 -3.75 0');
299 Seeker_Fire_Missile('-1.25 +3.75 0');
303 Seeker_Fire_Missile('+1.25 +3.75 0');
307 self.enemy = oldenemy;
311 void Seeker_Tag_Explode ()
313 //if(other==self.owner)
315 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_BOUNCE, self);
320 void Seeker_Tag_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
322 if (self.health <= 0)
324 self.health = self.health - damage;
325 if (self.health <= 0)
326 Seeker_Tag_Explode();
330 void Seeker_Tag_Touch()
336 dir = normalize (self.owner.origin - self.origin);
337 org2 = findbetterlocation (self.origin, 8);
339 te_knightspike(org2);
341 self.event_damage = SUB_Null;
342 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_HEADSHOT, self);
344 if (other.takedamage == DAMAGE_AIM && other.deadflag == DEAD_NO)
347 e.cnt = autocvar_g_balance_seeker_missile_count;
348 e.owner = self.owner;
350 e.think = Seeker_Vollycontroler_Think;
358 void Seeker_Fire_Tag()
360 local entity missile;
361 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
362 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
364 if(autocvar_g_balance_seeker_reload_ammo)
366 self.clip_load -= autocvar_g_balance_seeker_tag_ammo;
367 self.seeker_load = self.clip_load;
370 self.ammo_rockets -= autocvar_g_balance_seeker_tag_ammo;
373 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);
376 missile.owner = self;
377 missile.classname = "seeker_tag";
378 missile.bot_dodge = TRUE;
379 missile.bot_dodgerating = 50;
380 missile.touch = Seeker_Tag_Touch;
381 missile.think = SUB_Remove;
382 missile.nextthink = time + autocvar_g_balance_seeker_tag_lifetime;
383 missile.movetype = MOVETYPE_FLY;
384 missile.solid = SOLID_BBOX;
385 missile.owner = self;
387 missile.takedamage = DAMAGE_YES;
388 missile.event_damage = Seeker_Tag_Explode;
389 missile.health = autocvar_g_balance_seeker_tag_health;
390 missile.damageforcescale = autocvar_g_balance_seeker_tag_damageforcescale;
392 setorigin (missile, w_shotorg);
393 setsize (missile, '-2 -2 -2', '2 2 2');
395 missile.flags = FL_PROJECTILE;
397 missile.movetype = MOVETYPE_FLY;
398 W_SETUPPROJECTILEVELOCITY(missile, g_balance_seeker_tag);
399 missile.angles = vectoangles (missile.velocity);
401 CSQCProjectile(missile, TRUE, PROJECTILE_TAG, FALSE); // has sound
403 other = missile; MUTATOR_CALLHOOK(EditProjectile);
407 void Seeker_Flac_Explode ()
409 self.event_damage = SUB_Null;
411 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);
416 void Seeker_Flac_Touch()
420 Seeker_Flac_Explode();
423 void Seeker_Fire_Flac()
425 local entity missile;
429 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
430 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
432 if(autocvar_g_balance_seeker_reload_ammo)
434 self.clip_load -= autocvar_g_balance_seeker_flac_ammo;
435 self.seeker_load = self.clip_load;
438 self.ammo_rockets -= autocvar_g_balance_seeker_flac_ammo;
441 c = mod(self.bulletcounter, 4);
445 f_diff = '-1.25 -3.75 0';
448 f_diff = '+1.25 -3.75 0';
451 f_diff = '-1.25 +3.75 0';
455 f_diff = '+1.25 +3.75 0';
458 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/flac_fire.wav", CHAN_WEAPON, autocvar_g_balance_seeker_flac_damage);
461 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
464 missile.owner = missile.realowner = self;
465 missile.classname = "missile";
466 missile.bot_dodge = TRUE;
467 missile.bot_dodgerating = autocvar_g_balance_seeker_flac_damage;
468 missile.touch = Seeker_Flac_Explode;
469 missile.use = Seeker_Flac_Explode;
470 missile.think = adaptor_think2use_hittype_splash;
471 missile.nextthink = time + autocvar_g_balance_seeker_flac_lifetime + autocvar_g_balance_seeker_flac_lifetime_rand;
472 missile.solid = SOLID_BBOX;
473 missile.movetype = MOVETYPE_FLY;
474 missile.projectiledeathtype = WEP_SEEKER;
475 missile.projectiledeathtype = WEP_SEEKER | HITTYPE_SECONDARY;
476 missile.flags = FL_PROJECTILE;
479 //missile.angles = vectoangles (missile.velocity);
480 //missile.scale = 0.4; // BUG: the model is too big
482 setorigin (missile, w_shotorg);
483 setsize (missile, '-2 -2 -2', '2 2 2');
485 W_SETUPPROJECTILEVELOCITY_UP(missile, g_balance_seeker_flac);
486 CSQCProjectile(missile, TRUE, PROJECTILE_FLAC, TRUE);
488 other = missile; MUTATOR_CALLHOOK(EditProjectile);
491 void spawnfunc_weapon_seeker (void)
493 weapon_defaultspawnfunc(WEP_SEEKER);
496 float w_seeker(float req)
501 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_seeker_tag_speed, 0, 20, FALSE);
503 else if (req == WR_THINK)
505 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
508 else if (self.BUTTON_ATCK)
510 if (weapon_prepareattack(0, autocvar_g_balance_seeker_tag_refire))
513 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_seeker_tag_animtime, w_ready);
517 else if (self.BUTTON_ATCK2)
519 if (weapon_prepareattack(1, autocvar_g_balance_seeker_flac_refire))
522 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_seeker_flac_animtime, w_ready);
526 else if (req == WR_PRECACHE)
528 precache_model ("models/weapons/g_seeker.md3");
529 precache_model ("models/weapons/v_seeker.md3");
530 precache_model ("models/weapons/h_seeker.iqm");
531 precache_sound ("weapons/tag_fire.wav");
532 precache_sound ("weapons/flac_fire.wav");
533 precache_sound ("weapons/seeker_fire.wav");
534 precache_sound ("weapons/reload.wav");
536 else if (req == WR_SETUP)
538 weapon_setup(WEP_SEEKER);
539 W_Seeker_SetAmmoCounter();
541 else if (req == WR_CHECKAMMO1)
543 ammo_amount = self.ammo_cells >= autocvar_g_balance_seeker_missile_ammo;
544 ammo_amount += (autocvar_g_balance_seeker_reload_ammo && self.seeker_load >= autocvar_g_balance_seeker_missile_ammo);
547 else if (req == WR_CHECKAMMO2)
549 ammo_amount = self.ammo_cells >= autocvar_g_balance_seeker_flac_ammo;
550 ammo_amount += (autocvar_g_balance_seeker_reload_ammo && self.seeker_load >= autocvar_g_balance_seeker_flac_ammo);
553 else if (req == WR_RESETPLAYER)
555 // all weapons must be fully loaded when we spawn
556 self.seeker_load = autocvar_g_balance_seeker_reload_ammo;
558 else if (req == WR_RELOAD)
566 float w_seeker(float req)
568 if(req == WR_IMPACTEFFECT)
571 org2 = w_org + w_backoff * 6;
572 if(w_deathtype & HITTYPE_SECONDARY)
574 pointparticles(particleeffectnum("flac_explode"), org2, '0 0 0', 1);
578 sound(self, CHAN_PROJECTILE, "weapons/flacexp1.wav", 1, ATTN_NORM);
579 else if (w_random<0.7)
580 sound(self, CHAN_PROJECTILE, "weapons/flacexp2.wav", 1, ATTN_NORM);
582 sound(self, CHAN_PROJECTILE, "weapons/flacexp3.wav", 1, ATTN_NORM);
587 if(w_deathtype & HITTYPE_BOUNCE)
589 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
593 sound(self, CHAN_PROJECTILE, "weapons/tagexp1.wav", 1, ATTN_NORM);
594 else if (w_random<0.7)
595 sound(self, CHAN_PROJECTILE, "weapons/tagexp2.wav", 1, ATTN_NORM);
597 sound(self, CHAN_PROJECTILE, "weapons/tagexp3.wav", 1, ATTN_NORM);
600 else if(w_deathtype & HITTYPE_HEADSHOT)
603 sound(self, CHAN_PROJECTILE, "weapons/tag_impact.wav", 1, ATTN_NORM);
607 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
611 sound(self, CHAN_PROJECTILE, "weapons/seekerexp1.wav", 1, ATTN_NORM);
612 else if (w_random<0.7)
613 sound(self, CHAN_PROJECTILE, "weapons/seekerexp2.wav", 1, ATTN_NORM);
615 sound(self, CHAN_PROJECTILE, "weapons/seekerexp3.wav", 1, ATTN_NORM);
620 else if(req == WR_PRECACHE)
622 precache_sound("weapons/flacexp1.wav");
623 precache_sound("weapons/flacexp2.wav");
624 precache_sound("weapons/flacexp3.wav");
625 precache_sound("weapons/seekerexp1.wav");
626 precache_sound("weapons/seekerexp2.wav");
627 precache_sound("weapons/seekerexp3.wav");
628 precache_sound("weapons/tagexp1.wav");
629 precache_sound("weapons/tagexp2.wav");
630 precache_sound("weapons/tagexp3.wav");
631 precache_sound("weapons/tag_impact.wav");
633 else if (req == WR_SUICIDEMESSAGE)
634 w_deathtypestring = _("%s played with tiny rockets");
635 else if (req == WR_KILLMESSAGE)
637 if(w_deathtype & HITTYPE_SECONDARY)
638 w_deathtypestring = _("%s ran into %s's flac");
640 w_deathtypestring = _("%s was tagged by %s");