/* fullname */ _("Shockwave")
);
-#define SHOCKWAVE_SETTINGS(w_cvar,w_prop) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_damage) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_distance) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_edgedamage) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_force) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_force_forwardbias) \
- /*w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_force_velocitybias)*/ \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_force_zscale) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_jump_damage) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_jump_edgedamage) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_jump_force) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_jump_force_velocitybias) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_jump_force_zscale) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_jump_multiplier_accuracy) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_jump_multiplier_distance) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_jump_multiplier_min) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_jump_radius) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_multiplier_accuracy) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_multiplier_distance) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_multiplier_min) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_splash_damage) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_splash_edgedamage) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_splash_force) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_splash_force_forwardbias) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_splash_multiplier_accuracy) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_splash_multiplier_distance) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_splash_multiplier_min) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_splash_radius) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_spread_max) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, blast_spread_min) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, melee_animtime) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, melee_damage) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, melee_delay) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, melee_force) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, melee_multihit) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, melee_no_doubleslap) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, melee_nonplayerdamage) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, melee_range) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, melee_refire) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, melee_swing_side) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, melee_swing_up) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, melee_time) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, melee_traces) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, pellets_ammo) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, pellets_animtime) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, pellets_bulletconstant) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, pellets_bullets) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, pellets_damage) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, pellets_force) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, pellets_refire) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, pellets_speed) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, pellets_spread) \
- w_cvar(WEP_SHOCKWAVE, shockwave, MO_NONE, secondary) \
- w_prop(WEP_SHOCKWAVE, shockwave, reloading_ammo, reload_ammo) \
- w_prop(WEP_SHOCKWAVE, shockwave, reloading_time, reload_time) \
- w_prop(WEP_SHOCKWAVE, shockwave, switchdelay_raise, switchdelay_raise) \
- w_prop(WEP_SHOCKWAVE, shockwave, switchdelay_drop, switchdelay_drop)
+#define SHOCKWAVE_SETTINGS(w_cvar,w_prop) SHOCKWAVE_SETTINGS_LIST(w_cvar, w_prop, SHOCKWAVE, shockwave)
+#define SHOCKWAVE_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
+ w_cvar(id, sn, MO_NONE, blast_damage) \
+ w_cvar(id, sn, MO_NONE, blast_distance) \
+ w_cvar(id, sn, MO_NONE, blast_edgedamage) \
+ w_cvar(id, sn, MO_NONE, blast_force) \
+ w_cvar(id, sn, MO_NONE, blast_force_forwardbias) \
+ /*w_cvar(id, sn, MO_NONE, blast_force_velocitybias)*/ \
+ w_cvar(id, sn, MO_NONE, blast_force_zscale) \
+ w_cvar(id, sn, MO_NONE, blast_jump_damage) \
+ w_cvar(id, sn, MO_NONE, blast_jump_edgedamage) \
+ w_cvar(id, sn, MO_NONE, blast_jump_force) \
+ w_cvar(id, sn, MO_NONE, blast_jump_force_velocitybias) \
+ w_cvar(id, sn, MO_NONE, blast_jump_force_zscale) \
+ w_cvar(id, sn, MO_NONE, blast_jump_multiplier_accuracy) \
+ w_cvar(id, sn, MO_NONE, blast_jump_multiplier_distance) \
+ w_cvar(id, sn, MO_NONE, blast_jump_multiplier_min) \
+ w_cvar(id, sn, MO_NONE, blast_jump_radius) \
+ w_cvar(id, sn, MO_NONE, blast_multiplier_accuracy) \
+ w_cvar(id, sn, MO_NONE, blast_multiplier_distance) \
+ w_cvar(id, sn, MO_NONE, blast_multiplier_min) \
+ w_cvar(id, sn, MO_NONE, blast_splash_damage) \
+ w_cvar(id, sn, MO_NONE, blast_splash_edgedamage) \
+ w_cvar(id, sn, MO_NONE, blast_splash_force) \
+ w_cvar(id, sn, MO_NONE, blast_splash_force_forwardbias) \
+ w_cvar(id, sn, MO_NONE, blast_splash_multiplier_accuracy) \
+ w_cvar(id, sn, MO_NONE, blast_splash_multiplier_distance) \
+ w_cvar(id, sn, MO_NONE, blast_splash_multiplier_min) \
+ w_cvar(id, sn, MO_NONE, blast_splash_radius) \
+ w_cvar(id, sn, MO_NONE, blast_spread_max) \
+ w_cvar(id, sn, MO_NONE, blast_spread_min) \
+ w_cvar(id, sn, MO_NONE, melee_animtime) \
+ w_cvar(id, sn, MO_NONE, melee_damage) \
+ w_cvar(id, sn, MO_NONE, melee_delay) \
+ w_cvar(id, sn, MO_NONE, melee_force) \
+ w_cvar(id, sn, MO_NONE, melee_multihit) \
+ w_cvar(id, sn, MO_NONE, melee_no_doubleslap) \
+ w_cvar(id, sn, MO_NONE, melee_nonplayerdamage) \
+ w_cvar(id, sn, MO_NONE, melee_range) \
+ w_cvar(id, sn, MO_NONE, melee_refire) \
+ w_cvar(id, sn, MO_NONE, melee_swing_side) \
+ w_cvar(id, sn, MO_NONE, melee_swing_up) \
+ w_cvar(id, sn, MO_NONE, melee_time) \
+ w_cvar(id, sn, MO_NONE, melee_traces) \
+ w_cvar(id, sn, MO_NONE, pellets_ammo) \
+ w_cvar(id, sn, MO_NONE, pellets_animtime) \
+ w_cvar(id, sn, MO_NONE, pellets_bulletconstant) \
+ w_cvar(id, sn, MO_NONE, pellets_bullets) \
+ w_cvar(id, sn, MO_NONE, pellets_damage) \
+ w_cvar(id, sn, MO_NONE, pellets_force) \
+ w_cvar(id, sn, MO_NONE, pellets_refire) \
+ w_cvar(id, sn, MO_NONE, pellets_speed) \
+ w_cvar(id, sn, MO_NONE, pellets_spread) \
+ w_cvar(id, sn, MO_NONE, primary) \
+ w_cvar(id, sn, MO_NONE, secondary) \
+ w_prop(id, sn, float, reloading_ammo, reload_ammo) \
+ w_prop(id, sn, float, reloading_time, reload_time) \
+ w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
+ w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
+ w_prop(id, sn, string, weaponreplace, weaponreplace) \
+ w_prop(id, sn, float, weaponstart, weaponstart) \
+ w_prop(id, sn, float, weaponstartoverride, weaponstartoverride)
#ifdef SVQC
SHOCKWAVE_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
void W_Shockwave_Pellets(void)
{
float sc;
- float ammoamount;
- float bullets;
- float d;
- float f;
- float spread;
- float bulletspeed;
- float bulletconstant;
entity flash;
- ammoamount = autocvar_g_balance_shockwave_pellets_ammo;
- bullets = autocvar_g_balance_shockwave_pellets_bullets;
- d = autocvar_g_balance_shockwave_pellets_damage;
- f = autocvar_g_balance_shockwave_pellets_force;
- spread = autocvar_g_balance_shockwave_pellets_spread;
- bulletspeed = autocvar_g_balance_shockwave_pellets_speed;
- bulletconstant = autocvar_g_balance_shockwave_pellets_bulletconstant;
+ W_DecreaseAmmo(ammo_shells, WEP_CVAR(shockwave, pellets_ammo), WEP_CVAR(shockwave, reload_ammo));
- W_DecreaseAmmo(ammo_shells, ammoamount, autocvar_g_balance_shockwave_reload_ammo);
-
- W_SetupShot(self, TRUE, 5, "weapons/shockwave_fire.wav", CH_WEAPON_A, d * bullets);
- for(sc = 0;sc < bullets;sc = sc + 1)
- fireBallisticBullet(w_shotorg, w_shotdir, spread, bulletspeed, 5, d, f, WEP_SHOCKWAVE, 0, bulletconstant);
+ W_SetupShot(self, TRUE, 5, "weapons/shockwave_fire.wav", CH_WEAPON_A, WEP_CVAR(shockwave, pellets_damage) * WEP_CVAR(shockwave, pellets_bullets));
+
+ for(sc = 0; sc < WEP_CVAR(shockwave, pellets_bullets); ++sc)
+ {
+ fireBallisticBullet(
+ w_shotorg,
+ w_shotdir,
+ WEP_CVAR(shockwave, pellets_spread),
+ WEP_CVAR(shockwave, pellets_speed),
+ 5,
+ WEP_CVAR(shockwave, pellets_damage),
+ WEP_CVAR(shockwave, pellets_force),
+ WEP_SHOCKWAVE,
+ 0,
+ WEP_CVAR(shockwave, pellets_bulletconstant)
+ );
+ }
endFireBallisticBullet();
- pointparticles(particleeffectnum("shockwave_muzzleflash"), w_shotorg, w_shotdir * 1000, autocvar_g_balance_shockwave_pellets_ammo);
+ pointparticles(particleeffectnum("shockwave_muzzleflash"), w_shotorg, w_shotdir * 1000, WEP_CVAR(shockwave, pellets_ammo));
// casing code
if(autocvar_g_casings >= 1)
- for(sc = 0;sc < ammoamount;sc = sc + 1)
- SpawnCasing(((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 30) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 1, self);
+ {
+ for(sc = 0;sc < WEP_CVAR(shockwave, pellets_ammo); ++sc)
+ {
+ SpawnCasing(
+ (
+ ((random () * 50 + 50) * v_right)
+ -
+ (v_forward * (random () * 25 + 25))
+ -
+ ((random () * 5 - 30) * v_up)
+ ),
+ 2,
+ vectoangles(v_forward),
+ '0 250 0',
+ 100,
+ 1,
+ self
+ );
+ }
+ }
// muzzle flash for 1st person view
flash = spawn();
float distance_from_line = vlen(targetorg - nearest_on_line);
spreadlimit = (distance_of_attack ? min(1, (vlen(sw_shotorg - nearest_on_line) / distance_of_attack)) : 1);
- spreadlimit = (WEP_CVAR(shockwave, blast_spread_min) * (1 - spreadlimit) + WEP_CVAR(shockwave, blast_spread_max) * spreadlimit);
-
+ spreadlimit =
+ (
+ (WEP_CVAR(shockwave, blast_spread_min) * (1 - spreadlimit))
+ +
+ (WEP_CVAR(shockwave, blast_spread_max) * spreadlimit)
+ );
+
if(
(spreadlimit && (distance_from_line <= spreadlimit))
&&
vector final_force,
float final_damage)
{
- if not(head) { return FALSE; }
+ if(!head) { return FALSE; }
float i;
++queue;
{
// declarations
float multiplier, multiplier_from_accuracy, multiplier_from_distance;
- float final_damage; //, final_spread;
+ float final_damage;
vector final_force, center, vel;
- entity head, next;
+ entity head;
float i, queue = 0;
//entity transform = WarpZone_trace_transform;
// do the firing effect now
- //SendCSQCShockwaveParticle(attack_endpos);
- Damage_DamageInfo(attack_hitpos, WEP_CVAR(shockwave, blast_splash_damage), WEP_CVAR(shockwave, blast_splash_edgedamage), WEP_CVAR(shockwave, blast_splash_radius), w_shotdir * WEP_CVAR(shockwave, blast_splash_force), WEP_SHOCKWAVE, 0, self);
+ //SendCSQCShockwaveParticle(attack_endpos); // WEAPONTODO
+ Damage_DamageInfo(
+ attack_hitpos,
+ WEP_CVAR(shockwave, blast_splash_damage),
+ WEP_CVAR(shockwave, blast_splash_edgedamage),
+ WEP_CVAR(shockwave, blast_splash_radius),
+ w_shotdir * WEP_CVAR(shockwave, blast_splash_force),
+ WEP_SHOCKWAVE,
+ 0,
+ self
+ );
// splash damage/jumping trace
- head = WarpZone_FindRadius(attack_hitpos, max(WEP_CVAR(shockwave, blast_splash_radius), WEP_CVAR(shockwave, blast_jump_radius)), FALSE);
+ head = WarpZone_FindRadius(
+ attack_hitpos,
+ max(
+ WEP_CVAR(shockwave, blast_splash_radius),
+ WEP_CVAR(shockwave, blast_jump_radius)
+ ),
+ FALSE
+ );
+
while(head)
{
- next = head.chain;
-
if(head.takedamage)
{
- center = CENTER_OR_VIEWOFS(head);
-
float distance_to_head = vlen(attack_hitpos - head.WarpZone_findradius_nearest);
if((head == self) && (distance_to_head <= WEP_CVAR(shockwave, blast_jump_radius)))
{
- multiplier_from_accuracy = (1 - (distance_to_head ? min(1, (distance_to_head / WEP_CVAR(shockwave, blast_jump_radius))) : 0));
- multiplier_from_distance = (1 - (distance_to_hit ? min(1, (distance_to_hit / distance_to_end)) : 0));
- multiplier = max(WEP_CVAR(shockwave, blast_jump_multiplier_min), ((multiplier_from_accuracy * WEP_CVAR(shockwave, blast_jump_multiplier_accuracy)) + (multiplier_from_distance * WEP_CVAR(shockwave, blast_jump_multiplier_distance))));
-
- final_force = ((normalize(center - attack_hitpos) * WEP_CVAR(shockwave, blast_jump_force)) * multiplier);
- vel = head.velocity; vel_z = 0;
- vel = normalize(vel) * bound(0, vlen(vel) / autocvar_sv_maxspeed, 1) * WEP_CVAR(shockwave, blast_jump_force_velocitybias);
- final_force = (vlen(final_force) * normalize(normalize(final_force) + vel));
+ // ========================
+ // BLAST JUMP CALCULATION
+ // ========================
+
+ // calculate importance of distance and accuracy for this attack
+ multiplier_from_accuracy = (1 -
+ (distance_to_head ?
+ min(1, (distance_to_head / WEP_CVAR(shockwave, blast_jump_radius)))
+ :
+ 0
+ )
+ );
+ multiplier_from_distance = (1 -
+ (distance_to_hit ?
+ min(1, (distance_to_hit / distance_to_end))
+ :
+ 0
+ )
+ );
+ multiplier =
+ max(
+ WEP_CVAR(shockwave, blast_jump_multiplier_min),
+ (
+ (multiplier_from_accuracy * WEP_CVAR(shockwave, blast_jump_multiplier_accuracy))
+ +
+ (multiplier_from_distance * WEP_CVAR(shockwave, blast_jump_multiplier_distance))
+ )
+ );
+
+ // calculate damage from multiplier: 1 = "highest" damage, 0 = "lowest" edgedamage
+ final_damage =
+ (
+ (WEP_CVAR(shockwave, blast_jump_damage) * multiplier)
+ +
+ (WEP_CVAR(shockwave, blast_jump_edgedamage) * (1 - multiplier))
+ );
+
+ // figure out the direction of force
+ vel = normalize(combine_to_vector(head.velocity_x, head.velocity_y, 0));
+ vel *=
+ (
+ bound(0, (vlen(vel) / autocvar_sv_maxspeed), 1)
+ *
+ WEP_CVAR(shockwave, blast_jump_force_velocitybias)
+ );
+ final_force = normalize((CENTER_OR_VIEWOFS(head) - attack_hitpos) + vel);
+
+ // 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_damage = (WEP_CVAR(shockwave, blast_jump_damage) * multiplier + WEP_CVAR(shockwave, blast_jump_edgedamage) * (1 - multiplier));
- Damage(head, self, self, final_damage, WEP_SHOCKWAVE, head.origin, final_force);
- //print("SELF HIT: multiplier = ", ftos(multiplier), strcat(", damage = ", ftos(final_damage), ", force = ", ftos(vlen(final_force))),"... multiplier_from_accuracy = ", ftos(multiplier_from_accuracy), ", multiplier_from_distance = ", ftos(multiplier_from_distance), ".\n");
+ // trigger damage with this calculated info
+ Damage(
+ head,
+ self,
+ self,
+ final_damage,
+ WEP_SHOCKWAVE,
+ head.origin,
+ final_force
+ );
+
+ #ifdef DEBUG_SHOCKWAVE
+ print(sprintf(
+ "SELF HIT: multiplier = %f, damage = %f, force = %f... "
+ "multiplier_from_accuracy = %f, multiplier_from_distance = %f.\n",
+ multiplier,
+ final_damage,
+ vlen(final_force),
+ multiplier_from_accuracy,
+ multiplier_from_distance
+ ));
+ #endif
}
- else if (distance_to_head <= WEP_CVAR(shockwave, blast_splash_radius))
- {
- multiplier_from_accuracy = (1 - (distance_to_head ? min(1, (distance_to_head / WEP_CVAR(shockwave, blast_splash_radius))) : 0));
- multiplier_from_distance = (1 - (distance_to_hit ? min(1, (distance_to_hit / distance_to_end)) : 0));
- multiplier = max(WEP_CVAR(shockwave, blast_splash_multiplier_min), ((multiplier_from_accuracy * WEP_CVAR(shockwave, blast_splash_multiplier_accuracy)) + (multiplier_from_distance * WEP_CVAR(shockwave, blast_splash_multiplier_distance))));
-
- final_force = normalize(center - (attack_hitpos - (w_shotdir * WEP_CVAR(shockwave, blast_splash_force_forwardbias))));
+ else if(distance_to_head <= WEP_CVAR(shockwave, blast_splash_radius))
+ {
+ // ==========================
+ // BLAST SPLASH CALCULATION
+ // ==========================
+
+ // calculate importance of distance and accuracy for this attack
+ multiplier_from_accuracy = (1 -
+ (distance_to_head ?
+ min(1, (distance_to_head / WEP_CVAR(shockwave, blast_splash_radius)))
+ :
+ 0
+ )
+ );
+ multiplier_from_distance = (1 -
+ (distance_to_hit ?
+ min(1, (distance_to_hit / distance_to_end))
+ :
+ 0
+ )
+ );
+ multiplier =
+ max(
+ WEP_CVAR(shockwave, blast_splash_multiplier_min),
+ (
+ (multiplier_from_accuracy * WEP_CVAR(shockwave, blast_splash_multiplier_accuracy))
+ +
+ (multiplier_from_distance * WEP_CVAR(shockwave, blast_splash_multiplier_distance))
+ )
+ );
+
+ // calculate damage from multiplier: 1 = "highest" damage, 0 = "lowest" edgedamage
+ final_damage =
+ (
+ (WEP_CVAR(shockwave, blast_splash_damage) * multiplier)
+ +
+ (WEP_CVAR(shockwave, blast_splash_edgedamage) * (1 - multiplier))
+ );
+
+ // figure out the direction of force
+ final_force = (w_shotdir * WEP_CVAR(shockwave, blast_splash_force_forwardbias));
+ final_force = normalize(CENTER_OR_VIEWOFS(head) - (attack_hitpos - final_force));
//te_lightning2(world, attack_hitpos, (attack_hitpos + (final_force * 200)));
- final_force = ((final_force * WEP_CVAR(shockwave, blast_splash_force)) * multiplier);
+
+ // 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_damage = (WEP_CVAR(shockwave, blast_splash_damage) * multiplier + WEP_CVAR(shockwave, blast_splash_edgedamage) * (1 - multiplier));
+ // queue damage with this calculated info
if(W_Shockwave_Attack_CheckHit(queue, head, final_force, final_damage)) { ++queue; }
- //print("SPLASH HIT: multiplier = ", ftos(multiplier), strcat(", damage = ", ftos(final_damage), ", force = ", ftos(vlen(final_force))),"... multiplier_from_accuracy = ", ftos(multiplier_from_accuracy), ", multiplier_from_distance = ", ftos(multiplier_from_distance), ".\n");
+
+ #ifdef DEBUG_SHOCKWAVE
+ print(sprintf(
+ "SPLASH HIT: multiplier = %f, damage = %f, force = %f... "
+ "multiplier_from_accuracy = %f, multiplier_from_distance = %f.\n",
+ multiplier,
+ final_damage,
+ vlen(final_force),
+ multiplier_from_accuracy,
+ multiplier_from_distance
+ ));
+ #endif
}
}
- head = next;
+ head = head.chain;
}
// cone damage trace
head = WarpZone_FindRadius(w_shotorg, WEP_CVAR(shockwave, blast_distance), FALSE);
while(head)
{
- next = head.chain;
-
if((head != self) && head.takedamage)
{
+ // ========================
+ // BLAST CONE CALCULATION
+ // ========================
+
// if it's a player, use the view origin as reference (stolen from RadiusDamage functions in g_damage.qc)
center = CENTER_OR_VIEWOFS(head);
h = vlen(center - self.origin);
ang = acos(dotproduct(normalize(center - self.origin), w_shotdir));
a = h * cos(ang);
+ // WEAPONTODO: replace with simpler method
vector nearest_on_line = (w_shotorg + a * w_shotdir);
vector nearest_to_attacker = WarpZoneLib_NearestPointOnBox(center + head.mins, center + head.maxs, nearest_on_line);
if((distance_to_target <= WEP_CVAR(shockwave, blast_distance))
&& (W_Shockwave_Attack_IsVisible(head, nearest_on_line, w_shotorg, attack_endpos)))
{
- multiplier_from_accuracy = (1 - W_Shockwave_Attack_CheckSpread(nearest_to_attacker, nearest_on_line, w_shotorg, attack_endpos));
- multiplier_from_distance = (1 - (distance_to_hit ? min(1, (distance_to_target / distance_to_end)) : 0));
- multiplier = max(WEP_CVAR(shockwave, blast_multiplier_min), ((multiplier_from_accuracy * WEP_CVAR(shockwave, blast_multiplier_accuracy)) + (multiplier_from_distance * WEP_CVAR(shockwave, blast_multiplier_distance))));
-
- final_force = normalize(center - (nearest_on_line - (w_shotdir * WEP_CVAR(shockwave, blast_force_forwardbias))));
+ // calculate importance of distance and accuracy for this attack
+ multiplier_from_accuracy = (1 -
+ W_Shockwave_Attack_CheckSpread(
+ nearest_to_attacker,
+ nearest_on_line,
+ w_shotorg,
+ attack_endpos
+ )
+ );
+ multiplier_from_distance = (1 -
+ (distance_to_hit ?
+ min(1, (distance_to_target / distance_to_end))
+ :
+ 0
+ )
+ );
+ multiplier =
+ max(
+ WEP_CVAR(shockwave, blast_multiplier_min),
+ (
+ (multiplier_from_accuracy * WEP_CVAR(shockwave, blast_multiplier_accuracy))
+ +
+ (multiplier_from_distance * WEP_CVAR(shockwave, blast_multiplier_distance))
+ )
+ );
+
+ // calculate damage from multiplier: 1 = "highest" damage, 0 = "lowest" edgedamage
+ final_damage =
+ (
+ (WEP_CVAR(shockwave, blast_damage) * multiplier)
+ +
+ (WEP_CVAR(shockwave, blast_edgedamage) * (1 - multiplier))
+ );
+
+ // figure out the direction of force
+ final_force = (w_shotdir * WEP_CVAR(shockwave, blast_force_forwardbias));
+ final_force = normalize(center - (nearest_on_line - final_force));
//te_lightning2(world, nearest_on_line, (attack_hitpos + (final_force * 200)));
- final_force = ((final_force * WEP_CVAR(shockwave, blast_force)) * multiplier);
+
+ // 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_damage = (WEP_CVAR(shockwave, blast_damage) * multiplier + WEP_CVAR(shockwave, blast_edgedamage) * (1 - multiplier));
+ // queue damage with this calculated info
if(W_Shockwave_Attack_CheckHit(queue, head, final_force, final_damage)) { ++queue; }
- //print("CONE HIT: multiplier = ", ftos(multiplier), strcat(", damage = ", ftos(final_damage), ", force = ", ftos(vlen(final_force))),"... multiplier_from_accuracy = ", ftos(multiplier_from_accuracy), ", multiplier_from_distance = ", ftos(multiplier_from_distance), ".\n");
+
+ #ifdef DEBUG_SHOCKWAVE
+ print(sprintf(
+ "BLAST HIT: multiplier = %f, damage = %f, force = %f... "
+ "multiplier_from_accuracy = %f, multiplier_from_distance = %f.\n",
+ multiplier,
+ final_damage,
+ vlen(final_force),
+ multiplier_from_accuracy,
+ multiplier_from_distance
+ ));
+ #endif
}
}
- head = next;
+ head = head.chain;
}
for(i = 1; i <= queue; ++i)
final_force = shockwave_hit_force[i];
final_damage = shockwave_hit_damage[i];
- Damage(head, self, self, final_damage, WEP_SHOCKWAVE, head.origin, final_force);
- print("SHOCKWAVE by ", self.netname, ": damage = ", ftos(final_damage), ", force = ", ftos(vlen(final_force)), ".\n");
+ Damage(
+ head,
+ self,
+ self,
+ final_damage,
+ WEP_SHOCKWAVE,
+ head.origin,
+ final_force
+ );
+
+ #ifdef DEBUG_SHOCKWAVE
+ print(sprintf(
+ "SHOCKWAVE by %s: damage = %f, force = %f.\n",
+ self.netname,
+ final_damage,
+ vlen(final_force)
+ ));
+ #endif
shockwave_hit[i] = world;
shockwave_hit_force[i] = '0 0 0';
shockwave_hit_damage[i] = 0;
}
- //print("queue was ", ftos(queue), ".\n\n");
}
float W_Shockwave(float req)
{
case WR_AIM:
{
- if(vlen(self.origin-self.enemy.origin) <= WEP_CVAR(shockwave, melee_range))
+ if(vlen(self.origin - self.enemy.origin) <= WEP_CVAR(shockwave, melee_range))
{ self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, FALSE); }
else
{ self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, FALSE); }
}
case WR_THINK:
{
- if(autocvar_g_balance_shockwave_reload_ammo && self.clip_load < autocvar_g_balance_shockwave_pellets_ammo) // forced reload
+ if(WEP_CVAR(shockwave, reload_ammo) && self.clip_load < WEP_CVAR(shockwave, pellets_ammo)) // forced reload
{
// don't force reload an empty shockwave if its melee attack is active
- if(!(autocvar_g_balance_shockwave_secondary && self.ammo_shells < autocvar_g_balance_shockwave_pellets_ammo))
+ if(!(WEP_CVAR(shockwave, secondary) && self.ammo_shells < WEP_CVAR(shockwave, pellets_ammo)))
WEP_ACTION(self.weapon, WR_RELOAD);
}
else
{
- if (self.BUTTON_ATCK)
+ if(self.BUTTON_ATCK)
{
- if (time >= self.shockwave_pelletstime) // handle refire separately so the secondary can be fired straight after a primary
+ switch(WEP_CVAR(shockwave, primary))
{
- if(weapon_prepareattack(0, autocvar_g_balance_shockwave_pellets_animtime))
+ case 1:
+ {
+ if(time >= self.shockwave_pelletstime) // handle refire separately so the secondary can be fired straight after a primary
+ {
+ if(weapon_prepareattack(0, WEP_CVAR(shockwave, pellets_animtime)))
+ {
+ W_Shockwave_Attack();
+ self.shockwave_pelletstime = time + WEP_CVAR(shockwave, pellets_refire) * W_WeaponRateFactor();
+ weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(shockwave, pellets_animtime), w_ready);
+ }
+ }
+ break;
+ }
+ case 2:
{
- W_Shockwave_Attack();
- self.shockwave_pelletstime = time + autocvar_g_balance_shockwave_pellets_refire * W_WeaponRateFactor();
- weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_shockwave_pellets_animtime, w_ready);
+ if(time >= self.shockwave_pelletstime) // handle refire separately so the secondary can be fired straight after a primary
+ {
+ if(weapon_prepareattack(0, WEP_CVAR(shockwave, pellets_animtime)))
+ {
+ W_Shockwave_Pellets();
+ self.shockwave_pelletstime = time + WEP_CVAR(shockwave, pellets_refire) * W_WeaponRateFactor();
+ weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(shockwave, pellets_animtime), w_ready);
+ }
+ }
+ break;
}
}
}
- }
- if (self.clip_load >= 0) // we are not currently reloading
- if (!self.crouch) // no crouchmelee please
- if (self.BUTTON_ATCK2 && autocvar_g_balance_shockwave_secondary)
- if (weapon_prepareattack(1, WEP_CVAR(shockwave, melee_refire)))
- {
- // attempt forcing playback of the anim by switching to another anim (that we never play) here...
- weapon_thinkf(WFRAME_FIRE1, 0, W_Shockwave_Melee);
+
+ if(self.clip_load >= 0) // we are not currently reloading
+ if(!self.crouch) // no crouchmelee please
+ if(self.BUTTON_ATCK2 && WEP_CVAR(shockwave, secondary))
+ if(weapon_prepareattack(1, WEP_CVAR(shockwave, melee_refire)))
+ {
+ // attempt forcing playback of the anim by switching to another anim (that we never play) here...
+ weapon_thinkf(WFRAME_FIRE1, 0, W_Shockwave_Melee);
+ }
}
return TRUE;
}
case WR_CHECKAMMO1:
{
- ammo_amount = self.ammo_shells >= autocvar_g_balance_shockwave_pellets_ammo;
- ammo_amount += self.(weapon_load[WEP_SHOCKWAVE]) >= autocvar_g_balance_shockwave_pellets_ammo;
+ ammo_amount = self.ammo_shells >= WEP_CVAR(shockwave, pellets_ammo);
+ ammo_amount += self.(weapon_load[WEP_SHOCKWAVE]) >= WEP_CVAR(shockwave, pellets_ammo);
return ammo_amount;
}
case WR_CHECKAMMO2:
}
case WR_RELOAD:
{
- W_Reload(autocvar_g_balance_shockwave_pellets_ammo, "weapons/reload.wav");
+ W_Reload(WEP_CVAR(shockwave, pellets_ammo), "weapons/reload.wav");
return TRUE;
}
case WR_SUICIDEMESSAGE: