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.weapon_load[WEP_SEEKER];
16 self.clip_size = autocvar_g_balance_seeker_reload_ammo; // for the crosshair ammo display
20 void W_Seeker_Reload()
22 self.reload_ammo_player = ammo_fuel;
23 self.reload_ammo_min = min(autocvar_g_balance_seeker_missile_ammo, autocvar_g_balance_seeker_tag_ammo);
24 self.reload_ammo_amount = autocvar_g_balance_seeker_reload_ammo;
25 self.reload_time = autocvar_g_balance_seeker_reload_time;
26 self.reload_sound = "weapons/reload.wav";
31 void Seeker_Missile_Explode ()
33 self.event_damage = SUB_Null;
34 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);
39 void Seeker_Missile_Touch()
43 Seeker_Missile_Explode();
46 void Seeker_Missile_Think()
49 vector desireddir, olddir, newdir, eorg;
56 self.projectiledeathtype |= HITTYPE_SPLASH;
57 Seeker_Missile_Explode();
60 spd = vlen(self.velocity);
62 spd - autocvar_g_balance_seeker_missile_decel * frametime,
63 autocvar_g_balance_seeker_missile_speed_max,
64 spd + autocvar_g_balance_seeker_missile_accel * frametime
67 if (self.enemy != world)
68 if (self.enemy.takedamage != DAMAGE_AIM || self.enemy.deadflag != DEAD_NO)
71 if (self.enemy != world)
74 eorg = 0.5 * (e.absmin + e.absmax);
75 turnrate = autocvar_g_balance_seeker_missile_turnrate; // how fast to turn
76 desireddir = normalize(eorg - self.origin);
77 olddir = normalize(self.velocity); // get my current direction
78 dist = vlen(eorg - self.origin);
80 // Do evasive maneuvers for world objects? ( this should be a cpu hog. :P )
81 if (autocvar_g_balance_seeker_missile_smart && (dist > autocvar_g_balance_seeker_missile_smart_mindist))
83 // Is it a better idea (shorter distance) to trace to the target itself?
84 if ( vlen(self.origin + olddir * self.wait) < dist)
85 traceline(self.origin, self.origin + olddir * self.wait, FALSE, self);
87 traceline(self.origin, eorg, FALSE, self);
89 // Setup adaptive tracelength
90 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);
92 // Calc how important it is that we turn and add this to the desierd (enemy) dir.
93 desireddir = normalize(((trace_plane_normal * (1 - trace_fraction)) + (desireddir * trace_fraction)) * 0.5);
96 newdir = normalize(olddir + desireddir * turnrate); // take the average of the 2 directions; not the best method but simple & easy
97 self.velocity = newdir * spd; // make me fly in the new direction at my flight speed
101 if (autocvar_g_balance_seeker_missile_proxy)
103 if ( dist <= autocvar_g_balance_seeker_missile_proxy_maxrange)
105 if (self.autoswitch == 0)
107 self.autoswitch = time + autocvar_g_balance_seeker_missile_proxy_delay;
111 if (self.autoswitch <= time)
113 Seeker_Missile_Explode();
120 if (self.autoswitch != 0)
126 if (self.enemy.deadflag != DEAD_NO)
129 self.cnt = time + 1 + (random() * 4);
130 self.nextthink = self.cnt;
134 //self.angles = vectoangles(self.velocity); // turn model in the new flight direction
135 self.nextthink = time;// + 0.05; // csqc projectiles
136 UpdateCSQCProjectile(self);
141 void Seeker_Missile_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
143 if (self.health <= 0)
146 if (self.owner == attacker)
147 self.health = self.health - (damage * 0.25);
149 self.health = self.health - damage;
151 if (self.health <= 0)
152 W_PrepareExplosionByDamage(attacker, Seeker_Missile_Explode);
156 void Seeker_Missile_Animate()
158 self.frame = self.frame +1;
159 self.nextthink = time + 0.05;
161 if (self.enemy != world)
162 if (self.enemy.takedamage != DAMAGE_AIM || self.enemy.deadflag != DEAD_NO)
167 self.think = Seeker_Missile_Think;
168 self.nextthink = time;// + cvar("g_balance_seeker_missile_activate_delay"); // cant dealy with csqc projectiles
170 if (autocvar_g_balance_seeker_missile_proxy)
171 self.movetype = MOVETYPE_BOUNCEMISSILE;
173 self.movetype = MOVETYPE_FLYMISSILE;
176 UpdateCSQCProjectile(self);
180 void Seeker_Fire_Missile(vector f_diff)
182 local entity missile;
184 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
185 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
187 if(autocvar_g_balance_seeker_reload_ammo)
189 self.clip_load -= autocvar_g_balance_seeker_missile_ammo;
190 self.weapon_load[WEP_SEEKER] = self.clip_load;
193 self.ammo_rockets -= autocvar_g_balance_seeker_missile_ammo;
196 makevectors(self.v_angle);
197 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/seeker_fire.wav", CHAN_WEAPON, 0);
199 pointparticles(particleeffectnum("seeker_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
201 //self.detornator = FALSE;
204 missile.owner = self;
205 missile.classname = "seeker_missile";
206 missile.bot_dodge = TRUE;
207 missile.bot_dodgerating = autocvar_g_balance_seeker_missile_damage;
209 missile.think = Seeker_Missile_Think;
210 missile.touch = Seeker_Missile_Touch;
211 missile.event_damage = Seeker_Missile_Damage;
212 missile.nextthink = time;// + 0.2;// + cvar("g_balance_seeker_missile_activate_delay");
213 missile.cnt = time + autocvar_g_balance_seeker_missile_lifetime;
214 missile.enemy = self.enemy;
215 missile.solid = SOLID_BBOX;
217 missile.takedamage = DAMAGE_YES;
218 missile.health = autocvar_g_balance_seeker_missile_health;
219 missile.damageforcescale = autocvar_g_balance_seeker_missile_damageforcescale;
220 missile.projectiledeathtype = WEP_SEEKER;
221 //missile.think = Seeker_Missile_Animate; // csqc projectiles.
224 setorigin (missile, w_shotorg);
225 setsize (missile, '-4 -4 -4', '4 4 4');
226 missile.movetype = MOVETYPE_FLYMISSILE;
227 missile.flags = FL_PROJECTILE;
228 W_SETUPPROJECTILEVELOCITY_UP(missile, g_balance_seeker_missile);
230 missile.angles = vectoangles (missile.velocity);
232 CSQCProjectile(missile, FALSE, PROJECTILE_SEEKER, TRUE);
234 other = missile; MUTATOR_CALLHOOK(EditProjectile);
237 void Seeker_Vollycontroler_Think()
240 entity oldself,oldenemy;
241 self.cnt = self.cnt - 1;
243 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))
249 self.nextthink = time + autocvar_g_balance_seeker_missile_delay;
254 oldenemy = self.enemy;
255 self.enemy = oldself.enemy;
257 c = mod(oldself.cnt, 4);
261 Seeker_Fire_Missile('-1.25 -3.75 0');
264 Seeker_Fire_Missile('+1.25 -3.75 0');
267 Seeker_Fire_Missile('-1.25 +3.75 0');
271 Seeker_Fire_Missile('+1.25 +3.75 0');
275 self.enemy = oldenemy;
279 void Seeker_Tag_Explode ()
281 //if(other==self.owner)
283 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_BOUNCE, self);
288 void Seeker_Tag_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
290 if (self.health <= 0)
292 self.health = self.health - damage;
293 if (self.health <= 0)
294 Seeker_Tag_Explode();
298 void Seeker_Tag_Touch()
304 dir = normalize (self.owner.origin - self.origin);
305 org2 = findbetterlocation (self.origin, 8);
307 te_knightspike(org2);
309 self.event_damage = SUB_Null;
310 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_HEADSHOT, self);
312 if (other.takedamage == DAMAGE_AIM && other.deadflag == DEAD_NO)
315 e.cnt = autocvar_g_balance_seeker_missile_count;
316 e.owner = self.owner;
318 e.think = Seeker_Vollycontroler_Think;
326 void Seeker_Fire_Tag()
328 local entity missile;
329 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
330 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
332 if(autocvar_g_balance_seeker_reload_ammo)
334 self.clip_load -= autocvar_g_balance_seeker_tag_ammo;
335 self.weapon_load[WEP_SEEKER] = self.clip_load;
338 self.ammo_rockets -= autocvar_g_balance_seeker_tag_ammo;
341 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);
344 missile.owner = self;
345 missile.classname = "seeker_tag";
346 missile.bot_dodge = TRUE;
347 missile.bot_dodgerating = 50;
348 missile.touch = Seeker_Tag_Touch;
349 missile.think = SUB_Remove;
350 missile.nextthink = time + autocvar_g_balance_seeker_tag_lifetime;
351 missile.movetype = MOVETYPE_FLY;
352 missile.solid = SOLID_BBOX;
353 missile.owner = self;
355 missile.takedamage = DAMAGE_YES;
356 missile.event_damage = Seeker_Tag_Explode;
357 missile.health = autocvar_g_balance_seeker_tag_health;
358 missile.damageforcescale = autocvar_g_balance_seeker_tag_damageforcescale;
360 setorigin (missile, w_shotorg);
361 setsize (missile, '-2 -2 -2', '2 2 2');
363 missile.flags = FL_PROJECTILE;
365 missile.movetype = MOVETYPE_FLY;
366 W_SETUPPROJECTILEVELOCITY(missile, g_balance_seeker_tag);
367 missile.angles = vectoangles (missile.velocity);
369 CSQCProjectile(missile, TRUE, PROJECTILE_TAG, FALSE); // has sound
371 other = missile; MUTATOR_CALLHOOK(EditProjectile);
375 void Seeker_Flac_Explode ()
377 self.event_damage = SUB_Null;
379 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);
384 void Seeker_Flac_Touch()
388 Seeker_Flac_Explode();
391 void Seeker_Fire_Flac()
393 local entity missile;
397 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
398 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
400 if(autocvar_g_balance_seeker_reload_ammo)
402 self.clip_load -= autocvar_g_balance_seeker_flac_ammo;
403 self.weapon_load[WEP_SEEKER] = self.clip_load;
406 self.ammo_rockets -= autocvar_g_balance_seeker_flac_ammo;
409 c = mod(self.bulletcounter, 4);
413 f_diff = '-1.25 -3.75 0';
416 f_diff = '+1.25 -3.75 0';
419 f_diff = '-1.25 +3.75 0';
423 f_diff = '+1.25 +3.75 0';
426 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/flac_fire.wav", CHAN_WEAPON, autocvar_g_balance_seeker_flac_damage);
429 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
432 missile.owner = missile.realowner = self;
433 missile.classname = "missile";
434 missile.bot_dodge = TRUE;
435 missile.bot_dodgerating = autocvar_g_balance_seeker_flac_damage;
436 missile.touch = Seeker_Flac_Explode;
437 missile.use = Seeker_Flac_Explode;
438 missile.think = adaptor_think2use_hittype_splash;
439 missile.nextthink = time + autocvar_g_balance_seeker_flac_lifetime + autocvar_g_balance_seeker_flac_lifetime_rand;
440 missile.solid = SOLID_BBOX;
441 missile.movetype = MOVETYPE_FLY;
442 missile.projectiledeathtype = WEP_SEEKER;
443 missile.projectiledeathtype = WEP_SEEKER | HITTYPE_SECONDARY;
444 missile.flags = FL_PROJECTILE;
447 //missile.angles = vectoangles (missile.velocity);
448 //missile.scale = 0.4; // BUG: the model is too big
450 setorigin (missile, w_shotorg);
451 setsize (missile, '-2 -2 -2', '2 2 2');
453 W_SETUPPROJECTILEVELOCITY_UP(missile, g_balance_seeker_flac);
454 CSQCProjectile(missile, TRUE, PROJECTILE_FLAC, TRUE);
456 other = missile; MUTATOR_CALLHOOK(EditProjectile);
459 void spawnfunc_weapon_seeker (void)
461 weapon_defaultspawnfunc(WEP_SEEKER);
464 float w_seeker(float req)
469 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_seeker_tag_speed, 0, 20, FALSE);
471 else if (req == WR_THINK)
473 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
476 else if (self.BUTTON_ATCK)
478 if (weapon_prepareattack(0, autocvar_g_balance_seeker_tag_refire))
481 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_seeker_tag_animtime, w_ready);
485 else if (self.BUTTON_ATCK2)
487 if (weapon_prepareattack(1, autocvar_g_balance_seeker_flac_refire))
490 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_seeker_flac_animtime, w_ready);
494 else if (req == WR_PRECACHE)
496 precache_model ("models/weapons/g_seeker.md3");
497 precache_model ("models/weapons/v_seeker.md3");
498 precache_model ("models/weapons/h_seeker.iqm");
499 precache_sound ("weapons/tag_fire.wav");
500 precache_sound ("weapons/flac_fire.wav");
501 precache_sound ("weapons/seeker_fire.wav");
502 precache_sound ("weapons/reload.wav");
504 else if (req == WR_SETUP)
506 weapon_setup(WEP_SEEKER);
507 W_Seeker_SetAmmoCounter();
509 else if (req == WR_CHECKAMMO1)
511 ammo_amount = self.ammo_cells >= autocvar_g_balance_seeker_missile_ammo;
512 ammo_amount += self.weapon_load[WEP_SEEKER] >= autocvar_g_balance_seeker_missile_ammo;
515 else if (req == WR_CHECKAMMO2)
517 ammo_amount = self.ammo_cells >= autocvar_g_balance_seeker_flac_ammo;
518 ammo_amount += self.weapon_load[WEP_SEEKER] >= autocvar_g_balance_seeker_flac_ammo;
521 else if (req == WR_RESETPLAYER)
523 // all weapons must be fully loaded when we spawn
524 self.weapon_load[WEP_SEEKER] = autocvar_g_balance_seeker_reload_ammo;
526 else if (req == WR_RELOAD)
534 float w_seeker(float req)
536 if(req == WR_IMPACTEFFECT)
539 org2 = w_org + w_backoff * 6;
540 if(w_deathtype & HITTYPE_SECONDARY)
542 pointparticles(particleeffectnum("flac_explode"), org2, '0 0 0', 1);
546 sound(self, CHAN_PROJECTILE, "weapons/flacexp1.wav", 1, ATTN_NORM);
547 else if (w_random<0.7)
548 sound(self, CHAN_PROJECTILE, "weapons/flacexp2.wav", 1, ATTN_NORM);
550 sound(self, CHAN_PROJECTILE, "weapons/flacexp3.wav", 1, ATTN_NORM);
555 if(w_deathtype & HITTYPE_BOUNCE)
557 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
561 sound(self, CHAN_PROJECTILE, "weapons/tagexp1.wav", 1, ATTN_NORM);
562 else if (w_random<0.7)
563 sound(self, CHAN_PROJECTILE, "weapons/tagexp2.wav", 1, ATTN_NORM);
565 sound(self, CHAN_PROJECTILE, "weapons/tagexp3.wav", 1, ATTN_NORM);
568 else if(w_deathtype & HITTYPE_HEADSHOT)
571 sound(self, CHAN_PROJECTILE, "weapons/tag_impact.wav", 1, ATTN_NORM);
575 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
579 sound(self, CHAN_PROJECTILE, "weapons/seekerexp1.wav", 1, ATTN_NORM);
580 else if (w_random<0.7)
581 sound(self, CHAN_PROJECTILE, "weapons/seekerexp2.wav", 1, ATTN_NORM);
583 sound(self, CHAN_PROJECTILE, "weapons/seekerexp3.wav", 1, ATTN_NORM);
588 else if(req == WR_PRECACHE)
590 precache_sound("weapons/flacexp1.wav");
591 precache_sound("weapons/flacexp2.wav");
592 precache_sound("weapons/flacexp3.wav");
593 precache_sound("weapons/seekerexp1.wav");
594 precache_sound("weapons/seekerexp2.wav");
595 precache_sound("weapons/seekerexp3.wav");
596 precache_sound("weapons/tagexp1.wav");
597 precache_sound("weapons/tagexp2.wav");
598 precache_sound("weapons/tagexp3.wav");
599 precache_sound("weapons/tag_impact.wav");
601 else if (req == WR_SUICIDEMESSAGE)
602 w_deathtypestring = _("%s played with tiny rockets");
603 else if (req == WR_KILLMESSAGE)
605 if(w_deathtype & HITTYPE_SECONDARY)
606 w_deathtypestring = _("%s ran into %s's flac");
608 w_deathtypestring = _("%s was tagged by %s");