]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/turrets/turret/phaser.qc
Merge branch 'master' into TimePath/scoreboard_elo
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / turret / phaser.qc
1 #ifndef TURRET_PHASER_H
2 #define TURRET_PHASER_H
3
4 #include "phaser_weapon.qh"
5
6 CLASS(PhaserTurret, Turret)
7 /* spawnflags */ ATTRIB(PhaserTurret, spawnflags, int, TUR_FLAG_SNIPER | TUR_FLAG_HITSCAN | TUR_FLAG_PLAYER);
8 /* mins       */ ATTRIB(PhaserTurret, mins, vector, '-32 -32 0');
9 /* maxs       */ ATTRIB(PhaserTurret, maxs, vector, '32 32 64');
10 /* modelname  */ ATTRIB(PhaserTurret, mdl, string, "base.md3");
11 /* model      */ ATTRIB_STRZONE(PhaserTurret, model, string, strcat("models/turrets/", this.mdl));
12 /* head_model */ ATTRIB_STRZONE(PhaserTurret, head_model, string, strcat("models/turrets/", "phaser.md3"));
13 /* netname    */ ATTRIB(PhaserTurret, netname, string, "phaser");
14 /* fullname   */ ATTRIB(PhaserTurret, turret_name, string, _("Phaser Cannon"));
15     ATTRIB(PhaserTurret, m_weapon, Weapon, WEP_PHASER);
16 ENDCLASS(PhaserTurret)
17 REGISTER_TURRET(PHASER, NEW(PhaserTurret));
18
19 #endif
20
21 #ifdef IMPLEMENTATION
22
23 #ifdef SVQC
24
25 spawnfunc(turret_phaser) { if (!turret_initialize(this, TUR_PHASER)) remove(this); }
26
27 .int fireflag;
28
29 METHOD(PhaserTurret, tr_think, void(PhaserTurret thistur, entity it))
30 {
31     if (it.tur_head.frame != 0)
32     {
33         if (it.fireflag == 1)
34         {
35             if (it.tur_head.frame == 10)
36                 it.tur_head.frame = 1;
37             else
38                 it.tur_head.frame = it.tur_head.frame +1;
39         }
40         else if (it.fireflag == 2 )
41         {
42             it.tur_head.frame = it.tur_head.frame +1;
43             if (it.tur_head.frame == 15)
44             {
45                 it.tur_head.frame = 0;
46                 it.fireflag = 0;
47             }
48         }
49     }
50 }
51 bool turret_phaser_firecheck(entity this);
52 METHOD(PhaserTurret, tr_setup, void(PhaserTurret this, entity it))
53 {
54     it.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIEVE;
55     it.aim_flags = TFL_AIM_LEAD;
56
57     it.turret_firecheckfunc = turret_phaser_firecheck;
58 }
59 bool turret_phaser_firecheck(entity this)
60 {
61     if (this.fireflag != 0) return false;
62     return turret_firecheck(this);
63 }
64
65 #endif
66 #endif