Files
CalamityModPublic/Projectiles/Enemy/InkPoisonCloud.cs
T
mountaindrew10 6493453fd7 1 - Colossal Squid ink projectiles and Toxic Minnow poison clouds are easier to see.
2 - Juvenile Eidolon Wyrms no longer summon cultist projectiles and no longer use telekinesis.
2023-01-09 15:44:10 -06:00

86 lines
2.8 KiB
C#

using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Enemy
{
public class InkPoisonCloud : 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.Opacity = 0f;
Projectile.penetrate = -1;
Projectile.tileCollide = false;
Projectile.ignoreWater = true;
Projectile.timeLeft = 3600;
}
public override void AI()
{
Lighting.AddLight(Projectile.Center, 0.5f * Projectile.Opacity, 0.5f * Projectile.Opacity, 0.5f * Projectile.Opacity);
Projectile.frameCounter++;
if (Projectile.frameCounter > 9)
{
Projectile.frame++;
Projectile.frameCounter = 0;
}
if (Projectile.frame > 3)
Projectile.frame = 0;
Projectile.velocity *= 0.97f;
Projectile.ai[0] += 1f;
if (Projectile.ai[0] >= 120f)
{
if (Projectile.Opacity > 0f)
{
Projectile.Opacity -= 0.02f;
if (Projectile.Opacity < 0f)
Projectile.Opacity = 0f;
}
else if (Projectile.owner == Main.myPlayer)
Projectile.Kill();
}
else if (Projectile.Opacity < 0.9f)
{
Projectile.Opacity += 0.12f;
if (Projectile.Opacity > 0.9f)
Projectile.Opacity = 0.9f;
}
}
public override bool PreDraw(ref Color lightColor)
{
lightColor.R = (byte)(255 * Projectile.Opacity);
lightColor.G = (byte)(255 * Projectile.Opacity);
lightColor.B = (byte)(255 * Projectile.Opacity);
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor);
return false;
}
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 20f, targetHitbox);
public override bool CanHitPlayer(Player target) => Projectile.Opacity >= 0.9f;
public override void OnHitPlayer(Player target, int damage, bool crit)
{
if (damage <= 0)
return;
if (Projectile.Opacity >= 0.9f)
target.AddBuff(BuffID.Darkness, 300, true);
}
}
}