Files
CalamityModPublic/Projectiles/Magic/GleamingBolt.cs
T
Andrew Marheine 79752074bd 1 - Cryogen no longer drops Frost Cores.
2 - Adjusted more homing projectile code.
2021-04-06 21:55:12 -05:00

67 lines
2.6 KiB
C#

using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Magic
{
public class GleamingBolt : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Bolt");
}
public override void SetDefaults()
{
projectile.width = 26;
projectile.height = 26;
projectile.friendly = true;
projectile.timeLeft = 250;
projectile.penetrate = 1;
projectile.magic = true;
}
public override void AI()
{
projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * projectile.direction;
projectile.velocity *= 0.985f;
for (int dust = 0; dust < 2; dust++)
{
int randomDust = Utils.SelectRandom(Main.rand, new int[]
{
64,
204
});
Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, randomDust, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f);
}
}
public override void Kill(int timeLeft)
{
for (int k = 0; k < 5; k++)
{
int randomDust = Utils.SelectRandom(Main.rand, new int[]
{
64,
204
});
Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, randomDust, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f);
}
float spread = 90f * 0.0174f;
double startAngle = Math.Atan2(projectile.velocity.X, projectile.velocity.Y) - spread / 2;
double deltaAngle = spread / 8f;
double offsetAngle;
if (projectile.owner == Main.myPlayer)
{
for (int i = 0; i < 3; i++)
{
offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i;
Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType<GleamingBolt2>(), (int)(projectile.damage * 0.75), projectile.knockBack, projectile.owner, 0f, 0f);
Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType<GleamingBolt2>(), (int)(projectile.damage * 0.75), projectile.knockBack, projectile.owner, 0f, 0f);
}
}
Main.PlaySound(SoundID.Item105, projectile.position);
}
}
}