]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/turrets/turret/mlrs.qc
Turrets: make plasma turrets use weapons
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / turret / mlrs.qc
1 #ifndef TUR_MLRS_H
2 #define TUR_MLRS_H
3
4 CLASS(MLRSTurret, Turret)
5 /* spawnflags */ ATTRIB(MLRSTurret, spawnflags, int, TUR_FLAG_SPLASH | TUR_FLAG_MEDPROJ | TUR_FLAG_PLAYER);
6 /* mins       */ ATTRIB(MLRSTurret, mins, vector, '-32 -32 0');
7 /* maxs       */ ATTRIB(MLRSTurret, maxs, vector, '32 32 64');
8 /* modelname  */ ATTRIB(MLRSTurret, mdl, string, "base.md3");
9 /* model      */ ATTRIB(MLRSTurret, model, string, strzone(strcat("models/turrets/", this.mdl)));
10 /* head_model */ ATTRIB(MLRSTurret, head_model, string, strzone(strcat("models/turrets/", "mlrs.md3")));
11 /* netname    */ ATTRIB(MLRSTurret, netname, string, "mlrs");
12 /* fullname   */ ATTRIB(MLRSTurret, turret_name, string, _("MLRS Turret"));
13 ENDCLASS(MLRSTurret)
14
15 REGISTER_TURRET(MLRS, NEW(MLRSTurret));
16
17 #endif
18
19 #ifdef IMPLEMENTATION
20 #ifdef SVQC
21 void spawnfunc_turret_mlrs() { SELFPARAM(); if(!turret_initialize(TUR_MLRS.m_id)) remove(self); }
22
23         METHOD(MLRSTurret, tr_attack, void(MLRSTurret thistur))
24         {
25             entity missile;
26
27             turret_tag_fire_update();
28             missile = turret_projectile(SND(ROCKET_FIRE), 6, 10, DEATH_TURRET_MLRS, PROJECTILE_ROCKET, TRUE, TRUE);
29             missile.nextthink = time + max(self.tur_impacttime,(self.shot_radius * 2) / self.shot_speed);
30             missile.missile_flags = MIF_SPLASH;
31             te_explosion (missile.origin);
32         }
33         METHOD(MLRSTurret, tr_think, bool(MLRSTurret thistur))
34         {
35             // 0 = full, 6 = empty
36             self.tur_head.frame = bound(0, 6 - floor(0.1 + self.ammo / self.shot_dmg), 6);
37             if(self.tur_head.frame < 0)
38             {
39                 LOG_TRACE("ammo:",ftos(self.ammo),"\n");
40                 LOG_TRACE("shot_dmg:",ftos(self.shot_dmg),"\n");
41             }
42
43             return true;
44         }
45         METHOD(MLRSTurret, tr_death, bool(MLRSTurret thistur))
46         {
47             return true;
48         }
49         METHOD(MLRSTurret, tr_setup, bool(MLRSTurret thistur))
50         {
51             self.ammo_flags = TFL_AMMO_ROCKETS | TFL_AMMO_RECHARGE;
52             self.aim_flags = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE;
53
54             self.damage_flags |= TFL_DMG_HEADSHAKE;
55             self.shoot_flags  |= TFL_SHOOT_VOLLYALWAYS;
56             self.volly_counter = self.shot_volly;
57
58             return true;
59         }
60         METHOD(MLRSTurret, tr_precache, bool(MLRSTurret thistur))
61         {
62             return true;
63         }
64
65 #endif // SVQC
66 #ifdef CSQC
67         METHOD(MLRSTurret, tr_setup, bool(MLRSTurret thistur))
68         {
69             return true;
70         }
71         METHOD(MLRSTurret, tr_precache, bool(MLRSTurret thistur))
72         {
73             return true;
74         }
75
76 #endif // CSQC
77 #endif // REGISTER_TURRET