Added Trident of the Sunken
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace ForgottenWawiTech.Content.Projectiles.TridentOfTheSunken
|
||||
{
|
||||
public class TridentOfTheSunkenShot : ModProjectile
|
||||
{
|
||||
private const float ExplosionRadiusBlocks = 20f;
|
||||
private const int ExplosionDamage = 5000;
|
||||
private const int DrownDuration = 600; // 10 seconds
|
||||
|
||||
private bool HasDetonated
|
||||
{
|
||||
get => Projectile.localAI[1] == 1f;
|
||||
set => Projectile.localAI[1] = value ? 1f : 0f;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 256;
|
||||
Projectile.height = 30;
|
||||
Projectile.friendly = true;
|
||||
Projectile.hostile = false;
|
||||
Projectile.DamageType = DamageClass.Magic;
|
||||
Projectile.penetrate = 1;
|
||||
Projectile.aiStyle = 0;
|
||||
Projectile.tileCollide = true;
|
||||
Projectile.ignoreWater = false;
|
||||
Projectile.extraUpdates = 1;
|
||||
Projectile.timeLeft = 180;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
if (Projectile.velocity.LengthSquared() > 0.0001f)
|
||||
{
|
||||
Projectile.direction = Projectile.spriteDirection = Projectile.velocity.X >= 0f ? 1 : -1;
|
||||
Projectile.rotation = Projectile.velocity.ToRotation();
|
||||
if (Projectile.spriteDirection == -1)
|
||||
{
|
||||
Projectile.rotation += MathHelper.Pi;
|
||||
}
|
||||
}
|
||||
Lighting.AddLight(Projectile.Center, 0.1f, 0.2f, 0.6f);
|
||||
|
||||
if (Main.rand.NextBool(3))
|
||||
{
|
||||
Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.WaterCandle, 0f, 0f, 150, default, 1.1f);
|
||||
dust.velocity *= 0.3f;
|
||||
dust.noGravity = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool OnTileCollide(Vector2 oldVelocity)
|
||||
{
|
||||
Detonate();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
||||
{
|
||||
target.AddBuff(BuffID.Suffocation, DrownDuration);
|
||||
Detonate();
|
||||
Projectile.Kill();
|
||||
}
|
||||
|
||||
public override void Kill(int timeLeft)
|
||||
{
|
||||
Detonate();
|
||||
}
|
||||
|
||||
private void Detonate()
|
||||
{
|
||||
if (HasDetonated)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
HasDetonated = true;
|
||||
|
||||
if (Projectile.owner == Main.myPlayer)
|
||||
{
|
||||
float radiusPixels = ExplosionRadiusBlocks * 16f;
|
||||
int explosion = Projectile.NewProjectile(Projectile.GetSource_Death(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType<TridentOfTheSunkenBlast>(), ExplosionDamage, 8f, Projectile.owner, radiusPixels);
|
||||
if (Main.projectile.IndexInRange(explosion))
|
||||
{
|
||||
Main.projectile[explosion].localAI[0] = radiusPixels;
|
||||
}
|
||||
}
|
||||
|
||||
SoundEngine.PlaySound(SoundID.Item14 with { Volume = 1f, Pitch = -0.2f }, Projectile.Center);
|
||||
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
Vector2 velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(2f, 6f);
|
||||
Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.BlueCrystalShard, velocity.X, velocity.Y, 150, default, 1.2f);
|
||||
dust.noGravity = true;
|
||||
}
|
||||
Projectile.timeLeft = Math.Min(Projectile.timeLeft, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user