3 /* WEP_##id */ SHOCKWAVE,
4 /* function */ W_Shockwave,
5 /* ammotype */ ammo_none,
7 /* flags */ WEP_FLAG_NORMAL | WEP_TYPE_HITSCAN | WEP_FLAG_CANCLIMB | WEP_FLAG_MUTATORBLOCKED,
8 /* rating */ BOT_PICKUP_RATING_LOW,
9 /* color */ '0.5 0.25 0',
10 /* modelname */ "shotgun",
11 /* simplemdl */ "foobar",
12 /* crosshair */ "gfx/crosshairshotgun 0.7",
13 /* wepimg */ "weaponshotgun",
14 /* refname */ "shockwave",
15 /* wepname */ _("Shockwave")
18 #define SHOCKWAVE_SETTINGS(w_cvar,w_prop) SHOCKWAVE_SETTINGS_LIST(w_cvar, w_prop, SHOCKWAVE, shockwave)
19 #define SHOCKWAVE_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
20 w_cvar(id, sn, NONE, blast_animtime) \
21 w_cvar(id, sn, NONE, blast_damage) \
22 w_cvar(id, sn, NONE, blast_distance) \
23 w_cvar(id, sn, NONE, blast_edgedamage) \
24 w_cvar(id, sn, NONE, blast_force) \
25 w_cvar(id, sn, NONE, blast_force_forwardbias) \
26 w_cvar(id, sn, NONE, blast_force_zscale) \
27 w_cvar(id, sn, NONE, blast_jump_damage) \
28 w_cvar(id, sn, NONE, blast_jump_edgedamage) \
29 w_cvar(id, sn, NONE, blast_jump_force) \
30 w_cvar(id, sn, NONE, blast_jump_force_velocitybias) \
31 w_cvar(id, sn, NONE, blast_jump_force_zscale) \
32 w_cvar(id, sn, NONE, blast_jump_multiplier_accuracy) \
33 w_cvar(id, sn, NONE, blast_jump_multiplier_distance) \
34 w_cvar(id, sn, NONE, blast_jump_multiplier_min) \
35 w_cvar(id, sn, NONE, blast_jump_radius) \
36 w_cvar(id, sn, NONE, blast_multiplier_accuracy) \
37 w_cvar(id, sn, NONE, blast_multiplier_distance) \
38 w_cvar(id, sn, NONE, blast_multiplier_min) \
39 w_cvar(id, sn, NONE, blast_refire) \
40 w_cvar(id, sn, NONE, blast_splash_damage) \
41 w_cvar(id, sn, NONE, blast_splash_edgedamage) \
42 w_cvar(id, sn, NONE, blast_splash_force) \
43 w_cvar(id, sn, NONE, blast_splash_force_forwardbias) \
44 w_cvar(id, sn, NONE, blast_splash_multiplier_accuracy) \
45 w_cvar(id, sn, NONE, blast_splash_multiplier_distance) \
46 w_cvar(id, sn, NONE, blast_splash_multiplier_min) \
47 w_cvar(id, sn, NONE, blast_splash_radius) \
48 w_cvar(id, sn, NONE, blast_spread_max) \
49 w_cvar(id, sn, NONE, blast_spread_min) \
50 w_cvar(id, sn, NONE, melee_animtime) \
51 w_cvar(id, sn, NONE, melee_damage) \
52 w_cvar(id, sn, NONE, melee_delay) \
53 w_cvar(id, sn, NONE, melee_force) \
54 w_cvar(id, sn, NONE, melee_multihit) \
55 w_cvar(id, sn, NONE, melee_no_doubleslap) \
56 w_cvar(id, sn, NONE, melee_nonplayerdamage) \
57 w_cvar(id, sn, NONE, melee_range) \
58 w_cvar(id, sn, NONE, melee_refire) \
59 w_cvar(id, sn, NONE, melee_swing_side) \
60 w_cvar(id, sn, NONE, melee_swing_up) \
61 w_cvar(id, sn, NONE, melee_time) \
62 w_cvar(id, sn, NONE, melee_traces) \
63 w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
64 w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
65 w_prop(id, sn, string, weaponreplace, weaponreplace) \
66 w_prop(id, sn, float, weaponstart, weaponstart) \
67 w_prop(id, sn, float, weaponstartoverride, weaponstartoverride) \
68 w_prop(id, sn, float, weaponthrowable, weaponthrowable)
71 SHOCKWAVE_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
74 void Net_ReadShockwaveParticle(void);
84 void spawnfunc_weapon_shockwave(void)
86 //if(autocvar_sv_q3acompat_machineshockwaveswap) // WEAPONTODO
87 if(autocvar_sv_q3acompat_machineshotgunswap)
88 if(self.classname != "droppedweapon")
90 weapon_defaultspawnfunc(WEP_MACHINEGUN);
93 weapon_defaultspawnfunc(WEP_SHOCKWAVE);
96 #define MAX_SHOCKWAVE_HITS 10
97 //#define DEBUG_SHOCKWAVE
100 .entity swing_alreadyhit;
101 .float shockwave_blasttime;
102 entity shockwave_hit[MAX_SHOCKWAVE_HITS];
103 float shockwave_hit_damage[MAX_SHOCKWAVE_HITS];
104 vector shockwave_hit_force[MAX_SHOCKWAVE_HITS];
107 void W_Shockwave_Melee_Think(void)
110 float i, f, swing, swing_factor, swing_damage, meleetime, is_player;
111 entity target_victim;
114 // check to see if we can still continue, otherwise give up now
115 if((self.realowner.deadflag != DEAD_NO) && WEP_CVAR(shockwave, melee_no_doubleslap))
121 // set start time of melee
125 W_PlayStrengthSound(self.realowner);
128 // update values for v_* vectors
129 makevectors(self.realowner.v_angle);
131 // calculate swing percentage based on time
132 meleetime = WEP_CVAR(shockwave, melee_time) * W_WeaponRateFactor();
133 swing = bound(0, (self.cnt + meleetime - time) / meleetime, 10);
134 f = ((1 - swing) * WEP_CVAR(shockwave, melee_traces));
136 // perform the traces needed for this frame
137 for(i=self.swing_prev; i < f; ++i)
139 swing_factor = ((1 - (i / WEP_CVAR(shockwave, melee_traces))) * 2 - 1);
141 targpos = (self.realowner.origin + self.realowner.view_ofs
142 + (v_forward * WEP_CVAR(shockwave, melee_range))
143 + (v_up * swing_factor * WEP_CVAR(shockwave, melee_swing_up))
144 + (v_right * swing_factor * WEP_CVAR(shockwave, melee_swing_side)));
146 WarpZone_traceline_antilag(
148 (self.realowner.origin + self.realowner.view_ofs),
152 ANTILAG_LATENCY(self.realowner)
155 // draw lightning beams for debugging
156 #ifdef DEBUG_SHOCKWAVE
157 te_lightning2(world, targpos, self.realowner.origin + self.realowner.view_ofs + v_forward * 5 - v_up * 5);
158 te_customflash(targpos, 40, 2, '1 1 1');
161 is_player = (IS_PLAYER(trace_ent) || trace_ent.classname == "body" || (trace_ent.flags & FL_MONSTER));
163 if((trace_fraction < 1) // if trace is good, apply the damage and remove self if necessary
164 && (trace_ent.takedamage == DAMAGE_AIM)
165 && (trace_ent != self.swing_alreadyhit)
166 && (is_player || WEP_CVAR(shockwave, melee_nonplayerdamage)))
168 target_victim = trace_ent; // so it persists through other calls
170 if(is_player) // this allows us to be able to nerf the non-player damage done in e.g. assault or onslaught
171 swing_damage = (WEP_CVAR(shockwave, melee_damage) * min(1, swing_factor + 1));
173 swing_damage = (WEP_CVAR(shockwave, melee_nonplayerdamage) * min(1, swing_factor + 1));
175 // trigger damage with this calculated info
181 (WEP_SHOCKWAVE | HITTYPE_SECONDARY),
182 (self.realowner.origin + self.realowner.view_ofs),
183 (v_forward * WEP_CVAR(shockwave, melee_force))
187 if(accuracy_isgooddamage(self.realowner, target_victim))
188 { accuracy_add(self.realowner, WEP_SHOCKWAVE, 0, swing_damage); }
190 #ifdef DEBUG_SHOCKWAVE
192 "MELEE: %s hitting %s with %f damage (factor: %f) at %f time.\n",
193 self.realowner.netname,
194 target_victim.netname,
201 // allow multiple hits with one swing, but not against the same player twice
202 if(WEP_CVAR(shockwave, melee_multihit))
204 self.swing_alreadyhit = target_victim;
205 continue; // move along to next trace
215 if(time >= self.cnt + meleetime)
225 self.nextthink = time;
229 void W_Shockwave_Melee(void)
231 sound(self, CH_WEAPON_A, "weapons/shotgun_melee.wav", VOL_BASE, ATTN_NORM);
232 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR(shockwave, melee_animtime), w_ready);
236 meleetemp.owner = meleetemp.realowner = self;
237 meleetemp.think = W_Shockwave_Melee_Think;
238 meleetemp.nextthink = time + WEP_CVAR(shockwave, melee_delay) * W_WeaponRateFactor();
239 W_SetupShot_Range(self, TRUE, 0, "", 0, WEP_CVAR(shockwave, melee_damage), WEP_CVAR(shockwave, melee_range));
242 // SHOCKWAVE ATTACK MODE
243 float W_Shockwave_Attack_CheckSpread(
245 vector nearest_on_line,
247 vector attack_endpos)
250 float distance_of_attack = vlen(sw_shotorg - attack_endpos);
251 float distance_from_line = vlen(targetorg - nearest_on_line);
253 spreadlimit = (distance_of_attack ? min(1, (vlen(sw_shotorg - nearest_on_line) / distance_of_attack)) : 1);
256 (WEP_CVAR(shockwave, blast_spread_min) * (1 - spreadlimit))
258 (WEP_CVAR(shockwave, blast_spread_max) * spreadlimit)
262 (spreadlimit && (distance_from_line <= spreadlimit))
264 ((vlen(normalize(targetorg - sw_shotorg) - normalize(attack_endpos - sw_shotorg)) * RAD2DEG) <= 90)
266 { return bound(0, (distance_from_line / spreadlimit), 1); }
271 float W_Shockwave_Attack_IsVisible(
273 vector nearest_on_line,
275 vector attack_endpos)
277 vector nearest_to_attacker = head.WarpZone_findradius_nearest;
278 vector center = (head.origin + (head.mins + head.maxs) * 0.5);
282 // STEP ONE: Check if the nearest point is clear
283 if(W_Shockwave_Attack_CheckSpread(nearest_to_attacker, nearest_on_line, sw_shotorg, attack_endpos))
285 WarpZone_TraceLine(sw_shotorg, nearest_to_attacker, MOVE_NOMONSTERS, self);
286 if(trace_fraction == 1) { return TRUE; } // yes, the nearest point is clear and we can allow the damage
289 // STEP TWO: Check if shotorg to center point is clear
290 if(W_Shockwave_Attack_CheckSpread(center, nearest_on_line, sw_shotorg, attack_endpos))
292 WarpZone_TraceLine(sw_shotorg, center, MOVE_NOMONSTERS, self);
293 if(trace_fraction == 1) { return TRUE; } // yes, the center point is clear and we can allow the damage
296 // STEP THREE: Check each corner to see if they are clear
299 corner = get_corner_position(head, i);
300 if(W_Shockwave_Attack_CheckSpread(corner, nearest_on_line, sw_shotorg, attack_endpos))
302 WarpZone_TraceLine(sw_shotorg, corner, MOVE_NOMONSTERS, self);
303 if(trace_fraction == 1) { return TRUE; } // yes, this corner is clear and we can allow the damage
310 float W_Shockwave_Attack_CheckHit(
316 if(!head) { return FALSE; }
319 for(i = 0; i <= queue; ++i)
321 if(shockwave_hit[i] == head)
323 if(vlen(final_force) > vlen(shockwave_hit_force[i])) { shockwave_hit_force[i] = final_force; }
324 if(final_damage > shockwave_hit_damage[i]) { shockwave_hit_damage[i] = final_damage; }
329 shockwave_hit[queue] = head;
330 shockwave_hit_force[queue] = final_force;
331 shockwave_hit_damage[queue] = final_damage;
335 void W_Shockwave_Send(void)
337 WriteByte(MSG_BROADCAST, SVC_TEMPENTITY);
338 WriteByte(MSG_BROADCAST, TE_CSQC_SHOCKWAVEPARTICLE);
339 WriteCoord(MSG_BROADCAST, w_shotorg_x);
340 WriteCoord(MSG_BROADCAST, w_shotorg_y);
341 WriteCoord(MSG_BROADCAST, w_shotorg_z);
342 WriteCoord(MSG_BROADCAST, w_shotdir_x);
343 WriteCoord(MSG_BROADCAST, w_shotdir_y);
344 WriteCoord(MSG_BROADCAST, w_shotdir_z);
345 WriteShort(MSG_BROADCAST, WEP_CVAR(shockwave, blast_distance));
346 WriteByte(MSG_BROADCAST, bound(0, WEP_CVAR(shockwave, blast_spread_max), 255));
347 WriteByte(MSG_BROADCAST, bound(0, WEP_CVAR(shockwave, blast_spread_min), 255));
348 WriteByte(MSG_BROADCAST, num_for_edict(self));
351 void W_Shockwave_Attack(void)
354 float multiplier, multiplier_from_accuracy, multiplier_from_distance;
356 vector final_force, center, vel;
361 // set up the shot direction
362 W_SetupShot(self, FALSE, 3, "weapons/lasergun_fire.wav", CH_WEAPON_B, WEP_CVAR(shockwave, blast_damage));
363 vector attack_endpos = (w_shotorg + (w_shotdir * WEP_CVAR(shockwave, blast_distance)));
364 WarpZone_TraceLine(w_shotorg, attack_endpos, MOVE_NOMONSTERS, self);
365 vector attack_hitpos = trace_endpos;
366 float distance_to_end = vlen(w_shotorg - attack_endpos);
367 float distance_to_hit = vlen(w_shotorg - attack_hitpos);
368 //entity transform = WarpZone_trace_transform;
370 // do the firing effect now
374 WEP_CVAR(shockwave, blast_splash_damage),
375 WEP_CVAR(shockwave, blast_splash_edgedamage),
376 WEP_CVAR(shockwave, blast_splash_radius),
377 w_shotdir * WEP_CVAR(shockwave, blast_splash_force),
383 // splash damage/jumping trace
384 head = WarpZone_FindRadius(
387 WEP_CVAR(shockwave, blast_splash_radius),
388 WEP_CVAR(shockwave, blast_jump_radius)
397 float distance_to_head = vlen(attack_hitpos - head.WarpZone_findradius_nearest);
399 if((head == self) && (distance_to_head <= WEP_CVAR(shockwave, blast_jump_radius)))
401 // ========================
402 // BLAST JUMP CALCULATION
403 // ========================
405 // calculate importance of distance and accuracy for this attack
406 multiplier_from_accuracy = (1 -
408 min(1, (distance_to_head / WEP_CVAR(shockwave, blast_jump_radius)))
413 multiplier_from_distance = (1 -
415 min(1, (distance_to_hit / distance_to_end))
422 WEP_CVAR(shockwave, blast_jump_multiplier_min),
424 (multiplier_from_accuracy * WEP_CVAR(shockwave, blast_jump_multiplier_accuracy))
426 (multiplier_from_distance * WEP_CVAR(shockwave, blast_jump_multiplier_distance))
430 // calculate damage from multiplier: 1 = "highest" damage, 0 = "lowest" edgedamage
433 (WEP_CVAR(shockwave, blast_jump_damage) * multiplier)
435 (WEP_CVAR(shockwave, blast_jump_edgedamage) * (1 - multiplier))
438 // figure out the direction of force
439 vel = normalize(combine_to_vector(head.velocity_x, head.velocity_y, 0));
442 bound(0, (vlen(vel) / autocvar_sv_maxspeed), 1)
444 WEP_CVAR(shockwave, blast_jump_force_velocitybias)
446 final_force = normalize((CENTER_OR_VIEWOFS(head) - attack_hitpos) + vel);
448 // now multiply the direction by force units
449 final_force *= (WEP_CVAR(shockwave, blast_jump_force) * multiplier);
450 final_force_z *= WEP_CVAR(shockwave, blast_jump_force_zscale);
452 // trigger damage with this calculated info
463 #ifdef DEBUG_SHOCKWAVE
465 "SELF HIT: multiplier = %f, damage = %f, force = %f... "
466 "multiplier_from_accuracy = %f, multiplier_from_distance = %f.\n",
470 multiplier_from_accuracy,
471 multiplier_from_distance
475 else if(distance_to_head <= WEP_CVAR(shockwave, blast_splash_radius))
477 // ==========================
478 // BLAST SPLASH CALCULATION
479 // ==========================
481 // calculate importance of distance and accuracy for this attack
482 multiplier_from_accuracy = (1 -
484 min(1, (distance_to_head / WEP_CVAR(shockwave, blast_splash_radius)))
489 multiplier_from_distance = (1 -
491 min(1, (distance_to_hit / distance_to_end))
498 WEP_CVAR(shockwave, blast_splash_multiplier_min),
500 (multiplier_from_accuracy * WEP_CVAR(shockwave, blast_splash_multiplier_accuracy))
502 (multiplier_from_distance * WEP_CVAR(shockwave, blast_splash_multiplier_distance))
506 // calculate damage from multiplier: 1 = "highest" damage, 0 = "lowest" edgedamage
509 (WEP_CVAR(shockwave, blast_splash_damage) * multiplier)
511 (WEP_CVAR(shockwave, blast_splash_edgedamage) * (1 - multiplier))
514 // figure out the direction of force
515 final_force = (w_shotdir * WEP_CVAR(shockwave, blast_splash_force_forwardbias));
516 final_force = normalize(CENTER_OR_VIEWOFS(head) - (attack_hitpos - final_force));
517 //te_lightning2(world, attack_hitpos, (attack_hitpos + (final_force * 200)));
519 // now multiply the direction by force units
520 final_force *= (WEP_CVAR(shockwave, blast_splash_force) * multiplier);
521 final_force_z *= WEP_CVAR(shockwave, blast_force_zscale);
523 // queue damage with this calculated info
524 if(W_Shockwave_Attack_CheckHit(queue, head, final_force, final_damage)) { queue = min(queue + 1, MAX_SHOCKWAVE_HITS); }
526 #ifdef DEBUG_SHOCKWAVE
528 "SPLASH HIT: multiplier = %f, damage = %f, force = %f... "
529 "multiplier_from_accuracy = %f, multiplier_from_distance = %f.\n",
533 multiplier_from_accuracy,
534 multiplier_from_distance
543 head = WarpZone_FindRadius(w_shotorg, WEP_CVAR(shockwave, blast_distance), FALSE);
546 if((head != self) && head.takedamage)
548 // ========================
549 // BLAST CONE CALCULATION
550 // ========================
552 // if it's a player, use the view origin as reference (stolen from RadiusDamage functions in g_damage.qc)
553 center = CENTER_OR_VIEWOFS(head);
555 // find the closest point on the enemy to the center of the attack
556 float ang; // angle between shotdir and h
557 float h; // hypotenuse, which is the distance between attacker to head
558 float a; // adjacent side, which is the distance between attacker and the point on w_shotdir that is closest to head.origin
560 h = vlen(center - self.origin);
561 ang = acos(dotproduct(normalize(center - self.origin), w_shotdir));
563 // WEAPONTODO: replace with simpler method
565 vector nearest_on_line = (w_shotorg + a * w_shotdir);
566 vector nearest_to_attacker = WarpZoneLib_NearestPointOnBox(center + head.mins, center + head.maxs, nearest_on_line);
568 if((vlen(head.WarpZone_findradius_dist) <= WEP_CVAR(shockwave, blast_distance))
569 && (W_Shockwave_Attack_IsVisible(head, nearest_on_line, w_shotorg, attack_endpos)))
571 // calculate importance of distance and accuracy for this attack
572 multiplier_from_accuracy = (1 -
573 W_Shockwave_Attack_CheckSpread(
580 multiplier_from_distance = (1 -
582 min(1, (vlen(head.WarpZone_findradius_dist) / distance_to_end))
589 WEP_CVAR(shockwave, blast_multiplier_min),
591 (multiplier_from_accuracy * WEP_CVAR(shockwave, blast_multiplier_accuracy))
593 (multiplier_from_distance * WEP_CVAR(shockwave, blast_multiplier_distance))
597 // calculate damage from multiplier: 1 = "highest" damage, 0 = "lowest" edgedamage
600 (WEP_CVAR(shockwave, blast_damage) * multiplier)
602 (WEP_CVAR(shockwave, blast_edgedamage) * (1 - multiplier))
605 // figure out the direction of force
606 final_force = (w_shotdir * WEP_CVAR(shockwave, blast_force_forwardbias));
607 final_force = normalize(center - (nearest_on_line - final_force));
608 //te_lightning2(world, nearest_on_line, (attack_hitpos + (final_force * 200)));
610 // now multiply the direction by force units
611 final_force *= (WEP_CVAR(shockwave, blast_force) * multiplier);
612 final_force_z *= WEP_CVAR(shockwave, blast_force_zscale);
614 // queue damage with this calculated info
615 if(W_Shockwave_Attack_CheckHit(queue, head, final_force, final_damage)) { queue = min(queue + 1, MAX_SHOCKWAVE_HITS); }
617 #ifdef DEBUG_SHOCKWAVE
619 "BLAST HIT: multiplier = %f, damage = %f, force = %f... "
620 "multiplier_from_accuracy = %f, multiplier_from_distance = %f.\n",
624 multiplier_from_accuracy,
625 multiplier_from_distance
633 for(i = 1; i <= queue; ++i)
635 head = shockwave_hit[i-1];
636 final_force = shockwave_hit_force[i-1];
637 final_damage = shockwave_hit_damage[i-1];
649 if(accuracy_isgooddamage(self.realowner, head))
652 accuracy_add(self.realowner, WEP_SHOCKWAVE, 0, final_damage);
655 #ifdef DEBUG_SHOCKWAVE
657 "SHOCKWAVE by %s: damage = %f, force = %f.\n",
664 shockwave_hit[i-1] = world;
665 shockwave_hit_force[i-1] = '0 0 0';
666 shockwave_hit_damage[i-1] = 0;
670 float W_Shockwave(float req)
676 if(vlen(self.origin - self.enemy.origin) <= WEP_CVAR(shockwave, melee_range))
677 { self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, FALSE); }
679 { self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, FALSE); }
687 if(time >= self.shockwave_blasttime) // handle refire separately so the secondary can be fired straight after a primary
689 if(weapon_prepareattack(0, WEP_CVAR(shockwave, blast_animtime)))
691 W_Shockwave_Attack();
692 self.shockwave_blasttime = time + WEP_CVAR(shockwave, blast_refire) * W_WeaponRateFactor();
693 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(shockwave, blast_animtime), w_ready);
697 else if(self.BUTTON_ATCK2)
699 //if(self.clip_load >= 0) // we are not currently reloading
700 if(!self.crouch) // no crouchmelee please
701 if(weapon_prepareattack(1, WEP_CVAR(shockwave, melee_refire)))
703 // attempt forcing playback of the anim by switching to another anim (that we never play) here...
704 weapon_thinkf(WFRAME_FIRE1, 0, W_Shockwave_Melee);
712 precache_model("models/uziflash.md3");
713 precache_model("models/weapons/g_shotgun.md3");
714 precache_model("models/weapons/v_shotgun.md3");
715 precache_model("models/weapons/h_shotgun.iqm");
716 precache_sound("misc/itempickup.wav");
717 precache_sound("weapons/lasergun_fire.wav");
718 precache_sound("weapons/shotgun_melee.wav");
719 SHOCKWAVE_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP)
725 // shockwave has infinite ammo
730 SHOCKWAVE_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
733 case WR_SUICIDEMESSAGE:
735 return WEAPON_THINKING_WITH_PORTALS;
739 if(w_deathtype & HITTYPE_SECONDARY)
740 return WEAPON_SHOCKWAVE_MURDER_SLAP;
742 return WEAPON_SHOCKWAVE_MURDER;
749 // WEAPONTODO: add client side settings for these
750 #define SW_MAXALPHA 0.5
751 #define SW_FADETIME 0.4
752 #define SW_DISTTOMIN 200
753 void Draw_Shockwave()
755 // fading/removal control
756 float a = bound(0, (SW_MAXALPHA - ((time - self.sw_time) / SW_FADETIME)), SW_MAXALPHA);
757 if(a < ALPHA_MIN_VISIBLE) { remove(self); }
759 // WEAPONTODO: save this only once when creating the entity
760 vector sw_color = getcsqcplayercolor(self.sv_entnum); // GetTeamRGB(GetPlayerColor(self.sv_entnum));
762 // WEAPONTODO: trace to find what we actually hit
763 vector endpos = (self.sw_shotorg + (self.sw_shotdir * self.sw_distance));
765 vectorvectors(self.sw_shotdir);
766 vector right = v_right; // save this for when we do makevectors later
767 vector up = v_up; // save this for when we do makevectors later
769 // WEAPONTODO: combine and simplify these calculations
770 vector min_end = ((self.sw_shotorg + (self.sw_shotdir * SW_DISTTOMIN)) + (up * self.sw_spread_min));
771 vector max_end = (endpos + (up * self.sw_spread_max));
772 float spread_to_min = vlen(normalize(min_end - self.sw_shotorg) - self.sw_shotdir);
773 float spread_to_max = vlen(normalize(max_end - min_end) - self.sw_shotdir);
775 vector first_min_end = '0 0 0', prev_min_end = '0 0 0', new_min_end = '0 0 0';
776 vector first_max_end = '0 0 0', prev_max_end = '0 0 0', new_max_end = '0 0 0';
777 float new_max_dist, new_min_dist;
779 vector deviation, angle = '0 0 0';
780 float counter, divisions = 20;
781 for(counter = 0; counter < divisions; ++counter)
783 // perfect circle effect lines
784 makevectors('0 360 0' * (0.75 + (counter - 0.5) / divisions));
785 angle_y = v_forward_x;
786 angle_z = v_forward_y;
788 // first do the spread_to_min effect
789 deviation = angle * spread_to_min;
790 deviation = ((self.sw_shotdir + (right * deviation_y) + (up * deviation_z)));
791 new_min_dist = SW_DISTTOMIN;
792 new_min_end = (self.sw_shotorg + (deviation * new_min_dist));
793 //te_lightning2(world, new_min_end, self.sw_shotorg);
795 // then calculate spread_to_max effect
796 deviation = angle * spread_to_max;
797 deviation = ((self.sw_shotdir + (right * deviation_y) + (up * deviation_z)));
798 new_max_dist = vlen(new_min_end - endpos);
799 new_max_end = (new_min_end + (deviation * new_max_dist));
800 //te_lightning2(world, new_end, prev_min_end);
805 first_min_end = new_min_end;
806 first_max_end = new_max_end;
811 // draw from shot origin to min spread radius
812 R_BeginPolygon("", DRAWFLAG_NORMAL);
813 R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
814 R_PolygonVertex(new_min_end, '0 0 0', sw_color, a);
815 R_PolygonVertex(self.sw_shotorg, '0 0 0', sw_color, a);
818 // draw from min spread radius to max spread radius
819 R_BeginPolygon("", DRAWFLAG_NORMAL);
820 R_PolygonVertex(new_min_end, '0 0 0', sw_color, a);
821 R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
822 R_PolygonVertex(prev_max_end, '0 0 0', sw_color, a);
823 R_PolygonVertex(new_max_end, '0 0 0', sw_color, a);
827 prev_min_end = new_min_end;
828 prev_max_end = new_max_end;
830 // last division only
831 if((counter + 1) == divisions)
833 // draw from shot origin to min spread radius
834 R_BeginPolygon("", DRAWFLAG_NORMAL);
835 R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
836 R_PolygonVertex(first_min_end, '0 0 0', sw_color, a);
837 R_PolygonVertex(self.sw_shotorg, '0 0 0', sw_color, a);
840 // draw from min spread radius to max spread radius
841 R_BeginPolygon("", DRAWFLAG_NORMAL);
842 R_PolygonVertex(first_min_end, '0 0 0', sw_color, a);
843 R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
844 R_PolygonVertex(prev_max_end, '0 0 0', sw_color, a);
845 R_PolygonVertex(first_max_end, '0 0 0', sw_color, a);
851 void Net_ReadShockwaveParticle(void)
855 shockwave.draw = Draw_Shockwave;
857 shockwave.sw_shotorg_x = ReadCoord(); shockwave.sw_shotorg_y = ReadCoord(); shockwave.sw_shotorg_z = ReadCoord();
858 shockwave.sw_shotdir_x = ReadCoord(); shockwave.sw_shotdir_y = ReadCoord(); shockwave.sw_shotdir_z = ReadCoord();
860 shockwave.sw_distance = ReadShort();
861 shockwave.sw_spread_max = ReadByte();
862 shockwave.sw_spread_min = ReadByte();
864 shockwave.sv_entnum = ReadByte();
866 shockwave.sw_time = time;
869 float W_Shockwave(float req)
873 case WR_IMPACTEFFECT:
875 // handled by Net_ReadShockwaveParticle
877 //org2 = w_org + w_backoff * 2;
878 //pointparticles(particleeffectnum("laser_impact"), org2, w_backoff * 1000, 1);
883 //precache_sound("weapons/ric1.wav");
884 //precache_sound("weapons/ric2.wav");
885 //precache_sound("weapons/ric3.wav");
890 // no weapon specific image for this weapon