]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/tturrets/units/unit_flac.qc
Merge branch 'master' into terencehill/physics_panel_updates
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / tturrets / units / unit_flac.qc
1 void spawnfunc_turret_flac();
2 void turret_flac_dinit();
3 void turret_flac_attack();
4 void turret_flac_projectile_explode();
5
6 void turret_flac_attack()
7 {
8     local entity proj;
9
10     turret_tag_fire_update();
11
12     sound (self, CH_WEAPON_A, "weapons/hagar_fire.wav", VOL_BASE, ATTN_NORM);
13     proj = spawn ();
14     setorigin(proj, self.tur_shotorg);
15     setsize(proj, '0 0 0', '0 0 0');
16     proj.classname          = "flac_projectile";
17     proj.owner              = self;
18     proj.bot_dodge          = TRUE;
19     proj.bot_dodgerating    = self.shot_dmg;
20     proj.solid              = SOLID_BBOX;
21     proj.movetype           = MOVETYPE_FLYMISSILE;
22     proj.flags              = FL_PROJECTILE;
23     proj.takedamage         = DAMAGE_NO;
24     proj.velocity           = normalize(self.tur_shotdir_updated + randomvec() * self.shot_spread) * self.shot_speed;
25     proj.angles             = vectoangles(proj.velocity);
26     proj.touch              = turret_flac_projectile_explode;
27     proj.think              = turret_flac_projectile_explode;
28     proj.nextthink          = time + max(self.tur_impacttime,(self.shot_radius * 3) / self.shot_speed);
29     proj.enemy              = self.enemy;
30     proj.cnt                = time + 5;
31
32     CSQCProjectile(proj, TRUE, PROJECTILE_HAGAR, TRUE);
33
34     self.tur_head.frame = self.tur_head.frame + 1;
35     if (self.tur_head.frame >= 4) self.tur_head.frame = 0;
36
37 }
38
39 void turret_flac_projectile_explode()
40 {
41     if( (self.enemy != world) &&
42         (vlen(self.origin - self.enemy.origin) < self.owner.shot_radius * 3) )
43     {
44         // OMG HAXX!
45         setorigin(self,self.enemy.origin + randomvec() * self.owner.shot_radius);
46     }
47     self.event_damage = SUB_Null;
48
49 #ifdef TURRET_DEBUG
50     float ftmp;
51     ftmp = RadiusDamage (self, self.owner, self.owner.shot_dmg, 0, self.owner.shot_radius, world, self.owner.shot_force, DEATH_TURRET_FLAC, world);
52     self.owner.tur_dbg_dmg_t_h = self.owner.tur_dbg_dmg_t_h + ftmp; //self.owner.shot_dmg;
53     self.owner.tur_dbg_dmg_t_f = self.owner.tur_dbg_dmg_t_f + self.owner.shot_dmg;
54 #else
55     RadiusDamage (self, self.owner, self.owner.shot_dmg, self.owner.shot_dmg * 0.5, self.owner.shot_radius, world, self.owner.shot_force, DEATH_TURRET_FLAC, world);
56 #endif
57
58     remove (self);
59 }
60
61
62 void turret_flac_dinit()
63 {
64     if (self.netname == "")      self.netname  = "FLAC Cannon";
65
66     self.turrcaps_flags = TFL_TURRCAPS_RADIUSDMG | TFL_TURRCAPS_FASTPROJ | TFL_TURRCAPS_MISSILEKILL;
67     self.ammo_flags     = TFL_AMMO_ROCKETS | TFL_AMMO_RECHARGE;
68     self.aim_flags      = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE;
69
70     if (turret_stdproc_init("flac_std", "models/turrets/base.md3", "models/turrets/flac.md3", TID_FLAC) == 0)
71     {
72         remove(self);
73         return;
74     }
75     setsize(self.tur_head,'-32 -32 0','32 32 64');
76
77     self.damage_flags |= TFL_DMG_HEADSHAKE;
78     self.target_select_flags |= TFL_TARGETSELECT_NOTURRETS | TFL_TARGETSELECT_MISSILESONLY;
79
80
81     // Our fire routine
82     self.turret_firefunc  = turret_flac_attack;
83
84 }
85 /*QUAKED turret_flac (0 .5 .8) ?
86 */
87
88 void spawnfunc_turret_flac()
89 {
90     precache_model ("models/turrets/base.md3");
91     precache_model ("models/turrets/flac.md3");
92
93     self.think = turret_flac_dinit;
94     self.nextthink = time + 0.5;
95 }
96