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
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 this weapon is reloadable, decrease its load. Else decrease the player's ammo
162 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
164 if(autocvar_g_balance_seeker_reload_ammo)
166 self.clip_load -= autocvar_g_balance_seeker_missile_ammo;
167 self.weapon_load[WEP_SEEKER] = self.clip_load;
170 self.ammo_rockets -= autocvar_g_balance_seeker_missile_ammo;
173 makevectors(self.v_angle);
174 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/seeker_fire.wav", CHAN_WEAPON, 0);
176 pointparticles(particleeffectnum("seeker_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
178 //self.detornator = FALSE;
181 missile.owner = self;
182 missile.classname = "seeker_missile";
183 missile.bot_dodge = TRUE;
184 missile.bot_dodgerating = autocvar_g_balance_seeker_missile_damage;
186 missile.think = Seeker_Missile_Think;
187 missile.touch = Seeker_Missile_Touch;
188 missile.event_damage = Seeker_Missile_Damage;
189 missile.nextthink = time;// + 0.2;// + cvar("g_balance_seeker_missile_activate_delay");
190 missile.cnt = time + autocvar_g_balance_seeker_missile_lifetime;
191 missile.enemy = self.enemy;
192 missile.solid = SOLID_BBOX;
194 missile.takedamage = DAMAGE_YES;
195 missile.health = autocvar_g_balance_seeker_missile_health;
196 missile.damageforcescale = autocvar_g_balance_seeker_missile_damageforcescale;
197 missile.projectiledeathtype = WEP_SEEKER;
198 //missile.think = Seeker_Missile_Animate; // csqc projectiles.
201 setorigin (missile, w_shotorg);
202 setsize (missile, '-4 -4 -4', '4 4 4');
203 missile.movetype = MOVETYPE_FLYMISSILE;
204 missile.flags = FL_PROJECTILE;
205 W_SETUPPROJECTILEVELOCITY_UP(missile, g_balance_seeker_missile);
207 missile.angles = vectoangles (missile.velocity);
209 CSQCProjectile(missile, FALSE, PROJECTILE_SEEKER, TRUE);
211 other = missile; MUTATOR_CALLHOOK(EditProjectile);
214 void Seeker_Vollycontroler_Think()
217 entity oldself,oldenemy;
218 self.cnt = self.cnt - 1;
220 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))
226 self.nextthink = time + autocvar_g_balance_seeker_missile_delay;
231 oldenemy = self.enemy;
232 self.enemy = oldself.enemy;
234 c = mod(oldself.cnt, 4);
238 Seeker_Fire_Missile('-1.25 -3.75 0');
241 Seeker_Fire_Missile('+1.25 -3.75 0');
244 Seeker_Fire_Missile('-1.25 +3.75 0');
248 Seeker_Fire_Missile('+1.25 +3.75 0');
252 self.enemy = oldenemy;
256 void Seeker_Tag_Explode ()
258 //if(other==self.owner)
260 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_BOUNCE, self);
265 void Seeker_Tag_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
267 if (self.health <= 0)
269 self.health = self.health - damage;
270 if (self.health <= 0)
271 Seeker_Tag_Explode();
275 void Seeker_Tag_Touch()
281 dir = normalize (self.owner.origin - self.origin);
282 org2 = findbetterlocation (self.origin, 8);
284 te_knightspike(org2);
286 self.event_damage = SUB_Null;
287 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_HEADSHOT, self);
289 if (other.takedamage == DAMAGE_AIM && other.deadflag == DEAD_NO)
292 e.cnt = autocvar_g_balance_seeker_missile_count;
293 e.owner = self.owner;
295 e.think = Seeker_Vollycontroler_Think;
303 void Seeker_Fire_Tag()
305 local entity missile;
306 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
307 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
309 if(autocvar_g_balance_seeker_reload_ammo)
311 self.clip_load -= autocvar_g_balance_seeker_tag_ammo;
312 self.weapon_load[WEP_SEEKER] = self.clip_load;
315 self.ammo_rockets -= autocvar_g_balance_seeker_tag_ammo;
318 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);
321 missile.owner = self;
322 missile.classname = "seeker_tag";
323 missile.bot_dodge = TRUE;
324 missile.bot_dodgerating = 50;
325 missile.touch = Seeker_Tag_Touch;
326 missile.think = SUB_Remove;
327 missile.nextthink = time + autocvar_g_balance_seeker_tag_lifetime;
328 missile.movetype = MOVETYPE_FLY;
329 missile.solid = SOLID_BBOX;
330 missile.owner = self;
332 missile.takedamage = DAMAGE_YES;
333 missile.event_damage = Seeker_Tag_Explode;
334 missile.health = autocvar_g_balance_seeker_tag_health;
335 missile.damageforcescale = autocvar_g_balance_seeker_tag_damageforcescale;
337 setorigin (missile, w_shotorg);
338 setsize (missile, '-2 -2 -2', '2 2 2');
340 missile.flags = FL_PROJECTILE;
342 missile.movetype = MOVETYPE_FLY;
343 W_SETUPPROJECTILEVELOCITY(missile, g_balance_seeker_tag);
344 missile.angles = vectoangles (missile.velocity);
346 CSQCProjectile(missile, TRUE, PROJECTILE_TAG, FALSE); // has sound
348 other = missile; MUTATOR_CALLHOOK(EditProjectile);
352 void Seeker_Flac_Explode ()
354 self.event_damage = SUB_Null;
356 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);
361 void Seeker_Flac_Touch()
365 Seeker_Flac_Explode();
368 void Seeker_Fire_Flac()
370 local entity missile;
374 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
375 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
377 if(autocvar_g_balance_seeker_reload_ammo)
379 self.clip_load -= autocvar_g_balance_seeker_flac_ammo;
380 self.weapon_load[WEP_SEEKER] = self.clip_load;
383 self.ammo_rockets -= autocvar_g_balance_seeker_flac_ammo;
386 c = mod(self.bulletcounter, 4);
390 f_diff = '-1.25 -3.75 0';
393 f_diff = '+1.25 -3.75 0';
396 f_diff = '-1.25 +3.75 0';
400 f_diff = '+1.25 +3.75 0';
403 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/flac_fire.wav", CHAN_WEAPON, autocvar_g_balance_seeker_flac_damage);
406 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
409 missile.owner = missile.realowner = self;
410 missile.classname = "missile";
411 missile.bot_dodge = TRUE;
412 missile.bot_dodgerating = autocvar_g_balance_seeker_flac_damage;
413 missile.touch = Seeker_Flac_Explode;
414 missile.use = Seeker_Flac_Explode;
415 missile.think = adaptor_think2use_hittype_splash;
416 missile.nextthink = time + autocvar_g_balance_seeker_flac_lifetime + autocvar_g_balance_seeker_flac_lifetime_rand;
417 missile.solid = SOLID_BBOX;
418 missile.movetype = MOVETYPE_FLY;
419 missile.projectiledeathtype = WEP_SEEKER;
420 missile.projectiledeathtype = WEP_SEEKER | HITTYPE_SECONDARY;
421 missile.flags = FL_PROJECTILE;
424 //missile.angles = vectoangles (missile.velocity);
425 //missile.scale = 0.4; // BUG: the model is too big
427 setorigin (missile, w_shotorg);
428 setsize (missile, '-2 -2 -2', '2 2 2');
430 W_SETUPPROJECTILEVELOCITY_UP(missile, g_balance_seeker_flac);
431 CSQCProjectile(missile, TRUE, PROJECTILE_FLAC, TRUE);
433 other = missile; MUTATOR_CALLHOOK(EditProjectile);
436 void spawnfunc_weapon_seeker (void)
438 weapon_defaultspawnfunc(WEP_SEEKER);
441 float w_seeker(float req)
446 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_seeker_tag_speed, 0, 20, FALSE);
448 else if (req == WR_THINK)
450 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
451 weapon_action(self.weapon, WR_RELOAD);
453 else if (self.BUTTON_ATCK)
455 if (weapon_prepareattack(0, autocvar_g_balance_seeker_tag_refire))
458 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_seeker_tag_animtime, w_ready);
462 else if (self.BUTTON_ATCK2)
464 if (weapon_prepareattack(1, autocvar_g_balance_seeker_flac_refire))
467 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_seeker_flac_animtime, w_ready);
471 else if (req == WR_PRECACHE)
473 precache_model ("models/weapons/g_seeker.md3");
474 precache_model ("models/weapons/v_seeker.md3");
475 precache_model ("models/weapons/h_seeker.iqm");
476 precache_sound ("weapons/tag_fire.wav");
477 precache_sound ("weapons/flac_fire.wav");
478 precache_sound ("weapons/seeker_fire.wav");
479 precache_sound ("weapons/reload.wav");
481 else if (req == WR_SETUP)
483 weapon_setup(WEP_SEEKER);
485 else if (req == WR_CHECKAMMO1)
487 ammo_amount = self.ammo_cells >= autocvar_g_balance_seeker_missile_ammo;
488 ammo_amount += self.weapon_load[WEP_SEEKER] >= autocvar_g_balance_seeker_missile_ammo;
491 else if (req == WR_CHECKAMMO2)
493 ammo_amount = self.ammo_cells >= autocvar_g_balance_seeker_flac_ammo;
494 ammo_amount += self.weapon_load[WEP_SEEKER] >= autocvar_g_balance_seeker_flac_ammo;
497 else if (req == WR_RELOAD)
499 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");
505 float w_seeker(float req)
507 if(req == WR_IMPACTEFFECT)
510 org2 = w_org + w_backoff * 6;
511 if(w_deathtype & HITTYPE_SECONDARY)
513 pointparticles(particleeffectnum("flac_explode"), org2, '0 0 0', 1);
517 sound(self, CHAN_PROJECTILE, "weapons/flacexp1.wav", 1, ATTN_NORM);
518 else if (w_random<0.7)
519 sound(self, CHAN_PROJECTILE, "weapons/flacexp2.wav", 1, ATTN_NORM);
521 sound(self, CHAN_PROJECTILE, "weapons/flacexp3.wav", 1, ATTN_NORM);
526 if(w_deathtype & HITTYPE_BOUNCE)
528 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
532 sound(self, CHAN_PROJECTILE, "weapons/tagexp1.wav", 1, ATTN_NORM);
533 else if (w_random<0.7)
534 sound(self, CHAN_PROJECTILE, "weapons/tagexp2.wav", 1, ATTN_NORM);
536 sound(self, CHAN_PROJECTILE, "weapons/tagexp3.wav", 1, ATTN_NORM);
539 else if(w_deathtype & HITTYPE_HEADSHOT)
542 sound(self, CHAN_PROJECTILE, "weapons/tag_impact.wav", 1, ATTN_NORM);
546 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
550 sound(self, CHAN_PROJECTILE, "weapons/seekerexp1.wav", 1, ATTN_NORM);
551 else if (w_random<0.7)
552 sound(self, CHAN_PROJECTILE, "weapons/seekerexp2.wav", 1, ATTN_NORM);
554 sound(self, CHAN_PROJECTILE, "weapons/seekerexp3.wav", 1, ATTN_NORM);
559 else if(req == WR_PRECACHE)
561 precache_sound("weapons/flacexp1.wav");
562 precache_sound("weapons/flacexp2.wav");
563 precache_sound("weapons/flacexp3.wav");
564 precache_sound("weapons/seekerexp1.wav");
565 precache_sound("weapons/seekerexp2.wav");
566 precache_sound("weapons/seekerexp3.wav");
567 precache_sound("weapons/tagexp1.wav");
568 precache_sound("weapons/tagexp2.wav");
569 precache_sound("weapons/tagexp3.wav");
570 precache_sound("weapons/tag_impact.wav");
572 else if (req == WR_SUICIDEMESSAGE)
573 w_deathtypestring = _("%s played with tiny rockets");
574 else if (req == WR_KILLMESSAGE)
576 if(w_deathtype & HITTYPE_SECONDARY)
577 w_deathtypestring = _("%s ran into %s's flac");
579 w_deathtypestring = _("%s was tagged by %s");