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 W_Reload(ammo_rockets, min(autocvar_g_balance_seeker_missile_ammo, autocvar_g_balance_seeker_tag_ammo), autocvar_g_balance_seeker_reload_ammo, autocvar_g_balance_seeker_reload_time, "weapons/reload.wav");
13 void Seeker_Missile_Explode ()
15 self.event_damage = SUB_Null;
16 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);
21 void Seeker_Missile_Touch()
25 Seeker_Missile_Explode();
28 void Seeker_Missile_Think()
31 vector desireddir, olddir, newdir, eorg;
38 self.projectiledeathtype |= HITTYPE_SPLASH;
39 Seeker_Missile_Explode();
42 spd = vlen(self.velocity);
44 spd - autocvar_g_balance_seeker_missile_decel * frametime,
45 autocvar_g_balance_seeker_missile_speed_max,
46 spd + autocvar_g_balance_seeker_missile_accel * frametime
49 if (self.enemy != world)
50 if (self.enemy.takedamage != DAMAGE_AIM || self.enemy.deadflag != DEAD_NO)
53 if (self.enemy != world)
56 eorg = 0.5 * (e.absmin + e.absmax);
57 turnrate = autocvar_g_balance_seeker_missile_turnrate; // how fast to turn
58 desireddir = normalize(eorg - self.origin);
59 olddir = normalize(self.velocity); // get my current direction
60 dist = vlen(eorg - self.origin);
62 // Do evasive maneuvers for world objects? ( this should be a cpu hog. :P )
63 if (autocvar_g_balance_seeker_missile_smart && (dist > autocvar_g_balance_seeker_missile_smart_mindist))
65 // Is it a better idea (shorter distance) to trace to the target itself?
66 if ( vlen(self.origin + olddir * self.wait) < dist)
67 traceline(self.origin, self.origin + olddir * self.wait, FALSE, self);
69 traceline(self.origin, eorg, FALSE, self);
71 // Setup adaptive tracelength
72 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);
74 // Calc how important it is that we turn and add this to the desierd (enemy) dir.
75 desireddir = normalize(((trace_plane_normal * (1 - trace_fraction)) + (desireddir * trace_fraction)) * 0.5);
78 newdir = normalize(olddir + desireddir * turnrate); // take the average of the 2 directions; not the best method but simple & easy
79 self.velocity = newdir * spd; // make me fly in the new direction at my flight speed
83 if (autocvar_g_balance_seeker_missile_proxy)
85 if ( dist <= autocvar_g_balance_seeker_missile_proxy_maxrange)
87 if (self.autoswitch == 0)
89 self.autoswitch = time + autocvar_g_balance_seeker_missile_proxy_delay;
93 if (self.autoswitch <= time)
95 Seeker_Missile_Explode();
102 if (self.autoswitch != 0)
108 if (self.enemy.deadflag != DEAD_NO)
111 self.cnt = time + 1 + (random() * 4);
112 self.nextthink = self.cnt;
116 //self.angles = vectoangles(self.velocity); // turn model in the new flight direction
117 self.nextthink = time;// + 0.05; // csqc projectiles
118 UpdateCSQCProjectile(self);
123 void Seeker_Missile_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
125 if (self.health <= 0)
128 if (self.owner == attacker)
129 self.health = self.health - (damage * 0.25);
131 self.health = self.health - damage;
133 if (self.health <= 0)
134 W_PrepareExplosionByDamage(attacker, Seeker_Missile_Explode);
138 void Seeker_Missile_Animate()
140 self.frame = self.frame +1;
141 self.nextthink = time + 0.05;
143 if (self.enemy != world)
144 if (self.enemy.takedamage != DAMAGE_AIM || self.enemy.deadflag != DEAD_NO)
149 self.think = Seeker_Missile_Think;
150 self.nextthink = time;// + cvar("g_balance_seeker_missile_activate_delay"); // cant dealy with csqc projectiles
152 if (autocvar_g_balance_seeker_missile_proxy)
153 self.movetype = MOVETYPE_BOUNCEMISSILE;
155 self.movetype = MOVETYPE_FLYMISSILE;
158 UpdateCSQCProjectile(self);
162 void Seeker_Fire_Missile(vector f_diff)
164 local entity missile;
166 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
167 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
169 if(autocvar_g_balance_seeker_reload_ammo)
171 self.clip_load -= autocvar_g_balance_seeker_missile_ammo;
172 self.weapon_load[WEP_SEEKER] = self.clip_load;
175 self.ammo_rockets -= autocvar_g_balance_seeker_missile_ammo;
178 makevectors(self.v_angle);
179 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/seeker_fire.wav", CHAN_WEAPON, 0);
181 pointparticles(particleeffectnum("seeker_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
183 //self.detornator = FALSE;
186 missile.owner = self;
187 missile.classname = "seeker_missile";
188 missile.bot_dodge = TRUE;
189 missile.bot_dodgerating = autocvar_g_balance_seeker_missile_damage;
191 missile.think = Seeker_Missile_Think;
192 missile.touch = Seeker_Missile_Touch;
193 missile.event_damage = Seeker_Missile_Damage;
194 missile.nextthink = time;// + 0.2;// + cvar("g_balance_seeker_missile_activate_delay");
195 missile.cnt = time + autocvar_g_balance_seeker_missile_lifetime;
196 missile.enemy = self.enemy;
197 missile.solid = SOLID_BBOX;
199 missile.takedamage = DAMAGE_YES;
200 missile.health = autocvar_g_balance_seeker_missile_health;
201 missile.damageforcescale = autocvar_g_balance_seeker_missile_damageforcescale;
202 missile.projectiledeathtype = WEP_SEEKER;
203 //missile.think = Seeker_Missile_Animate; // csqc projectiles.
206 setorigin (missile, w_shotorg);
207 setsize (missile, '-4 -4 -4', '4 4 4');
208 missile.movetype = MOVETYPE_FLYMISSILE;
209 missile.flags = FL_PROJECTILE;
210 W_SETUPPROJECTILEVELOCITY_UP(missile, g_balance_seeker_missile);
212 missile.angles = vectoangles (missile.velocity);
214 CSQCProjectile(missile, FALSE, PROJECTILE_SEEKER, TRUE);
216 other = missile; MUTATOR_CALLHOOK(EditProjectile);
219 void Seeker_Vollycontroler_Think()
222 entity oldself,oldenemy;
223 self.cnt = self.cnt - 1;
225 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))
231 self.nextthink = time + autocvar_g_balance_seeker_missile_delay;
236 oldenemy = self.enemy;
237 self.enemy = oldself.enemy;
239 c = mod(oldself.cnt, 4);
243 Seeker_Fire_Missile('-1.25 -3.75 0');
246 Seeker_Fire_Missile('+1.25 -3.75 0');
249 Seeker_Fire_Missile('-1.25 +3.75 0');
253 Seeker_Fire_Missile('+1.25 +3.75 0');
257 self.enemy = oldenemy;
261 void Seeker_Tag_Explode ()
263 //if(other==self.owner)
265 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_BOUNCE, self);
270 void Seeker_Tag_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
272 if (self.health <= 0)
274 self.health = self.health - damage;
275 if (self.health <= 0)
276 Seeker_Tag_Explode();
280 void Seeker_Tag_Touch()
286 dir = normalize (self.owner.origin - self.origin);
287 org2 = findbetterlocation (self.origin, 8);
289 te_knightspike(org2);
291 self.event_damage = SUB_Null;
292 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_HEADSHOT, self);
294 if (other.takedamage == DAMAGE_AIM && other.deadflag == DEAD_NO)
297 e.cnt = autocvar_g_balance_seeker_missile_count;
298 e.owner = self.owner;
300 e.think = Seeker_Vollycontroler_Think;
308 void Seeker_Fire_Tag()
310 local entity missile;
311 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
312 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
314 if(autocvar_g_balance_seeker_reload_ammo)
316 self.clip_load -= autocvar_g_balance_seeker_tag_ammo;
317 self.weapon_load[WEP_SEEKER] = self.clip_load;
320 self.ammo_rockets -= autocvar_g_balance_seeker_tag_ammo;
323 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);
326 missile.owner = self;
327 missile.classname = "seeker_tag";
328 missile.bot_dodge = TRUE;
329 missile.bot_dodgerating = 50;
330 missile.touch = Seeker_Tag_Touch;
331 missile.think = SUB_Remove;
332 missile.nextthink = time + autocvar_g_balance_seeker_tag_lifetime;
333 missile.movetype = MOVETYPE_FLY;
334 missile.solid = SOLID_BBOX;
335 missile.owner = self;
337 missile.takedamage = DAMAGE_YES;
338 missile.event_damage = Seeker_Tag_Explode;
339 missile.health = autocvar_g_balance_seeker_tag_health;
340 missile.damageforcescale = autocvar_g_balance_seeker_tag_damageforcescale;
342 setorigin (missile, w_shotorg);
343 setsize (missile, '-2 -2 -2', '2 2 2');
345 missile.flags = FL_PROJECTILE;
347 missile.movetype = MOVETYPE_FLY;
348 W_SETUPPROJECTILEVELOCITY(missile, g_balance_seeker_tag);
349 missile.angles = vectoangles (missile.velocity);
351 CSQCProjectile(missile, TRUE, PROJECTILE_TAG, FALSE); // has sound
353 other = missile; MUTATOR_CALLHOOK(EditProjectile);
357 void Seeker_Flac_Explode ()
359 self.event_damage = SUB_Null;
361 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);
366 void Seeker_Flac_Touch()
370 Seeker_Flac_Explode();
373 void Seeker_Fire_Flac()
375 local entity missile;
379 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
380 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
382 if(autocvar_g_balance_seeker_reload_ammo)
384 self.clip_load -= autocvar_g_balance_seeker_flac_ammo;
385 self.weapon_load[WEP_SEEKER] = self.clip_load;
388 self.ammo_rockets -= autocvar_g_balance_seeker_flac_ammo;
391 c = mod(self.bulletcounter, 4);
395 f_diff = '-1.25 -3.75 0';
398 f_diff = '+1.25 -3.75 0';
401 f_diff = '-1.25 +3.75 0';
405 f_diff = '+1.25 +3.75 0';
408 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/flac_fire.wav", CHAN_WEAPON, autocvar_g_balance_seeker_flac_damage);
411 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
414 missile.owner = missile.realowner = self;
415 missile.classname = "missile";
416 missile.bot_dodge = TRUE;
417 missile.bot_dodgerating = autocvar_g_balance_seeker_flac_damage;
418 missile.touch = Seeker_Flac_Explode;
419 missile.use = Seeker_Flac_Explode;
420 missile.think = adaptor_think2use_hittype_splash;
421 missile.nextthink = time + autocvar_g_balance_seeker_flac_lifetime + autocvar_g_balance_seeker_flac_lifetime_rand;
422 missile.solid = SOLID_BBOX;
423 missile.movetype = MOVETYPE_FLY;
424 missile.projectiledeathtype = WEP_SEEKER;
425 missile.projectiledeathtype = WEP_SEEKER | HITTYPE_SECONDARY;
426 missile.flags = FL_PROJECTILE;
429 //missile.angles = vectoangles (missile.velocity);
430 //missile.scale = 0.4; // BUG: the model is too big
432 setorigin (missile, w_shotorg);
433 setsize (missile, '-2 -2 -2', '2 2 2');
435 W_SETUPPROJECTILEVELOCITY_UP(missile, g_balance_seeker_flac);
436 CSQCProjectile(missile, TRUE, PROJECTILE_FLAC, TRUE);
438 other = missile; MUTATOR_CALLHOOK(EditProjectile);
441 void spawnfunc_weapon_seeker (void)
443 weapon_defaultspawnfunc(WEP_SEEKER);
446 float w_seeker(float req)
451 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_seeker_tag_speed, 0, 20, FALSE);
453 else if (req == WR_THINK)
455 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
458 else if (self.BUTTON_ATCK)
460 if (weapon_prepareattack(0, autocvar_g_balance_seeker_tag_refire))
463 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_seeker_tag_animtime, w_ready);
467 else if (self.BUTTON_ATCK2)
469 if (weapon_prepareattack(1, autocvar_g_balance_seeker_flac_refire))
472 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_seeker_flac_animtime, w_ready);
476 else if (req == WR_PRECACHE)
478 precache_model ("models/weapons/g_seeker.md3");
479 precache_model ("models/weapons/v_seeker.md3");
480 precache_model ("models/weapons/h_seeker.iqm");
481 precache_sound ("weapons/tag_fire.wav");
482 precache_sound ("weapons/flac_fire.wav");
483 precache_sound ("weapons/seeker_fire.wav");
484 precache_sound ("weapons/reload.wav");
486 else if (req == WR_SETUP)
488 weapon_setup(WEP_SEEKER);
490 else if (req == WR_CHECKAMMO1)
492 ammo_amount = self.ammo_cells >= autocvar_g_balance_seeker_missile_ammo;
493 ammo_amount += self.weapon_load[WEP_SEEKER] >= autocvar_g_balance_seeker_missile_ammo;
496 else if (req == WR_CHECKAMMO2)
498 ammo_amount = self.ammo_cells >= autocvar_g_balance_seeker_flac_ammo;
499 ammo_amount += self.weapon_load[WEP_SEEKER] >= autocvar_g_balance_seeker_flac_ammo;
502 else if (req == WR_RELOAD)
510 float w_seeker(float req)
512 if(req == WR_IMPACTEFFECT)
515 org2 = w_org + w_backoff * 6;
516 if(w_deathtype & HITTYPE_SECONDARY)
518 pointparticles(particleeffectnum("flac_explode"), org2, '0 0 0', 1);
522 sound(self, CHAN_PROJECTILE, "weapons/flacexp1.wav", 1, ATTN_NORM);
523 else if (w_random<0.7)
524 sound(self, CHAN_PROJECTILE, "weapons/flacexp2.wav", 1, ATTN_NORM);
526 sound(self, CHAN_PROJECTILE, "weapons/flacexp3.wav", 1, ATTN_NORM);
531 if(w_deathtype & HITTYPE_BOUNCE)
533 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
537 sound(self, CHAN_PROJECTILE, "weapons/tagexp1.wav", 1, ATTN_NORM);
538 else if (w_random<0.7)
539 sound(self, CHAN_PROJECTILE, "weapons/tagexp2.wav", 1, ATTN_NORM);
541 sound(self, CHAN_PROJECTILE, "weapons/tagexp3.wav", 1, ATTN_NORM);
544 else if(w_deathtype & HITTYPE_HEADSHOT)
547 sound(self, CHAN_PROJECTILE, "weapons/tag_impact.wav", 1, ATTN_NORM);
551 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
555 sound(self, CHAN_PROJECTILE, "weapons/seekerexp1.wav", 1, ATTN_NORM);
556 else if (w_random<0.7)
557 sound(self, CHAN_PROJECTILE, "weapons/seekerexp2.wav", 1, ATTN_NORM);
559 sound(self, CHAN_PROJECTILE, "weapons/seekerexp3.wav", 1, ATTN_NORM);
564 else if(req == WR_PRECACHE)
566 precache_sound("weapons/flacexp1.wav");
567 precache_sound("weapons/flacexp2.wav");
568 precache_sound("weapons/flacexp3.wav");
569 precache_sound("weapons/seekerexp1.wav");
570 precache_sound("weapons/seekerexp2.wav");
571 precache_sound("weapons/seekerexp3.wav");
572 precache_sound("weapons/tagexp1.wav");
573 precache_sound("weapons/tagexp2.wav");
574 precache_sound("weapons/tagexp3.wav");
575 precache_sound("weapons/tag_impact.wav");
577 else if (req == WR_SUICIDEMESSAGE)
578 w_deathtypestring = _("%s played with tiny rockets");
579 else if (req == WR_KILLMESSAGE)
581 if(w_deathtype & HITTYPE_SECONDARY)
582 w_deathtypestring = _("%s ran into %s's flac");
584 w_deathtypestring = _("%s was tagged by %s");