Give W_SetupShot a deathtype parameter, fixes some ugly hacks
[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(this.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                 this.health = this.health - (damage * 0.25);
135         else
136                 this.health = this.health - damage;
137
138         if(this.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) ? WEP_SEEKER.m_id | HITTYPE_SECONDARY : WEP_SEEKER.m_id));
173         w_shotorg += f_diff;
174         Send_Effect(EFFECT_SEEKER_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
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         missile.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 = WEP_SEEKER.m_id | HITTYPE_SECONDARY;
201         else
202                 missile.projectiledeathtype = WEP_SEEKER.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), WEP_SEEKER.m_id | HITTYPE_SECONDARY);
270         w_shotorg += f_diff;
271
272         Send_Effect(EFFECT_HAGAR_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
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 = WEP_SEEKER.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(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(WEP_SEEKER, 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         float c;
346         entity oldenemy;
347         this.cnt = this.cnt - 1;
348
349         Weapon thiswep = WEP_SEEKER;
350         .entity weaponentity = this.weaponentity_fld;
351         if((!(this.realowner.items & IT_UNLIMITED_AMMO) && GetResourceAmount(this.realowner, thiswep.ammo_type) < WEP_CVAR(seeker, missile_ammo)) || (this.cnt <= -1) || (IS_DEAD(this.realowner)) || (this.realowner.(weaponentity).m_switchweapon != WEP_SEEKER))
352         {
353                 delete(this);
354                 return;
355         }
356
357         this.nextthink = time + WEP_CVAR(seeker, missile_delay) * W_WeaponRateFactor(this.realowner);
358
359         entity own = this.realowner;
360
361         oldenemy = own.enemy;
362         own.enemy = this.enemy;
363
364         c = own.cnt % 4;
365         switch(c)
366         {
367                 case 0:
368                         W_Seeker_Fire_Missile(WEP_SEEKER, own, weaponentity, '-1.25 -3.75 0', own.enemy); // TODO
369                         break;
370                 case 1:
371                         W_Seeker_Fire_Missile(WEP_SEEKER, own, weaponentity, '+1.25 -3.75 0', own.enemy); // TODO
372                         break;
373                 case 2:
374                         W_Seeker_Fire_Missile(WEP_SEEKER, own, weaponentity, '-1.25 +3.75 0', own.enemy); // TODO
375                         break;
376                 case 3:
377                 default:
378                         W_Seeker_Fire_Missile(WEP_SEEKER, own, weaponentity, '+1.25 +3.75 0', own.enemy); // TODO
379                         break;
380         }
381
382         own.enemy = oldenemy;
383 }
384
385 void W_Seeker_Tracker_Think(entity this)
386 {
387         .entity weaponentity = this.weaponentity_fld;
388         // commit suicide if: You die OR target dies OR you switch away from the seeker OR commit suicide if lifetime is up
389         if((IS_DEAD(this.realowner)) || (IS_DEAD(this.tag_target)) || (this.realowner.(weaponentity).m_switchweapon != WEP_SEEKER)
390         || (time > this.tag_time + WEP_CVAR(seeker, tag_tracker_lifetime)))
391         {
392                 if(this)
393                 {
394                         WaypointSprite_Kill(this.tag_target.wps_tag_tracker);
395                         delete(this);
396                 }
397                 return;
398         }
399
400         // Update the think method information
401         this.nextthink = time;
402 }
403
404 // ============================
405 // Begin: Tag projectile
406 // ============================
407 void W_Seeker_Tag_Explode(entity this)
408 {
409         //if(other==this.realowner)
410         //    return;
411         Damage_DamageInfo(this.origin, 0, 0, 0, this.velocity, WEP_SEEKER.m_id | HITTYPE_BOUNCE, 0, this);
412
413         delete(this);
414 }
415
416 void W_Seeker_Tag_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
417 {
418         if(this.health <= 0)
419                 return;
420         this.health = this.health - damage;
421         if(this.health <= 0)
422                 W_Seeker_Tag_Explode(this);
423 }
424
425 void W_Seeker_Tag_Touch(entity this, entity toucher)
426 {
427         vector dir;
428         vector org2;
429         entity e;
430
431         PROJECTILE_TOUCH(this, toucher);
432
433         dir     = normalize(this.realowner.origin - this.origin);
434         org2    = findbetterlocation(this.origin, 8);
435
436         te_knightspike(org2);
437
438         this.event_damage = func_null;
439         Damage_DamageInfo(this.origin, 0, 0, 0, this.velocity, WEP_SEEKER.m_id | HITTYPE_BOUNCE | HITTYPE_SECONDARY, toucher.species, this);
440
441         if(toucher.takedamage == DAMAGE_AIM && !IS_DEAD(toucher))
442         {
443                 // check to see if this person is already tagged by me
444                 .entity weaponentity = this.weaponentity_fld;
445                 entity tag = W_Seeker_Tagged_Info(this.realowner, weaponentity, toucher);
446
447                 if(tag != NULL)
448                 {
449                         if(toucher.wps_tag_tracker && (WEP_CVAR(seeker, type) == 1)) // don't attach another waypointsprite without killing the old one first
450                                 WaypointSprite_Kill(toucher.wps_tag_tracker);
451
452                         tag.tag_time = time;
453                 }
454                 else
455                 {
456                         //sprint(this.realowner, strcat("You just tagged ^2", toucher.netname, "^7 with a tracking device!\n"));
457                         e             = new(tag_tracker);
458                         e.weaponentity_fld = this.weaponentity_fld;
459                         e.cnt         = WEP_CVAR(seeker, missile_count);
460                         e.owner       = this.owner;
461                         e.realowner   = this.realowner;
462                         IL_PUSH(g_seeker_trackers, e);
463
464                         if(WEP_CVAR(seeker, type) == 1)
465                         {
466                                 e.tag_target  = toucher;
467                                 e.tag_time    = time;
468                                 setthink(e, W_Seeker_Tracker_Think);
469                         }
470                         else
471                         {
472                                 e.enemy     = toucher;
473                                 setthink(e, W_Seeker_Vollycontroller_Think);
474                         }
475
476                         e.nextthink   = time;
477                 }
478
479                 if(WEP_CVAR(seeker, type) == 1)
480                 {
481                         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);
482                         WaypointSprite_UpdateRule(toucher.wps_tag_tracker, 0, SPRITERULE_DEFAULT);
483                 }
484         }
485
486         delete(this);
487         return;
488 }
489
490 void W_Seeker_Fire_Tag(Weapon thiswep, entity actor, .entity weaponentity)
491 {
492         W_DecreaseAmmo(thiswep, actor, WEP_CVAR(seeker, tag_ammo), weaponentity);
493
494         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), WEP_SEEKER.m_id | HITTYPE_BOUNCE | HITTYPE_SECONDARY);
495
496         entity missile          = new(seeker_tag);
497         missile.weaponentity_fld = weaponentity;
498         missile.owner           = missile.realowner = actor;
499         missile.bot_dodge       = true;
500         missile.bot_dodgerating = 50;
501         settouch(missile, W_Seeker_Tag_Touch);
502         setthink(missile, SUB_Remove);
503         missile.nextthink       = time + WEP_CVAR(seeker, tag_lifetime);
504         set_movetype(missile, MOVETYPE_FLY);
505         missile.solid           = SOLID_BBOX;
506
507         missile.takedamage       = DAMAGE_YES;
508         missile.event_damage     = W_Seeker_Tag_Damage;
509         missile.health           = WEP_CVAR(seeker, tag_health);
510         missile.damageforcescale = WEP_CVAR(seeker, tag_damageforcescale);
511
512         setorigin(missile, w_shotorg);
513         setsize(missile, '-2 -2 -2', '2 2 2');
514
515         missile.flags = FL_PROJECTILE;
516         IL_PUSH(g_projectiles, missile);
517         IL_PUSH(g_bot_dodge, missile);
518         //missile.missile_flags = MIF_..?;
519
520         set_movetype(missile, MOVETYPE_FLY);
521         W_SetupProjVelocity_PRE(missile, seeker, tag_);
522         missile.angles = vectoangles(missile.velocity);
523
524         CSQCProjectile(missile, true, PROJECTILE_TAG, false); // has sound
525
526         MUTATOR_CALLHOOK(EditProjectile, actor, missile);
527 }
528
529 // ============================
530 // Begin: Genereal weapon functions
531 // ============================
532
533 METHOD(Seeker, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
534 {
535     if(WEP_CVAR(seeker, type) == 1)
536         if(W_Seeker_Tagged_Info(actor, weaponentity, actor.enemy) != NULL)
537             PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR(seeker, missile_speed_max), 0, WEP_CVAR(seeker, missile_lifetime), false);
538         else
539             PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, WEP_CVAR(seeker, tag_speed), 0, WEP_CVAR(seeker, tag_lifetime), false);
540     else
541         PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR(seeker, tag_speed), 0, WEP_CVAR(seeker, tag_lifetime), false);
542 }
543 METHOD(Seeker, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
544 {
545     if(autocvar_g_balance_seeker_reload_ammo && actor.(weaponentity).clip_load < min(WEP_CVAR(seeker, missile_ammo), WEP_CVAR(seeker, tag_ammo))) { // forced reload
546         thiswep.wr_reload(thiswep, actor, weaponentity);
547     } else if(fire & 1)
548     {
549         if(WEP_CVAR(seeker, type) == 1)
550         {
551             if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(seeker, missile_refire)))
552             {
553                 W_Seeker_Attack(actor, weaponentity);
554                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(seeker, missile_animtime), w_ready);
555             }
556         }
557         else
558         {
559             if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(seeker, tag_refire)))
560             {
561                 W_Seeker_Fire_Tag(thiswep, actor, weaponentity);
562                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(seeker, tag_animtime), w_ready);
563             }
564         }
565     }
566
567     else if(fire & 2)
568     {
569         if(WEP_CVAR(seeker, type) == 1)
570         {
571             if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(seeker, tag_refire)))
572             {
573                 W_Seeker_Fire_Tag(thiswep, actor, weaponentity);
574                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(seeker, tag_animtime), w_ready);
575             }
576         }
577         else
578         {
579             if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(seeker, flac_refire)))
580             {
581                 W_Seeker_Fire_Flac(thiswep, actor, weaponentity);
582                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(seeker, flac_animtime), w_ready);
583             }
584         }
585     }
586 }
587 METHOD(Seeker, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
588 {
589     float ammo_amount;
590     if(WEP_CVAR(seeker, type) == 1)
591     {
592         ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(seeker, missile_ammo);
593         ammo_amount += actor.(weaponentity).(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, missile_ammo);
594     }
595     else
596     {
597         ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(seeker, tag_ammo);
598         ammo_amount += actor.(weaponentity).(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, tag_ammo);
599     }
600     return ammo_amount;
601 }
602 METHOD(Seeker, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
603 {
604     float ammo_amount;
605     if(WEP_CVAR(seeker, type) == 1)
606     {
607         ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(seeker, tag_ammo);
608         ammo_amount += actor.(weaponentity).(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, tag_ammo);
609     }
610     else
611     {
612         ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(seeker, flac_ammo);
613         ammo_amount += actor.(weaponentity).(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, flac_ammo);
614     }
615     return ammo_amount;
616 }
617 METHOD(Seeker, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
618 {
619     W_Reload(actor, weaponentity, min(WEP_CVAR(seeker, missile_ammo), WEP_CVAR(seeker, tag_ammo)), SND_RELOAD);
620 }
621 METHOD(Seeker, wr_suicidemessage, Notification(entity thiswep))
622 {
623     return WEAPON_SEEKER_SUICIDE;
624 }
625 METHOD(Seeker, wr_killmessage, Notification(entity thiswep))
626 {
627     if(w_deathtype & HITTYPE_SECONDARY)
628         return WEAPON_SEEKER_MURDER_TAG;
629     else
630         return WEAPON_SEEKER_MURDER_SPRAY;
631 }
632
633 #endif
634 #ifdef CSQC
635
636 METHOD(Seeker, wr_impacteffect, void(entity thiswep, entity actor))
637 {
638     vector org2;
639     org2 = w_org + w_backoff * 6;
640     if(w_deathtype & HITTYPE_BOUNCE)
641     {
642         if(w_deathtype & HITTYPE_SECONDARY)
643         {
644             if(!w_issilent)
645                 sound(actor, CH_SHOTS, SND_TAG_IMPACT, 1, ATTEN_NORM);
646         }
647         else
648         {
649             pointparticles(EFFECT_HAGAR_EXPLODE, org2, '0 0 0', 1);
650             if(!w_issilent)
651             {
652                 if(w_random<0.15)
653                     sound(actor, CH_SHOTS, SND_TAGEXP1, 1, ATTEN_NORM);
654                 else if(w_random<0.7)
655                     sound(actor, CH_SHOTS, SND_TAGEXP2, 1, ATTEN_NORM);
656                 else
657                     sound(actor, CH_SHOTS, SND_TAGEXP3, 1, ATTEN_NORM);
658             }
659         }
660     }
661     else
662     {
663         pointparticles(EFFECT_HAGAR_EXPLODE, org2, '0 0 0', 1);
664         if(!w_issilent)
665         {
666             if(w_random<0.15)
667                 sound(actor, CH_SHOTS, SND_SEEKEREXP1, 1, ATTEN_NORM);
668             else if(w_random<0.7)
669                 sound(actor, CH_SHOTS, SND_SEEKEREXP2, 1, ATTEN_NORM);
670             else
671                 sound(actor, CH_SHOTS, SND_SEEKEREXP3, 1, ATTEN_NORM);
672         }
673     }
674 }
675
676 #endif