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);
85 void spawnfunc_weapon_shockwave(void)
87 //if(autocvar_sv_q3acompat_machineshockwaveswap) // WEAPONTODO
88 if(autocvar_sv_q3acompat_machineshotgunswap)
89 if(self.classname != "droppedweapon")
91 weapon_defaultspawnfunc(WEP_MACHINEGUN.m_id);
94 weapon_defaultspawnfunc(WEP_SHOCKWAVE.m_id);
97 const float MAX_SHOCKWAVE_HITS = 10;
98 //#define DEBUG_SHOCKWAVE
101 .entity swing_alreadyhit;
102 .float shockwave_blasttime;
103 entity shockwave_hit[MAX_SHOCKWAVE_HITS];
104 float shockwave_hit_damage[MAX_SHOCKWAVE_HITS];
105 vector shockwave_hit_force[MAX_SHOCKWAVE_HITS];
108 void W_Shockwave_Melee_Think(void)
111 float i, f, swing, swing_factor, swing_damage, meleetime, is_player;
112 entity target_victim;
115 // check to see if we can still continue, otherwise give up now
116 if((self.realowner.deadflag != DEAD_NO) && WEP_CVAR(shockwave, melee_no_doubleslap))
122 // set start time of melee
126 W_PlayStrengthSound(self.realowner);
129 // update values for v_* vectors
130 makevectors(self.realowner.v_angle);
132 // calculate swing percentage based on time
133 meleetime = WEP_CVAR(shockwave, melee_time) * W_WeaponRateFactor();
134 swing = bound(0, (self.cnt + meleetime - time) / meleetime, 10);
135 f = ((1 - swing) * WEP_CVAR(shockwave, melee_traces));
137 // perform the traces needed for this frame
138 for(i=self.swing_prev; i < f; ++i)
140 swing_factor = ((1 - (i / WEP_CVAR(shockwave, melee_traces))) * 2 - 1);
142 targpos = (self.realowner.origin + self.realowner.view_ofs
143 + (v_forward * WEP_CVAR(shockwave, melee_range))
144 + (v_up * swing_factor * WEP_CVAR(shockwave, melee_swing_up))
145 + (v_right * swing_factor * WEP_CVAR(shockwave, melee_swing_side)));
147 WarpZone_traceline_antilag(
149 (self.realowner.origin + self.realowner.view_ofs),
153 ANTILAG_LATENCY(self.realowner)
156 // draw lightning beams for debugging
157 #ifdef DEBUG_SHOCKWAVE
158 te_lightning2(world, targpos, self.realowner.origin + self.realowner.view_ofs + v_forward * 5 - v_up * 5);
159 te_customflash(targpos, 40, 2, '1 1 1');
162 is_player = (IS_PLAYER(trace_ent) || trace_ent.classname == "body" || IS_MONSTER(trace_ent));
164 if((trace_fraction < 1) // if trace is good, apply the damage and remove self if necessary
165 && (trace_ent.takedamage == DAMAGE_AIM)
166 && (trace_ent != self.swing_alreadyhit)
167 && (is_player || WEP_CVAR(shockwave, melee_nonplayerdamage)))
169 target_victim = trace_ent; // so it persists through other calls
171 if(is_player) // this allows us to be able to nerf the non-player damage done in e.g. assault or onslaught
172 swing_damage = (WEP_CVAR(shockwave, melee_damage) * min(1, swing_factor + 1));
174 swing_damage = (WEP_CVAR(shockwave, melee_nonplayerdamage) * min(1, swing_factor + 1));
176 // trigger damage with this calculated info
182 (WEP_SHOCKWAVE.m_id | HITTYPE_SECONDARY),
183 (self.realowner.origin + self.realowner.view_ofs),
184 (v_forward * WEP_CVAR(shockwave, melee_force))
188 if(accuracy_isgooddamage(self.realowner, target_victim))
189 { accuracy_add(self.realowner, WEP_SHOCKWAVE.m_id, 0, swing_damage); }
191 #ifdef DEBUG_SHOCKWAVE
193 "MELEE: %s hitting %s with %f damage (factor: %f) at %f time.\n",
194 self.realowner.netname,
195 target_victim.netname,
202 // allow multiple hits with one swing, but not against the same player twice
203 if(WEP_CVAR(shockwave, melee_multihit))
205 self.swing_alreadyhit = target_victim;
206 continue; // move along to next trace
216 if(time >= self.cnt + meleetime)
226 self.nextthink = time;
230 void W_Shockwave_Melee(void)
232 sound(self, CH_WEAPON_A, W_Sound("shotgun_melee"), VOL_BASE, ATTN_NORM);
233 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR(shockwave, melee_animtime), w_ready);
237 meleetemp.owner = meleetemp.realowner = self;
238 meleetemp.think = W_Shockwave_Melee_Think;
239 meleetemp.nextthink = time + WEP_CVAR(shockwave, melee_delay) * W_WeaponRateFactor();
240 W_SetupShot_Range(self, true, 0, "", 0, WEP_CVAR(shockwave, melee_damage), WEP_CVAR(shockwave, melee_range));
243 // SHOCKWAVE ATTACK MODE
244 float W_Shockwave_Attack_CheckSpread(
246 vector nearest_on_line,
248 vector attack_endpos)
251 float distance_of_attack = vlen(sw_shotorg - attack_endpos);
252 float distance_from_line = vlen(targetorg - nearest_on_line);
254 spreadlimit = (distance_of_attack ? min(1, (vlen(sw_shotorg - nearest_on_line) / distance_of_attack)) : 1);
257 (WEP_CVAR(shockwave, blast_spread_min) * (1 - spreadlimit))
259 (WEP_CVAR(shockwave, blast_spread_max) * spreadlimit)
263 (spreadlimit && (distance_from_line <= spreadlimit))
265 ((vlen(normalize(targetorg - sw_shotorg) - normalize(attack_endpos - sw_shotorg)) * RAD2DEG) <= 90)
267 { return bound(0, (distance_from_line / spreadlimit), 1); }
272 float W_Shockwave_Attack_IsVisible(
274 vector nearest_on_line,
276 vector attack_endpos)
278 vector nearest_to_attacker = head.WarpZone_findradius_nearest;
279 vector center = (head.origin + (head.mins + head.maxs) * 0.5);
283 // STEP ONE: Check if the nearest point is clear
284 if(W_Shockwave_Attack_CheckSpread(nearest_to_attacker, nearest_on_line, sw_shotorg, attack_endpos))
286 WarpZone_TraceLine(sw_shotorg, nearest_to_attacker, MOVE_NOMONSTERS, self);
287 if(trace_fraction == 1) { return true; } // yes, the nearest point is clear and we can allow the damage
290 // STEP TWO: Check if shotorg to center point is clear
291 if(W_Shockwave_Attack_CheckSpread(center, nearest_on_line, sw_shotorg, attack_endpos))
293 WarpZone_TraceLine(sw_shotorg, center, MOVE_NOMONSTERS, self);
294 if(trace_fraction == 1) { return true; } // yes, the center point is clear and we can allow the damage
297 // STEP THREE: Check each corner to see if they are clear
300 corner = get_corner_position(head, i);
301 if(W_Shockwave_Attack_CheckSpread(corner, nearest_on_line, sw_shotorg, attack_endpos))
303 WarpZone_TraceLine(sw_shotorg, corner, MOVE_NOMONSTERS, self);
304 if(trace_fraction == 1) { return true; } // yes, this corner is clear and we can allow the damage
311 float W_Shockwave_Attack_CheckHit(
317 if(!head) { return false; }
320 for(i = 0; i <= queue; ++i)
322 if(shockwave_hit[i] == head)
324 if(vlen(final_force) > vlen(shockwave_hit_force[i])) { shockwave_hit_force[i] = final_force; }
325 if(final_damage > shockwave_hit_damage[i]) { shockwave_hit_damage[i] = final_damage; }
330 shockwave_hit[queue] = head;
331 shockwave_hit_force[queue] = final_force;
332 shockwave_hit_damage[queue] = final_damage;
336 void W_Shockwave_Send(void)
338 WriteByte(MSG_BROADCAST, SVC_TEMPENTITY);
339 WriteByte(MSG_BROADCAST, TE_CSQC_SHOCKWAVEPARTICLE);
340 WriteCoord(MSG_BROADCAST, w_shotorg.x);
341 WriteCoord(MSG_BROADCAST, w_shotorg.y);
342 WriteCoord(MSG_BROADCAST, w_shotorg.z);
343 WriteCoord(MSG_BROADCAST, w_shotdir.x);
344 WriteCoord(MSG_BROADCAST, w_shotdir.y);
345 WriteCoord(MSG_BROADCAST, w_shotdir.z);
346 WriteShort(MSG_BROADCAST, WEP_CVAR(shockwave, blast_distance));
347 WriteByte(MSG_BROADCAST, bound(0, WEP_CVAR(shockwave, blast_spread_max), 255));
348 WriteByte(MSG_BROADCAST, bound(0, WEP_CVAR(shockwave, blast_spread_min), 255));
349 WriteByte(MSG_BROADCAST, num_for_edict(self));
352 void W_Shockwave_Attack(void)
355 float multiplier, multiplier_from_accuracy, multiplier_from_distance;
357 vector final_force, center, vel;
362 // set up the shot direction
363 W_SetupShot(self, false, 3, W_Sound("lasergun_fire"), CH_WEAPON_B, WEP_CVAR(shockwave, blast_damage));
364 vector attack_endpos = (w_shotorg + (w_shotdir * WEP_CVAR(shockwave, blast_distance)));
365 WarpZone_TraceLine(w_shotorg, attack_endpos, MOVE_NOMONSTERS, self);
366 vector attack_hitpos = trace_endpos;
367 float distance_to_end = vlen(w_shotorg - attack_endpos);
368 float distance_to_hit = vlen(w_shotorg - attack_hitpos);
369 //entity transform = WarpZone_trace_transform;
371 // do the firing effect now
375 WEP_CVAR(shockwave, blast_splash_damage),
376 WEP_CVAR(shockwave, blast_splash_edgedamage),
377 WEP_CVAR(shockwave, blast_splash_radius),
378 w_shotdir * WEP_CVAR(shockwave, blast_splash_force),
384 // splash damage/jumping trace
385 head = WarpZone_FindRadius(
388 WEP_CVAR(shockwave, blast_splash_radius),
389 WEP_CVAR(shockwave, blast_jump_radius)
398 float distance_to_head = vlen(attack_hitpos - head.WarpZone_findradius_nearest);
400 if((head == self) && (distance_to_head <= WEP_CVAR(shockwave, blast_jump_radius)))
402 // ========================
403 // BLAST JUMP CALCULATION
404 // ========================
406 // calculate importance of distance and accuracy for this attack
407 multiplier_from_accuracy = (1 -
409 min(1, (distance_to_head / WEP_CVAR(shockwave, blast_jump_radius)))
414 multiplier_from_distance = (1 -
416 min(1, (distance_to_hit / distance_to_end))
423 WEP_CVAR(shockwave, blast_jump_multiplier_min),
425 (multiplier_from_accuracy * WEP_CVAR(shockwave, blast_jump_multiplier_accuracy))
427 (multiplier_from_distance * WEP_CVAR(shockwave, blast_jump_multiplier_distance))
431 // calculate damage from multiplier: 1 = "highest" damage, 0 = "lowest" edgedamage
434 (WEP_CVAR(shockwave, blast_jump_damage) * multiplier)
436 (WEP_CVAR(shockwave, blast_jump_edgedamage) * (1 - multiplier))
439 // figure out the direction of force
440 vel = normalize(combine_to_vector(head.velocity.x, head.velocity.y, 0));
443 bound(0, (vlen(vel) / autocvar_sv_maxspeed), 1)
445 WEP_CVAR(shockwave, blast_jump_force_velocitybias)
447 final_force = normalize((CENTER_OR_VIEWOFS(head) - attack_hitpos) + vel);
449 // now multiply the direction by force units
450 final_force *= (WEP_CVAR(shockwave, blast_jump_force) * multiplier);
451 final_force.z *= WEP_CVAR(shockwave, blast_jump_force_zscale);
453 // trigger damage with this calculated info
464 #ifdef DEBUG_SHOCKWAVE
466 "SELF HIT: multiplier = %f, damage = %f, force = %f... "
467 "multiplier_from_accuracy = %f, multiplier_from_distance = %f.\n",
471 multiplier_from_accuracy,
472 multiplier_from_distance
476 else if(distance_to_head <= WEP_CVAR(shockwave, blast_splash_radius))
478 // ==========================
479 // BLAST SPLASH CALCULATION
480 // ==========================
482 // calculate importance of distance and accuracy for this attack
483 multiplier_from_accuracy = (1 -
485 min(1, (distance_to_head / WEP_CVAR(shockwave, blast_splash_radius)))
490 multiplier_from_distance = (1 -
492 min(1, (distance_to_hit / distance_to_end))
499 WEP_CVAR(shockwave, blast_splash_multiplier_min),
501 (multiplier_from_accuracy * WEP_CVAR(shockwave, blast_splash_multiplier_accuracy))
503 (multiplier_from_distance * WEP_CVAR(shockwave, blast_splash_multiplier_distance))
507 // calculate damage from multiplier: 1 = "highest" damage, 0 = "lowest" edgedamage
510 (WEP_CVAR(shockwave, blast_splash_damage) * multiplier)
512 (WEP_CVAR(shockwave, blast_splash_edgedamage) * (1 - multiplier))
515 // figure out the direction of force
516 final_force = (w_shotdir * WEP_CVAR(shockwave, blast_splash_force_forwardbias));
517 final_force = normalize(CENTER_OR_VIEWOFS(head) - (attack_hitpos - final_force));
518 //te_lightning2(world, attack_hitpos, (attack_hitpos + (final_force * 200)));
520 // now multiply the direction by force units
521 final_force *= (WEP_CVAR(shockwave, blast_splash_force) * multiplier);
522 final_force.z *= WEP_CVAR(shockwave, blast_force_zscale);
524 // queue damage with this calculated info
525 if(W_Shockwave_Attack_CheckHit(queue, head, final_force, final_damage)) { queue = min(queue + 1, MAX_SHOCKWAVE_HITS); }
527 #ifdef DEBUG_SHOCKWAVE
529 "SPLASH HIT: multiplier = %f, damage = %f, force = %f... "
530 "multiplier_from_accuracy = %f, multiplier_from_distance = %f.\n",
534 multiplier_from_accuracy,
535 multiplier_from_distance
544 head = WarpZone_FindRadius(w_shotorg, WEP_CVAR(shockwave, blast_distance), false);
547 if((head != self) && head.takedamage)
549 // ========================
550 // BLAST CONE CALCULATION
551 // ========================
553 // if it's a player, use the view origin as reference (stolen from RadiusDamage functions in g_damage.qc)
554 center = CENTER_OR_VIEWOFS(head);
556 // find the closest point on the enemy to the center of the attack
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 a = h * (normalize(center - self.origin) * w_shotdir);
562 // WEAPONTODO: replace with simpler method
564 vector nearest_on_line = (w_shotorg + a * w_shotdir);
565 vector nearest_to_attacker = WarpZoneLib_NearestPointOnBox(center + head.mins, center + head.maxs, nearest_on_line);
567 if((vlen(head.WarpZone_findradius_dist) <= WEP_CVAR(shockwave, blast_distance))
568 && (W_Shockwave_Attack_IsVisible(head, nearest_on_line, w_shotorg, attack_endpos)))
570 // calculate importance of distance and accuracy for this attack
571 multiplier_from_accuracy = (1 -
572 W_Shockwave_Attack_CheckSpread(
579 multiplier_from_distance = (1 -
581 min(1, (vlen(head.WarpZone_findradius_dist) / distance_to_end))
588 WEP_CVAR(shockwave, blast_multiplier_min),
590 (multiplier_from_accuracy * WEP_CVAR(shockwave, blast_multiplier_accuracy))
592 (multiplier_from_distance * WEP_CVAR(shockwave, blast_multiplier_distance))
596 // calculate damage from multiplier: 1 = "highest" damage, 0 = "lowest" edgedamage
599 (WEP_CVAR(shockwave, blast_damage) * multiplier)
601 (WEP_CVAR(shockwave, blast_edgedamage) * (1 - multiplier))
604 // figure out the direction of force
605 final_force = (w_shotdir * WEP_CVAR(shockwave, blast_force_forwardbias));
606 final_force = normalize(center - (nearest_on_line - final_force));
607 //te_lightning2(world, nearest_on_line, (attack_hitpos + (final_force * 200)));
609 // now multiply the direction by force units
610 final_force *= (WEP_CVAR(shockwave, blast_force) * multiplier);
611 final_force.z *= WEP_CVAR(shockwave, blast_force_zscale);
613 // queue damage with this calculated info
614 if(W_Shockwave_Attack_CheckHit(queue, head, final_force, final_damage)) { queue = min(queue + 1, MAX_SHOCKWAVE_HITS); }
616 #ifdef DEBUG_SHOCKWAVE
618 "BLAST HIT: multiplier = %f, damage = %f, force = %f... "
619 "multiplier_from_accuracy = %f, multiplier_from_distance = %f.\n",
623 multiplier_from_accuracy,
624 multiplier_from_distance
632 for(i = 1; i <= queue; ++i)
634 head = shockwave_hit[i-1];
635 final_force = shockwave_hit_force[i-1];
636 final_damage = shockwave_hit_damage[i-1];
648 if(accuracy_isgooddamage(self.realowner, head))
651 accuracy_add(self.realowner, WEP_SHOCKWAVE.m_id, 0, final_damage);
654 #ifdef DEBUG_SHOCKWAVE
656 "SHOCKWAVE by %s: damage = %f, force = %f.\n",
663 shockwave_hit[i-1] = world;
664 shockwave_hit_force[i-1] = '0 0 0';
665 shockwave_hit_damage[i-1] = 0;
669 bool W_Shockwave(int req)
675 if(vlen(self.origin - self.enemy.origin) <= WEP_CVAR(shockwave, melee_range))
676 { self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, false); }
678 { self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, false); }
686 if(time >= self.shockwave_blasttime) // handle refire separately so the secondary can be fired straight after a primary
688 if(weapon_prepareattack(0, WEP_CVAR(shockwave, blast_animtime)))
690 W_Shockwave_Attack();
691 self.shockwave_blasttime = time + WEP_CVAR(shockwave, blast_refire) * W_WeaponRateFactor();
692 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(shockwave, blast_animtime), w_ready);
696 else if(self.BUTTON_ATCK2)
698 //if(self.clip_load >= 0) // we are not currently reloading
699 if(!self.crouch) // no crouchmelee please
700 if(weapon_prepareattack(1, WEP_CVAR(shockwave, melee_refire)))
702 // attempt forcing playback of the anim by switching to another anim (that we never play) here...
703 weapon_thinkf(WFRAME_FIRE1, 0, W_Shockwave_Melee);
711 precache_model("models/uziflash.md3");
712 precache_model(W_Model("g_shotgun.md3"));
713 precache_model(W_Model("v_shotgun.md3"));
714 precache_model(W_Model("h_shotgun.iqm"));
715 precache_sound("misc/itempickup.wav");
716 precache_sound(W_Sound("lasergun_fire"));
717 precache_sound(W_Sound("shotgun_melee"));
718 SHOCKWAVE_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
724 // shockwave has infinite ammo
729 SHOCKWAVE_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
732 case WR_SUICIDEMESSAGE:
734 return WEAPON_THINKING_WITH_PORTALS;
738 if(w_deathtype & HITTYPE_SECONDARY)
739 return WEAPON_SHOCKWAVE_MURDER_SLAP;
741 return WEAPON_SHOCKWAVE_MURDER;
748 // WEAPONTODO: add client side settings for these
749 const float SW_MAXALPHA = 0.5;
750 const float SW_FADETIME = 0.4;
751 const float SW_DISTTOMIN = 200;
752 void Draw_Shockwave()
754 // fading/removal control
755 float a = bound(0, (SW_MAXALPHA - ((time - self.sw_time) / SW_FADETIME)), SW_MAXALPHA);
756 if(a < ALPHA_MIN_VISIBLE) { remove(self); }
758 // WEAPONTODO: save this only once when creating the entity
759 vector sw_color = getcsqcplayercolor(self.sv_entnum); // GetTeamRGB(GetPlayerColor(self.sv_entnum));
761 // WEAPONTODO: trace to find what we actually hit
762 vector endpos = (self.sw_shotorg + (self.sw_shotdir * self.sw_distance));
764 vectorvectors(self.sw_shotdir);
765 vector right = v_right; // save this for when we do makevectors later
766 vector up = v_up; // save this for when we do makevectors later
768 // WEAPONTODO: combine and simplify these calculations
769 vector min_end = ((self.sw_shotorg + (self.sw_shotdir * SW_DISTTOMIN)) + (up * self.sw_spread_min));
770 vector max_end = (endpos + (up * self.sw_spread_max));
771 float spread_to_min = vlen(normalize(min_end - self.sw_shotorg) - self.sw_shotdir);
772 float spread_to_max = vlen(normalize(max_end - min_end) - self.sw_shotdir);
774 vector first_min_end = '0 0 0', prev_min_end = '0 0 0', new_min_end = '0 0 0';
775 vector first_max_end = '0 0 0', prev_max_end = '0 0 0', new_max_end = '0 0 0';
776 float new_max_dist, new_min_dist;
778 vector deviation, angle = '0 0 0';
779 float counter, divisions = 20;
780 for(counter = 0; counter < divisions; ++counter)
782 // perfect circle effect lines
783 makevectors('0 360 0' * (0.75 + (counter - 0.5) / divisions));
784 angle.y = v_forward.x;
785 angle.z = v_forward.y;
787 // first do the spread_to_min effect
788 deviation = angle * spread_to_min;
789 deviation = ((self.sw_shotdir + (right * deviation.y) + (up * deviation.z)));
790 new_min_dist = SW_DISTTOMIN;
791 new_min_end = (self.sw_shotorg + (deviation * new_min_dist));
792 //te_lightning2(world, new_min_end, self.sw_shotorg);
794 // then calculate spread_to_max effect
795 deviation = angle * spread_to_max;
796 deviation = ((self.sw_shotdir + (right * deviation.y) + (up * deviation.z)));
797 new_max_dist = vlen(new_min_end - endpos);
798 new_max_end = (new_min_end + (deviation * new_max_dist));
799 //te_lightning2(world, new_end, prev_min_end);
804 first_min_end = new_min_end;
805 first_max_end = new_max_end;
810 // draw from shot origin to min spread radius
811 R_BeginPolygon("", DRAWFLAG_NORMAL);
812 R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
813 R_PolygonVertex(new_min_end, '0 0 0', sw_color, a);
814 R_PolygonVertex(self.sw_shotorg, '0 0 0', sw_color, a);
817 // draw from min spread radius to max spread radius
818 R_BeginPolygon("", DRAWFLAG_NORMAL);
819 R_PolygonVertex(new_min_end, '0 0 0', sw_color, a);
820 R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
821 R_PolygonVertex(prev_max_end, '0 0 0', sw_color, a);
822 R_PolygonVertex(new_max_end, '0 0 0', sw_color, a);
826 prev_min_end = new_min_end;
827 prev_max_end = new_max_end;
829 // last division only
830 if((counter + 1) == divisions)
832 // draw from shot origin to min spread radius
833 R_BeginPolygon("", DRAWFLAG_NORMAL);
834 R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
835 R_PolygonVertex(first_min_end, '0 0 0', sw_color, a);
836 R_PolygonVertex(self.sw_shotorg, '0 0 0', sw_color, a);
839 // draw from min spread radius to max spread radius
840 R_BeginPolygon("", DRAWFLAG_NORMAL);
841 R_PolygonVertex(first_min_end, '0 0 0', sw_color, a);
842 R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
843 R_PolygonVertex(prev_max_end, '0 0 0', sw_color, a);
844 R_PolygonVertex(first_max_end, '0 0 0', sw_color, a);
850 void Net_ReadShockwaveParticle(void)
854 shockwave.draw = Draw_Shockwave;
856 shockwave.sw_shotorg_x = ReadCoord(); shockwave.sw_shotorg_y = ReadCoord(); shockwave.sw_shotorg_z = ReadCoord();
857 shockwave.sw_shotdir_x = ReadCoord(); shockwave.sw_shotdir_y = ReadCoord(); shockwave.sw_shotdir_z = ReadCoord();
859 shockwave.sw_distance = ReadShort();
860 shockwave.sw_spread_max = ReadByte();
861 shockwave.sw_spread_min = ReadByte();
863 shockwave.sv_entnum = ReadByte();
865 shockwave.sw_time = time;
868 bool W_Shockwave(int req)
872 case WR_IMPACTEFFECT:
874 // handled by Net_ReadShockwaveParticle
876 //org2 = w_org + w_backoff * 2;
877 //pointparticles(particleeffectnum("laser_impact"), org2, w_backoff * 1000, 1);
882 //precache_sound(W_Sound("ric1"));
883 //precache_sound(W_Sound("ric2"));
884 //precache_sound(W_Sound("ric3"));
889 // no weapon specific image for this weapon