Note: Does not include item rarities, and appears to shown nonexistant using directive movement in the commit. This does not really affect anything, however.
124 lines
4.9 KiB
C#
124 lines
4.9 KiB
C#
using CalamityMod.Buffs.DamageOverTime;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using System;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Projectiles.Magic
|
|
{
|
|
public class UndinesRetributionSpear : ModProjectile
|
|
{
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Undine's Retribution");
|
|
Main.projFrames[projectile.type] = 4;
|
|
ProjectileID.Sets.TrailCacheLength[projectile.type] = 4;
|
|
ProjectileID.Sets.TrailingMode[projectile.type] = 0;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
projectile.width = 20;
|
|
projectile.height = 20;
|
|
projectile.friendly = true;
|
|
projectile.ignoreWater = true;
|
|
projectile.tileCollide = false;
|
|
projectile.magic = true;
|
|
projectile.extraUpdates = 1;
|
|
projectile.penetrate = 1;
|
|
projectile.timeLeft = 420;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
projectile.frameCounter++;
|
|
if (projectile.frameCounter > 4)
|
|
{
|
|
projectile.frame++;
|
|
projectile.frameCounter = 0;
|
|
}
|
|
if (projectile.frame > 3)
|
|
{
|
|
projectile.frame = 0;
|
|
}
|
|
float num953 = 25f * projectile.ai[1]; //100
|
|
float scaleFactor12 = 5f * projectile.ai[1]; //5
|
|
float num954 = 500f;
|
|
if (projectile.velocity.X < 0f)
|
|
{
|
|
projectile.spriteDirection = -1;
|
|
projectile.rotation = (float)Math.Atan2((double)-(double)projectile.velocity.Y, (double)-(double)projectile.velocity.X);
|
|
}
|
|
else
|
|
{
|
|
projectile.spriteDirection = 1;
|
|
projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X);
|
|
}
|
|
Lighting.AddLight(projectile.Center, 0f, 0.1f, 0.7f);
|
|
if (Main.player[projectile.owner].active && !Main.player[projectile.owner].dead)
|
|
{
|
|
if (projectile.Distance(Main.player[projectile.owner].Center) > num954)
|
|
{
|
|
Vector2 vector102 = projectile.DirectionTo(Main.player[projectile.owner].Center);
|
|
if (vector102.HasNaNs())
|
|
{
|
|
vector102 = Vector2.UnitY;
|
|
}
|
|
projectile.velocity = (projectile.velocity * (num953 - 1f) + vector102 * scaleFactor12) / num953;
|
|
return;
|
|
}
|
|
|
|
CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 600f, 9f, 20f);
|
|
}
|
|
else
|
|
{
|
|
if (projectile.timeLeft > 30)
|
|
{
|
|
projectile.timeLeft = 30;
|
|
}
|
|
}
|
|
}
|
|
|
|
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
|
{
|
|
CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1);
|
|
return false;
|
|
}
|
|
|
|
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
|
|
{
|
|
target.AddBuff(ModContent.BuffType<CrushDepth>(), 180);
|
|
}
|
|
|
|
public override void Kill(int timeLeft)
|
|
{
|
|
projectile.position = projectile.Center;
|
|
projectile.width = projectile.height = 64;
|
|
projectile.position.X = projectile.position.X - (float)(projectile.width / 2);
|
|
projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2);
|
|
projectile.maxPenetrate = -1;
|
|
projectile.penetrate = -1;
|
|
projectile.usesLocalNPCImmunity = true;
|
|
projectile.localNPCHitCooldown = 10;
|
|
projectile.damage /= 2;
|
|
projectile.Damage();
|
|
Main.PlaySound(SoundID.Item21, projectile.position);
|
|
for (int num193 = 0; num193 < 4; num193++)
|
|
{
|
|
Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 33, 0f, 0f, 100, new Color(0, 255, 255), 1.5f);
|
|
}
|
|
for (int num194 = 0; num194 < 6; num194++)
|
|
{
|
|
int num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 186, 0f, 0f, 0, new Color(0, 255, 255), 2.5f);
|
|
Main.dust[num195].noGravity = true;
|
|
Main.dust[num195].velocity *= 3f;
|
|
num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 186, 0f, 0f, 100, new Color(0, 255, 255), 1.5f);
|
|
Main.dust[num195].velocity *= 2f;
|
|
Main.dust[num195].noGravity = true;
|
|
}
|
|
}
|
|
}
|
|
}
|