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, message, 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(void);
87 void spawnfunc_weapon_shockwave(void)
89 //if(autocvar_sv_q3acompat_machineshockwaveswap) // WEAPONTODO
90 if(autocvar_sv_q3acompat_machineshotgunswap)
91 if(self.classname != "droppedweapon")
93 weapon_defaultspawnfunc(WEP_MACHINEGUN.m_id);
96 weapon_defaultspawnfunc(WEP_SHOCKWAVE.m_id);
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(void)
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, bool fire1, bool fire2)
234 sound(self, CH_WEAPON_A, SND_SHOTGUN_MELEE, VOL_BASE, ATTN_NORM);
235 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR(shockwave, melee_animtime), w_ready);
239 meleetemp.owner = meleetemp.realowner = self;
240 meleetemp.think = W_Shockwave_Melee_Think;
241 meleetemp.nextthink = time + WEP_CVAR(shockwave, melee_delay) * W_WeaponRateFactor();
242 W_SetupShot_Range(self, 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(void)
340 WriteByte(MSG_BROADCAST, SVC_TEMPENTITY);
341 WriteByte(MSG_BROADCAST, TE_CSQC_SHOCKWAVEPARTICLE);
342 WriteCoord(MSG_BROADCAST, w_shotorg.x);
343 WriteCoord(MSG_BROADCAST, w_shotorg.y);
344 WriteCoord(MSG_BROADCAST, w_shotorg.z);
345 WriteCoord(MSG_BROADCAST, w_shotdir.x);
346 WriteCoord(MSG_BROADCAST, w_shotdir.y);
347 WriteCoord(MSG_BROADCAST, w_shotdir.z);
348 WriteShort(MSG_BROADCAST, WEP_CVAR(shockwave, blast_distance));
349 WriteByte(MSG_BROADCAST, bound(0, WEP_CVAR(shockwave, blast_spread_max), 255));
350 WriteByte(MSG_BROADCAST, bound(0, WEP_CVAR(shockwave, blast_spread_min), 255));
351 WriteByte(MSG_BROADCAST, num_for_edict(self));
354 void W_Shockwave_Attack(void)
357 float multiplier, multiplier_from_accuracy, multiplier_from_distance;
359 vector final_force, center, vel;
364 // set up the shot direction
365 W_SetupShot(self, false, 3, SND(LASERGUN_FIRE), CH_WEAPON_B, WEP_CVAR(shockwave, blast_damage));
366 vector attack_endpos = (w_shotorg + (w_shotdir * WEP_CVAR(shockwave, blast_distance)));
367 WarpZone_TraceLine(w_shotorg, attack_endpos, MOVE_NOMONSTERS, self);
368 vector attack_hitpos = trace_endpos;
369 float distance_to_end = vlen(w_shotorg - attack_endpos);
370 float distance_to_hit = vlen(w_shotorg - attack_hitpos);
371 //entity transform = WarpZone_trace_transform;
373 // do the firing effect now
377 WEP_CVAR(shockwave, blast_splash_damage),
378 WEP_CVAR(shockwave, blast_splash_edgedamage),
379 WEP_CVAR(shockwave, blast_splash_radius),
380 w_shotdir * WEP_CVAR(shockwave, blast_splash_force),
386 // splash damage/jumping trace
387 head = WarpZone_FindRadius(
390 WEP_CVAR(shockwave, blast_splash_radius),
391 WEP_CVAR(shockwave, blast_jump_radius)
400 float distance_to_head = vlen(attack_hitpos - head.WarpZone_findradius_nearest);
402 if((head == self) && (distance_to_head <= WEP_CVAR(shockwave, blast_jump_radius)))
404 // ========================
405 // BLAST JUMP CALCULATION
406 // ========================
408 // calculate importance of distance and accuracy for this attack
409 multiplier_from_accuracy = (1 -
411 min(1, (distance_to_head / WEP_CVAR(shockwave, blast_jump_radius)))
416 multiplier_from_distance = (1 -
418 min(1, (distance_to_hit / distance_to_end))
425 WEP_CVAR(shockwave, blast_jump_multiplier_min),
427 (multiplier_from_accuracy * WEP_CVAR(shockwave, blast_jump_multiplier_accuracy))
429 (multiplier_from_distance * WEP_CVAR(shockwave, blast_jump_multiplier_distance))
433 // calculate damage from multiplier: 1 = "highest" damage, 0 = "lowest" edgedamage
436 (WEP_CVAR(shockwave, blast_jump_damage) * multiplier)
438 (WEP_CVAR(shockwave, blast_jump_edgedamage) * (1 - multiplier))
441 // figure out the direction of force
442 vel = normalize(combine_to_vector(head.velocity.x, head.velocity.y, 0));
445 bound(0, (vlen(vel) / autocvar_sv_maxspeed), 1)
447 WEP_CVAR(shockwave, blast_jump_force_velocitybias)
449 final_force = normalize((CENTER_OR_VIEWOFS(head) - attack_hitpos) + vel);
451 // now multiply the direction by force units
452 final_force *= (WEP_CVAR(shockwave, blast_jump_force) * multiplier);
453 final_force.z *= WEP_CVAR(shockwave, blast_jump_force_zscale);
455 // trigger damage with this calculated info
466 #ifdef DEBUG_SHOCKWAVE
468 "SELF HIT: multiplier = %f, damage = %f, force = %f... "
469 "multiplier_from_accuracy = %f, multiplier_from_distance = %f.\n",
473 multiplier_from_accuracy,
474 multiplier_from_distance
478 else if(distance_to_head <= WEP_CVAR(shockwave, blast_splash_radius))
480 // ==========================
481 // BLAST SPLASH CALCULATION
482 // ==========================
484 // calculate importance of distance and accuracy for this attack
485 multiplier_from_accuracy = (1 -
487 min(1, (distance_to_head / WEP_CVAR(shockwave, blast_splash_radius)))
492 multiplier_from_distance = (1 -
494 min(1, (distance_to_hit / distance_to_end))
501 WEP_CVAR(shockwave, blast_splash_multiplier_min),
503 (multiplier_from_accuracy * WEP_CVAR(shockwave, blast_splash_multiplier_accuracy))
505 (multiplier_from_distance * WEP_CVAR(shockwave, blast_splash_multiplier_distance))
509 // calculate damage from multiplier: 1 = "highest" damage, 0 = "lowest" edgedamage
512 (WEP_CVAR(shockwave, blast_splash_damage) * multiplier)
514 (WEP_CVAR(shockwave, blast_splash_edgedamage) * (1 - multiplier))
517 // figure out the direction of force
518 final_force = (w_shotdir * WEP_CVAR(shockwave, blast_splash_force_forwardbias));
519 final_force = normalize(CENTER_OR_VIEWOFS(head) - (attack_hitpos - final_force));
520 //te_lightning2(world, attack_hitpos, (attack_hitpos + (final_force * 200)));
522 // now multiply the direction by force units
523 final_force *= (WEP_CVAR(shockwave, blast_splash_force) * multiplier);
524 final_force.z *= WEP_CVAR(shockwave, blast_force_zscale);
526 // queue damage with this calculated info
527 if(W_Shockwave_Attack_CheckHit(queue, head, final_force, final_damage)) { queue = min(queue + 1, MAX_SHOCKWAVE_HITS); }
529 #ifdef DEBUG_SHOCKWAVE
531 "SPLASH HIT: multiplier = %f, damage = %f, force = %f... "
532 "multiplier_from_accuracy = %f, multiplier_from_distance = %f.\n",
536 multiplier_from_accuracy,
537 multiplier_from_distance
546 head = WarpZone_FindRadius(w_shotorg, WEP_CVAR(shockwave, blast_distance), false);
549 if((head != self) && head.takedamage)
551 // ========================
552 // BLAST CONE CALCULATION
553 // ========================
555 // if it's a player, use the view origin as reference (stolen from RadiusDamage functions in g_damage.qc)
556 center = CENTER_OR_VIEWOFS(head);
558 // find the closest point on the enemy to the center of the attack
559 float h; // hypotenuse, which is the distance between attacker to head
560 float a; // adjacent side, which is the distance between attacker and the point on w_shotdir that is closest to head.origin
562 h = vlen(center - self.origin);
563 a = h * (normalize(center - self.origin) * w_shotdir);
564 // WEAPONTODO: replace with simpler method
566 vector nearest_on_line = (w_shotorg + a * w_shotdir);
567 vector nearest_to_attacker = WarpZoneLib_NearestPointOnBox(center + head.mins, center + head.maxs, nearest_on_line);
569 if((vlen(head.WarpZone_findradius_dist) <= WEP_CVAR(shockwave, blast_distance))
570 && (W_Shockwave_Attack_IsVisible(head, nearest_on_line, w_shotorg, attack_endpos)))
572 // calculate importance of distance and accuracy for this attack
573 multiplier_from_accuracy = (1 -
574 W_Shockwave_Attack_CheckSpread(
581 multiplier_from_distance = (1 -
583 min(1, (vlen(head.WarpZone_findradius_dist) / distance_to_end))
590 WEP_CVAR(shockwave, blast_multiplier_min),
592 (multiplier_from_accuracy * WEP_CVAR(shockwave, blast_multiplier_accuracy))
594 (multiplier_from_distance * WEP_CVAR(shockwave, blast_multiplier_distance))
598 // calculate damage from multiplier: 1 = "highest" damage, 0 = "lowest" edgedamage
601 (WEP_CVAR(shockwave, blast_damage) * multiplier)
603 (WEP_CVAR(shockwave, blast_edgedamage) * (1 - multiplier))
606 // figure out the direction of force
607 final_force = (w_shotdir * WEP_CVAR(shockwave, blast_force_forwardbias));
608 final_force = normalize(center - (nearest_on_line - final_force));
609 //te_lightning2(world, nearest_on_line, (attack_hitpos + (final_force * 200)));
611 // now multiply the direction by force units
612 final_force *= (WEP_CVAR(shockwave, blast_force) * multiplier);
613 final_force.z *= WEP_CVAR(shockwave, blast_force_zscale);
615 // queue damage with this calculated info
616 if(W_Shockwave_Attack_CheckHit(queue, head, final_force, final_damage)) { queue = min(queue + 1, MAX_SHOCKWAVE_HITS); }
618 #ifdef DEBUG_SHOCKWAVE
620 "BLAST HIT: multiplier = %f, damage = %f, force = %f... "
621 "multiplier_from_accuracy = %f, multiplier_from_distance = %f.\n",
625 multiplier_from_accuracy,
626 multiplier_from_distance
634 for(i = 1; i <= queue; ++i)
636 head = shockwave_hit[i-1];
637 final_force = shockwave_hit_force[i-1];
638 final_damage = shockwave_hit_damage[i-1];
650 if(accuracy_isgooddamage(self.realowner, head))
653 accuracy_add(self.realowner, WEP_SHOCKWAVE.m_id, 0, final_damage);
656 #ifdef DEBUG_SHOCKWAVE
658 "SHOCKWAVE by %s: damage = %f, force = %f.\n",
665 shockwave_hit[i-1] = world;
666 shockwave_hit_force[i-1] = '0 0 0';
667 shockwave_hit_damage[i-1] = 0;
671 METHOD(Shockwave, wr_aim, bool(entity thiswep))
673 if(vlen(self.origin - self.enemy.origin) <= WEP_CVAR(shockwave, melee_range))
674 { self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, false); }
676 { self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, false); }
680 METHOD(Shockwave, wr_think, bool(entity thiswep, bool fire1, bool fire2))
684 if(time >= self.shockwave_blasttime) // handle refire separately so the secondary can be fired straight after a primary
686 if(weapon_prepareattack(false, WEP_CVAR(shockwave, blast_animtime)))
688 W_Shockwave_Attack();
689 self.shockwave_blasttime = time + WEP_CVAR(shockwave, blast_refire) * W_WeaponRateFactor();
690 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(shockwave, blast_animtime), w_ready);
696 //if(self.clip_load >= 0) // we are not currently reloading
697 if(!self.crouch) // no crouchmelee please
698 if(weapon_prepareattack(true, WEP_CVAR(shockwave, melee_refire)))
700 // attempt forcing playback of the anim by switching to another anim (that we never play) here...
701 weapon_thinkf(WFRAME_FIRE1, 0, W_Shockwave_Melee);
707 METHOD(Shockwave, wr_init, bool(entity thiswep))
709 SHOCKWAVE_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
712 METHOD(Shockwave, wr_checkammo1, bool(entity thiswep))
714 return true; // infinite ammo
716 METHOD(Shockwave, wr_checkammo2, bool(entity thiswep))
718 // shockwave has infinite ammo
721 METHOD(Shockwave, wr_config, bool(entity thiswep))
723 SHOCKWAVE_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
726 METHOD(Shockwave, wr_suicidemessage, bool(entity thiswep))
728 return WEAPON_THINKING_WITH_PORTALS;
730 METHOD(Shockwave, wr_killmessage, bool(entity thiswep))
732 if(w_deathtype & HITTYPE_SECONDARY)
733 return WEAPON_SHOCKWAVE_MURDER_SLAP;
735 return WEAPON_SHOCKWAVE_MURDER;
740 // WEAPONTODO: add client side settings for these
741 const float SW_MAXALPHA = 0.5;
742 const float SW_FADETIME = 0.4;
743 const float SW_DISTTOMIN = 200;
744 void Draw_Shockwave()
746 // fading/removal control
747 float a = bound(0, (SW_MAXALPHA - ((time - self.sw_time) / SW_FADETIME)), SW_MAXALPHA);
748 if(a < ALPHA_MIN_VISIBLE) { remove(self); }
750 // WEAPONTODO: save this only once when creating the entity
751 vector sw_color = getcsqcplayercolor(self.sv_entnum); // GetTeamRGB(GetPlayerColor(self.sv_entnum));
753 // WEAPONTODO: trace to find what we actually hit
754 vector endpos = (self.sw_shotorg + (self.sw_shotdir * self.sw_distance));
756 vectorvectors(self.sw_shotdir);
757 vector right = v_right; // save this for when we do makevectors later
758 vector up = v_up; // save this for when we do makevectors later
760 // WEAPONTODO: combine and simplify these calculations
761 vector min_end = ((self.sw_shotorg + (self.sw_shotdir * SW_DISTTOMIN)) + (up * self.sw_spread_min));
762 vector max_end = (endpos + (up * self.sw_spread_max));
763 float spread_to_min = vlen(normalize(min_end - self.sw_shotorg) - self.sw_shotdir);
764 float spread_to_max = vlen(normalize(max_end - min_end) - self.sw_shotdir);
766 vector first_min_end = '0 0 0', prev_min_end = '0 0 0', new_min_end = '0 0 0';
767 vector first_max_end = '0 0 0', prev_max_end = '0 0 0', new_max_end = '0 0 0';
768 float new_max_dist, new_min_dist;
770 vector deviation, angle = '0 0 0';
771 float counter, divisions = 20;
772 for(counter = 0; counter < divisions; ++counter)
774 // perfect circle effect lines
775 makevectors('0 360 0' * (0.75 + (counter - 0.5) / divisions));
776 angle.y = v_forward.x;
777 angle.z = v_forward.y;
779 // first do the spread_to_min effect
780 deviation = angle * spread_to_min;
781 deviation = ((self.sw_shotdir + (right * deviation.y) + (up * deviation.z)));
782 new_min_dist = SW_DISTTOMIN;
783 new_min_end = (self.sw_shotorg + (deviation * new_min_dist));
784 //te_lightning2(world, new_min_end, self.sw_shotorg);
786 // then calculate spread_to_max effect
787 deviation = angle * spread_to_max;
788 deviation = ((self.sw_shotdir + (right * deviation.y) + (up * deviation.z)));
789 new_max_dist = vlen(new_min_end - endpos);
790 new_max_end = (new_min_end + (deviation * new_max_dist));
791 //te_lightning2(world, new_end, prev_min_end);
796 first_min_end = new_min_end;
797 first_max_end = new_max_end;
802 // draw from shot origin to min spread radius
803 R_BeginPolygon("", DRAWFLAG_NORMAL);
804 R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
805 R_PolygonVertex(new_min_end, '0 0 0', sw_color, a);
806 R_PolygonVertex(self.sw_shotorg, '0 0 0', sw_color, a);
809 // draw from min spread radius to max spread radius
810 R_BeginPolygon("", DRAWFLAG_NORMAL);
811 R_PolygonVertex(new_min_end, '0 0 0', sw_color, a);
812 R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
813 R_PolygonVertex(prev_max_end, '0 0 0', sw_color, a);
814 R_PolygonVertex(new_max_end, '0 0 0', sw_color, a);
818 prev_min_end = new_min_end;
819 prev_max_end = new_max_end;
821 // last division only
822 if((counter + 1) == divisions)
824 // draw from shot origin to min spread radius
825 R_BeginPolygon("", DRAWFLAG_NORMAL);
826 R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
827 R_PolygonVertex(first_min_end, '0 0 0', sw_color, a);
828 R_PolygonVertex(self.sw_shotorg, '0 0 0', sw_color, a);
831 // draw from min spread radius to max spread radius
832 R_BeginPolygon("", DRAWFLAG_NORMAL);
833 R_PolygonVertex(first_min_end, '0 0 0', sw_color, a);
834 R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
835 R_PolygonVertex(prev_max_end, '0 0 0', sw_color, a);
836 R_PolygonVertex(first_max_end, '0 0 0', sw_color, a);
842 void Net_ReadShockwaveParticle(void)
846 shockwave.draw = Draw_Shockwave;
848 shockwave.sw_shotorg_x = ReadCoord(); shockwave.sw_shotorg_y = ReadCoord(); shockwave.sw_shotorg_z = ReadCoord();
849 shockwave.sw_shotdir_x = ReadCoord(); shockwave.sw_shotdir_y = ReadCoord(); shockwave.sw_shotdir_z = ReadCoord();
851 shockwave.sw_distance = ReadShort();
852 shockwave.sw_spread_max = ReadByte();
853 shockwave.sw_spread_min = ReadByte();
855 shockwave.sv_entnum = ReadByte();
857 shockwave.sw_time = time;
860 METHOD(Shockwave, wr_impacteffect, bool(entity thiswep))
862 // handled by Net_ReadShockwaveParticle
864 //org2 = w_org + w_backoff * 2;
865 //pointparticles(particleeffectnum(EFFECT_BLASTER_IMPACT), org2, w_backoff * 1000, 1);
868 METHOD(Shockwave, wr_init, bool(entity thiswep))
872 METHOD(Shockwave, wr_zoomreticle, bool(entity thiswep))
874 // no weapon specific image for this weapon