]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/w_crylink.qc
fix turrets for onslaught: default them to have no team and attack nobody if not...
[divverent/nexuiz.git] / data / qcsrc / server / w_crylink.qc
1 .float gravity;
2 const vector proj_color = '1 1 1';
3
4 .entity realowner;
5
6 void W_Crylink_Touch (void)
7 {
8         float finalhit;
9         float f;
10         if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
11         {
12                 remove(self);
13                 return;
14         }
15         pointparticles(particleeffectnum("crylink_impactbig"), self.origin, '0 0 0', 1);
16         finalhit = ((self.cnt <= 0) || (other.takedamage != DAMAGE_NO));
17         if(finalhit)
18                 f = 1;
19         else
20                 f = cvar("g_balance_crylink_primary_bouncedamagefactor");
21         if(self.alpha)
22                 f *= self.alpha;
23         RadiusDamage (self, self.realowner, cvar("g_balance_crylink_primary_damage") * f, cvar("g_balance_crylink_primary_edgedamage") * f, cvar("g_balance_crylink_primary_radius"), world, cvar("g_balance_crylink_primary_force") * f, self.projectiledeathtype, other);
24         if (finalhit)
25         {
26                 remove (self);
27                 return;
28         }
29         self.cnt = self.cnt - 1;
30         self.angles = vectoangles(self.velocity);
31         self.owner = world;
32         self.projectiledeathtype |= HITTYPE_BOUNCE;
33         //self.scale = 1 + self.cnt;
34 }
35
36 void W_Crylink_Touch2 (void)
37 {
38         float finalhit;
39         float f;
40         if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
41         {
42                 remove(self);
43                 return;
44         }
45         pointparticles(particleeffectnum("crylink_impact"), self.origin, '0 0 0', 1);
46         finalhit = ((self.cnt <= 0) || (other.takedamage != DAMAGE_NO));
47         if(finalhit)
48                 f = 1;
49         else
50                 f = cvar("g_balance_crylink_secondary_bouncedamagefactor");
51         if(self.alpha)
52                 f *= self.alpha;
53         RadiusDamage (self, self.realowner, cvar("g_balance_crylink_secondary_damage") * f, cvar("g_balance_crylink_secondary_edgedamage") * f, cvar("g_balance_crylink_secondary_radius"), world, cvar("g_balance_crylink_secondary_force") * f, self.projectiledeathtype, other);
54         if (finalhit)
55         {
56                 remove (self);
57                 return;
58         }
59         self.cnt = self.cnt - 1;
60         self.angles = vectoangles(self.velocity);
61         self.owner = world;
62         self.projectiledeathtype |= HITTYPE_BOUNCE;
63 //      self.scale = 1 + 1 * self.cnt;
64 }
65
66 void W_Crylink_Attack (void)
67 {
68         local float counter, shots;
69         local entity proj;
70         local vector s;
71
72         if not(self.items & IT_UNLIMITED_AMMO)
73                 self.ammo_cells = self.ammo_cells - cvar("g_balance_crylink_primary_ammo");
74
75         W_SetupShot (self, '25 8 -8', FALSE, 2, "weapons/crylink_fire.wav");
76
77         shots = cvar("g_balance_crylink_primary_shots");
78         pointparticles(particleeffectnum("crylink_muzzleflash"), w_shotorg, w_shotdir * 1000, shots);
79         while (counter < shots)
80         {
81                 proj = spawn ();
82                 proj.realowner = proj.owner = self;
83                 proj.classname = "spike";
84                 proj.bot_dodge = TRUE;
85                 proj.bot_dodgerating = cvar("g_balance_crylink_primary_damage");
86
87                 proj.movetype = MOVETYPE_BOUNCEMISSILE;
88                 proj.solid = SOLID_BBOX;
89                 proj.projectiledeathtype = WEP_CRYLINK;
90                 //proj.gravity = 0.001;
91
92                 setmodel (proj, "models/plasmatrail.mdl"); // precision set below
93                 setsize (proj, '0 0 0', '0 0 0');
94                 setorigin (proj, w_shotorg);
95
96                 s = '0 0 0';
97                 if (counter == 0)
98                         s = '0 0 0';
99                 else if (counter == 1)
100                         s = '0 0 1';
101                 else if (counter == 2)
102                         s = '0 -0.71 -0.71';
103                 else if (counter == 3)
104                         s = '0 0.71 -0.71';
105                 else
106                         s = randomvec();
107                 s = s * cvar("g_balance_crylink_primary_spread");
108                 proj.velocity = (w_shotdir + v_right * s_y + v_up * s_z) * cvar("g_balance_crylink_primary_speed");
109 //              proj.velocity = (w_shotdir + randomvec() * cvar("g_balance_crylink_primary_spread")) * cvar("g_balance_crylink_primary_speed");
110                 W_SetupProjectileVelocity(proj);
111                 proj.touch = W_Crylink_Touch;
112                 if(counter == 0)
113                         SUB_SetFade(proj, time + cvar("g_balance_crylink_primary_middle_lifetime"), cvar("g_balance_crylink_primary_middle_fadetime"));
114                 else if(counter <= 3)
115                         SUB_SetFade(proj, time + cvar("g_balance_crylink_primary_star_lifetime"), cvar("g_balance_crylink_primary_star_fadetime"));
116                 else
117                         SUB_SetFade(proj, time + cvar("g_balance_crylink_primary_other_lifetime"), cvar("g_balance_crylink_primary_other_fadetime"));
118                 proj.cnt = cvar("g_balance_crylink_primary_bounces");
119                 proj.scale = 1 + 1 * proj.cnt;
120
121                 proj.angles = vectoangles (proj.velocity);
122
123                 //proj.glow_size = 20;
124
125                 proj.effects = EF_LOWPRECISION;
126                 proj.flags = FL_PROJECTILE;
127                 proj.colormod = proj_color;
128                 counter = counter + 1;
129         }
130 }
131
132 void W_Crylink_Attack2 (void)
133 {
134         local float counter, shots;
135         local entity proj;
136
137         if not(self.items & IT_UNLIMITED_AMMO)
138                 self.ammo_cells = self.ammo_cells - cvar("g_balance_crylink_secondary_ammo");
139
140         W_SetupShot (self, '25 8 -8', FALSE, 2, "weapons/crylink_fire.wav");
141
142         shots = cvar("g_balance_crylink_secondary_shots");
143         pointparticles(particleeffectnum("crylink_muzzleflash"), w_shotorg, w_shotdir * 1000, shots);
144         while (counter < shots)
145         {
146                 proj = spawn ();
147                 proj.realowner = proj.owner = self;
148                 proj.classname = "spike";
149                 proj.bot_dodge = TRUE;
150                 proj.bot_dodgerating = cvar("g_balance_crylink_secondary_damage");
151
152                 proj.movetype = MOVETYPE_BOUNCEMISSILE;
153                 proj.solid = SOLID_BBOX;
154                 proj.projectiledeathtype = WEP_CRYLINK | HITTYPE_SECONDARY;
155                 //proj.gravity = 0.001;
156
157                 setmodel (proj, "models/plasmatrail.mdl"); // precision set below
158                 setsize (proj, '0 0 0', '0 0 0');
159                 setorigin (proj, w_shotorg);
160
161                 proj.velocity = (w_shotdir + (((counter + 0.5) / shots) * 2 - 1) * v_right * cvar("g_balance_crylink_secondary_spread")) * cvar("g_balance_crylink_secondary_speed");
162                 W_SetupProjectileVelocity(proj);
163                 proj.touch = W_Crylink_Touch2;
164                 if(counter == (shots - 1) / 2)
165                         SUB_SetFade(proj, time + cvar("g_balance_crylink_secondary_middle_lifetime"), cvar("g_balance_crylink_secondary_middle_fadetime"));
166                 else
167                         SUB_SetFade(proj, time + cvar("g_balance_crylink_secondary_line_lifetime"), cvar("g_balance_crylink_secondary_line_fadetime"));
168                 proj.cnt = cvar("g_balance_crylink_secondary_bounces");
169                 proj.scale = 1 + 1 * proj.cnt;
170
171                 proj.angles = vectoangles (proj.velocity);
172
173                 //proj.glow_size = 20;
174
175                 proj.effects = EF_LOWPRECISION;
176                 proj.flags = FL_PROJECTILE;
177                 proj.colormod = proj_color;
178                 counter = counter + 1;
179         }
180 }
181
182
183 /*
184 // experimental lightning gun
185 void W_Crylink_Attack3 (void)
186 {
187         if not(self.items & IT_UNLIMITED_AMMO)
188                 self.ammo_cells = self.ammo_cells - cvar("g_balance_crylink_primary_ammo");
189         W_SetupShot (self, '25 8 -8', TRUE, 0, "weapons/crylink_fire.wav");
190
191         traceline_antilag(self, w_shotorg, w_shotorg + w_shotdir * 1000, FALSE, self, self.ping * 0.001);
192
193         pointparticles(particleeffectnum("lightning_muzzleflash", w_shotorg, w_shotdir * 1000, 1);
194         pointparticles(particleeffectnum("lightning_impact", trace_endpos, trace_plane_normal * 1000, 1);
195         trailparticles(world, particleeffectnum("lightning_beam", w_shotorg, trace_endpos);
196
197         if (trace_fraction < 1)
198                 Damage(trace_ent, self, self, cvar("g_balance_crylink_primary_damage"), WEP_CRYLINK | HITTYPE_SECONDARY, trace_endpos, '0 0 0');
199 }
200 */
201
202 void spawnfunc_weapon_crylink (void)
203 {
204         weapon_defaultspawnfunc(WEP_CRYLINK);
205 }
206
207 float w_crylink(float req)
208 {
209         if (req == WR_AIM)
210         {
211                 if (random() > 0.15)
212                         self.BUTTON_ATCK = bot_aim(cvar("g_balance_crylink_primary_speed"), 0, cvar("g_balance_crylink_primary_middle_lifetime"), FALSE);
213                 else
214                         self.BUTTON_ATCK2 = bot_aim(cvar("g_balance_crylink_secondary_speed"), 0, cvar("g_balance_crylink_secondary_middle_lifetime"), FALSE);
215         }
216         else if (req == WR_THINK)
217         {
218                 if (self.BUTTON_ATCK)
219                 if (weapon_prepareattack(0, cvar("g_balance_crylink_primary_refire")))
220                 {
221                         W_Crylink_Attack();
222                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_crylink_primary_animtime"), w_ready);
223                 }
224                 if (self.BUTTON_ATCK2)
225                 if (weapon_prepareattack(1, cvar("g_balance_crylink_secondary_refire")))
226                 {
227                         W_Crylink_Attack2();
228                         weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_crylink_secondary_animtime"), w_ready);
229                 }
230         }
231         else if (req == WR_PRECACHE)
232         {
233                 precache_model ("models/plasma.mdl");
234                 precache_model ("models/plasmatrail.mdl");
235                 precache_model ("models/weapons/g_crylink.md3");
236                 precache_model ("models/weapons/v_crylink.md3");
237                 precache_model ("models/weapons/w_crylink.zym");
238                 precache_sound ("weapons/crylink_fire.wav");
239         }
240         else if (req == WR_SETUP)
241                 weapon_setup(WEP_CRYLINK);
242         else if (req == WR_CHECKAMMO1)
243                 return self.ammo_cells >= cvar("g_balance_crylink_primary_ammo");
244         else if (req == WR_CHECKAMMO2)
245                 return self.ammo_cells >= cvar("g_balance_crylink_secondary_ammo");
246         else if (req == WR_SUICIDEMESSAGE)
247         {
248                 w_deathtypestring = "succeeded at self-destructing himself with the Crylink";
249         }
250         else if (req == WR_KILLMESSAGE)
251         {
252                 if(w_deathtype & HITTYPE_BOUNCE)
253                         w_deathtypestring = "could not hide from #'s Crylink"; // unchecked: SPLASH (SECONDARY can't be)
254                 else if(w_deathtype & HITTYPE_SPLASH)
255                         w_deathtypestring = "was too close to #'s Crylink"; // unchecked: SECONDARY
256                 else
257                         w_deathtypestring = "took a close look at #'s Crylink"; // unchecked: SECONDARY
258         }
259         return TRUE;
260 };