Files
CalamityModPublic/Projectiles/Boss/ProfanedSpear.cs
T

100 lines
3.6 KiB
C#

using CalamityMod.Buffs.DamageOverTime;
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 ProfanedSpear : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Profaned Spear");
ProjectileID.Sets.TrailCacheLength[projectile.type] = 4;
ProjectileID.Sets.TrailingMode[projectile.type] = 0;
}
public override void SetDefaults()
{
projectile.width = 38;
projectile.height = 38;
projectile.hostile = true;
projectile.tileCollide = false;
projectile.penetrate = -1;
projectile.alpha = 255;
projectile.timeLeft = 300;
cooldownSlot = 1;
}
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.timeLeft < 210)
projectile.tileCollide = true;
projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 0.785f;
projectile.alpha -= 3;
projectile.ai[1] += 1f;
if (projectile.ai[1] <= 20f)
{
projectile.velocity.X *= 0.95f;
projectile.velocity.Y *= 0.95f;
}
else if (projectile.ai[1] > 20f && projectile.ai[1] <= 39f)
{
projectile.velocity.X *= 1.1f;
projectile.velocity.Y *= 1.1f;
}
else if (projectile.ai[1] == 40f)
{
projectile.ai[1] = 0f;
}
projectile.localAI[0] += 1f;
if (projectile.localAI[0] == 30f)
{
projectile.localAI[0] = 0f;
for (int l = 0; l < 12; l++)
{
Vector2 vector3 = Vector2.UnitX * (float)-(float)projectile.width / 2f;
vector3 += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default) * new Vector2(8f, 16f);
vector3 = vector3.RotatedBy((double)(projectile.rotation - 1.57079637f), default);
int num9 = Dust.NewDust(projectile.Center, 0, 0, 244, 0f, 0f, 160, default, 1f);
Main.dust[num9].scale = 1.1f;
Main.dust[num9].noGravity = true;
Main.dust[num9].position = projectile.Center + vector3;
Main.dust[num9].velocity = projectile.velocity * 0.1f;
Main.dust[num9].velocity = Vector2.Normalize(projectile.Center - projectile.velocity * 3f - Main.dust[num9].position) * 1.25f;
}
}
}
public override Color? GetAlpha(Color lightColor)
{
return new Color(250, 150, 0, projectile.alpha);
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1);
return false;
}
public override void OnHitPlayer(Player target, int damage, bool crit)
{
target.AddBuff(ModContent.BuffType<HolyFlames>(), 120);
}
}
}