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 #define X(BEGIN, P, END, class, prefix) \
20 P(class, prefix, blast_animtime, float, NONE) \
21 P(class, prefix, blast_damage, float, NONE) \
22 P(class, prefix, blast_distance, float, NONE) \
23 P(class, prefix, blast_edgedamage, float, NONE) \
24 P(class, prefix, blast_force, float, NONE) \
25 P(class, prefix, blast_force_forwardbias, float, NONE) \
26 P(class, prefix, blast_force_zscale, float, NONE) \
27 P(class, prefix, blast_jump_damage, float, NONE) \
28 P(class, prefix, blast_jump_edgedamage, float, NONE) \
29 P(class, prefix, blast_jump_force, float, NONE) \
30 P(class, prefix, blast_jump_force_velocitybias, float, NONE) \
31 P(class, prefix, blast_jump_force_zscale, float, NONE) \
32 P(class, prefix, blast_jump_multiplier_accuracy, float, NONE) \
33 P(class, prefix, blast_jump_multiplier_distance, float, NONE) \
34 P(class, prefix, blast_jump_multiplier_min, float, NONE) \
35 P(class, prefix, blast_jump_radius, float, NONE) \
36 P(class, prefix, blast_multiplier_accuracy, float, NONE) \
37 P(class, prefix, blast_multiplier_distance, float, NONE) \
38 P(class, prefix, blast_multiplier_min, float, NONE) \
39 P(class, prefix, blast_refire, float, NONE) \
40 P(class, prefix, blast_splash_damage, float, NONE) \
41 P(class, prefix, blast_splash_edgedamage, float, NONE) \
42 P(class, prefix, blast_splash_force, float, NONE) \
43 P(class, prefix, blast_splash_force_forwardbias, float, NONE) \
44 P(class, prefix, blast_splash_multiplier_accuracy, float, NONE) \
45 P(class, prefix, blast_splash_multiplier_distance, float, NONE) \
46 P(class, prefix, blast_splash_multiplier_min, float, NONE) \
47 P(class, prefix, blast_splash_radius, float, NONE) \
48 P(class, prefix, blast_spread_max, float, NONE) \
49 P(class, prefix, blast_spread_min, float, NONE) \
50 P(class, prefix, melee_animtime, float, NONE) \
51 P(class, prefix, melee_damage, float, NONE) \
52 P(class, prefix, melee_delay, float, NONE) \
53 P(class, prefix, melee_force, float, NONE) \
54 P(class, prefix, melee_multihit, float, NONE) \
55 P(class, prefix, melee_no_doubleslap, float, NONE) \
56 P(class, prefix, melee_nonplayerdamage, float, NONE) \
57 P(class, prefix, melee_range, float, NONE) \
58 P(class, prefix, melee_refire, float, NONE) \
59 P(class, prefix, melee_swing_side, float, NONE) \
60 P(class, prefix, melee_swing_up, float, NONE) \
61 P(class, prefix, melee_time, float, NONE) \
62 P(class, prefix, melee_traces, float, NONE) \
63 P(class, prefix, switchdelay_raise, float, NONE) \
64 P(class, prefix, switchdelay_drop, float, NONE) \
65 P(class, prefix, weaponreplace, string, NONE) \
66 P(class, prefix, weaponstart, float, NONE) \
67 P(class, prefix, weaponstartoverride, float, NONE) \
68 P(class, prefix, weaponthrowable, float, NONE) \
70 W_PROPS(X, Shockwave, shockwave)
74 REGISTER_WEAPON(SHOCKWAVE, shockwave, NEW(Shockwave));
78 void Net_ReadShockwaveParticle();
89 REGISTER_NET_TEMP(TE_CSQC_SHOCKWAVEPARTICLE)
92 spawnfunc(weapon_shockwave)
94 //if(autocvar_sv_q3acompat_machineshockwaveswap) // WEAPONTODO
95 if(autocvar_sv_q3acompat_machineshotgunswap)
96 if(self.classname != "droppedweapon")
98 weapon_defaultspawnfunc(this, WEP_MACHINEGUN);
101 weapon_defaultspawnfunc(this, WEP_SHOCKWAVE);
104 const float MAX_SHOCKWAVE_HITS = 10;
105 //#define DEBUG_SHOCKWAVE
108 .entity swing_alreadyhit;
109 .float shockwave_blasttime;
110 entity shockwave_hit[MAX_SHOCKWAVE_HITS];
111 float shockwave_hit_damage[MAX_SHOCKWAVE_HITS];
112 vector shockwave_hit_force[MAX_SHOCKWAVE_HITS];
115 void W_Shockwave_Melee_Think(entity this)
118 float i, f, swing, swing_factor, swing_damage, meleetime, is_player;
119 entity target_victim;
122 // check to see if we can still continue, otherwise give up now
123 if(IS_DEAD(self.realowner) && WEP_CVAR(shockwave, melee_no_doubleslap))
129 // set start time of melee
133 W_PlayStrengthSound(self.realowner);
136 // update values for v_* vectors
137 makevectors(self.realowner.v_angle);
139 // calculate swing percentage based on time
140 meleetime = WEP_CVAR(shockwave, melee_time) * W_WeaponRateFactor();
141 swing = bound(0, (self.cnt + meleetime - time) / meleetime, 10);
142 f = ((1 - swing) * WEP_CVAR(shockwave, melee_traces));
144 // perform the traces needed for this frame
145 for(i=self.swing_prev; i < f; ++i)
147 swing_factor = ((1 - (i / WEP_CVAR(shockwave, melee_traces))) * 2 - 1);
149 targpos = (self.realowner.origin + self.realowner.view_ofs
150 + (v_forward * WEP_CVAR(shockwave, melee_range))
151 + (v_up * swing_factor * WEP_CVAR(shockwave, melee_swing_up))
152 + (v_right * swing_factor * WEP_CVAR(shockwave, melee_swing_side)));
154 WarpZone_traceline_antilag(
156 (self.realowner.origin + self.realowner.view_ofs),
160 ANTILAG_LATENCY(self.realowner)
163 // draw lightning beams for debugging
164 #ifdef DEBUG_SHOCKWAVE
165 te_lightning2(world, targpos, self.realowner.origin + self.realowner.view_ofs + v_forward * 5 - v_up * 5);
166 te_customflash(targpos, 40, 2, '1 1 1');
169 is_player = (IS_PLAYER(trace_ent) || trace_ent.classname == "body" || IS_MONSTER(trace_ent));
171 if((trace_fraction < 1) // if trace is good, apply the damage and remove self if necessary
172 && (trace_ent.takedamage == DAMAGE_AIM)
173 && (trace_ent != self.swing_alreadyhit)
174 && (is_player || WEP_CVAR(shockwave, melee_nonplayerdamage)))
176 target_victim = trace_ent; // so it persists through other calls
178 if(is_player) // this allows us to be able to nerf the non-player damage done in e.g. assault or onslaught
179 swing_damage = (WEP_CVAR(shockwave, melee_damage) * min(1, swing_factor + 1));
181 swing_damage = (WEP_CVAR(shockwave, melee_nonplayerdamage) * min(1, swing_factor + 1));
183 // trigger damage with this calculated info
189 (WEP_SHOCKWAVE.m_id | HITTYPE_SECONDARY),
190 (self.realowner.origin + self.realowner.view_ofs),
191 (v_forward * WEP_CVAR(shockwave, melee_force))
195 if(accuracy_isgooddamage(self.realowner, target_victim))
196 { accuracy_add(self.realowner, WEP_SHOCKWAVE.m_id, 0, swing_damage); }
198 #ifdef DEBUG_SHOCKWAVE
200 "MELEE: %s hitting %s with %f damage (factor: %f) at %f time.\n",
201 self.realowner.netname,
202 target_victim.netname,
209 // allow multiple hits with one swing, but not against the same player twice
210 if(WEP_CVAR(shockwave, melee_multihit))
212 self.swing_alreadyhit = target_victim;
213 continue; // move along to next trace
223 if(time >= self.cnt + meleetime)
233 self.nextthink = time;
237 void W_Shockwave_Melee(Weapon thiswep, entity actor, .entity weaponentity, int fire)
239 sound(actor, CH_WEAPON_A, SND_SHOTGUN_MELEE, VOL_BASE, ATTN_NORM);
240 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(shockwave, melee_animtime), w_ready);
242 entity meleetemp = new_pure(meleetemp);
243 meleetemp.owner = meleetemp.realowner = actor;
244 setthink(meleetemp, W_Shockwave_Melee_Think);
245 meleetemp.nextthink = time + WEP_CVAR(shockwave, melee_delay) * W_WeaponRateFactor();
246 W_SetupShot_Range(actor, true, 0, SND_Null, 0, WEP_CVAR(shockwave, melee_damage), WEP_CVAR(shockwave, melee_range));
249 // SHOCKWAVE ATTACK MODE
250 float W_Shockwave_Attack_CheckSpread(
252 vector nearest_on_line,
254 vector attack_endpos)
257 float distance_of_attack = vlen(sw_shotorg - attack_endpos);
258 float distance_from_line = vlen(targetorg - nearest_on_line);
260 spreadlimit = (distance_of_attack ? min(1, (vlen(sw_shotorg - nearest_on_line) / distance_of_attack)) : 1);
263 (WEP_CVAR(shockwave, blast_spread_min) * (1 - spreadlimit))
265 (WEP_CVAR(shockwave, blast_spread_max) * spreadlimit)
269 (spreadlimit && (distance_from_line <= spreadlimit))
271 ((vlen(normalize(targetorg - sw_shotorg) - normalize(attack_endpos - sw_shotorg)) * RAD2DEG) <= 90)
273 { return bound(0, (distance_from_line / spreadlimit), 1); }
278 float W_Shockwave_Attack_IsVisible(
281 vector nearest_on_line,
283 vector attack_endpos)
284 {entity this = actor;
285 vector nearest_to_attacker = head.WarpZone_findradius_nearest;
286 vector center = (head.origin + (head.mins + head.maxs) * 0.5);
290 // STEP ONE: Check if the nearest point is clear
291 if(W_Shockwave_Attack_CheckSpread(nearest_to_attacker, nearest_on_line, sw_shotorg, attack_endpos))
293 WarpZone_TraceLine(sw_shotorg, nearest_to_attacker, MOVE_NOMONSTERS, self);
294 if(trace_fraction == 1) { return true; } // yes, the nearest point is clear and we can allow the damage
297 // STEP TWO: Check if shotorg to center point is clear
298 if(W_Shockwave_Attack_CheckSpread(center, nearest_on_line, sw_shotorg, attack_endpos))
300 WarpZone_TraceLine(sw_shotorg, center, MOVE_NOMONSTERS, self);
301 if(trace_fraction == 1) { return true; } // yes, the center point is clear and we can allow the damage
304 // STEP THREE: Check each corner to see if they are clear
307 corner = get_corner_position(head, i);
308 if(W_Shockwave_Attack_CheckSpread(corner, nearest_on_line, sw_shotorg, attack_endpos))
310 WarpZone_TraceLine(sw_shotorg, corner, MOVE_NOMONSTERS, self);
311 if(trace_fraction == 1) { return true; } // yes, this corner is clear and we can allow the damage
318 float W_Shockwave_Attack_CheckHit(
324 if(!head) { return false; }
327 for(i = 0; i <= queue; ++i)
329 if(shockwave_hit[i] == head)
331 if(vlen(final_force) > vlen(shockwave_hit_force[i])) { shockwave_hit_force[i] = final_force; }
332 if(final_damage > shockwave_hit_damage[i]) { shockwave_hit_damage[i] = final_damage; }
337 shockwave_hit[queue] = head;
338 shockwave_hit_force[queue] = final_force;
339 shockwave_hit_damage[queue] = final_damage;
343 void W_Shockwave_Send(entity actor)
345 WriteHeader(MSG_BROADCAST, TE_CSQC_SHOCKWAVEPARTICLE);
346 WriteCoord(MSG_BROADCAST, w_shotorg.x);
347 WriteCoord(MSG_BROADCAST, w_shotorg.y);
348 WriteCoord(MSG_BROADCAST, w_shotorg.z);
349 WriteCoord(MSG_BROADCAST, w_shotdir.x);
350 WriteCoord(MSG_BROADCAST, w_shotdir.y);
351 WriteCoord(MSG_BROADCAST, w_shotdir.z);
352 WriteShort(MSG_BROADCAST, WEP_CVAR(shockwave, blast_distance));
353 WriteByte(MSG_BROADCAST, bound(0, WEP_CVAR(shockwave, blast_spread_max), 255));
354 WriteByte(MSG_BROADCAST, bound(0, WEP_CVAR(shockwave, blast_spread_min), 255));
355 WriteByte(MSG_BROADCAST, etof(actor));
358 void W_Shockwave_Attack(entity actor)
359 {entity this = actor;
361 float multiplier, multiplier_from_accuracy, multiplier_from_distance;
363 vector final_force, center, vel;
368 // set up the shot direction
369 W_SetupShot(self, false, 3, SND_LASERGUN_FIRE, CH_WEAPON_B, WEP_CVAR(shockwave, blast_damage));
370 vector attack_endpos = (w_shotorg + (w_shotdir * WEP_CVAR(shockwave, blast_distance)));
371 WarpZone_TraceLine(w_shotorg, attack_endpos, MOVE_NOMONSTERS, self);
372 vector attack_hitpos = trace_endpos;
373 float distance_to_end = vlen(w_shotorg - attack_endpos);
374 float distance_to_hit = vlen(w_shotorg - attack_hitpos);
375 //entity transform = WarpZone_trace_transform;
377 // do the firing effect now
378 W_Shockwave_Send(self);
381 WEP_CVAR(shockwave, blast_splash_damage),
382 WEP_CVAR(shockwave, blast_splash_edgedamage),
383 WEP_CVAR(shockwave, blast_splash_radius),
384 w_shotdir * WEP_CVAR(shockwave, blast_splash_force),
390 // splash damage/jumping trace
391 head = WarpZone_FindRadius(
394 WEP_CVAR(shockwave, blast_splash_radius),
395 WEP_CVAR(shockwave, blast_jump_radius)
404 float distance_to_head = vlen(attack_hitpos - head.WarpZone_findradius_nearest);
406 if((head == self) && (distance_to_head <= WEP_CVAR(shockwave, blast_jump_radius)))
408 // ========================
409 // BLAST JUMP CALCULATION
410 // ========================
412 // calculate importance of distance and accuracy for this attack
413 multiplier_from_accuracy = (1 -
415 min(1, (distance_to_head / WEP_CVAR(shockwave, blast_jump_radius)))
420 multiplier_from_distance = (1 -
422 min(1, (distance_to_hit / distance_to_end))
429 WEP_CVAR(shockwave, blast_jump_multiplier_min),
431 (multiplier_from_accuracy * WEP_CVAR(shockwave, blast_jump_multiplier_accuracy))
433 (multiplier_from_distance * WEP_CVAR(shockwave, blast_jump_multiplier_distance))
437 // calculate damage from multiplier: 1 = "highest" damage, 0 = "lowest" edgedamage
440 (WEP_CVAR(shockwave, blast_jump_damage) * multiplier)
442 (WEP_CVAR(shockwave, blast_jump_edgedamage) * (1 - multiplier))
445 // figure out the direction of force
446 vel = normalize(vec3(head.velocity.x, head.velocity.y, 0));
449 bound(0, (vlen(vel) / autocvar_sv_maxspeed), 1)
451 WEP_CVAR(shockwave, blast_jump_force_velocitybias)
453 final_force = normalize((CENTER_OR_VIEWOFS(head) - attack_hitpos) + vel);
455 // now multiply the direction by force units
456 final_force *= (WEP_CVAR(shockwave, blast_jump_force) * multiplier);
457 final_force.z *= WEP_CVAR(shockwave, blast_jump_force_zscale);
459 // trigger damage with this calculated info
470 #ifdef DEBUG_SHOCKWAVE
472 "SELF HIT: multiplier = %f, damage = %f, force = %f... "
473 "multiplier_from_accuracy = %f, multiplier_from_distance = %f.\n",
477 multiplier_from_accuracy,
478 multiplier_from_distance
482 else if(distance_to_head <= WEP_CVAR(shockwave, blast_splash_radius))
484 // ==========================
485 // BLAST SPLASH CALCULATION
486 // ==========================
488 // calculate importance of distance and accuracy for this attack
489 multiplier_from_accuracy = (1 -
491 min(1, (distance_to_head / WEP_CVAR(shockwave, blast_splash_radius)))
496 multiplier_from_distance = (1 -
498 min(1, (distance_to_hit / distance_to_end))
505 WEP_CVAR(shockwave, blast_splash_multiplier_min),
507 (multiplier_from_accuracy * WEP_CVAR(shockwave, blast_splash_multiplier_accuracy))
509 (multiplier_from_distance * WEP_CVAR(shockwave, blast_splash_multiplier_distance))
513 // calculate damage from multiplier: 1 = "highest" damage, 0 = "lowest" edgedamage
516 (WEP_CVAR(shockwave, blast_splash_damage) * multiplier)
518 (WEP_CVAR(shockwave, blast_splash_edgedamage) * (1 - multiplier))
521 // figure out the direction of force
522 final_force = (w_shotdir * WEP_CVAR(shockwave, blast_splash_force_forwardbias));
523 final_force = normalize(CENTER_OR_VIEWOFS(head) - (attack_hitpos - final_force));
524 //te_lightning2(world, attack_hitpos, (attack_hitpos + (final_force * 200)));
526 // now multiply the direction by force units
527 final_force *= (WEP_CVAR(shockwave, blast_splash_force) * multiplier);
528 final_force.z *= WEP_CVAR(shockwave, blast_force_zscale);
530 // queue damage with this calculated info
531 if(W_Shockwave_Attack_CheckHit(queue, head, final_force, final_damage)) { queue = min(queue + 1, MAX_SHOCKWAVE_HITS); }
533 #ifdef DEBUG_SHOCKWAVE
535 "SPLASH HIT: multiplier = %f, damage = %f, force = %f... "
536 "multiplier_from_accuracy = %f, multiplier_from_distance = %f.\n",
540 multiplier_from_accuracy,
541 multiplier_from_distance
550 head = WarpZone_FindRadius(w_shotorg, WEP_CVAR(shockwave, blast_distance), false);
553 if((head != self) && head.takedamage)
555 // ========================
556 // BLAST CONE CALCULATION
557 // ========================
559 // if it's a player, use the view origin as reference (stolen from RadiusDamage functions in g_damage.qc)
560 center = CENTER_OR_VIEWOFS(head);
562 // find the closest point on the enemy to the center of the attack
563 float h; // hypotenuse, which is the distance between attacker to head
564 float a; // adjacent side, which is the distance between attacker and the point on w_shotdir that is closest to head.origin
566 h = vlen(center - self.origin);
567 a = h * (normalize(center - self.origin) * w_shotdir);
568 // WEAPONTODO: replace with simpler method
570 vector nearest_on_line = (w_shotorg + a * w_shotdir);
571 vector nearest_to_attacker = WarpZoneLib_NearestPointOnBox(center + head.mins, center + head.maxs, nearest_on_line);
573 if((vlen(head.WarpZone_findradius_dist) <= WEP_CVAR(shockwave, blast_distance))
574 && (W_Shockwave_Attack_IsVisible(self, head, nearest_on_line, w_shotorg, attack_endpos)))
576 // calculate importance of distance and accuracy for this attack
577 multiplier_from_accuracy = (1 -
578 W_Shockwave_Attack_CheckSpread(
585 multiplier_from_distance = (1 -
587 min(1, (vlen(head.WarpZone_findradius_dist) / distance_to_end))
594 WEP_CVAR(shockwave, blast_multiplier_min),
596 (multiplier_from_accuracy * WEP_CVAR(shockwave, blast_multiplier_accuracy))
598 (multiplier_from_distance * WEP_CVAR(shockwave, blast_multiplier_distance))
602 // calculate damage from multiplier: 1 = "highest" damage, 0 = "lowest" edgedamage
605 (WEP_CVAR(shockwave, blast_damage) * multiplier)
607 (WEP_CVAR(shockwave, blast_edgedamage) * (1 - multiplier))
610 // figure out the direction of force
611 final_force = (w_shotdir * WEP_CVAR(shockwave, blast_force_forwardbias));
612 final_force = normalize(center - (nearest_on_line - final_force));
613 //te_lightning2(world, nearest_on_line, (attack_hitpos + (final_force * 200)));
615 // now multiply the direction by force units
616 final_force *= (WEP_CVAR(shockwave, blast_force) * multiplier);
617 final_force.z *= WEP_CVAR(shockwave, blast_force_zscale);
619 // queue damage with this calculated info
620 if(W_Shockwave_Attack_CheckHit(queue, head, final_force, final_damage)) { queue = min(queue + 1, MAX_SHOCKWAVE_HITS); }
622 #ifdef DEBUG_SHOCKWAVE
624 "BLAST HIT: multiplier = %f, damage = %f, force = %f... "
625 "multiplier_from_accuracy = %f, multiplier_from_distance = %f.\n",
629 multiplier_from_accuracy,
630 multiplier_from_distance
638 for(i = 1; i <= queue; ++i)
640 head = shockwave_hit[i-1];
641 final_force = shockwave_hit_force[i-1];
642 final_damage = shockwave_hit_damage[i-1];
654 if(accuracy_isgooddamage(self.realowner, head))
657 accuracy_add(self.realowner, WEP_SHOCKWAVE.m_id, 0, final_damage);
660 #ifdef DEBUG_SHOCKWAVE
662 "SHOCKWAVE by %s: damage = %f, force = %f.\n",
669 shockwave_hit[i-1] = world;
670 shockwave_hit_force[i-1] = '0 0 0';
671 shockwave_hit_damage[i-1] = 0;
675 METHOD(Shockwave, wr_aim, void(entity thiswep, entity actor))
678 if(vlen(self.origin - self.enemy.origin) <= WEP_CVAR(shockwave, melee_range))
679 { PHYS_INPUT_BUTTON_ATCK2(self) = bot_aim(self, 1000000, 0, 0.001, false); }
681 { PHYS_INPUT_BUTTON_ATCK(self) = bot_aim(self, 1000000, 0, 0.001, false); }
683 METHOD(Shockwave, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
687 if(time >= actor.shockwave_blasttime) // handle refire separately so the secondary can be fired straight after a primary
689 if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(shockwave, blast_animtime)))
691 W_Shockwave_Attack(actor);
692 actor.shockwave_blasttime = time + WEP_CVAR(shockwave, blast_refire) * W_WeaponRateFactor();
693 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(shockwave, blast_animtime), w_ready);
699 //if(actor.clip_load >= 0) // we are not currently reloading
700 if(!actor.crouch) // no crouchmelee please
701 if(weapon_prepareattack(thiswep, actor, weaponentity, true, 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(actor, weaponentity, WFRAME_FIRE1, 0, W_Shockwave_Melee);
708 METHOD(Shockwave, wr_checkammo1, bool(entity thiswep, entity actor))
710 return true; // infinite ammo
712 METHOD(Shockwave, wr_checkammo2, bool(entity thiswep, entity actor))
714 // shockwave has infinite ammo
717 METHOD(Shockwave, wr_suicidemessage, Notification(entity thiswep))
719 return WEAPON_THINKING_WITH_PORTALS;
721 METHOD(Shockwave, wr_killmessage, Notification(entity thiswep))
723 if(w_deathtype & HITTYPE_SECONDARY)
724 return WEAPON_SHOCKWAVE_MURDER_SLAP;
726 return WEAPON_SHOCKWAVE_MURDER;
731 // WEAPONTODO: add client side settings for these
732 const float SW_MAXALPHA = 0.5;
733 const float SW_FADETIME = 0.4;
734 const float SW_DISTTOMIN = 200;
735 void Draw_Shockwave(entity this)
737 // fading/removal control
738 float a = bound(0, (SW_MAXALPHA - ((time - this.sw_time) / SW_FADETIME)), SW_MAXALPHA);
739 if(a < ALPHA_MIN_VISIBLE) { remove(this); }
741 // WEAPONTODO: save this only once when creating the entity
742 vector sw_color = entcs_GetColor(this.sv_entnum - 1); // GetTeamRGB(entcs_GetTeam(this.sv_entnum));
744 // WEAPONTODO: trace to find what we actually hit
745 vector endpos = (this.sw_shotorg + (this.sw_shotdir * this.sw_distance));
747 vectorvectors(this.sw_shotdir);
748 vector right = v_right; // save this for when we do makevectors later
749 vector up = v_up; // save this for when we do makevectors later
751 // WEAPONTODO: combine and simplify these calculations
752 vector min_end = ((this.sw_shotorg + (this.sw_shotdir * SW_DISTTOMIN)) + (up * this.sw_spread_min));
753 vector max_end = (endpos + (up * this.sw_spread_max));
754 float spread_to_min = vlen(normalize(min_end - this.sw_shotorg) - this.sw_shotdir);
755 float spread_to_max = vlen(normalize(max_end - min_end) - this.sw_shotdir);
757 vector first_min_end = '0 0 0', prev_min_end = '0 0 0', new_min_end = '0 0 0';
758 vector first_max_end = '0 0 0', prev_max_end = '0 0 0', new_max_end = '0 0 0';
759 float new_max_dist, new_min_dist;
761 vector deviation, angle = '0 0 0';
762 float counter, divisions = 20;
763 for(counter = 0; counter < divisions; ++counter)
765 // perfect circle effect lines
766 makevectors('0 360 0' * (0.75 + (counter - 0.5) / divisions));
767 angle.y = v_forward.x;
768 angle.z = v_forward.y;
770 // first do the spread_to_min effect
771 deviation = angle * spread_to_min;
772 deviation = ((this.sw_shotdir + (right * deviation.y) + (up * deviation.z)));
773 new_min_dist = SW_DISTTOMIN;
774 new_min_end = (this.sw_shotorg + (deviation * new_min_dist));
775 //te_lightning2(world, new_min_end, this.sw_shotorg);
777 // then calculate spread_to_max effect
778 deviation = angle * spread_to_max;
779 deviation = ((this.sw_shotdir + (right * deviation.y) + (up * deviation.z)));
780 new_max_dist = vlen(new_min_end - endpos);
781 new_max_end = (new_min_end + (deviation * new_max_dist));
782 //te_lightning2(world, new_end, prev_min_end);
787 first_min_end = new_min_end;
788 first_max_end = new_max_end;
793 // draw from shot origin to min spread radius
794 R_BeginPolygon("", DRAWFLAG_NORMAL);
795 R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
796 R_PolygonVertex(new_min_end, '0 0 0', sw_color, a);
797 R_PolygonVertex(this.sw_shotorg, '0 0 0', sw_color, a);
800 // draw from min spread radius to max spread radius
801 R_BeginPolygon("", DRAWFLAG_NORMAL);
802 R_PolygonVertex(new_min_end, '0 0 0', sw_color, a);
803 R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
804 R_PolygonVertex(prev_max_end, '0 0 0', sw_color, a);
805 R_PolygonVertex(new_max_end, '0 0 0', sw_color, a);
809 prev_min_end = new_min_end;
810 prev_max_end = new_max_end;
812 // last division only
813 if((counter + 1) == divisions)
815 // draw from shot origin to min spread radius
816 R_BeginPolygon("", DRAWFLAG_NORMAL);
817 R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
818 R_PolygonVertex(first_min_end, '0 0 0', sw_color, a);
819 R_PolygonVertex(this.sw_shotorg, '0 0 0', sw_color, a);
822 // draw from min spread radius to max spread radius
823 R_BeginPolygon("", DRAWFLAG_NORMAL);
824 R_PolygonVertex(first_min_end, '0 0 0', sw_color, a);
825 R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
826 R_PolygonVertex(prev_max_end, '0 0 0', sw_color, a);
827 R_PolygonVertex(first_max_end, '0 0 0', sw_color, a);
833 NET_HANDLE(TE_CSQC_SHOCKWAVEPARTICLE, bool isNew)
835 Net_ReadShockwaveParticle();
839 void Net_ReadShockwaveParticle()
843 shockwave.draw = Draw_Shockwave;
845 shockwave.sw_shotorg_x = ReadCoord(); shockwave.sw_shotorg_y = ReadCoord(); shockwave.sw_shotorg_z = ReadCoord();
846 shockwave.sw_shotdir_x = ReadCoord(); shockwave.sw_shotdir_y = ReadCoord(); shockwave.sw_shotdir_z = ReadCoord();
848 shockwave.sw_distance = ReadShort();
849 shockwave.sw_spread_max = ReadByte();
850 shockwave.sw_spread_min = ReadByte();
852 shockwave.sv_entnum = ReadByte();
854 shockwave.sw_time = time;
857 METHOD(Shockwave, wr_impacteffect, void(entity thiswep, entity actor))
859 // handled by Net_ReadShockwaveParticle
861 //org2 = w_org + w_backoff * 2;
862 //pointparticles(EFFECT_BLASTER_IMPACT, org2, w_backoff * 1000, 1);