Files
CalamityModPublic/Projectiles/Rogue/ProfanedPartisanSpear.cs
T
Ozzatron d4b5160f98 1 - Fully replaced Momentum Capacitor. It is now a channeled Burden Breaker.
2 - Stealth no longer gives movement speed.
3 - Moved a bunch of CalamityGlobalProjectile utilities to CalamityUtils where they belong.
4 - Renamed several things in CalamityGlobalProjectile
2022-07-02 19:42:56 -04:00

101 lines
3.2 KiB
C#

using Terraria;
using Terraria.ModLoader;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using CalamityMod.Buffs.DamageOverTime;
namespace CalamityMod.Projectiles.Rogue
{
public class ProfanedPartisanSpear : ModProjectile
{
public int timer = 0;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Profaned Spear");
}
public override void SetDefaults()
{
Projectile.width = 10;
Projectile.height = 10;
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.DamageType = RogueDamageClass.Instance;
Projectile.penetrate = -1;
Projectile.extraUpdates = 3;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 10;
Projectile.timeLeft = 600;
}
public override bool OnTileCollide(Vector2 oldVelocity)
{
if (Projectile.ai[1] != 1f)
{
if (Projectile.velocity.X != oldVelocity.X)
{
Projectile.velocity.X = -oldVelocity.X;
}
if (Projectile.velocity.Y != oldVelocity.Y)
{
Projectile.velocity.Y = -oldVelocity.Y;
}
Projectile.ai[1] = 1f;
Projectile.ai[0] = 1f;
Projectile.extraUpdates = 2;
if (Projectile.timeLeft > 280)
Projectile.timeLeft = 280;
}
return false;
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
target.AddBuff(ModContent.BuffType<HolyFlames>(), 180);
OnHitEffects();
}
public override void OnHitPvp(Player target, int damage, bool crit)
{
target.AddBuff(ModContent.BuffType<HolyFlames>(), 180);
OnHitEffects();
}
private void OnHitEffects()
{
if (Projectile.ai[1] != 1f)
{
Projectile.velocity.X *= -1f;
Projectile.velocity.Y *= -1f;
Projectile.ai[1] = 1f;
Projectile.ai[0] = 1f;
Projectile.extraUpdates = 2;
if (Projectile.timeLeft > 280)
Projectile.timeLeft = 280;
}
}
public override void AI()
{
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2;
if (Projectile.ai[0] == 1f)
timer++;
if (timer >= 5)
Projectile.penetrate = 1;
if (timer >= 10)
{
CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 300f, 7f, 20f);
}
}
public override bool PreDraw(ref Color lightColor)
{
Texture2D tex = ModContent.Request<Texture2D>(Texture).Value;
Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, tex.Size() / 2f, Projectile.scale, SpriteEffects.None, 0);
return false;
}
}
}