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_Reload()
25 self.reload_ammo_player = ammo_fuel;
26 self.reload_ammo_min = min(autocvar_g_balance_seeker_missile_ammo, autocvar_g_balance_seeker_tag_ammo);
27 self.reload_ammo_amount = autocvar_g_balance_seeker_reload_ammo;
28 self.reload_time = autocvar_g_balance_seeker_reload_time;
29 self.reload_sound = "weapons/reload.wav";
34 void Seeker_Missile_Explode ()
36 self.event_damage = SUB_Null;
37 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);
42 void Seeker_Missile_Touch()
46 Seeker_Missile_Explode();
49 void Seeker_Missile_Think()
52 vector desireddir, olddir, newdir, eorg;
59 self.projectiledeathtype |= HITTYPE_SPLASH;
60 Seeker_Missile_Explode();
63 spd = vlen(self.velocity);
65 spd - autocvar_g_balance_seeker_missile_decel * frametime,
66 autocvar_g_balance_seeker_missile_speed_max,
67 spd + autocvar_g_balance_seeker_missile_accel * frametime
70 if (self.enemy != world)
71 if (self.enemy.takedamage != DAMAGE_AIM || self.enemy.deadflag != DEAD_NO)
74 if (self.enemy != world)
77 eorg = 0.5 * (e.absmin + e.absmax);
78 turnrate = autocvar_g_balance_seeker_missile_turnrate; // how fast to turn
79 desireddir = normalize(eorg - self.origin);
80 olddir = normalize(self.velocity); // get my current direction
81 dist = vlen(eorg - self.origin);
83 // Do evasive maneuvers for world objects? ( this should be a cpu hog. :P )
84 if (autocvar_g_balance_seeker_missile_smart && (dist > autocvar_g_balance_seeker_missile_smart_mindist))
86 // Is it a better idea (shorter distance) to trace to the target itself?
87 if ( vlen(self.origin + olddir * self.wait) < dist)
88 traceline(self.origin, self.origin + olddir * self.wait, FALSE, self);
90 traceline(self.origin, eorg, FALSE, self);
92 // Setup adaptive tracelength
93 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);
95 // Calc how important it is that we turn and add this to the desierd (enemy) dir.
96 desireddir = normalize(((trace_plane_normal * (1 - trace_fraction)) + (desireddir * trace_fraction)) * 0.5);
99 newdir = normalize(olddir + desireddir * turnrate); // take the average of the 2 directions; not the best method but simple & easy
100 self.velocity = newdir * spd; // make me fly in the new direction at my flight speed
104 if (autocvar_g_balance_seeker_missile_proxy)
106 if ( dist <= autocvar_g_balance_seeker_missile_proxy_maxrange)
108 if (self.autoswitch == 0)
110 self.autoswitch = time + autocvar_g_balance_seeker_missile_proxy_delay;
114 if (self.autoswitch <= time)
116 Seeker_Missile_Explode();
123 if (self.autoswitch != 0)
129 if (self.enemy.deadflag != DEAD_NO)
132 self.cnt = time + 1 + (random() * 4);
133 self.nextthink = self.cnt;
137 //self.angles = vectoangles(self.velocity); // turn model in the new flight direction
138 self.nextthink = time;// + 0.05; // csqc projectiles
139 UpdateCSQCProjectile(self);
144 void Seeker_Missile_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
146 if (self.health <= 0)
149 if (self.owner == attacker)
150 self.health = self.health - (damage * 0.25);
152 self.health = self.health - damage;
154 if (self.health <= 0)
155 W_PrepareExplosionByDamage(attacker, Seeker_Missile_Explode);
159 void Seeker_Missile_Animate()
161 self.frame = self.frame +1;
162 self.nextthink = time + 0.05;
164 if (self.enemy != world)
165 if (self.enemy.takedamage != DAMAGE_AIM || self.enemy.deadflag != DEAD_NO)
170 self.think = Seeker_Missile_Think;
171 self.nextthink = time;// + cvar("g_balance_seeker_missile_activate_delay"); // cant dealy with csqc projectiles
173 if (autocvar_g_balance_seeker_missile_proxy)
174 self.movetype = MOVETYPE_BOUNCEMISSILE;
176 self.movetype = MOVETYPE_FLYMISSILE;
179 UpdateCSQCProjectile(self);
183 void Seeker_Fire_Missile(vector f_diff)
185 local entity missile;
187 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
188 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
190 if(autocvar_g_balance_seeker_reload_ammo)
192 self.clip_load -= autocvar_g_balance_seeker_missile_ammo;
193 self.seeker_load = self.clip_load;
196 self.ammo_rockets -= autocvar_g_balance_seeker_missile_ammo;
199 makevectors(self.v_angle);
200 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/seeker_fire.wav", CHAN_WEAPON, 0);
202 pointparticles(particleeffectnum("seeker_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
204 //self.detornator = FALSE;
207 missile.owner = self;
208 missile.classname = "seeker_missile";
209 missile.bot_dodge = TRUE;
210 missile.bot_dodgerating = autocvar_g_balance_seeker_missile_damage;
212 missile.think = Seeker_Missile_Think;
213 missile.touch = Seeker_Missile_Touch;
214 missile.event_damage = Seeker_Missile_Damage;
215 missile.nextthink = time;// + 0.2;// + cvar("g_balance_seeker_missile_activate_delay");
216 missile.cnt = time + autocvar_g_balance_seeker_missile_lifetime;
217 missile.enemy = self.enemy;
218 missile.solid = SOLID_BBOX;
220 missile.takedamage = DAMAGE_YES;
221 missile.health = autocvar_g_balance_seeker_missile_health;
222 missile.damageforcescale = autocvar_g_balance_seeker_missile_damageforcescale;
223 missile.projectiledeathtype = WEP_SEEKER;
224 //missile.think = Seeker_Missile_Animate; // csqc projectiles.
227 setorigin (missile, w_shotorg);
228 setsize (missile, '-4 -4 -4', '4 4 4');
229 missile.movetype = MOVETYPE_FLYMISSILE;
230 missile.flags = FL_PROJECTILE;
231 W_SETUPPROJECTILEVELOCITY_UP(missile, g_balance_seeker_missile);
233 missile.angles = vectoangles (missile.velocity);
235 CSQCProjectile(missile, FALSE, PROJECTILE_SEEKER, TRUE);
237 other = missile; MUTATOR_CALLHOOK(EditProjectile);
240 void Seeker_Vollycontroler_Think()
243 entity oldself,oldenemy;
244 self.cnt = self.cnt - 1;
246 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))
252 self.nextthink = time + autocvar_g_balance_seeker_missile_delay;
257 oldenemy = self.enemy;
258 self.enemy = oldself.enemy;
260 c = mod(oldself.cnt, 4);
264 Seeker_Fire_Missile('-1.25 -3.75 0');
267 Seeker_Fire_Missile('+1.25 -3.75 0');
270 Seeker_Fire_Missile('-1.25 +3.75 0');
274 Seeker_Fire_Missile('+1.25 +3.75 0');
278 self.enemy = oldenemy;
282 void Seeker_Tag_Explode ()
284 //if(other==self.owner)
286 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_BOUNCE, self);
291 void Seeker_Tag_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
293 if (self.health <= 0)
295 self.health = self.health - damage;
296 if (self.health <= 0)
297 Seeker_Tag_Explode();
301 void Seeker_Tag_Touch()
307 dir = normalize (self.owner.origin - self.origin);
308 org2 = findbetterlocation (self.origin, 8);
310 te_knightspike(org2);
312 self.event_damage = SUB_Null;
313 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_HEADSHOT, self);
315 if (other.takedamage == DAMAGE_AIM && other.deadflag == DEAD_NO)
318 e.cnt = autocvar_g_balance_seeker_missile_count;
319 e.owner = self.owner;
321 e.think = Seeker_Vollycontroler_Think;
329 void Seeker_Fire_Tag()
331 local entity missile;
332 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
333 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
335 if(autocvar_g_balance_seeker_reload_ammo)
337 self.clip_load -= autocvar_g_balance_seeker_tag_ammo;
338 self.seeker_load = self.clip_load;
341 self.ammo_rockets -= autocvar_g_balance_seeker_tag_ammo;
344 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);
347 missile.owner = self;
348 missile.classname = "seeker_tag";
349 missile.bot_dodge = TRUE;
350 missile.bot_dodgerating = 50;
351 missile.touch = Seeker_Tag_Touch;
352 missile.think = SUB_Remove;
353 missile.nextthink = time + autocvar_g_balance_seeker_tag_lifetime;
354 missile.movetype = MOVETYPE_FLY;
355 missile.solid = SOLID_BBOX;
356 missile.owner = self;
358 missile.takedamage = DAMAGE_YES;
359 missile.event_damage = Seeker_Tag_Explode;
360 missile.health = autocvar_g_balance_seeker_tag_health;
361 missile.damageforcescale = autocvar_g_balance_seeker_tag_damageforcescale;
363 setorigin (missile, w_shotorg);
364 setsize (missile, '-2 -2 -2', '2 2 2');
366 missile.flags = FL_PROJECTILE;
368 missile.movetype = MOVETYPE_FLY;
369 W_SETUPPROJECTILEVELOCITY(missile, g_balance_seeker_tag);
370 missile.angles = vectoangles (missile.velocity);
372 CSQCProjectile(missile, TRUE, PROJECTILE_TAG, FALSE); // has sound
374 other = missile; MUTATOR_CALLHOOK(EditProjectile);
378 void Seeker_Flac_Explode ()
380 self.event_damage = SUB_Null;
382 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);
387 void Seeker_Flac_Touch()
391 Seeker_Flac_Explode();
394 void Seeker_Fire_Flac()
396 local entity missile;
400 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
401 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
403 if(autocvar_g_balance_seeker_reload_ammo)
405 self.clip_load -= autocvar_g_balance_seeker_flac_ammo;
406 self.seeker_load = self.clip_load;
409 self.ammo_rockets -= autocvar_g_balance_seeker_flac_ammo;
412 c = mod(self.bulletcounter, 4);
416 f_diff = '-1.25 -3.75 0';
419 f_diff = '+1.25 -3.75 0';
422 f_diff = '-1.25 +3.75 0';
426 f_diff = '+1.25 +3.75 0';
429 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/flac_fire.wav", CHAN_WEAPON, autocvar_g_balance_seeker_flac_damage);
432 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
435 missile.owner = missile.realowner = self;
436 missile.classname = "missile";
437 missile.bot_dodge = TRUE;
438 missile.bot_dodgerating = autocvar_g_balance_seeker_flac_damage;
439 missile.touch = Seeker_Flac_Explode;
440 missile.use = Seeker_Flac_Explode;
441 missile.think = adaptor_think2use_hittype_splash;
442 missile.nextthink = time + autocvar_g_balance_seeker_flac_lifetime + autocvar_g_balance_seeker_flac_lifetime_rand;
443 missile.solid = SOLID_BBOX;
444 missile.movetype = MOVETYPE_FLY;
445 missile.projectiledeathtype = WEP_SEEKER;
446 missile.projectiledeathtype = WEP_SEEKER | HITTYPE_SECONDARY;
447 missile.flags = FL_PROJECTILE;
450 //missile.angles = vectoangles (missile.velocity);
451 //missile.scale = 0.4; // BUG: the model is too big
453 setorigin (missile, w_shotorg);
454 setsize (missile, '-2 -2 -2', '2 2 2');
456 W_SETUPPROJECTILEVELOCITY_UP(missile, g_balance_seeker_flac);
457 CSQCProjectile(missile, TRUE, PROJECTILE_FLAC, TRUE);
459 other = missile; MUTATOR_CALLHOOK(EditProjectile);
462 void spawnfunc_weapon_seeker (void)
464 weapon_defaultspawnfunc(WEP_SEEKER);
467 float w_seeker(float req)
472 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_seeker_tag_speed, 0, 20, FALSE);
474 else if (req == WR_THINK)
476 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
479 else if (self.BUTTON_ATCK)
481 if (weapon_prepareattack(0, autocvar_g_balance_seeker_tag_refire))
484 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_seeker_tag_animtime, w_ready);
488 else if (self.BUTTON_ATCK2)
490 if (weapon_prepareattack(1, autocvar_g_balance_seeker_flac_refire))
493 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_seeker_flac_animtime, w_ready);
497 else if (req == WR_PRECACHE)
499 precache_model ("models/weapons/g_seeker.md3");
500 precache_model ("models/weapons/v_seeker.md3");
501 precache_model ("models/weapons/h_seeker.iqm");
502 precache_sound ("weapons/tag_fire.wav");
503 precache_sound ("weapons/flac_fire.wav");
504 precache_sound ("weapons/seeker_fire.wav");
505 precache_sound ("weapons/reload.wav");
507 else if (req == WR_SETUP)
509 weapon_setup(WEP_SEEKER);
510 W_Seeker_SetAmmoCounter();
512 else if (req == WR_CHECKAMMO1)
514 ammo_amount = self.ammo_cells >= autocvar_g_balance_seeker_missile_ammo;
515 ammo_amount += self.seeker_load >= autocvar_g_balance_seeker_missile_ammo;
518 else if (req == WR_CHECKAMMO2)
520 ammo_amount = self.ammo_cells >= autocvar_g_balance_seeker_flac_ammo;
521 ammo_amount += self.seeker_load >= autocvar_g_balance_seeker_flac_ammo;
524 else if (req == WR_RESETPLAYER)
526 // all weapons must be fully loaded when we spawn
527 self.seeker_load = autocvar_g_balance_seeker_reload_ammo;
529 else if (req == WR_RELOAD)
537 float w_seeker(float req)
539 if(req == WR_IMPACTEFFECT)
542 org2 = w_org + w_backoff * 6;
543 if(w_deathtype & HITTYPE_SECONDARY)
545 pointparticles(particleeffectnum("flac_explode"), org2, '0 0 0', 1);
549 sound(self, CHAN_PROJECTILE, "weapons/flacexp1.wav", 1, ATTN_NORM);
550 else if (w_random<0.7)
551 sound(self, CHAN_PROJECTILE, "weapons/flacexp2.wav", 1, ATTN_NORM);
553 sound(self, CHAN_PROJECTILE, "weapons/flacexp3.wav", 1, ATTN_NORM);
558 if(w_deathtype & HITTYPE_BOUNCE)
560 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
564 sound(self, CHAN_PROJECTILE, "weapons/tagexp1.wav", 1, ATTN_NORM);
565 else if (w_random<0.7)
566 sound(self, CHAN_PROJECTILE, "weapons/tagexp2.wav", 1, ATTN_NORM);
568 sound(self, CHAN_PROJECTILE, "weapons/tagexp3.wav", 1, ATTN_NORM);
571 else if(w_deathtype & HITTYPE_HEADSHOT)
574 sound(self, CHAN_PROJECTILE, "weapons/tag_impact.wav", 1, ATTN_NORM);
578 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
582 sound(self, CHAN_PROJECTILE, "weapons/seekerexp1.wav", 1, ATTN_NORM);
583 else if (w_random<0.7)
584 sound(self, CHAN_PROJECTILE, "weapons/seekerexp2.wav", 1, ATTN_NORM);
586 sound(self, CHAN_PROJECTILE, "weapons/seekerexp3.wav", 1, ATTN_NORM);
591 else if(req == WR_PRECACHE)
593 precache_sound("weapons/flacexp1.wav");
594 precache_sound("weapons/flacexp2.wav");
595 precache_sound("weapons/flacexp3.wav");
596 precache_sound("weapons/seekerexp1.wav");
597 precache_sound("weapons/seekerexp2.wav");
598 precache_sound("weapons/seekerexp3.wav");
599 precache_sound("weapons/tagexp1.wav");
600 precache_sound("weapons/tagexp2.wav");
601 precache_sound("weapons/tagexp3.wav");
602 precache_sound("weapons/tag_impact.wav");
604 else if (req == WR_SUICIDEMESSAGE)
605 w_deathtypestring = _("%s played with tiny rockets");
606 else if (req == WR_KILLMESSAGE)
608 if(w_deathtype & HITTYPE_SECONDARY)
609 w_deathtypestring = _("%s ran into %s's flac");
611 w_deathtypestring = _("%s was tagged by %s");