2 REGISTER_WEAPON(SEEKER, w_seeker, IT_ROCKETS, 9, WEP_FLAG_NORMAL | WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "seeker", "seeker", "T.A.G. Seeker");
5 //.float speed; = switchweapon
6 //.float proxytime; = autoswitch
9 void Seeker_Missile_Explode ()
11 self.event_damage = SUB_Null;
12 RadiusDamage (self, self.owner, cvar("g_balance_seeker_missile_damage"), cvar("g_balance_seeker_missile_edgedamage"), cvar("g_balance_seeker_missile_radius"), world, cvar("g_balance_seeker_missile_force"), self.projectiledeathtype, other);
17 void Seeker_Missile_Touch()
21 Seeker_Missile_Explode();
24 void Seeker_Missile_Think()
27 vector desireddir, olddir, newdir, eorg;
33 self.projectiledeathtype |= HITTYPE_SPLASH;
34 Seeker_Missile_Explode();
37 if (!self.switchweapon)
38 self.switchweapon = cvar("g_balance_seeker_missile_speed");
40 if ((self.switchweapon < cvar("g_balance_seeker_missile_speed_max")) && cvar("g_balance_seeker_missile_speed_accel"))
41 self.switchweapon = self.switchweapon * cvar("g_balance_seeker_missile_accel");
43 if (self.switchweapon > cvar("g_balance_seeker_missile_speed_max"))
44 self.switchweapon = self.switchweapon * cvar("g_balance_seeker_missile_decel");
46 if (self.enemy != world)
47 if (self.enemy.takedamage != DAMAGE_AIM || self.enemy.deadflag != DEAD_NO)
50 if (self.enemy != world)
53 eorg = 0.5 * (e.absmin + e.absmax);
54 turnrate = cvar("g_balance_seeker_missile_turnrate"); // how fast to turn
55 desireddir = normalize(eorg - self.origin);
56 olddir = normalize(self.velocity); // get my current direction
57 dist = vlen(eorg - self.origin);
59 // Do evasive maneuvers for world objects? ( this should be a cpu hog. :P )
60 if (cvar("g_balance_seeker_missile_smart") && (dist > cvar("g_balance_seeker_missile_smart_mindist")))
62 // Is it a better idea (shorter distance) to trace to the target itself?
63 if ( vlen(self.origin + olddir * self.wait) < dist)
64 traceline(self.origin, self.origin + olddir * self.wait, FALSE, self);
66 traceline(self.origin, eorg, FALSE, self);
68 // Setup adaptive tracelength
69 self.wait = vlen(self.origin - trace_endpos);
70 if (self.wait < cvar("g_balance_seeker_missile_smart_trace_min")) self.wait = cvar("g_balance_seeker_missile_smart_trace_min");
71 if (self.wait > cvar("g_balance_seeker_missile_smart_trace_max")) self.wait = cvar("g_balance_seeker_missile_smart_trace_max");
73 // Calc how important it is that we turn and add this to the desierd (enemy) dir.
74 desireddir = normalize(((trace_plane_normal * (1 - trace_fraction)) + (desireddir * trace_fraction)) * 0.5);
77 //newdir = normalize((olddir + desireddir * turnrate) * 0.5);// take the average of the 2 directions; not the best method but simple & easy
78 newdir = normalize(olddir + desireddir * turnrate);// take the average of the 2 directions; not the best method but simple & easy
80 self.velocity = newdir * self.switchweapon; // make me fly in the new direction at my flight speed
84 if (cvar("g_balance_seeker_missile_proxy"))
86 if ( dist <= cvar("g_balance_seeker_missile_proxy_maxrange"))
88 if (self.autoswitch == 0)
90 self.autoswitch = time + cvar("g_balance_seeker_missile_proxy_delay");
94 if (self.autoswitch <= time)
96 Seeker_Missile_Explode();
103 if (self.autoswitch != 0)
109 if (self.enemy.deadflag != DEAD_NO)
112 self.cnt = time + 1 + (random() * 4);
113 self.nextthink = self.cnt;
117 self.angles = vectoangles(self.velocity); // turn model in the new flight direction
118 self.nextthink = time + 0.05;
120 UpdateCSQCProjectile(self);
125 void Seeker_Missile_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
130 if (self.health <= 0)
133 if (self.owner == attacker)
136 self.health = self.health - d;
138 if (self.health <= 0)
139 W_PrepareExplosionByDamage(attacker, Seeker_Missile_Explode);
142 void Seeker_Missile_Animate()
144 self.frame = self.frame +1;
145 self.nextthink = time + 0.05;
147 if (self.enemy != world)
148 if (self.enemy.takedamage != DAMAGE_AIM || self.enemy.deadflag != DEAD_NO)
153 self.think = Seeker_Missile_Think;
154 self.nextthink = time;// + cvar("g_balance_seeker_missile_activate_delay"); // cant dealy with csqc projectiles
156 if (cvar("g_balance_seeker_missile_proxy"))
157 self.movetype = MOVETYPE_BOUNCEMISSILE;
159 self.movetype = MOVETYPE_FLYMISSILE;
162 UpdateCSQCProjectile(self);
165 void Seeker_Fire_Missile(vector f_diff)
167 local entity missile;
169 if not(self.owner.items & IT_UNLIMITED_WEAPON_AMMO)
170 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_seeker_missile_ammo");
172 makevectors(self.v_angle);
173 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/seeker_fire.wav", cvar("g_balance_seeker_missile_damage"));
175 pointparticles(particleeffectnum("seeker_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
177 //self.detornator = FALSE;
180 missile.owner = self;
181 missile.classname = "seeker_missile";
182 missile.bot_dodge = TRUE;
183 missile.bot_dodgerating = cvar("g_balance_seeker_missile_damage");
185 missile.think = Seeker_Missile_Animate;
187 //if (!cvar("g_balance_seeker_missile_proxy"))
188 missile.touch = Seeker_Missile_Touch;
190 missile.event_damage = Seeker_Missile_Damage;
191 missile.nextthink = time;// + 0.2;// + cvar("g_balance_seeker_missile_activate_delay");
192 missile.cnt = time + cvar("g_balance_seeker_missile_lifetime");
193 missile.enemy = self.enemy;
194 missile.solid = SOLID_BBOX;
196 missile.takedamage = DAMAGE_YES;
197 missile.health = cvar("g_balance_seeker_missile_health");
198 missile.damageforcescale = cvar("g_balance_seeker_missile_damageforcescale");
199 missile.projectiledeathtype = WEP_SEEKER;
201 setorigin (missile, w_shotorg);
202 setsize (missile, '-4 -4 -4', '4 4 4');
205 missile.movetype = MOVETYPE_FLYMISSILE;// MOVETYPE_TOSS;
207 missile.flags = FL_PROJECTILE;
209 W_SETUPPROJECTILEVELOCITY_UP(missile, g_balance_seeker_missile);
211 missile.switchweapon = vlen(missile.velocity);
212 missile.angles = vectoangles (missile.velocity);
214 CSQCProjectile(missile, FALSE, PROJECTILE_SEEKER, TRUE);
217 void Seeker_Vollycontroler_Think()
220 entity oldself,oldenemy;
221 self.cnt = self.cnt - 1;
223 if((!(self.owner.items & IT_UNLIMITED_AMMO) && self.owner.ammo_rockets < cvar("g_balance_seeker_missile_ammo")) || (self.cnt <= -1) || (self.owner.deadflag != DEAD_NO))
229 self.nextthink = time + cvar("g_balance_seeker_missile_delay");
234 oldenemy = self.enemy;
235 self.enemy = oldself.enemy;
237 c = mod(oldself.cnt, 4);
241 Seeker_Fire_Missile('-1.25 -3.75 0');
244 Seeker_Fire_Missile('+1.25 -3.75 0');
247 Seeker_Fire_Missile('-1.25 +3.75 0');
251 Seeker_Fire_Missile('+1.25 +3.75 0');
255 self.enemy = oldenemy;
259 void Seeker_Tag_Explode ()
261 //if(other==self.owner)
263 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_BOUNCE, self);
268 void Seeker_Tag_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
270 if (self.health <= 0)
272 self.health = self.health - damage;
273 if (self.health <= 0)
274 Seeker_Tag_Explode();
277 void Seeker_Tag_Think()
283 void Seeker_Tag_Touch()
288 dir = normalize (self.owner.origin - self.origin);
289 org2 = findbetterlocation (self.origin, 8);
291 te_knightspike(org2);
293 self.event_damage = SUB_Null;
294 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_HEADSHOT, self);
296 if (other.takedamage == DAMAGE_AIM && other.deadflag == DEAD_NO)
300 e.cnt = cvar("g_balance_seeker_missile_count");
301 e.owner = self.owner;
303 e.think = Seeker_Vollycontroler_Think;
306 //sprint(self.owner, "^1Target lock ^3[^7 ",other.netname, " ^3]^1 acquired - autofire activated.\n");
307 //sprint(other,"^1You are targeted!\n");
309 // stuffcmd(other,"play2 weapons/zany-alarm4.ogg\n");
310 // stuffcmd(self.owner, "play2 weapons/zany-lock4.ogg\n");
319 void Seeker_Fire_Tag()
321 local entity missile;
322 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
323 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_seeker_tag_ammo");
325 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/tag_fire.wav", 0);
328 missile.owner = self;
329 missile.classname = "seeker_tag";
330 missile.bot_dodge = TRUE;
331 missile.bot_dodgerating = 50;
332 missile.touch = Seeker_Tag_Touch;
333 missile.think = Seeker_Tag_Think;
334 missile.nextthink = time + cvar("g_balance_seeker_tag_lifetime");
335 missile.movetype = MOVETYPE_FLY;
336 missile.solid = SOLID_BBOX;
337 missile.owner = self;
339 missile.takedamage = DAMAGE_YES;
340 missile.event_damage = Seeker_Tag_Explode;
341 missile.health = cvar("g_balance_seeker_tag_health");
342 missile.damageforcescale = cvar("g_balance_seeker_tag_damageforcescale");
344 setorigin (missile, w_shotorg);
345 setsize (missile, '-2 -2 -2', '2 2 2');
347 missile.flags = FL_PROJECTILE;
349 missile.movetype = MOVETYPE_FLY;
350 W_SETUPPROJECTILEVELOCITY(missile, g_balance_seeker_tag);
351 missile.angles = vectoangles (missile.velocity);
353 CSQCProjectile(missile, TRUE, PROJECTILE_TAG, FALSE); // has sound
357 void Seeker_Flac_Explode ()
359 self.event_damage = SUB_Null;
361 RadiusDamage (self, self.owner, cvar("g_balance_seeker_flac_damage"), cvar("g_balance_seeker_flac_edgedamage"), cvar("g_balance_seeker_flac_radius"), world, cvar("g_balance_seeker_flac_force"), self.projectiledeathtype, other);
366 void Seeker_Flac_Touch()
370 Seeker_Flac_Explode();
373 void Seeker_Fire_Flac()
375 local entity missile;
379 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
380 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_seeker_flac_ammo");
382 c = mod(self.bulletcounter, 4);
386 f_diff = '-1.25 -3.75 0';
389 f_diff = '+1.25 -3.75 0';
392 f_diff = '-1.25 +3.75 0';
396 f_diff = '+1.25 +3.75 0';
399 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/flac_fire.wav", cvar("g_balance_seeker_flac_damage"));
402 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
405 missile.owner = missile.realowner = self;
406 missile.classname = "missile";
407 missile.bot_dodge = TRUE;
408 missile.bot_dodgerating = cvar("g_balance_seeker_flac_damage");
409 missile.touch = Seeker_Flac_Explode;
410 missile.use = Seeker_Flac_Explode;
411 missile.think = adaptor_think2use_hittype_splash;
412 missile.nextthink = time + cvar("g_balance_seeker_flac_lifetime") + cvar("g_balance_seeker_flac_lifetime_rand");
413 missile.solid = SOLID_BBOX;
414 missile.scale = 0.4; // BUG: the model is too big
415 missile.projectiledeathtype = WEP_SEEKER;
416 setorigin (missile, w_shotorg);
417 setsize (missile, '-2 -2 -2', '2 2 2');
418 missile.projectiledeathtype = WEP_SEEKER | HITTYPE_SECONDARY;
420 missile.movetype = MOVETYPE_FLY;
421 W_SETUPPROJECTILEVELOCITY_UP(missile, g_balance_seeker_flac);
423 missile.angles = vectoangles (missile.velocity);
424 missile.flags = FL_PROJECTILE;
426 CSQCProjectile(missile, TRUE, PROJECTILE_FLAC, TRUE);
429 void spawnfunc_weapon_seeker (void)
431 weapon_defaultspawnfunc(WEP_SEEKER);
434 float w_seeker(float req)
437 self.BUTTON_ATCK = bot_aim(cvar("g_balance_seeker_tag_speed"), 0, 20, FALSE);
439 else if (req == WR_THINK)
441 if (self.BUTTON_ATCK)
442 if (weapon_prepareattack(0, cvar("g_balance_seeker_tag_refire")))
445 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_seeker_tag_animtime"), w_ready);
448 if (self.BUTTON_ATCK2)
449 if (weapon_prepareattack(1, cvar("g_balance_seeker_flac_refire")))
452 weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_seeker_flac_animtime"), w_ready);
456 else if (req == WR_PRECACHE)
458 precache_model ("models/weapons/g_seeker.md3");
459 precache_model ("models/weapons/v_seeker.md3");
460 precache_model ("models/weapons/h_seeker.iqm");
461 precache_sound ("weapons/tag_fire.wav");
462 precache_sound ("weapons/flac_fire.wav");
463 precache_sound ("weapons/seeker_fire.wav");
465 else if (req == WR_SETUP)
466 weapon_setup(WEP_SEEKER);
467 else if (req == WR_CHECKAMMO1)
468 return self.ammo_rockets >= cvar("g_balance_seeker_tag_ammo") + cvar("g_balance_seeker_missile_ammo");
469 else if (req == WR_CHECKAMMO2)
470 return self.ammo_rockets >= cvar("g_balance_seeker_flac_ammo");
471 else if (req == WR_SUICIDEMESSAGE)
472 w_deathtypestring = "played with tiny rockets";
473 else if (req == WR_KILLMESSAGE)
475 if(w_deathtype & HITTYPE_SECONDARY)
476 w_deathtypestring = "ran into #'s flac";
478 w_deathtypestring = "was tagged by";
484 float w_seeker(float req)
486 if(req == WR_IMPACTEFFECT)
489 org2 = w_org + w_backoff * 6;
490 if(w_deathtype & HITTYPE_SECONDARY)
492 pointparticles(particleeffectnum("flac_explode"), org2, '0 0 0', 1);
496 sound(self, CHAN_PROJECTILE, "weapons/flacexp1.wav", 1, ATTN_NORM);
497 else if (w_random<0.7)
498 sound(self, CHAN_PROJECTILE, "weapons/flacexp2.wav", 1, ATTN_NORM);
500 sound(self, CHAN_PROJECTILE, "weapons/flacexp3.wav", 1, ATTN_NORM);
505 if(w_deathtype & HITTYPE_BOUNCE)
507 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
511 sound(self, CHAN_PROJECTILE, "weapons/tagexp1.wav", 1, ATTN_NORM);
512 else if (w_random<0.7)
513 sound(self, CHAN_PROJECTILE, "weapons/tagexp2.wav", 1, ATTN_NORM);
515 sound(self, CHAN_PROJECTILE, "weapons/tagexp3.wav", 1, ATTN_NORM);
518 else if(w_deathtype & HITTYPE_HEADSHOT)
521 sound(self, CHAN_PROJECTILE, "weapons/tag_impact.wav", 1, ATTN_NORM);
525 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
529 sound(self, CHAN_PROJECTILE, "weapons/seekerexp1.wav", 1, ATTN_NORM);
530 else if (w_random<0.7)
531 sound(self, CHAN_PROJECTILE, "weapons/seekerexp2.wav", 1, ATTN_NORM);
533 sound(self, CHAN_PROJECTILE, "weapons/seekerexp3.wav", 1, ATTN_NORM);
538 else if(req == WR_PRECACHE)
540 precache_sound("weapons/flacexp1.wav");
541 precache_sound("weapons/flacexp2.wav");
542 precache_sound("weapons/flacexp3.wav");
543 precache_sound("weapons/seekerexp1.wav");
544 precache_sound("weapons/seekerexp2.wav");
545 precache_sound("weapons/seekerexp3.wav");
546 precache_sound("weapons/tagexp1.wav");
547 precache_sound("weapons/tagexp2.wav");
548 precache_sound("weapons/tagexp3.wav");
549 precache_sound("weapons/tag_impact.wav");