4 /* function */ w_seeker,
5 /* ammotype */ IT_ROCKETS,
7 /* flags */ WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH,
8 /* rating */ BOT_PICKUP_RATING_MID,
10 /* shortname */ "seeker",
11 /* fullname */ _("T.A.G. Seeker")
15 //.float proxytime; = autoswitch
17 .entity tag_target, wps_tag_tracker;
20 // ============================
21 // Begin: Missile functions, these are general functions to be manipulated by other code
22 // ============================
23 void Seeker_Missile_Explode ()
25 self.event_damage = func_null;
26 RadiusDamage (self, self.realowner, 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);
31 void Seeker_Missile_Touch()
35 Seeker_Missile_Explode();
38 void Seeker_Missile_Think()
41 vector desireddir, olddir, newdir, eorg;
48 self.projectiledeathtype |= HITTYPE_SPLASH;
49 Seeker_Missile_Explode();
52 spd = vlen(self.velocity);
54 spd - autocvar_g_balance_seeker_missile_decel * frametime,
55 autocvar_g_balance_seeker_missile_speed_max,
56 spd + autocvar_g_balance_seeker_missile_accel * frametime
59 if (self.enemy != world)
60 if (self.enemy.takedamage != DAMAGE_AIM || self.enemy.deadflag != DEAD_NO)
63 if (self.enemy != world)
66 eorg = 0.5 * (e.absmin + e.absmax);
67 turnrate = autocvar_g_balance_seeker_missile_turnrate; // how fast to turn
68 desireddir = normalize(eorg - self.origin);
69 olddir = normalize(self.velocity); // get my current direction
70 dist = vlen(eorg - self.origin);
72 // Do evasive maneuvers for world objects? ( this should be a cpu hog. :P )
73 if (autocvar_g_balance_seeker_missile_smart && (dist > autocvar_g_balance_seeker_missile_smart_mindist))
75 // Is it a better idea (shorter distance) to trace to the target itself?
76 if ( vlen(self.origin + olddir * self.wait) < dist)
77 traceline(self.origin, self.origin + olddir * self.wait, FALSE, self);
79 traceline(self.origin, eorg, FALSE, self);
81 // Setup adaptive tracelength
82 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);
84 // Calc how important it is that we turn and add this to the desierd (enemy) dir.
85 desireddir = normalize(((trace_plane_normal * (1 - trace_fraction)) + (desireddir * trace_fraction)) * 0.5);
88 newdir = normalize(olddir + desireddir * turnrate); // take the average of the 2 directions; not the best method but simple & easy
89 self.velocity = newdir * spd; // make me fly in the new direction at my flight speed
95 if (autocvar_g_balance_seeker_missile_proxy)
97 if ( dist <= autocvar_g_balance_seeker_missile_proxy_maxrange)
99 if (self.autoswitch == 0)
101 self.autoswitch = time + autocvar_g_balance_seeker_missile_proxy_delay;
105 if (self.autoswitch <= time)
107 Seeker_Missile_Explode();
114 if (self.autoswitch != 0)
120 if (self.enemy.deadflag != DEAD_NO)
123 self.cnt = time + 1 + (random() * 4);
124 self.nextthink = self.cnt;
128 //self.angles = vectoangles(self.velocity); // turn model in the new flight direction
129 self.nextthink = time;// + 0.05; // csqc projectiles
130 UpdateCSQCProjectile(self);
135 void Seeker_Missile_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
137 if (self.health <= 0)
140 if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, -1)) // no exceptions
141 return; // g_projectiles_damage says to halt
143 if (self.realowner == attacker)
144 self.health = self.health - (damage * 0.25);
146 self.health = self.health - damage;
148 if (self.health <= 0)
149 W_PrepareExplosionByDamage(attacker, Seeker_Missile_Explode);
153 void Seeker_Missile_Animate()
155 self.frame = self.frame +1;
156 self.nextthink = time + 0.05;
158 if (self.enemy != world)
159 if (self.enemy.takedamage != DAMAGE_AIM || self.enemy.deadflag != DEAD_NO)
164 self.think = Seeker_Missile_Think;
165 self.nextthink = time;// + cvar("g_balance_seeker_missile_activate_delay"); // cant dealy with csqc projectiles
167 if (autocvar_g_balance_seeker_missile_proxy)
168 self.movetype = MOVETYPE_BOUNCEMISSILE;
170 self.movetype = MOVETYPE_FLYMISSILE;
173 UpdateCSQCProjectile(self);
177 void Seeker_Fire_Missile(vector f_diff, entity m_target)
181 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_seeker_missile_ammo, autocvar_g_balance_seeker_reload_ammo);
183 makevectors(self.v_angle);
184 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/seeker_fire.wav", CH_WEAPON_A, 0);
186 pointparticles(particleeffectnum("seeker_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
188 //self.detornator = FALSE;
191 missile.owner = missile.realowner = self;
192 missile.classname = "seeker_missile";
193 missile.bot_dodge = TRUE;
194 missile.bot_dodgerating = autocvar_g_balance_seeker_missile_damage;
196 missile.think = Seeker_Missile_Think;
197 missile.touch = Seeker_Missile_Touch;
198 missile.event_damage = Seeker_Missile_Damage;
199 missile.nextthink = time;// + 0.2;// + cvar("g_balance_seeker_missile_activate_delay");
200 missile.cnt = time + autocvar_g_balance_seeker_missile_lifetime;
201 missile.enemy = m_target;
202 missile.solid = SOLID_BBOX;
204 missile.takedamage = DAMAGE_YES;
205 missile.health = autocvar_g_balance_seeker_missile_health;
206 missile.damageforcescale = autocvar_g_balance_seeker_missile_damageforcescale;
207 missile.damagedbycontents = TRUE;
208 //missile.think = Seeker_Missile_Animate; // csqc projectiles.
210 if (missile.enemy != world)
211 missile.projectiledeathtype = WEP_SEEKER | HITTYPE_SECONDARY;
213 missile.projectiledeathtype = WEP_SEEKER;
216 setorigin (missile, w_shotorg);
217 setsize (missile, '-4 -4 -4', '4 4 4');
218 missile.movetype = MOVETYPE_FLYMISSILE;
219 missile.flags = FL_PROJECTILE;
220 missile.missile_flags = MIF_SPLASH | MIF_GUIDED_TAG;
222 W_SETUPPROJECTILEVELOCITY_UP(missile, g_balance_seeker_missile);
224 missile.angles = vectoangles (missile.velocity);
226 CSQCProjectile(missile, FALSE, PROJECTILE_SEEKER, TRUE);
228 other = missile; MUTATOR_CALLHOOK(EditProjectile);
231 // ============================
232 // Begin: FLAC, close range attack meant for defeating rockets which are coming at you.
233 // ============================
234 void Seeker_Flac_Explode ()
236 self.event_damage = func_null;
238 RadiusDamage (self, self.realowner, 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);
243 void Seeker_Flac_Touch()
247 Seeker_Flac_Explode();
250 void Seeker_Fire_Flac()
256 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_seeker_flac_ammo, autocvar_g_balance_seeker_reload_ammo);
258 c = mod(self.bulletcounter, 4);
262 f_diff = '-1.25 -3.75 0';
265 f_diff = '+1.25 -3.75 0';
268 f_diff = '-1.25 +3.75 0';
272 f_diff = '+1.25 +3.75 0';
275 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/flac_fire.wav", CH_WEAPON_A, autocvar_g_balance_seeker_flac_damage);
278 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
281 missile.owner = missile.realowner = self;
282 missile.classname = "missile";
283 missile.bot_dodge = TRUE;
284 missile.bot_dodgerating = autocvar_g_balance_seeker_flac_damage;
285 missile.touch = Seeker_Flac_Explode;
286 missile.use = Seeker_Flac_Explode;
287 missile.think = adaptor_think2use_hittype_splash;
288 missile.nextthink = time + autocvar_g_balance_seeker_flac_lifetime + autocvar_g_balance_seeker_flac_lifetime_rand;
289 missile.solid = SOLID_BBOX;
290 missile.movetype = MOVETYPE_FLY;
291 missile.projectiledeathtype = WEP_SEEKER;
292 missile.projectiledeathtype = WEP_SEEKER | HITTYPE_SECONDARY;
293 missile.flags = FL_PROJECTILE;
294 missile.missile_flags = MIF_SPLASH;
297 //missile.angles = vectoangles (missile.velocity);
298 //missile.scale = 0.4; // BUG: the model is too big
300 setorigin (missile, w_shotorg);
301 setsize (missile, '-2 -2 -2', '2 2 2');
303 W_SETUPPROJECTILEVELOCITY_UP(missile, g_balance_seeker_flac);
304 CSQCProjectile(missile, TRUE, PROJECTILE_FLAC, TRUE);
306 other = missile; MUTATOR_CALLHOOK(EditProjectile);
309 // ============================
310 // Begin: Tag and rocket controllers
311 // ============================
312 entity Seeker_Tagged_Info(entity isowner, entity istarget)
315 for(tag = world; (tag = find(tag, classname, "tag_tracker")); )
316 if ((tag.realowner == isowner) && (tag.tag_target == istarget))
324 entity tracker, closest_target;
326 closest_target = world;
327 for(tracker = world; (tracker = find(tracker, classname, "tag_tracker")); ) if (tracker.realowner == self)
331 if (vlen(self.origin - tracker.tag_target.origin) < vlen(self.origin - closest_target.origin))
332 closest_target = tracker.tag_target;
335 closest_target = tracker.tag_target;
338 traceline(self.origin + self.view_ofs, closest_target.origin, MOVE_NOMONSTERS, self);
339 if ((!closest_target) || ((trace_fraction < 1) && (trace_ent != closest_target)))
340 closest_target = world;
342 Seeker_Fire_Missile('0 0 0', closest_target);
345 void Seeker_Vollycontroller_Think() // TODO: Merge this with Seeker_Attack
348 entity oldself,oldenemy;
349 self.cnt = self.cnt - 1;
351 if((!(self.realowner.items & IT_UNLIMITED_AMMO) && self.realowner.ammo_rockets < autocvar_g_balance_seeker_missile_ammo) || (self.cnt <= -1) || (self.realowner.deadflag != DEAD_NO) || (self.realowner.switchweapon != WEP_SEEKER))
357 self.nextthink = time + autocvar_g_balance_seeker_missile_delay * W_WeaponRateFactor();
360 self = self.realowner;
362 oldenemy = self.enemy;
363 self.enemy = oldself.enemy;
365 c = mod(self.cnt, 4);
369 Seeker_Fire_Missile('-1.25 -3.75 0', self.enemy);
372 Seeker_Fire_Missile('+1.25 -3.75 0', self.enemy);
375 Seeker_Fire_Missile('-1.25 +3.75 0', self.enemy);
379 Seeker_Fire_Missile('+1.25 +3.75 0', self.enemy);
383 self.enemy = oldenemy;
387 void Seeker_Tracker_Think()
389 // commit suicide if: You die OR target dies OR you switch away from the seeker OR commit suicide if lifetime is up
390 if ((self.realowner.deadflag != DEAD_NO) || (self.tag_target.deadflag != DEAD_NO) || (self.realowner.switchweapon != WEP_SEEKER)
391 || (time > self.tag_time + autocvar_g_balance_seeker_tag_tracker_lifetime))
395 WaypointSprite_Kill(self.tag_target.wps_tag_tracker);
401 // Update the think method information
402 self.nextthink = time;
405 // ============================
406 // Begin: Tag projectile
407 // ============================
408 void Seeker_Tag_Explode ()
410 //if(other==self.realowner)
412 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_BOUNCE, other.species, self);
417 void Seeker_Tag_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
419 if (self.health <= 0)
421 self.health = self.health - damage;
422 if (self.health <= 0)
423 Seeker_Tag_Explode();
426 void Seeker_Tag_Touch()
434 dir = normalize (self.realowner.origin - self.origin);
435 org2 = findbetterlocation (self.origin, 8);
437 te_knightspike(org2);
439 self.event_damage = func_null;
440 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_BOUNCE | HITTYPE_SECONDARY, other.species, self);
442 if (other.takedamage == DAMAGE_AIM && other.deadflag == DEAD_NO)
444 // check to see if this person is already tagged by me
445 entity tag = Seeker_Tagged_Info(self.realowner, other);
449 if (other.wps_tag_tracker && (autocvar_g_balance_seeker_type == 1)) // don't attach another waypointsprite without killing the old one first
450 WaypointSprite_Kill(other.wps_tag_tracker);
456 //sprint(self.realowner, strcat("You just tagged ^2", other.netname, "^7 with a tracking device!\n"));
458 e.cnt = autocvar_g_balance_seeker_missile_count;
459 e.classname = "tag_tracker";
460 e.owner = self.owner;
461 e.realowner = self.realowner;
463 if (autocvar_g_balance_seeker_type == 1)
465 e.tag_target = other;
467 e.think = Seeker_Tracker_Think;
472 e.think = Seeker_Vollycontroller_Think;
478 if (autocvar_g_balance_seeker_type == 1)
480 WaypointSprite_Spawn("tagged-target", autocvar_g_balance_seeker_tag_tracker_lifetime, 0, other, '0 0 64', self.realowner, 0, other, wps_tag_tracker, TRUE, RADARICON_TAGGED, '0.5 1 0');
481 WaypointSprite_UpdateRule(other.wps_tag_tracker, 0, SPRITERULE_DEFAULT);
489 void Seeker_Fire_Tag()
492 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_seeker_tag_ammo, autocvar_g_balance_seeker_reload_ammo);
494 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/tag_fire.wav", CH_WEAPON_A, autocvar_g_balance_seeker_missile_damage * autocvar_g_balance_seeker_missile_count);
497 missile.owner = missile.realowner = self;
498 missile.classname = "seeker_tag";
499 missile.bot_dodge = TRUE;
500 missile.bot_dodgerating = 50;
501 missile.touch = Seeker_Tag_Touch;
502 missile.think = SUB_Remove;
503 missile.nextthink = time + autocvar_g_balance_seeker_tag_lifetime;
504 missile.movetype = MOVETYPE_FLY;
505 missile.solid = SOLID_BBOX;
507 missile.takedamage = DAMAGE_YES;
508 missile.event_damage = Seeker_Tag_Damage;
509 missile.health = autocvar_g_balance_seeker_tag_health;
510 missile.damageforcescale = autocvar_g_balance_seeker_tag_damageforcescale;
512 setorigin (missile, w_shotorg);
513 setsize (missile, '-2 -2 -2', '2 2 2');
515 missile.flags = FL_PROJECTILE;
516 //missile.missile_flags = MIF_..?;
518 missile.movetype = MOVETYPE_FLY;
519 W_SETUPPROJECTILEVELOCITY(missile, g_balance_seeker_tag);
520 missile.angles = vectoangles (missile.velocity);
522 CSQCProjectile(missile, TRUE, PROJECTILE_TAG, FALSE); // has sound
524 other = missile; MUTATOR_CALLHOOK(EditProjectile);
527 // ============================
528 // Begin: Genereal weapon functions
529 // ============================
530 void spawnfunc_weapon_seeker (void)
532 weapon_defaultspawnfunc(WEP_SEEKER);
535 float w_seeker(float req)
541 if (autocvar_g_balance_seeker_type == 1)
542 if (Seeker_Tagged_Info(self, self.enemy) != world)
543 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_seeker_missile_speed_max, 0, autocvar_g_balance_seeker_missile_lifetime, FALSE);
545 self.BUTTON_ATCK2 = bot_aim(autocvar_g_balance_seeker_tag_speed, 0, autocvar_g_balance_seeker_tag_lifetime, FALSE);
547 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_seeker_tag_speed, 0, autocvar_g_balance_seeker_tag_lifetime, FALSE);
549 else if (req == WR_THINK)
551 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
552 weapon_action(self.weapon, WR_RELOAD);
554 else if (self.BUTTON_ATCK)
556 if (autocvar_g_balance_seeker_type == 1)
558 if (weapon_prepareattack(0, autocvar_g_balance_seeker_missile_refire))
561 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_seeker_missile_animtime, w_ready);
566 if (weapon_prepareattack(0, autocvar_g_balance_seeker_tag_refire))
569 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_seeker_tag_animtime, w_ready);
574 else if (self.BUTTON_ATCK2)
576 if (autocvar_g_balance_seeker_type == 1)
578 if (weapon_prepareattack(0, autocvar_g_balance_seeker_tag_refire))
581 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_seeker_tag_animtime, w_ready);
586 if (weapon_prepareattack(0, autocvar_g_balance_seeker_flac_refire))
589 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_seeker_flac_animtime, w_ready);
594 else if (req == WR_PRECACHE)
596 precache_model ("models/weapons/g_seeker.md3");
597 precache_model ("models/weapons/v_seeker.md3");
598 precache_model ("models/weapons/h_seeker.iqm");
599 precache_sound ("weapons/tag_fire.wav");
600 precache_sound ("weapons/flac_fire.wav");
601 precache_sound ("weapons/seeker_fire.wav");
602 //precache_sound ("weapons/reload.wav"); // until weapons have individual reload sounds, precache the reload sound somewhere else
604 else if (req == WR_SETUP)
606 weapon_setup(WEP_SEEKER);
607 self.current_ammo = ammo_rockets;
609 else if (req == WR_CHECKAMMO1)
611 if (autocvar_g_balance_seeker_type == 1)
613 ammo_amount = self.ammo_rockets >= autocvar_g_balance_seeker_missile_ammo;
614 ammo_amount += self.(weapon_load[WEP_SEEKER]) >= autocvar_g_balance_seeker_missile_ammo;
618 ammo_amount = self.ammo_rockets >= autocvar_g_balance_seeker_tag_ammo;
619 ammo_amount += self.(weapon_load[WEP_SEEKER]) >= autocvar_g_balance_seeker_tag_ammo;
624 else if (req == WR_CHECKAMMO2)
626 if (autocvar_g_balance_seeker_type == 1)
628 ammo_amount = self.ammo_rockets >= autocvar_g_balance_seeker_tag_ammo;
629 ammo_amount += self.(weapon_load[WEP_SEEKER]) >= autocvar_g_balance_seeker_tag_ammo;
633 ammo_amount = self.ammo_rockets >= autocvar_g_balance_seeker_flac_ammo;
634 ammo_amount += self.(weapon_load[WEP_SEEKER]) >= autocvar_g_balance_seeker_flac_ammo;
639 else if (req == WR_RELOAD)
641 W_Reload(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");
643 else if (req == WR_SUICIDEMESSAGE)
645 return WEAPON_SEEKER_SUICIDE;
647 else if (req == WR_KILLMESSAGE)
649 if(w_deathtype & HITTYPE_SECONDARY)
650 return WEAPON_SEEKER_MURDER_TAG;
652 return WEAPON_SEEKER_MURDER_SPRAY;
658 float w_seeker(float req)
660 if(req == WR_IMPACTEFFECT)
663 org2 = w_org + w_backoff * 6;
664 if(w_deathtype & HITTYPE_BOUNCE)
666 if(w_deathtype & HITTYPE_SECONDARY)
669 sound(self, CH_SHOTS, "weapons/tag_impact.wav", 1, ATTEN_NORM);
673 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
677 sound(self, CH_SHOTS, "weapons/tagexp1.wav", 1, ATTEN_NORM);
678 else if (w_random<0.7)
679 sound(self, CH_SHOTS, "weapons/tagexp2.wav", 1, ATTEN_NORM);
681 sound(self, CH_SHOTS, "weapons/tagexp3.wav", 1, ATTEN_NORM);
687 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
691 sound(self, CH_SHOTS, "weapons/seekerexp1.wav", 1, ATTEN_NORM);
692 else if (w_random<0.7)
693 sound(self, CH_SHOTS, "weapons/seekerexp2.wav", 1, ATTEN_NORM);
695 sound(self, CH_SHOTS, "weapons/seekerexp3.wav", 1, ATTEN_NORM);
699 else if(req == WR_PRECACHE)
701 precache_sound("weapons/seekerexp1.wav");
702 precache_sound("weapons/seekerexp2.wav");
703 precache_sound("weapons/seekerexp3.wav");
704 precache_sound("weapons/tagexp1.wav");
705 precache_sound("weapons/tagexp2.wav");
706 precache_sound("weapons/tagexp3.wav");
707 precache_sound("weapons/tag_impact.wav");