Files
CalamityModPublic/Projectiles/Boss/FoveanatorLaser.cs
T
mountaindrew10 4f8ff657fa 1 - Many Foveanator changes.
2 - Many Slime God changes (can someone please fix the bestiary image, because I don't want to).
3 - Improved Profaned Guardian Commander and Defender charge a bit.
4 - Fixed Rev+ Destroyer not having a netMode check for the segment spawning.
5 - Fixed Retinazer projectile firing offsets and rotation rate.
2024-09-11 09:08:20 -05:00

101 lines
3.3 KiB
C#

using System;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.NPCs.TownNPCs;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Boss
{
public class FoveanatorLaser : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Boss";
private const int FadeOutTime = 30;
private const float Acceleration = 1.05f;
private const float MaxVelocity = 24f;
public override void SetStaticDefaults()
{
Main.projFrames[Projectile.type] = 4;
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 2;
ProjectileID.Sets.TrailingMode[Projectile.type] = 0;
}
public override void SetDefaults()
{
Projectile.width = 16;
Projectile.height = 16;
Projectile.hostile = true;
Projectile.ignoreWater = true;
Projectile.Opacity = 0f;
Projectile.penetrate = -1;
Projectile.timeLeft = 300;
}
public override void AI()
{
Projectile.frameCounter++;
if (Projectile.frameCounter > 4)
{
Projectile.frame++;
Projectile.frameCounter = 0;
}
if (Projectile.frame > 3)
Projectile.frame = 0;
if (Projectile.velocity.Length() < MaxVelocity)
{
Projectile.velocity *= Acceleration;
if (Projectile.velocity.Length() > MaxVelocity)
{
Projectile.velocity.Normalize();
Projectile.velocity *= MaxVelocity;
}
}
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2;
Lighting.AddLight(Projectile.Center, 0.4f * Projectile.Opacity, 0.1f * Projectile.Opacity, (Main.DiscoB / 255f) * 0.5f * Projectile.Opacity);
if (Projectile.timeLeft < FadeOutTime)
{
Projectile.Opacity -= 1f / FadeOutTime;
}
else if (Projectile.Opacity < 1f)
{
Projectile.Opacity += 0.25f;
if (Projectile.Opacity > 1f)
Projectile.Opacity = 1f;
}
}
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.timeLeft >= FadeOutTime;
public override void OnHitPlayer(Player target, Player.HurtInfo info)
{
if (Projectile.timeLeft >= FadeOutTime)
target.AddBuff(BuffID.Frostburn, 90);
}
public override bool OnTileCollide(Vector2 oldVelocity)
{
Collision.HitTiles(Projectile.Center, Projectile.velocity, Projectile.width, Projectile.height);
SoundEngine.PlaySound(SoundID.Item10, Projectile.position);
return true;
}
}
}