64b73577156504897d57ec6fb7e8acd9ce25a605
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / turret / ewheel_weapon.qc
1 #ifndef TURRET_EWHEEL_WEAPON_H
2 #define TURRET_EWHEEL_WEAPON_H
3
4 CLASS(EWheelAttack, PortoLaunch)
5 /* flags     */ ATTRIB(EWheelAttack, spawnflags, int, WEP_TYPE_OTHER);
6 /* impulse   */ ATTRIB(EWheelAttack, impulse, int, 5);
7 /* refname   */ ATTRIB(EWheelAttack, netname, string, "turret_ewheel");
8 /* wepname   */ ATTRIB(EWheelAttack, message, string, _("eWheel"));
9 ENDCLASS(EWheelAttack)
10 REGISTER_WEAPON(EWHEEL, NEW(EWheelAttack));
11
12 #endif
13
14 #ifdef IMPLEMENTATION
15
16 #ifdef SVQC
17
18 void turret_initparams(entity);
19 METHOD(EWheelAttack, wr_think, bool(entity thiswep, bool fire1, bool fire2)) {
20     SELFPARAM();
21     bool isPlayer = IS_PLAYER(self);
22     if (fire1)
23     if (!isPlayer || weapon_prepareattack(false, WEP_CVAR_PRI(electro, refire))) {
24         if (isPlayer) {
25             turret_initparams(self);
26             W_SetupShot_Dir(self, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
27             self.tur_shotdir_updated = w_shotdir;
28             self.tur_shotorg = w_shotorg;
29             self.tur_head = self;
30             weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
31         }
32
33         turret_do_updates(self);
34
35         entity missile = turret_projectile(SND(LASERGUN_FIRE), 1, 0, DEATH_TURRET_EWHEEL, PROJECTILE_BLASTER, true, true);
36         missile.missile_flags = MIF_SPLASH;
37
38         Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
39
40         if (!isPlayer) {
41             self.tur_head.frame += 2;
42
43             if (self.tur_head.frame > 3)
44                 self.tur_head.frame = 0;
45         }
46     }
47     return true;
48 }
49
50 #endif
51
52 #endif