2 REGISTER_WEAPON(SEEKER, w_seeker, IT_ROCKETS, 8, WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "seeker", "seeker", _("T.A.G. Seeker"))
5 //.float proxytime; = autoswitch
7 .entity tag_target, wps_tag_tracker;
10 // ============================
11 // Begin: Missile functions, these are general functions to be manipulated by other code
12 // ============================
13 void Seeker_Missile_Explode ()
15 self.event_damage = SUB_Null;
16 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);
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.realowner == attacker)
129 self.health = self.health - (damage * 0.25);
131 self.health = self.health - damage;
133 print(strcat("seeker missile health ", ftos(self.health), " after ", ftos(damage), " damage... (at time: ", ftos(time), ")\n"));
135 if (self.health <= 0)
136 W_PrepareExplosionByDamage(attacker, Seeker_Missile_Explode);
140 void Seeker_Missile_Animate()
142 self.frame = self.frame +1;
143 self.nextthink = time + 0.05;
145 if (self.enemy != world)
146 if (self.enemy.takedamage != DAMAGE_AIM || self.enemy.deadflag != DEAD_NO)
151 self.think = Seeker_Missile_Think;
152 self.nextthink = time;// + cvar("g_balance_seeker_missile_activate_delay"); // cant dealy with csqc projectiles
154 if (autocvar_g_balance_seeker_missile_proxy)
155 self.movetype = MOVETYPE_BOUNCEMISSILE;
157 self.movetype = MOVETYPE_FLYMISSILE;
160 UpdateCSQCProjectile(self);
164 void Seeker_Fire_Missile(vector f_diff, entity m_target)
166 local entity missile;
168 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_seeker_missile_ammo, autocvar_g_balance_seeker_reload_ammo);
170 makevectors(self.v_angle);
171 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/seeker_fire.wav", CH_WEAPON_A, 0);
173 pointparticles(particleeffectnum("seeker_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
175 //self.detornator = FALSE;
178 missile.owner = missile.realowner = self;
179 missile.classname = "seeker_missile";
180 missile.bot_dodge = TRUE;
181 missile.bot_dodgerating = autocvar_g_balance_seeker_missile_damage;
183 missile.think = Seeker_Missile_Think;
184 missile.touch = Seeker_Missile_Touch;
185 missile.event_damage = Seeker_Missile_Damage;
186 missile.nextthink = time;// + 0.2;// + cvar("g_balance_seeker_missile_activate_delay");
187 missile.cnt = time + autocvar_g_balance_seeker_missile_lifetime;
188 missile.enemy = m_target;
189 missile.solid = SOLID_BBOX;
191 missile.takedamage = DAMAGE_YES;
192 missile.health = autocvar_g_balance_seeker_missile_health;
193 missile.damageforcescale = autocvar_g_balance_seeker_missile_damageforcescale;
194 missile.damagedbycontents = TRUE;
195 //missile.think = Seeker_Missile_Animate; // csqc projectiles.
197 if (missile.enemy != world)
198 missile.projectiledeathtype = WEP_SEEKER | HITTYPE_SECONDARY;
200 missile.projectiledeathtype = WEP_SEEKER;
203 setorigin (missile, w_shotorg);
204 setsize (missile, '-4 -4 -4', '4 4 4');
205 missile.movetype = MOVETYPE_FLYMISSILE;
206 missile.flags = FL_PROJECTILE;
207 W_SETUPPROJECTILEVELOCITY_UP(missile, g_balance_seeker_missile);
209 missile.angles = vectoangles (missile.velocity);
211 CSQCProjectile(missile, FALSE, PROJECTILE_SEEKER, TRUE);
213 other = missile; MUTATOR_CALLHOOK(EditProjectile);
216 // ============================
217 // Begin: FLAC, close range attack meant for defeating rockets which are coming at you.
218 // ============================
219 void Seeker_Flac_Explode ()
221 self.event_damage = SUB_Null;
223 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);
228 void Seeker_Flac_Touch()
232 Seeker_Flac_Explode();
235 void Seeker_Fire_Flac()
237 local entity missile;
241 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_seeker_flac_ammo, autocvar_g_balance_seeker_reload_ammo);
243 c = mod(self.bulletcounter, 4);
247 f_diff = '-1.25 -3.75 0';
250 f_diff = '+1.25 -3.75 0';
253 f_diff = '-1.25 +3.75 0';
257 f_diff = '+1.25 +3.75 0';
260 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);
263 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
266 missile.owner = missile.realowner = self;
267 missile.classname = "missile";
268 missile.bot_dodge = TRUE;
269 missile.bot_dodgerating = autocvar_g_balance_seeker_flac_damage;
270 missile.touch = Seeker_Flac_Explode;
271 missile.use = Seeker_Flac_Explode;
272 missile.think = adaptor_think2use_hittype_splash;
273 missile.nextthink = time + autocvar_g_balance_seeker_flac_lifetime + autocvar_g_balance_seeker_flac_lifetime_rand;
274 missile.solid = SOLID_BBOX;
275 missile.movetype = MOVETYPE_FLY;
276 missile.projectiledeathtype = WEP_SEEKER;
277 missile.projectiledeathtype = WEP_SEEKER | HITTYPE_SECONDARY;
278 missile.flags = FL_PROJECTILE;
281 //missile.angles = vectoangles (missile.velocity);
282 //missile.scale = 0.4; // BUG: the model is too big
284 setorigin (missile, w_shotorg);
285 setsize (missile, '-2 -2 -2', '2 2 2');
287 W_SETUPPROJECTILEVELOCITY_UP(missile, g_balance_seeker_flac);
288 CSQCProjectile(missile, TRUE, PROJECTILE_FLAC, TRUE);
290 other = missile; MUTATOR_CALLHOOK(EditProjectile);
293 // ============================
294 // Begin: Tag and rocket controllers
295 // ============================
296 entity Seeker_Tagged_Info(entity isowner, entity istarget)
299 for(tag = world; (tag = find(tag, classname, "tag_tracker")); )
300 if ((tag.realowner == isowner) && (tag.tag_target == istarget))
308 entity tracker, closest_target;
310 for(tracker = world; (tracker = find(tracker, classname, "tag_tracker")); ) if (tracker.realowner == self)
314 if (vlen(self.origin - tracker.tag_target.origin) < vlen(self.origin - closest_target.origin))
315 closest_target = tracker.tag_target;
318 closest_target = tracker.tag_target;
321 traceline(self.origin + self.view_ofs, closest_target.origin, MOVE_NOMONSTERS, self);
322 if ((!closest_target) || ((trace_fraction < 1) && (trace_ent != closest_target)))
323 closest_target = world;
325 Seeker_Fire_Missile('0 0 0', closest_target);
328 void Seeker_Vollycontroller_Think() // TODO: Merge this with Seeker_Attack
331 entity oldself,oldenemy;
332 self.cnt = self.cnt - 1;
334 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))
340 self.nextthink = time + autocvar_g_balance_seeker_missile_delay * W_WeaponRateFactor();
343 self = self.realowner;
345 oldenemy = self.enemy;
346 self.enemy = oldself.enemy;
348 c = mod(self.cnt, 4);
352 Seeker_Fire_Missile('-1.25 -3.75 0', self.enemy);
355 Seeker_Fire_Missile('+1.25 -3.75 0', self.enemy);
358 Seeker_Fire_Missile('-1.25 +3.75 0', self.enemy);
362 Seeker_Fire_Missile('+1.25 +3.75 0', self.enemy);
366 self.enemy = oldenemy;
370 void Seeker_Tracker_Think()
372 // commit suicide if: You die OR target dies OR you switch away from the seeker OR commit suicide if lifetime is up
373 if ((self.realowner.deadflag != DEAD_NO) || (self.tag_target.deadflag != DEAD_NO) || (self.realowner.switchweapon != WEP_SEEKER)
374 || (time > self.tag_time + autocvar_g_balance_seeker_tag_tracker_lifetime))
378 WaypointSprite_Kill(self.tag_target.wps_tag_tracker);
384 // Update the think method information
385 self.nextthink = time;
388 // ============================
389 // Begin: Tag projectile
390 // ============================
391 void Seeker_Tag_Explode ()
393 //if(other==self.realowner)
395 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_BOUNCE, self);
400 void Seeker_Tag_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
402 if (self.health <= 0)
404 self.health = self.health - damage;
405 if (self.health <= 0)
406 Seeker_Tag_Explode();
409 void Seeker_Tag_Touch()
417 dir = normalize (self.realowner.origin - self.origin);
418 org2 = findbetterlocation (self.origin, 8);
420 te_knightspike(org2);
422 self.event_damage = SUB_Null;
423 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_HEADSHOT, self);
425 if (other.takedamage == DAMAGE_AIM && other.deadflag == DEAD_NO)
427 // check to see if this person is already tagged by me
428 entity tag = Seeker_Tagged_Info(self.realowner, other);
432 if (other.wps_tag_tracker && (autocvar_g_balance_seeker_type == 1)) // don't attach another waypointsprite without killing the old one first
433 WaypointSprite_Kill(other.wps_tag_tracker);
439 //sprint(self.realowner, strcat("You just tagged ^2", other.netname, "^7 with a tracking device!\n"));
441 e.cnt = autocvar_g_balance_seeker_missile_count;
442 e.classname = "tag_tracker";
443 e.owner = self.owner;
444 e.realowner = self.realowner;
446 if (autocvar_g_balance_seeker_type == 1)
448 e.tag_target = other;
450 e.think = Seeker_Tracker_Think;
455 e.think = Seeker_Vollycontroller_Think;
461 if (autocvar_g_balance_seeker_type == 1)
463 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');
464 WaypointSprite_UpdateRule(other.wps_tag_tracker, 0, SPRITERULE_DEFAULT);
472 void Seeker_Fire_Tag()
474 local entity missile;
475 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_seeker_tag_ammo, autocvar_g_balance_seeker_reload_ammo);
477 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);
480 missile.owner = missile.realowner = self;
481 missile.classname = "seeker_tag";
482 missile.bot_dodge = TRUE;
483 missile.bot_dodgerating = 50;
484 missile.touch = Seeker_Tag_Touch;
485 missile.think = SUB_Remove;
486 missile.nextthink = time + autocvar_g_balance_seeker_tag_lifetime;
487 missile.movetype = MOVETYPE_FLY;
488 missile.solid = SOLID_BBOX;
490 missile.takedamage = DAMAGE_YES;
491 missile.event_damage = Seeker_Tag_Explode;
492 missile.health = autocvar_g_balance_seeker_tag_health;
493 missile.damageforcescale = autocvar_g_balance_seeker_tag_damageforcescale;
495 setorigin (missile, w_shotorg);
496 setsize (missile, '-2 -2 -2', '2 2 2');
498 missile.flags = FL_PROJECTILE;
500 missile.movetype = MOVETYPE_FLY;
501 W_SETUPPROJECTILEVELOCITY(missile, g_balance_seeker_tag);
502 missile.angles = vectoangles (missile.velocity);
504 CSQCProjectile(missile, TRUE, PROJECTILE_TAG, FALSE); // has sound
506 other = missile; MUTATOR_CALLHOOK(EditProjectile);
509 // ============================
510 // Begin: Genereal weapon functions
511 // ============================
512 void spawnfunc_weapon_seeker (void)
514 weapon_defaultspawnfunc(WEP_SEEKER);
517 float w_seeker(float req)
523 if (autocvar_g_balance_seeker_type == 1)
524 if (Seeker_Tagged_Info(self, self.enemy) != world)
525 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_seeker_missile_speed_max, 0, autocvar_g_balance_seeker_missile_lifetime, FALSE);
527 self.BUTTON_ATCK2 = bot_aim(autocvar_g_balance_seeker_tag_speed, 0, autocvar_g_balance_seeker_tag_lifetime, FALSE);
529 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_seeker_tag_speed, 0, autocvar_g_balance_seeker_tag_lifetime, FALSE);
531 else if (req == WR_THINK)
533 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
534 weapon_action(self.weapon, WR_RELOAD);
536 else if (self.BUTTON_ATCK)
538 if (autocvar_g_balance_seeker_type == 1)
540 if (weapon_prepareattack(0, autocvar_g_balance_seeker_missile_refire))
543 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_seeker_missile_animtime, w_ready);
548 if (weapon_prepareattack(0, autocvar_g_balance_seeker_tag_refire))
551 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_seeker_tag_animtime, w_ready);
556 else if (self.BUTTON_ATCK2)
558 if (autocvar_g_balance_seeker_type == 1)
560 if (weapon_prepareattack(0, autocvar_g_balance_seeker_tag_refire))
563 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_seeker_tag_animtime, w_ready);
568 if (weapon_prepareattack(0, autocvar_g_balance_seeker_flac_refire))
571 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_seeker_flac_animtime, w_ready);
576 else if (req == WR_PRECACHE)
578 precache_model ("models/weapons/g_seeker.md3");
579 precache_model ("models/weapons/v_seeker.md3");
580 precache_model ("models/weapons/h_seeker.iqm");
581 precache_sound ("weapons/tag_fire.wav");
582 precache_sound ("weapons/flac_fire.wav");
583 precache_sound ("weapons/seeker_fire.wav");
584 //precache_sound ("weapons/reload.wav"); // until weapons have individual reload sounds, precache the reload sound somewhere else
586 else if (req == WR_SETUP)
588 weapon_setup(WEP_SEEKER);
589 self.current_ammo = ammo_rockets;
591 else if (req == WR_CHECKAMMO1)
593 ammo_amount = self.ammo_rockets >= autocvar_g_balance_seeker_missile_ammo;
594 ammo_amount += self.weapon_load[WEP_SEEKER] >= autocvar_g_balance_seeker_missile_ammo;
597 else if (req == WR_CHECKAMMO2)
599 ammo_amount = self.ammo_rockets >= autocvar_g_balance_seeker_tag_ammo;
600 ammo_amount += self.weapon_load[WEP_SEEKER] >= autocvar_g_balance_seeker_tag_ammo;
603 else if (req == WR_RELOAD)
605 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");
611 float w_seeker(float req)
613 if(req == WR_IMPACTEFFECT)
616 org2 = w_org + w_backoff * 6;
617 if(w_deathtype & HITTYPE_BOUNCE)
619 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
623 sound(self, CH_SHOTS, "weapons/tagexp1.wav", 1, ATTN_NORM);
624 else if (w_random<0.7)
625 sound(self, CH_SHOTS, "weapons/tagexp2.wav", 1, ATTN_NORM);
627 sound(self, CH_SHOTS, "weapons/tagexp3.wav", 1, ATTN_NORM);
630 else if(w_deathtype & HITTYPE_HEADSHOT)
633 sound(self, CH_SHOTS, "weapons/tag_impact.wav", 1, ATTN_NORM);
637 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
641 sound(self, CH_SHOTS, "weapons/seekerexp1.wav", 1, ATTN_NORM);
642 else if (w_random<0.7)
643 sound(self, CH_SHOTS, "weapons/seekerexp2.wav", 1, ATTN_NORM);
645 sound(self, CH_SHOTS, "weapons/seekerexp3.wav", 1, ATTN_NORM);
649 else if(req == WR_PRECACHE)
651 precache_sound("weapons/seekerexp1.wav");
652 precache_sound("weapons/seekerexp2.wav");
653 precache_sound("weapons/seekerexp3.wav");
654 precache_sound("weapons/tagexp1.wav");
655 precache_sound("weapons/tagexp2.wav");
656 precache_sound("weapons/tagexp3.wav");
657 precache_sound("weapons/tag_impact.wav");
659 else if (req == WR_SUICIDEMESSAGE)
660 w_deathtypestring = _("%s played with tiny rockets");
661 else if (req == WR_KILLMESSAGE)
663 if(w_deathtype & HITTYPE_SECONDARY)
664 w_deathtypestring = _("%s was tagged by %s");
666 w_deathtypestring = _("%s was pummeled by %s");