2 REGISTER_WEAPON(SEEKER, w_seeker, IT_ROCKETS, 9, WEP_FLAG_NORMAL | WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "seeker", "seeker", "T.A.G. Seeker");
4 //.float speed; = switchweapon
5 //.float proxytime; = autoswitch
8 void Seeker_Missile_Explode ()
10 self.event_damage = SUB_Null;
11 RadiusDamage (self, self.owner, cvar("g_balance_seeker_missile_damage"), cvar("g_balance_seeker_missile_edgedamage"), cvar("g_balance_seeker_missile_radius"), world, cvar("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;
31 Seeker_Missile_Explode();
33 if (!self.switchweapon)
34 self.switchweapon = cvar("g_balance_seeker_missile_speed");
36 if ((self.switchweapon < cvar("g_balance_seeker_missile_speed_max")) && cvar("g_balance_seeker_missile_speed_accel"))
37 self.switchweapon = self.switchweapon * cvar("g_balance_seeker_missile_accel");
39 if (self.switchweapon > cvar("g_balance_seeker_missile_speed_max"))
40 self.switchweapon = self.switchweapon * cvar("g_balance_seeker_missile_decel");
42 if (self.enemy != world)
43 if (self.enemy.takedamage != DAMAGE_AIM || self.enemy.deadflag != DEAD_NO)
46 if (self.enemy != world)
49 eorg = 0.5 * (e.absmin + e.absmax);
50 turnrate = cvar("g_balance_seeker_missile_turnrate"); // how fast to turn
51 desireddir = normalize(eorg - self.origin);
52 olddir = normalize(self.velocity); // get my current direction
53 dist = vlen(eorg - self.origin);
55 // Do evasive maneuvers for world objects? ( this should be a cpu hog. :P )
56 if (cvar("g_balance_seeker_missile_smart") && (dist > cvar("g_balance_seeker_missile_smart_mindist")))
58 // Is it a better idea (shorter distance) to trace to the target itself?
59 if ( vlen(self.origin + olddir * self.wait) < dist)
60 traceline(self.origin, self.origin + olddir * self.wait, FALSE, self);
62 traceline(self.origin, eorg, FALSE, self);
64 // Setup adaptive tracelength
65 self.wait = vlen(self.origin - trace_endpos);
66 if (self.wait < cvar("g_balance_seeker_missile_smart_trace_min")) self.wait = cvar("g_balance_seeker_missile_smart_trace_min");
67 if (self.wait > cvar("g_balance_seeker_missile_smart_trace_max")) self.wait = cvar("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) * 0.5);// take the average of the 2 directions; not the best method but simple & easy
74 newdir = normalize(olddir + desireddir * turnrate);// take the average of the 2 directions; not the best method but simple & easy
76 self.velocity = newdir * self.switchweapon; // make me fly in the new direction at my flight speed
80 if (cvar("g_balance_seeker_missile_proxy"))
82 if ( dist <= cvar("g_balance_seeker_missile_proxy_maxrange"))
84 if (self.autoswitch == 0)
86 self.autoswitch = time + cvar("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;
116 UpdateCSQCProjectile(self);
121 void Seeker_Missile_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
126 if (self.health <= 0)
129 if (self.owner == attacker)
132 self.health = self.health - d;
134 if (self.health <= 0)
135 W_PrepareExplosionByDamage(attacker, Seeker_Missile_Explode);
138 void Seeker_Missile_Animate()
140 self.frame = self.frame +1;
141 self.nextthink = time + 0.05;
143 if (self.enemy != world)
144 if (self.enemy.takedamage != DAMAGE_AIM || self.enemy.deadflag != DEAD_NO)
149 self.think = Seeker_Missile_Think;
150 self.nextthink = time;// + cvar("g_balance_seeker_missile_activate_delay"); // cant dealy with csqc projectiles
152 if (cvar("g_balance_seeker_missile_proxy"))
153 self.movetype = MOVETYPE_BOUNCEMISSILE;
155 self.movetype = MOVETYPE_FLYMISSILE;
158 UpdateCSQCProjectile(self);
161 void Seeker_Fire_Missile(vector f_diff)
163 local entity missile;
165 if not(self.owner.items & IT_UNLIMITED_WEAPON_AMMO)
166 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_seeker_missile_ammo");
168 makevectors(self.v_angle);
169 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/seeker_fire.wav", cvar("g_balance_seeker_missile_damage"));
171 pointparticles(particleeffectnum("seeker_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
173 //self.detornator = FALSE;
176 missile.owner = self;
177 missile.classname = "seeker_missile";
178 missile.bot_dodge = TRUE;
179 missile.bot_dodgerating = cvar("g_balance_seeker_missile_damage");
181 missile.think = Seeker_Missile_Animate;
183 //if (!cvar("g_balance_seeker_missile_proxy"))
184 missile.touch = Seeker_Missile_Touch;
186 missile.event_damage = Seeker_Missile_Damage;
187 missile.nextthink = time;// + 0.2;// + cvar("g_balance_seeker_missile_activate_delay");
188 missile.cnt = time + cvar("g_balance_seeker_missile_lifetime");
189 missile.enemy = self.enemy;
190 missile.solid = SOLID_BBOX;
192 missile.takedamage = DAMAGE_YES;
193 missile.health = cvar("g_balance_seeker_missile_health");
194 missile.damageforcescale = cvar("g_balance_seeker_missile_damageforcescale");
195 missile.projectiledeathtype = WEP_SEEKER;
197 setorigin (missile, w_shotorg);
198 setsize (missile, '-4 -4 -4', '4 4 4');
201 missile.movetype = MOVETYPE_FLYMISSILE;// MOVETYPE_TOSS;
203 missile.flags = FL_PROJECTILE;
205 W_SETUPPROJECTILEVELOCITY_UP(missile, g_balance_seeker_missile);
207 missile.switchweapon = vlen(missile.velocity);
208 missile.angles = vectoangles (missile.velocity);
210 CSQCProjectile(missile, FALSE, PROJECTILE_SEEKER, TRUE);
213 void Seeker_Vollycontroler_Think()
216 entity oldself,oldenemy;
217 self.cnt = self.cnt - 1;
219 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
220 if ((self.owner.ammo_rockets < cvar("g_balance_seeker_missile_ammo")) || (self.cnt <= -1) || (self.owner.deadflag != DEAD_NO))
226 self.nextthink = time + cvar("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();
274 void Seeker_Tag_Think()
280 void Seeker_Tag_Touch()
285 dir = normalize (self.owner.origin - self.origin);
286 org2 = findbetterlocation (self.origin, 8);
288 te_knightspike(org2);
290 self.event_damage = SUB_Null;
291 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_HEADSHOT, self);
293 if (other.takedamage == DAMAGE_AIM && other.deadflag == DEAD_NO)
297 e.cnt = cvar("g_balance_seeker_missile_count");
298 e.owner = self.owner;
300 e.think = Seeker_Vollycontroler_Think;
303 //sprint(self.owner, "^1Target lock ^3[^7 ",other.netname, " ^3]^1 acquired - autofire activated.\n");
304 //sprint(other,"^1You are targeted!\n");
306 // stuffcmd(other,"play2 weapons/zany-alarm4.ogg\n");
307 // stuffcmd(self.owner, "play2 weapons/zany-lock4.ogg\n");
316 void Seeker_Fire_Tag()
318 local entity missile;
319 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
320 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_seeker_tag_ammo");
322 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/tag_fire.wav", 0);
325 missile.owner = self;
326 missile.classname = "seeker_tag";
327 missile.bot_dodge = TRUE;
328 missile.bot_dodgerating = 50;
329 missile.touch = Seeker_Tag_Touch;
330 missile.think = Seeker_Tag_Think;
331 missile.nextthink = time + cvar("g_balance_seeker_tag_lifetime");
332 missile.movetype = MOVETYPE_FLY;
333 missile.solid = SOLID_BBOX;
334 missile.owner = self;
336 missile.takedamage = DAMAGE_YES;
337 missile.event_damage = Seeker_Tag_Explode;
338 missile.health = cvar("g_balance_seeker_tag_health");
339 missile.damageforcescale = cvar("g_balance_seeker_tag_damageforcescale");
341 setorigin (missile, w_shotorg);
342 setsize (missile, '-2 -2 -2', '2 2 2');
344 missile.flags = FL_PROJECTILE;
346 missile.movetype = MOVETYPE_FLY;
347 W_SETUPPROJECTILEVELOCITY(missile, g_balance_seeker_tag);
348 missile.angles = vectoangles (missile.velocity);
350 CSQCProjectile(missile, TRUE, PROJECTILE_TAG, FALSE); // has sound
354 void Seeker_Flac_Explode ()
356 self.event_damage = SUB_Null;
358 RadiusDamage (self, self.owner, cvar("g_balance_seeker_flac_damage"), cvar("g_balance_seeker_flac_edgedamage"), cvar("g_balance_seeker_flac_radius"), world, cvar("g_balance_seeker_flac_force"), self.projectiledeathtype, other);
363 void Seeker_Flac_Touch()
367 Seeker_Flac_Explode();
370 void Seeker_Fire_Flac()
372 local entity missile;
376 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
377 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_seeker_flac_ammo");
379 c = mod(self.bulletcounter, 4);
383 f_diff = '-1.25 -3.75 0';
386 f_diff = '+1.25 -3.75 0';
389 f_diff = '-1.25 +3.75 0';
393 f_diff = '+1.25 +3.75 0';
396 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/flac_fire.wav", cvar("g_balance_seeker_flac_damage"));
399 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
402 missile.owner = missile.realowner = self;
403 missile.classname = "missile";
404 missile.bot_dodge = TRUE;
405 missile.bot_dodgerating = cvar("g_balance_seeker_flac_damage");
406 missile.touch = Seeker_Flac_Explode;
407 missile.use = Seeker_Flac_Explode;
408 missile.think = Seeker_Flac_Explode;
409 missile.nextthink = time + cvar("g_balance_seeker_flac_lifetime") + cvar("g_balance_seeker_flac_lifetime_rand");
410 missile.solid = SOLID_BBOX;
411 missile.scale = 0.4; // BUG: the model is too big
412 missile.projectiledeathtype = WEP_SEEKER;
413 setorigin (missile, w_shotorg);
414 setsize (missile, '-2 -2 -2', '2 2 2');
415 missile.projectiledeathtype = WEP_SEEKER | HITTYPE_SECONDARY;
417 missile.movetype = MOVETYPE_FLY;
418 W_SETUPPROJECTILEVELOCITY_UP(missile, g_balance_seeker_flac);
420 missile.angles = vectoangles (missile.velocity);
421 missile.flags = FL_PROJECTILE;
423 CSQCProjectile(missile, TRUE, PROJECTILE_FLAC, TRUE);
426 void spawnfunc_weapon_seeker (void)
428 weapon_defaultspawnfunc(WEP_SEEKER);
431 float w_seeker(float req)
434 self.BUTTON_ATCK = bot_aim(cvar("g_balance_seeker_tag_speed"), 0, 20, FALSE);
436 else if (req == WR_THINK)
438 if (self.BUTTON_ATCK)
439 if (weapon_prepareattack(0, cvar("g_balance_seeker_tag_refire")))
442 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_seeker_tag_animtime"), w_ready);
445 if (self.BUTTON_ATCK2)
446 if (weapon_prepareattack(1, cvar("g_balance_seeker_flac_refire")))
449 weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_seeker_flac_animtime"), w_ready);
453 else if (req == WR_PRECACHE)
455 precache_model ("models/weapons/g_seeker.md3");
456 precache_model ("models/weapons/v_seeker.md3");
457 precache_model ("models/weapons/h_seeker.dpm");
458 precache_sound ("weapons/tag_fire.wav");
459 precache_sound ("weapons/flac_fire.wav");
460 precache_sound ("weapons/seeker_fire.wav");
462 else if (req == WR_SETUP)
463 weapon_setup(WEP_SEEKER);
464 else if (req == WR_CHECKAMMO1)
465 return self.ammo_rockets >= cvar("g_balance_seeker_tag_ammo") + cvar("g_balance_seeker_missile_ammo");
466 else if (req == WR_CHECKAMMO2)
467 return self.ammo_rockets >= cvar("g_balance_seeker_flac_ammo");
468 else if (req == WR_SUICIDEMESSAGE)
469 w_deathtypestring = "played with tiny rockets";
470 else if (req == WR_KILLMESSAGE)
472 if(w_deathtype & HITTYPE_SECONDARY)
473 w_deathtypestring = "ran into #'s flac";
475 w_deathtypestring = "was tagged by";