Files
CalamityModPublic/Projectiles/Enemy/InkPoisonCloud3.cs
T

75 lines
2.2 KiB
C#

using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Enemy
{
public class InkPoisonCloud3 : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Ink Cloud");
Main.projFrames[Projectile.type] = 4;
}
public override void SetDefaults()
{
Projectile.width = 52;
Projectile.height = 48;
Projectile.hostile = true;
Projectile.alpha = 255;
Projectile.penetrate = -1;
Projectile.tileCollide = false;
Projectile.ignoreWater = true;
Projectile.timeLeft = 3600;
}
public override void AI()
{
Projectile.frameCounter++;
if (Projectile.frameCounter > 9)
{
Projectile.frame++;
Projectile.frameCounter = 0;
}
if (Projectile.frame > 3)
Projectile.frame = 0;
Projectile.velocity *= 0.999f;
Projectile.ai[0] += 1f;
if (Projectile.ai[0] >= 120f)
{
if (Projectile.alpha < 255)
{
Projectile.alpha += 5;
if (Projectile.alpha > 255)
Projectile.alpha = 255;
}
else if (Projectile.owner == Main.myPlayer)
Projectile.Kill();
}
else if (Projectile.alpha > 80)
{
Projectile.alpha -= 30;
if (Projectile.alpha < 80)
Projectile.alpha = 80;
}
}
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 20f, targetHitbox);
public override bool CanHitPlayer(Player target) => Projectile.alpha == 80;
public override void OnHitPlayer(Player target, int damage, bool crit)
{
if (damage <= 0)
return;
if (Projectile.alpha == 80)
target.AddBuff(BuffID.Darkness, 300, true);
}
}
}