Files
CalamityModPublic/Projectiles/Boss/AstralLaser.cs
T
mountaindrew10 4534407745 1 - Astrum Deus no longer spams god ray laser projectiles in phase 2.
2 - Astrum Aureus laser projectiles accelerate after moving at regular velocity for some time in Expert+, this is to make them dangerous if the player just tries to run away.
3 - Astrum Aureus homing flames have a higher top velocity in Death Mode.
2023-02-24 06:50:57 -06:00

108 lines
3.5 KiB
C#

using CalamityMod.Buffs.DamageOverTime;
using Microsoft.Xna.Framework;
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Boss
{
public class AstralLaser : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Astral Laser Volley");
Main.projFrames[Projectile.type] = 3;
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 4;
ProjectileID.Sets.TrailingMode[Projectile.type] = 0;
}
public override void SetDefaults()
{
Projectile.width = 20;
Projectile.height = 20;
Projectile.hostile = true;
Projectile.ignoreWater = true;
Projectile.tileCollide = false;
Projectile.alpha = 255;
Projectile.penetrate = -1;
Projectile.timeLeft = 1200;
Projectile.extraUpdates = 1;
}
public override void AI()
{
Projectile.frameCounter++;
if (Projectile.frameCounter > 8)
{
Projectile.frame++;
Projectile.frameCounter = 0;
}
if (Projectile.frame > 2)
Projectile.frame = 0;
// Speed up after some time
if (Projectile.timeLeft < 600 && Main.expertMode)
{
if (Projectile.velocity.Length() < Projectile.ai[1])
{
Projectile.velocity *= 1.005f;
if (Projectile.velocity.Length() > Projectile.ai[1])
{
Projectile.velocity.Normalize();
Projectile.velocity *= Projectile.ai[1];
}
}
}
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);
}
Lighting.AddLight(Projectile.Center, 0.3f, 0.3f, 0f);
Projectile.ai[0] += 1f;
if (Projectile.ai[0] > 18f)
{
if (Projectile.alpha > 0)
Projectile.alpha -= 3;
}
}
public override bool PreDraw(ref Color lightColor)
{
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1);
return false;
}
public override bool CanHitPlayer(Player target) => Projectile.timeLeft >= 85;
public override Color? GetAlpha(Color lightColor)
{
if (Projectile.timeLeft < 85)
{
byte b2 = (byte)(Projectile.timeLeft * 3);
byte a2 = (byte)(Projectile.alpha * (b2 / 255f));
return new Color(b2, b2, b2, a2);
}
return new Color(255, 255, 255, Projectile.alpha);
}
public override void OnHitPlayer(Player target, int damage, bool crit)
{
if (damage <= 0)
return;
if (Projectile.timeLeft >= 85)
target.AddBuff(ModContent.BuffType<AstralInfectionDebuff>(), 120);
}
}
}