Weapons: hide from menu
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / turret / flac_weapon.qc
1 #ifndef TURRET_FLAC_WEAPON_H
2 #define TURRET_FLAC_WEAPON_H
3
4 CLASS(FlacAttack, PortoLaunch)
5 /* flags     */ ATTRIB(FlacAttack, spawnflags, int, WEP_TYPE_OTHER | WEP_FLAG_HIDDEN);
6 /* impulse   */ ATTRIB(FlacAttack, impulse, int, 5);
7 /* refname   */ ATTRIB(FlacAttack, netname, string, "turret_flac");
8 /* wepname   */ ATTRIB(FlacAttack, message, string, _("FLAC"));
9 ENDCLASS(FlacAttack)
10 REGISTER_WEAPON(FLAC, NEW(FlacAttack));
11
12 #endif
13
14 #ifdef IMPLEMENTATION
15
16 #ifdef SVQC
17
18 void turret_flac_projectile_think_explode();
19 METHOD(FlacAttack, wr_think, bool(entity thiswep, bool fire1, bool fire2)) {
20     SELFPARAM();
21     bool isPlayer = IS_PLAYER(self);
22     if (fire1)
23     if (!isPlayer || weapon_prepareattack(false, WEP_CVAR_PRI(electro, refire))) {
24         if (isPlayer) {
25             turret_initparams(self);
26             W_SetupShot_Dir(self, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
27             self.tur_shotdir_updated = w_shotdir;
28             self.tur_shotorg = w_shotorg;
29             self.tur_head = self;
30             self.tur_impacttime = 10;
31             weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
32         }
33
34         turret_tag_fire_update();
35
36         entity proj = turret_projectile(SND(HAGAR_FIRE), 5, 0, DEATH_TURRET_FLAC, PROJECTILE_HAGAR, true, true);
37         proj.missile_flags = MIF_SPLASH | MIF_PROXY;
38         proj.think        = turret_flac_projectile_think_explode;
39         proj.nextthink  = time + self.tur_impacttime + (random() * 0.01 - random() * 0.01);
40         Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
41
42         if (!isPlayer) {
43             self.tur_head.frame = self.tur_head.frame + 1;
44             if (self.tur_head.frame >= 4)
45                 self.tur_head.frame = 0;
46         }
47     }
48     return true;
49 }
50
51 void turret_flac_projectile_think_explode()
52 {
53     SELFPARAM();
54     if (self.enemy != world)
55     if (vlen(self.origin - self.enemy.origin) < self.owner.shot_radius * 3)
56         setorigin(self,self.enemy.origin + randomvec() * self.owner.shot_radius);
57
58 #ifdef TURRET_DEBUG
59     float d = RadiusDamage (self, self.owner, self.owner.shot_dmg, self.owner.shot_dmg, self.owner.shot_radius, self, world, self.owner.shot_force, self.totalfrags, world);
60     self.owner.tur_dbg_dmg_t_h = self.owner.tur_dbg_dmg_t_h + d;
61     self.owner.tur_dbg_dmg_t_f = self.owner.tur_dbg_dmg_t_f + self.owner.shot_dmg;
62 #else
63     RadiusDamage (self, self.realowner, self.owner.shot_dmg, self.owner.shot_dmg, self.owner.shot_radius, self, world, self.owner.shot_force, self.totalfrags, world);
64 #endif
65     remove(self);
66 }
67
68 #endif
69
70 #endif