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