Weapons: hide from menu
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / turret / machinegun_weapon.qc
1 #ifndef TURRET_MACHINEGUN_WEAPON_H
2 #define TURRET_MACHINEGUN_WEAPON_H
3
4 CLASS(MachineGunTurretAttack, PortoLaunch)
5 /* flags     */ ATTRIB(MachineGunTurretAttack, spawnflags, int, WEP_TYPE_OTHER | WEP_FLAG_HIDDEN);
6 /* impulse   */ ATTRIB(MachineGunTurretAttack, impulse, int, 9);
7 /* refname   */ ATTRIB(MachineGunTurretAttack, netname, string, "turret_machinegun");
8 /* wepname   */ ATTRIB(MachineGunTurretAttack, message, string, _("Machinegun"));
9 ENDCLASS(MachineGunTurretAttack)
10 REGISTER_WEAPON(TUR_MACHINEGUN, NEW(MachineGunTurretAttack));
11
12 #endif
13
14 #ifdef IMPLEMENTATION
15
16 #ifdef SVQC
17
18 void W_MachineGun_MuzzleFlash();
19
20 METHOD(MachineGunTurretAttack, wr_think, bool(entity thiswep, bool fire1, bool fire2))
21 {
22     SELFPARAM();
23     bool isPlayer = IS_PLAYER(self);
24     if (fire1)
25     if (!isPlayer || weapon_prepareattack(false, WEP_CVAR(machinegun, sustained_refire))) {
26         if (isPlayer) {
27             turret_initparams(self);
28             W_SetupShot_Dir(self, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
29             self.tur_shotdir_updated = w_shotdir;
30             self.tur_shotorg = w_shotorg;
31             self.tur_head = self;
32             weapon_thinkf(WFRAME_FIRE1, 0, w_ready);
33         }
34         fireBullet (self.tur_shotorg, self.tur_shotdir_updated, self.shot_spread, 0, self.shot_dmg, self.shot_force, DEATH_TURRET_MACHINEGUN, 0);
35         W_MachineGun_MuzzleFlash();
36         setattachment(self.muzzle_flash, self.tur_head, "tag_fire");
37     }
38     return true;
39 }
40
41 #endif
42
43 #endif