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