73 lines
1.9 KiB
C#
73 lines
1.9 KiB
C#
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.Audio;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace FabusMod.Projectiles.SorcerousStaff;
|
|
|
|
public class TranquilityProj : ModProjectile
|
|
{
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 10;
|
|
Projectile.height = 10;
|
|
Projectile.light = 1f;
|
|
AIType = 1;
|
|
Projectile.aiStyle = 1;
|
|
Projectile.friendly = true;
|
|
Projectile.penetrate = 1;
|
|
Projectile.timeLeft = 600;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
if (Utils.NextFloat(Main.rand) < 0.1f && Projectile.alpha <= 100)
|
|
{
|
|
int dust1 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, ModContent.DustType<Dusts.RainbowDust>());
|
|
Main.dust[dust1].scale = 0.9f;
|
|
Main.dust[dust1].velocity *= 0.1f;
|
|
Main.dust[dust1].noGravity = true;
|
|
|
|
int dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, ModContent.DustType<Dusts.RainbowDust2>());
|
|
Main.dust[dust2].scale = 0.9f;
|
|
Main.dust[dust2].velocity *= 0.1f;
|
|
Main.dust[dust2].noGravity = true;
|
|
|
|
int dust3 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, ModContent.DustType<Dusts.RainbowDust3>());
|
|
Main.dust[dust3].scale = 0.9f;
|
|
Main.dust[dust3].velocity *= 0.1f;
|
|
Main.dust[dust3].noGravity = true;
|
|
}
|
|
}
|
|
|
|
public override bool OnTileCollide(Vector2 oldVelocity)
|
|
{
|
|
Projectile.penetrate--;
|
|
if (Projectile.penetrate <= 0)
|
|
{
|
|
Projectile.Kill();
|
|
}
|
|
else
|
|
{
|
|
Projectile.ai[0] += 0.1f;
|
|
if (Projectile.velocity.X != oldVelocity.X)
|
|
{
|
|
Projectile.velocity.X = 0f - oldVelocity.X;
|
|
}
|
|
if (Projectile.velocity.Y != oldVelocity.Y)
|
|
{
|
|
Projectile.velocity.Y = 0f - oldVelocity.Y;
|
|
}
|
|
Projectile.velocity *= 0.75f;
|
|
SoundEngine.PlaySound(SoundID.Item27, Projectile.position);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public override void Kill(int timeLeft)
|
|
{
|
|
SoundEngine.PlaySound(SoundID.Item27, Projectile.position);
|
|
}
|
|
}
|