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