4 CLASS(PhaserTurretAttack, PortoLaunch)
5 /* flags */ ATTRIB(PhaserTurretAttack, spawnflags, int, WEP_TYPE_OTHER);
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));
12 CLASS(PhaserTurret, Turret)
13 /* spawnflags */ ATTRIB(PhaserTurret, spawnflags, int, TUR_FLAG_SNIPER | TUR_FLAG_HITSCAN | TUR_FLAG_PLAYER);
14 /* mins */ ATTRIB(PhaserTurret, mins, vector, '-32 -32 0');
15 /* maxs */ ATTRIB(PhaserTurret, maxs, vector, '32 32 64');
16 /* modelname */ ATTRIB(PhaserTurret, mdl, string, "base.md3");
17 /* model */ ATTRIB(PhaserTurret, model, string, strzone(strcat("models/turrets/", this.mdl)));
18 /* head_model */ ATTRIB(PhaserTurret, head_model, string, strzone(strcat("models/turrets/", "phaser.md3")));
19 /* netname */ ATTRIB(PhaserTurret, netname, string, "phaser");
20 /* fullname */ ATTRIB(PhaserTurret, turret_name, string, _("Phaser Cannon"));
21 ATTRIB(PhaserTurret, m_weapon, Weapon, WEP_PHASER);
22 ENDCLASS(PhaserTurret)
23 REGISTER_TURRET(PHASER, NEW(PhaserTurret));
31 METHOD(PhaserTurretAttack, wr_think, bool(entity thiswep, bool fire1, bool fire2)) {
33 bool isPlayer = IS_PLAYER(self);
35 if (!isPlayer || weapon_prepareattack(false, WEP_CVAR_PRI(electro, refire))) {
37 turret_initparams(self);
38 W_SetupShot_Dir(self, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
39 self.tur_shotdir_updated = w_shotdir;
40 self.tur_shotorg = w_shotorg;
43 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
45 entity beam = spawn();
46 beam.ticrate = 0.1; //autocvar_sys_ticrate;
47 setmodel(beam, MDL_TUR_PHASER_BEAM);
48 beam.effects = EF_LOWPRECISION;
49 beam.solid = SOLID_NOT;
50 beam.think = beam_think;
51 beam.cnt = time + self.shot_speed;
52 beam.shot_spread = time + 2;
53 beam.nextthink = time;
55 beam.shot_dmg = self.shot_dmg / (self.shot_speed / beam.ticrate);
56 beam.scale = self.target_range / 256;
57 beam.movetype = MOVETYPE_NONE;
58 beam.enemy = self.enemy;
59 beam.bot_dodge = true;
60 beam.bot_dodgerating = beam.shot_dmg;
61 sound (beam, CH_SHOTS_SINGLE, SND_TUR_PHASER, VOL_BASE, ATTEN_NORM);
64 beam.attack_finished_single = self.attack_finished_single;
65 self.attack_finished_single = time; // + autocvar_sys_ticrate;
67 setattachment(beam,self.tur_head, "tag_fire");
69 soundat (self, trace_endpos, CH_SHOTS, SND(NEXIMPACT), VOL_BASE, ATTEN_NORM);
71 if (self.tur_head.frame == 0)
72 self.tur_head.frame = 1;
77 float turret_phaser_firecheck()
79 if (self.fireflag != 0) return 0;
80 return turret_firecheck();
85 if ((time > self.cnt) || (self.owner.deadflag != DEAD_NO))
87 self.owner.attack_finished_single = time + self.owner.shot_refire;
88 self.owner.fireflag = 2;
89 self.owner.tur_head.frame = 10;
90 sound (self, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
95 turret_do_updates(self.owner);
97 if (time - self.shot_spread > 0)
99 self.shot_spread = time + 2;
100 sound (self, CH_SHOTS_SINGLE, SND_TUR_PHASER, VOL_BASE, ATTEN_NORM);
104 self.nextthink = time + self.ticrate;
106 self.owner.attack_finished_single = time + frametime;
108 FireImoBeam ( self.tur_shotorg,
109 self.tur_shotorg + self.tur_shotdir_updated * self.target_range,
110 '-1 -1 -1' * self.shot_radius,
111 '1 1 1' * self.shot_radius,
115 DEATH_TURRET_PHASER);
117 self.scale = vlen(self.owner.tur_shotorg - trace_endpos) / 256;
121 void spawnfunc_turret_phaser() { SELFPARAM(); if(!turret_initialize(TUR_PHASER)) remove(self); }
123 METHOD(PhaserTurret, tr_think, void(PhaserTurret thistur))
125 if (self.tur_head.frame != 0)
127 if (self.fireflag == 1)
129 if (self.tur_head.frame == 10)
130 self.tur_head.frame = 1;
132 self.tur_head.frame = self.tur_head.frame +1;
134 else if (self.fireflag == 2 )
136 self.tur_head.frame = self.tur_head.frame +1;
137 if (self.tur_head.frame == 15)
139 self.tur_head.frame = 0;
145 METHOD(PhaserTurret, tr_setup, void(PhaserTurret this, entity it))
147 it.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIEVE;
148 it.aim_flags = TFL_AIM_LEAD;
150 it.turret_firecheckfunc = turret_phaser_firecheck;