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");
5 //.float speed; = switchweapon
6 //.float proxytime; = autoswitch
9 void Seeker_Missile_Explode ()
11 self.event_damage = SUB_Null;
12 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);
17 void Seeker_Missile_Touch()
21 Seeker_Missile_Explode();
24 void Seeker_Missile_Think()
27 vector desireddir, olddir, newdir, eorg;
33 self.projectiledeathtype |= HITTYPE_SPLASH;
34 Seeker_Missile_Explode();
37 if (!self.switchweapon)
38 self.switchweapon = cvar("g_balance_seeker_missile_speed");
40 if ((self.switchweapon < cvar("g_balance_seeker_missile_speed_max")) && cvar("g_balance_seeker_missile_speed_accel"))
41 self.switchweapon = self.switchweapon * cvar("g_balance_seeker_missile_accel");
43 if (self.switchweapon > cvar("g_balance_seeker_missile_speed_max"))
44 self.switchweapon = self.switchweapon * cvar("g_balance_seeker_missile_decel");
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 = cvar("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 (cvar("g_balance_seeker_missile_smart") && (dist > cvar("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 = vlen(self.origin - trace_endpos);
70 if (self.wait < cvar("g_balance_seeker_missile_smart_trace_min")) self.wait = cvar("g_balance_seeker_missile_smart_trace_min");
71 if (self.wait > cvar("g_balance_seeker_missile_smart_trace_max")) self.wait = cvar("g_balance_seeker_missile_smart_trace_max");
73 // Calc how important it is that we turn and add this to the desierd (enemy) dir.
74 desireddir = normalize(((trace_plane_normal * (1 - trace_fraction)) + (desireddir * trace_fraction)) * 0.5);
77 //newdir = normalize((olddir + desireddir * turnrate) * 0.5);// take the average of the 2 directions; not the best method but simple & easy
78 newdir = normalize(olddir + desireddir * turnrate);// take the average of the 2 directions; not the best method but simple & easy
80 self.velocity = newdir * self.switchweapon; // make me fly in the new direction at my flight speed
84 if (cvar("g_balance_seeker_missile_proxy"))
86 if ( dist <= cvar("g_balance_seeker_missile_proxy_maxrange"))
88 if (self.autoswitch == 0)
90 self.autoswitch = time + cvar("g_balance_seeker_missile_proxy_delay");
94 if (self.autoswitch <= time)
96 Seeker_Missile_Explode();
103 if (self.autoswitch != 0)
109 if (self.enemy.deadflag != DEAD_NO)
112 self.cnt = time + 1 + (random() * 4);
113 self.nextthink = self.cnt;
117 self.angles = vectoangles(self.velocity); // turn model in the new flight direction
118 self.nextthink = time + 0.05;
120 UpdateCSQCProjectile(self);
125 void Seeker_Missile_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
130 if (self.health <= 0)
133 if (self.owner == attacker)
136 self.health = self.health - d;
138 if (self.health <= 0)
139 W_PrepareExplosionByDamage(attacker, Seeker_Missile_Explode);
142 void Seeker_Missile_Animate()
144 self.frame = self.frame +1;
145 self.nextthink = time + 0.05;
147 if (self.enemy != world)
148 if (self.enemy.takedamage != DAMAGE_AIM || self.enemy.deadflag != DEAD_NO)
153 self.think = Seeker_Missile_Think;
154 self.nextthink = time;// + cvar("g_balance_seeker_missile_activate_delay"); // cant dealy with csqc projectiles
156 if (cvar("g_balance_seeker_missile_proxy"))
157 self.movetype = MOVETYPE_BOUNCEMISSILE;
159 self.movetype = MOVETYPE_FLYMISSILE;
162 UpdateCSQCProjectile(self);
165 void Seeker_Fire_Missile(vector f_diff)
167 local entity missile;
169 if not(self.owner.items & IT_UNLIMITED_WEAPON_AMMO)
170 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_seeker_missile_ammo");
172 makevectors(self.v_angle);
173 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/seeker_fire.wav", cvar("g_balance_seeker_missile_damage"));
175 pointparticles(particleeffectnum("seeker_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
177 //self.detornator = FALSE;
180 missile.owner = self;
181 missile.classname = "seeker_missile";
182 missile.bot_dodge = TRUE;
183 missile.bot_dodgerating = cvar("g_balance_seeker_missile_damage");
185 missile.think = Seeker_Missile_Animate;
187 //if (!cvar("g_balance_seeker_missile_proxy"))
188 missile.touch = Seeker_Missile_Touch;
190 missile.event_damage = Seeker_Missile_Damage;
191 missile.nextthink = time;// + 0.2;// + cvar("g_balance_seeker_missile_activate_delay");
192 missile.cnt = time + cvar("g_balance_seeker_missile_lifetime");
193 missile.enemy = self.enemy;
194 missile.solid = SOLID_BBOX;
196 missile.takedamage = DAMAGE_YES;
197 missile.health = cvar("g_balance_seeker_missile_health");
198 missile.damageforcescale = cvar("g_balance_seeker_missile_damageforcescale");
199 missile.projectiledeathtype = WEP_SEEKER;
201 setorigin (missile, w_shotorg);
202 setsize (missile, '-4 -4 -4', '4 4 4');
205 missile.movetype = MOVETYPE_FLYMISSILE;// MOVETYPE_TOSS;
207 missile.flags = FL_PROJECTILE;
209 W_SETUPPROJECTILEVELOCITY_UP(missile, g_balance_seeker_missile);
211 missile.switchweapon = vlen(missile.velocity);
212 missile.angles = vectoangles (missile.velocity);
214 CSQCProjectile(missile, FALSE, PROJECTILE_SEEKER, TRUE);
216 other = missile; MUTATOR_CALLHOOK(EditProjectile);
219 void Seeker_Vollycontroler_Think()
222 entity oldself,oldenemy;
223 self.cnt = self.cnt - 1;
225 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))
231 self.nextthink = time + cvar("g_balance_seeker_missile_delay");
236 oldenemy = self.enemy;
237 self.enemy = oldself.enemy;
239 c = mod(oldself.cnt, 4);
243 Seeker_Fire_Missile('-1.25 -3.75 0');
246 Seeker_Fire_Missile('+1.25 -3.75 0');
249 Seeker_Fire_Missile('-1.25 +3.75 0');
253 Seeker_Fire_Missile('+1.25 +3.75 0');
257 self.enemy = oldenemy;
261 void Seeker_Tag_Explode ()
263 //if(other==self.owner)
265 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_BOUNCE, self);
270 void Seeker_Tag_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
272 if (self.health <= 0)
274 self.health = self.health - damage;
275 if (self.health <= 0)
276 Seeker_Tag_Explode();
279 void Seeker_Tag_Think()
285 void Seeker_Tag_Touch()
290 dir = normalize (self.owner.origin - self.origin);
291 org2 = findbetterlocation (self.origin, 8);
293 te_knightspike(org2);
295 self.event_damage = SUB_Null;
296 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_HEADSHOT, self);
298 if (other.takedamage == DAMAGE_AIM && other.deadflag == DEAD_NO)
302 e.cnt = cvar("g_balance_seeker_missile_count");
303 e.owner = self.owner;
305 e.think = Seeker_Vollycontroler_Think;
308 //sprint(self.owner, "^1Target lock ^3[^7 ",other.netname, " ^3]^1 acquired - autofire activated.\n");
309 //sprint(other,"^1You are targeted!\n");
311 // stuffcmd(other,"play2 weapons/zany-alarm4.ogg\n");
312 // stuffcmd(self.owner, "play2 weapons/zany-lock4.ogg\n");
321 void Seeker_Fire_Tag()
323 local entity missile;
324 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
325 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_seeker_tag_ammo");
327 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/tag_fire.wav", 0);
330 missile.owner = self;
331 missile.classname = "seeker_tag";
332 missile.bot_dodge = TRUE;
333 missile.bot_dodgerating = 50;
334 missile.touch = Seeker_Tag_Touch;
335 missile.think = Seeker_Tag_Think;
336 missile.nextthink = time + cvar("g_balance_seeker_tag_lifetime");
337 missile.movetype = MOVETYPE_FLY;
338 missile.solid = SOLID_BBOX;
339 missile.owner = self;
341 missile.takedamage = DAMAGE_YES;
342 missile.event_damage = Seeker_Tag_Explode;
343 missile.health = cvar("g_balance_seeker_tag_health");
344 missile.damageforcescale = cvar("g_balance_seeker_tag_damageforcescale");
346 setorigin (missile, w_shotorg);
347 setsize (missile, '-2 -2 -2', '2 2 2');
349 missile.flags = FL_PROJECTILE;
351 missile.movetype = MOVETYPE_FLY;
352 W_SETUPPROJECTILEVELOCITY(missile, g_balance_seeker_tag);
353 missile.angles = vectoangles (missile.velocity);
355 CSQCProjectile(missile, TRUE, PROJECTILE_TAG, FALSE); // has sound
357 other = missile; MUTATOR_CALLHOOK(EditProjectile);
361 void Seeker_Flac_Explode ()
363 self.event_damage = SUB_Null;
365 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);
370 void Seeker_Flac_Touch()
374 Seeker_Flac_Explode();
377 void Seeker_Fire_Flac()
379 local entity missile;
383 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
384 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_seeker_flac_ammo");
386 c = mod(self.bulletcounter, 4);
390 f_diff = '-1.25 -3.75 0';
393 f_diff = '+1.25 -3.75 0';
396 f_diff = '-1.25 +3.75 0';
400 f_diff = '+1.25 +3.75 0';
403 W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/flac_fire.wav", cvar("g_balance_seeker_flac_damage"));
406 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
409 missile.owner = missile.realowner = self;
410 missile.classname = "missile";
411 missile.bot_dodge = TRUE;
412 missile.bot_dodgerating = cvar("g_balance_seeker_flac_damage");
413 missile.touch = Seeker_Flac_Explode;
414 missile.use = Seeker_Flac_Explode;
415 missile.think = adaptor_think2use_hittype_splash;
416 missile.nextthink = time + cvar("g_balance_seeker_flac_lifetime") + cvar("g_balance_seeker_flac_lifetime_rand");
417 missile.solid = SOLID_BBOX;
418 missile.scale = 0.4; // BUG: the model is too big
419 missile.projectiledeathtype = WEP_SEEKER;
420 setorigin (missile, w_shotorg);
421 setsize (missile, '-2 -2 -2', '2 2 2');
422 missile.projectiledeathtype = WEP_SEEKER | HITTYPE_SECONDARY;
424 missile.movetype = MOVETYPE_FLY;
425 W_SETUPPROJECTILEVELOCITY_UP(missile, g_balance_seeker_flac);
427 missile.angles = vectoangles (missile.velocity);
428 missile.flags = FL_PROJECTILE;
430 CSQCProjectile(missile, TRUE, PROJECTILE_FLAC, TRUE);
432 other = missile; MUTATOR_CALLHOOK(EditProjectile);
435 void spawnfunc_weapon_seeker (void)
437 weapon_defaultspawnfunc(WEP_SEEKER);
440 float w_seeker(float req)
443 self.BUTTON_ATCK = bot_aim(cvar("g_balance_seeker_tag_speed"), 0, 20, FALSE);
445 else if (req == WR_THINK)
447 if (self.BUTTON_ATCK)
448 if (weapon_prepareattack(0, cvar("g_balance_seeker_tag_refire")))
451 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_seeker_tag_animtime"), w_ready);
454 if (self.BUTTON_ATCK2)
455 if (weapon_prepareattack(1, cvar("g_balance_seeker_flac_refire")))
458 weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_seeker_flac_animtime"), w_ready);
462 else if (req == WR_PRECACHE)
464 precache_model ("models/weapons/g_seeker.md3");
465 precache_model ("models/weapons/v_seeker.md3");
466 precache_model ("models/weapons/h_seeker.iqm");
467 precache_sound ("weapons/tag_fire.wav");
468 precache_sound ("weapons/flac_fire.wav");
469 precache_sound ("weapons/seeker_fire.wav");
471 else if (req == WR_SETUP)
472 weapon_setup(WEP_SEEKER);
473 else if (req == WR_CHECKAMMO1)
474 return self.ammo_rockets >= cvar("g_balance_seeker_tag_ammo") + cvar("g_balance_seeker_missile_ammo");
475 else if (req == WR_CHECKAMMO2)
476 return self.ammo_rockets >= cvar("g_balance_seeker_flac_ammo");
481 float w_seeker(float req)
483 if(req == WR_IMPACTEFFECT)
486 org2 = w_org + w_backoff * 6;
487 if(w_deathtype & HITTYPE_SECONDARY)
489 pointparticles(particleeffectnum("flac_explode"), org2, '0 0 0', 1);
493 sound(self, CHAN_PROJECTILE, "weapons/flacexp1.wav", 1, ATTN_NORM);
494 else if (w_random<0.7)
495 sound(self, CHAN_PROJECTILE, "weapons/flacexp2.wav", 1, ATTN_NORM);
497 sound(self, CHAN_PROJECTILE, "weapons/flacexp3.wav", 1, ATTN_NORM);
502 if(w_deathtype & HITTYPE_BOUNCE)
504 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
508 sound(self, CHAN_PROJECTILE, "weapons/tagexp1.wav", 1, ATTN_NORM);
509 else if (w_random<0.7)
510 sound(self, CHAN_PROJECTILE, "weapons/tagexp2.wav", 1, ATTN_NORM);
512 sound(self, CHAN_PROJECTILE, "weapons/tagexp3.wav", 1, ATTN_NORM);
515 else if(w_deathtype & HITTYPE_HEADSHOT)
518 sound(self, CHAN_PROJECTILE, "weapons/tag_impact.wav", 1, ATTN_NORM);
522 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
526 sound(self, CHAN_PROJECTILE, "weapons/seekerexp1.wav", 1, ATTN_NORM);
527 else if (w_random<0.7)
528 sound(self, CHAN_PROJECTILE, "weapons/seekerexp2.wav", 1, ATTN_NORM);
530 sound(self, CHAN_PROJECTILE, "weapons/seekerexp3.wav", 1, ATTN_NORM);
535 else if(req == WR_PRECACHE)
537 precache_sound("weapons/flacexp1.wav");
538 precache_sound("weapons/flacexp2.wav");
539 precache_sound("weapons/flacexp3.wav");
540 precache_sound("weapons/seekerexp1.wav");
541 precache_sound("weapons/seekerexp2.wav");
542 precache_sound("weapons/seekerexp3.wav");
543 precache_sound("weapons/tagexp1.wav");
544 precache_sound("weapons/tagexp2.wav");
545 precache_sound("weapons/tagexp3.wav");
546 precache_sound("weapons/tag_impact.wav");
548 else if (req == WR_SUICIDEMESSAGE)
549 w_deathtypestring = "%s played with tiny rockets";
550 else if (req == WR_KILLMESSAGE)
552 if(w_deathtype & HITTYPE_SECONDARY)
553 w_deathtypestring = "%s ran into %s's flac";
555 w_deathtypestring = "%s was tagged by %s";