]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/turrets/unit/plasma.qc
Merge branch 'master' into Mario/turrets
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / unit / plasma.qc
1 #ifdef REGISTER_TURRET
2 REGISTER_TURRET(
3 /* TUR_##id   */ PLASMA,
4 /* function   */ t_plasma,
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 */ "plasma.md3",
9 /* netname        */ "plasma",
10 /* fullname   */ _("Plasma Cannon")
11 );
12
13 #define PLASMA_SETTINGS(turret) 
14
15
16 #ifdef SVQC
17 PLASMA_SETTINGS(plasma)
18 #endif // SVQC
19 #else
20 #ifdef SVQC
21
22 void spawnfunc_turret_plasma() { if not(turret_initialize(TUR_PLASMA)) remove(self); }
23
24 float t_plasma(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                                 if (self.tur_head.frame == 0)
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
72                                 pointparticles(particleeffectnum("laser_muzzleflash"), self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
73                                 if (self.tur_head.frame == 0)
74                                         self.tur_head.frame = 1;
75                         }
76
77                         return TRUE;
78                 }
79                 case TR_THINK:
80                 {
81                         if (self.tur_head.frame != 0)
82                                 self.tur_head.frame = self.tur_head.frame + 1;
83
84                         if (self.tur_head.frame > 5)
85                                 self.tur_head.frame = 0;
86
87                         return TRUE;
88                 }
89                 case TR_DEATH:
90                 {
91                         return TRUE;
92                 }
93                 case TR_SETUP:
94                 {
95                         self.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIEVE;
96                         self.damage_flags |= TFL_DMG_HEADSHAKE;
97                         self.firecheck_flags |= TFL_FIRECHECK_AFF;
98                         self.aim_flags = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE | TFL_AIM_SPLASH;
99                         
100                         turret_do_updates(self);
101
102                         return TRUE;
103                 }
104                 case TR_PRECACHE:
105                 {
106                         precache_model ("models/turrets/base.md3");
107                         precache_model ("models/turrets/plasma.md3");
108                         return TRUE;
109                 }
110                 case TR_CONFIG:
111                 {
112                         TUR_CONFIG_SETTINGS(PLASMA_SETTINGS(plasma))
113                         return TRUE;
114                 }
115         }
116
117         return TRUE;
118 }
119
120 #endif // SVQC
121 #ifdef CSQC
122 float t_plasma(float req)
123 {
124         switch(req)
125         {
126                 case TR_SETUP:
127                 {
128                         return TRUE;
129                 }
130                 case TR_PRECACHE:
131                 {
132                         precache_model ("models/turrets/base.md3");
133                         precache_model ("models/turrets/plasma.md3");
134                         return TRUE;
135                 }
136         }
137
138         return TRUE;
139 }
140
141 #endif // CSQC
142 #endif // REGISTER_TURRET