Merge branch 'master' into TimePath/unified_weapons
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / turret / mlrs.qc
1 #ifndef TURRET_MLRS_H
2 #define TURRET_MLRS_H
3
4 #include "mlrs_weapon.qc"
5
6 CLASS(MLRSTurret, Turret)
7 /* spawnflags */ ATTRIB(MLRSTurret, spawnflags, int, TUR_FLAG_SPLASH | TUR_FLAG_MEDPROJ | TUR_FLAG_PLAYER);
8 /* mins       */ ATTRIB(MLRSTurret, mins, vector, '-32 -32 0');
9 /* maxs       */ ATTRIB(MLRSTurret, maxs, vector, '32 32 64');
10 /* modelname  */ ATTRIB(MLRSTurret, mdl, string, "base.md3");
11 /* model      */ ATTRIB(MLRSTurret, model, string, strzone(strcat("models/turrets/", this.mdl)));
12 /* head_model */ ATTRIB(MLRSTurret, head_model, string, strzone(strcat("models/turrets/", "mlrs.md3")));
13 /* netname    */ ATTRIB(MLRSTurret, netname, string, "mlrs");
14 /* fullname   */ ATTRIB(MLRSTurret, turret_name, string, _("MLRS Turret"));
15     ATTRIB(MLRSTurret, m_weapon, Weapon, WEP_TUR_MLRS);
16 ENDCLASS(MLRSTurret)
17 REGISTER_TURRET(MLRS, NEW(MLRSTurret));
18
19 #endif
20
21 #ifdef IMPLEMENTATION
22
23 #include "mlrs_weapon.qc"
24
25 #ifdef SVQC
26
27 spawnfunc(turret_mlrs) { if (!turret_initialize(TUR_MLRS)) remove(self); }
28
29 METHOD(MLRSTurret, tr_think, void(MLRSTurret thistur))
30 {
31     // 0 = full, 6 = empty
32     self.tur_head.frame = bound(0, 6 - floor(0.1 + self.ammo / self.shot_dmg), 6);
33     if(self.tur_head.frame < 0)
34     {
35         LOG_TRACE("ammo:",ftos(self.ammo),"\n");
36         LOG_TRACE("shot_dmg:",ftos(self.shot_dmg),"\n");
37     }
38 }
39 METHOD(MLRSTurret, tr_setup, void(MLRSTurret this, entity it))
40 {
41     it.ammo_flags = TFL_AMMO_ROCKETS | TFL_AMMO_RECHARGE;
42     it.aim_flags = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE;
43
44     it.damage_flags |= TFL_DMG_HEADSHAKE;
45     it.shoot_flags  |= TFL_SHOOT_VOLLYALWAYS;
46     it.volly_counter = it.shot_volly;
47 }
48
49 #endif // SVQC
50 #endif