Merge branch 'master' into terencehill/music_player
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / tturrets / units / unit_plasma.qc
1 void spawnfunc_turret_plasma();
2 void spawnfunc_turret_plasma_dual();
3
4 void turret_plasma_std_init();
5 void turret_plasma_dual_init();
6
7 void turret_plasma_attack();
8
9
10 void turret_plasma_postthink()
11 {
12     if (self.tur_head.frame != 0)
13         self.tur_head.frame = self.tur_head.frame + 1;
14
15     if (self.tur_head.frame > 5)
16         self.tur_head.frame = 0;
17 }
18
19 void turret_plasma_dual_postthink()
20 {
21     if ((self.tur_head.frame != 0) && (self.tur_head.frame != 3))
22         self.tur_head.frame = self.tur_head.frame + 1;
23
24     if (self.tur_head.frame > 6)
25         self.tur_head.frame = 0;
26 }
27
28 void turret_plasma_minsta_attack (void)
29 {
30         float flying;
31         flying = IsFlying(self); // do this BEFORE to make the trace values from FireRailgunBullet last
32
33         FireRailgunBullet (self.tur_shotorg, self.tur_shotorg + self.tur_shotdir_updated * MAX_SHOT_DISTANCE, 10000000000,
34                                            800, 0, 0, 0, 0, DEATH_TURRET_PLASMA);
35
36
37         pointparticles(particleeffectnum("nex_muzzleflash"), self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
38
39         // teamcolor / hit beam effect
40         vector v;
41         v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
42         if(teamplay)
43         {
44             switch(self.team)
45             {
46             case NUM_TEAM_1:   // Red
47                     WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3RED"), self.tur_shotorg, v);
48                 break;
49             case NUM_TEAM_2:   // Blue
50                     WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3BLUE"), self.tur_shotorg, v);
51                 break;
52             case NUM_TEAM_3:   // Yellow
53                     WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3YELLOW"), self.tur_shotorg, v);
54                 break;
55             case NUM_TEAM_4:   // Pink
56                     WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3PINK"), self.tur_shotorg, v);
57                 break;
58             }
59         }
60         else
61         WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3"), self.tur_shotorg, v);
62     if (self.tur_head.frame == 0)
63         self.tur_head.frame = 1;
64 }
65
66 void turret_plasma_attack()
67 {
68     entity missile = turret_projectile("weapons/hagar_fire.wav", 1, 0, DEATH_TURRET_PLASMA, PROJECTILE_ELECTRO_BEAM, TRUE, TRUE);
69     missile.missile_flags = MIF_SPLASH;
70
71     pointparticles(particleeffectnum("laser_muzzleflash"), self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
72     if (self.tur_head.frame == 0)
73         self.tur_head.frame = 1;
74 }
75
76 void turret_plasma_dual_attack()
77 {
78     entity missile = turret_projectile("weapons/hagar_fire.wav", 1, 0, DEATH_TURRET_PLASMA, PROJECTILE_ELECTRO_BEAM, TRUE, TRUE);
79     missile.missile_flags = MIF_SPLASH;
80     pointparticles(particleeffectnum("laser_muzzleflash"), self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
81     self.tur_head.frame += 1;
82 }
83
84 void turret_plasma_std_init()
85 {
86     if (self.netname == "")      self.netname     = "Plasma Cannon";
87
88     // What ammo to use
89     self.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIVE;
90
91     // How to aim
92     self.aim_flags      = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE | TFL_AIM_GROUNDGROUND;
93     self.turrcaps_flags = TFL_TURRCAPS_RADIUSDMG | TFL_TURRCAPS_MEDPROJ | TFL_TURRCAPS_PLAYERKILL;
94
95     if (turret_stdproc_init("plasma_std", "models/turrets/base.md3", "models/turrets/plasma.md3", TID_PLASMA) == 0)
96     {
97         remove(self);
98         return;
99     }
100
101     self.damage_flags    |= TFL_DMG_HEADSHAKE;
102     self.firecheck_flags |= TFL_FIRECHECK_AFF;
103
104     // Our fireing routine
105     if(g_instagib)
106         self.turret_firefunc  = turret_plasma_minsta_attack;
107     else
108         self.turret_firefunc  = turret_plasma_attack;
109
110     // Custom per turret frame stuff. usualy animation.
111     self.turret_postthink = turret_plasma_postthink;
112     turret_do_updates(self);
113 }
114
115
116 void turret_plasma_dual_init()
117 {
118     if (self.netname == "")      self.netname     = "Dual Plasma Cannon";
119
120     // What ammo to use
121     self.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIVE;
122
123     // How to aim at targets
124     self.aim_flags      = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE  | TFL_AIM_GROUNDGROUND ;
125     self.turrcaps_flags = TFL_TURRCAPS_RADIUSDMG | TFL_TURRCAPS_MEDPROJ | TFL_TURRCAPS_PLAYERKILL;
126
127     if (turret_stdproc_init("plasma_dual", "models/turrets/base.md3", "models/turrets/plasmad.md3", TID_PLASMA_DUAL) == 0)
128     {
129         remove(self);
130         return;
131     }
132
133     self.damage_flags    |= TFL_DMG_HEADSHAKE;
134     self.firecheck_flags |= TFL_FIRECHECK_AFF;
135
136     // Our fireing routine
137     self.turret_firefunc  = turret_plasma_dual_attack;
138
139     // Custom per turret frame stuff. usualy animation.
140     self.turret_postthink = turret_plasma_dual_postthink;
141 }
142
143
144 /*
145 * Basic moderate (std) or fast (dual) fireing, short-mid range energy cannon.
146 * Not too mutch of a therat on its own, but can be rather dangerous in groups.
147 * Regenerates ammo slowly, support with a fusionreactor(s) to do some real damage.
148 */
149
150 /*QUAKED turret_plasma (0 .5 .8) ?
151 */
152 void spawnfunc_turret_plasma()
153 {
154     g_turrets_common_precash();
155     precache_model ("models/turrets/plasma.md3");
156     precache_model ("models/turrets/base.md3");
157
158     self.think = turret_plasma_std_init;
159     self.nextthink = time + 0.5;
160 }
161
162 /*QUAKED turret_plasma_dual (0 .5 .8) ?
163 */
164 void spawnfunc_turret_plasma_dual()
165 {
166
167     precache_model ("models/turrets/plasmad.md3");
168     precache_model ("models/turrets/base.md3");
169
170     self.think = turret_plasma_dual_init;
171     self.nextthink = time + 0.5;
172 }
173