Files
CalamityModPublic/Projectiles/Enemy/SulphuricAcidMist.cs
T

100 lines
3.1 KiB
C#

using CalamityMod.Buffs.StatDebuffs;
using Microsoft.Xna.Framework;
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.Audio;
namespace CalamityMod.Projectiles.Enemy
{
public class SulphuricAcidMist : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Enemy";
public override void SetStaticDefaults()
{
Main.projFrames[Projectile.type] = 10;
}
public override void SetDefaults()
{
Projectile.width = 20;
Projectile.height = 20;
Projectile.hostile = true;
Projectile.ignoreWater = true;
Projectile.penetrate = 1;
Projectile.timeLeft = 600;
Projectile.Opacity = 0f;
}
public override void AI()
{
Projectile.frameCounter++;
if (Projectile.frameCounter > 4)
{
Projectile.frame++;
Projectile.frameCounter = 0;
}
if (Projectile.frame > 9)
Projectile.frame = 0;
if (Projectile.ai[1] == 0f)
{
Projectile.ai[1] = 1f;
SoundEngine.PlaySound(SoundID.Item111, Projectile.position);
}
if (Projectile.velocity.X < 0f)
{
Projectile.spriteDirection = -1;
Projectile.rotation = (float)Math.Atan2((double)-(double)Projectile.velocity.Y, (double)-(double)Projectile.velocity.X);
}
else
{
Projectile.spriteDirection = 1;
Projectile.rotation = (float)Math.Atan2((double)Projectile.velocity.Y, (double)Projectile.velocity.X);
}
Projectile.ai[0] += 1f;
if (Projectile.ai[0] >= 480f)
{
if (Projectile.Opacity > 0f)
{
Projectile.Opacity -= 0.02f;
if (Projectile.Opacity <= 0f)
{
Projectile.Opacity = 0f;
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, 1);
return false;
}
public override bool CanHitPlayer(Player target) => Projectile.Opacity >= 0.9f;
public override void OnHitPlayer(Player target, Player.HurtInfo info)
{
if (info.Damage <= 0)
return;
if (Projectile.Opacity >= 0.9f)
target.AddBuff(ModContent.BuffType<Irradiated>(), 120);
}
}
}