1 //.float speed; = switchweapon
2 //.float proxytime; = autoswitch
5 void Seeker_Missile_Explode ()
7 self.event_damage = SUB_Null;
8 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);
13 void Seeker_Missile_Touch()
17 Seeker_Missile_Explode();
20 void Seeker_Missile_Think()
23 vector desireddir, olddir, newdir, eorg;
28 Seeker_Missile_Explode();
30 if (!self.switchweapon)
31 self.switchweapon = cvar("g_balance_seeker_missile_speed");
33 if ((self.switchweapon < cvar("g_balance_seeker_missile_speed_max")) && cvar("g_balance_seeker_missile_speed_accel"))
34 self.switchweapon = self.switchweapon * cvar("g_balance_seeker_missile_accel");
36 if (self.switchweapon > cvar("g_balance_seeker_missile_speed_max"))
37 self.switchweapon = self.switchweapon * cvar("g_balance_seeker_missile_decel");
39 if (self.enemy != world)
40 if (self.enemy.takedamage != DAMAGE_AIM || self.enemy.deadflag != DEAD_NO)
43 if (self.enemy != world)
46 eorg = 0.5 * (e.absmin + e.absmax);
47 turnrate = cvar("g_balance_seeker_missile_turnrate"); // how fast to turn
48 desireddir = normalize(eorg - self.origin);
49 olddir = normalize(self.velocity); // get my current direction
50 dist = vlen(eorg - self.origin);
52 // Do evasive maneuvers for world objects? ( this should be a cpu hog. :P )
53 if (cvar("g_balance_seeker_missile_smart") && (dist > cvar("g_balance_seeker_missile_smart_mindist")))
55 // Is it a better idea (shorter distance) to trace to the target itself?
56 if ( vlen(self.origin + olddir * self.wait) < dist)
57 traceline(self.origin, self.origin + olddir * self.wait, FALSE, self);
59 traceline(self.origin, eorg, FALSE, self);
61 // Setup adaptive tracelength
62 self.wait = vlen(self.origin - trace_endpos);
63 if (self.wait < cvar("g_balance_seeker_missile_smart_trace_min")) self.wait = cvar("g_balance_seeker_missile_smart_trace_min");
64 if (self.wait > cvar("g_balance_seeker_missile_smart_trace_max")) self.wait = cvar("g_balance_seeker_missile_smart_trace_max");
66 // Calc how important it is that we turn and add this to the desierd (enemy) dir.
67 desireddir = normalize(((trace_plane_normal * (1 - trace_fraction)) + (desireddir * trace_fraction)) * 0.5);
70 //newdir = normalize((olddir + desireddir * turnrate) * 0.5);// take the average of the 2 directions; not the best method but simple & easy
71 newdir = normalize(olddir + desireddir * turnrate);// take the average of the 2 directions; not the best method but simple & easy
73 self.velocity = newdir * self.switchweapon; // make me fly in the new direction at my flight speed
77 if (cvar("g_balance_seeker_missile_proxy"))
79 if ( dist <= cvar("g_balance_seeker_missile_proxy_maxrange"))
81 if (self.autoswitch == 0)
83 self.autoswitch = time + cvar("g_balance_seeker_missile_proxy_delay");
87 if (self.autoswitch <= time)
89 Seeker_Missile_Explode();
96 if (self.autoswitch != 0)
102 if (self.enemy.deadflag != DEAD_NO)
105 self.cnt = time + 1 + (random() * 4);
106 self.nextthink = self.cnt;
110 self.angles = vectoangles(self.velocity); // turn model in the new flight direction
111 self.nextthink = time + 0.05;
113 UpdateCSQCProjectile(self);
118 void Seeker_Missile_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
123 if (self.owner == attacker)
126 self.health = self.health - d;
128 if (self.health <= 0)
129 W_PrepareExplosionByDamage(attacker, Seeker_Missile_Explode);
132 void Seeker_Missile_Animate()
134 self.frame = self.frame +1;
135 self.nextthink = time + 0.05;
137 if (self.enemy != world)
138 if (self.enemy.takedamage != DAMAGE_AIM || self.enemy.deadflag != DEAD_NO)
143 self.think = Seeker_Missile_Think;
144 self.nextthink = time;// + cvar("g_balance_seeker_missile_activate_delay"); // cant dealy with csqc projectiles
146 if (cvar("g_balance_seeker_guided_proxy"))
147 self.movetype = MOVETYPE_BOUNCEMISSILE;
149 self.movetype = MOVETYPE_FLYMISSILE;
152 UpdateCSQCProjectile(self);
155 void Seeker_Fire_Missile(vector f_diff)
157 local entity missile;
159 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
160 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_seeker_missile_ammo");
162 makevectors(self.v_angle);
163 W_SetupShot (self, FALSE, 2, "weapons/seeker_fire.wav");
165 pointparticles(particleeffectnum("seeker_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
167 //self.detornator = FALSE;
170 missile.owner = self;
171 missile.classname = "seeker_missile";
172 missile.bot_dodge = TRUE;
173 missile.bot_dodgerating = cvar("g_balance_seeker_missile_damage");
175 missile.think = Seeker_Missile_Animate;
177 //if (!cvar("g_balance_seeker_missile_proxy"))
178 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 + cvar("g_balance_seeker_missile_lifetime");
183 missile.enemy = self.enemy;
184 missile.switchweapon = cvar("g_balance_seeker_missile_speed");
185 missile.solid = SOLID_BBOX;
187 missile.takedamage = DAMAGE_YES;
188 missile.damageforcescale = 4;
190 missile.projectiledeathtype = WEP_SEEKER;
192 setorigin (missile, w_shotorg);
193 setsize (missile, '-2 -2 -2', '2 2 2');
196 missile.movetype = MOVETYPE_FLYMISSILE;// MOVETYPE_TOSS;
198 missile.flags = FL_PROJECTILE;
200 missile.velocity = (w_shotdir + '0 0 0.45') * missile.switchweapon;
201 W_SetupProjectileVelocity(missile);
203 missile.switchweapon = vlen(missile.velocity);
204 missile.angles = vectoangles (missile.velocity);
206 CSQCProjectile(missile, FALSE, PROJECTILE_SEEKER, TRUE);
209 void Seeker_Vollycontroler_Think()
212 entity oldself,oldenemy;
213 self.cnt = self.cnt - 1;
215 if ((self.owner.ammo_rockets < cvar("g_balance_seeker_missile_ammo")) || (self.cnt <= -1) || (self.owner.deadflag != DEAD_NO))
221 self.nextthink = time + cvar("g_balance_seeker_missile_delay");
226 oldenemy = self.enemy;
227 self.enemy = oldself.enemy;
229 c = mod(oldself.cnt, 4);
233 Seeker_Fire_Missile('-1.25 -3.75 0');
236 Seeker_Fire_Missile('+1.25 -3.75 0');
239 Seeker_Fire_Missile('-1.25 +3.75 0');
243 Seeker_Fire_Missile('+1.25 +3.75 0');
247 self.enemy = oldenemy;
251 void Seeker_Tag_Explode ()
253 //if(other==self.owner)
255 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_BOUNCE);
260 void Seeker_Tag_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
262 self.health = self.health - damage;
263 if (self.health <= 0)
264 Seeker_Tag_Explode();
267 void Seeker_Tag_Think()
273 void Seeker_Tag_Touch()
278 dir = normalize (self.owner.origin - self.origin);
279 org2 = findbetterlocation (self.origin, 8);
281 te_knightspike(org2);
283 self.event_damage = SUB_Null;
284 Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER | HITTYPE_HEADSHOT);
286 if (other.takedamage == DAMAGE_AIM && other.deadflag == DEAD_NO)
290 e.cnt = cvar("g_balance_seeker_missile_count");
291 e.owner = self.owner;
293 e.think = Seeker_Vollycontroler_Think;
296 //sprint(self.owner, "^1Target lock ^3[^7 ",other.netname, " ^3]^1 acquired - autofire activated.\n");
297 //sprint(other,"^1You are targeted!\n");
299 // stuffcmd(other,"play2 weapons/zany-alarm4.ogg\n");
300 // stuffcmd(self.owner, "play2 weapons/zany-lock4.ogg\n");
309 void Seeker_Fire_Tag()
311 local entity missile;
312 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
313 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_seeker_tag_ammo");
315 W_SetupShot (self, FALSE, 2, "weapons/tag_fire.wav");
318 missile.owner = self;
319 missile.classname = "seeker_tag";
320 missile.bot_dodge = TRUE;
321 missile.bot_dodgerating = 50;
322 missile.touch = Seeker_Tag_Touch;
323 missile.think = Seeker_Tag_Think;
324 missile.nextthink = time + 15;
325 missile.movetype = MOVETYPE_FLY;
326 missile.solid = SOLID_BBOX;
327 missile.owner = self;
329 missile.takedamage = DAMAGE_YES;
330 missile.event_damage = Seeker_Tag_Explode;
333 setorigin (missile, w_shotorg);
335 missile.flags = FL_PROJECTILE;
337 missile.velocity = w_shotdir * cvar("g_balance_seeker_tag_speed");
338 missile.movetype = MOVETYPE_BOUNCEMISSILE;
339 W_SetupProjectileVelocity(missile);
340 missile.angles = vectoangles (missile.velocity);
342 CSQCProjectile(missile, TRUE, PROJECTILE_TAG, FALSE); // has sound
346 void Seeker_Flac_Explode ()
348 self.event_damage = SUB_Null;
350 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);
355 void Seeker_Flac_Touch()
359 Seeker_Flac_Explode();
362 void Seeker_Fire_Flac()
364 local entity missile;
368 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
369 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_seeker_flac_ammo");
371 c = mod(self.bulletcounter, 4);
375 f_diff = '-1.25 -3.75 0';
378 f_diff = '+1.25 -3.75 0';
381 f_diff = '-1.25 +3.75 0';
385 f_diff = '+1.25 +3.75 0';
388 W_SetupShot (self, FALSE, 2, "weapons/flac_fire.wav");
391 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
394 missile.owner = missile.realowner = self;
395 missile.classname = "missile";
396 missile.bot_dodge = TRUE;
397 missile.bot_dodgerating = cvar("g_balance_seeker_flac_damage");
398 missile.touch = Seeker_Flac_Explode;
399 missile.use = Seeker_Flac_Explode;
400 missile.think = Seeker_Flac_Explode;
401 missile.nextthink = time + cvar("g_balance_seeker_flac_lifetime") + cvar("g_balance_seeker_flac_lifetime_rand");
402 missile.solid = SOLID_BBOX;
403 missile.scale = 0.4; // BUG: the model is too big
404 missile.projectiledeathtype = WEP_SEEKER;
405 setorigin (missile, w_shotorg);
406 missile.projectiledeathtype = WEP_SEEKER | HITTYPE_SECONDARY;
408 missile.movetype = MOVETYPE_FLY;
409 w_shotdir = w_shotdir + '0 0 0.3';
410 missile.velocity = (w_shotdir + randomvec() * cvar("g_balance_seeker_flac_spread")) * cvar("g_balance_seeker_flac_speed");
412 W_SetupProjectileVelocity(missile);
414 missile.angles = vectoangles (missile.velocity);
415 missile.flags = FL_PROJECTILE;
417 CSQCProjectile(missile, TRUE, PROJECTILE_FLAC, TRUE);
420 void spawnfunc_weapon_seeker (void)
422 weapon_defaultspawnfunc(WEP_SEEKER);
425 float w_seeker(float req)
428 self.BUTTON_ATCK = bot_aim(cvar("g_balance_seeker_tag_speed"), 0, 20, FALSE);
430 else if (req == WR_THINK)
432 if (self.BUTTON_ATCK)
433 if (weapon_prepareattack(0, cvar("g_balance_seeker_tag_refire")))
436 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_seeker_tag_animtime"), w_ready);
439 if (self.BUTTON_ATCK2)
440 if (weapon_prepareattack(1, cvar("g_balance_seeker_flac_refire")))
443 weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_seeker_flac_animtime"), w_ready);
447 else if (req == WR_PRECACHE)
449 precache_model ("models/weapons/g_seeker.md3");
450 precache_model ("models/weapons/v_seeker.md3");
451 precache_model ("models/weapons/h_seeker.dpm");
452 precache_sound ("weapons/tag_fire.wav");
453 precache_sound ("weapons/flac_fire.wav");
454 precache_sound ("weapons/seeker_fire.wav");
456 else if (req == WR_SETUP)
457 weapon_setup(WEP_SEEKER);
458 else if (req == WR_CHECKAMMO1)
459 return self.ammo_rockets >= cvar("g_balance_seeker_tag_ammo") + cvar("g_balance_seeker_missile_ammo");
460 else if (req == WR_CHECKAMMO2)
461 return self.ammo_rockets >= cvar("g_balance_seeker_flac_ammo");
462 else if (req == WR_SUICIDEMESSAGE)
463 w_deathtypestring = "played with tiny rockets";
464 else if (req == WR_KILLMESSAGE)
466 if(w_deathtype & HITTYPE_SECONDARY)
467 w_deathtypestring = "ran into #'s flac";
469 w_deathtypestring = "was tagged by";