2 CLASS(Shockwave, Weapon)
3 /* ammotype */ //ATTRIB(Shockwave, ammo_field, .int, ammo_none)
4 /* impulse */ ATTRIB(Shockwave, impulse, int, 2)
5 /* flags */ ATTRIB(Shockwave, spawnflags, int, WEP_FLAG_NORMAL | WEP_TYPE_HITSCAN | WEP_FLAG_CANCLIMB | WEP_FLAG_MUTATORBLOCKED);
6 /* rating */ ATTRIB(Shockwave, bot_pickupbasevalue, float, BOT_PICKUP_RATING_LOW);
7 /* color */ ATTRIB(Shockwave, wpcolor, vector, '0.5 0.25 0');
8 /* modelname */ ATTRIB(Shockwave, mdl, string, "shotgun");
10 /* model */ ATTRIB(Shockwave, m_model, Model, MDL_SHOCKWAVE_ITEM);
12 /* crosshair */ ATTRIB(Shockwave, w_crosshair, string, "gfx/crosshairshotgun");
13 /* crosshair */ ATTRIB(Shockwave, w_crosshair_size, float, 0.7);
14 /* wepimg */ ATTRIB(Shockwave, model2, string, "weaponshotgun");
15 /* refname */ ATTRIB(Shockwave, netname, string, "shockwave");
16 /* wepname */ ATTRIB(Shockwave, m_name, string, _("Shockwave"));
18 REGISTER_WEAPON(SHOCKWAVE, NEW(Shockwave));
20 #define SHOCKWAVE_SETTINGS(w_cvar,w_prop) SHOCKWAVE_SETTINGS_LIST(w_cvar, w_prop, SHOCKWAVE, shockwave)
21 #define SHOCKWAVE_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
22 w_cvar(id, sn, NONE, blast_animtime) \
23 w_cvar(id, sn, NONE, blast_damage) \
24 w_cvar(id, sn, NONE, blast_distance) \
25 w_cvar(id, sn, NONE, blast_edgedamage) \
26 w_cvar(id, sn, NONE, blast_force) \
27 w_cvar(id, sn, NONE, blast_force_forwardbias) \
28 w_cvar(id, sn, NONE, blast_force_zscale) \
29 w_cvar(id, sn, NONE, blast_jump_damage) \
30 w_cvar(id, sn, NONE, blast_jump_edgedamage) \
31 w_cvar(id, sn, NONE, blast_jump_force) \
32 w_cvar(id, sn, NONE, blast_jump_force_velocitybias) \
33 w_cvar(id, sn, NONE, blast_jump_force_zscale) \
34 w_cvar(id, sn, NONE, blast_jump_multiplier_accuracy) \
35 w_cvar(id, sn, NONE, blast_jump_multiplier_distance) \
36 w_cvar(id, sn, NONE, blast_jump_multiplier_min) \
37 w_cvar(id, sn, NONE, blast_jump_radius) \
38 w_cvar(id, sn, NONE, blast_multiplier_accuracy) \
39 w_cvar(id, sn, NONE, blast_multiplier_distance) \
40 w_cvar(id, sn, NONE, blast_multiplier_min) \
41 w_cvar(id, sn, NONE, blast_refire) \
42 w_cvar(id, sn, NONE, blast_splash_damage) \
43 w_cvar(id, sn, NONE, blast_splash_edgedamage) \
44 w_cvar(id, sn, NONE, blast_splash_force) \
45 w_cvar(id, sn, NONE, blast_splash_force_forwardbias) \
46 w_cvar(id, sn, NONE, blast_splash_multiplier_accuracy) \
47 w_cvar(id, sn, NONE, blast_splash_multiplier_distance) \
48 w_cvar(id, sn, NONE, blast_splash_multiplier_min) \
49 w_cvar(id, sn, NONE, blast_splash_radius) \
50 w_cvar(id, sn, NONE, blast_spread_max) \
51 w_cvar(id, sn, NONE, blast_spread_min) \
52 w_cvar(id, sn, NONE, melee_animtime) \
53 w_cvar(id, sn, NONE, melee_damage) \
54 w_cvar(id, sn, NONE, melee_delay) \
55 w_cvar(id, sn, NONE, melee_force) \
56 w_cvar(id, sn, NONE, melee_multihit) \
57 w_cvar(id, sn, NONE, melee_no_doubleslap) \
58 w_cvar(id, sn, NONE, melee_nonplayerdamage) \
59 w_cvar(id, sn, NONE, melee_range) \
60 w_cvar(id, sn, NONE, melee_refire) \
61 w_cvar(id, sn, NONE, melee_swing_side) \
62 w_cvar(id, sn, NONE, melee_swing_up) \
63 w_cvar(id, sn, NONE, melee_time) \
64 w_cvar(id, sn, NONE, melee_traces) \
65 w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
66 w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
67 w_prop(id, sn, string, weaponreplace, weaponreplace) \
68 w_prop(id, sn, float, weaponstart, weaponstart) \
69 w_prop(id, sn, float, weaponstartoverride, weaponstartoverride) \
70 w_prop(id, sn, float, weaponthrowable, weaponthrowable)
73 SHOCKWAVE_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
76 void Net_ReadShockwaveParticle();
87 spawnfunc(weapon_shockwave)
89 //if(autocvar_sv_q3acompat_machineshockwaveswap) // WEAPONTODO
90 if(autocvar_sv_q3acompat_machineshotgunswap)
91 if(self.classname != "droppedweapon")
93 weapon_defaultspawnfunc(this, WEP_MACHINEGUN);
96 weapon_defaultspawnfunc(this, WEP_SHOCKWAVE);
99 const float MAX_SHOCKWAVE_HITS = 10;
100 //#define DEBUG_SHOCKWAVE
103 .entity swing_alreadyhit;
104 .float shockwave_blasttime;
105 entity shockwave_hit[MAX_SHOCKWAVE_HITS];
106 float shockwave_hit_damage[MAX_SHOCKWAVE_HITS];
107 vector shockwave_hit_force[MAX_SHOCKWAVE_HITS];
110 void W_Shockwave_Melee_Think()
113 float i, f, swing, swing_factor, swing_damage, meleetime, is_player;
114 entity target_victim;
117 // check to see if we can still continue, otherwise give up now
118 if((self.realowner.deadflag != DEAD_NO) && WEP_CVAR(shockwave, melee_no_doubleslap))
124 // set start time of melee
128 W_PlayStrengthSound(self.realowner);
131 // update values for v_* vectors
132 makevectors(self.realowner.v_angle);
134 // calculate swing percentage based on time
135 meleetime = WEP_CVAR(shockwave, melee_time) * W_WeaponRateFactor();
136 swing = bound(0, (self.cnt + meleetime - time) / meleetime, 10);
137 f = ((1 - swing) * WEP_CVAR(shockwave, melee_traces));
139 // perform the traces needed for this frame
140 for(i=self.swing_prev; i < f; ++i)
142 swing_factor = ((1 - (i / WEP_CVAR(shockwave, melee_traces))) * 2 - 1);
144 targpos = (self.realowner.origin + self.realowner.view_ofs
145 + (v_forward * WEP_CVAR(shockwave, melee_range))
146 + (v_up * swing_factor * WEP_CVAR(shockwave, melee_swing_up))
147 + (v_right * swing_factor * WEP_CVAR(shockwave, melee_swing_side)));
149 WarpZone_traceline_antilag(
151 (self.realowner.origin + self.realowner.view_ofs),
155 ANTILAG_LATENCY(self.realowner)
158 // draw lightning beams for debugging
159 #ifdef DEBUG_SHOCKWAVE
160 te_lightning2(world, targpos, self.realowner.origin + self.realowner.view_ofs + v_forward * 5 - v_up * 5);
161 te_customflash(targpos, 40, 2, '1 1 1');
164 is_player = (IS_PLAYER(trace_ent) || trace_ent.classname == "body" || IS_MONSTER(trace_ent));
166 if((trace_fraction < 1) // if trace is good, apply the damage and remove self if necessary
167 && (trace_ent.takedamage == DAMAGE_AIM)
168 && (trace_ent != self.swing_alreadyhit)
169 && (is_player || WEP_CVAR(shockwave, melee_nonplayerdamage)))
171 target_victim = trace_ent; // so it persists through other calls
173 if(is_player) // this allows us to be able to nerf the non-player damage done in e.g. assault or onslaught
174 swing_damage = (WEP_CVAR(shockwave, melee_damage) * min(1, swing_factor + 1));
176 swing_damage = (WEP_CVAR(shockwave, melee_nonplayerdamage) * min(1, swing_factor + 1));
178 // trigger damage with this calculated info
184 (WEP_SHOCKWAVE.m_id | HITTYPE_SECONDARY),
185 (self.realowner.origin + self.realowner.view_ofs),
186 (v_forward * WEP_CVAR(shockwave, melee_force))
190 if(accuracy_isgooddamage(self.realowner, target_victim))
191 { accuracy_add(self.realowner, WEP_SHOCKWAVE.m_id, 0, swing_damage); }
193 #ifdef DEBUG_SHOCKWAVE
195 "MELEE: %s hitting %s with %f damage (factor: %f) at %f time.\n",
196 self.realowner.netname,
197 target_victim.netname,
204 // allow multiple hits with one swing, but not against the same player twice
205 if(WEP_CVAR(shockwave, melee_multihit))
207 self.swing_alreadyhit = target_victim;
208 continue; // move along to next trace
218 if(time >= self.cnt + meleetime)
228 self.nextthink = time;
232 void W_Shockwave_Melee(Weapon thiswep, entity actor, .entity weaponentity, int fire)
234 sound(actor, CH_WEAPON_A, SND_SHOTGUN_MELEE, VOL_BASE, ATTN_NORM);
235 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(shockwave, melee_animtime), w_ready);
237 entity meleetemp = new(meleetemp);
238 make_pure(meleetemp);
239 meleetemp.owner = meleetemp.realowner = actor;
240 meleetemp.think = W_Shockwave_Melee_Think;
241 meleetemp.nextthink = time + WEP_CVAR(shockwave, melee_delay) * W_WeaponRateFactor();
242 W_SetupShot_Range(actor, true, 0, "", 0, WEP_CVAR(shockwave, melee_damage), WEP_CVAR(shockwave, melee_range));
245 // SHOCKWAVE ATTACK MODE
246 float W_Shockwave_Attack_CheckSpread(
248 vector nearest_on_line,
250 vector attack_endpos)
253 float distance_of_attack = vlen(sw_shotorg - attack_endpos);
254 float distance_from_line = vlen(targetorg - nearest_on_line);
256 spreadlimit = (distance_of_attack ? min(1, (vlen(sw_shotorg - nearest_on_line) / distance_of_attack)) : 1);
259 (WEP_CVAR(shockwave, blast_spread_min) * (1 - spreadlimit))
261 (WEP_CVAR(shockwave, blast_spread_max) * spreadlimit)
265 (spreadlimit && (distance_from_line <= spreadlimit))
267 ((vlen(normalize(targetorg - sw_shotorg) - normalize(attack_endpos - sw_shotorg)) * RAD2DEG) <= 90)
269 { return bound(0, (distance_from_line / spreadlimit), 1); }
274 float W_Shockwave_Attack_IsVisible(
276 vector nearest_on_line,
278 vector attack_endpos)
280 vector nearest_to_attacker = head.WarpZone_findradius_nearest;
281 vector center = (head.origin + (head.mins + head.maxs) * 0.5);
285 // STEP ONE: Check if the nearest point is clear
286 if(W_Shockwave_Attack_CheckSpread(nearest_to_attacker, nearest_on_line, sw_shotorg, attack_endpos))
288 WarpZone_TraceLine(sw_shotorg, nearest_to_attacker, MOVE_NOMONSTERS, self);
289 if(trace_fraction == 1) { return true; } // yes, the nearest point is clear and we can allow the damage
292 // STEP TWO: Check if shotorg to center point is clear
293 if(W_Shockwave_Attack_CheckSpread(center, nearest_on_line, sw_shotorg, attack_endpos))
295 WarpZone_TraceLine(sw_shotorg, center, MOVE_NOMONSTERS, self);
296 if(trace_fraction == 1) { return true; } // yes, the center point is clear and we can allow the damage
299 // STEP THREE: Check each corner to see if they are clear
302 corner = get_corner_position(head, i);
303 if(W_Shockwave_Attack_CheckSpread(corner, nearest_on_line, sw_shotorg, attack_endpos))
305 WarpZone_TraceLine(sw_shotorg, corner, MOVE_NOMONSTERS, self);
306 if(trace_fraction == 1) { return true; } // yes, this corner is clear and we can allow the damage
313 float W_Shockwave_Attack_CheckHit(
319 if(!head) { return false; }
322 for(i = 0; i <= queue; ++i)
324 if(shockwave_hit[i] == head)
326 if(vlen(final_force) > vlen(shockwave_hit_force[i])) { shockwave_hit_force[i] = final_force; }
327 if(final_damage > shockwave_hit_damage[i]) { shockwave_hit_damage[i] = final_damage; }
332 shockwave_hit[queue] = head;
333 shockwave_hit_force[queue] = final_force;
334 shockwave_hit_damage[queue] = final_damage;
338 void W_Shockwave_Send()
340 WriteHeader(MSG_BROADCAST, TE_CSQC_SHOCKWAVEPARTICLE);
341 WriteCoord(MSG_BROADCAST, w_shotorg.x);
342 WriteCoord(MSG_BROADCAST, w_shotorg.y);
343 WriteCoord(MSG_BROADCAST, w_shotorg.z);
344 WriteCoord(MSG_BROADCAST, w_shotdir.x);
345 WriteCoord(MSG_BROADCAST, w_shotdir.y);
346 WriteCoord(MSG_BROADCAST, w_shotdir.z);
347 WriteShort(MSG_BROADCAST, WEP_CVAR(shockwave, blast_distance));
348 WriteByte(MSG_BROADCAST, bound(0, WEP_CVAR(shockwave, blast_spread_max), 255));
349 WriteByte(MSG_BROADCAST, bound(0, WEP_CVAR(shockwave, blast_spread_min), 255));
350 WriteByte(MSG_BROADCAST, num_for_edict(self));
353 void W_Shockwave_Attack()
356 float multiplier, multiplier_from_accuracy, multiplier_from_distance;
358 vector final_force, center, vel;
363 // set up the shot direction
364 W_SetupShot(self, false, 3, SND(LASERGUN_FIRE), CH_WEAPON_B, WEP_CVAR(shockwave, blast_damage));
365 vector attack_endpos = (w_shotorg + (w_shotdir * WEP_CVAR(shockwave, blast_distance)));
366 WarpZone_TraceLine(w_shotorg, attack_endpos, MOVE_NOMONSTERS, self);
367 vector attack_hitpos = trace_endpos;
368 float distance_to_end = vlen(w_shotorg - attack_endpos);
369 float distance_to_hit = vlen(w_shotorg - attack_hitpos);
370 //entity transform = WarpZone_trace_transform;
372 // do the firing effect now
376 WEP_CVAR(shockwave, blast_splash_damage),
377 WEP_CVAR(shockwave, blast_splash_edgedamage),
378 WEP_CVAR(shockwave, blast_splash_radius),
379 w_shotdir * WEP_CVAR(shockwave, blast_splash_force),
385 // splash damage/jumping trace
386 head = WarpZone_FindRadius(
389 WEP_CVAR(shockwave, blast_splash_radius),
390 WEP_CVAR(shockwave, blast_jump_radius)
399 float distance_to_head = vlen(attack_hitpos - head.WarpZone_findradius_nearest);
401 if((head == self) && (distance_to_head <= WEP_CVAR(shockwave, blast_jump_radius)))
403 // ========================
404 // BLAST JUMP CALCULATION
405 // ========================
407 // calculate importance of distance and accuracy for this attack
408 multiplier_from_accuracy = (1 -
410 min(1, (distance_to_head / WEP_CVAR(shockwave, blast_jump_radius)))
415 multiplier_from_distance = (1 -
417 min(1, (distance_to_hit / distance_to_end))
424 WEP_CVAR(shockwave, blast_jump_multiplier_min),
426 (multiplier_from_accuracy * WEP_CVAR(shockwave, blast_jump_multiplier_accuracy))
428 (multiplier_from_distance * WEP_CVAR(shockwave, blast_jump_multiplier_distance))
432 // calculate damage from multiplier: 1 = "highest" damage, 0 = "lowest" edgedamage
435 (WEP_CVAR(shockwave, blast_jump_damage) * multiplier)
437 (WEP_CVAR(shockwave, blast_jump_edgedamage) * (1 - multiplier))
440 // figure out the direction of force
441 vel = normalize(vec3(head.velocity.x, head.velocity.y, 0));
444 bound(0, (vlen(vel) / autocvar_sv_maxspeed), 1)
446 WEP_CVAR(shockwave, blast_jump_force_velocitybias)
448 final_force = normalize((CENTER_OR_VIEWOFS(head) - attack_hitpos) + vel);
450 // now multiply the direction by force units
451 final_force *= (WEP_CVAR(shockwave, blast_jump_force) * multiplier);
452 final_force.z *= WEP_CVAR(shockwave, blast_jump_force_zscale);
454 // trigger damage with this calculated info
465 #ifdef DEBUG_SHOCKWAVE
467 "SELF HIT: multiplier = %f, damage = %f, force = %f... "
468 "multiplier_from_accuracy = %f, multiplier_from_distance = %f.\n",
472 multiplier_from_accuracy,
473 multiplier_from_distance
477 else if(distance_to_head <= WEP_CVAR(shockwave, blast_splash_radius))
479 // ==========================
480 // BLAST SPLASH CALCULATION
481 // ==========================
483 // calculate importance of distance and accuracy for this attack
484 multiplier_from_accuracy = (1 -
486 min(1, (distance_to_head / WEP_CVAR(shockwave, blast_splash_radius)))
491 multiplier_from_distance = (1 -
493 min(1, (distance_to_hit / distance_to_end))
500 WEP_CVAR(shockwave, blast_splash_multiplier_min),
502 (multiplier_from_accuracy * WEP_CVAR(shockwave, blast_splash_multiplier_accuracy))
504 (multiplier_from_distance * WEP_CVAR(shockwave, blast_splash_multiplier_distance))
508 // calculate damage from multiplier: 1 = "highest" damage, 0 = "lowest" edgedamage
511 (WEP_CVAR(shockwave, blast_splash_damage) * multiplier)
513 (WEP_CVAR(shockwave, blast_splash_edgedamage) * (1 - multiplier))
516 // figure out the direction of force
517 final_force = (w_shotdir * WEP_CVAR(shockwave, blast_splash_force_forwardbias));
518 final_force = normalize(CENTER_OR_VIEWOFS(head) - (attack_hitpos - final_force));
519 //te_lightning2(world, attack_hitpos, (attack_hitpos + (final_force * 200)));
521 // now multiply the direction by force units
522 final_force *= (WEP_CVAR(shockwave, blast_splash_force) * multiplier);
523 final_force.z *= WEP_CVAR(shockwave, blast_force_zscale);
525 // queue damage with this calculated info
526 if(W_Shockwave_Attack_CheckHit(queue, head, final_force, final_damage)) { queue = min(queue + 1, MAX_SHOCKWAVE_HITS); }
528 #ifdef DEBUG_SHOCKWAVE
530 "SPLASH HIT: multiplier = %f, damage = %f, force = %f... "
531 "multiplier_from_accuracy = %f, multiplier_from_distance = %f.\n",
535 multiplier_from_accuracy,
536 multiplier_from_distance
545 head = WarpZone_FindRadius(w_shotorg, WEP_CVAR(shockwave, blast_distance), false);
548 if((head != self) && head.takedamage)
550 // ========================
551 // BLAST CONE CALCULATION
552 // ========================
554 // if it's a player, use the view origin as reference (stolen from RadiusDamage functions in g_damage.qc)
555 center = CENTER_OR_VIEWOFS(head);
557 // find the closest point on the enemy to the center of the attack
558 float h; // hypotenuse, which is the distance between attacker to head
559 float a; // adjacent side, which is the distance between attacker and the point on w_shotdir that is closest to head.origin
561 h = vlen(center - self.origin);
562 a = h * (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.m_id, 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 METHOD(Shockwave, wr_aim, void(entity thiswep))
672 if(vlen(self.origin - self.enemy.origin) <= WEP_CVAR(shockwave, melee_range))
673 { self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, false); }
675 { self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, false); }
677 METHOD(Shockwave, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
681 if(time >= actor.shockwave_blasttime) // handle refire separately so the secondary can be fired straight after a primary
683 if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(shockwave, blast_animtime)))
685 W_Shockwave_Attack();
686 actor.shockwave_blasttime = time + WEP_CVAR(shockwave, blast_refire) * W_WeaponRateFactor();
687 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(shockwave, blast_animtime), w_ready);
693 //if(actor.clip_load >= 0) // we are not currently reloading
694 if(!actor.crouch) // no crouchmelee please
695 if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR(shockwave, melee_refire)))
697 // attempt forcing playback of the anim by switching to another anim (that we never play) here...
698 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, W_Shockwave_Melee);
702 METHOD(Shockwave, wr_init, void(entity thiswep))
704 SHOCKWAVE_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
706 METHOD(Shockwave, wr_checkammo1, bool(entity thiswep))
708 return true; // infinite ammo
710 METHOD(Shockwave, wr_checkammo2, bool(entity thiswep))
712 // shockwave has infinite ammo
715 METHOD(Shockwave, wr_config, void(entity thiswep))
717 SHOCKWAVE_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
719 METHOD(Shockwave, wr_suicidemessage, int(entity thiswep))
721 return WEAPON_THINKING_WITH_PORTALS;
723 METHOD(Shockwave, wr_killmessage, int(entity thiswep))
725 if(w_deathtype & HITTYPE_SECONDARY)
726 return WEAPON_SHOCKWAVE_MURDER_SLAP;
728 return WEAPON_SHOCKWAVE_MURDER;
733 // WEAPONTODO: add client side settings for these
734 const float SW_MAXALPHA = 0.5;
735 const float SW_FADETIME = 0.4;
736 const float SW_DISTTOMIN = 200;
737 void Draw_Shockwave(entity this)
739 // fading/removal control
740 float a = bound(0, (SW_MAXALPHA - ((time - self.sw_time) / SW_FADETIME)), SW_MAXALPHA);
741 if(a < ALPHA_MIN_VISIBLE) { remove(self); }
743 // WEAPONTODO: save this only once when creating the entity
744 vector sw_color = getcsqcplayercolor(self.sv_entnum); // GetTeamRGB(GetPlayerColor(self.sv_entnum));
746 // WEAPONTODO: trace to find what we actually hit
747 vector endpos = (self.sw_shotorg + (self.sw_shotdir * self.sw_distance));
749 vectorvectors(self.sw_shotdir);
750 vector right = v_right; // save this for when we do makevectors later
751 vector up = v_up; // save this for when we do makevectors later
753 // WEAPONTODO: combine and simplify these calculations
754 vector min_end = ((self.sw_shotorg + (self.sw_shotdir * SW_DISTTOMIN)) + (up * self.sw_spread_min));
755 vector max_end = (endpos + (up * self.sw_spread_max));
756 float spread_to_min = vlen(normalize(min_end - self.sw_shotorg) - self.sw_shotdir);
757 float spread_to_max = vlen(normalize(max_end - min_end) - self.sw_shotdir);
759 vector first_min_end = '0 0 0', prev_min_end = '0 0 0', new_min_end = '0 0 0';
760 vector first_max_end = '0 0 0', prev_max_end = '0 0 0', new_max_end = '0 0 0';
761 float new_max_dist, new_min_dist;
763 vector deviation, angle = '0 0 0';
764 float counter, divisions = 20;
765 for(counter = 0; counter < divisions; ++counter)
767 // perfect circle effect lines
768 makevectors('0 360 0' * (0.75 + (counter - 0.5) / divisions));
769 angle.y = v_forward.x;
770 angle.z = v_forward.y;
772 // first do the spread_to_min effect
773 deviation = angle * spread_to_min;
774 deviation = ((self.sw_shotdir + (right * deviation.y) + (up * deviation.z)));
775 new_min_dist = SW_DISTTOMIN;
776 new_min_end = (self.sw_shotorg + (deviation * new_min_dist));
777 //te_lightning2(world, new_min_end, self.sw_shotorg);
779 // then calculate spread_to_max effect
780 deviation = angle * spread_to_max;
781 deviation = ((self.sw_shotdir + (right * deviation.y) + (up * deviation.z)));
782 new_max_dist = vlen(new_min_end - endpos);
783 new_max_end = (new_min_end + (deviation * new_max_dist));
784 //te_lightning2(world, new_end, prev_min_end);
789 first_min_end = new_min_end;
790 first_max_end = new_max_end;
795 // draw from shot origin to min spread radius
796 R_BeginPolygon("", DRAWFLAG_NORMAL);
797 R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
798 R_PolygonVertex(new_min_end, '0 0 0', sw_color, a);
799 R_PolygonVertex(self.sw_shotorg, '0 0 0', sw_color, a);
802 // draw from min spread radius to max spread radius
803 R_BeginPolygon("", DRAWFLAG_NORMAL);
804 R_PolygonVertex(new_min_end, '0 0 0', sw_color, a);
805 R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
806 R_PolygonVertex(prev_max_end, '0 0 0', sw_color, a);
807 R_PolygonVertex(new_max_end, '0 0 0', sw_color, a);
811 prev_min_end = new_min_end;
812 prev_max_end = new_max_end;
814 // last division only
815 if((counter + 1) == divisions)
817 // draw from shot origin to min spread radius
818 R_BeginPolygon("", DRAWFLAG_NORMAL);
819 R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
820 R_PolygonVertex(first_min_end, '0 0 0', sw_color, a);
821 R_PolygonVertex(self.sw_shotorg, '0 0 0', sw_color, a);
824 // draw from min spread radius to max spread radius
825 R_BeginPolygon("", DRAWFLAG_NORMAL);
826 R_PolygonVertex(first_min_end, '0 0 0', sw_color, a);
827 R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
828 R_PolygonVertex(prev_max_end, '0 0 0', sw_color, a);
829 R_PolygonVertex(first_max_end, '0 0 0', sw_color, a);
835 NET_HANDLE(TE_CSQC_SHOCKWAVEPARTICLE, bool isNew)
837 Net_ReadShockwaveParticle();
841 void Net_ReadShockwaveParticle()
845 shockwave.draw = Draw_Shockwave;
847 shockwave.sw_shotorg_x = ReadCoord(); shockwave.sw_shotorg_y = ReadCoord(); shockwave.sw_shotorg_z = ReadCoord();
848 shockwave.sw_shotdir_x = ReadCoord(); shockwave.sw_shotdir_y = ReadCoord(); shockwave.sw_shotdir_z = ReadCoord();
850 shockwave.sw_distance = ReadShort();
851 shockwave.sw_spread_max = ReadByte();
852 shockwave.sw_spread_min = ReadByte();
854 shockwave.sv_entnum = ReadByte();
856 shockwave.sw_time = time;
859 METHOD(Shockwave, wr_impacteffect, void(entity thiswep))
861 // handled by Net_ReadShockwaveParticle
863 //org2 = w_org + w_backoff * 2;
864 //pointparticles(EFFECT_BLASTER_IMPACT, org2, w_backoff * 1000, 1);