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 #else
13 #ifdef SVQC
14 void spawnfunc_turret_plasma() { if(!turret_initialize(TUR_PLASMA)) remove(self); }
15
16 float t_plasma(float req)
17 {
18         switch(req)
19         {
20                 case TR_ATTACK:
21                 {
22                         if(g_minstagib)
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                                 pointparticles(particleeffectnum("nex_muzzleflash"), self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
31
32                                 // teamcolor / hit beam effect
33                                 vector v;
34                                 string s;
35                                 v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
36                                 s = strcat("TE_TEI_G3", Static_Team_ColorName_Upper(self.team));
37                                 
38                                 WarpZone_TrailParticles(world, particleeffectnum(s), self.tur_shotorg, v);
39                                 
40                                 if (self.tur_head.frame == 0)
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
48                                 pointparticles(particleeffectnum("laser_muzzleflash"), self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
49                                 if (self.tur_head.frame == 0)
50                                         self.tur_head.frame = 1;
51                         }
52
53                         return TRUE;
54                 }
55                 case TR_THINK:
56                 {
57                         if (self.tur_head.frame != 0)
58                                 self.tur_head.frame = self.tur_head.frame + 1;
59
60                         if (self.tur_head.frame > 5)
61                                 self.tur_head.frame = 0;
62
63                         return TRUE;
64                 }
65                 case TR_DEATH:
66                 {
67                         return TRUE;
68                 }
69                 case TR_SETUP:
70                 {
71                         self.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIEVE;
72                         self.damage_flags |= TFL_DMG_HEADSHAKE;
73                         self.firecheck_flags |= TFL_FIRECHECK_AFF;
74                         self.aim_flags = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE | TFL_AIM_SPLASH;
75                         
76                         turret_do_updates(self);
77
78                         return TRUE;
79                 }
80                 case TR_PRECACHE:
81                 {
82                         precache_model ("models/turrets/base.md3");
83                         precache_model ("models/turrets/plasma.md3");
84                         return TRUE;
85                 }
86         }
87
88         return TRUE;
89 }
90
91 #endif // SVQC
92 #ifdef CSQC
93 float t_plasma(float req)
94 {
95         switch(req)
96         {
97                 case TR_SETUP:
98                 {
99                         return TRUE;
100                 }
101                 case TR_PRECACHE:
102                 {
103                         precache_model ("models/turrets/base.md3");
104                         precache_model ("models/turrets/plasma.md3");
105                         return TRUE;
106                 }
107         }
108
109         return TRUE;
110 }
111
112 #endif // CSQC
113 #endif // REGISTER_TURRET