2 REGISTER_WEAPON(SEEKER, w_seeker, IT_ROCKETS, 8, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "seeker", "seeker", _("T.A.G. Seeker"))
5 //.float proxytime; = autoswitch
10 self.reload_ammo_player = ammo_rockets;
11 self.reload_ammo_min = min(autocvar_g_balance_seeker_missile_ammo, autocvar_g_balance_seeker_tag_ammo);
12 self.reload_ammo_amount = autocvar_g_balance_seeker_reload_ammo;
13 self.reload_time = autocvar_g_balance_seeker_reload_time;
14 self.reload_sound = "weapons/reload.wav";
19 void Seeker_Missile_Explode ()
21 self.event_damage = SUB_Null;
22 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);
27 void Seeker_Missile_Touch()
31 Seeker_Missile_Explode();
34 void Seeker_Missile_Think()
37 vector desireddir, olddir, newdir, eorg;
44 self.projectiledeathtype |= HITTYPE_SPLASH;
45 Seeker_Missile_Explode();
48 spd = vlen(self.velocity);
50 spd - autocvar_g_balance_seeker_missile_decel * frametime,
51 autocvar_g_balance_seeker_missile_speed_max,
52 spd + autocvar_g_balance_seeker_missile_accel * frametime
55 if (self.enemy != world)
56 if (self.enemy.takedamage != DAMAGE_AIM || self.enemy.deadflag != DEAD_NO)
59 if (self.enemy != world)
62 eorg = 0.5 * (e.absmin + e.absmax);
63 turnrate = autocvar_g_balance_seeker_missile_turnrate; // how fast to turn
64 desireddir = normalize(eorg - self.origin);
65 olddir = normalize(self.velocity); // get my current direction
66 dist = vlen(eorg - self.origin);
68 // Do evasive maneuvers for world objects? ( this should be a cpu hog. :P )
69 if (autocvar_g_balance_seeker_missile_smart && (dist > autocvar_g_balance_seeker_missile_smart_mindist))
71 // Is it a better idea (shorter distance) to trace to the target itself?
72 if ( vlen(self.origin + olddir * self.wait) < dist)
73 traceline(self.origin, self.origin + olddir * self.wait, FALSE, self);
75 traceline(self.origin, eorg, FALSE, self);
77 // Setup adaptive tracelength
78 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);
80 // Calc how important it is that we turn and add this to the desierd (enemy) dir.
81 desireddir = normalize(((trace_plane_normal * (1 - trace_fraction)) + (desireddir * trace_fraction)) * 0.5);
84 newdir = normalize(olddir + desireddir * turnrate); // take the average of the 2 directions; not the best method but simple & easy
85 self.velocity = newdir * spd; // make me fly in the new direction at my flight speed
89 if (autocvar_g_balance_seeker_missile_proxy)
91 if ( dist <= autocvar_g_balance_seeker_missile_proxy_maxrange)
93 if (self.autoswitch == 0)
95 self.autoswitch = time + autocvar_g_balance_seeker_missile_proxy_delay;
99 if (self.autoswitch <= time)
101 Seeker_Missile_Explode();
108 if (self.autoswitch != 0)
114 if (self.enemy.deadflag != DEAD_NO)
117 self.cnt = time + 1 + (random() * 4);
118 self.nextthink = self.cnt;
122 //self.angles = vectoangles(self.velocity); // turn model in the new flight direction
123 self.nextthink = time;// + 0.05; // csqc projectiles
124 UpdateCSQCProjectile(self);
129 void Seeker_Missile_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
131 if (self.health <= 0)
134 if (self.owner == attacker)
135 self.health = self.health - (damage * 0.25);
137 self.health = self.health - damage;
139 if (self.health <= 0)
140 W_PrepareExplosionByDamage(attacker, Seeker_Missile_Explode);
144 void Seeker_Missile_Animate()
146 self.frame = self.frame +1;
147 self.nextthink = time + 0.05;
149 if (self.enemy != world)
150 if (self.enemy.takedamage != DAMAGE_AIM || self.enemy.deadflag != DEAD_NO)
155 self.think = Seeker_Missile_Think;
156 self.nextthink = time;// + cvar("g_balance_seeker_missile_activate_delay"); // cant dealy with csqc projectiles
158 if (autocvar_g_balance_seeker_missile_proxy)
159 self.movetype = MOVETYPE_BOUNCEMISSILE;
161 self.movetype = MOVETYPE_FLYMISSILE;
164 UpdateCSQCProjectile(self);
168 void Seeker_Fire_Missile(vector f_diff)
170 local entity missile;
172 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
173 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
175 if(autocvar_g_balance_seeker_reload_ammo)
177 self.clip_load -= autocvar_g_balance_seeker_missile_ammo;
178 self.weapon_load[WEP_SEEKER] = self.clip_load;
181 self.ammo_rockets -= autocvar_g_balance_seeker_missile_ammo;
184 makevectors(self.v_angle);
185 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/seeker_fire.wav", CHAN_WEAPON, 0);
187 pointparticles(particleeffectnum("seeker_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
189 //self.detornator = FALSE;
192 missile.owner = self;
193 missile.classname = "seeker_missile";
194 missile.bot_dodge = TRUE;
195 missile.bot_dodgerating = autocvar_g_balance_seeker_missile_damage;
197 missile.think = Seeker_Missile_Think;
198 missile.touch = Seeker_Missile_Touch;
199 missile.event_damage = Seeker_Missile_Damage;
200 missile.nextthink = time;// + 0.2;// + cvar("g_balance_seeker_missile_activate_delay");
201 missile.cnt = time + autocvar_g_balance_seeker_missile_lifetime;
202 missile.enemy = self.enemy;
203 missile.solid = SOLID_BBOX;
205 missile.takedamage = DAMAGE_YES;
206 missile.health = autocvar_g_balance_seeker_missile_health;
207 missile.damageforcescale = autocvar_g_balance_seeker_missile_damageforcescale;
208 missile.projectiledeathtype = WEP_SEEKER;
209 //missile.think = Seeker_Missile_Animate; // csqc projectiles.
212 setorigin (missile, w_shotorg);
213 setsize (missile, '-4 -4 -4', '4 4 4');
214 missile.movetype = MOVETYPE_FLYMISSILE;
215 missile.flags = FL_PROJECTILE;
216 W_SETUPPROJECTILEVELOCITY_UP(missile, g_balance_seeker_missile);
218 missile.angles = vectoangles (missile.velocity);
220 CSQCProjectile(missile, FALSE, PROJECTILE_SEEKER, TRUE);
222 other = missile; MUTATOR_CALLHOOK(EditProjectile);
225 void Seeker_Vollycontroler_Think()
228 entity oldself,oldenemy;
229 self.cnt = self.cnt - 1;
231 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))
237 self.nextthink = time + autocvar_g_balance_seeker_missile_delay;
242 oldenemy = self.enemy;
243 self.enemy = oldself.enemy;
245 c = mod(oldself.cnt, 4);
249 Seeker_Fire_Missile('-1.25 -3.75 0');
252 Seeker_Fire_Missile('+1.25 -3.75 0');
255 Seeker_Fire_Missile('-1.25 +3.75 0');
259 Seeker_Fire_Missile('+1.25 +3.75 0');
263 self.enemy = oldenemy;
267 void Seeker_Tag_Explode ()
269 //if(other==self.owner)
271 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_BOUNCE, self);
276 void Seeker_Tag_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
278 if (self.health <= 0)
280 self.health = self.health - damage;
281 if (self.health <= 0)
282 Seeker_Tag_Explode();
286 void Seeker_Tag_Touch()
292 dir = normalize (self.owner.origin - self.origin);
293 org2 = findbetterlocation (self.origin, 8);
295 te_knightspike(org2);
297 self.event_damage = SUB_Null;
298 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_HEADSHOT, self);
300 if (other.takedamage == DAMAGE_AIM && other.deadflag == DEAD_NO)
303 e.cnt = autocvar_g_balance_seeker_missile_count;
304 e.owner = self.owner;
306 e.think = Seeker_Vollycontroler_Think;
314 void Seeker_Fire_Tag()
316 local entity missile;
317 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
318 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
320 if(autocvar_g_balance_seeker_reload_ammo)
322 self.clip_load -= autocvar_g_balance_seeker_tag_ammo;
323 self.weapon_load[WEP_SEEKER] = self.clip_load;
326 self.ammo_rockets -= autocvar_g_balance_seeker_tag_ammo;
329 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);
332 missile.owner = self;
333 missile.classname = "seeker_tag";
334 missile.bot_dodge = TRUE;
335 missile.bot_dodgerating = 50;
336 missile.touch = Seeker_Tag_Touch;
337 missile.think = SUB_Remove;
338 missile.nextthink = time + autocvar_g_balance_seeker_tag_lifetime;
339 missile.movetype = MOVETYPE_FLY;
340 missile.solid = SOLID_BBOX;
341 missile.owner = self;
343 missile.takedamage = DAMAGE_YES;
344 missile.event_damage = Seeker_Tag_Explode;
345 missile.health = autocvar_g_balance_seeker_tag_health;
346 missile.damageforcescale = autocvar_g_balance_seeker_tag_damageforcescale;
348 setorigin (missile, w_shotorg);
349 setsize (missile, '-2 -2 -2', '2 2 2');
351 missile.flags = FL_PROJECTILE;
353 missile.movetype = MOVETYPE_FLY;
354 W_SETUPPROJECTILEVELOCITY(missile, g_balance_seeker_tag);
355 missile.angles = vectoangles (missile.velocity);
357 CSQCProjectile(missile, TRUE, PROJECTILE_TAG, FALSE); // has sound
359 other = missile; MUTATOR_CALLHOOK(EditProjectile);
363 void Seeker_Flac_Explode ()
365 self.event_damage = SUB_Null;
367 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);
372 void Seeker_Flac_Touch()
376 Seeker_Flac_Explode();
379 void Seeker_Fire_Flac()
381 local entity missile;
385 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
386 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
388 if(autocvar_g_balance_seeker_reload_ammo)
390 self.clip_load -= autocvar_g_balance_seeker_flac_ammo;
391 self.weapon_load[WEP_SEEKER] = self.clip_load;
394 self.ammo_rockets -= autocvar_g_balance_seeker_flac_ammo;
397 c = mod(self.bulletcounter, 4);
401 f_diff = '-1.25 -3.75 0';
404 f_diff = '+1.25 -3.75 0';
407 f_diff = '-1.25 +3.75 0';
411 f_diff = '+1.25 +3.75 0';
414 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/flac_fire.wav", CHAN_WEAPON, autocvar_g_balance_seeker_flac_damage);
417 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
420 missile.owner = missile.realowner = self;
421 missile.classname = "missile";
422 missile.bot_dodge = TRUE;
423 missile.bot_dodgerating = autocvar_g_balance_seeker_flac_damage;
424 missile.touch = Seeker_Flac_Explode;
425 missile.use = Seeker_Flac_Explode;
426 missile.think = adaptor_think2use_hittype_splash;
427 missile.nextthink = time + autocvar_g_balance_seeker_flac_lifetime + autocvar_g_balance_seeker_flac_lifetime_rand;
428 missile.solid = SOLID_BBOX;
429 missile.movetype = MOVETYPE_FLY;
430 missile.projectiledeathtype = WEP_SEEKER;
431 missile.projectiledeathtype = WEP_SEEKER | HITTYPE_SECONDARY;
432 missile.flags = FL_PROJECTILE;
435 //missile.angles = vectoangles (missile.velocity);
436 //missile.scale = 0.4; // BUG: the model is too big
438 setorigin (missile, w_shotorg);
439 setsize (missile, '-2 -2 -2', '2 2 2');
441 W_SETUPPROJECTILEVELOCITY_UP(missile, g_balance_seeker_flac);
442 CSQCProjectile(missile, TRUE, PROJECTILE_FLAC, TRUE);
444 other = missile; MUTATOR_CALLHOOK(EditProjectile);
447 void spawnfunc_weapon_seeker (void)
449 weapon_defaultspawnfunc(WEP_SEEKER);
452 float w_seeker(float req)
457 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_seeker_tag_speed, 0, 20, FALSE);
459 else if (req == WR_THINK)
461 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
464 else if (self.BUTTON_ATCK)
466 if (weapon_prepareattack(0, autocvar_g_balance_seeker_tag_refire))
469 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_seeker_tag_animtime, w_ready);
473 else if (self.BUTTON_ATCK2)
475 if (weapon_prepareattack(1, autocvar_g_balance_seeker_flac_refire))
478 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_seeker_flac_animtime, w_ready);
482 else if (req == WR_PRECACHE)
484 precache_model ("models/weapons/g_seeker.md3");
485 precache_model ("models/weapons/v_seeker.md3");
486 precache_model ("models/weapons/h_seeker.iqm");
487 precache_sound ("weapons/tag_fire.wav");
488 precache_sound ("weapons/flac_fire.wav");
489 precache_sound ("weapons/seeker_fire.wav");
490 precache_sound ("weapons/reload.wav");
492 else if (req == WR_SETUP)
494 weapon_setup(WEP_SEEKER);
496 else if (req == WR_CHECKAMMO1)
498 ammo_amount = self.ammo_cells >= autocvar_g_balance_seeker_missile_ammo;
499 ammo_amount += self.weapon_load[WEP_SEEKER] >= autocvar_g_balance_seeker_missile_ammo;
502 else if (req == WR_CHECKAMMO2)
504 ammo_amount = self.ammo_cells >= autocvar_g_balance_seeker_flac_ammo;
505 ammo_amount += self.weapon_load[WEP_SEEKER] >= autocvar_g_balance_seeker_flac_ammo;
508 else if (req == WR_RELOAD)
516 float w_seeker(float req)
518 if(req == WR_IMPACTEFFECT)
521 org2 = w_org + w_backoff * 6;
522 if(w_deathtype & HITTYPE_SECONDARY)
524 pointparticles(particleeffectnum("flac_explode"), org2, '0 0 0', 1);
528 sound(self, CHAN_PROJECTILE, "weapons/flacexp1.wav", 1, ATTN_NORM);
529 else if (w_random<0.7)
530 sound(self, CHAN_PROJECTILE, "weapons/flacexp2.wav", 1, ATTN_NORM);
532 sound(self, CHAN_PROJECTILE, "weapons/flacexp3.wav", 1, ATTN_NORM);
537 if(w_deathtype & HITTYPE_BOUNCE)
539 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
543 sound(self, CHAN_PROJECTILE, "weapons/tagexp1.wav", 1, ATTN_NORM);
544 else if (w_random<0.7)
545 sound(self, CHAN_PROJECTILE, "weapons/tagexp2.wav", 1, ATTN_NORM);
547 sound(self, CHAN_PROJECTILE, "weapons/tagexp3.wav", 1, ATTN_NORM);
550 else if(w_deathtype & HITTYPE_HEADSHOT)
553 sound(self, CHAN_PROJECTILE, "weapons/tag_impact.wav", 1, ATTN_NORM);
557 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
561 sound(self, CHAN_PROJECTILE, "weapons/seekerexp1.wav", 1, ATTN_NORM);
562 else if (w_random<0.7)
563 sound(self, CHAN_PROJECTILE, "weapons/seekerexp2.wav", 1, ATTN_NORM);
565 sound(self, CHAN_PROJECTILE, "weapons/seekerexp3.wav", 1, ATTN_NORM);
570 else if(req == WR_PRECACHE)
572 precache_sound("weapons/flacexp1.wav");
573 precache_sound("weapons/flacexp2.wav");
574 precache_sound("weapons/flacexp3.wav");
575 precache_sound("weapons/seekerexp1.wav");
576 precache_sound("weapons/seekerexp2.wav");
577 precache_sound("weapons/seekerexp3.wav");
578 precache_sound("weapons/tagexp1.wav");
579 precache_sound("weapons/tagexp2.wav");
580 precache_sound("weapons/tagexp3.wav");
581 precache_sound("weapons/tag_impact.wav");
583 else if (req == WR_SUICIDEMESSAGE)
584 w_deathtypestring = _("%s played with tiny rockets");
585 else if (req == WR_KILLMESSAGE)
587 if(w_deathtype & HITTYPE_SECONDARY)
588 w_deathtypestring = _("%s ran into %s's flac");
590 w_deathtypestring = _("%s was tagged by %s");