3 /* WEP_##id */ SHOCKWAVE,
4 /* function */ W_Shockwave,
5 /* ammotype */ IT_SHELLS,
7 /* flags */ WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN,
8 /* rating */ BOT_PICKUP_RATING_LOW,
10 /* netname */ "shockwave",
11 /* fullname */ _("Shockwave")
14 #define SHOCKWAVE_SETTINGS(w_cvar,w_prop) \
15 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_damage) \
16 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_distance) \
17 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_edgedamage) \
18 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_force) \
19 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_force_forwardbias) \
20 /*w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_force_velocitybias)*/ \
21 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_force_zscale) \
22 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_jump_damage) \
23 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_jump_edgedamage) \
24 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_jump_force) \
25 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_jump_force_velocitybias) \
26 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_jump_force_zscale) \
27 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_jump_multiplier_accuracy) \
28 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_jump_multiplier_distance) \
29 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_jump_multiplier_min) \
30 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_jump_radius) \
31 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_multiplier_accuracy) \
32 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_multiplier_distance) \
33 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_multiplier_min) \
34 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_splash_damage) \
35 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_splash_edgedamage) \
36 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_splash_force) \
37 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_splash_force_forwardbias) \
38 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_splash_multiplier_accuracy) \
39 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_splash_multiplier_distance) \
40 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_splash_multiplier_min) \
41 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_splash_radius) \
42 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_spread_max) \
43 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_spread_min) \
44 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, melee_animtime) \
45 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, melee_damage) \
46 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, melee_delay) \
47 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, melee_force) \
48 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, melee_multihit) \
49 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, melee_no_doubleslap) \
50 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, melee_nonplayerdamage) \
51 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, melee_range) \
52 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, melee_refire) \
53 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, melee_swing_side) \
54 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, melee_swing_up) \
55 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, melee_time) \
56 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, melee_traces) \
57 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, pellets_ammo) \
58 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, pellets_animtime) \
59 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, pellets_bulletconstant) \
60 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, pellets_bullets) \
61 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, pellets_damage) \
62 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, pellets_force) \
63 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, pellets_refire) \
64 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, pellets_speed) \
65 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, pellets_spread) \
66 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, primary) \
67 w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, secondary) \
68 w_prop(WEP_SHOCKWAVE, shockwave, float, reloading_ammo, reload_ammo) \
69 w_prop(WEP_SHOCKWAVE, shockwave, float, reloading_time, reload_time) \
70 w_prop(WEP_SHOCKWAVE, shockwave, float, switchdelay_raise, switchdelay_raise) \
71 w_prop(WEP_SHOCKWAVE, shockwave, float, switchdelay_drop, switchdelay_drop) \
72 w_prop(WEP_SHOCKWAVE, shockwave, string, weaponreplace, weaponreplace) \
73 w_prop(WEP_SHOCKWAVE, shockwave, float, weaponstart, weaponstart)
76 SHOCKWAVE_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
80 void spawnfunc_weapon_shockwave()
82 //if(autocvar_sv_q3acompat_machineshockwaveswap)
83 if(autocvar_sv_q3acompat_machineshotgunswap)
84 if(self.classname != "droppedweapon")
86 weapon_defaultspawnfunc(WEP_UZI);
89 weapon_defaultspawnfunc(WEP_SHOCKWAVE);
93 .entity swing_alreadyhit;
94 .float shockwave_pelletstime;
95 entity shockwave_hit[32];
96 float shockwave_hit_damage[32];
97 vector shockwave_hit_force[32];
99 // LEGACY ATTACK MODE: Scattered bullets
100 void W_Shockwave_Pellets(void)
105 W_DecreaseAmmo(ammo_shells, WEP_CVAR(shockwave, pellets_ammo), WEP_CVAR(shockwave, reload_ammo));
107 W_SetupShot(self, TRUE, 5, "weapons/shockwave_fire.wav", CH_WEAPON_A, WEP_CVAR(shockwave, pellets_damage) * WEP_CVAR(shockwave, pellets_bullets));
109 for(sc = 0; sc < WEP_CVAR(shockwave, pellets_bullets); ++sc)
114 WEP_CVAR(shockwave, pellets_spread),
115 WEP_CVAR(shockwave, pellets_speed),
117 WEP_CVAR(shockwave, pellets_damage),
118 WEP_CVAR(shockwave, pellets_force),
121 WEP_CVAR(shockwave, pellets_bulletconstant)
124 endFireBallisticBullet();
126 pointparticles(particleeffectnum("shockwave_muzzleflash"), w_shotorg, w_shotdir * 1000, WEP_CVAR(shockwave, pellets_ammo));
129 if(autocvar_g_casings >= 1)
131 for(sc = 0;sc < WEP_CVAR(shockwave, pellets_ammo); ++sc)
135 ((random () * 50 + 50) * v_right)
137 (v_forward * (random () * 25 + 25))
139 ((random () * 5 - 30) * v_up)
142 vectoangles(v_forward),
151 // muzzle flash for 1st person view
153 setmodel(flash, "models/uziflash.md3"); // precision set below
154 flash.think = SUB_Remove;
155 flash.nextthink = time + 0.06;
156 flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
157 W_AttachToShotorg(flash, '5 0 0');
161 void W_Shockwave_Melee_Think()
164 float i, f, swing, swing_factor, swing_damage, meleetime, is_player;
165 entity target_victim;
168 if(!self.cnt) // set start time of melee
171 W_PlayStrengthSound(self.realowner);
174 makevectors(self.realowner.v_angle); // update values for v_* vectors
176 // calculate swing percentage based on time
177 meleetime = WEP_CVAR(shockwave, melee_time) * W_WeaponRateFactor();
178 swing = bound(0, (self.cnt + meleetime - time) / meleetime, 10);
179 f = ((1 - swing) * WEP_CVAR(shockwave, melee_traces));
181 // check to see if we can still continue, otherwise give up now
182 if((self.realowner.deadflag != DEAD_NO) && WEP_CVAR(shockwave, melee_no_doubleslap))
188 // if okay, perform the traces needed for this frame
189 for(i=self.swing_prev; i < f; ++i)
191 swing_factor = ((1 - (i / WEP_CVAR(shockwave, melee_traces))) * 2 - 1);
193 targpos = (self.realowner.origin + self.realowner.view_ofs
194 + (v_forward * WEP_CVAR(shockwave, melee_range))
195 + (v_up * swing_factor * WEP_CVAR(shockwave, melee_swing_up))
196 + (v_right * swing_factor * WEP_CVAR(shockwave, melee_swing_side)));
198 WarpZone_traceline_antilag(self.realowner, self.realowner.origin + self.realowner.view_ofs, targpos, FALSE, self.realowner, ANTILAG_LATENCY(self.realowner));
200 // draw lightning beams for debugging
201 te_lightning2(world, targpos, self.realowner.origin + self.realowner.view_ofs + v_forward * 5 - v_up * 5);
202 te_customflash(targpos, 40, 2, '1 1 1');
204 is_player = (trace_ent.classname == "player" || trace_ent.classname == "body");
206 if((trace_fraction < 1) // if trace is good, apply the damage and remove self
207 && (trace_ent.takedamage == DAMAGE_AIM)
208 && (trace_ent != self.swing_alreadyhit)
209 && (is_player || WEP_CVAR(shockwave, melee_nonplayerdamage)))
211 target_victim = trace_ent; // so it persists through other calls
213 if(is_player) // this allows us to be able to nerf the non-player damage done in e.g. assault or onslaught.
214 swing_damage = (WEP_CVAR(shockwave, melee_damage * min(1, swing_factor + 1)));
216 swing_damage = (WEP_CVAR(shockwave, melee_nonplayerdamage * min(1, swing_factor + 1)));
218 //print(strcat(self.realowner.netname, " hitting ", target_victim.netname, " with ", strcat(ftos(swing_damage), " damage (factor: ", ftos(swing_factor), ") at "), ftos(time), " seconds.\n"));
220 Damage(target_victim, self.realowner, self.realowner,
221 swing_damage, WEP_SHOCKWAVE | HITTYPE_SECONDARY,
222 self.realowner.origin + self.realowner.view_ofs,
223 v_forward * WEP_CVAR(shockwave, melee_force));
225 if(accuracy_isgooddamage(self.realowner, target_victim)) { accuracy_add(self.realowner, WEP_SHOCKWAVE, 0, swing_damage); }
227 if(WEP_CVAR(shockwave, melee_multihit)) // allow multiple hits with one swing, but not against the same player twice.
229 self.swing_alreadyhit = target_victim;
230 continue; // move along to next trace
240 if(time >= self.cnt + meleetime)
250 self.nextthink = time;
254 void W_Shockwave_Melee()
256 sound(self, CH_WEAPON_A, "weapons/shotgun_melee.wav", VOL_BASE, ATTN_NORM);
257 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR(shockwave, melee_animtime), w_ready);
261 meleetemp.owner = meleetemp.realowner = self;
262 meleetemp.think = W_Shockwave_Melee_Think;
263 meleetemp.nextthink = time + WEP_CVAR(shockwave, melee_delay) * W_WeaponRateFactor();
264 W_SetupShot_Range(self, TRUE, 0, "", 0, WEP_CVAR(shockwave, melee_damage), WEP_CVAR(shockwave, melee_range));
267 // SHOCKWAVE ATTACK MODE
268 float W_Shockwave_Attack_CheckSpread(
270 vector nearest_on_line,
272 vector attack_endpos)
275 float distance_of_attack = vlen(sw_shotorg - attack_endpos);
276 float distance_from_line = vlen(targetorg - nearest_on_line);
278 spreadlimit = (distance_of_attack ? min(1, (vlen(sw_shotorg - nearest_on_line) / distance_of_attack)) : 1);
281 (WEP_CVAR(shockwave, blast_spread_min) * (1 - spreadlimit))
283 (WEP_CVAR(shockwave, blast_spread_max) * spreadlimit)
287 (spreadlimit && (distance_from_line <= spreadlimit))
289 ((vlen(normalize(targetorg - sw_shotorg) - normalize(attack_endpos - sw_shotorg)) * RAD2DEG) <= 90)
291 { return bound(0, (distance_from_line / spreadlimit), 1); }
296 float W_Shockwave_Attack_IsVisible(
298 vector nearest_on_line,
300 vector attack_endpos)
302 vector nearest_to_attacker = head.WarpZone_findradius_nearest;
303 vector center = (head.origin + (head.mins + head.maxs) * 0.5);
307 // STEP ONE: Check if the nearest point is clear
308 if(W_Shockwave_Attack_CheckSpread(nearest_to_attacker, nearest_on_line, sw_shotorg, attack_endpos))
310 WarpZone_TraceLine(sw_shotorg, nearest_to_attacker, MOVE_NOMONSTERS, self);
311 if(trace_fraction == 1) { return TRUE; } // yes, the nearest point is clear and we can allow the damage
314 // STEP TWO: Check if shotorg to center point is clear
315 if(W_Shockwave_Attack_CheckSpread(center, nearest_on_line, sw_shotorg, attack_endpos))
317 WarpZone_TraceLine(sw_shotorg, center, MOVE_NOMONSTERS, self);
318 if(trace_fraction == 1) { return TRUE; } // yes, the center point is clear and we can allow the damage
321 // STEP THREE: Check each corner to see if they are clear
324 corner = get_corner_position(head, i);
325 if(W_Shockwave_Attack_CheckSpread(corner, nearest_on_line, sw_shotorg, attack_endpos))
327 WarpZone_TraceLine(sw_shotorg, corner, MOVE_NOMONSTERS, self);
328 if(trace_fraction == 1) { return TRUE; } // yes, this corner is clear and we can allow the damage
335 float W_Shockwave_Attack_CheckHit(
341 if(!head) { return FALSE; }
346 for(i = 1; i <= queue; ++i)
348 if(shockwave_hit[i] == head)
350 if(vlen(final_force) > vlen(shockwave_hit_force[i])) { shockwave_hit_force[i] = final_force; }
351 if(final_damage > shockwave_hit_damage[i]) { shockwave_hit_damage[i] = final_damage; }
356 shockwave_hit[queue] = head;
357 shockwave_hit_force[queue] = final_force;
358 shockwave_hit_damage[queue] = final_damage;
362 void W_Shockwave_Attack()
365 float multiplier, multiplier_from_accuracy, multiplier_from_distance;
367 vector final_force, center, vel;
372 // set up the shot direction
373 W_SetupShot(self, FALSE, 3, "weapons/lasergun_fire.wav", CH_WEAPON_B, WEP_CVAR(shockwave, blast_damage));
374 vector attack_endpos = (w_shotorg + (w_shotdir * WEP_CVAR(shockwave, blast_distance)));
375 WarpZone_TraceLine(w_shotorg, attack_endpos, MOVE_NOMONSTERS, self);
376 vector attack_hitpos = trace_endpos;
377 float distance_to_end = vlen(w_shotorg - attack_endpos);
378 float distance_to_hit = vlen(w_shotorg - attack_hitpos);
379 //entity transform = WarpZone_trace_transform;
381 // do the firing effect now
382 //SendCSQCShockwaveParticle(attack_endpos); // WEAPONTODO
385 WEP_CVAR(shockwave, blast_splash_damage),
386 WEP_CVAR(shockwave, blast_splash_edgedamage),
387 WEP_CVAR(shockwave, blast_splash_radius),
388 w_shotdir * WEP_CVAR(shockwave, blast_splash_force),
394 // splash damage/jumping trace
395 head = WarpZone_FindRadius(
398 WEP_CVAR(shockwave, blast_splash_radius),
399 WEP_CVAR(shockwave, blast_jump_radius)
408 float distance_to_head = vlen(attack_hitpos - head.WarpZone_findradius_nearest);
410 if((head == self) && (distance_to_head <= WEP_CVAR(shockwave, blast_jump_radius)))
412 // ========================
413 // BLAST JUMP CALCULATION
414 // ========================
416 // calculate importance of distance and accuracy for this attack
417 multiplier_from_accuracy = (1 -
419 min(1, (distance_to_head / WEP_CVAR(shockwave, blast_jump_radius)))
424 multiplier_from_distance = (1 -
426 min(1, (distance_to_hit / distance_to_end))
433 WEP_CVAR(shockwave, blast_jump_multiplier_min),
435 (multiplier_from_accuracy * WEP_CVAR(shockwave, blast_jump_multiplier_accuracy))
437 (multiplier_from_distance * WEP_CVAR(shockwave, blast_jump_multiplier_distance))
441 // calculate damage from multiplier: 1 = "highest" damage, 0 = "lowest" edgedamage
444 (WEP_CVAR(shockwave, blast_jump_damage) * multiplier)
446 (WEP_CVAR(shockwave, blast_jump_edgedamage) * (1 - multiplier))
449 // figure out the direction of force
450 vel = normalize(combine_to_vector(head.velocity_x, head.velocity_y, 0));
453 bound(0, (vlen(vel) / autocvar_sv_maxspeed), 1)
455 WEP_CVAR(shockwave, blast_jump_force_velocitybias)
457 final_force = normalize((CENTER_OR_VIEWOFS(head) - attack_hitpos) + vel);
459 // now multiply the direction by force units
460 final_force *= (WEP_CVAR(shockwave, blast_jump_force) * multiplier);
461 final_force_z *= WEP_CVAR(shockwave, blast_jump_force_zscale);
463 // trigger damage with this calculated info
474 #ifdef DEBUG_SHOCKWAVE
476 "SELF HIT: multiplier = %f, damage = %f, force = %f... "
477 "multiplier_from_accuracy = %f, multiplier_from_distance = %f.\n",
481 multiplier_from_accuracy,
482 multiplier_from_distance
486 else if(distance_to_head <= WEP_CVAR(shockwave, blast_splash_radius))
488 // ==========================
489 // BLAST SPLASH CALCULATION
490 // ==========================
492 // calculate importance of distance and accuracy for this attack
493 multiplier_from_accuracy = (1 -
495 min(1, (distance_to_head / WEP_CVAR(shockwave, blast_splash_radius)))
500 multiplier_from_distance = (1 -
502 min(1, (distance_to_hit / distance_to_end))
509 WEP_CVAR(shockwave, blast_splash_multiplier_min),
511 (multiplier_from_accuracy * WEP_CVAR(shockwave, blast_splash_multiplier_accuracy))
513 (multiplier_from_distance * WEP_CVAR(shockwave, blast_splash_multiplier_distance))
517 // calculate damage from multiplier: 1 = "highest" damage, 0 = "lowest" edgedamage
520 (WEP_CVAR(shockwave, blast_splash_damage) * multiplier)
522 (WEP_CVAR(shockwave, blast_splash_edgedamage) * (1 - multiplier))
525 // figure out the direction of force
526 final_force = (w_shotdir * WEP_CVAR(shockwave, blast_splash_force_forwardbias));
527 final_force = normalize(CENTER_OR_VIEWOFS(head) - (attack_hitpos - final_force));
528 //te_lightning2(world, attack_hitpos, (attack_hitpos + (final_force * 200)));
530 // now multiply the direction by force units
531 final_force *= (WEP_CVAR(shockwave, blast_splash_force) * multiplier);
532 final_force_z *= WEP_CVAR(shockwave, blast_force_zscale);
534 // queue damage with this calculated info
535 if(W_Shockwave_Attack_CheckHit(queue, head, final_force, final_damage)) { ++queue; }
537 #ifdef DEBUG_SHOCKWAVE
539 "SPLASH HIT: multiplier = %f, damage = %f, force = %f... "
540 "multiplier_from_accuracy = %f, multiplier_from_distance = %f.\n",
544 multiplier_from_accuracy,
545 multiplier_from_distance
554 head = WarpZone_FindRadius(w_shotorg, WEP_CVAR(shockwave, blast_distance), FALSE);
557 if((head != self) && head.takedamage)
559 // ========================
560 // BLAST CONE CALCULATION
561 // ========================
563 // if it's a player, use the view origin as reference (stolen from RadiusDamage functions in g_damage.qc)
564 center = CENTER_OR_VIEWOFS(head);
566 // find the closest point on the enemy to the center of the attack
567 float ang; // angle between shotdir and h
568 float h; // hypotenuse, which is the distance between attacker to head
569 float a; // adjacent side, which is the distance between attacker and the point on w_shotdir that is closest to head.origin
571 h = vlen(center - self.origin);
572 ang = acos(dotproduct(normalize(center - self.origin), w_shotdir));
574 // WEAPONTODO: replace with simpler method
576 vector nearest_on_line = (w_shotorg + a * w_shotdir);
577 vector nearest_to_attacker = WarpZoneLib_NearestPointOnBox(center + head.mins, center + head.maxs, nearest_on_line);
578 float distance_to_target = vlen(w_shotorg - nearest_to_attacker); // todo: use the findradius function for this
580 if((distance_to_target <= WEP_CVAR(shockwave, blast_distance))
581 && (W_Shockwave_Attack_IsVisible(head, nearest_on_line, w_shotorg, attack_endpos)))
583 // calculate importance of distance and accuracy for this attack
584 multiplier_from_accuracy = (1 -
585 W_Shockwave_Attack_CheckSpread(
592 multiplier_from_distance = (1 -
594 min(1, (distance_to_target / distance_to_end))
601 WEP_CVAR(shockwave, blast_multiplier_min),
603 (multiplier_from_accuracy * WEP_CVAR(shockwave, blast_multiplier_accuracy))
605 (multiplier_from_distance * WEP_CVAR(shockwave, blast_multiplier_distance))
609 // calculate damage from multiplier: 1 = "highest" damage, 0 = "lowest" edgedamage
612 (WEP_CVAR(shockwave, blast_damage) * multiplier)
614 (WEP_CVAR(shockwave, blast_edgedamage) * (1 - multiplier))
617 // figure out the direction of force
618 final_force = (w_shotdir * WEP_CVAR(shockwave, blast_force_forwardbias));
619 final_force = normalize(center - (nearest_on_line - final_force));
620 //te_lightning2(world, nearest_on_line, (attack_hitpos + (final_force * 200)));
622 // now multiply the direction by force units
623 final_force *= (WEP_CVAR(shockwave, blast_force) * multiplier);
624 final_force_z *= WEP_CVAR(shockwave, blast_force_zscale);
626 // queue damage with this calculated info
627 if(W_Shockwave_Attack_CheckHit(queue, head, final_force, final_damage)) { ++queue; }
629 #ifdef DEBUG_SHOCKWAVE
631 "BLAST HIT: multiplier = %f, damage = %f, force = %f... "
632 "multiplier_from_accuracy = %f, multiplier_from_distance = %f.\n",
636 multiplier_from_accuracy,
637 multiplier_from_distance
645 for(i = 1; i <= queue; ++i)
647 head = shockwave_hit[i];
648 final_force = shockwave_hit_force[i];
649 final_damage = shockwave_hit_damage[i];
661 #ifdef DEBUG_SHOCKWAVE
663 "SHOCKWAVE by %s: damage = %f, force = %f.\n",
670 shockwave_hit[i] = world;
671 shockwave_hit_force[i] = '0 0 0';
672 shockwave_hit_damage[i] = 0;
676 float W_Shockwave(float req)
683 if(vlen(self.origin - self.enemy.origin) <= WEP_CVAR(shockwave, melee_range))
684 { self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, FALSE); }
686 { self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, FALSE); }
692 if(WEP_CVAR(shockwave, reload_ammo) && self.clip_load < WEP_CVAR(shockwave, pellets_ammo)) // forced reload
694 // don't force reload an empty shockwave if its melee attack is active
695 if(!(WEP_CVAR(shockwave, secondary) && self.ammo_shells < WEP_CVAR(shockwave, pellets_ammo)))
696 WEP_ACTION(self.weapon, WR_RELOAD);
702 switch(WEP_CVAR(shockwave, primary))
706 if(time >= self.shockwave_pelletstime) // handle refire separately so the secondary can be fired straight after a primary
708 if(weapon_prepareattack(0, WEP_CVAR(shockwave, pellets_animtime)))
710 W_Shockwave_Attack();
711 self.shockwave_pelletstime = time + WEP_CVAR(shockwave, pellets_refire) * W_WeaponRateFactor();
712 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(shockwave, pellets_animtime), w_ready);
719 if(time >= self.shockwave_pelletstime) // handle refire separately so the secondary can be fired straight after a primary
721 if(weapon_prepareattack(0, WEP_CVAR(shockwave, pellets_animtime)))
723 W_Shockwave_Pellets();
724 self.shockwave_pelletstime = time + WEP_CVAR(shockwave, pellets_refire) * W_WeaponRateFactor();
725 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(shockwave, pellets_animtime), w_ready);
733 if(self.clip_load >= 0) // we are not currently reloading
734 if(!self.crouch) // no crouchmelee please
735 if(self.BUTTON_ATCK2 && WEP_CVAR(shockwave, secondary))
736 if(weapon_prepareattack(1, WEP_CVAR(shockwave, melee_refire)))
738 // attempt forcing playback of the anim by switching to another anim (that we never play) here...
739 weapon_thinkf(WFRAME_FIRE1, 0, W_Shockwave_Melee);
747 precache_model("models/uziflash.md3");
748 precache_model("models/weapons/g_shockwave.md3");
749 precache_model("models/weapons/v_shockwave.md3");
750 precache_model("models/weapons/h_shockwave.iqm");
751 precache_sound("misc/itempickup.wav");
752 precache_sound("weapons/shockwave_fire.wav");
753 precache_sound("weapons/shockwave_melee.wav");
754 SHOCKWAVE_SETTINGS(WEP_SKIPCVAR, WEP_SET_PROP)
759 self.current_ammo = ammo_shells;
764 ammo_amount = self.ammo_shells >= WEP_CVAR(shockwave, pellets_ammo);
765 ammo_amount += self.(weapon_load[WEP_SHOCKWAVE]) >= WEP_CVAR(shockwave, pellets_ammo);
770 // melee attack is always available
775 SHOCKWAVE_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
780 W_Reload(WEP_CVAR(shockwave, pellets_ammo), "weapons/reload.wav");
783 case WR_SUICIDEMESSAGE:
785 return WEAPON_THINKING_WITH_PORTALS;
789 if(w_deathtype & HITTYPE_SECONDARY)
790 return WEAPON_SHOCKWAVE_MURDER_SLAP;
792 return WEAPON_SHOCKWAVE_MURDER;
799 float W_Shockwave(float req)
803 case WR_IMPACTEFFECT:
806 org2 = w_org + w_backoff * 2;
807 pointparticles(particleeffectnum("shockwave_impact"), org2, w_backoff * 1000, 1);
812 //precache_sound("weapons/ric1.wav");
813 //precache_sound("weapons/ric2.wav");
814 //precache_sound("weapons/ric3.wav");