Files
CalamityModPublic/Projectiles/Rogue/TheSyringeCinder.cs
T

125 lines
4.6 KiB
C#

using Microsoft.Xna.Framework;
using System;
using Terraria;
using Terraria.ModLoader;
using CalamityMod.Buffs.DamageOverTime;
namespace CalamityMod.Projectiles.Rogue
{
public class TheSyringeCinder : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Rogue";
public override void SetStaticDefaults()
{
Main.projFrames[Projectile.type] = 4;
}
public override void SetDefaults()
{
Projectile.width = 14;
Projectile.height = 14;
Projectile.friendly = true;
Projectile.penetrate = -1;
Projectile.timeLeft = 120;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 10;
Projectile.DamageType = RogueDamageClass.Instance;
Projectile.alpha = 100;
}
public override void AI()
{
//make it face the way it's going
if (Projectile.ai[1] == 1f)
{
Projectile.rotation += Projectile.velocity.X * 0.1f;
Projectile.rotation = -Projectile.velocity.X * 0.05f;
}
else
{
Projectile.rotation = (float)Math.Atan2((double)Projectile.velocity.Y, (double)Projectile.velocity.X) + ((3 * MathHelper.Pi) / 2);
Projectile.spriteDirection = ((Projectile.velocity.X > 0f) ? -1 : 1);
}
//frames
Projectile.frameCounter++;
if (Projectile.frameCounter > 6)
{
Projectile.frame++;
Projectile.frameCounter = 0;
}
if (Projectile.frame > 3)
{
Projectile.frame = 0;
}
//movement
if (Projectile.velocity.X != Projectile.velocity.X)
{
Projectile.velocity.X = Projectile.velocity.X * -0.1f;
}
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.ai[0] += 1f;
if (Projectile.ai[0] > 5f)
{
Projectile.ai[0] = 5f;
if (Projectile.velocity.Y == 0f && Projectile.velocity.X != 0f)
{
Projectile.velocity.X = Projectile.velocity.X * 0.97f;
if ((double)Projectile.velocity.X > -0.01 && (double)Projectile.velocity.X < 0.01)
{
Projectile.velocity.X = 0f;
Projectile.netUpdate = true;
}
}
Projectile.velocity.Y = Projectile.velocity.Y + 0.2f;
}
if (Main.rand.NextBool(4))
{
int num199 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 89, 0f, 0f, 100, default, 1f);
Dust dust = Main.dust[num199];
dust.position.X -= 2f;
dust.position.Y += 2f;
dust.scale += (float)Main.rand.Next(50) * 0.01f;
dust.noGravity = true;
dust.velocity.Y -= 2f;
}
if (Main.rand.NextBool(10))
{
int num200 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 89, 0f, 0f, 100, default, 1f);
Dust dust = Main.dust[num200];
dust.position.X -= 2f;
dust.position.Y += 2f;
dust.scale += 0.3f + (float)Main.rand.Next(50) * 0.01f;
dust.noGravity = true;
dust.velocity *= 0.1f;
}
if ((double)Projectile.velocity.Y < 0.25 && (double)Projectile.velocity.Y > 0.15)
{
Projectile.velocity.X = Projectile.velocity.X * 0.8f;
}
if (Projectile.velocity.Y > 16f)
{
Projectile.velocity.Y = 16f;
}
}
public override bool OnTileCollide(Vector2 oldVelocity)
{
Projectile.ai[1] = 1f;
return false;
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType<Plague>(), 120);
public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType<Plague>(), 120);
}
}