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((!(self.owner.items & IT_UNLIMITED_AMMO) && self.owner.ammo_rockets < cvar("g_balance_seeker_missile_ammo")) || (self.cnt <= -1) || (self.owner.deadflag != DEAD_NO))
225 self.nextthink = time + cvar("g_balance_seeker_missile_delay");
230 oldenemy = self.enemy;
231 self.enemy = oldself.enemy;
233 c = mod(oldself.cnt, 4);
237 Seeker_Fire_Missile('-1.25 -3.75 0');
240 Seeker_Fire_Missile('+1.25 -3.75 0');
243 Seeker_Fire_Missile('-1.25 +3.75 0');
247 Seeker_Fire_Missile('+1.25 +3.75 0');
251 self.enemy = oldenemy;
255 void Seeker_Tag_Explode ()
257 //if(other==self.owner)
259 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_BOUNCE, self);
264 void Seeker_Tag_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
266 if (self.health <= 0)
268 self.health = self.health - damage;
269 if (self.health <= 0)
270 Seeker_Tag_Explode();
273 void Seeker_Tag_Think()
279 void Seeker_Tag_Touch()
284 dir = normalize (self.owner.origin - self.origin);
285 org2 = findbetterlocation (self.origin, 8);
287 te_knightspike(org2);
289 self.event_damage = SUB_Null;
290 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_HEADSHOT, self);
292 if (other.takedamage == DAMAGE_AIM && other.deadflag == DEAD_NO)
296 e.cnt = cvar("g_balance_seeker_missile_count");
297 e.owner = self.owner;
299 e.think = Seeker_Vollycontroler_Think;
302 //sprint(self.owner, "^1Target lock ^3[^7 ",other.netname, " ^3]^1 acquired - autofire activated.\n");
303 //sprint(other,"^1You are targeted!\n");
305 // stuffcmd(other,"play2 weapons/zany-alarm4.ogg\n");
306 // stuffcmd(self.owner, "play2 weapons/zany-lock4.ogg\n");
315 void Seeker_Fire_Tag()
317 local entity missile;
318 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
319 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_seeker_tag_ammo");
321 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/tag_fire.wav", 0);
324 missile.owner = self;
325 missile.classname = "seeker_tag";
326 missile.bot_dodge = TRUE;
327 missile.bot_dodgerating = 50;
328 missile.touch = Seeker_Tag_Touch;
329 missile.think = Seeker_Tag_Think;
330 missile.nextthink = time + cvar("g_balance_seeker_tag_lifetime");
331 missile.movetype = MOVETYPE_FLY;
332 missile.solid = SOLID_BBOX;
333 missile.owner = self;
335 missile.takedamage = DAMAGE_YES;
336 missile.event_damage = Seeker_Tag_Explode;
337 missile.health = cvar("g_balance_seeker_tag_health");
338 missile.damageforcescale = cvar("g_balance_seeker_tag_damageforcescale");
340 setorigin (missile, w_shotorg);
341 setsize (missile, '-2 -2 -2', '2 2 2');
343 missile.flags = FL_PROJECTILE;
345 missile.movetype = MOVETYPE_FLY;
346 W_SETUPPROJECTILEVELOCITY(missile, g_balance_seeker_tag);
347 missile.angles = vectoangles (missile.velocity);
349 CSQCProjectile(missile, TRUE, PROJECTILE_TAG, FALSE); // has sound
353 void Seeker_Flac_Explode ()
355 self.event_damage = SUB_Null;
357 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);
362 void Seeker_Flac_Touch()
366 Seeker_Flac_Explode();
369 void Seeker_Fire_Flac()
371 local entity missile;
375 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
376 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_seeker_flac_ammo");
378 c = mod(self.bulletcounter, 4);
382 f_diff = '-1.25 -3.75 0';
385 f_diff = '+1.25 -3.75 0';
388 f_diff = '-1.25 +3.75 0';
392 f_diff = '+1.25 +3.75 0';
395 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/flac_fire.wav", cvar("g_balance_seeker_flac_damage"));
398 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
401 missile.owner = missile.realowner = self;
402 missile.classname = "missile";
403 missile.bot_dodge = TRUE;
404 missile.bot_dodgerating = cvar("g_balance_seeker_flac_damage");
405 missile.touch = Seeker_Flac_Explode;
406 missile.use = Seeker_Flac_Explode;
407 missile.think = Seeker_Flac_Explode;
408 missile.nextthink = time + cvar("g_balance_seeker_flac_lifetime") + cvar("g_balance_seeker_flac_lifetime_rand");
409 missile.solid = SOLID_BBOX;
410 missile.scale = 0.4; // BUG: the model is too big
411 missile.projectiledeathtype = WEP_SEEKER;
412 setorigin (missile, w_shotorg);
413 setsize (missile, '-2 -2 -2', '2 2 2');
414 missile.projectiledeathtype = WEP_SEEKER | HITTYPE_SECONDARY;
416 missile.movetype = MOVETYPE_FLY;
417 W_SETUPPROJECTILEVELOCITY_UP(missile, g_balance_seeker_flac);
419 missile.angles = vectoangles (missile.velocity);
420 missile.flags = FL_PROJECTILE;
422 CSQCProjectile(missile, TRUE, PROJECTILE_FLAC, TRUE);
425 void spawnfunc_weapon_seeker (void)
427 weapon_defaultspawnfunc(WEP_SEEKER);
430 float w_seeker(float req)
433 self.BUTTON_ATCK = bot_aim(cvar("g_balance_seeker_tag_speed"), 0, 20, FALSE);
435 else if (req == WR_THINK)
437 if (self.BUTTON_ATCK)
438 if (weapon_prepareattack(0, cvar("g_balance_seeker_tag_refire")))
441 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_seeker_tag_animtime"), w_ready);
444 if (self.BUTTON_ATCK2)
445 if (weapon_prepareattack(1, cvar("g_balance_seeker_flac_refire")))
448 weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_seeker_flac_animtime"), w_ready);
452 else if (req == WR_PRECACHE)
454 precache_model ("models/weapons/g_seeker.md3");
455 precache_model ("models/weapons/v_seeker.md3");
456 precache_model ("models/weapons/h_seeker.dpm");
457 precache_sound ("weapons/tag_fire.wav");
458 precache_sound ("weapons/flac_fire.wav");
459 precache_sound ("weapons/seeker_fire.wav");
461 else if (req == WR_SETUP)
462 weapon_setup(WEP_SEEKER);
463 else if (req == WR_CHECKAMMO1)
464 return self.ammo_rockets >= cvar("g_balance_seeker_tag_ammo") + cvar("g_balance_seeker_missile_ammo");
465 else if (req == WR_CHECKAMMO2)
466 return self.ammo_rockets >= cvar("g_balance_seeker_flac_ammo");
467 else if (req == WR_SUICIDEMESSAGE)
468 w_deathtypestring = "played with tiny rockets";
469 else if (req == WR_KILLMESSAGE)
471 if(w_deathtype & HITTYPE_SECONDARY)
472 w_deathtypestring = "ran into #'s flac";
474 w_deathtypestring = "was tagged by";