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 const float 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 h; // hypotenuse, which is the distance between attacker to head
557 float a; // adjacent side, which is the distance between attacker and the point on w_shotdir that is closest to head.origin
559 h = vlen(center - self.origin);
560 a = h * (normalize(center - self.origin) * w_shotdir);
561 // WEAPONTODO: replace with simpler method
563 vector nearest_on_line = (w_shotorg + a * w_shotdir);
564 vector nearest_to_attacker = WarpZoneLib_NearestPointOnBox(center + head.mins, center + head.maxs, nearest_on_line);
566 if((vlen(head.WarpZone_findradius_dist) <= WEP_CVAR(shockwave, blast_distance))
567 && (W_Shockwave_Attack_IsVisible(head, nearest_on_line, w_shotorg, attack_endpos)))
569 // calculate importance of distance and accuracy for this attack
570 multiplier_from_accuracy = (1 -
571 W_Shockwave_Attack_CheckSpread(
578 multiplier_from_distance = (1 -
580 min(1, (vlen(head.WarpZone_findradius_dist) / distance_to_end))
587 WEP_CVAR(shockwave, blast_multiplier_min),
589 (multiplier_from_accuracy * WEP_CVAR(shockwave, blast_multiplier_accuracy))
591 (multiplier_from_distance * WEP_CVAR(shockwave, blast_multiplier_distance))
595 // calculate damage from multiplier: 1 = "highest" damage, 0 = "lowest" edgedamage
598 (WEP_CVAR(shockwave, blast_damage) * multiplier)
600 (WEP_CVAR(shockwave, blast_edgedamage) * (1 - multiplier))
603 // figure out the direction of force
604 final_force = (w_shotdir * WEP_CVAR(shockwave, blast_force_forwardbias));
605 final_force = normalize(center - (nearest_on_line - final_force));
606 //te_lightning2(world, nearest_on_line, (attack_hitpos + (final_force * 200)));
608 // now multiply the direction by force units
609 final_force *= (WEP_CVAR(shockwave, blast_force) * multiplier);
610 final_force.z *= WEP_CVAR(shockwave, blast_force_zscale);
612 // queue damage with this calculated info
613 if(W_Shockwave_Attack_CheckHit(queue, head, final_force, final_damage)) { queue = min(queue + 1, MAX_SHOCKWAVE_HITS); }
615 #ifdef DEBUG_SHOCKWAVE
617 "BLAST HIT: multiplier = %f, damage = %f, force = %f... "
618 "multiplier_from_accuracy = %f, multiplier_from_distance = %f.\n",
622 multiplier_from_accuracy,
623 multiplier_from_distance
631 for(i = 1; i <= queue; ++i)
633 head = shockwave_hit[i-1];
634 final_force = shockwave_hit_force[i-1];
635 final_damage = shockwave_hit_damage[i-1];
647 if(accuracy_isgooddamage(self.realowner, head))
650 accuracy_add(self.realowner, WEP_SHOCKWAVE, 0, final_damage);
653 #ifdef DEBUG_SHOCKWAVE
655 "SHOCKWAVE by %s: damage = %f, force = %f.\n",
662 shockwave_hit[i-1] = world;
663 shockwave_hit_force[i-1] = '0 0 0';
664 shockwave_hit_damage[i-1] = 0;
668 bool W_Shockwave(int req)
674 if(vlen(self.origin - self.enemy.origin) <= WEP_CVAR(shockwave, melee_range))
675 { self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, false); }
677 { self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, false); }
685 if(time >= self.shockwave_blasttime) // handle refire separately so the secondary can be fired straight after a primary
687 if(weapon_prepareattack(0, WEP_CVAR(shockwave, blast_animtime)))
689 W_Shockwave_Attack();
690 self.shockwave_blasttime = time + WEP_CVAR(shockwave, blast_refire) * W_WeaponRateFactor();
691 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(shockwave, blast_animtime), w_ready);
695 else if(self.BUTTON_ATCK2)
697 //if(self.clip_load >= 0) // we are not currently reloading
698 if(!self.crouch) // no crouchmelee please
699 if(weapon_prepareattack(1, WEP_CVAR(shockwave, melee_refire)))
701 // attempt forcing playback of the anim by switching to another anim (that we never play) here...
702 weapon_thinkf(WFRAME_FIRE1, 0, W_Shockwave_Melee);
710 precache_model("models/uziflash.md3");
711 precache_model("models/weapons/g_shotgun.md3");
712 precache_model("models/weapons/v_shotgun.md3");
713 precache_model("models/weapons/h_shotgun.iqm");
714 precache_sound("misc/itempickup.wav");
715 precache_sound("weapons/lasergun_fire.wav");
716 precache_sound("weapons/shotgun_melee.wav");
717 SHOCKWAVE_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
723 // shockwave has infinite ammo
728 SHOCKWAVE_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
731 case WR_SUICIDEMESSAGE:
733 return WEAPON_THINKING_WITH_PORTALS;
737 if(w_deathtype & HITTYPE_SECONDARY)
738 return WEAPON_SHOCKWAVE_MURDER_SLAP;
740 return WEAPON_SHOCKWAVE_MURDER;
747 // WEAPONTODO: add client side settings for these
748 const float SW_MAXALPHA = 0.5;
749 const float SW_FADETIME = 0.4;
750 const float SW_DISTTOMIN = 200;
751 void Draw_Shockwave()
753 // fading/removal control
754 float a = bound(0, (SW_MAXALPHA - ((time - self.sw_time) / SW_FADETIME)), SW_MAXALPHA);
755 if(a < ALPHA_MIN_VISIBLE) { remove(self); }
757 // WEAPONTODO: save this only once when creating the entity
758 vector sw_color = getcsqcplayercolor(self.sv_entnum); // GetTeamRGB(GetPlayerColor(self.sv_entnum));
760 // WEAPONTODO: trace to find what we actually hit
761 vector endpos = (self.sw_shotorg + (self.sw_shotdir * self.sw_distance));
763 vectorvectors(self.sw_shotdir);
764 vector right = v_right; // save this for when we do makevectors later
765 vector up = v_up; // save this for when we do makevectors later
767 // WEAPONTODO: combine and simplify these calculations
768 vector min_end = ((self.sw_shotorg + (self.sw_shotdir * SW_DISTTOMIN)) + (up * self.sw_spread_min));
769 vector max_end = (endpos + (up * self.sw_spread_max));
770 float spread_to_min = vlen(normalize(min_end - self.sw_shotorg) - self.sw_shotdir);
771 float spread_to_max = vlen(normalize(max_end - min_end) - self.sw_shotdir);
773 vector first_min_end = '0 0 0', prev_min_end = '0 0 0', new_min_end = '0 0 0';
774 vector first_max_end = '0 0 0', prev_max_end = '0 0 0', new_max_end = '0 0 0';
775 float new_max_dist, new_min_dist;
777 vector deviation, angle = '0 0 0';
778 float counter, divisions = 20;
779 for(counter = 0; counter < divisions; ++counter)
781 // perfect circle effect lines
782 makevectors('0 360 0' * (0.75 + (counter - 0.5) / divisions));
783 angle.y = v_forward.x;
784 angle.z = v_forward.y;
786 // first do the spread_to_min effect
787 deviation = angle * spread_to_min;
788 deviation = ((self.sw_shotdir + (right * deviation.y) + (up * deviation.z)));
789 new_min_dist = SW_DISTTOMIN;
790 new_min_end = (self.sw_shotorg + (deviation * new_min_dist));
791 //te_lightning2(world, new_min_end, self.sw_shotorg);
793 // then calculate spread_to_max effect
794 deviation = angle * spread_to_max;
795 deviation = ((self.sw_shotdir + (right * deviation.y) + (up * deviation.z)));
796 new_max_dist = vlen(new_min_end - endpos);
797 new_max_end = (new_min_end + (deviation * new_max_dist));
798 //te_lightning2(world, new_end, prev_min_end);
803 first_min_end = new_min_end;
804 first_max_end = new_max_end;
809 // draw from shot origin to min spread radius
810 R_BeginPolygon("", DRAWFLAG_NORMAL);
811 R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
812 R_PolygonVertex(new_min_end, '0 0 0', sw_color, a);
813 R_PolygonVertex(self.sw_shotorg, '0 0 0', sw_color, a);
816 // draw from min spread radius to max spread radius
817 R_BeginPolygon("", DRAWFLAG_NORMAL);
818 R_PolygonVertex(new_min_end, '0 0 0', sw_color, a);
819 R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
820 R_PolygonVertex(prev_max_end, '0 0 0', sw_color, a);
821 R_PolygonVertex(new_max_end, '0 0 0', sw_color, a);
825 prev_min_end = new_min_end;
826 prev_max_end = new_max_end;
828 // last division only
829 if((counter + 1) == divisions)
831 // draw from shot origin to min spread radius
832 R_BeginPolygon("", DRAWFLAG_NORMAL);
833 R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
834 R_PolygonVertex(first_min_end, '0 0 0', sw_color, a);
835 R_PolygonVertex(self.sw_shotorg, '0 0 0', sw_color, a);
838 // draw from min spread radius to max spread radius
839 R_BeginPolygon("", DRAWFLAG_NORMAL);
840 R_PolygonVertex(first_min_end, '0 0 0', sw_color, a);
841 R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
842 R_PolygonVertex(prev_max_end, '0 0 0', sw_color, a);
843 R_PolygonVertex(first_max_end, '0 0 0', sw_color, a);
849 void Net_ReadShockwaveParticle(void)
853 shockwave.draw = Draw_Shockwave;
855 shockwave.sw_shotorg_x = ReadCoord(); shockwave.sw_shotorg_y = ReadCoord(); shockwave.sw_shotorg_z = ReadCoord();
856 shockwave.sw_shotdir_x = ReadCoord(); shockwave.sw_shotdir_y = ReadCoord(); shockwave.sw_shotdir_z = ReadCoord();
858 shockwave.sw_distance = ReadShort();
859 shockwave.sw_spread_max = ReadByte();
860 shockwave.sw_spread_min = ReadByte();
862 shockwave.sv_entnum = ReadByte();
864 shockwave.sw_time = time;
867 bool W_Shockwave(int req)
871 case WR_IMPACTEFFECT:
873 // handled by Net_ReadShockwaveParticle
875 //org2 = w_org + w_backoff * 2;
876 //pointparticles(particleeffectnum("laser_impact"), org2, w_backoff * 1000, 1);
881 //precache_sound("weapons/ric1.wav");
882 //precache_sound("weapons/ric2.wav");
883 //precache_sound("weapons/ric3.wav");
888 // no weapon specific image for this weapon