Files
CalamityModPublic/Projectiles/Boss/WaterSpear.cs
T
Andrew Marheine 6636deaeff 1 - Ares and Thanos hopefully update their HP values every frame to match the part with the lowest HP.
2 - Animated Thanos and Ares lasers.
3 - Post-DoG moon/eclipse event enemies no longer use a different i-frame slot.
4 - Various other small fixes.
2021-08-07 10:44:51 -05:00

93 lines
3.1 KiB
C#

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.IO;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Boss
{
public class WaterSpear : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Water Spear");
ProjectileID.Sets.TrailCacheLength[projectile.type] = 4;
ProjectileID.Sets.TrailingMode[projectile.type] = 0;
}
public override void SetDefaults()
{
projectile.width = 14;
projectile.height = 14;
projectile.hostile = true;
projectile.ignoreWater = true;
projectile.tileCollide = false;
projectile.penetrate = -1;
projectile.timeLeft = 300;
projectile.Opacity = 0f;
projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true;
}
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()
{
if (projectile.velocity.Length() < 10f)
projectile.velocity *= 1.01f;
if (projectile.ai[1] == 0f)
{
for (int num621 = 0; num621 < 10; num621++)
{
int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 33, 0f, 0f, 100, default, 2f);
Main.dust[num622].velocity *= 3f;
if (Main.rand.NextBool(2))
{
Main.dust[num622].scale = 0.5f;
Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f;
}
}
projectile.ai[1] = 1f;
}
if (projectile.timeLeft < 30)
projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / 30f, 0f, 1f);
else
projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - 270) / 30f), 0f, 1f);
projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2;
Lighting.AddLight(projectile.Center, 0f, 0f, 0.5f * projectile.Opacity);
}
public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f;
public override bool PreDraw(SpriteBatch spriteBatch, 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 void Kill(int timeLeft)
{
for (int k = 0; k < 5; k++)
{
Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 33, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f);
}
}
}
}