]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/turrets/turret/ewheel_weapon.qc
Merge branch 'master' into TimePath/csqc_viewmodels
[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 | WEP_FLAG_HIDDEN | WEP_FLAG_MUTATORBLOCKED);
6 /* impulse   */ ATTRIB(EWheelAttack, impulse, int, 5);
7 /* refname   */ ATTRIB(EWheelAttack, netname, string, "turret_ewheel");
8 /* wepname   */ ATTRIB(EWheelAttack, m_name, 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, void(entity thiswep, entity actor, .entity weaponentity, int fire)) {
20     bool isPlayer = IS_PLAYER(actor);
21     if (fire & 1)
22     if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire))) {
23         if (isPlayer) {
24             turret_initparams(actor);
25             W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
26             actor.tur_shotdir_updated = w_shotdir;
27             actor.tur_shotorg = w_shotorg;
28             actor.tur_head = actor;
29             weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
30         }
31
32         turret_do_updates(actor);
33
34         entity missile = turret_projectile(SND(LASERGUN_FIRE), 1, 0, DEATH_TURRET_EWHEEL.m_id, PROJECTILE_BLASTER, true, true);
35         missile.missile_flags = MIF_SPLASH;
36
37         Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, actor.tur_shotorg, actor.tur_shotdir_updated * 1000, 1);
38
39         if (!isPlayer) {
40             actor.tur_head.frame += 2;
41
42             if (actor.tur_head.frame > 3)
43                 actor.tur_head.frame = 0;
44         }
45     }
46 }
47
48 #endif
49
50 #endif