]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/turrets/unit/plasma_dual.qc
Clean up turrets system a bit
[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
13 #define PLASMA_DUAL_SETTINGS(turret) 
14
15
16 #ifdef SVQC
17 PLASMA_DUAL_SETTINGS(plasma_dual)
18 #endif // SVQC
19 #else
20 #ifdef SVQC
21
22 void spawnfunc_turret_plasma_dual() { if not(turret_initialize(TUR_PLASMA_DUAL)) remove(self); }
23
24 float t_plasma_dual(float req)
25 {
26         switch(req)
27         {
28                 case TR_ATTACK:
29                 {
30                         if(g_minstagib)
31                         {
32                                 float flying;
33                                 flying = IsFlying(self); // do this BEFORE to make the trace values from FireRailgunBullet last
34
35                                 FireRailgunBullet (self.tur_shotorg, self.tur_shotorg + self.tur_shotdir_updated * MAX_SHOT_DISTANCE, 10000000000,
36                                                                    800, 0, 0, 0, 0, DEATH_TURRET_PLASMA);
37
38
39                                 pointparticles(particleeffectnum("nex_muzzleflash"), self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
40
41                                 // teamcolor / hit beam effect
42                                 vector v;
43                                 v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
44                                 if(teamplay)
45                                 {
46                                         switch(self.team)
47                                         {
48                                                 case NUM_TEAM_1:   // Red
49                                                                 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3RED"), self.tur_shotorg, v);
50                                                         break;
51                                                 case NUM_TEAM_2:   // Blue
52                                                                 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3BLUE"), self.tur_shotorg, v);
53                                                         break;
54                                                 case NUM_TEAM_3:   // Yellow
55                                                                 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3YELLOW"), self.tur_shotorg, v);
56                                                         break;
57                                                 case NUM_TEAM_4:   // Pink
58                                                                 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3PINK"), self.tur_shotorg, v);
59                                                         break;
60                                         }
61                                 }
62                                 else
63                                         WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3"), self.tur_shotorg, v);
64                                         
65                                 self.tur_head.frame += 1;
66                         }
67                         else
68                         {
69                                 entity missile = turret_projectile("weapons/hagar_fire.wav", 1, 0, DEATH_TURRET_PLASMA, PROJECTILE_ELECTRO_BEAM, TRUE, TRUE);
70                                 missile.missile_flags = MIF_SPLASH;
71                                 pointparticles(particleeffectnum("laser_muzzleflash"), self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
72                                 self.tur_head.frame += 1;
73                         }
74
75                         return TRUE;
76                 }
77                 case TR_THINK:
78                 {
79                         if ((self.tur_head.frame != 0) && (self.tur_head.frame != 3))
80                                 self.tur_head.frame = self.tur_head.frame + 1;
81
82                         if (self.tur_head.frame > 6)
83                                 self.tur_head.frame = 0;
84
85                         return TRUE;
86                 }
87                 case TR_DEATH:
88                 {
89                         return TRUE;
90                 }
91                 case TR_SETUP:
92                 {
93                         self.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIEVE;
94                         self.damage_flags |= TFL_DMG_HEADSHAKE;
95                         self.firecheck_flags |= TFL_FIRECHECK_AFF;
96                         self.aim_flags = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE | TFL_AIM_SPLASH;
97                         
98                         turret_do_updates(self);
99
100                         return TRUE;
101                 }
102                 case TR_PRECACHE:
103                 {
104                         precache_model ("models/turrets/base.md3");
105                         precache_model ("models/turrets/plasmad.md3");
106                         return TRUE;
107                 }
108                 case TR_CONFIG:
109                 {
110                         TUR_CONFIG_SETTINGS(PLASMA_DUAL_SETTINGS(plasma_dual))
111                         return TRUE;
112                 }
113         }
114
115         return TRUE;
116 }
117
118 #endif // SVQC
119 #ifdef CSQC
120 float t_plasma_dual(float req)
121 {
122         switch(req)
123         {
124                 case TR_SETUP:
125                 {
126                         return TRUE;
127                 }
128                 case TR_PRECACHE:
129                 {
130                         precache_model ("models/turrets/base.md3");
131                         precache_model ("models/turrets/plasmad.md3");
132                         return TRUE;
133                 }
134         }
135
136         return TRUE;
137 }
138
139 #endif // CSQC
140 #endif // REGISTER_TURRET