]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/weapons/w_shockwave.qc
Merge remote-tracking branch 'origin/master' into samual/weapons
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / w_shockwave.qc
1 #ifdef REGISTER_WEAPON
2 REGISTER_WEAPON(
3 /* WEP_##id */ SHOCKWAVE,
4 /* function */ W_Shockwave,
5 /* ammotype */ IT_SHELLS,
6 /* impulse  */ 2,
7 /* flags    */ WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN,
8 /* rating   */ BOT_PICKUP_RATING_LOW,
9 /* model    */ "shotgun",
10 /* netname  */ "shockwave",
11 /* fullname */ _("Shockwave")
12 );
13 #else
14 #ifdef SVQC
15 void spawnfunc_weapon_shockwave()
16 {
17         if(autocvar_sv_q3acompat_machineshockwaveswap)
18         if(self.classname != "droppedweapon")
19         {
20                 weapon_defaultspawnfunc(WEP_UZI);
21                 return;
22         }
23         weapon_defaultspawnfunc(WEP_SHOCKWAVE);
24 }
25 .float swing_prev;
26 .entity swing_alreadyhit;
27 .float shockwave_pelletstime;
28 entity shockwave_hit[32];
29 float shockwave_hit_damage[32];
30 vector shockwave_hit_force[32];
31
32 // LEGACY ATTACK MODE: Scattered bullets
33 void W_Shockwave_Pellets(void)
34 {
35         float sc;
36         float ammoamount;
37         float bullets;
38         float d;
39         float f;
40         float spread;
41         float bulletspeed;
42         float bulletconstant;
43         entity flash;
44
45         ammoamount = autocvar_g_balance_shockwave_pellets_ammo;
46         bullets = autocvar_g_balance_shockwave_pellets_bullets;
47         d = autocvar_g_balance_shockwave_pellets_damage;
48         f = autocvar_g_balance_shockwave_pellets_force;
49         spread = autocvar_g_balance_shockwave_pellets_spread;
50         bulletspeed = autocvar_g_balance_shockwave_pellets_speed;
51         bulletconstant = autocvar_g_balance_shockwave_pellets_bulletconstant;
52
53         W_DecreaseAmmo(ammo_shells, ammoamount, autocvar_g_balance_shockwave_reload_ammo);
54
55         W_SetupShot (self, autocvar_g_antilag_bullets && bulletspeed >= autocvar_g_antilag_bullets, 5, "weapons/shockwave_fire.wav", CH_WEAPON_A, d * bullets);
56         for (sc = 0;sc < bullets;sc = sc + 1)
57                 fireBallisticBullet(w_shotorg, w_shotdir, spread, bulletspeed, 5, d, f, WEP_SHOCKWAVE, 0, 1, bulletconstant);
58         endFireBallisticBullet();
59
60         pointparticles(particleeffectnum("shockwave_muzzleflash"), w_shotorg, w_shotdir * 1000, autocvar_g_balance_shockwave_pellets_ammo);
61
62         // casing code
63         if (autocvar_g_casings >= 1)
64                 for (sc = 0;sc < ammoamount;sc = sc + 1)
65                         SpawnCasing (((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 30) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 1, self);
66
67         // muzzle flash for 1st person view
68         flash = spawn();
69         setmodel(flash, "models/uziflash.md3"); // precision set below
70         flash.think = SUB_Remove;
71         flash.nextthink = time + 0.06;
72         flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
73         W_AttachToShotorg(flash, '5 0 0');
74 }
75
76 // MELEE ATTACK MODE
77 void W_Shockwave_Melee_Think()
78 {
79         // declarations
80         float i, f, swing, swing_factor, swing_damage, meleetime, is_player;
81         entity target_victim;
82         vector targpos;
83
84         if(!self.cnt) // set start time of melee
85         {
86                 self.cnt = time; 
87                 W_PlayStrengthSound(self.realowner);
88         }
89
90         makevectors(self.realowner.v_angle); // update values for v_* vectors
91         
92         // calculate swing percentage based on time
93         meleetime = autocvar_g_balance_laser_melee_time * W_WeaponRateFactor();
94         swing = bound(0, (self.cnt + meleetime - time) / meleetime, 10);
95         f = ((1 - swing) * autocvar_g_balance_laser_melee_traces);
96         
97         // check to see if we can still continue, otherwise give up now
98         if((self.realowner.deadflag != DEAD_NO) && autocvar_g_balance_laser_melee_no_doubleslap)
99         {
100                 remove(self);
101                 return;
102         }
103         
104         // if okay, perform the traces needed for this frame 
105         for(i=self.swing_prev; i < f; ++i)
106         {
107                 swing_factor = ((1 - (i / autocvar_g_balance_laser_melee_traces)) * 2 - 1);
108                 
109                 targpos = (self.realowner.origin + self.realowner.view_ofs 
110                         + (v_forward * autocvar_g_balance_laser_melee_range)
111                         + (v_up * swing_factor * autocvar_g_balance_laser_melee_swing_up)
112                         + (v_right * swing_factor * autocvar_g_balance_laser_melee_swing_side));
113
114                 WarpZone_traceline_antilag(self.realowner, self.realowner.origin + self.realowner.view_ofs, targpos, FALSE, self.realowner, ANTILAG_LATENCY(self.realowner));
115                 
116                 // draw lightning beams for debugging
117                 te_lightning2(world, targpos, self.realowner.origin + self.realowner.view_ofs + v_forward * 5 - v_up * 5); 
118                 te_customflash(targpos, 40,  2, '1 1 1');
119                 
120                 is_player = (trace_ent.classname == "player" || trace_ent.classname == "body");
121
122                 if((trace_fraction < 1) // if trace is good, apply the damage and remove self
123                         && (trace_ent.takedamage == DAMAGE_AIM)  
124                         && (trace_ent != self.swing_alreadyhit)
125                         && (is_player || autocvar_g_balance_laser_melee_nonplayerdamage))
126                 {
127                         target_victim = trace_ent; // so it persists through other calls
128                         
129                         if(is_player) // this allows us to be able to nerf the non-player damage done in e.g. assault or onslaught.
130                                 swing_damage = (autocvar_g_balance_laser_melee_damage * min(1, swing_factor + 1));
131                         else
132                                 swing_damage = (autocvar_g_balance_laser_melee_nonplayerdamage * min(1, swing_factor + 1));
133                         
134                         //print(strcat(self.realowner.netname, " hitting ", target_victim.netname, " with ", strcat(ftos(swing_damage), " damage (factor: ", ftos(swing_factor), ") at "), ftos(time), " seconds.\n"));
135                         
136                         Damage(target_victim, self.realowner, self.realowner, 
137                                 swing_damage, WEP_SHOCKWAVE | HITTYPE_SECONDARY, 
138                                 self.realowner.origin + self.realowner.view_ofs, 
139                                 v_forward * autocvar_g_balance_laser_melee_force);
140                                 
141                         if(accuracy_isgooddamage(self.realowner, target_victim)) { accuracy_add(self.realowner, WEP_SHOCKWAVE, 0, swing_damage); }
142                         
143                         if(autocvar_g_balance_laser_melee_multihit) // allow multiple hits with one swing, but not against the same player twice.
144                         {
145                                 self.swing_alreadyhit = target_victim;
146                                 continue; // move along to next trace
147                         }
148                         else
149                         {
150                                 remove(self);
151                                 return;
152                         }
153                 }
154         }
155         
156         if(time >= self.cnt + meleetime)
157         {
158                 // melee is finished
159                 remove(self);
160                 return;
161         }
162         else
163         {
164                 // set up next frame 
165                 self.swing_prev = i;
166                 self.nextthink = time;
167         }
168 }
169
170 void W_Shockwave_Melee()
171 {
172         sound(self, CH_WEAPON_A, "weapons/shotgun_melee.wav", VOL_BASE, ATTN_NORM);
173         weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_laser_melee_animtime, w_ready);
174
175         entity meleetemp;
176         meleetemp = spawn();
177         meleetemp.owner = meleetemp.realowner = self;
178         meleetemp.think = W_Shockwave_Melee_Think;
179         meleetemp.nextthink = time + autocvar_g_balance_shockwave_melee_delay * W_WeaponRateFactor();
180         W_SetupShot_Range(self, TRUE, 0, "", 0, autocvar_g_balance_shockwave_melee_damage, autocvar_g_balance_shockwave_melee_range);
181 }
182
183 // SHOCKWAVE ATTACK MODE
184 float W_Shockwave_Attack_CheckSpread(
185         vector targetorg,
186         vector nearest_on_line,
187         vector sw_shotorg,
188         vector attack_endpos)
189 {
190         float spreadlimit;
191         float distance_of_attack = vlen(sw_shotorg - attack_endpos);
192         float distance_from_line = vlen(targetorg - nearest_on_line);
193         
194         spreadlimit = (distance_of_attack ? min(1, (vlen(sw_shotorg - nearest_on_line) / distance_of_attack)) : 1);
195         spreadlimit = (autocvar_g_balance_laser_shockwave_spread_min * (1 - spreadlimit) + autocvar_g_balance_laser_shockwave_spread_max * spreadlimit);
196         
197         if(
198                 (spreadlimit && (distance_from_line <= spreadlimit))
199                 &&
200                 ((vlen(normalize(targetorg - sw_shotorg) - normalize(attack_endpos - sw_shotorg)) * RAD2DEG) <= 90)
201         )
202                 { return bound(0, (distance_from_line / spreadlimit), 1); }
203         else
204                 { return FALSE; }
205 }
206
207 float W_Shockwave_Attack_IsVisible(
208         entity head,
209         vector nearest_on_line,
210         vector sw_shotorg,
211         vector attack_endpos)
212 {
213         vector nearest_to_attacker = head.WarpZone_findradius_nearest;
214         vector center = (head.origin + (head.mins + head.maxs) * 0.5);
215         vector corner;
216         float i;
217
218         // STEP ONE: Check if the nearest point is clear
219         if(W_Shockwave_Attack_CheckSpread(nearest_to_attacker, nearest_on_line, sw_shotorg, attack_endpos))
220         {
221                 WarpZone_TraceLine(sw_shotorg, nearest_to_attacker, MOVE_NOMONSTERS, self);
222                 if(trace_fraction == 1) { return TRUE; } // yes, the nearest point is clear and we can allow the damage
223         }
224
225         // STEP TWO: Check if shotorg to center point is clear
226         if(W_Shockwave_Attack_CheckSpread(center, nearest_on_line, sw_shotorg, attack_endpos))
227         {
228                 WarpZone_TraceLine(sw_shotorg, center, MOVE_NOMONSTERS, self);
229                 if(trace_fraction == 1) { return TRUE; } // yes, the center point is clear and we can allow the damage
230         }
231
232         // STEP THREE: Check each corner to see if they are clear
233         for(i=1; i<=8; ++i)
234         {
235                 corner = get_corner_position(head, i);
236                 if(W_Shockwave_Attack_CheckSpread(corner, nearest_on_line, sw_shotorg, attack_endpos))
237                 {
238                         WarpZone_TraceLine(sw_shotorg, corner, MOVE_NOMONSTERS, self);
239                         if(trace_fraction == 1) { return TRUE; } // yes, this corner is clear and we can allow the damage
240                 }
241         }
242
243         return FALSE;
244 }
245
246 float W_Shockwave_Attack_CheckHit(
247         float queue,
248         entity head,
249         vector final_force,
250         float final_damage)
251 {
252         if not(head) { return FALSE; }
253         float i;
254
255         ++queue;
256         
257         for(i = 1; i <= queue; ++i)
258         {
259                 if(shockwave_hit[i] == head)
260                 {
261                         if(vlen(final_force) > vlen(shockwave_hit_force[i])) { shockwave_hit_force[i] = final_force; }
262                         if(final_damage > shockwave_hit_damage[i]) { shockwave_hit_damage[i] = final_damage; }
263                         return FALSE;
264                 }
265         }
266
267         shockwave_hit[queue] = head;
268         shockwave_hit_force[queue] = final_force;
269         shockwave_hit_damage[queue] = final_damage;
270         return TRUE;
271 }
272
273 void W_Shockwave_Attack()
274 {
275         // declarations
276         float multiplier, multiplier_from_accuracy, multiplier_from_distance;
277         float final_damage; //, final_spread;
278         vector final_force, center, vel;
279         entity head, next;
280
281         float i, queue = 0;
282         
283         // set up the shot direction
284         W_SetupShot(self, FALSE, 3, "weapons/lasergun_fire.wav", CH_WEAPON_B, autocvar_g_balance_laser_shockwave_damage);
285         vector attack_endpos = (w_shotorg + (w_shotdir * autocvar_g_balance_laser_shockwave_distance));
286         WarpZone_TraceLine(w_shotorg, attack_endpos, MOVE_NOMONSTERS, self);
287         vector attack_hitpos = trace_endpos;
288         float distance_to_end = vlen(w_shotorg - attack_endpos);
289         float distance_to_hit = vlen(w_shotorg - attack_hitpos);
290         //entity transform = WarpZone_trace_transform;
291
292         // do the firing effect now
293         SendCSQCShockwaveParticle(attack_endpos);
294         Damage_DamageInfo(attack_hitpos, autocvar_g_balance_laser_shockwave_splash_damage, autocvar_g_balance_laser_shockwave_splash_edgedamage, autocvar_g_balance_laser_shockwave_splash_radius, w_shotdir * autocvar_g_balance_laser_shockwave_splash_force, WEP_SHOCKWAVE, 0, self);
295
296         // splash damage/jumping trace
297         head = WarpZone_FindRadius(attack_hitpos, max(autocvar_g_balance_laser_shockwave_splash_radius, autocvar_g_balance_laser_shockwave_jump_radius), FALSE);
298         while(head)
299         {
300                 next = head.chain;
301
302                 if(head.takedamage)
303                 {
304                         center = PLAYER_CENTER(head);
305
306                         float distance_to_head = vlen(attack_hitpos - head.WarpZone_findradius_nearest);
307                         
308                         if((head == self) && (distance_to_head <= autocvar_g_balance_laser_shockwave_jump_radius))
309                         {
310                                 multiplier_from_accuracy = (1 - (distance_to_head ? min(1, (distance_to_head / autocvar_g_balance_laser_shockwave_jump_radius)) : 0));
311                                 multiplier_from_distance = (1 - (distance_to_hit ? min(1, (distance_to_hit / distance_to_end)) : 0));
312                                 multiplier = max(autocvar_g_balance_laser_shockwave_jump_multiplier_min, ((multiplier_from_accuracy * autocvar_g_balance_laser_shockwave_jump_multiplier_accuracy) + (multiplier_from_distance * autocvar_g_balance_laser_shockwave_jump_multiplier_distance)));
313
314                                 final_force = ((normalize(center - attack_hitpos) * autocvar_g_balance_laser_shockwave_jump_force) * multiplier);
315                                 vel = head.velocity; vel_z = 0;
316                                 vel = normalize(vel) * bound(0, vlen(vel) / autocvar_sv_maxspeed, 1) * autocvar_g_balance_laser_shockwave_jump_force_velocitybias;
317                                 final_force = (vlen(final_force) * normalize(normalize(final_force) + vel));
318                                 final_force_z *= autocvar_g_balance_laser_shockwave_jump_force_zscale;
319                                 final_damage = (autocvar_g_balance_laser_shockwave_jump_damage * multiplier + autocvar_g_balance_laser_shockwave_jump_edgedamage * (1 - multiplier));
320
321                                 Damage(head, self, self, final_damage, WEP_SHOCKWAVE, head.origin, final_force);
322                                 //print("SELF HIT: multiplier = ", ftos(multiplier), strcat(", damage = ", ftos(final_damage), ", force = ", ftos(vlen(final_force))),"... multiplier_from_accuracy = ", ftos(multiplier_from_accuracy), ", multiplier_from_distance = ", ftos(multiplier_from_distance), ".\n");
323                         }
324                         else if (distance_to_head <= autocvar_g_balance_laser_shockwave_splash_radius)
325                         {       
326                                 multiplier_from_accuracy = (1 - (distance_to_head ? min(1, (distance_to_head / autocvar_g_balance_laser_shockwave_splash_radius)) : 0));
327                                 multiplier_from_distance = (1 - (distance_to_hit ? min(1, (distance_to_hit / distance_to_end)) : 0));
328                                 multiplier = max(autocvar_g_balance_laser_shockwave_splash_multiplier_min, ((multiplier_from_accuracy * autocvar_g_balance_laser_shockwave_splash_multiplier_accuracy) + (multiplier_from_distance * autocvar_g_balance_laser_shockwave_splash_multiplier_distance)));
329
330                                 final_force = normalize(center - (attack_hitpos - (w_shotdir * autocvar_g_balance_laser_shockwave_splash_force_forwardbias)));
331                                 //te_lightning2(world, attack_hitpos, (attack_hitpos + (final_force * 200)));
332                                 final_force = ((final_force * autocvar_g_balance_laser_shockwave_splash_force) * multiplier);
333                                 final_force_z *= autocvar_g_balance_laser_shockwave_force_zscale;
334                                 final_damage = (autocvar_g_balance_laser_shockwave_splash_damage * multiplier + autocvar_g_balance_laser_shockwave_splash_edgedamage * (1 - multiplier));
335
336                                 if(W_Shockwave_Attack_CheckHit(queue, head, final_force, final_damage)) { ++queue; }
337                                 //print("SPLASH HIT: multiplier = ", ftos(multiplier), strcat(", damage = ", ftos(final_damage), ", force = ", ftos(vlen(final_force))),"... multiplier_from_accuracy = ", ftos(multiplier_from_accuracy), ", multiplier_from_distance = ", ftos(multiplier_from_distance), ".\n");
338                         }
339                 }
340                 head = next;
341         }
342
343         // cone damage trace
344         head = WarpZone_FindRadius(w_shotorg, autocvar_g_balance_laser_shockwave_distance, FALSE);
345         while(head)
346         {
347                 next = head.chain;
348                 
349                 if((head != self) && head.takedamage)
350                 {
351                         // if it's a player, use the view origin as reference (stolen from RadiusDamage functions in g_damage.qc) 
352                         center = CENTER_OR_VIEWOFS(head);
353
354                         // find the closest point on the enemy to the center of the attack
355                         float ang; // angle between shotdir and h
356                         float h; // hypotenuse, which is the distance between attacker to head
357                         float a; // adjacent side, which is the distance between attacker and the point on w_shotdir that is closest to head.origin
358                         
359                         h = vlen(center - self.origin);
360                         ang = acos(dotproduct(normalize(center - self.origin), w_shotdir));
361                         a = h * cos(ang);
362
363                         vector nearest_on_line = (w_shotorg + a * w_shotdir);
364                         vector nearest_to_attacker = WarpZoneLib_NearestPointOnBox(center + head.mins, center + head.maxs, nearest_on_line);
365                         float distance_to_target = vlen(w_shotorg - nearest_to_attacker); // todo: use the findradius function for this
366
367                         if((distance_to_target <= autocvar_g_balance_laser_shockwave_distance) 
368                                 && (W_Shockwave_Attack_IsVisible(head, nearest_on_line, w_shotorg, attack_endpos)))
369                         {
370                                 multiplier_from_accuracy = (1 - W_Shockwave_Attack_CheckSpread(nearest_to_attacker, nearest_on_line, w_shotorg, attack_endpos));
371                                 multiplier_from_distance = (1 - (distance_to_hit ? min(1, (distance_to_target / distance_to_end)) : 0));
372                                 multiplier = max(autocvar_g_balance_laser_shockwave_multiplier_min, ((multiplier_from_accuracy * autocvar_g_balance_laser_shockwave_multiplier_accuracy) + (multiplier_from_distance * autocvar_g_balance_laser_shockwave_multiplier_distance)));
373
374                                 final_force = normalize(center - (nearest_on_line - (w_shotdir * autocvar_g_balance_laser_shockwave_force_forwardbias)));
375                                 //te_lightning2(world, nearest_on_line, (attack_hitpos + (final_force * 200)));
376                                 final_force = ((final_force * autocvar_g_balance_laser_shockwave_force) * multiplier);
377                                 final_force_z *= autocvar_g_balance_laser_shockwave_force_zscale;
378                                 final_damage = (autocvar_g_balance_laser_shockwave_damage * multiplier + autocvar_g_balance_laser_shockwave_edgedamage * (1 - multiplier));
379
380                                 if(W_Shockwave_Attack_CheckHit(queue, head, final_force, final_damage)) { ++queue; }
381                                 //print("CONE HIT: multiplier = ", ftos(multiplier), strcat(", damage = ", ftos(final_damage), ", force = ", ftos(vlen(final_force))),"... multiplier_from_accuracy = ", ftos(multiplier_from_accuracy), ", multiplier_from_distance = ", ftos(multiplier_from_distance), ".\n");
382                         }
383                 }
384                 head = next;
385         }
386
387         for(i = 1; i <= queue; ++i)
388         {
389                 head = shockwave_hit[i];
390                 final_force = shockwave_hit_force[i];
391                 final_damage = shockwave_hit_damage[i];
392                 
393                 Damage(head, self, self, final_damage, WEP_SHOCKWAVE, head.origin, final_force);
394                 print("SHOCKWAVE by ", self.netname, ": damage = ", ftos(final_damage), ", force = ", ftos(vlen(final_force)), ".\n");
395                 
396                 shockwave_hit[i] = world;
397                 shockwave_hit_force[i] = '0 0 0';
398                 shockwave_hit_damage[i] = 0;
399         }
400         //print("queue was ", ftos(queue), ".\n\n");
401 }
402
403 float W_Shockwave(float req)
404 {
405         float ammo_amount;
406         
407         switch(req)
408         {
409                 case WR_AIM:
410                 {
411                         if(vlen(self.origin-self.enemy.origin) <= autocvar_g_balance_shockwave_secondary_melee_range)
412                                 self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, FALSE);
413                         else
414                         {
415                                 if(autocvar_g_antilag_bullets)
416                                         self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, FALSE);
417                                 else
418                                         self.BUTTON_ATCK = bot_aim(autocvar_g_balance_shockwave_pellets_speed, 0, 0.001, FALSE);
419                         }
420                         
421                         return TRUE;
422                 }
423                 case WR_THINK:
424                 {
425                         if(autocvar_g_balance_shockwave_reload_ammo && self.clip_load < autocvar_g_balance_shockwave_pellets_ammo) // forced reload
426                         {
427                                 // don't force reload an empty shockwave if its melee attack is active
428                                 if not(autocvar_g_balance_shockwave_secondary && self.ammo_shells < autocvar_g_balance_shockwave_pellets_ammo)
429                                         WEP_ACTION(self.weapon, WR_RELOAD);
430                         }
431                         else
432                         {
433                                 if (self.BUTTON_ATCK)
434                                 {
435                                         if (time >= self.shockwave_pelletstime) // handle refire separately so the secondary can be fired straight after a primary
436                                         {
437                                                 if(weapon_prepareattack(0, autocvar_g_balance_shockwave_pellets_animtime))
438                                                 {
439                                                         W_Shockwave_Attack();
440                                                         self.shockwave_pelletstime = time + autocvar_g_balance_shockwave_pellets_refire * W_WeaponRateFactor();
441                                                         weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_shockwave_pellets_animtime, w_ready);
442                                                 }
443                                         }
444                                 }
445                         }
446                         if (self.clip_load >= 0) // we are not currently reloading
447                         if (!self.crouch) // no crouchmelee please
448                         if (self.BUTTON_ATCK2 && autocvar_g_balance_shockwave_secondary)
449                         if (weapon_prepareattack(1, autocvar_g_balance_shockwave_secondary_refire))
450                         {
451                                 // attempt forcing playback of the anim by switching to another anim (that we never play) here...
452                                 weapon_thinkf(WFRAME_FIRE1, 0, W_Shockwave_Melee);
453                         }
454                         
455                         return TRUE;
456                 }
457                 case WR_INIT:
458                 {
459                         precache_model ("models/uziflash.md3");
460                         precache_model ("models/weapons/g_shockwave.md3");
461                         precache_model ("models/weapons/v_shockwave.md3");
462                         precache_model ("models/weapons/h_shockwave.iqm");
463                         precache_sound ("misc/itempickup.wav");
464                         precache_sound ("weapons/shockwave_fire.wav");
465                         precache_sound ("weapons/shockwave_melee.wav");
466                         return TRUE;
467                 }
468                 case WR_SETUP:
469                 {
470                         self.current_ammo = ammo_shells;
471                         return TRUE;
472                 }
473                 case WR_CHECKAMMO1:
474                 {
475                         ammo_amount = self.ammo_shells >= autocvar_g_balance_shockwave_pellets_ammo;
476                         ammo_amount += self.(weapon_load[WEP_SHOCKWAVE]) >= autocvar_g_balance_shockwave_pellets_ammo;
477                         return ammo_amount;
478                 }
479                 case WR_CHECKAMMO2:
480                 {
481                         // melee attack is always available
482                         return TRUE;
483                 }
484                 case WR_RELOAD:
485                 {
486                         W_Reload(autocvar_g_balance_shockwave_pellets_ammo, "weapons/reload.wav");
487                         return TRUE;
488                 }
489                 case WR_SUICIDEMESSAGE:
490                 {
491                         return WEAPON_THINKING_WITH_PORTALS;
492                 }
493                 case WR_KILLMESSAGE:
494                 {
495                         if(w_deathtype & HITTYPE_SECONDARY)
496                                 return WEAPON_SHOCKWAVE_MURDER_SLAP;
497                         else
498                                 return WEAPON_SHOCKWAVE_MURDER;
499                 }
500         }
501         return TRUE;
502 }
503 #endif
504 #ifdef CSQC
505 .float prevric;
506 float W_Shockwave(float req)
507 {
508         switch(req)
509         {
510                 case WR_IMPACTEFFECT:
511                 {
512                         vector org2;
513                         org2 = w_org + w_backoff * 2;
514                         pointparticles(particleeffectnum("shockwave_impact"), org2, w_backoff * 1000, 1);
515                         if(!w_issilent && time - self.prevric > 0.25)
516                         {
517                                 if(w_random < 0.0165)
518                                         sound(self, CH_SHOTS, "weapons/ric1.wav", VOL_BASE, ATTEN_NORM);
519                                 else if(w_random < 0.033)
520                                         sound(self, CH_SHOTS, "weapons/ric2.wav", VOL_BASE, ATTEN_NORM);
521                                 else if(w_random < 0.05)
522                                         sound(self, CH_SHOTS, "weapons/ric3.wav", VOL_BASE, ATTEN_NORM);
523                                 self.prevric = time;
524                         }
525                         return TRUE;
526                 }
527                 case WR_INIT:
528                 {
529                         precache_sound("weapons/ric1.wav");
530                         precache_sound("weapons/ric2.wav");
531                         precache_sound("weapons/ric3.wav");
532                         return TRUE;
533                 }
534         }
535         return TRUE;
536 }
537 #endif
538 #endif