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