Don't multiply shot direction by 1000 in each case, fixes strange flashes appearing...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapon / seeker.qc
1 #include "seeker.qh"
2
3 #ifdef SVQC
4
5 // ============================
6 // Begin: Missile functions, these are general functions to be manipulated by other code
7 // ============================
8 void W_Seeker_Missile_Explode(entity this, entity directhitentity)
9 {
10         this.event_damage = func_null;
11         RadiusDamage(this, this.realowner, WEP_CVAR(seeker, missile_damage), WEP_CVAR(seeker, missile_edgedamage), WEP_CVAR(seeker, missile_radius), NULL, NULL, WEP_CVAR(seeker, missile_force), this.projectiledeathtype, this.weaponentity_fld, directhitentity);
12
13         delete(this);
14 }
15
16 void W_Seeker_Missile_Explode_think(entity this)
17 {
18         W_Seeker_Missile_Explode(this, NULL);
19 }
20
21 void W_Seeker_Missile_Touch(entity this, entity toucher)
22 {
23         PROJECTILE_TOUCH(this, toucher);
24
25         W_Seeker_Missile_Explode(this, toucher);
26 }
27
28 void W_Seeker_Missile_Think(entity this)
29 {
30         entity e;
31         vector desireddir, olddir, newdir, eorg;
32         float turnrate;
33         float dist;
34         float spd;
35
36         if(time > this.cnt)
37         {
38                 this.projectiledeathtype |= HITTYPE_SPLASH;
39                 W_Seeker_Missile_Explode(this, NULL);
40         }
41
42         spd = vlen(this.velocity);
43         spd = bound(
44                 spd - WEP_CVAR(seeker, missile_decel) * frametime,
45                 WEP_CVAR(seeker, missile_speed_max),
46                 spd + WEP_CVAR(seeker, missile_accel) * frametime
47         );
48
49         if(this.enemy != NULL)
50                 if(this.enemy.takedamage != DAMAGE_AIM || IS_DEAD(this.enemy))
51                         this.enemy = NULL;
52
53         if(this.enemy != NULL)
54         {
55                 e               = this.enemy;
56                 eorg            = 0.5 * (e.absmin + e.absmax);
57                 turnrate        = WEP_CVAR(seeker, missile_turnrate); // how fast to turn
58                 desireddir      = normalize(eorg - this.origin);
59                 olddir          = normalize(this.velocity); // get my current direction
60                 dist            = vlen(eorg - this.origin);
61
62                 // Do evasive maneuvers for world objects? ( this should be a cpu hog. :P )
63                 if(WEP_CVAR(seeker, missile_smart) && (dist > WEP_CVAR(seeker, missile_smart_mindist)))
64                 {
65                         // Is it a better idea (shorter distance) to trace to the target itself?
66                         if( vdist(this.origin + olddir * this.wait, <, dist))
67                                 traceline(this.origin, this.origin + olddir * this.wait, false, this);
68                         else
69                                 traceline(this.origin, eorg, false, this);
70
71                         // Setup adaptive tracelength
72                         this.wait = bound(WEP_CVAR(seeker, missile_smart_trace_min), vlen(this.origin - trace_endpos), this.wait = WEP_CVAR(seeker, missile_smart_trace_max));
73
74                         // Calc how important it is that we turn and add this to the desierd (enemy) dir.
75                         desireddir  = normalize(((trace_plane_normal * (1 - trace_fraction)) + (desireddir * trace_fraction)) * 0.5);
76                 }
77
78                 newdir = normalize(olddir + desireddir * turnrate); // take the average of the 2 directions; not the best method but simple & easy
79                 this.velocity = newdir * spd; // make me fly in the new direction at my flight speed
80         }
81         else
82                 dist = 0;
83
84         // Proxy
85         if(WEP_CVAR(seeker, missile_proxy))
86         {
87                 if(dist <= WEP_CVAR(seeker, missile_proxy_maxrange))
88                 {
89                         if(this.autoswitch == 0)
90                         {
91                                 this.autoswitch = time + WEP_CVAR(seeker, missile_proxy_delay);
92                         }
93                         else
94                         {
95                                 if(this.autoswitch <= time)
96                                 {
97                                         W_Seeker_Missile_Explode(this, NULL);
98                                         this.autoswitch = 0;
99                                 }
100                         }
101                 }
102                 else
103                 {
104                         if(this.autoswitch != 0)
105                                 this.autoswitch = 0;
106                 }
107         }
108         ///////////////
109
110         if(IS_DEAD(this.enemy))
111         {
112                 this.enemy = NULL;
113                 this.cnt = time + 1 + (random() * 4);
114                 this.nextthink = this.cnt;
115                 return;
116         }
117
118         //this.angles = vectoangles(this.velocity);                     // turn model in the new flight direction
119         this.nextthink = time;// + 0.05; // csqc projectiles
120         UpdateCSQCProjectile(this);
121 }
122
123
124
125 void W_Seeker_Missile_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
126 {
127         if(GetResource(this, RES_HEALTH) <= 0)
128                 return;
129
130         if(!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions
131                 return; // g_projectiles_damage says to halt
132
133         if(this.realowner == attacker)
134                 TakeResource(this, RES_HEALTH, (damage * 0.25));
135         else
136                 TakeResource(this, RES_HEALTH, damage);
137
138         if(GetResource(this, RES_HEALTH) <= 0)
139                 W_PrepareExplosionByDamage(this, attacker, W_Seeker_Missile_Explode_think);
140 }
141
142 /*
143 void W_Seeker_Missile_Animate(entity this)
144 {
145         this.frame = this.frame +1;
146         this.nextthink = time + 0.05;
147
148         if(this.enemy != NULL)
149                 if(this.enemy.takedamage != DAMAGE_AIM || IS_DEAD(this.enemy))
150                         this.enemy = NULL;
151
152         if(this.frame == 5)
153         {
154                 this.think           = W_Seeker_Missile_Think;
155                 this.nextthink       = time;// + cvar("g_balance_seeker_missile_activate_delay"); // cant dealy with csqc projectiles
156
157                 if(autocvar_g_balance_seeker_missile_proxy)
158                         this.move_movetype    = MOVETYPE_BOUNCEMISSILE;
159                 else
160                         this.move_movetype    = MOVETYPE_FLYMISSILE;
161         }
162
163         UpdateCSQCProjectile(this);
164 }
165 */
166
167 void W_Seeker_Fire_Missile(Weapon thiswep, entity actor, .entity weaponentity, vector f_diff, entity m_target)
168 {
169         W_DecreaseAmmo(thiswep, actor, WEP_CVAR(seeker, missile_ammo), weaponentity);
170
171         makevectors(actor.v_angle);
172         W_SetupShot_ProjectileSize(actor, weaponentity, '-2 -2 -2', '2 2 2', false, 2, SND_SEEKER_FIRE, CH_WEAPON_A, 0, ((m_target != NULL) ? thiswep.m_id | HITTYPE_SECONDARY : thiswep.m_id));
173         w_shotorg += f_diff;
174         W_MuzzleFlash(actor, weaponentity, EFFECT_SEEKER_MUZZLEFLASH, MDL_Null, w_shotorg, w_shotdir);
175
176         //actor.detornator         = false;
177
178         entity missile                 = new(seeker_missile);
179         missile.owner           = missile.realowner = actor;
180         missile.bot_dodge       = true;
181         missile.bot_dodgerating = WEP_CVAR(seeker, missile_damage);
182
183         setthink(missile, W_Seeker_Missile_Think);
184         settouch(missile, W_Seeker_Missile_Touch);
185         missile.event_damage    = W_Seeker_Missile_Damage;
186         missile.nextthink       = time;// + 0.2;// + cvar("g_balance_seeker_missile_activate_delay");
187         missile.cnt             = time + WEP_CVAR(seeker, missile_lifetime);
188         missile.enemy           = m_target;
189         missile.solid           = SOLID_BBOX;
190         missile.scale           = 2;
191         missile.takedamage      = DAMAGE_YES;
192         missile.weaponentity_fld = weaponentity;
193         SetResourceExplicit(missile, RES_HEALTH, WEP_CVAR(seeker, missile_health));
194         missile.damageforcescale = WEP_CVAR(seeker, missile_damageforcescale);
195         missile.damagedbycontents = true;
196         IL_PUSH(g_damagedbycontents, missile);
197         //missile.think           = W_Seeker_Missile_Animate; // csqc projectiles.
198
199         if(missile.enemy != NULL)
200                 missile.projectiledeathtype = thiswep.m_id | HITTYPE_SECONDARY;
201         else
202                 missile.projectiledeathtype = thiswep.m_id;
203
204
205         setorigin(missile, w_shotorg);
206         setsize(missile, '-4 -4 -4', '4 4 4');
207         set_movetype(missile, MOVETYPE_FLYMISSILE);
208         missile.flags = FL_PROJECTILE;
209         IL_PUSH(g_projectiles, missile);
210         IL_PUSH(g_bot_dodge, missile);
211         missile.missile_flags = MIF_SPLASH | MIF_GUIDED_TAG;
212
213         W_SetupProjVelocity_UP_PRE(missile, seeker, missile_);
214
215         missile.angles = vectoangles(missile.velocity);
216
217         CSQCProjectile(missile, false, PROJECTILE_SEEKER, true);
218
219         MUTATOR_CALLHOOK(EditProjectile, actor, missile);
220 }
221
222 // ============================
223 // Begin: FLAC, close range attack meant for defeating rockets which are coming at you.
224 // ============================
225 void W_Seeker_Flac_Explode(entity this, entity directhitentity)
226 {
227         this.event_damage = func_null;
228
229         RadiusDamage(this, this.realowner, WEP_CVAR(seeker, flac_damage), WEP_CVAR(seeker, flac_edgedamage), WEP_CVAR(seeker, flac_radius), NULL, NULL, WEP_CVAR(seeker, flac_force), this.projectiledeathtype, this.weaponentity_fld, directhitentity);
230
231         delete(this);
232 }
233
234 void W_Seeker_Flac_Touch(entity this, entity toucher)
235 {
236         W_Seeker_Flac_Explode(this, toucher);
237 }
238
239 void W_Seeker_Flac_Explode_use(entity this, entity actor, entity trigger)
240 {
241         W_Seeker_Flac_Explode(this, trigger);
242 }
243
244 void W_Seeker_Fire_Flac(Weapon thiswep, entity actor, .entity weaponentity)
245 {
246         entity missile;
247         vector f_diff;
248         float c;
249
250         W_DecreaseAmmo(thiswep, actor, WEP_CVAR(seeker, flac_ammo), weaponentity);
251
252         c = actor.(weaponentity).bulletcounter % 4;
253         switch(c)
254         {
255                 case 0:
256                         f_diff = '-1.25 -3.75 0';
257                         break;
258                 case 1:
259                         f_diff = '+1.25 -3.75 0';
260                         break;
261                 case 2:
262                         f_diff = '-1.25 +3.75 0';
263                         break;
264                 case 3:
265                 default:
266                         f_diff = '+1.25 +3.75 0';
267                         break;
268         }
269         W_SetupShot_ProjectileSize(actor, weaponentity, '-2 -2 -2', '2 2 2', false, 2, SND_FLAC_FIRE, CH_WEAPON_A, WEP_CVAR(seeker, flac_damage), thiswep.m_id | HITTYPE_SECONDARY);
270         w_shotorg += f_diff;
271
272         W_MuzzleFlash(actor, weaponentity, EFFECT_HAGAR_MUZZLEFLASH, MDL_Null, w_shotorg, w_shotdir);
273
274         missile                                 = new(missile);
275         missile.owner                   = missile.realowner = actor;
276         missile.bot_dodge               = true;
277         missile.bot_dodgerating = WEP_CVAR(seeker, flac_damage);
278         settouch(missile, W_Seeker_Flac_Touch);
279         missile.use                     = W_Seeker_Flac_Explode_use;
280         setthink(missile, adaptor_think2use_hittype_splash);
281         missile.nextthink               = time + WEP_CVAR(seeker, flac_lifetime) + WEP_CVAR(seeker, flac_lifetime_rand);
282         missile.solid                   = SOLID_BBOX;
283         set_movetype(missile, MOVETYPE_FLY);
284         missile.projectiledeathtype = thiswep.m_id | HITTYPE_SECONDARY;
285         missile.weaponentity_fld = weaponentity;
286         missile.flags = FL_PROJECTILE;
287         IL_PUSH(g_projectiles, missile);
288         IL_PUSH(g_bot_dodge, missile);
289         missile.missile_flags       = MIF_SPLASH;
290
291         // csqc projectiles
292         //missile.angles                                = vectoangles(missile.velocity);
293         //missile.scale = 0.4; // BUG: the model is too big
294
295         setorigin(missile, w_shotorg);
296         setsize(missile, '-2 -2 -2', '2 2 2');
297
298         W_SetupProjVelocity_UP_PRE(missile, seeker, flac_);
299         CSQCProjectile(missile, true, PROJECTILE_FLAC, true);
300
301         MUTATOR_CALLHOOK(EditProjectile, actor, missile);
302 }
303
304 // ============================
305 // Begin: Tag and rocket controllers
306 // ============================
307 entity W_Seeker_Tagged_Info(entity isowner, .entity weaponentity, entity istarget)
308 {
309         IL_EACH(g_seeker_trackers, it.classname == "tag_tracker" && it.realowner == isowner,
310         {
311                 if(it.tag_target == istarget && it.weaponentity_fld == weaponentity)
312                         return it;
313         });
314
315         return NULL;
316 }
317
318 void W_Seeker_Attack(Weapon thiswep, entity actor, .entity weaponentity)
319 {
320         entity closest_target = NULL;
321
322         IL_EACH(g_seeker_trackers, it.classname == "tag_tracker" && it.realowner == actor,
323         {
324                 if(closest_target)
325                 {
326                         if(vlen2(actor.origin - it.tag_target.origin) < vlen2(actor.origin - closest_target.origin))
327                                 closest_target = it.tag_target;
328                 }
329                 else
330                         closest_target = it.tag_target;
331         });
332
333         if(closest_target)
334         {
335                 traceline(actor.origin + actor.view_ofs, closest_target.origin, MOVE_NOMONSTERS, actor);
336                 if(!closest_target || (trace_fraction < 1 && trace_ent != closest_target))
337                         closest_target = NULL;
338         }
339
340         W_Seeker_Fire_Missile(thiswep, actor, weaponentity, '0 0 0', closest_target);
341 }
342
343 void W_Seeker_Vollycontroller_Think(entity this) // TODO: Merge this with W_Seeker_Attack
344 {
345         this.cnt = this.cnt - 1;
346
347         Weapon thiswep = WEP_SEEKER;
348         .entity weaponentity = this.weaponentity_fld;
349         if((!(this.realowner.items & IT_UNLIMITED_AMMO) && GetResource(this.realowner, thiswep.ammo_type) < WEP_CVAR(seeker, missile_ammo)) || (this.cnt <= -1) || (IS_DEAD(this.realowner)) || (this.realowner.(weaponentity).m_switchweapon != thiswep))
350         {
351                 delete(this);
352                 return;
353         }
354
355         this.nextthink = time + WEP_CVAR(seeker, missile_delay) * W_WeaponRateFactor(this.realowner);
356
357         entity own = this.realowner;
358
359         entity oldenemy = own.enemy;
360         own.enemy = this.enemy;
361
362         switch(own.cnt % 4)
363         {
364                 case 0:
365                         W_Seeker_Fire_Missile(thiswep, own, weaponentity, '-1.25 -3.75 0', own.enemy); // TODO
366                         break;
367                 case 1:
368                         W_Seeker_Fire_Missile(thiswep, own, weaponentity, '+1.25 -3.75 0', own.enemy); // TODO
369                         break;
370                 case 2:
371                         W_Seeker_Fire_Missile(thiswep, own, weaponentity, '-1.25 +3.75 0', own.enemy); // TODO
372                         break;
373                 case 3:
374                 default:
375                         W_Seeker_Fire_Missile(thiswep, own, weaponentity, '+1.25 +3.75 0', own.enemy); // TODO
376                         break;
377         }
378
379         own.enemy = oldenemy;
380 }
381
382 void W_Seeker_Tracker_Think(entity this)
383 {
384         .entity weaponentity = this.weaponentity_fld;
385         // commit suicide if: You die OR target dies OR you switch away from the seeker OR commit suicide if lifetime is up
386         if((IS_DEAD(this.realowner)) || (IS_DEAD(this.tag_target)) || (this.realowner.(weaponentity).m_switchweapon != WEP_SEEKER)
387         || (time > this.tag_time + WEP_CVAR(seeker, tag_tracker_lifetime)))
388         {
389                 if(this)
390                 {
391                         WaypointSprite_Kill(this.tag_target.wps_tag_tracker);
392                         delete(this);
393                 }
394                 return;
395         }
396
397         // Update the think method information
398         this.nextthink = time;
399 }
400
401 // ============================
402 // Begin: Tag projectile
403 // ============================
404 void W_Seeker_Tag_Explode(entity this)
405 {
406         //if(other==this.realowner)
407         //    return;
408         Damage_DamageInfo(this.origin, 0, 0, 0, this.velocity, WEP_SEEKER.m_id | HITTYPE_BOUNCE, 0, this);
409
410         delete(this);
411 }
412
413 void W_Seeker_Tag_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
414 {
415         if(GetResource(this, RES_HEALTH) <= 0)
416                 return;
417         TakeResource(this, RES_HEALTH, damage);
418         if(GetResource(this, RES_HEALTH) <= 0)
419                 W_Seeker_Tag_Explode(this);
420 }
421
422 void W_Seeker_Tag_Touch(entity this, entity toucher)
423 {
424         vector dir;
425         vector org2;
426         entity e;
427
428         PROJECTILE_TOUCH(this, toucher);
429
430         dir     = normalize(this.realowner.origin - this.origin);
431         org2    = findbetterlocation(this.origin, 8);
432
433         te_knightspike(org2);
434
435         this.event_damage = func_null;
436         Damage_DamageInfo(this.origin, 0, 0, 0, this.velocity, WEP_SEEKER.m_id | HITTYPE_BOUNCE | HITTYPE_SECONDARY, toucher.species, this);
437
438         if(toucher.takedamage == DAMAGE_AIM && !IS_DEAD(toucher))
439         {
440                 // check to see if this person is already tagged by me
441                 .entity weaponentity = this.weaponentity_fld;
442                 entity tag = W_Seeker_Tagged_Info(this.realowner, weaponentity, toucher);
443
444                 if(tag != NULL)
445                 {
446                         if(toucher.wps_tag_tracker && (WEP_CVAR(seeker, type) == 1)) // don't attach another waypointsprite without killing the old one first
447                                 WaypointSprite_Kill(toucher.wps_tag_tracker);
448
449                         tag.tag_time = time;
450                 }
451                 else
452                 {
453                         //sprint(this.realowner, strcat("You just tagged ^2", toucher.netname, "^7 with a tracking device!\n"));
454                         e             = new(tag_tracker);
455                         e.weaponentity_fld = this.weaponentity_fld;
456                         e.cnt         = WEP_CVAR(seeker, missile_count);
457                         e.owner       = this.owner;
458                         e.realowner   = this.realowner;
459                         IL_PUSH(g_seeker_trackers, e);
460
461                         if(WEP_CVAR(seeker, type) == 1)
462                         {
463                                 e.tag_target  = toucher;
464                                 e.tag_time    = time;
465                                 setthink(e, W_Seeker_Tracker_Think);
466                         }
467                         else
468                         {
469                                 e.enemy     = toucher;
470                                 setthink(e, W_Seeker_Vollycontroller_Think);
471                         }
472
473                         e.nextthink   = time;
474                 }
475
476                 if(WEP_CVAR(seeker, type) == 1)
477                 {
478                         WaypointSprite_Spawn(WP_Seeker, WEP_CVAR(seeker, tag_tracker_lifetime), 0, toucher, '0 0 64', this.realowner, 0, toucher, wps_tag_tracker, true, RADARICON_TAGGED);
479                         WaypointSprite_UpdateRule(toucher.wps_tag_tracker, 0, SPRITERULE_DEFAULT);
480                 }
481         }
482
483         delete(this);
484         return;
485 }
486
487 void W_Seeker_Fire_Tag(Weapon thiswep, entity actor, .entity weaponentity)
488 {
489         W_DecreaseAmmo(thiswep, actor, WEP_CVAR(seeker, tag_ammo), weaponentity);
490
491         W_SetupShot_ProjectileSize(actor, weaponentity, '-2 -2 -2', '2 2 2', false, 2, SND_TAG_FIRE, CH_WEAPON_A, WEP_CVAR(seeker, missile_damage) * WEP_CVAR(seeker, missile_count), thiswep.m_id | HITTYPE_BOUNCE | HITTYPE_SECONDARY);
492
493         entity missile          = new(seeker_tag);
494         missile.weaponentity_fld = weaponentity;
495         missile.owner           = missile.realowner = actor;
496         missile.bot_dodge       = true;
497         missile.bot_dodgerating = 50;
498         settouch(missile, W_Seeker_Tag_Touch);
499         setthink(missile, SUB_Remove);
500         missile.nextthink       = time + WEP_CVAR(seeker, tag_lifetime);
501         set_movetype(missile, MOVETYPE_FLY);
502         missile.solid           = SOLID_BBOX;
503
504         missile.takedamage       = DAMAGE_YES;
505         missile.event_damage     = W_Seeker_Tag_Damage;
506         SetResourceExplicit(missile, RES_HEALTH, WEP_CVAR(seeker, tag_health));
507         missile.damageforcescale = WEP_CVAR(seeker, tag_damageforcescale);
508
509         setorigin(missile, w_shotorg);
510         setsize(missile, '-2 -2 -2', '2 2 2');
511
512         missile.flags = FL_PROJECTILE;
513         IL_PUSH(g_projectiles, missile);
514         IL_PUSH(g_bot_dodge, missile);
515         //missile.missile_flags = MIF_..?;
516
517         set_movetype(missile, MOVETYPE_FLY);
518         W_SetupProjVelocity_PRE(missile, seeker, tag_);
519         missile.angles = vectoangles(missile.velocity);
520
521         CSQCProjectile(missile, true, PROJECTILE_TAG, false); // has sound
522
523         MUTATOR_CALLHOOK(EditProjectile, actor, missile);
524 }
525
526 // ============================
527 // Begin: Genereal weapon functions
528 // ============================
529
530 METHOD(Seeker, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
531 {
532     if(WEP_CVAR(seeker, type) == 1)
533     {
534         if(W_Seeker_Tagged_Info(actor, weaponentity, actor.enemy) != NULL)
535             PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR(seeker, missile_speed_max), 0, WEP_CVAR(seeker, missile_lifetime), false);
536         else
537             PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, WEP_CVAR(seeker, tag_speed), 0, WEP_CVAR(seeker, tag_lifetime), false);
538     }
539     else
540         PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR(seeker, tag_speed), 0, WEP_CVAR(seeker, tag_lifetime), false);
541 }
542 METHOD(Seeker, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
543 {
544     if(autocvar_g_balance_seeker_reload_ammo && actor.(weaponentity).clip_load < min(WEP_CVAR(seeker, missile_ammo), WEP_CVAR(seeker, tag_ammo))) { // forced reload
545         thiswep.wr_reload(thiswep, actor, weaponentity);
546     } else if(fire & 1)
547     {
548         if(WEP_CVAR(seeker, type) == 1)
549         {
550             if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(seeker, missile_refire)))
551             {
552                 W_Seeker_Attack(thiswep, actor, weaponentity);
553                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(seeker, missile_animtime), w_ready);
554             }
555         }
556         else
557         {
558             if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(seeker, tag_refire)))
559             {
560                 W_Seeker_Fire_Tag(thiswep, actor, weaponentity);
561                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(seeker, tag_animtime), w_ready);
562             }
563         }
564     }
565
566     else if(fire & 2)
567     {
568         if(WEP_CVAR(seeker, type) == 1)
569         {
570             if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(seeker, tag_refire)))
571             {
572                 W_Seeker_Fire_Tag(thiswep, actor, weaponentity);
573                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(seeker, tag_animtime), w_ready);
574             }
575         }
576         else
577         {
578             if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(seeker, flac_refire)))
579             {
580                 W_Seeker_Fire_Flac(thiswep, actor, weaponentity);
581                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(seeker, flac_animtime), w_ready);
582             }
583         }
584     }
585 }
586 METHOD(Seeker, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
587 {
588     float ammo_amount;
589     if(WEP_CVAR(seeker, type) == 1)
590     {
591         ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(seeker, missile_ammo);
592         ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR(seeker, missile_ammo);
593     }
594     else
595     {
596         ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(seeker, tag_ammo);
597         ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR(seeker, tag_ammo);
598     }
599     return ammo_amount;
600 }
601 METHOD(Seeker, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
602 {
603     float ammo_amount;
604     if(WEP_CVAR(seeker, type) == 1)
605     {
606         ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(seeker, tag_ammo);
607         ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR(seeker, tag_ammo);
608     }
609     else
610     {
611         ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(seeker, flac_ammo);
612         ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR(seeker, flac_ammo);
613     }
614     return ammo_amount;
615 }
616 METHOD(Seeker, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
617 {
618     W_Reload(actor, weaponentity, min(WEP_CVAR(seeker, missile_ammo), WEP_CVAR(seeker, tag_ammo)), SND_RELOAD);
619 }
620 METHOD(Seeker, wr_suicidemessage, Notification(entity thiswep))
621 {
622     return WEAPON_SEEKER_SUICIDE;
623 }
624 METHOD(Seeker, wr_killmessage, Notification(entity thiswep))
625 {
626     if(w_deathtype & HITTYPE_SECONDARY)
627         return WEAPON_SEEKER_MURDER_TAG;
628     else
629         return WEAPON_SEEKER_MURDER_SPRAY;
630 }
631
632 #endif
633 #ifdef CSQC
634
635 METHOD(Seeker, wr_impacteffect, void(entity thiswep, entity actor))
636 {
637     vector org2;
638     org2 = w_org + w_backoff * 6;
639     if(w_deathtype & HITTYPE_BOUNCE)
640     {
641         if(w_deathtype & HITTYPE_SECONDARY)
642         {
643             if(!w_issilent)
644                 sound(actor, CH_SHOTS, SND_TAG_IMPACT, 1, ATTEN_NORM);
645         }
646         else
647         {
648             pointparticles(EFFECT_HAGAR_EXPLODE, org2, '0 0 0', 1);
649             if(!w_issilent)
650             {
651                 if(w_random<0.15)
652                     sound(actor, CH_SHOTS, SND_TAGEXP1, 1, ATTEN_NORM);
653                 else if(w_random<0.7)
654                     sound(actor, CH_SHOTS, SND_TAGEXP2, 1, ATTEN_NORM);
655                 else
656                     sound(actor, CH_SHOTS, SND_TAGEXP3, 1, ATTEN_NORM);
657             }
658         }
659     }
660     else
661     {
662         pointparticles(EFFECT_HAGAR_EXPLODE, org2, '0 0 0', 1);
663         if(!w_issilent)
664         {
665             if(w_random<0.15)
666                 sound(actor, CH_SHOTS, SND_SEEKEREXP1, 1, ATTEN_NORM);
667             else if(w_random<0.7)
668                 sound(actor, CH_SHOTS, SND_SEEKEREXP2, 1, ATTEN_NORM);
669             else
670                 sound(actor, CH_SHOTS, SND_SEEKEREXP3, 1, ATTEN_NORM);
671         }
672     }
673 }
674
675 #endif