93 lines
3.5 KiB
C#
93 lines
3.5 KiB
C#
using CalamityMod.Buffs.DamageOverTime;
|
|
using CalamityMod.Buffs.StatDebuffs;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using System;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
namespace CalamityMod.Projectiles.Melee
|
|
{
|
|
public class SpatialSpear4 : ModProjectile
|
|
{
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Spear");
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
projectile.width = 10;
|
|
projectile.height = 10;
|
|
projectile.friendly = true;
|
|
projectile.melee = true;
|
|
projectile.tileCollide = false;
|
|
projectile.penetrate = 1;
|
|
projectile.timeLeft = 25;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
Lighting.AddLight(projectile.Center, 0.5f, 0.5f, 0.05f);
|
|
projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver4;
|
|
if (projectile.localAI[1] == 0f)
|
|
{
|
|
projectile.scale -= 0.01f;
|
|
projectile.alpha += 15;
|
|
if (projectile.alpha >= 125)
|
|
{
|
|
projectile.alpha = 130;
|
|
projectile.localAI[1] = 1f;
|
|
}
|
|
}
|
|
else if (projectile.localAI[1] == 1f)
|
|
{
|
|
projectile.scale += 0.01f;
|
|
projectile.alpha -= 15;
|
|
if (projectile.alpha <= 0)
|
|
{
|
|
projectile.alpha = 0;
|
|
projectile.localAI[1] = 0f;
|
|
}
|
|
}
|
|
if (Main.rand.NextBool(8))
|
|
{
|
|
Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 244, projectile.velocity.X * 0.1f, projectile.velocity.Y * 0.1f);
|
|
}
|
|
}
|
|
|
|
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
|
{
|
|
if (projectile.timeLeft > 20)
|
|
return false;
|
|
|
|
Texture2D tex = Main.projectileTexture[projectile.type];
|
|
spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, projectile.GetAlpha(lightColor), projectile.rotation, tex.Size() / 2f, projectile.scale, SpriteEffects.None, 0f);
|
|
return false;
|
|
}
|
|
|
|
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
|
|
{
|
|
target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 90);
|
|
target.AddBuff(BuffID.Frostburn, 90);
|
|
target.AddBuff(ModContent.BuffType<HolyFlames>(), 90);
|
|
}
|
|
|
|
public override void Kill(int timeLeft)
|
|
{
|
|
for (int num795 = 4; num795 < 12; num795++)
|
|
{
|
|
float num796 = projectile.oldVelocity.X * (30f / num795);
|
|
float num797 = projectile.oldVelocity.Y * (30f / num795);
|
|
int num798 = Dust.NewDust(new Vector2(projectile.oldPosition.X - num796, projectile.oldPosition.Y - num797), 8, 8, 244, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, default, 1.8f);
|
|
Main.dust[num798].noGravity = true;
|
|
Dust dust = Main.dust[num798];
|
|
dust.velocity *= 0.5f;
|
|
num798 = Dust.NewDust(new Vector2(projectile.oldPosition.X - num796, projectile.oldPosition.Y - num797), 8, 8, 244, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, default, 1.4f);
|
|
dust = Main.dust[num798];
|
|
dust.velocity *= 0.05f;
|
|
}
|
|
}
|
|
}
|
|
}
|