8068ab1d7e8d97c49ecb22ad90932cec40d33844
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / unit / flac.qc
1 #ifdef REGISTER_TURRET
2 REGISTER_TURRET(
3 /* TUR_##id   */ FLAC,
4 /* function   */ t_flac,
5 /* spawnflags */ TUR_FLAG_SPLASH | TUR_FLAG_FASTPROJ | TUR_FLAG_MISSILE,
6 /* mins,maxs  */ '-32 -32 0', '32 32 64',
7 /* model          */ "base.md3",
8 /* head_model */ "flac.md3",
9 /* netname        */ "flac",
10 /* fullname   */ _("FLAC Cannon")
11 );
12 #else
13 #ifdef SVQC
14 void turret_flac_projectile_think_explode()
15 {
16         if(self.enemy != world)
17         if(vlen(self.origin - self.enemy.origin) < self.owner.shot_radius * 3)
18                 setorigin(self,self.enemy.origin + randomvec() * self.owner.shot_radius);
19
20 #ifdef TURRET_DEBUG
21         float d;
22         d = RadiusDamage (self, self.owner, self.owner.shot_dmg, self.owner.shot_dmg, self.owner.shot_radius, self, world, self.owner.shot_force, self.totalfrags, world);
23         self.owner.tur_dbg_dmg_t_h = self.owner.tur_dbg_dmg_t_h + d;
24         self.owner.tur_dbg_dmg_t_f = self.owner.tur_dbg_dmg_t_f + self.owner.shot_dmg;
25 #else
26         RadiusDamage (self, self.realowner, self.owner.shot_dmg, self.owner.shot_dmg, self.owner.shot_radius, self, world, self.owner.shot_force, self.totalfrags, world);
27 #endif
28         remove(self);
29 }
30
31 void spawnfunc_turret_flac() { if(!turret_initialize(TUR_FLAC)) remove(self); }
32
33 float t_flac(float req)
34 {
35         switch(req)
36         {
37                 case TR_ATTACK:
38                 {
39                         entity proj;
40
41                         turret_tag_fire_update();
42
43                         proj = turret_projectile("weapons/hagar_fire.wav", 5, 0, DEATH_TURRET_FLAC, PROJECTILE_HAGAR, TRUE, TRUE);
44                         pointparticles(particleeffectnum("laser_muzzleflash"), self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
45                         proj.think        = turret_flac_projectile_think_explode;
46                         proj.nextthink  = time + self.tur_impacttime + (random() * 0.01 - random() * 0.01);
47                         proj.missile_flags = MIF_SPLASH | MIF_PROXY;
48
49                         self.tur_head.frame = self.tur_head.frame + 1;
50                         if (self.tur_head.frame >= 4)
51                                 self.tur_head.frame = 0;
52                         
53                         return true;
54                 }
55                 case TR_THINK:
56                 {
57                         return true;
58                 }
59                 case TR_DEATH:
60                 {
61                         return true;
62                 }
63                 case TR_SETUP:
64                 {
65                         self.ammo_flags = TFL_AMMO_ROCKETS | TFL_AMMO_RECHARGE;
66                         self.aim_flags = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE;
67                         self.damage_flags |= TFL_DMG_HEADSHAKE;
68                         self.target_select_flags |= TFL_TARGETSELECT_NOTURRETS | TFL_TARGETSELECT_MISSILESONLY;
69                 
70                         return true;
71                 }
72                 case TR_PRECACHE:
73                 {
74                         precache_model ("models/turrets/base.md3");
75                         precache_model ("models/turrets/flac.md3");
76                         return true;
77                 }
78         }
79
80         return true;
81 }
82
83 #endif // SVQC
84 #ifdef CSQC
85 float t_flac(float req)
86 {
87         switch(req)
88         {
89                 case TR_SETUP:
90                 {
91                         return true;
92                 }
93                 case TR_PRECACHE:
94                 {
95                         return true;
96                 }
97         }
98
99         return true;
100 }
101
102 #endif // CSQC
103 #endif // REGISTER_TURRET