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, world, autocvar_g_balance_seeker_missile_force, self.projectiledeathtype, other);
32 void Seeker_Missile_Touch()
36 Seeker_Missile_Explode();
39 void Seeker_Missile_Think()
42 vector desireddir, olddir, newdir, eorg;
49 self.projectiledeathtype |= HITTYPE_SPLASH;
50 Seeker_Missile_Explode();
53 spd = vlen(self.velocity);
55 spd - autocvar_g_balance_seeker_missile_decel * frametime,
56 autocvar_g_balance_seeker_missile_speed_max,
57 spd + autocvar_g_balance_seeker_missile_accel * frametime
60 if (self.enemy != world)
61 if (self.enemy.takedamage != DAMAGE_AIM || self.enemy.deadflag != DEAD_NO)
64 if (self.enemy != world)
67 eorg = 0.5 * (e.absmin + e.absmax);
68 turnrate = autocvar_g_balance_seeker_missile_turnrate; // how fast to turn
69 desireddir = normalize(eorg - self.origin);
70 olddir = normalize(self.velocity); // get my current direction
71 dist = vlen(eorg - self.origin);
73 // Do evasive maneuvers for world objects? ( this should be a cpu hog. :P )
74 if (autocvar_g_balance_seeker_missile_smart && (dist > autocvar_g_balance_seeker_missile_smart_mindist))
76 // Is it a better idea (shorter distance) to trace to the target itself?
77 if ( vlen(self.origin + olddir * self.wait) < dist)
78 traceline(self.origin, self.origin + olddir * self.wait, FALSE, self);
80 traceline(self.origin, eorg, FALSE, self);
82 // Setup adaptive tracelength
83 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);
85 // Calc how important it is that we turn and add this to the desierd (enemy) dir.
86 desireddir = normalize(((trace_plane_normal * (1 - trace_fraction)) + (desireddir * trace_fraction)) * 0.5);
89 newdir = normalize(olddir + desireddir * turnrate); // take the average of the 2 directions; not the best method but simple & easy
90 self.velocity = newdir * spd; // make me fly in the new direction at my flight speed
96 if (autocvar_g_balance_seeker_missile_proxy)
98 if ( dist <= autocvar_g_balance_seeker_missile_proxy_maxrange)
100 if (self.autoswitch == 0)
102 self.autoswitch = time + autocvar_g_balance_seeker_missile_proxy_delay;
106 if (self.autoswitch <= time)
108 Seeker_Missile_Explode();
115 if (self.autoswitch != 0)
121 if (self.enemy.deadflag != DEAD_NO)
124 self.cnt = time + 1 + (random() * 4);
125 self.nextthink = self.cnt;
129 //self.angles = vectoangles(self.velocity); // turn model in the new flight direction
130 self.nextthink = time;// + 0.05; // csqc projectiles
131 UpdateCSQCProjectile(self);
136 void Seeker_Missile_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
138 if (self.health <= 0)
141 if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, -1)) // no exceptions
142 return; // g_projectiles_damage says to halt
144 if (self.realowner == attacker)
145 self.health = self.health - (damage * 0.25);
147 self.health = self.health - damage;
149 if (self.health <= 0)
150 W_PrepareExplosionByDamage(attacker, Seeker_Missile_Explode);
154 void Seeker_Missile_Animate()
156 self.frame = self.frame +1;
157 self.nextthink = time + 0.05;
159 if (self.enemy != world)
160 if (self.enemy.takedamage != DAMAGE_AIM || self.enemy.deadflag != DEAD_NO)
165 self.think = Seeker_Missile_Think;
166 self.nextthink = time;// + cvar("g_balance_seeker_missile_activate_delay"); // cant dealy with csqc projectiles
168 if (autocvar_g_balance_seeker_missile_proxy)
169 self.movetype = MOVETYPE_BOUNCEMISSILE;
171 self.movetype = MOVETYPE_FLYMISSILE;
174 UpdateCSQCProjectile(self);
178 void Seeker_Fire_Missile(vector f_diff, entity m_target)
182 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_seeker_missile_ammo, autocvar_g_balance_seeker_reload_ammo);
184 makevectors(self.v_angle);
185 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/seeker_fire.wav", CH_WEAPON_A, 0);
187 pointparticles(particleeffectnum("seeker_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
189 //self.detornator = FALSE;
192 missile.owner = missile.realowner = 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 = m_target;
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.damagedbycontents = TRUE;
209 //missile.think = Seeker_Missile_Animate; // csqc projectiles.
211 if (missile.enemy != world)
212 missile.projectiledeathtype = WEP_SEEKER | HITTYPE_SECONDARY;
214 missile.projectiledeathtype = WEP_SEEKER;
217 setorigin (missile, w_shotorg);
218 setsize (missile, '-4 -4 -4', '4 4 4');
219 missile.movetype = MOVETYPE_FLYMISSILE;
220 missile.flags = FL_PROJECTILE;
221 missile.missile_flags = MIF_SPLASH | MIF_GUIDED_TAG;
223 W_SETUPPROJECTILEVELOCITY_UP(missile, g_balance_seeker_missile);
225 missile.angles = vectoangles (missile.velocity);
227 CSQCProjectile(missile, FALSE, PROJECTILE_SEEKER, TRUE);
229 other = missile; MUTATOR_CALLHOOK(EditProjectile);
232 // ============================
233 // Begin: FLAC, close range attack meant for defeating rockets which are coming at you.
234 // ============================
235 void Seeker_Flac_Explode ()
237 self.event_damage = func_null;
239 RadiusDamage (self, self.realowner, autocvar_g_balance_seeker_flac_damage, autocvar_g_balance_seeker_flac_edgedamage, autocvar_g_balance_seeker_flac_radius, world, world, autocvar_g_balance_seeker_flac_force, self.projectiledeathtype, other);
244 void Seeker_Flac_Touch()
248 Seeker_Flac_Explode();
251 void Seeker_Fire_Flac()
257 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_seeker_flac_ammo, autocvar_g_balance_seeker_reload_ammo);
259 c = mod(self.bulletcounter, 4);
263 f_diff = '-1.25 -3.75 0';
266 f_diff = '+1.25 -3.75 0';
269 f_diff = '-1.25 +3.75 0';
273 f_diff = '+1.25 +3.75 0';
276 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);
279 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
282 missile.owner = missile.realowner = self;
283 missile.classname = "missile";
284 missile.bot_dodge = TRUE;
285 missile.bot_dodgerating = autocvar_g_balance_seeker_flac_damage;
286 missile.touch = Seeker_Flac_Explode;
287 missile.use = Seeker_Flac_Explode;
288 missile.think = adaptor_think2use_hittype_splash;
289 missile.nextthink = time + autocvar_g_balance_seeker_flac_lifetime + autocvar_g_balance_seeker_flac_lifetime_rand;
290 missile.solid = SOLID_BBOX;
291 missile.movetype = MOVETYPE_FLY;
292 missile.projectiledeathtype = WEP_SEEKER;
293 missile.projectiledeathtype = WEP_SEEKER | HITTYPE_SECONDARY;
294 missile.flags = FL_PROJECTILE;
295 missile.missile_flags = MIF_SPLASH;
298 //missile.angles = vectoangles (missile.velocity);
299 //missile.scale = 0.4; // BUG: the model is too big
301 setorigin (missile, w_shotorg);
302 setsize (missile, '-2 -2 -2', '2 2 2');
304 W_SETUPPROJECTILEVELOCITY_UP(missile, g_balance_seeker_flac);
305 CSQCProjectile(missile, TRUE, PROJECTILE_FLAC, TRUE);
307 other = missile; MUTATOR_CALLHOOK(EditProjectile);
310 // ============================
311 // Begin: Tag and rocket controllers
312 // ============================
313 entity Seeker_Tagged_Info(entity isowner, entity istarget)
316 for(tag = world; (tag = find(tag, classname, "tag_tracker")); )
317 if ((tag.realowner == isowner) && (tag.tag_target == istarget))
325 entity tracker, closest_target;
327 closest_target = world;
328 for(tracker = world; (tracker = find(tracker, classname, "tag_tracker")); ) if (tracker.realowner == self)
332 if (vlen(self.origin - tracker.tag_target.origin) < vlen(self.origin - closest_target.origin))
333 closest_target = tracker.tag_target;
336 closest_target = tracker.tag_target;
339 traceline(self.origin + self.view_ofs, closest_target.origin, MOVE_NOMONSTERS, self);
340 if ((!closest_target) || ((trace_fraction < 1) && (trace_ent != closest_target)))
341 closest_target = world;
343 Seeker_Fire_Missile('0 0 0', closest_target);
346 void Seeker_Vollycontroller_Think() // TODO: Merge this with Seeker_Attack
349 entity oldself,oldenemy;
350 self.cnt = self.cnt - 1;
352 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))
358 self.nextthink = time + autocvar_g_balance_seeker_missile_delay * W_WeaponRateFactor();
361 self = self.realowner;
363 oldenemy = self.enemy;
364 self.enemy = oldself.enemy;
366 c = mod(self.cnt, 4);
370 Seeker_Fire_Missile('-1.25 -3.75 0', self.enemy);
373 Seeker_Fire_Missile('+1.25 -3.75 0', self.enemy);
376 Seeker_Fire_Missile('-1.25 +3.75 0', self.enemy);
380 Seeker_Fire_Missile('+1.25 +3.75 0', self.enemy);
384 self.enemy = oldenemy;
388 void Seeker_Tracker_Think()
390 // commit suicide if: You die OR target dies OR you switch away from the seeker OR commit suicide if lifetime is up
391 if ((self.realowner.deadflag != DEAD_NO) || (self.tag_target.deadflag != DEAD_NO) || (self.realowner.switchweapon != WEP_SEEKER)
392 || (time > self.tag_time + autocvar_g_balance_seeker_tag_tracker_lifetime))
396 WaypointSprite_Kill(self.tag_target.wps_tag_tracker);
402 // Update the think method information
403 self.nextthink = time;
406 // ============================
407 // Begin: Tag projectile
408 // ============================
409 void Seeker_Tag_Explode ()
411 //if(other==self.realowner)
413 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_BOUNCE, other.species, self);
418 void Seeker_Tag_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
420 if (self.health <= 0)
422 self.health = self.health - damage;
423 if (self.health <= 0)
424 Seeker_Tag_Explode();
427 void Seeker_Tag_Touch()
435 dir = normalize (self.realowner.origin - self.origin);
436 org2 = findbetterlocation (self.origin, 8);
438 te_knightspike(org2);
440 self.event_damage = func_null;
441 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_BOUNCE | HITTYPE_SECONDARY, other.species, self);
443 if (other.takedamage == DAMAGE_AIM && other.deadflag == DEAD_NO)
445 // check to see if this person is already tagged by me
446 entity tag = Seeker_Tagged_Info(self.realowner, other);
450 if (other.wps_tag_tracker && (autocvar_g_balance_seeker_type == 1)) // don't attach another waypointsprite without killing the old one first
451 WaypointSprite_Kill(other.wps_tag_tracker);
457 //sprint(self.realowner, strcat("You just tagged ^2", other.netname, "^7 with a tracking device!\n"));
459 e.cnt = autocvar_g_balance_seeker_missile_count;
460 e.classname = "tag_tracker";
461 e.owner = self.owner;
462 e.realowner = self.realowner;
464 if (autocvar_g_balance_seeker_type == 1)
466 e.tag_target = other;
468 e.think = Seeker_Tracker_Think;
473 e.think = Seeker_Vollycontroller_Think;
479 if (autocvar_g_balance_seeker_type == 1)
481 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');
482 WaypointSprite_UpdateRule(other.wps_tag_tracker, 0, SPRITERULE_DEFAULT);
490 void Seeker_Fire_Tag()
493 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_seeker_tag_ammo, autocvar_g_balance_seeker_reload_ammo);
495 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);
498 missile.owner = missile.realowner = self;
499 missile.classname = "seeker_tag";
500 missile.bot_dodge = TRUE;
501 missile.bot_dodgerating = 50;
502 missile.touch = Seeker_Tag_Touch;
503 missile.think = SUB_Remove;
504 missile.nextthink = time + autocvar_g_balance_seeker_tag_lifetime;
505 missile.movetype = MOVETYPE_FLY;
506 missile.solid = SOLID_BBOX;
508 missile.takedamage = DAMAGE_YES;
509 missile.event_damage = Seeker_Tag_Damage;
510 missile.health = autocvar_g_balance_seeker_tag_health;
511 missile.damageforcescale = autocvar_g_balance_seeker_tag_damageforcescale;
513 setorigin (missile, w_shotorg);
514 setsize (missile, '-2 -2 -2', '2 2 2');
516 missile.flags = FL_PROJECTILE;
517 //missile.missile_flags = MIF_..?;
519 missile.movetype = MOVETYPE_FLY;
520 W_SETUPPROJECTILEVELOCITY(missile, g_balance_seeker_tag);
521 missile.angles = vectoangles (missile.velocity);
523 CSQCProjectile(missile, TRUE, PROJECTILE_TAG, FALSE); // has sound
525 other = missile; MUTATOR_CALLHOOK(EditProjectile);
528 // ============================
529 // Begin: Genereal weapon functions
530 // ============================
531 void spawnfunc_weapon_seeker (void)
533 weapon_defaultspawnfunc(WEP_SEEKER);
536 float w_seeker(float req)
542 if (autocvar_g_balance_seeker_type == 1)
543 if (Seeker_Tagged_Info(self, self.enemy) != world)
544 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_seeker_missile_speed_max, 0, autocvar_g_balance_seeker_missile_lifetime, FALSE);
546 self.BUTTON_ATCK2 = bot_aim(autocvar_g_balance_seeker_tag_speed, 0, autocvar_g_balance_seeker_tag_lifetime, FALSE);
548 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_seeker_tag_speed, 0, autocvar_g_balance_seeker_tag_lifetime, FALSE);
550 else if (req == WR_THINK)
552 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
553 weapon_action(self.weapon, WR_RELOAD);
555 else if (self.BUTTON_ATCK)
557 if (autocvar_g_balance_seeker_type == 1)
559 if (weapon_prepareattack(0, autocvar_g_balance_seeker_missile_refire))
562 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_seeker_missile_animtime, w_ready);
567 if (weapon_prepareattack(0, autocvar_g_balance_seeker_tag_refire))
570 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_seeker_tag_animtime, w_ready);
575 else if (self.BUTTON_ATCK2)
577 if (autocvar_g_balance_seeker_type == 1)
579 if (weapon_prepareattack(0, autocvar_g_balance_seeker_tag_refire))
582 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_seeker_tag_animtime, w_ready);
587 if (weapon_prepareattack(0, autocvar_g_balance_seeker_flac_refire))
590 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_seeker_flac_animtime, w_ready);
595 else if (req == WR_PRECACHE)
597 precache_model ("models/weapons/g_seeker.md3");
598 precache_model ("models/weapons/v_seeker.md3");
599 precache_model ("models/weapons/h_seeker.iqm");
600 precache_sound ("weapons/tag_fire.wav");
601 precache_sound ("weapons/flac_fire.wav");
602 precache_sound ("weapons/seeker_fire.wav");
603 //precache_sound ("weapons/reload.wav"); // until weapons have individual reload sounds, precache the reload sound somewhere else
605 else if (req == WR_SETUP)
607 weapon_setup(WEP_SEEKER);
608 self.current_ammo = ammo_rockets;
610 else if (req == WR_CHECKAMMO1)
612 if (autocvar_g_balance_seeker_type == 1)
614 ammo_amount = self.ammo_rockets >= autocvar_g_balance_seeker_missile_ammo;
615 ammo_amount += self.(weapon_load[WEP_SEEKER]) >= autocvar_g_balance_seeker_missile_ammo;
619 ammo_amount = self.ammo_rockets >= autocvar_g_balance_seeker_tag_ammo;
620 ammo_amount += self.(weapon_load[WEP_SEEKER]) >= autocvar_g_balance_seeker_tag_ammo;
625 else if (req == WR_CHECKAMMO2)
627 if (autocvar_g_balance_seeker_type == 1)
629 ammo_amount = self.ammo_rockets >= autocvar_g_balance_seeker_tag_ammo;
630 ammo_amount += self.(weapon_load[WEP_SEEKER]) >= autocvar_g_balance_seeker_tag_ammo;
634 ammo_amount = self.ammo_rockets >= autocvar_g_balance_seeker_flac_ammo;
635 ammo_amount += self.(weapon_load[WEP_SEEKER]) >= autocvar_g_balance_seeker_flac_ammo;
640 else if (req == WR_RELOAD)
642 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");
644 else if (req == WR_SUICIDEMESSAGE)
646 return WEAPON_SEEKER_SUICIDE;
648 else if (req == WR_KILLMESSAGE)
650 if(w_deathtype & HITTYPE_SECONDARY)
651 return WEAPON_SEEKER_MURDER_TAG;
653 return WEAPON_SEEKER_MURDER_SPRAY;
659 float w_seeker(float req)
661 if(req == WR_IMPACTEFFECT)
664 org2 = w_org + w_backoff * 6;
665 if(w_deathtype & HITTYPE_BOUNCE)
667 if(w_deathtype & HITTYPE_SECONDARY)
670 sound(self, CH_SHOTS, "weapons/tag_impact.wav", 1, ATTN_NORM);
674 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
678 sound(self, CH_SHOTS, "weapons/tagexp1.wav", 1, ATTN_NORM);
679 else if (w_random<0.7)
680 sound(self, CH_SHOTS, "weapons/tagexp2.wav", 1, ATTN_NORM);
682 sound(self, CH_SHOTS, "weapons/tagexp3.wav", 1, ATTN_NORM);
688 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
692 sound(self, CH_SHOTS, "weapons/seekerexp1.wav", 1, ATTN_NORM);
693 else if (w_random<0.7)
694 sound(self, CH_SHOTS, "weapons/seekerexp2.wav", 1, ATTN_NORM);
696 sound(self, CH_SHOTS, "weapons/seekerexp3.wav", 1, ATTN_NORM);
700 else if(req == WR_PRECACHE)
702 precache_sound("weapons/seekerexp1.wav");
703 precache_sound("weapons/seekerexp2.wav");
704 precache_sound("weapons/seekerexp3.wav");
705 precache_sound("weapons/tagexp1.wav");
706 precache_sound("weapons/tagexp2.wav");
707 precache_sound("weapons/tagexp3.wav");
708 precache_sound("weapons/tag_impact.wav");