Files
CalamityModPublic/Projectiles/Boss/AstralLaser.cs
T
Andrew Marheine 905893790d 1 - Thanos, I want to die.
2 - Adjusted Wyrm HP and lightning velocity.
2021-06-16 12:41:41 -05:00

91 lines
2.9 KiB
C#

using CalamityMod.Buffs.DamageOverTime;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
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 = 240;
projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true;
}
public override void AI()
{
projectile.frameCounter++;
if (projectile.frameCounter > 4)
{
projectile.frame++;
projectile.frameCounter = 0;
}
if (projectile.frame > 2)
projectile.frame = 0;
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] > 9f)
{
if (projectile.alpha > 0)
projectile.alpha -= 5;
}
}
public override bool PreDraw(SpriteBatch spriteBatch, 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 (projectile.timeLeft >= 85)
target.AddBuff(ModContent.BuffType<AstralInfectionDebuff>(), 120);
}
}
}