Files
CalamityModPublic/Projectiles/Boss/GreatSandBlast.cs
T
mountaindrew10 c1620d1711 1 - King Slime jewel telegraph works now.
2 - Made GSS sand projectiles full bright for a better fight experience.
2023-07-20 00:52:51 -05:00

102 lines
4.0 KiB
C#

using Microsoft.Xna.Framework;
using System;
using System.IO;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.Audio;
using CalamityMod.World;
namespace CalamityMod.Projectiles.Boss
{
public class GreatSandBlast : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Boss";
public override void SetStaticDefaults()
{
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 4;
ProjectileID.Sets.TrailingMode[Projectile.type] = 0;
}
public override void SetDefaults()
{
Projectile.width = 10;
Projectile.height = 10;
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
Projectile.scale = 2f;
Projectile.hostile = true;
Projectile.tileCollide = false;
Projectile.penetrate = 1;
Projectile.timeLeft = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 900 : 600;
Projectile.aiStyle = ProjAIStyleID.Arrow;
Projectile.alpha = 255;
}
public override void SendExtraAI(BinaryWriter writer)
{
writer.Write(Projectile.localAI[0]);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
Projectile.localAI[0] = reader.ReadSingle();
}
public override void AI()
{
Projectile.tileCollide = Projectile.timeLeft < 540;
Projectile.rotation = (float)Math.Atan2((double)Projectile.velocity.Y, (double)Projectile.velocity.X) + 1.57f;
Projectile.localAI[0] += 1f;
if (Projectile.localAI[0] > 4f)
{
Projectile.alpha -= 50;
if (Projectile.alpha < 0)
{
Projectile.alpha = 0;
}
int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 85, 0f, 0f, 100, default, 1f);
Main.dust[num469].noGravity = true;
Main.dust[num469].velocity *= 0f;
}
}
public override void Kill(int timeLeft)
{
SoundEngine.PlaySound(SoundID.Item14, Projectile.Center);
Projectile.position = Projectile.Center;
Projectile.width = Projectile.height = (int)(32 * Projectile.scale);
Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2);
Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2);
int num226 = 36;
for (int num227 = 0; num227 < num226; num227++)
{
Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f;
vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center;
Vector2 vector7 = vector6 - Projectile.Center;
int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 85, vector7.X * 1.5f, vector7.Y * 1.5f, 100, default, 1.2f);
Main.dust[num228].noGravity = true;
Main.dust[num228].noLight = true;
Main.dust[num228].velocity = vector7;
}
Projectile.Damage();
}
public override void OnHitPlayer(Player target, Player.HurtInfo info)
{
if (info.Damage <= 0)
return;
target.velocity *= 0.5f;
}
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;
}
}
}