99 lines
3.8 KiB
C#
99 lines
3.8 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;
|
|
using Terraria.Audio;
|
|
namespace CalamityMod.Projectiles.Melee
|
|
{
|
|
public class DepthOrb2 : ModProjectile
|
|
{
|
|
public override string Texture => "CalamityMod/Projectiles/Melee/DepthOrb";
|
|
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Beam");
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 20;
|
|
Projectile.height = 20;
|
|
Projectile.aiStyle = ProjAIStyleID.Beam;
|
|
Projectile.friendly = true;
|
|
Projectile.DamageType = DamageClass.Melee;
|
|
Projectile.penetrate = 1;
|
|
Projectile.timeLeft = 120;
|
|
Projectile.ignoreWater = true;
|
|
Projectile.extraUpdates = 1;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
Lighting.AddLight(Projectile.Center, 0f, 0f, 0.5f);
|
|
|
|
int num458 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 0.4f);
|
|
Main.dust[num458].noGravity = true;
|
|
Main.dust[num458].velocity *= 0.5f;
|
|
Main.dust[num458].velocity += Projectile.velocity * 0.1f;
|
|
|
|
CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 200f, 12f, 20f);
|
|
}
|
|
|
|
public override bool PreDraw(ref Color lightColor)
|
|
{
|
|
if (Projectile.timeLeft > 115)
|
|
return false;
|
|
|
|
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;
|
|
}
|
|
|
|
public override Color? GetAlpha(Color lightColor)
|
|
{
|
|
return new Color(50, 50, 255, Projectile.alpha);
|
|
}
|
|
|
|
public override void Kill(int timeLeft)
|
|
{
|
|
SoundEngine.PlaySound(SoundID.Item10, Projectile.position);
|
|
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);
|
|
for (int dustIndex = 0; dustIndex <= 30; dustIndex++)
|
|
{
|
|
float num463 = (float)Main.rand.Next(-10, 11);
|
|
float num464 = (float)Main.rand.Next(-10, 11);
|
|
float num465 = (float)Main.rand.Next(3, 9);
|
|
float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464));
|
|
num466 = num465 / num466;
|
|
num463 *= num466;
|
|
num464 *= num466;
|
|
int num467 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 1.2f);
|
|
Dust dust = Main.dust[num467];
|
|
dust.noGravity = true;
|
|
dust.position.X = Projectile.Center.X;
|
|
dust.position.Y = Projectile.Center.Y;
|
|
dust.position.X += (float)Main.rand.Next(-10, 11);
|
|
dust.position.Y += (float)Main.rand.Next(-10, 11);
|
|
dust.velocity.X = num463;
|
|
dust.velocity.Y = num464;
|
|
}
|
|
Projectile.maxPenetrate = -1;
|
|
Projectile.penetrate = -1;
|
|
Projectile.usesLocalNPCImmunity = true;
|
|
Projectile.localNPCHitCooldown = 10;
|
|
Projectile.Damage();
|
|
}
|
|
|
|
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
|
|
{
|
|
target.AddBuff(ModContent.BuffType<CrushDepth>(), 180);
|
|
}
|
|
}
|
|
}
|