increased hyperius bullet accuracy

This commit is contained in:
termigator1359 committed 2020-06-29 23:48:13 -04:00
1 parent 91ba51125d
commit 2f41ebaec9
1 file changed
+10 -25
+10 -25
View File
@@ -75,35 +75,20 @@ namespace CalamityMod.Projectiles.Ranged
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
float xPos = Main.rand.NextBool(2) ? projectile.position.X + 800 : projectile.position.X - 800;
Vector2 vector2 = new Vector2(xPos, projectile.position.Y + Main.rand.Next(-800, 801));
float num80 = xPos;
float speedX = (float)target.position.X - vector2.X;
float speedY = (float)target.position.Y - vector2.Y;
float dir = 10 / num80;
speedX *= dir * 150;
speedY *= dir * 150;
if (speedX > 15f)
{
speedX = 15f;
}
if (speedX < -15f)
{
speedX = -15f;
}
if (speedY > 15f)
{
speedY = 15f;
}
if (speedY < -15f)
{
speedY = -15f;
}
float xPos = projectile.Center.X + 800 * Main.rand.NextBool(2).ToDirectionInt();
float yPos = projectile.Center.Y + Main.rand.Next(-800, 801);
Vector2 spawnPosition = new Vector2(xPos, yPos);
Vector2 velocity = target.Center - spawnPosition;
float dir = 10 / spawnPosition.X;
velocity.X *= dir * 150;
velocity.Y *= dir * 150;
velocity.X = MathHelper.Clamp(velocity.X, -15f, 15f);
velocity.Y = MathHelper.Clamp(velocity.Y, -15f, 15f);
if (projectile.owner == Main.myPlayer)
{
int splitDamage = (int)(projectile.damage * 0.6f);
float splitKB = 1f;
Projectile.NewProjectile(vector2, new Vector2(speedX, speedY), ModContent.ProjectileType<HyperiusSplit>(), splitDamage, splitKB, projectile.owner);
Projectile.NewProjectile(spawnPosition, velocity, ModContent.ProjectileType<HyperiusSplit>(), splitDamage, splitKB, projectile.owner);
}
}