83c205026315af710dd41af4a89b3e1504a1d5c4
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / turret / plasma_weapon.qc
1 #ifndef TURRET_PLASMA_WEAPON_H
2 #define TURRET_PLASMA_WEAPON_H
3
4 CLASS(PlasmaAttack, PortoLaunch)
5 /* flags     */ ATTRIB(PlasmaAttack, spawnflags, int, WEP_TYPE_OTHER | WEP_FLAG_HIDDEN | WEP_FLAG_MUTATORBLOCKED);
6 /* impulse   */ ATTRIB(PlasmaAttack, impulse, int, 5);
7 /* refname   */ ATTRIB(PlasmaAttack, netname, string, "turret_plasma");
8 /* wepname   */ ATTRIB(PlasmaAttack, message, string, _("Plasma"));
9 ENDCLASS(PlasmaAttack)
10 REGISTER_WEAPON(PLASMA, NEW(PlasmaAttack));
11
12 #endif
13
14 #ifdef IMPLEMENTATION
15
16 #ifdef SVQC
17
18 METHOD(PlasmaAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) {
19         bool isPlayer = IS_PLAYER(actor);
20         if (fire1)
21         if (!isPlayer || weapon_prepareattack(actor, false, WEP_CVAR_PRI(electro, refire))) {
22                 if (isPlayer) {
23             turret_initparams(actor);
24             W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
25             actor.tur_shotdir_updated = w_shotdir;
26             actor.tur_shotorg = w_shotorg;
27             actor.tur_head = actor;
28             weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
29         }
30         entity missile = turret_projectile(SND(HAGAR_FIRE), 1, 0, DEATH_TURRET_PLASMA, PROJECTILE_ELECTRO_BEAM, true, true);
31         missile.missile_flags = MIF_SPLASH;
32         Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, actor.tur_shotorg, actor.tur_shotdir_updated * 1000, 1);
33         }
34 }
35
36 #endif
37
38 #endif