Files
CalamityModPublic/Projectiles/Melee/TumbleweedRolling.cs
T

73 lines
3.1 KiB
C#

using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.Audio;
namespace CalamityMod.Projectiles.Melee
{
public class TumbleweedRolling : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Melee";
public override string Texture => "CalamityMod/Projectiles/Melee/TumbleweedFlail";
public override void SetDefaults()
{
Projectile.width = 44;
Projectile.height = 44;
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.penetrate = 8;
Projectile.timeLeft = 300;
Projectile.DamageType = DamageClass.MeleeNoSpeed;
}
public override void AI()
{
if ((Projectile.velocity.X != Projectile.velocity.X && (Projectile.velocity.X < -3f || Projectile.velocity.X > 3f)) ||
(Projectile.velocity.Y != Projectile.velocity.Y && (Projectile.velocity.Y < -3f || Projectile.velocity.Y > 3f)))
{
Collision.HitTiles(Projectile.position, Projectile.velocity, Projectile.width, Projectile.height);
SoundEngine.PlaySound(SoundID.NPCHit11, Projectile.position);
}
if (Projectile.velocity.X != Projectile.velocity.X)
{
Projectile.velocity.X = Projectile.velocity.X * -0.5f;
}
if (Projectile.velocity.Y != Projectile.velocity.Y && Projectile.velocity.Y > 1f)
{
Projectile.velocity.Y = Projectile.velocity.Y * -0.5f;
}
Projectile.rotation += Projectile.velocity.X * 0.05f;
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
// TODO -- Make this use proper i-frame variables.
target.immune[Projectile.owner] = 5;
}
public override void Kill(int timeLeft)
{
SoundEngine.PlaySound(SoundID.NPCDeath15, Projectile.position);
for (int num621 = 0; num621 < 20; num621++)
{
int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 32, 0f, 0f, 100, default, 1.2f);
Main.dust[num622].velocity *= 3f;
if (Main.rand.NextBool(2))
{
Main.dust[num622].scale = 0.5f;
Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f;
}
}
for (int num623 = 0; num623 < 30; num623++)
{
int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 85, 0f, 0f, 100, default, 1.7f);
Main.dust[num624].noGravity = true;
Main.dust[num624].velocity *= 5f;
num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 85, 0f, 0f, 100, default, 1f);
Main.dust[num624].velocity *= 2f;
}
}
}
}