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
7 .entity tag_target, wps_tag_tracker;
10 void Seeker_Missile_Explode ()
12 self.event_damage = SUB_Null;
13 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);
18 void Seeker_Missile_Touch()
22 Seeker_Missile_Explode();
25 void Seeker_Missile_Think()
28 vector desireddir, olddir, newdir, eorg;
35 self.projectiledeathtype |= HITTYPE_SPLASH;
36 Seeker_Missile_Explode();
39 spd = vlen(self.velocity);
41 spd - autocvar_g_balance_seeker_missile_decel * frametime,
42 autocvar_g_balance_seeker_missile_speed_max,
43 spd + autocvar_g_balance_seeker_missile_accel * frametime
46 if (self.enemy != world)
47 if (self.enemy.takedamage != DAMAGE_AIM || self.enemy.deadflag != DEAD_NO)
50 if (self.enemy != world)
53 eorg = 0.5 * (e.absmin + e.absmax);
54 turnrate = autocvar_g_balance_seeker_missile_turnrate; // how fast to turn
55 desireddir = normalize(eorg - self.origin);
56 olddir = normalize(self.velocity); // get my current direction
57 dist = vlen(eorg - self.origin);
59 // Do evasive maneuvers for world objects? ( this should be a cpu hog. :P )
60 if (autocvar_g_balance_seeker_missile_smart && (dist > autocvar_g_balance_seeker_missile_smart_mindist))
62 // Is it a better idea (shorter distance) to trace to the target itself?
63 if ( vlen(self.origin + olddir * self.wait) < dist)
64 traceline(self.origin, self.origin + olddir * self.wait, FALSE, self);
66 traceline(self.origin, eorg, FALSE, self);
68 // Setup adaptive tracelength
69 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);
71 // Calc how important it is that we turn and add this to the desierd (enemy) dir.
72 desireddir = normalize(((trace_plane_normal * (1 - trace_fraction)) + (desireddir * trace_fraction)) * 0.5);
75 newdir = normalize(olddir + desireddir * turnrate); // take the average of the 2 directions; not the best method but simple & easy
76 self.velocity = newdir * spd; // make me fly in the new direction at my flight speed
80 if (autocvar_g_balance_seeker_missile_proxy)
82 if ( dist <= autocvar_g_balance_seeker_missile_proxy_maxrange)
84 if (self.autoswitch == 0)
86 self.autoswitch = time + autocvar_g_balance_seeker_missile_proxy_delay;
90 if (self.autoswitch <= time)
92 Seeker_Missile_Explode();
99 if (self.autoswitch != 0)
105 if (self.enemy.deadflag != DEAD_NO)
108 self.cnt = time + 1 + (random() * 4);
109 self.nextthink = self.cnt;
113 //self.angles = vectoangles(self.velocity); // turn model in the new flight direction
114 self.nextthink = time;// + 0.05; // csqc projectiles
115 UpdateCSQCProjectile(self);
120 void Seeker_Missile_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
122 if (self.health <= 0)
125 if (self.owner == attacker)
126 self.health = self.health - (damage * 0.25);
128 self.health = self.health - damage;
130 if (self.health <= 0)
131 W_PrepareExplosionByDamage(attacker, Seeker_Missile_Explode);
135 void Seeker_Missile_Animate()
137 self.frame = self.frame +1;
138 self.nextthink = time + 0.05;
140 if (self.enemy != world)
141 if (self.enemy.takedamage != DAMAGE_AIM || self.enemy.deadflag != DEAD_NO)
146 self.think = Seeker_Missile_Think;
147 self.nextthink = time;// + cvar("g_balance_seeker_missile_activate_delay"); // cant dealy with csqc projectiles
149 if (autocvar_g_balance_seeker_missile_proxy)
150 self.movetype = MOVETYPE_BOUNCEMISSILE;
152 self.movetype = MOVETYPE_FLYMISSILE;
155 UpdateCSQCProjectile(self);
159 void Seeker_Fire_Missile(vector f_diff, entity m_target)
161 local entity missile;
163 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_seeker_missile_ammo, autocvar_g_balance_seeker_reload_ammo);
165 makevectors(self.v_angle);
166 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/seeker_fire.wav", CHAN_WEAPON, 0);
168 pointparticles(particleeffectnum("seeker_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
170 //self.detornator = FALSE;
173 missile.owner = self;
174 missile.classname = "seeker_missile";
175 missile.bot_dodge = TRUE;
176 missile.bot_dodgerating = autocvar_g_balance_seeker_missile_damage;
178 missile.think = Seeker_Missile_Think;
179 missile.touch = Seeker_Missile_Touch;
180 missile.event_damage = Seeker_Missile_Damage;
181 missile.nextthink = time;// + 0.2;// + cvar("g_balance_seeker_missile_activate_delay");
182 missile.cnt = time + autocvar_g_balance_seeker_missile_lifetime;
183 missile.enemy = m_target;
184 missile.solid = SOLID_BBOX;
186 missile.takedamage = DAMAGE_YES;
187 missile.health = autocvar_g_balance_seeker_missile_health;
188 missile.damageforcescale = autocvar_g_balance_seeker_missile_damageforcescale;
189 //missile.think = Seeker_Missile_Animate; // csqc projectiles.
191 if (missile.enemy != world)
192 missile.projectiledeathtype = WEP_SEEKER | HITTYPE_SECONDARY;
194 missile.projectiledeathtype = WEP_SEEKER;
197 setorigin (missile, w_shotorg);
198 setsize (missile, '-4 -4 -4', '4 4 4');
199 missile.movetype = MOVETYPE_FLYMISSILE;
200 missile.flags = FL_PROJECTILE;
201 W_SETUPPROJECTILEVELOCITY_UP(missile, g_balance_seeker_missile);
203 missile.angles = vectoangles (missile.velocity);
205 CSQCProjectile(missile, FALSE, PROJECTILE_SEEKER, TRUE);
207 other = missile; MUTATOR_CALLHOOK(EditProjectile);
210 entity Seeker_Tagged_Info(entity isowner, entity istarget)
213 for(tag = world; (tag = find(tag, classname, "tag_tracker")); )
214 if ((tag.owner == isowner) && (tag.tag_target == istarget))
222 entity tracker, closest_target;
224 for(tracker = world; (tracker = find(tracker, classname, "tag_tracker")); ) if (tracker.owner == self)
228 if (vlen(self.origin - tracker.tag_target.origin) < vlen(self.origin - closest_target.origin))
229 closest_target = tracker.tag_target;
232 closest_target = tracker.tag_target;
235 traceline(self.origin + self.view_ofs, closest_target.origin, MOVE_NOMONSTERS, self);
236 if ((!closest_target) || ((trace_fraction < 1) && (trace_ent != closest_target)))
237 closest_target = world;
239 // we don't need to do this because the model is going to be changed anyway.
240 // CLEAN THIS UP IN THE FUTURE !!!!!!!!!!!
242 switch(mod(self.bulletcounter, 4))
245 Seeker_Fire_Missile('-1.25 -3.75 0', closest_target);
248 Seeker_Fire_Missile('+1.25 -3.75 0', closest_target);
251 Seeker_Fire_Missile('-1.25 +3.75 0', closest_target);
255 Seeker_Fire_Missile('+1.25 +3.75 0', closest_target);
260 Seeker_Fire_Missile('0 0 0', closest_target);
263 void Seeker_Tracker_Think()
265 // commit suicide if: You die OR target dies OR you switch away from the seeker OR commit suicide if lifetime is up
266 if ((self.owner.deadflag != DEAD_NO) || (self.tag_target.deadflag != DEAD_NO) || (self.owner.switchweapon != WEP_SEEKER)
267 || (time > self.tag_time + autocvar_g_balance_seeker_tag_tracker_lifetime))
271 WaypointSprite_Kill(self.tag_target.wps_tag_tracker);
277 // Update the think method information
278 self.nextthink = time;
281 void Seeker_Tag_Explode ()
283 //if(other==self.owner)
285 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_BOUNCE, self);
290 void Seeker_Tag_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
292 if (self.health <= 0)
294 self.health = self.health - damage;
295 if (self.health <= 0)
296 Seeker_Tag_Explode();
299 void Seeker_Tag_Touch()
305 dir = normalize (self.owner.origin - self.origin);
306 org2 = findbetterlocation (self.origin, 8);
308 te_knightspike(org2);
310 self.event_damage = SUB_Null;
311 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_HEADSHOT, self);
313 if (other.takedamage == DAMAGE_AIM && other.deadflag == DEAD_NO)
315 // check to see if this person is already tagged by me
316 entity tag = Seeker_Tagged_Info(self.owner, other);
320 if (other.wps_tag_tracker) // don't attach another waypointsprite without killing the old one first
321 WaypointSprite_Kill(other.wps_tag_tracker);
327 sprint(self.owner, strcat("You just tagged ^2", other.netname, "^7 with a tracking device!\n"));
329 e.classname = "tag_tracker";
330 e.owner = self.owner;
331 e.think = Seeker_Tracker_Think;
333 e.tag_target = other;
337 WaypointSprite_Spawn("tagged-target", autocvar_g_balance_seeker_tag_tracker_lifetime, 0, other, '0 0 64', self.owner, 0, other, wps_tag_tracker, TRUE);
338 WaypointSprite_UpdateRule(other.wps_tag_tracker, 0, SPRITERULE_DEFAULT);
345 void Seeker_Fire_Tag()
347 local entity missile;
348 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_seeker_tag_ammo, autocvar_g_balance_seeker_reload_ammo);
350 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);
353 missile.owner = self;
354 missile.classname = "seeker_tag";
355 missile.bot_dodge = TRUE;
356 missile.bot_dodgerating = 50;
357 missile.touch = Seeker_Tag_Touch;
358 missile.think = SUB_Remove;
359 missile.nextthink = time + autocvar_g_balance_seeker_tag_lifetime;
360 missile.movetype = MOVETYPE_FLY;
361 missile.solid = SOLID_BBOX;
362 missile.owner = self;
364 missile.takedamage = DAMAGE_YES;
365 missile.event_damage = Seeker_Tag_Explode;
366 missile.health = autocvar_g_balance_seeker_tag_health;
367 missile.damageforcescale = autocvar_g_balance_seeker_tag_damageforcescale;
369 setorigin (missile, w_shotorg);
370 setsize (missile, '-2 -2 -2', '2 2 2');
372 missile.flags = FL_PROJECTILE;
374 missile.movetype = MOVETYPE_FLY;
375 W_SETUPPROJECTILEVELOCITY(missile, g_balance_seeker_tag);
376 missile.angles = vectoangles (missile.velocity);
378 CSQCProjectile(missile, TRUE, PROJECTILE_TAG, FALSE); // has sound
380 other = missile; MUTATOR_CALLHOOK(EditProjectile);
383 void spawnfunc_weapon_seeker (void)
385 weapon_defaultspawnfunc(WEP_SEEKER);
388 float w_seeker(float req)
394 if (Seeker_Tagged_Info(self, self.enemy) != world)
395 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_seeker_missile_speed_max, 0, autocvar_g_balance_seeker_missile_lifetime, FALSE);
397 self.BUTTON_ATCK2 = bot_aim(autocvar_g_balance_seeker_tag_speed, 0, autocvar_g_balance_seeker_tag_lifetime, FALSE);
399 else if (req == WR_THINK)
401 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
402 weapon_action(self.weapon, WR_RELOAD);
404 else if (self.BUTTON_ATCK)
406 if (weapon_prepareattack(0, autocvar_g_balance_seeker_missile_refire))
409 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_seeker_missile_animtime, w_ready);
413 else if (self.BUTTON_ATCK2)
415 if (weapon_prepareattack(1, autocvar_g_balance_seeker_tag_refire))
418 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_seeker_tag_animtime, w_ready);
422 else if (req == WR_PRECACHE)
424 precache_model ("models/weapons/g_seeker.md3");
425 precache_model ("models/weapons/v_seeker.md3");
426 precache_model ("models/weapons/h_seeker.iqm");
427 precache_sound ("weapons/tag_fire.wav");
428 //precache_sound ("weapons/flac_fire.wav");
429 precache_sound ("weapons/seeker_fire.wav");
430 //precache_sound ("weapons/reload.wav"); // until weapons have individual reload sounds, precache the reload sound somewhere else
432 else if (req == WR_SETUP)
434 weapon_setup(WEP_SEEKER);
435 self.current_ammo = ammo_rockets;
437 else if (req == WR_CHECKAMMO1)
439 ammo_amount = self.ammo_rockets >= autocvar_g_balance_seeker_missile_ammo;
440 ammo_amount += self.weapon_load[WEP_SEEKER] >= autocvar_g_balance_seeker_missile_ammo;
443 else if (req == WR_CHECKAMMO2)
445 ammo_amount = self.ammo_rockets >= autocvar_g_balance_seeker_tag_ammo;
446 ammo_amount += self.weapon_load[WEP_SEEKER] >= autocvar_g_balance_seeker_tag_ammo;
449 else if (req == WR_RELOAD)
451 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");
457 float w_seeker(float req)
459 if(req == WR_IMPACTEFFECT)
462 org2 = w_org + w_backoff * 6;
463 if(w_deathtype & HITTYPE_BOUNCE)
465 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
469 sound(self, CHAN_PROJECTILE, "weapons/tagexp1.wav", 1, ATTN_NORM);
470 else if (w_random<0.7)
471 sound(self, CHAN_PROJECTILE, "weapons/tagexp2.wav", 1, ATTN_NORM);
473 sound(self, CHAN_PROJECTILE, "weapons/tagexp3.wav", 1, ATTN_NORM);
476 else if(w_deathtype & HITTYPE_HEADSHOT)
479 sound(self, CHAN_PROJECTILE, "weapons/tag_impact.wav", 1, ATTN_NORM);
483 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
487 sound(self, CHAN_PROJECTILE, "weapons/seekerexp1.wav", 1, ATTN_NORM);
488 else if (w_random<0.7)
489 sound(self, CHAN_PROJECTILE, "weapons/seekerexp2.wav", 1, ATTN_NORM);
491 sound(self, CHAN_PROJECTILE, "weapons/seekerexp3.wav", 1, ATTN_NORM);
495 else if(req == WR_PRECACHE)
497 precache_sound("weapons/seekerexp1.wav");
498 precache_sound("weapons/seekerexp2.wav");
499 precache_sound("weapons/seekerexp3.wav");
500 precache_sound("weapons/tagexp1.wav");
501 precache_sound("weapons/tagexp2.wav");
502 precache_sound("weapons/tagexp3.wav");
503 precache_sound("weapons/tag_impact.wav");
505 else if (req == WR_SUICIDEMESSAGE)
506 w_deathtypestring = _("%s played with tiny rockets");
507 else if (req == WR_KILLMESSAGE)
509 if(w_deathtype & HITTYPE_SECONDARY)
510 w_deathtypestring = _("%s was tagged by %s");
512 w_deathtypestring = _("%s was pummeled by %s");