Xonotic
phaser_weapon.qc
Go to the documentation of this file.
1 #include "phaser_weapon.qh"
2 
3 #ifdef SVQC
4 void beam_think(entity this);
5 
6 .int fireflag;
7 SOUND(PhaserTurretAttack_FIRE, W_Sound("electro_fire"));
8 METHOD(PhaserTurretAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
9 {
10  bool isPlayer = IS_PLAYER(actor);
11  if (fire & 1)
12  if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire))) {
13  if (isPlayer) {
14  turret_initparams(actor);
15  W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_PhaserTurretAttack_FIRE, CH_WEAPON_B, 0, DEATH_TURRET_PHASER.m_id);
16  actor.tur_shotdir_updated = w_shotdir;
17  actor.tur_shotorg = w_shotorg;
18  actor.tur_head = actor;
19  actor.shot_speed = 1;
20  weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
21  }
22  entity beam = new(PhaserTurret_beam);
23  beam.ticrate = 0.1; //autocvar_sys_ticrate;
24  setmodel(beam, MDL_TUR_PHASER_BEAM);
25  beam.effects = EF_LOWPRECISION;
26  beam.solid = SOLID_NOT;
27  setthink(beam, beam_think);
28  beam.cnt = time + actor.shot_speed;
29  beam.shot_spread = time + 2;
30  beam.nextthink = time;
31  beam.owner = actor;
32  beam.shot_dmg = actor.shot_dmg / (actor.shot_speed / beam.ticrate);
33  beam.scale = actor.target_range / 256;
35  beam.enemy = actor.enemy;
36  beam.bot_dodge = true;
37  IL_PUSH(g_bot_dodge, beam);
38  beam.bot_dodgerating = beam.shot_dmg;
39  sound (beam, CH_SHOTS_SINGLE, SND_TUR_PHASER, VOL_BASE, ATTEN_NORM);
40  actor.fireflag = 1;
41 
42  beam.attack_finished_single[0] = actor.attack_finished_single[0];
43  actor.attack_finished_single[0] = time; // + autocvar_sys_ticrate;
44 
45  setattachment(beam, actor.tur_head, "tag_fire");
46 
47  soundat (actor, trace_endpos, CH_SHOTS, SND(NEXIMPACT), VOL_BASE, ATTEN_NORM);
48  if (!isPlayer)
49  if (actor.tur_head.frame == 0)
50  actor.tur_head.frame = 1;
51  }
52 }
53 
54 void beam_think(entity this)
55 {
56  entity actor = this.owner;
57  if ((time > this.cnt) || (IS_DEAD(actor)))
58  {
59  actor.attack_finished_single[0] = time + actor.shot_refire;
60  actor.fireflag = 2;
61  actor.tur_head.frame = 10;
62  sound (this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
63  delete(this);
64  return;
65  }
66 
67  turret_do_updates(actor);
68 
69  if (time - this.shot_spread > 0)
70  {
71  this.shot_spread = time + 2;
72  sound (this, CH_SHOTS_SINGLE, SND_TUR_PHASER, VOL_BASE, ATTEN_NORM);
73  }
74 
75  this.nextthink = time + this.ticrate;
76 
77  actor.attack_finished_single[0] = time + frametime;
78  FireImoBeam ( actor, actor.tur_shotorg,
79  actor.tur_shotorg + actor.tur_shotdir_updated * actor.target_range,
80  '-1 -1 -1' * actor.shot_radius,
81  '1 1 1' * actor.shot_radius,
82  actor.shot_force,
83  this.shot_dmg,
84  0.75,
85  DEATH_TURRET_PHASER.m_id);
86  this.scale = vlen(actor.tur_shotorg - trace_endpos) / 256;
87 }
88 
89 #endif
const float SOLID_NOT
Definition: csprogsdefs.qc:244
#define WEP_CVAR_PRI(wepname, name)
Definition: all.qh:300
float MOVETYPE_NONE
Definition: progsdefs.qc:246
vector w_shotorg
Definition: tracing.qh:18
#define SND(id)
Definition: all.qh:35
entity() spawn
void w_ready(Weapon thiswep, entity actor,.entity weaponentity, int fire)
vector w_shotdir
Definition: tracing.qh:19
string W_Sound(string w_snd)
Definition: all.qc:281
#define METHOD(cname, name, prototype)
Definition: oo.qh:257
void turret_do_updates(entity e_turret)
updates aim org, shot org, shot dir and enemy org for selected turret
entity owner
Definition: main.qh:73
IntrusiveList g_bot_dodge
Definition: api.qh:150
#define setmodel(this, m)
Definition: model.qh:26
float cnt
Definition: powerups.qc:24
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
bool weapon_prepareattack(Weapon thiswep, entity actor,.entity weaponentity, bool secondary, float attacktime)
float frametime
Definition: csprogsdefs.qc:17
const float VOL_BASE
Definition: sound.qh:36
vector trace_endpos
Definition: csprogsdefs.qc:37
#define IS_DEAD(s)
Definition: utils.qh:26
const float ATTEN_NORM
Definition: sound.qh:30
float nextthink
Definition: csprogsdefs.qc:121
#define W_SetupShot_Dir(ent, wepent, s_forward, antilag, recoil, snd, chan, maxdamage, deathtype)
Definition: tracing.qh:31
const int CH_SHOTS
Definition: sound.qh:14
float scale
Definition: projectile.qc:14
void weapon_thinkf(entity actor,.entity weaponentity, WFRAME fr, float t, void(Weapon thiswep, entity actor,.entity weaponentity, int fire) func)
#define setthink(e, f)
const int CH_SHOTS_SINGLE
Definition: sound.qh:15
#define sound(e, c, s, v, a)
Definition: sound.qh:52
#define SOUND(name, path)
Definition: all.qh:30
float time
Definition: csprogsdefs.qc:16
const int CH_WEAPON_B
Definition: sound.qh:8
void set_movetype(entity this, int mt)
#define IS_PLAYER(v)
Definition: utils.qh:9
float EF_LOWPRECISION
float ticrate
Definition: main.qh:182
vector v_forward
Definition: csprogsdefs.qc:31