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