Get rid of g_turrets_unit_ewheel_std_target_range_fire, fix g_turrets_targetscan_mind...
[divverent/nexuiz.git] / data / qcsrc / server / tturrets / units / unit_flac.qc
1 void spawnfunc_turret_flac();\r
2 void turret_flac_dinit();\r
3 void turret_flac_attack();\r
4 void turret_flac_projectile_explode();\r
5 \r
6 void turret_flac_attack()\r
7 {\r
8     local entity proj;\r
9 \r
10     turret_tag_fire_update();\r
11 \r
12     sound (self, CHAN_WEAPON, "weapons/hagar_fire.wav", VOL_BASE, ATTN_NORM);\r
13     proj = spawn ();\r
14     setorigin(proj, self.tur_shotorg);\r
15     // setmodel(proj, "models/turrets/pd_proj.md3");\r
16     setsize(proj, '0 0 0', '0 0 0');\r
17     proj.classname          = "flac_projectile";\r
18     proj.owner              = self;\r
19     proj.bot_dodge          = TRUE;\r
20     proj.bot_dodgerating    = self.shot_dmg;\r
21     proj.solid              = SOLID_BBOX;\r
22     proj.movetype           = MOVETYPE_FLYMISSILE;\r
23     proj.flags              = FL_PROJECTILE;\r
24     // proj.effects            = EF_LOWPRECISION;\r
25     proj.takedamage         = DAMAGE_NO;\r
26     //proj.health             =  100;\r
27     proj.velocity           = normalize(self.tur_shotdir_updated + randomvec() * self.shot_spread) * self.shot_speed;\r
28     proj.angles             = vectoangles(proj.velocity);\r
29     proj.touch              = turret_flac_projectile_explode;\r
30     proj.think              = turret_flac_projectile_explode;\r
31     proj.nextthink          = time + max(self.tur_impacttime,(self.shot_radius * 3) / self.shot_speed);\r
32     proj.enemy              = self.enemy;\r
33     proj.cnt                = time + 5;\r
34 \r
35     CSQCProjectile(proj, TRUE, PROJECTILE_HAGAR, TRUE);\r
36 \r
37     self.tur_head.frame = self.tur_head.frame + 1;\r
38     if (self.tur_head.frame >= 4) self.tur_head.frame = 0;\r
39 \r
40 }\r
41 \r
42 void turret_flac_projectile_explode()\r
43 {\r
44     float ftmp;\r
45 \r
46     // FIXME: tur_impacttime is not accurate enougth, this is a dirty hakk to make flac work.\r
47 \r
48     //w_deathtypestring = "got caught in the flack.";\r
49 \r
50     if(self.enemy != world)\r
51     if(self.cnt < time)\r
52     if(vlen(self.origin - self.enemy.origin) > self.owner.shot_radius * 0.25)\r
53     {\r
54         self.nextthink = time; //vlen(self.origin - self.enemy.origin) / self.owner.shot_speed;\r
55         return;\r
56     }\r
57 \r
58 \r
59     te_explosion (self.origin);\r
60 \r
61     ftmp = crandom();\r
62     if (ftmp<-0.7)\r
63         sound (self, CHAN_PROJECTILE, "weapons/hagexp1.wav", VOL_BASE, ATTN_NORM);\r
64     else if (ftmp<0.4)\r
65         sound (self, CHAN_PROJECTILE, "weapons/hagexp2.wav", VOL_BASE, ATTN_NORM);\r
66     else if (ftmp<1)\r
67         sound (self, CHAN_PROJECTILE, "weapons/hagexp3.wav", VOL_BASE, ATTN_NORM);\r
68 \r
69 \r
70     self.event_damage = SUB_Null;\r
71 \r
72 \r
73 #ifdef TURRET_DEBUG\r
74     ftmp = RadiusDamage (self, self.owner, self.owner.shot_dmg, 0, self.owner.shot_radius, world, self.owner.shot_force, DEATH_TURRET, world);\r
75     self.owner.tur_dbg_dmg_t_h = self.owner.tur_dbg_dmg_t_h + ftmp; //self.owner.shot_dmg;\r
76     self.owner.tur_dbg_dmg_t_f = self.owner.tur_dbg_dmg_t_f + self.owner.shot_dmg;\r
77 #else\r
78     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, world);\r
79 #endif\r
80 \r
81     remove (self);\r
82 }\r
83 \r
84 \r
85 void turret_flac_dinit()\r
86 {\r
87     if (self.netname == "")      self.netname  = "FLAC Cannon";\r
88 \r
89 \r
90     self.turrcaps_flags = TFL_TURRCAPS_RADIUSDMG | TFL_TURRCAPS_FASTPROJ | TFL_TURRCAPS_MISSILEKILL;\r
91     self.ammo_flags     = TFL_AMMO_ROCKETS | TFL_AMMO_RECHARGE;\r
92     self.aim_flags      = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE;\r
93 \r
94     if (turret_stdproc_init("flac_std",0) == 0)\r
95     {\r
96         remove(self);\r
97         return;\r
98     }\r
99 \r
100     self.damage_flags |= TFL_DMG_HEADSHAKE;\r
101     self.target_select_flags |= TFL_TARGETSELECT_NOTURRETS;\r
102 \r
103     setmodel(self,"models/turrets/base.md3");\r
104     setmodel(self.tur_head,"models/turrets/flac.md3");\r
105 \r
106     if (!turret_tag_setup())\r
107         dprint("Warning: Turret ",self.classname, " faild to initialize md3 tags\n");\r
108 \r
109     // Our fire routine\r
110     self.turret_firefunc  = turret_flac_attack;\r
111 \r
112 }\r
113 /*QUAKED turret_flac (0 .5 .8) ?\r
114 */\r
115 \r
116 void spawnfunc_turret_flac()\r
117 {\r
118     precache_model ("models/turrets/base.md3");\r
119     precache_model ("models/turrets/flac.md3");\r
120     //precache_model("models/turrets/pd_proj.md3");\r
121 \r
122     self.think = turret_flac_dinit;\r
123     self.nextthink = time + 0.5;\r
124 }\r
125 \r