Hook: merge offhand and weapon behaviour
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / turret / mlrs_weapon.qc
1 #ifndef TURRET_MLRS_WEAPON_H
2 #define TURRET_MLRS_WEAPON_H
3
4 CLASS(MLRSTurretAttack, PortoLaunch)
5 /* flags     */ ATTRIB(MLRSTurretAttack, spawnflags, int, WEP_TYPE_OTHER | WEP_FLAG_HIDDEN | WEP_FLAG_MUTATORBLOCKED);
6 /* impulse   */ ATTRIB(MLRSTurretAttack, impulse, int, 9);
7 /* refname   */ ATTRIB(MLRSTurretAttack, netname, string, "turret_mlrs");
8 /* wepname   */ ATTRIB(MLRSTurretAttack, message, string, _("MLRS"));
9 ENDCLASS(MLRSTurretAttack)
10 REGISTER_WEAPON(TUR_MLRS, NEW(MLRSTurretAttack));
11
12 #endif
13
14 #ifdef IMPLEMENTATION
15
16 #ifdef SVQC
17
18 METHOD(MLRSTurretAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2))
19 {
20     bool isPlayer = IS_PLAYER(actor);
21     if (fire1)
22     if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR(machinegun, sustained_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             actor.shot_radius = 500;
30             weapon_thinkf(actor, WFRAME_FIRE1, 0, w_ready);
31         }
32         turret_tag_fire_update();
33         entity missile = turret_projectile(SND(ROCKET_FIRE), 6, 10, DEATH_TURRET_MLRS, PROJECTILE_ROCKET, TRUE, TRUE);
34         missile.nextthink = time + max(actor.tur_impacttime,(actor.shot_radius * 2) / actor.shot_speed);
35         missile.missile_flags = MIF_SPLASH;
36         te_explosion (missile.origin);
37     }
38 }
39
40 #endif
41
42 #endif