/* function */ W_Shockwave,
/* ammotype */ ammo_none,
/* impulse */ 2,
-/* flags */ WEP_FLAG_NORMAL | WEP_TYPE_HITSCAN,
+/* flags */ WEP_FLAG_NORMAL | WEP_TYPE_HITSCAN | WEP_FLAG_CANCLIMB | WEP_FLAG_MUTATORBLOCKED,
/* rating */ BOT_PICKUP_RATING_LOW,
/* color */ '0.5 0.25 0',
/* modelname */ "shotgun",
#ifdef SVQC
SHOCKWAVE_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
#endif
+#ifdef CSQC
+void Net_ReadShockwaveParticle(void);
+.vector sw_shotorg;
+.vector sw_shotdir;
+.float sw_distance;
+.float sw_spread_max;
+.float sw_spread_min;
+.float sw_time;
+#endif
#else
#ifdef SVQC
void spawnfunc_weapon_shockwave(void)
weapon_defaultspawnfunc(WEP_SHOCKWAVE);
}
-#define MAX_SHOCKWAVE_HITS 10
-#define DEBUG_SHOCKWAVE
+const float MAX_SHOCKWAVE_HITS = 10;
+//#define DEBUG_SHOCKWAVE
.float swing_prev;
.entity swing_alreadyhit;
self.realowner,
(self.realowner.origin + self.realowner.view_ofs),
targpos,
- FALSE,
+ false,
self.realowner,
ANTILAG_LATENCY(self.realowner)
);
// draw lightning beams for debugging
+#ifdef DEBUG_SHOCKWAVE
te_lightning2(world, targpos, self.realowner.origin + self.realowner.view_ofs + v_forward * 5 - v_up * 5);
te_customflash(targpos, 40, 2, '1 1 1');
+#endif
- is_player = (trace_ent.classname == "player" || trace_ent.classname == "body" || (trace_ent.flags & FL_MONSTER));
+ is_player = (IS_PLAYER(trace_ent) || trace_ent.classname == "body" || (trace_ent.flags & FL_MONSTER));
if((trace_fraction < 1) // if trace is good, apply the damage and remove self if necessary
&& (trace_ent.takedamage == DAMAGE_AIM)
meleetemp.owner = meleetemp.realowner = self;
meleetemp.think = W_Shockwave_Melee_Think;
meleetemp.nextthink = time + WEP_CVAR(shockwave, melee_delay) * W_WeaponRateFactor();
- W_SetupShot_Range(self, TRUE, 0, "", 0, WEP_CVAR(shockwave, melee_damage), WEP_CVAR(shockwave, melee_range));
+ W_SetupShot_Range(self, true, 0, "", 0, WEP_CVAR(shockwave, melee_damage), WEP_CVAR(shockwave, melee_range));
}
// SHOCKWAVE ATTACK MODE
)
{ return bound(0, (distance_from_line / spreadlimit), 1); }
else
- { return FALSE; }
+ { return false; }
}
float W_Shockwave_Attack_IsVisible(
if(W_Shockwave_Attack_CheckSpread(nearest_to_attacker, nearest_on_line, sw_shotorg, attack_endpos))
{
WarpZone_TraceLine(sw_shotorg, nearest_to_attacker, MOVE_NOMONSTERS, self);
- if(trace_fraction == 1) { return TRUE; } // yes, the nearest point is clear and we can allow the damage
+ if(trace_fraction == 1) { return true; } // yes, the nearest point is clear and we can allow the damage
}
// STEP TWO: Check if shotorg to center point is clear
if(W_Shockwave_Attack_CheckSpread(center, nearest_on_line, sw_shotorg, attack_endpos))
{
WarpZone_TraceLine(sw_shotorg, center, MOVE_NOMONSTERS, self);
- if(trace_fraction == 1) { return TRUE; } // yes, the center point is clear and we can allow the damage
+ if(trace_fraction == 1) { return true; } // yes, the center point is clear and we can allow the damage
}
// STEP THREE: Check each corner to see if they are clear
if(W_Shockwave_Attack_CheckSpread(corner, nearest_on_line, sw_shotorg, attack_endpos))
{
WarpZone_TraceLine(sw_shotorg, corner, MOVE_NOMONSTERS, self);
- if(trace_fraction == 1) { return TRUE; } // yes, this corner is clear and we can allow the damage
+ if(trace_fraction == 1) { return true; } // yes, this corner is clear and we can allow the damage
}
}
- return FALSE;
+ return false;
}
float W_Shockwave_Attack_CheckHit(
vector final_force,
float final_damage)
{
- if(!head) { return FALSE; }
+ if(!head) { return false; }
float i;
for(i = 0; i <= queue; ++i)
{
if(vlen(final_force) > vlen(shockwave_hit_force[i])) { shockwave_hit_force[i] = final_force; }
if(final_damage > shockwave_hit_damage[i]) { shockwave_hit_damage[i] = final_damage; }
- return FALSE;
+ return false;
}
}
shockwave_hit[queue] = head;
shockwave_hit_force[queue] = final_force;
shockwave_hit_damage[queue] = final_damage;
- return TRUE;
+ return true;
}
void W_Shockwave_Send(void)
{
WriteByte(MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte(MSG_BROADCAST, TE_CSQC_SHOCKWAVEPARTICLE);
- WriteCoord(MSG_BROADCAST, w_shotorg_x);
- WriteCoord(MSG_BROADCAST, w_shotorg_y);
- WriteCoord(MSG_BROADCAST, w_shotorg_z);
- WriteCoord(MSG_BROADCAST, w_shotdir_x);
- WriteCoord(MSG_BROADCAST, w_shotdir_y);
- WriteCoord(MSG_BROADCAST, w_shotdir_z);
+ WriteCoord(MSG_BROADCAST, w_shotorg.x);
+ WriteCoord(MSG_BROADCAST, w_shotorg.y);
+ WriteCoord(MSG_BROADCAST, w_shotorg.z);
+ WriteCoord(MSG_BROADCAST, w_shotdir.x);
+ WriteCoord(MSG_BROADCAST, w_shotdir.y);
+ WriteCoord(MSG_BROADCAST, w_shotdir.z);
WriteShort(MSG_BROADCAST, WEP_CVAR(shockwave, blast_distance));
WriteByte(MSG_BROADCAST, bound(0, WEP_CVAR(shockwave, blast_spread_max), 255));
WriteByte(MSG_BROADCAST, bound(0, WEP_CVAR(shockwave, blast_spread_min), 255));
float i, queue = 0;
// set up the shot direction
- W_SetupShot(self, FALSE, 3, "weapons/lasergun_fire.wav", CH_WEAPON_B, WEP_CVAR(shockwave, blast_damage));
+ W_SetupShot(self, false, 3, "weapons/lasergun_fire.wav", CH_WEAPON_B, WEP_CVAR(shockwave, blast_damage));
vector attack_endpos = (w_shotorg + (w_shotdir * WEP_CVAR(shockwave, blast_distance)));
WarpZone_TraceLine(w_shotorg, attack_endpos, MOVE_NOMONSTERS, self);
vector attack_hitpos = trace_endpos;
WEP_CVAR(shockwave, blast_splash_radius),
WEP_CVAR(shockwave, blast_jump_radius)
),
- FALSE
+ false
);
while(head)
);
// figure out the direction of force
- vel = normalize(combine_to_vector(head.velocity_x, head.velocity_y, 0));
+ vel = normalize(combine_to_vector(head.velocity.x, head.velocity.y, 0));
vel *=
(
bound(0, (vlen(vel) / autocvar_sv_maxspeed), 1)
// now multiply the direction by force units
final_force *= (WEP_CVAR(shockwave, blast_jump_force) * multiplier);
- final_force_z *= WEP_CVAR(shockwave, blast_jump_force_zscale);
+ final_force.z *= WEP_CVAR(shockwave, blast_jump_force_zscale);
// trigger damage with this calculated info
Damage(
// now multiply the direction by force units
final_force *= (WEP_CVAR(shockwave, blast_splash_force) * multiplier);
- final_force_z *= WEP_CVAR(shockwave, blast_force_zscale);
+ final_force.z *= WEP_CVAR(shockwave, blast_force_zscale);
// queue damage with this calculated info
if(W_Shockwave_Attack_CheckHit(queue, head, final_force, final_damage)) { queue = min(queue + 1, MAX_SHOCKWAVE_HITS); }
}
// cone damage trace
- head = WarpZone_FindRadius(w_shotorg, WEP_CVAR(shockwave, blast_distance), FALSE);
+ head = WarpZone_FindRadius(w_shotorg, WEP_CVAR(shockwave, blast_distance), false);
while(head)
{
if((head != self) && head.takedamage)
// now multiply the direction by force units
final_force *= (WEP_CVAR(shockwave, blast_force) * multiplier);
- final_force_z *= WEP_CVAR(shockwave, blast_force_zscale);
+ final_force.z *= WEP_CVAR(shockwave, blast_force_zscale);
// queue damage with this calculated info
if(W_Shockwave_Attack_CheckHit(queue, head, final_force, final_damage)) { queue = min(queue + 1, MAX_SHOCKWAVE_HITS); }
case WR_AIM:
{
if(vlen(self.origin - self.enemy.origin) <= WEP_CVAR(shockwave, melee_range))
- { self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, FALSE); }
+ { self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, false); }
else
- { self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, FALSE); }
+ { self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, false); }
- return TRUE;
+ return true;
}
case WR_THINK:
{
}
}
- return TRUE;
+ return true;
}
case WR_INIT:
{
precache_model("models/uziflash.md3");
- precache_model("models/weapons/g_shockwave.md3");
- precache_model("models/weapons/v_shockwave.md3");
- precache_model("models/weapons/h_shockwave.iqm");
+ precache_model("models/weapons/g_shotgun.md3");
+ precache_model("models/weapons/v_shotgun.md3");
+ precache_model("models/weapons/h_shotgun.iqm");
precache_sound("misc/itempickup.wav");
- precache_sound("weapons/shockwave_fire.wav");
- precache_sound("weapons/shockwave_melee.wav");
+ precache_sound("weapons/lasergun_fire.wav");
+ precache_sound("weapons/shotgun_melee.wav");
SHOCKWAVE_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP)
- return TRUE;
+ return true;
}
case WR_CHECKAMMO1:
case WR_CHECKAMMO2:
{
// shockwave has infinite ammo
- return TRUE;
+ return true;
}
case WR_CONFIG:
{
SHOCKWAVE_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
- return TRUE;
+ return true;
}
case WR_SUICIDEMESSAGE:
{
return WEAPON_SHOCKWAVE_MURDER;
}
}
- return FALSE;
+ return false;
}
#endif
#ifdef CSQC
+// WEAPONTODO: add client side settings for these
+const float SW_MAXALPHA = 0.5;
+const float SW_FADETIME = 0.4;
+const float SW_DISTTOMIN = 200;
+void Draw_Shockwave()
+{
+ // fading/removal control
+ float a = bound(0, (SW_MAXALPHA - ((time - self.sw_time) / SW_FADETIME)), SW_MAXALPHA);
+ if(a < ALPHA_MIN_VISIBLE) { remove(self); }
+
+ // WEAPONTODO: save this only once when creating the entity
+ vector sw_color = getcsqcplayercolor(self.sv_entnum); // GetTeamRGB(GetPlayerColor(self.sv_entnum));
+
+ // WEAPONTODO: trace to find what we actually hit
+ vector endpos = (self.sw_shotorg + (self.sw_shotdir * self.sw_distance));
+
+ vectorvectors(self.sw_shotdir);
+ vector right = v_right; // save this for when we do makevectors later
+ vector up = v_up; // save this for when we do makevectors later
+
+ // WEAPONTODO: combine and simplify these calculations
+ vector min_end = ((self.sw_shotorg + (self.sw_shotdir * SW_DISTTOMIN)) + (up * self.sw_spread_min));
+ vector max_end = (endpos + (up * self.sw_spread_max));
+ float spread_to_min = vlen(normalize(min_end - self.sw_shotorg) - self.sw_shotdir);
+ float spread_to_max = vlen(normalize(max_end - min_end) - self.sw_shotdir);
+
+ vector first_min_end = '0 0 0', prev_min_end = '0 0 0', new_min_end = '0 0 0';
+ vector first_max_end = '0 0 0', prev_max_end = '0 0 0', new_max_end = '0 0 0';
+ float new_max_dist, new_min_dist;
+
+ vector deviation, angle = '0 0 0';
+ float counter, divisions = 20;
+ for(counter = 0; counter < divisions; ++counter)
+ {
+ // perfect circle effect lines
+ makevectors('0 360 0' * (0.75 + (counter - 0.5) / divisions));
+ angle_y = v_forward.x;
+ angle_z = v_forward.y;
+
+ // first do the spread_to_min effect
+ deviation = angle * spread_to_min;
+ deviation = ((self.sw_shotdir + (right * deviation.y) + (up * deviation.z)));
+ new_min_dist = SW_DISTTOMIN;
+ new_min_end = (self.sw_shotorg + (deviation * new_min_dist));
+ //te_lightning2(world, new_min_end, self.sw_shotorg);
+
+ // then calculate spread_to_max effect
+ deviation = angle * spread_to_max;
+ deviation = ((self.sw_shotdir + (right * deviation.y) + (up * deviation.z)));
+ new_max_dist = vlen(new_min_end - endpos);
+ new_max_end = (new_min_end + (deviation * new_max_dist));
+ //te_lightning2(world, new_end, prev_min_end);
+
+
+ if(counter == 0)
+ {
+ first_min_end = new_min_end;
+ first_max_end = new_max_end;
+ }
+
+ if(counter >= 1)
+ {
+ // draw from shot origin to min spread radius
+ R_BeginPolygon("", DRAWFLAG_NORMAL);
+ R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
+ R_PolygonVertex(new_min_end, '0 0 0', sw_color, a);
+ R_PolygonVertex(self.sw_shotorg, '0 0 0', sw_color, a);
+ R_EndPolygon();
+
+ // draw from min spread radius to max spread radius
+ R_BeginPolygon("", DRAWFLAG_NORMAL);
+ R_PolygonVertex(new_min_end, '0 0 0', sw_color, a);
+ R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
+ R_PolygonVertex(prev_max_end, '0 0 0', sw_color, a);
+ R_PolygonVertex(new_max_end, '0 0 0', sw_color, a);
+ R_EndPolygon();
+ }
+
+ prev_min_end = new_min_end;
+ prev_max_end = new_max_end;
+
+ // last division only
+ if((counter + 1) == divisions)
+ {
+ // draw from shot origin to min spread radius
+ R_BeginPolygon("", DRAWFLAG_NORMAL);
+ R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
+ R_PolygonVertex(first_min_end, '0 0 0', sw_color, a);
+ R_PolygonVertex(self.sw_shotorg, '0 0 0', sw_color, a);
+ R_EndPolygon();
+
+ // draw from min spread radius to max spread radius
+ R_BeginPolygon("", DRAWFLAG_NORMAL);
+ R_PolygonVertex(first_min_end, '0 0 0', sw_color, a);
+ R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
+ R_PolygonVertex(prev_max_end, '0 0 0', sw_color, a);
+ R_PolygonVertex(first_max_end, '0 0 0', sw_color, a);
+ R_EndPolygon();
+ }
+ }
+}
+
+void Net_ReadShockwaveParticle(void)
+{
+ entity shockwave;
+ shockwave = spawn();
+ shockwave.draw = Draw_Shockwave;
+
+ shockwave.sw_shotorg_x = ReadCoord(); shockwave.sw_shotorg_y = ReadCoord(); shockwave.sw_shotorg_z = ReadCoord();
+ shockwave.sw_shotdir_x = ReadCoord(); shockwave.sw_shotdir_y = ReadCoord(); shockwave.sw_shotdir_z = ReadCoord();
+
+ shockwave.sw_distance = ReadShort();
+ shockwave.sw_spread_max = ReadByte();
+ shockwave.sw_spread_min = ReadByte();
+
+ shockwave.sv_entnum = ReadByte();
+
+ shockwave.sw_time = time;
+}
+
float W_Shockwave(float req)
{
switch(req)
{
case WR_IMPACTEFFECT:
{
- vector org2;
- org2 = w_org + w_backoff * 2;
- pointparticles(particleeffectnum("laser_impact"), org2, w_backoff * 1000, 1); // WEAPONTODO: replace with proper impact effect
- return TRUE;
+ // handled by Net_ReadShockwaveParticle
+ //vector org2;
+ //org2 = w_org + w_backoff * 2;
+ //pointparticles(particleeffectnum("laser_impact"), org2, w_backoff * 1000, 1);
+ return false;
}
case WR_INIT:
{
//precache_sound("weapons/ric1.wav");
//precache_sound("weapons/ric2.wav");
//precache_sound("weapons/ric3.wav");
- return FALSE;
+ return false;
}
case WR_ZOOMRETICLE:
{
// no weapon specific image for this weapon
- return FALSE;
+ return false;
}
}
- return FALSE;
+ return false;
}
#endif
#endif