98 lines
3.5 KiB
C#
98 lines
3.5 KiB
C#
using CalamityMod.Buffs.DamageOverTime;
|
|
using Microsoft.Xna.Framework;
|
|
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.Calamity().DealsDefenseDamage = true;
|
|
Projectile.width = 32;
|
|
Projectile.height = 32;
|
|
Projectile.hostile = true;
|
|
Projectile.tileCollide = false;
|
|
Projectile.penetrate = -1;
|
|
Projectile.alpha = 255;
|
|
Projectile.timeLeft = 300;
|
|
}
|
|
|
|
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) + MathHelper.PiOver4;
|
|
|
|
if (Projectile.alpha > 0)
|
|
Projectile.alpha -= 17;
|
|
|
|
Projectile.ai[1] += 1f;
|
|
if (Projectile.ai[1] <= 20f)
|
|
Projectile.velocity *= 0.95f;
|
|
else if (Projectile.ai[1] > 20f && Projectile.ai[1] <= 39f)
|
|
Projectile.velocity *= 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(ref Color lightColor)
|
|
{
|
|
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1);
|
|
return false;
|
|
}
|
|
|
|
public override void OnHitPlayer(Player target, int damage, bool crit)
|
|
{
|
|
if (damage <= 0)
|
|
return;
|
|
|
|
target.AddBuff(ModContent.BuffType<HolyFlames>(), 180);
|
|
}
|
|
}
|
|
}
|