]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/turrets/turret/plasma_dual.qc
Turrets: make plasma turrets use weapons
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / turret / plasma_dual.qc
1 #ifndef TUR_PLASMA_DUAL_H
2 #define TUR_PLASMA_DUAL_H
3
4 CLASS(DualPlasmaTurret, Turret)
5 /* spawnflags */ ATTRIB(DualPlasmaTurret, spawnflags, int, TUR_FLAG_SPLASH | TUR_FLAG_MEDPROJ | TUR_FLAG_PLAYER);
6 /* mins       */ ATTRIB(DualPlasmaTurret, mins, vector, '-32 -32 0');
7 /* maxs       */ ATTRIB(DualPlasmaTurret, maxs, vector, '32 32 64');
8 /* modelname  */ ATTRIB(DualPlasmaTurret, mdl, string, "base.md3");
9 /* model      */ ATTRIB(DualPlasmaTurret, model, string, strzone(strcat("models/turrets/", this.mdl)));
10 /* head_model */ ATTRIB(DualPlasmaTurret, head_model, string, strzone(strcat("models/turrets/", "plasmad.md3")));
11 /* netname    */ ATTRIB(DualPlasmaTurret, netname, string, "plasma_dual");
12 /* fullname   */ ATTRIB(DualPlasmaTurret, turret_name, string, _("Dual Plasma Cannon"));
13 ENDCLASS(DualPlasmaTurret)
14
15 REGISTER_TURRET(PLASMA_DUAL, NEW(DualPlasmaTurret));
16
17 #endif
18
19 #ifdef IMPLEMENTATION
20
21 #include "../../weapons/all.qh"
22
23 CLASS(PlasmaDualAttack, PortoLaunch)
24 /* flags     */ ATTRIB(PlasmaDualAttack, spawnflags, int, WEP_TYPE_OTHER);
25 /* impulse   */ ATTRIB(PlasmaDualAttack, impulse, int, 5);
26 /* refname   */ ATTRIB(PlasmaDualAttack, netname, string, "plasmadual");
27 /* wepname   */ ATTRIB(PlasmaDualAttack, message, string, _("Dual plasma"));
28 ENDCLASS(PlasmaDualAttack)
29 REGISTER_WEAPON(PLASMA_DUAL, NEW(PlasmaDualAttack));
30
31 #ifdef SVQC
32
33 void turret_initparams(entity tur);
34 METHOD(PlasmaDualAttack, wr_think, bool(entity thiswep, bool fire1, bool fire2)) {
35         SELFPARAM();
36         bool isPlayer = IS_PLAYER(self);
37         if (fire1)
38         if (!isPlayer || weapon_prepareattack(false, WEP_CVAR_PRI(electro, refire))) {
39                 if (isPlayer) {
40             turret_initparams(self);
41             W_SetupShot_Dir(self, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
42             self.tur_shotdir_updated = w_shotdir;
43             self.tur_shotorg = w_shotorg;
44             self.tur_head = self;
45             weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
46         }
47         entity missile = turret_projectile(SND(HAGAR_FIRE), 1, 0, DEATH_TURRET_PLASMA, PROJECTILE_ELECTRO_BEAM, true, true);
48         missile.missile_flags = MIF_SPLASH;
49         Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
50         }
51         return true;
52 }
53
54 void spawnfunc_turret_plasma_dual() { SELFPARAM(); if(!turret_initialize(TUR_PLASMA_DUAL.m_id)) remove(self); }
55
56         METHOD(DualPlasmaTurret, tr_attack, void(DualPlasmaTurret thistur))
57         {
58             if (g_instagib) {
59                 FireRailgunBullet (self.tur_shotorg, self.tur_shotorg + self.tur_shotdir_updated * MAX_SHOT_DISTANCE, 10000000000,
60                                    800, 0, 0, 0, 0, DEATH_TURRET_PLASMA);
61
62
63                 Send_Effect(EFFECT_VORTEX_MUZZLEFLASH, self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
64
65                 // teamcolor / hit beam effect
66                 vector v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
67                 WarpZone_TrailParticles(world, particleeffectnum(EFFECT_VAPORIZER(self.team)), self.tur_shotorg, v);
68             } else {
69                 Weapon wep = WEP_PLASMA_DUAL;
70                 wep.wr_think(wep, true, false);
71             }
72             self.tur_head.frame += 1;
73         }
74         METHOD(DualPlasmaTurret, tr_think, bool(DualPlasmaTurret thistur))
75         {
76             if ((self.tur_head.frame != 0) && (self.tur_head.frame != 3))
77                 self.tur_head.frame = self.tur_head.frame + 1;
78
79             if (self.tur_head.frame > 6)
80                 self.tur_head.frame = 0;
81
82             return true;
83         }
84         METHOD(DualPlasmaTurret, tr_death, bool(DualPlasmaTurret thistur))
85         {
86             return true;
87         }
88         METHOD(DualPlasmaTurret, tr_setup, bool(DualPlasmaTurret thistur))
89         {
90             self.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIEVE;
91             self.damage_flags |= TFL_DMG_HEADSHAKE;
92             self.firecheck_flags |= TFL_FIRECHECK_AFF;
93             self.aim_flags = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE | TFL_AIM_SPLASH;
94
95             turret_do_updates(self);
96
97             return true;
98         }
99         METHOD(DualPlasmaTurret, tr_precache, bool(DualPlasmaTurret thistur))
100         {
101             return true;
102         }
103
104 #endif // SVQC
105 #ifdef CSQC
106         METHOD(DualPlasmaTurret, tr_setup, bool(DualPlasmaTurret thistur))
107         {
108             return true;
109         }
110         METHOD(DualPlasmaTurret, tr_precache, bool(DualPlasmaTurret thistur))
111         {
112             return true;
113         }
114
115 #endif // CSQC
116 #endif // REGISTER_TURRET