83 lines
3.1 KiB
C#
83 lines
3.1 KiB
C#
using Microsoft.Xna.Framework;
|
|
using System;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
using Terraria.Audio;
|
|
|
|
namespace CalamityMod.Projectiles.Magic
|
|
{
|
|
public class ForbiddenSunburst : ModProjectile, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Projectiles.Magic";
|
|
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
|
|
|
private static float ExplosionRadius = 190.0f;
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 220;
|
|
Projectile.height = 220;
|
|
Projectile.friendly = true;
|
|
Projectile.ignoreWater = false;
|
|
Projectile.tileCollide = false;
|
|
Projectile.penetrate = -1;
|
|
Projectile.timeLeft = 150;
|
|
Projectile.DamageType = DamageClass.Magic;
|
|
Projectile.usesIDStaticNPCImmunity = true;
|
|
Projectile.idStaticNPCHitCooldown = 8;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
Lighting.AddLight(Projectile.Center, 0.75f, 0.5f, 0f);
|
|
if (Projectile.wet && !Projectile.lavaWet)
|
|
{
|
|
Projectile.Kill();
|
|
}
|
|
if (Projectile.localAI[0] == 0f)
|
|
{
|
|
SoundEngine.PlaySound(SoundID.Item20, Projectile.position);
|
|
Projectile.localAI[0] += 1f;
|
|
}
|
|
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 rando1 = (float)Main.rand.Next(-25, 26);
|
|
float rando2 = (float)Main.rand.Next(-25, 26);
|
|
float rando3 = (float)Main.rand.Next(9, 24);
|
|
float randoAdjuster = (float)Math.Sqrt((double)(rando1 * rando1 + rando2 * rando2));
|
|
randoAdjuster = rando3 / randoAdjuster;
|
|
rando1 *= randoAdjuster;
|
|
rando2 *= randoAdjuster;
|
|
int orngDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 55, 0f, 0f, 100, default, 2.5f);
|
|
Dust dust = Main.dust[orngDust];
|
|
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 = rando1;
|
|
dust.velocity.Y = rando2;
|
|
timerCounter++;
|
|
}
|
|
}
|
|
|
|
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.OnFire3, 300);
|
|
|
|
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, ExplosionRadius, targetHitbox);
|
|
}
|
|
}
|