Merge branch 'master' into Mario/turrets
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / unit / plasma_dual.qc
1 #ifdef REGISTER_TURRET
2 REGISTER_TURRET(
3 /* TUR_##id   */ PLASMA_DUAL,
4 /* function   */ t_plasma_dual,
5 /* spawnflags */ TUR_FLAG_SPLASH | TUR_FLAG_MEDPROJ | TUR_FLAG_PLAYER,
6 /* mins,maxs  */ '-32 -32 0', '32 32 64',
7 /* model          */ "base.md3",
8 /* head_model */ "plasmad.md3",
9 /* netname        */ "plasma_dual",
10 /* fullname   */ _("Dual Plasma Cannon")
11 );
12 #else
13 #ifdef SVQC
14 void spawnfunc_turret_plasma_dual() { if(!turret_initialize(TUR_PLASMA_DUAL)) remove(self); }
15
16 float t_plasma_dual(float req)
17 {
18         switch(req)
19         {
20                 case TR_ATTACK:
21                 {
22                         if(g_instagib)
23                         {
24                                 float flying;
25                                 flying = IsFlying(self); // do this BEFORE to make the trace values from FireRailgunBullet last
26
27                                 FireRailgunBullet (self.tur_shotorg, self.tur_shotorg + self.tur_shotdir_updated * MAX_SHOT_DISTANCE, 10000000000,
28                                                                    800, 0, 0, 0, 0, DEATH_TURRET_PLASMA);
29
30
31                                 pointparticles(particleeffectnum("nex_muzzleflash"), self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
32
33                                 // teamcolor / hit beam effect
34                                 vector v;
35                                 string s;
36                                 v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
37                                 s = strcat("TE_TEI_G3", ((self.team) ? Static_Team_ColorName_Upper(self.team) : ""));
38                                 
39                                 WarpZone_TrailParticles(world, particleeffectnum(s), self.tur_shotorg, v);
40                                         
41                                 self.tur_head.frame += 1;
42                         }
43                         else
44                         {
45                                 entity missile = turret_projectile("weapons/hagar_fire.wav", 1, 0, DEATH_TURRET_PLASMA, PROJECTILE_ELECTRO_BEAM, TRUE, TRUE);
46                                 missile.missile_flags = MIF_SPLASH;
47                                 pointparticles(particleeffectnum("laser_muzzleflash"), self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
48                                 self.tur_head.frame += 1;
49                         }
50
51                         return true;
52                 }
53                 case TR_THINK:
54                 {
55                         if ((self.tur_head.frame != 0) && (self.tur_head.frame != 3))
56                                 self.tur_head.frame = self.tur_head.frame + 1;
57
58                         if (self.tur_head.frame > 6)
59                                 self.tur_head.frame = 0;
60
61                         return true;
62                 }
63                 case TR_DEATH:
64                 {
65                         return true;
66                 }
67                 case TR_SETUP:
68                 {
69                         self.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIEVE;
70                         self.damage_flags |= TFL_DMG_HEADSHAKE;
71                         self.firecheck_flags |= TFL_FIRECHECK_AFF;
72                         self.aim_flags = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE | TFL_AIM_SPLASH;
73                         
74                         turret_do_updates(self);
75
76                         return true;
77                 }
78                 case TR_PRECACHE:
79                 {
80                         precache_model ("models/turrets/base.md3");
81                         precache_model ("models/turrets/plasmad.md3");
82                         return true;
83                 }
84         }
85
86         return true;
87 }
88
89 #endif // SVQC
90 #ifdef CSQC
91 float t_plasma_dual(float req)
92 {
93         switch(req)
94         {
95                 case TR_SETUP:
96                 {
97                         return true;
98                 }
99                 case TR_PRECACHE:
100                 {
101                         return true;
102                 }
103         }
104
105         return true;
106 }
107
108 #endif // CSQC
109 #endif // REGISTER_TURRET