1 #ifndef TURRET_PHASER_WEAPON_H
2 #define TURRET_PHASER_WEAPON_H
4 CLASS(PhaserTurretAttack, PortoLaunch)
5 /* flags */ ATTRIB(PhaserTurretAttack, spawnflags, int, WEP_TYPE_OTHER | WEP_FLAG_HIDDEN);
6 /* impulse */ ATTRIB(PhaserTurretAttack, impulse, int, 9);
7 /* refname */ ATTRIB(PhaserTurretAttack, netname, string, "turret_phaser");
8 /* wepname */ ATTRIB(PhaserTurretAttack, message, string, _("Phaser"));
9 ENDCLASS(PhaserTurretAttack)
10 REGISTER_WEAPON(PHASER, NEW(PhaserTurretAttack));
21 METHOD(PhaserTurretAttack, wr_think, void(entity thiswep, bool fire1, bool fire2))
24 bool isPlayer = IS_PLAYER(self);
26 if (!isPlayer || weapon_prepareattack(false, WEP_CVAR_PRI(electro, refire))) {
28 turret_initparams(self);
29 W_SetupShot_Dir(self, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
30 self.tur_shotdir_updated = w_shotdir;
31 self.tur_shotorg = w_shotorg;
34 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
36 entity beam = spawn();
37 beam.ticrate = 0.1; //autocvar_sys_ticrate;
38 setmodel(beam, MDL_TUR_PHASER_BEAM);
39 beam.effects = EF_LOWPRECISION;
40 beam.solid = SOLID_NOT;
41 beam.think = beam_think;
42 beam.cnt = time + self.shot_speed;
43 beam.shot_spread = time + 2;
44 beam.nextthink = time;
46 beam.shot_dmg = self.shot_dmg / (self.shot_speed / beam.ticrate);
47 beam.scale = self.target_range / 256;
48 beam.movetype = MOVETYPE_NONE;
49 beam.enemy = self.enemy;
50 beam.bot_dodge = true;
51 beam.bot_dodgerating = beam.shot_dmg;
52 sound (beam, CH_SHOTS_SINGLE, SND_TUR_PHASER, VOL_BASE, ATTEN_NORM);
55 beam.attack_finished_single = self.attack_finished_single;
56 self.attack_finished_single = time; // + autocvar_sys_ticrate;
58 setattachment(beam,self.tur_head, "tag_fire");
60 soundat (self, trace_endpos, CH_SHOTS, SND(NEXIMPACT), VOL_BASE, ATTEN_NORM);
62 if (self.tur_head.frame == 0)
63 self.tur_head.frame = 1;
69 if ((time > self.cnt) || (self.owner.deadflag != DEAD_NO))
71 self.owner.attack_finished_single = time + self.owner.shot_refire;
72 self.owner.fireflag = 2;
73 self.owner.tur_head.frame = 10;
74 sound (self, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
79 turret_do_updates(self.owner);
81 if (time - self.shot_spread > 0)
83 self.shot_spread = time + 2;
84 sound (self, CH_SHOTS_SINGLE, SND_TUR_PHASER, VOL_BASE, ATTEN_NORM);
88 self.nextthink = time + self.ticrate;
90 self.owner.attack_finished_single = time + frametime;
92 FireImoBeam ( self.tur_shotorg,
93 self.tur_shotorg + self.tur_shotdir_updated * self.target_range,
94 '-1 -1 -1' * self.shot_radius,
95 '1 1 1' * self.shot_radius,
101 self.scale = vlen(self.owner.tur_shotorg - trace_endpos) / 256;