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 proxytime; = autoswitch
8 void Seeker_Missile_Explode ()
10 self.event_damage = SUB_Null;
11 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);
16 void Seeker_Missile_Touch()
20 Seeker_Missile_Explode();
23 void Seeker_Missile_Think()
26 vector desireddir, olddir, newdir, eorg;
33 self.projectiledeathtype |= HITTYPE_SPLASH;
34 Seeker_Missile_Explode();
37 spd = vlen(self.velocity);
39 spd - autocvar_g_balance_seeker_missile_decel * frametime,
40 autocvar_g_balance_seeker_missile_speed_max,
41 spd + autocvar_g_balance_seeker_missile_accel * frametime
44 if (self.enemy != world)
45 if (self.enemy.takedamage != DAMAGE_AIM || self.enemy.deadflag != DEAD_NO)
48 if (self.enemy != world)
51 eorg = 0.5 * (e.absmin + e.absmax);
52 turnrate = autocvar_g_balance_seeker_missile_turnrate; // how fast to turn
53 desireddir = normalize(eorg - self.origin);
54 olddir = normalize(self.velocity); // get my current direction
55 dist = vlen(eorg - self.origin);
57 // Do evasive maneuvers for world objects? ( this should be a cpu hog. :P )
58 if (autocvar_g_balance_seeker_missile_smart && (dist > autocvar_g_balance_seeker_missile_smart_mindist))
60 // Is it a better idea (shorter distance) to trace to the target itself?
61 if ( vlen(self.origin + olddir * self.wait) < dist)
62 traceline(self.origin, self.origin + olddir * self.wait, FALSE, self);
64 traceline(self.origin, eorg, FALSE, self);
66 // Setup adaptive tracelength
67 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);
69 // Calc how important it is that we turn and add this to the desierd (enemy) dir.
70 desireddir = normalize(((trace_plane_normal * (1 - trace_fraction)) + (desireddir * trace_fraction)) * 0.5);
73 newdir = normalize(olddir + desireddir * turnrate); // take the average of the 2 directions; not the best method but simple & easy
74 self.velocity = newdir * spd; // make me fly in the new direction at my flight speed
78 if (autocvar_g_balance_seeker_missile_proxy)
80 if ( dist <= autocvar_g_balance_seeker_missile_proxy_maxrange)
82 if (self.autoswitch == 0)
84 self.autoswitch = time + autocvar_g_balance_seeker_missile_proxy_delay;
88 if (self.autoswitch <= time)
90 Seeker_Missile_Explode();
97 if (self.autoswitch != 0)
103 if (self.enemy.deadflag != DEAD_NO)
106 self.cnt = time + 1 + (random() * 4);
107 self.nextthink = self.cnt;
111 //self.angles = vectoangles(self.velocity); // turn model in the new flight direction
112 self.nextthink = time;// + 0.05; // csqc projectiles
113 UpdateCSQCProjectile(self);
118 void Seeker_Missile_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
120 if (self.health <= 0)
123 if (self.owner == attacker)
124 self.health = self.health - (damage * 0.25);
126 self.health = self.health - damage;
128 if (self.health <= 0)
129 W_PrepareExplosionByDamage(attacker, Seeker_Missile_Explode);
133 void Seeker_Missile_Animate()
135 self.frame = self.frame +1;
136 self.nextthink = time + 0.05;
138 if (self.enemy != world)
139 if (self.enemy.takedamage != DAMAGE_AIM || self.enemy.deadflag != DEAD_NO)
144 self.think = Seeker_Missile_Think;
145 self.nextthink = time;// + cvar("g_balance_seeker_missile_activate_delay"); // cant dealy with csqc projectiles
147 if (autocvar_g_balance_seeker_missile_proxy)
148 self.movetype = MOVETYPE_BOUNCEMISSILE;
150 self.movetype = MOVETYPE_FLYMISSILE;
153 UpdateCSQCProjectile(self);
157 void Seeker_Fire_Missile(vector f_diff)
159 local entity missile;
161 if not(self.owner.items & IT_UNLIMITED_WEAPON_AMMO)
162 self.ammo_rockets = self.ammo_rockets - autocvar_g_balance_seeker_missile_ammo;
164 makevectors(self.v_angle);
165 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/seeker_fire.wav", CHAN_WEAPON, 0);
167 pointparticles(particleeffectnum("seeker_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
169 //self.detornator = FALSE;
172 missile.owner = self;
173 missile.classname = "seeker_missile";
174 missile.bot_dodge = TRUE;
175 missile.bot_dodgerating = autocvar_g_balance_seeker_missile_damage;
177 missile.think = Seeker_Missile_Think;
178 missile.touch = Seeker_Missile_Touch;
179 missile.event_damage = Seeker_Missile_Damage;
180 missile.nextthink = time;// + 0.2;// + cvar("g_balance_seeker_missile_activate_delay");
181 missile.cnt = time + autocvar_g_balance_seeker_missile_lifetime;
182 missile.enemy = self.enemy;
183 missile.solid = SOLID_BBOX;
185 missile.takedamage = DAMAGE_YES;
186 missile.health = autocvar_g_balance_seeker_missile_health;
187 missile.damageforcescale = autocvar_g_balance_seeker_missile_damageforcescale;
188 missile.projectiledeathtype = WEP_SEEKER;
189 //missile.think = Seeker_Missile_Animate; // csqc projectiles.
192 setorigin (missile, w_shotorg);
193 setsize (missile, '-4 -4 -4', '4 4 4');
194 missile.movetype = MOVETYPE_FLYMISSILE;
195 missile.flags = FL_PROJECTILE;
196 W_SETUPPROJECTILEVELOCITY_UP(missile, g_balance_seeker_missile);
198 missile.angles = vectoangles (missile.velocity);
200 CSQCProjectile(missile, FALSE, PROJECTILE_SEEKER, TRUE);
202 other = missile; MUTATOR_CALLHOOK(EditProjectile);
205 void Seeker_Vollycontroler_Think()
208 entity oldself,oldenemy;
209 self.cnt = self.cnt - 1;
211 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))
217 self.nextthink = time + autocvar_g_balance_seeker_missile_delay;
222 oldenemy = self.enemy;
223 self.enemy = oldself.enemy;
225 c = mod(oldself.cnt, 4);
229 Seeker_Fire_Missile('-1.25 -3.75 0');
232 Seeker_Fire_Missile('+1.25 -3.75 0');
235 Seeker_Fire_Missile('-1.25 +3.75 0');
239 Seeker_Fire_Missile('+1.25 +3.75 0');
243 self.enemy = oldenemy;
247 void Seeker_Tag_Explode ()
249 //if(other==self.owner)
251 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_BOUNCE, self);
256 void Seeker_Tag_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
258 if (self.health <= 0)
260 self.health = self.health - damage;
261 if (self.health <= 0)
262 Seeker_Tag_Explode();
266 void Seeker_Tag_Touch()
272 dir = normalize (self.owner.origin - self.origin);
273 org2 = findbetterlocation (self.origin, 8);
275 te_knightspike(org2);
277 self.event_damage = SUB_Null;
278 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_HEADSHOT, self);
280 if (other.takedamage == DAMAGE_AIM && other.deadflag == DEAD_NO)
283 e.cnt = autocvar_g_balance_seeker_missile_count;
284 e.owner = self.owner;
286 e.think = Seeker_Vollycontroler_Think;
294 void Seeker_Fire_Tag()
296 local entity missile;
297 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
298 self.ammo_rockets = self.ammo_rockets - autocvar_g_balance_seeker_tag_ammo;
300 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);
303 missile.owner = self;
304 missile.classname = "seeker_tag";
305 missile.bot_dodge = TRUE;
306 missile.bot_dodgerating = 50;
307 missile.touch = Seeker_Tag_Touch;
308 missile.think = SUB_Remove;
309 missile.nextthink = time + autocvar_g_balance_seeker_tag_lifetime;
310 missile.movetype = MOVETYPE_FLY;
311 missile.solid = SOLID_BBOX;
312 missile.owner = self;
314 missile.takedamage = DAMAGE_YES;
315 missile.event_damage = Seeker_Tag_Explode;
316 missile.health = autocvar_g_balance_seeker_tag_health;
317 missile.damageforcescale = autocvar_g_balance_seeker_tag_damageforcescale;
319 setorigin (missile, w_shotorg);
320 setsize (missile, '-2 -2 -2', '2 2 2');
322 missile.flags = FL_PROJECTILE;
324 missile.movetype = MOVETYPE_FLY;
325 W_SETUPPROJECTILEVELOCITY(missile, g_balance_seeker_tag);
326 missile.angles = vectoangles (missile.velocity);
328 CSQCProjectile(missile, TRUE, PROJECTILE_TAG, FALSE); // has sound
330 other = missile; MUTATOR_CALLHOOK(EditProjectile);
334 void Seeker_Flac_Explode ()
336 self.event_damage = SUB_Null;
338 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);
343 void Seeker_Flac_Touch()
347 Seeker_Flac_Explode();
350 void Seeker_Fire_Flac()
352 local entity missile;
356 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
357 self.ammo_rockets = self.ammo_rockets - autocvar_g_balance_seeker_flac_ammo;
359 c = mod(self.bulletcounter, 4);
363 f_diff = '-1.25 -3.75 0';
366 f_diff = '+1.25 -3.75 0';
369 f_diff = '-1.25 +3.75 0';
373 f_diff = '+1.25 +3.75 0';
376 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/flac_fire.wav", CHAN_WEAPON, autocvar_g_balance_seeker_flac_damage);
379 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
382 missile.owner = missile.realowner = self;
383 missile.classname = "missile";
384 missile.bot_dodge = TRUE;
385 missile.bot_dodgerating = autocvar_g_balance_seeker_flac_damage;
386 missile.touch = Seeker_Flac_Explode;
387 missile.use = Seeker_Flac_Explode;
388 missile.think = adaptor_think2use_hittype_splash;
389 missile.nextthink = time + autocvar_g_balance_seeker_flac_lifetime + autocvar_g_balance_seeker_flac_lifetime_rand;
390 missile.solid = SOLID_BBOX;
391 missile.movetype = MOVETYPE_FLY;
392 missile.projectiledeathtype = WEP_SEEKER;
393 missile.projectiledeathtype = WEP_SEEKER | HITTYPE_SECONDARY;
394 missile.flags = FL_PROJECTILE;
397 //missile.angles = vectoangles (missile.velocity);
398 //missile.scale = 0.4; // BUG: the model is too big
400 setorigin (missile, w_shotorg);
401 setsize (missile, '-2 -2 -2', '2 2 2');
403 W_SETUPPROJECTILEVELOCITY_UP(missile, g_balance_seeker_flac);
404 CSQCProjectile(missile, TRUE, PROJECTILE_FLAC, TRUE);
406 other = missile; MUTATOR_CALLHOOK(EditProjectile);
409 void spawnfunc_weapon_seeker (void)
411 weapon_defaultspawnfunc(WEP_SEEKER);
414 float w_seeker(float req)
417 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_seeker_tag_speed, 0, 20, FALSE);
419 else if (req == WR_THINK)
421 if (self.BUTTON_ATCK)
422 if (weapon_prepareattack(0, autocvar_g_balance_seeker_tag_refire))
425 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_seeker_tag_animtime, w_ready);
428 if (self.BUTTON_ATCK2)
429 if (weapon_prepareattack(1, autocvar_g_balance_seeker_flac_refire))
432 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_seeker_flac_animtime, w_ready);
436 else if (req == WR_PRECACHE)
438 precache_model ("models/weapons/g_seeker.md3");
439 precache_model ("models/weapons/v_seeker.md3");
440 precache_model ("models/weapons/h_seeker.iqm");
441 precache_sound ("weapons/tag_fire.wav");
442 precache_sound ("weapons/flac_fire.wav");
443 precache_sound ("weapons/seeker_fire.wav");
445 else if (req == WR_SETUP)
446 weapon_setup(WEP_SEEKER);
447 else if (req == WR_CHECKAMMO1)
448 return self.ammo_rockets >= autocvar_g_balance_seeker_tag_ammo + autocvar_g_balance_seeker_missile_ammo;
449 else if (req == WR_CHECKAMMO2)
450 return self.ammo_rockets >= autocvar_g_balance_seeker_flac_ammo;
455 float w_seeker(float req)
457 if(req == WR_IMPACTEFFECT)
460 org2 = w_org + w_backoff * 6;
461 if(w_deathtype & HITTYPE_SECONDARY)
463 pointparticles(particleeffectnum("flac_explode"), org2, '0 0 0', 1);
467 sound(self, CHAN_PROJECTILE, "weapons/flacexp1.wav", 1, ATTN_NORM);
468 else if (w_random<0.7)
469 sound(self, CHAN_PROJECTILE, "weapons/flacexp2.wav", 1, ATTN_NORM);
471 sound(self, CHAN_PROJECTILE, "weapons/flacexp3.wav", 1, ATTN_NORM);
476 if(w_deathtype & HITTYPE_BOUNCE)
478 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
482 sound(self, CHAN_PROJECTILE, "weapons/tagexp1.wav", 1, ATTN_NORM);
483 else if (w_random<0.7)
484 sound(self, CHAN_PROJECTILE, "weapons/tagexp2.wav", 1, ATTN_NORM);
486 sound(self, CHAN_PROJECTILE, "weapons/tagexp3.wav", 1, ATTN_NORM);
489 else if(w_deathtype & HITTYPE_HEADSHOT)
492 sound(self, CHAN_PROJECTILE, "weapons/tag_impact.wav", 1, ATTN_NORM);
496 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
500 sound(self, CHAN_PROJECTILE, "weapons/seekerexp1.wav", 1, ATTN_NORM);
501 else if (w_random<0.7)
502 sound(self, CHAN_PROJECTILE, "weapons/seekerexp2.wav", 1, ATTN_NORM);
504 sound(self, CHAN_PROJECTILE, "weapons/seekerexp3.wav", 1, ATTN_NORM);
509 else if(req == WR_PRECACHE)
511 precache_sound("weapons/flacexp1.wav");
512 precache_sound("weapons/flacexp2.wav");
513 precache_sound("weapons/flacexp3.wav");
514 precache_sound("weapons/seekerexp1.wav");
515 precache_sound("weapons/seekerexp2.wav");
516 precache_sound("weapons/seekerexp3.wav");
517 precache_sound("weapons/tagexp1.wav");
518 precache_sound("weapons/tagexp2.wav");
519 precache_sound("weapons/tagexp3.wav");
520 precache_sound("weapons/tag_impact.wav");
522 else if (req == WR_SUICIDEMESSAGE)
523 w_deathtypestring = "%s played with tiny rockets";
524 else if (req == WR_KILLMESSAGE)
526 if(w_deathtype & HITTYPE_SECONDARY)
527 w_deathtypestring = "%s ran into %s's flac";
529 w_deathtypestring = "%s was tagged by %s";