74 lines
3.0 KiB
C#
74 lines
3.0 KiB
C#
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
using Terraria.Audio;
|
|
|
|
namespace CalamityMod.Projectiles.Melee
|
|
{
|
|
public class TinyCrystal : ModProjectile, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Projectiles.Melee";
|
|
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 8;
|
|
Projectile.height = 8;
|
|
Projectile.friendly = true;
|
|
Projectile.DamageType = DamageClass.Melee;
|
|
Projectile.penetrate = 1;
|
|
Projectile.alpha = 255;
|
|
Projectile.timeLeft = 90;
|
|
}
|
|
|
|
public override bool? CanHitNPC(NPC target) => Projectile.timeLeft < 75 && target.CanBeChasedBy(Projectile);
|
|
|
|
public override void AI()
|
|
{
|
|
int dustType = Projectile.ai[0] == 0f ? 56 : 73;
|
|
for (int num92 = 0; num92 < 2; num92++)
|
|
{
|
|
float num93 = Projectile.velocity.X / 3f * (float)num92;
|
|
float num94 = Projectile.velocity.Y / 3f * (float)num92;
|
|
int num95 = 4;
|
|
int num96 = Dust.NewDust(new Vector2(Projectile.position.X + (float)num95, Projectile.position.Y + (float)num95), Projectile.width - num95 * 2, Projectile.height - num95 * 2, dustType, 0f, 0f, 100, default, 1.2f);
|
|
Main.dust[num96].noGravity = true;
|
|
Main.dust[num96].velocity *= 0.1f;
|
|
Main.dust[num96].velocity += Projectile.velocity * 0.1f;
|
|
Dust expr_47FA_cp_0 = Main.dust[num96];
|
|
expr_47FA_cp_0.position.X -= num93;
|
|
Dust expr_4815_cp_0 = Main.dust[num96];
|
|
expr_4815_cp_0.position.Y -= num94;
|
|
}
|
|
|
|
if (Main.rand.NextBool(10))
|
|
{
|
|
int num97 = 4;
|
|
int num98 = Dust.NewDust(new Vector2(Projectile.position.X + (float)num97, Projectile.position.Y + (float)num97), Projectile.width - num97 * 2, Projectile.height - num97 * 2, dustType, 0f, 0f, 100, default, 0.6f);
|
|
Main.dust[num98].velocity *= 0.25f;
|
|
Main.dust[num98].velocity += Projectile.velocity * 0.5f;
|
|
}
|
|
|
|
if (Projectile.timeLeft < 75)
|
|
CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 450f, 9f, 20f);
|
|
}
|
|
|
|
public override void Kill(int timeLeft)
|
|
{
|
|
int dustType = Projectile.ai[0] == 0f ? 56 : 73;
|
|
for (int k = 0; k < 5; k++)
|
|
{
|
|
Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, dustType, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f);
|
|
}
|
|
SoundEngine.PlaySound(SoundID.Item10, Projectile.position);
|
|
}
|
|
|
|
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
|
{
|
|
int buffType = Projectile.ai[0] == 0f ? BuffID.Frostburn : BuffID.OnFire;
|
|
target.AddBuff(buffType, 90);
|
|
}
|
|
}
|
|
}
|