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;
32 self.projectiledeathtype |= HITTYPE_SPLASH;
33 Seeker_Missile_Explode();
36 if (!self.switchweapon)
37 self.switchweapon = cvar("g_balance_seeker_missile_speed");
39 if ((self.switchweapon < cvar("g_balance_seeker_missile_speed_max")) && cvar("g_balance_seeker_missile_speed_accel"))
40 self.switchweapon = self.switchweapon * cvar("g_balance_seeker_missile_accel");
42 if (self.switchweapon > cvar("g_balance_seeker_missile_speed_max"))
43 self.switchweapon = self.switchweapon * cvar("g_balance_seeker_missile_decel");
45 if (self.enemy != world)
46 if (self.enemy.takedamage != DAMAGE_AIM || self.enemy.deadflag != DEAD_NO)
49 if (self.enemy != world)
52 eorg = 0.5 * (e.absmin + e.absmax);
53 turnrate = cvar("g_balance_seeker_missile_turnrate"); // how fast to turn
54 desireddir = normalize(eorg - self.origin);
55 olddir = normalize(self.velocity); // get my current direction
56 dist = vlen(eorg - self.origin);
58 // Do evasive maneuvers for world objects? ( this should be a cpu hog. :P )
59 if (cvar("g_balance_seeker_missile_smart") && (dist > cvar("g_balance_seeker_missile_smart_mindist")))
61 // Is it a better idea (shorter distance) to trace to the target itself?
62 if ( vlen(self.origin + olddir * self.wait) < dist)
63 traceline(self.origin, self.origin + olddir * self.wait, FALSE, self);
65 traceline(self.origin, eorg, FALSE, self);
67 // Setup adaptive tracelength
68 self.wait = vlen(self.origin - trace_endpos);
69 if (self.wait < cvar("g_balance_seeker_missile_smart_trace_min")) self.wait = cvar("g_balance_seeker_missile_smart_trace_min");
70 if (self.wait > cvar("g_balance_seeker_missile_smart_trace_max")) self.wait = cvar("g_balance_seeker_missile_smart_trace_max");
72 // Calc how important it is that we turn and add this to the desierd (enemy) dir.
73 desireddir = normalize(((trace_plane_normal * (1 - trace_fraction)) + (desireddir * trace_fraction)) * 0.5);
76 //newdir = normalize((olddir + desireddir * turnrate) * 0.5);// take the average of the 2 directions; not the best method but simple & easy
77 newdir = normalize(olddir + desireddir * turnrate);// take the average of the 2 directions; not the best method but simple & easy
79 self.velocity = newdir * self.switchweapon; // make me fly in the new direction at my flight speed
83 if (cvar("g_balance_seeker_missile_proxy"))
85 if ( dist <= cvar("g_balance_seeker_missile_proxy_maxrange"))
87 if (self.autoswitch == 0)
89 self.autoswitch = time + cvar("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;
119 UpdateCSQCProjectile(self);
124 void Seeker_Missile_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
129 if (self.health <= 0)
132 if (self.owner == attacker)
135 self.health = self.health - d;
137 if (self.health <= 0)
138 W_PrepareExplosionByDamage(attacker, Seeker_Missile_Explode);
141 void Seeker_Missile_Animate()
143 self.frame = self.frame +1;
144 self.nextthink = time + 0.05;
146 if (self.enemy != world)
147 if (self.enemy.takedamage != DAMAGE_AIM || self.enemy.deadflag != DEAD_NO)
152 self.think = Seeker_Missile_Think;
153 self.nextthink = time;// + cvar("g_balance_seeker_missile_activate_delay"); // cant dealy with csqc projectiles
155 if (cvar("g_balance_seeker_missile_proxy"))
156 self.movetype = MOVETYPE_BOUNCEMISSILE;
158 self.movetype = MOVETYPE_FLYMISSILE;
161 UpdateCSQCProjectile(self);
164 void Seeker_Fire_Missile(vector f_diff)
166 local entity missile;
168 if not(self.owner.items & IT_UNLIMITED_WEAPON_AMMO)
169 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_seeker_missile_ammo");
171 makevectors(self.v_angle);
172 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/seeker_fire.wav", cvar("g_balance_seeker_missile_damage"));
174 pointparticles(particleeffectnum("seeker_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
176 //self.detornator = FALSE;
179 missile.owner = self;
180 missile.classname = "seeker_missile";
181 missile.bot_dodge = TRUE;
182 missile.bot_dodgerating = cvar("g_balance_seeker_missile_damage");
184 missile.think = Seeker_Missile_Animate;
186 //if (!cvar("g_balance_seeker_missile_proxy"))
187 missile.touch = Seeker_Missile_Touch;
189 missile.event_damage = Seeker_Missile_Damage;
190 missile.nextthink = time;// + 0.2;// + cvar("g_balance_seeker_missile_activate_delay");
191 missile.cnt = time + cvar("g_balance_seeker_missile_lifetime");
192 missile.enemy = self.enemy;
193 missile.solid = SOLID_BBOX;
195 missile.takedamage = DAMAGE_YES;
196 missile.health = cvar("g_balance_seeker_missile_health");
197 missile.damageforcescale = cvar("g_balance_seeker_missile_damageforcescale");
198 missile.projectiledeathtype = WEP_SEEKER;
200 setorigin (missile, w_shotorg);
201 setsize (missile, '-4 -4 -4', '4 4 4');
204 missile.movetype = MOVETYPE_FLYMISSILE;// MOVETYPE_TOSS;
206 missile.flags = FL_PROJECTILE;
208 W_SETUPPROJECTILEVELOCITY_UP(missile, g_balance_seeker_missile);
210 missile.switchweapon = vlen(missile.velocity);
211 missile.angles = vectoangles (missile.velocity);
213 CSQCProjectile(missile, FALSE, PROJECTILE_SEEKER, TRUE);
216 void Seeker_Vollycontroler_Think()
219 entity oldself,oldenemy;
220 self.cnt = self.cnt - 1;
222 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))
228 self.nextthink = time + cvar("g_balance_seeker_missile_delay");
233 oldenemy = self.enemy;
234 self.enemy = oldself.enemy;
236 c = mod(oldself.cnt, 4);
240 Seeker_Fire_Missile('-1.25 -3.75 0');
243 Seeker_Fire_Missile('+1.25 -3.75 0');
246 Seeker_Fire_Missile('-1.25 +3.75 0');
250 Seeker_Fire_Missile('+1.25 +3.75 0');
254 self.enemy = oldenemy;
258 void Seeker_Tag_Explode ()
260 //if(other==self.owner)
262 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_BOUNCE, self);
267 void Seeker_Tag_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
269 if (self.health <= 0)
271 self.health = self.health - damage;
272 if (self.health <= 0)
273 Seeker_Tag_Explode();
276 void Seeker_Tag_Think()
282 void Seeker_Tag_Touch()
287 dir = normalize (self.owner.origin - self.origin);
288 org2 = findbetterlocation (self.origin, 8);
290 te_knightspike(org2);
292 self.event_damage = SUB_Null;
293 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_HEADSHOT, self);
295 if (other.takedamage == DAMAGE_AIM && other.deadflag == DEAD_NO)
299 e.cnt = cvar("g_balance_seeker_missile_count");
300 e.owner = self.owner;
302 e.think = Seeker_Vollycontroler_Think;
305 //sprint(self.owner, "^1Target lock ^3[^7 ",other.netname, " ^3]^1 acquired - autofire activated.\n");
306 //sprint(other,"^1You are targeted!\n");
308 // stuffcmd(other,"play2 weapons/zany-alarm4.ogg\n");
309 // stuffcmd(self.owner, "play2 weapons/zany-lock4.ogg\n");
318 void Seeker_Fire_Tag()
320 local entity missile;
321 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
322 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_seeker_tag_ammo");
324 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/tag_fire.wav", 0);
327 missile.owner = self;
328 missile.classname = "seeker_tag";
329 missile.bot_dodge = TRUE;
330 missile.bot_dodgerating = 50;
331 missile.touch = Seeker_Tag_Touch;
332 missile.think = Seeker_Tag_Think;
333 missile.nextthink = time + cvar("g_balance_seeker_tag_lifetime");
334 missile.movetype = MOVETYPE_FLY;
335 missile.solid = SOLID_BBOX;
336 missile.owner = self;
338 missile.takedamage = DAMAGE_YES;
339 missile.event_damage = Seeker_Tag_Explode;
340 missile.health = cvar("g_balance_seeker_tag_health");
341 missile.damageforcescale = cvar("g_balance_seeker_tag_damageforcescale");
343 setorigin (missile, w_shotorg);
344 setsize (missile, '-2 -2 -2', '2 2 2');
346 missile.flags = FL_PROJECTILE;
348 missile.movetype = MOVETYPE_FLY;
349 W_SETUPPROJECTILEVELOCITY(missile, g_balance_seeker_tag);
350 missile.angles = vectoangles (missile.velocity);
352 CSQCProjectile(missile, TRUE, PROJECTILE_TAG, FALSE); // has sound
356 void Seeker_Flac_Explode ()
358 self.event_damage = SUB_Null;
360 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);
365 void Seeker_Flac_Touch()
369 Seeker_Flac_Explode();
372 void Seeker_Fire_Flac()
374 local entity missile;
378 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
379 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_seeker_flac_ammo");
381 c = mod(self.bulletcounter, 4);
385 f_diff = '-1.25 -3.75 0';
388 f_diff = '+1.25 -3.75 0';
391 f_diff = '-1.25 +3.75 0';
395 f_diff = '+1.25 +3.75 0';
398 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/flac_fire.wav", cvar("g_balance_seeker_flac_damage"));
401 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
404 missile.owner = missile.realowner = self;
405 missile.classname = "missile";
406 missile.bot_dodge = TRUE;
407 missile.bot_dodgerating = cvar("g_balance_seeker_flac_damage");
408 missile.touch = Seeker_Flac_Explode;
409 missile.use = Seeker_Flac_Explode;
410 missile.think = adaptor_think2use_hittype_splash;
411 missile.nextthink = time + cvar("g_balance_seeker_flac_lifetime") + cvar("g_balance_seeker_flac_lifetime_rand");
412 missile.solid = SOLID_BBOX;
413 missile.scale = 0.4; // BUG: the model is too big
414 missile.projectiledeathtype = WEP_SEEKER;
415 setorigin (missile, w_shotorg);
416 setsize (missile, '-2 -2 -2', '2 2 2');
417 missile.projectiledeathtype = WEP_SEEKER | HITTYPE_SECONDARY;
419 missile.movetype = MOVETYPE_FLY;
420 W_SETUPPROJECTILEVELOCITY_UP(missile, g_balance_seeker_flac);
422 missile.angles = vectoangles (missile.velocity);
423 missile.flags = FL_PROJECTILE;
425 CSQCProjectile(missile, TRUE, PROJECTILE_FLAC, TRUE);
428 void spawnfunc_weapon_seeker (void)
430 weapon_defaultspawnfunc(WEP_SEEKER);
433 float w_seeker(float req)
436 self.BUTTON_ATCK = bot_aim(cvar("g_balance_seeker_tag_speed"), 0, 20, FALSE);
438 else if (req == WR_THINK)
440 if (self.BUTTON_ATCK)
441 if (weapon_prepareattack(0, cvar("g_balance_seeker_tag_refire")))
444 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_seeker_tag_animtime"), w_ready);
447 if (self.BUTTON_ATCK2)
448 if (weapon_prepareattack(1, cvar("g_balance_seeker_flac_refire")))
451 weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_seeker_flac_animtime"), w_ready);
455 else if (req == WR_PRECACHE)
457 precache_model ("models/weapons/g_seeker.md3");
458 precache_model ("models/weapons/v_seeker.md3");
459 precache_model ("models/weapons/h_seeker.iqm");
460 precache_sound ("weapons/tag_fire.wav");
461 precache_sound ("weapons/flac_fire.wav");
462 precache_sound ("weapons/seeker_fire.wav");
464 else if (req == WR_SETUP)
465 weapon_setup(WEP_SEEKER);
466 else if (req == WR_CHECKAMMO1)
467 return self.ammo_rockets >= cvar("g_balance_seeker_tag_ammo") + cvar("g_balance_seeker_missile_ammo");
468 else if (req == WR_CHECKAMMO2)
469 return self.ammo_rockets >= cvar("g_balance_seeker_flac_ammo");
470 else if (req == WR_SUICIDEMESSAGE)
471 w_deathtypestring = "played with tiny rockets";
472 else if (req == WR_KILLMESSAGE)
474 if(w_deathtype & HITTYPE_SECONDARY)
475 w_deathtypestring = "ran into #'s flac";
477 w_deathtypestring = "was tagged by";