76 lines
2.9 KiB
C#
76 lines
2.9 KiB
C#
using System;
|
|
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
namespace CalamityMod.Projectiles.Ranged
|
|
{
|
|
public class PlanarRipperExplosion : ModProjectile, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Projectiles.Ranged";
|
|
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 50;
|
|
Projectile.height = 50;
|
|
Projectile.friendly = true;
|
|
Projectile.ignoreWater = true;
|
|
Projectile.tileCollide = false;
|
|
Projectile.DamageType = DamageClass.Ranged;
|
|
Projectile.penetrate = -1;
|
|
Projectile.timeLeft = 30;
|
|
Projectile.usesLocalNPCImmunity = true;
|
|
Projectile.localNPCHitCooldown = -1;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.01f / 255f, (255 - Projectile.alpha) * 0.05f / 255f, (255 - Projectile.alpha) * 0.15f / 255f);
|
|
float projTimer = 25f;
|
|
if (Projectile.ai[0] > 180f)
|
|
{
|
|
projTimer -= (Projectile.ai[0] - 180f) / 2f;
|
|
}
|
|
if (projTimer <= 0f)
|
|
{
|
|
projTimer = 0f;
|
|
Projectile.Kill();
|
|
}
|
|
projTimer *= 0.7f;
|
|
Projectile.ai[0] += 4f;
|
|
int timerCounter = 0;
|
|
while ((float)timerCounter < projTimer)
|
|
{
|
|
float rand1 = (float)Main.rand.Next(-10, 11);
|
|
float rand2 = (float)Main.rand.Next(-10, 11);
|
|
float rand3 = (float)Main.rand.Next(3, 9);
|
|
float randAdjust = (float)Math.Sqrt((double)(rand1 * rand1 + rand2 * rand2));
|
|
randAdjust = rand3 / randAdjust;
|
|
rand1 *= randAdjust;
|
|
rand2 *= randAdjust;
|
|
int boomDustID = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Firework_Blue, 0f, 0f, 100, default, 0.5f);
|
|
Dust dust = Main.dust[boomDustID];
|
|
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 = rand1;
|
|
dust.velocity.Y = rand2;
|
|
timerCounter++;
|
|
}
|
|
}
|
|
|
|
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers)
|
|
{
|
|
Projectile.damage = (int)(Projectile.damage * 0.75);
|
|
}
|
|
|
|
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
|
{
|
|
target.AddBuff(BuffID.Electrified, 180);
|
|
}
|
|
}
|
|
}
|