Files
CalamityModPublic/Projectiles/Magic/WaterStream.cs
T
2023-05-28 06:14:26 +07:00

71 lines
3.0 KiB
C#

using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Magic
{
public class WaterStream : ModProjectile
{
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public override void SetDefaults()
{
Projectile.width = 32;
Projectile.height = 32;
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.penetrate = 3;
Projectile.extraUpdates = 2;
Projectile.DamageType = DamageClass.Magic;
Projectile.tileCollide = false;
}
public override void AI()
{
Projectile.ai[1]++;
if (Projectile.ai[1] >= 4f)
{
Projectile.tileCollide = true;
}
if (Projectile.timeLeft % 20 == 0)
{
if (Projectile.owner == Main.myPlayer)
{
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, 0f, 0f, ModContent.ProjectileType<WaterStream2>(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f);
}
}
Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0f / 255f, (255 - Projectile.alpha) * 0.15f / 255f, (255 - Projectile.alpha) * 0.25f / 255f);
Projectile.scale -= 0.002f;
if (Projectile.scale <= 0f)
{
Projectile.Kill();
}
if (Projectile.ai[0] <= 3f)
{
Projectile.ai[0] += 1f;
return;
}
Projectile.velocity.Y = Projectile.velocity.Y + 0.075f;
for (int num151 = 0; num151 < 3; num151++)
{
float num152 = Projectile.velocity.X / 3f * (float)num151;
float num153 = Projectile.velocity.Y / 3f * (float)num151;
int num154 = 14;
int num155 = Dust.NewDust(new Vector2(Projectile.position.X + (float)num154, Projectile.position.Y + (float)num154), Projectile.width - num154 * 2, Projectile.height - num154 * 2, 14, 0f, 0f, 100, new Color(0, 255, 255), 1f);
Dust dust = Main.dust[num155];
dust.noGravity = true;
dust.velocity *= 0.1f;
dust.velocity += Projectile.velocity * 0.5f;
dust.position.X -= num152;
dust.position.Y -= num153;
}
if (Main.rand.NextBool(8))
{
int num156 = 16;
int num157 = Dust.NewDust(new Vector2(Projectile.position.X + (float)num156, Projectile.position.Y + (float)num156), Projectile.width - num156 * 2, Projectile.height - num156 * 2, 14, 0f, 0f, 100, new Color(0, 255, 255), 0.5f);
Main.dust[num157].velocity *= 0.25f;
Main.dust[num157].velocity += Projectile.velocity * 0.5f;
}
}
}
}