1 #include "phaser_weapon.qh"
6 void beam_think(entity this);
9 SOUND(PhaserTurretAttack_FIRE, W_Sound("electro_fire"));
10 METHOD(PhaserTurretAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
12 bool isPlayer = IS_PLAYER(actor);
14 if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire))) {
16 turret_initparams(actor);
17 W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_PhaserTurretAttack_FIRE, CH_WEAPON_B, 0);
18 actor.tur_shotdir_updated = w_shotdir;
19 actor.tur_shotorg = w_shotorg;
20 actor.tur_head = actor;
22 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
24 entity beam = spawn();
25 beam.ticrate = 0.1; //autocvar_sys_ticrate;
26 setmodel(beam, MDL_TUR_PHASER_BEAM);
27 beam.effects = EF_LOWPRECISION;
28 beam.solid = SOLID_NOT;
29 setthink(beam, beam_think);
30 beam.cnt = time + actor.shot_speed;
31 beam.shot_spread = time + 2;
32 beam.nextthink = time;
34 beam.shot_dmg = actor.shot_dmg / (actor.shot_speed / beam.ticrate);
35 beam.scale = actor.target_range / 256;
36 set_movetype(beam, MOVETYPE_NONE);
37 beam.enemy = actor.enemy;
38 beam.bot_dodge = true;
39 IL_PUSH(g_bot_dodge, beam);
40 beam.bot_dodgerating = beam.shot_dmg;
41 sound (beam, CH_SHOTS_SINGLE, SND_TUR_PHASER, VOL_BASE, ATTEN_NORM);
44 beam.attack_finished_single[0] = actor.attack_finished_single[0];
45 actor.attack_finished_single[0] = time; // + autocvar_sys_ticrate;
47 setattachment(beam,actor.tur_head, "tag_fire");
49 soundat (actor, trace_endpos, CH_SHOTS, SND(NEXIMPACT), VOL_BASE, ATTEN_NORM);
51 if (actor.tur_head.frame == 0)
52 actor.tur_head.frame = 1;
56 void beam_think(entity this)
58 if ((time > this.cnt) || (IS_DEAD(this.owner)))
60 this.owner.attack_finished_single[0] = time + this.owner.shot_refire;
61 this.owner.fireflag = 2;
62 this.owner.tur_head.frame = 10;
63 sound (this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
68 turret_do_updates(this.owner);
70 if (time - this.shot_spread > 0)
72 this.shot_spread = time + 2;
73 sound (this, CH_SHOTS_SINGLE, SND_TUR_PHASER, VOL_BASE, ATTEN_NORM);
77 this.nextthink = time + this.ticrate;
79 this.owner.attack_finished_single[0] = time + frametime;
80 FireImoBeam ( this.owner, this.tur_shotorg,
81 this.tur_shotorg + this.tur_shotdir_updated * this.target_range,
82 '-1 -1 -1' * this.shot_radius,
83 '1 1 1' * this.shot_radius,
87 DEATH_TURRET_PHASER.m_id);
88 this.scale = vlen(this.owner.tur_shotorg - trace_endpos) / 256;