107 lines
3.9 KiB
C#
107 lines
3.9 KiB
C#
using Microsoft.Xna.Framework;
|
|
using System;
|
|
using Terraria; using CalamityMod.Projectiles; using Terraria.ModLoader; using CalamityMod.Dusts;
|
|
using Terraria.ModLoader; using CalamityMod.Dusts; using CalamityMod.Buffs; using CalamityMod.Items; using CalamityMod.NPCs; using CalamityMod.Projectiles; using CalamityMod.Tiles; using CalamityMod.Walls;
|
|
|
|
namespace CalamityMod.Projectiles
|
|
{
|
|
public class SHPExplosion : ModProjectile
|
|
{
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Explosion");
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
projectile.width = 500;
|
|
projectile.height = 500;
|
|
projectile.friendly = true;
|
|
projectile.ignoreWater = true;
|
|
projectile.tileCollide = false;
|
|
projectile.magic = true;
|
|
projectile.penetrate = -1;
|
|
projectile.timeLeft = 60;
|
|
projectile.usesLocalNPCImmunity = true;
|
|
projectile.localNPCHitCooldown = 10;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
float num = (float)Main.rand.Next(90, 111) * 0.01f;
|
|
num *= Main.essScale;
|
|
Lighting.AddLight(projectile.Center, 5f * num, 1f * num, 4f * num);
|
|
bool flag15 = false;
|
|
bool flag16 = false;
|
|
if (projectile.velocity.X < 0f && projectile.position.X < projectile.ai[0])
|
|
{
|
|
flag15 = true;
|
|
}
|
|
if (projectile.velocity.X > 0f && projectile.position.X > projectile.ai[0])
|
|
{
|
|
flag15 = true;
|
|
}
|
|
if (projectile.velocity.Y < 0f && projectile.position.Y < projectile.ai[1])
|
|
{
|
|
flag16 = true;
|
|
}
|
|
if (projectile.velocity.Y > 0f && projectile.position.Y > projectile.ai[1])
|
|
{
|
|
flag16 = true;
|
|
}
|
|
if (flag15 && flag16)
|
|
{
|
|
projectile.Kill();
|
|
}
|
|
float num461 = 25f;
|
|
if (projectile.ai[0] > 180f)
|
|
{
|
|
num461 -= (projectile.ai[0] - 180f) / 2f;
|
|
}
|
|
if (num461 <= 0f)
|
|
{
|
|
num461 = 0f;
|
|
projectile.Kill();
|
|
}
|
|
num461 *= 0.7f;
|
|
projectile.ai[0] += 4f;
|
|
int num462 = 0;
|
|
while ((float)num462 < num461)
|
|
{
|
|
float num463 = (float)Main.rand.Next(-40, 41);
|
|
float num464 = (float)Main.rand.Next(-40, 41);
|
|
float num465 = (float)Main.rand.Next(12, 36);
|
|
float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464));
|
|
num466 = num465 / num466;
|
|
num463 *= num466;
|
|
num464 *= num466;
|
|
int randomDust = Main.rand.Next(3);
|
|
if (randomDust == 0)
|
|
{
|
|
randomDust = 246;
|
|
}
|
|
else if (randomDust == 1)
|
|
{
|
|
randomDust = 73;
|
|
}
|
|
else
|
|
{
|
|
randomDust = 187;
|
|
}
|
|
int num467 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDust, 0f, 0f, 100, default, 2f);
|
|
Main.dust[num467].noGravity = true;
|
|
Main.dust[num467].position.X = projectile.Center.X;
|
|
Main.dust[num467].position.Y = projectile.Center.Y;
|
|
Dust expr_149DF_cp_0 = Main.dust[num467];
|
|
expr_149DF_cp_0.position.X += (float)Main.rand.Next(-10, 11);
|
|
Dust expr_14A09_cp_0 = Main.dust[num467];
|
|
expr_14A09_cp_0.position.Y += (float)Main.rand.Next(-10, 11);
|
|
Main.dust[num467].velocity.X = num463;
|
|
Main.dust[num467].velocity.Y = num464;
|
|
num462++;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
}
|