CSQCProjectile(self, TRUE, PROJECTILE_LASER, TRUE);
}
+
+float W_Laser_Shockwave_CheckSpread(vector targetorg, vector nearest_on_line, vector sw_shotorg, vector attack_hitpos)
+{
+ float spreadlimit;
+ float distance_of_attack = vlen(sw_shotorg - attack_hitpos);
+ 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 = (autocvar_g_balance_laser_primary_spread_min * (1 - spreadlimit) + autocvar_g_balance_laser_primary_spread_max * spreadlimit);
+
+ if(spreadlimit && (distance_from_line <= spreadlimit))
+ {
+ //te_lightning2(world, targetorg, nearest_on_line);
+ //te_lightning2(world, targetorg, sw_shotorg);
+ //print("just in case: ", ftos(distance_from_line), ", ", ftos(spreadlimit), ".\n");
+
+ return bound(0, (distance_from_line / spreadlimit), 1);
+ }
+ else
+ return FALSE;
+}
+
+float W_Laser_Shockwave_IsVisible(entity head, vector nearest_on_line, vector sw_shotorg, vector attack_hitpos)
+{
+ vector nearest_to_attacker = head.WarpZone_findradius_nearest;
+ vector center = (head.origin + (head.mins + head.maxs) * 0.5);
+ vector corner;
+ float i;
+
+ // STEP ONE: Check if the nearest point is clear
+ if(W_Laser_Shockwave_CheckSpread(nearest_to_attacker, nearest_on_line, sw_shotorg, attack_hitpos))
+ {
+ WarpZone_TraceLine(sw_shotorg, nearest_to_attacker, MOVE_WORLDONLY, self);
+ 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_Laser_Shockwave_CheckSpread(center, nearest_on_line, sw_shotorg, attack_hitpos))
+ {
+ WarpZone_TraceLine(sw_shotorg, center, MOVE_WORLDONLY, self);
+ 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
+ for(i=1; i<=8; ++i)
+ {
+ corner = get_corner_position(head, i);
+ if(W_Laser_Shockwave_CheckSpread(corner, nearest_on_line, sw_shotorg, attack_hitpos))
+ {
+ WarpZone_TraceLine(sw_shotorg, corner, MOVE_WORLDONLY, self);
+ if(trace_fraction == 1) { return TRUE; } // yes, this corner is clear and we can allow the damage
+ }
+ }
+
+ return FALSE;
+}
+
void W_Laser_Shockwave (void)
{
// declarations
float final_damage, final_spread;
entity head, next, aim_ent;
- vector nearest, attack_hitpos, angle_to_head, angle_to_attack, final_force, center;
+ vector attack_hitpos, final_force, center;
// set up the shot direction
vector wanted_shot_direction = (v_forward * cos(autocvar_g_balance_laser_primary_shotangle * DEG2RAD) + v_up * sin(autocvar_g_balance_laser_primary_shotangle * DEG2RAD));
W_SetupShot_Dir(self, wanted_shot_direction, FALSE, 3, "weapons/lasergun_fire.wav", CH_WEAPON_B, autocvar_g_balance_laser_primary_damage);
vector attack_endpos = (w_shotorg + (w_shotdir * autocvar_g_balance_laser_primary_radius));
- // find out what we're pointing at
+ // find out what we're pointing at and acquire the warpzone transform
WarpZone_TraceLine(w_shotorg, attack_endpos, FALSE, self);
aim_ent = trace_ent;
attack_hitpos = trace_endpos;
// did we hit a player directly?
if(aim_ent.takedamage)
{
- // if it's a player, use the view origin as reference (stolen from RadiusDamage functions in g_damage.qc)
+ // if it's a player, use the view origin as reference (stolen from RadiusDamage functions in g_damage.qc) // todo
if (aim_ent.classname == "player")
center = aim_ent.origin + aim_ent.view_ofs;
else
center = aim_ent.origin + (aim_ent.mins + aim_ent.maxs) * 0.5;
final_force = (normalize(center - attack_hitpos) * autocvar_g_balance_laser_primary_force);
- Damage(aim_ent, self, self, autocvar_g_balance_laser_primary_damage, WEP_LASER, w_shotorg, final_force);
- print("Player hit directly via aim!\n");
+ Damage(aim_ent, self, self, autocvar_g_balance_laser_primary_damage, WEP_LASER, aim_ent.origin, final_force);
}
// now figure out if I hit anything else than what my aim directly pointed at...
if((head != self && head != aim_ent) && (head.takedamage))
{
- // if it's a player, use the view origin as reference (stolen from RadiusDamage functions in g_damage.qc)
+ // if it's a player, use the view origin as reference (stolen from RadiusDamage functions in g_damage.qc) // todo
if (head.classname == "player")
center = head.origin + head.view_ofs;
else
// h = hypotenuse, which is the distance between attacker to head
// a = adjacent side, which is the distance between attacker and the point on w_shotdir that is closest to head.origin
- nearest = WarpZoneLib_NearestPointOnBox(center + head.mins, center + head.maxs, w_shotorg + a * w_shotdir);
+ vector nearest_on_line = (w_shotorg + a * w_shotdir);
+ vector nearest_to_attacker = WarpZoneLib_NearestPointOnBox(center + head.mins, center + head.maxs, nearest_on_line);
+ float distance_to_target = vlen(w_shotorg - nearest_to_attacker);
+ float distance_of_attack = vlen(w_shotorg - attack_hitpos);
- if(vlen(w_shotorg - nearest) <= autocvar_g_balance_laser_primary_radius)
+ if(distance_to_target <= autocvar_g_balance_laser_primary_radius)
{
- // is it within the limit of the spread?
- nearest = head.WarpZone_findradius_nearest;
- angle_to_head = normalize(nearest - w_shotorg);
- angle_to_attack = w_shotdir;
- final_spread = vlen(angle_to_head - angle_to_attack);
- if(final_spread <= autocvar_g_balance_laser_primary_spread)
+ if(W_Laser_Shockwave_IsVisible(head, nearest_on_line, w_shotorg, attack_hitpos))
{
- // TODO! we MUST check this, otherwise you can shoot through walls!
- // just how to make sure that if a small part of the player is visible, we'll hit him?
- // we can just do it the cheap way of tracing from shotorg to nearest, but what if there's an obstruction between those points, but the player still sees the enemy...?
-
- // is it visible to the weapon?
- //WarpZone_TraceLine(w_shotorg, nearest, MOVE_WORLDONLY, self);
- //if(trace_fraction == 1)
- //{
- // finally lets do some damage bitches!
- if(autocvar_g_balance_laser_primary_spread)
- final_damage = (final_spread / autocvar_g_balance_laser_primary_spread);
- else
- final_damage = 1;
-
- //final_force = (normalize(nearest - w_shotorg) * autocvar_g_balance_laser_primary_force); // we dont want to use nearest here, because that would result in some rather weird force dirs for the attacker...
- print(strcat("head.origin: ", vtos(head.origin), ", (w_shotorg + a * w_shotdir): ", vtos(w_shotorg + a * w_shotdir), ".\n"));
- print("a = ", ftos(a), " h = ", ftos(h), " ang = ", ftos(ang), "\n");
- final_force = (normalize(center - (w_shotorg + a * w_shotdir)) * autocvar_g_balance_laser_primary_force);
- final_damage = (autocvar_g_balance_laser_primary_damage * final_damage + autocvar_g_balance_laser_primary_edgedamage * (1 - final_damage));
-
- print(strcat("damage: ", ftos(final_damage), ", force: ", vtos(final_force), ".\n"));
-
- Damage(head, self, self, final_damage, WEP_LASER, head.origin, final_force);
-
- print(strcat(vtos(angle_to_head), " - ", vtos(angle_to_attack), ": ", ftos(vlen(angle_to_head - angle_to_attack)), ".\n"));
- //te_lightning2(world, nearest, w_shotorg);
-
- //pointparticles(particleeffectnum("rocket_guide"), w_shotorg, w_shotdir * 1000, 1);
- //SendCSQCShockwaveParticle(autocvar_g_balance_laser_primary_spread, trace_endpos);
- //}
+ float multiplier_from_accuracy = (1 - W_Laser_Shockwave_CheckSpread(nearest_to_attacker, nearest_on_line, w_shotorg, attack_hitpos));
+ float multiplier_from_distance = (1 - (distance_of_attack ? min(1, (distance_to_target / autocvar_g_balance_laser_primary_radius)) : 1));
+
+ float multiplier = max(autocvar_g_balance_laser_primary_multiplier_min, ((multiplier_from_accuracy * autocvar_g_balance_laser_primary_multiplier_accuracy) + (multiplier_from_distance * autocvar_g_balance_laser_primary_multiplier_distance)));
+ print("multiplier = ", ftos(multiplier), ", multiplier_from_accuracy = ", ftos(multiplier_from_accuracy), ", multiplier_from_distance = ", ftos(multiplier_from_distance), "\n");
+
+ //print(strcat("head.origin: ", vtos(head.origin), ", nearest_on_line: ", vtos(nearest_on_line), ".\n"));
+ final_force = ((normalize(center - nearest_on_line) * autocvar_g_balance_laser_primary_force) * multiplier);
+ final_damage = (autocvar_g_balance_laser_primary_damage * multiplier + autocvar_g_balance_laser_primary_edgedamage * (1 - multiplier));
+
+ print(strcat("damage: ", ftos(final_damage), ", force: ", vtos(final_force), ".\n"));
+
+ Damage(head, self, self, final_damage, WEP_LASER, head.origin, final_force);
+
+ //pointparticles(particleeffectnum("rocket_guide"), w_shotorg, w_shotdir * 1000, 1);
+ //SendCSQCShockwaveParticle(autocvar_g_balance_laser_primary_spread, trace_endpos);
}
}
}
missile.touch = W_Laser_Touch;
missile.flags = FL_PROJECTILE;
+ missile.missile_flags = MIF_SPLASH;
missile.think = W_Laser_Think;
missile.nextthink = time + autocvar_g_balance_laser_primary_delay;
{
W_DecreaseAmmo(ammo_none, 1, TRUE);
- W_Laser_Shockwave();
+
+ if not(autocvar_g_balance_laser_oldprimary)
+ W_Laser_Shockwave();
+ else
+ W_Laser_Attack(FALSE);
+
weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_laser_primary_animtime, w_ready);
}
}
else if (self.BUTTON_ATCK2)
{
- if(autocvar_g_balance_laser_secondary)
+ switch(autocvar_g_balance_laser_secondary)
{
- W_DecreaseAmmo(ammo_none, 1, TRUE);
+ case 0: // switch to last used weapon
+ {
+ if(self.switchweapon == WEP_LASER) // don't do this if already switching
+ W_LastWeapon();
- if (weapon_prepareattack(0, 0))
+ break;
+ }
+
+ case 1: // normal projectile secondary
{
- W_Laser_Attack2();
- weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_laser_secondary_animtime, w_ready);
+ if(weapon_prepareattack(0, autocvar_g_balance_laser_secondary_refire))
+ {
+ W_DecreaseAmmo(ammo_none, 1, TRUE);
+ W_Laser_Attack(TRUE);
+ weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_laser_secondary_animtime, w_ready);
+ }
+
+ break;
+ }
+
+ case 2: // gauntlet secondary
+ {
+ W_DecreaseAmmo(ammo_none, 1, TRUE);
+
+ if (weapon_prepareattack(0, 0))
+ {
+ W_Laser_Attack2();
+ weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_laser_secondary_animtime, w_ready);
+ }
+
+ break;
}
- }
- else
- {
- if(self.switchweapon == WEP_LASER) // don't do this if already switching
- W_LastWeapon();
}
}
}
{
vector org2;
org2 = w_org + w_backoff * 6;
- pointparticles(particleeffectnum("laser_impact"), org2, w_backoff * 1000, 1);
+ pointparticles(particleeffectnum("new_laser_impact"), org2, w_backoff * 1000, 1);
if(!w_issilent)
sound(self, CH_SHOTS, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM);
}