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 | WEP_FLAG_MUTATORBLOCKED);
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, entity actor, bool fire1, bool fire2))
23 bool isPlayer = IS_PLAYER(actor);
25 if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(electro, refire))) {
27 turret_initparams(actor);
28 W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
29 actor.tur_shotdir_updated = w_shotdir;
30 actor.tur_shotorg = w_shotorg;
31 actor.tur_head = actor;
33 weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
35 entity beam = spawn();
36 beam.ticrate = 0.1; //autocvar_sys_ticrate;
37 setmodel(beam, MDL_TUR_PHASER_BEAM);
38 beam.effects = EF_LOWPRECISION;
39 beam.solid = SOLID_NOT;
40 beam.think = beam_think;
41 beam.cnt = time + actor.shot_speed;
42 beam.shot_spread = time + 2;
43 beam.nextthink = time;
45 beam.shot_dmg = actor.shot_dmg / (actor.shot_speed / beam.ticrate);
46 beam.scale = actor.target_range / 256;
47 beam.movetype = MOVETYPE_NONE;
48 beam.enemy = actor.enemy;
49 beam.bot_dodge = true;
50 beam.bot_dodgerating = beam.shot_dmg;
51 sound (beam, CH_SHOTS_SINGLE, SND_TUR_PHASER, VOL_BASE, ATTEN_NORM);
54 beam.attack_finished_single = actor.attack_finished_single;
55 actor.attack_finished_single = time; // + autocvar_sys_ticrate;
57 setattachment(beam,actor.tur_head, "tag_fire");
59 soundat (actor, trace_endpos, CH_SHOTS, SND(NEXIMPACT), VOL_BASE, ATTEN_NORM);
61 if (actor.tur_head.frame == 0)
62 actor.tur_head.frame = 1;
68 if ((time > self.cnt) || (self.owner.deadflag != DEAD_NO))
70 self.owner.attack_finished_single = time + self.owner.shot_refire;
71 self.owner.fireflag = 2;
72 self.owner.tur_head.frame = 10;
73 sound (self, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
78 turret_do_updates(self.owner);
80 if (time - self.shot_spread > 0)
82 self.shot_spread = time + 2;
83 sound (self, CH_SHOTS_SINGLE, SND_TUR_PHASER, VOL_BASE, ATTEN_NORM);
87 self.nextthink = time + self.ticrate;
89 self.owner.attack_finished_single = time + frametime;
91 FireImoBeam ( self.tur_shotorg,
92 self.tur_shotorg + self.tur_shotdir_updated * self.target_range,
93 '-1 -1 -1' * self.shot_radius,
94 '1 1 1' * self.shot_radius,
98 DEATH_TURRET_PHASER.m_id);
100 self.scale = vlen(self.owner.tur_shotorg - trace_endpos) / 256;