Merge branch 'master' into Mario/turrets
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / unit / machinegun.qc
1 #ifdef REGISTER_TURRET
2 REGISTER_TURRET(
3 /* TUR_##id   */ MACHINEGUN,
4 /* function   */ t_machinegun,
5 /* spawnflags */ TUR_FLAG_PLAYER,
6 /* mins,maxs  */ '-32 -32 0', '32 32 64',
7 /* model          */ "base.md3",
8 /* head_model */ "machinegun.md3",
9 /* netname        */ "machinegun",
10 /* fullname   */ _("Machinegun Turret")
11 );
12 #else
13 #ifdef SVQC
14 void spawnfunc_turret_machinegun() { if(!turret_initialize(TUR_MACHINEGUN)) remove(self); }
15
16 float t_machinegun(float req)
17 {
18         switch(req)
19         {
20                 case TR_ATTACK:
21                 {
22                         fireBullet (self.tur_shotorg, self.tur_shotdir_updated, self.shot_spread, 0, self.shot_dmg, self.shot_force, DEATH_TURRET_MACHINEGUN, 0);
23
24                         W_MachineGun_MuzzleFlash();
25                         setattachment(self.muzzle_flash, self.tur_head, "tag_fire");
26
27                         return true;
28                 }
29                 case TR_THINK:
30                 {
31                         return true;
32                 }
33                 case TR_DEATH:
34                 {
35                         return true;
36                 }
37                 case TR_SETUP:
38                 {
39                         self.damage_flags |= TFL_DMG_HEADSHAKE;
40                         self.target_select_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK;
41                         self.ammo_flags = TFL_AMMO_BULLETS | TFL_AMMO_RECHARGE | TFL_AMMO_RECIEVE;
42                         self.aim_flags = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE;
43                         self.turret_flags |= TUR_FLAG_HITSCAN;
44
45                         return true;
46                 }
47                 case TR_PRECACHE:
48                 {
49                         precache_model ("models/turrets/base.md3");
50                         precache_model ("models/turrets/machinegun.md3");
51                         precache_sound ("weapons/uzi_fire.wav");
52                         return true;
53                 }
54         }
55
56         return true;
57 }
58
59 #endif // SVQC
60 #ifdef CSQC
61 float t_machinegun(float req)
62 {
63         switch(req)
64         {
65                 case TR_SETUP:
66                 {
67                         return true;
68                 }
69                 case TR_PRECACHE:
70                 {
71                         return true;
72                 }
73         }
74
75         return true;
76 }
77
78 #endif // CSQC
79 #endif // REGISTER_TURRET