Fixed custom swords having a wrong angle Fixed Skytide Dragoon having a long non-rotating melee hitbox and adjusted it's bolt visuals slightly Made it so Arc Flash Ring projectiles can only hit the target that created them, unless the target is invalid Added a "Hitbox viewer" to custom use style that can be turned on if you need to see the hitbox of custom weapons Updated how Azathoth attacks and gave it new visuals
127 lines
6.6 KiB
C#
127 lines
6.6 KiB
C#
using CalamityMod.Particles;
|
|
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.Audio;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Projectiles.Typeless
|
|
{
|
|
public class FlashBolt : ModProjectile, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Projectiles.Typeless";
|
|
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
|
public int time = 0;
|
|
public float colorValue = 0;
|
|
public float sizeMult = 1;
|
|
public bool invalidTarget => (Projectile.ai[0] < 0f || Projectile.ai[0] > 199f);
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 60;
|
|
Projectile.height = 60;
|
|
Projectile.friendly = true;
|
|
Projectile.tileCollide = false;
|
|
Projectile.ignoreWater = true;
|
|
Projectile.DamageType = AverageDamageClass.Instance;
|
|
Projectile.penetrate = 1; // Survives through its first hit by "cheating" and incrementing its own pierce counter
|
|
Projectile.extraUpdates = 75;
|
|
Projectile.timeLeft = 200;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
Player Owner = Main.player[Projectile.owner];
|
|
// Visibility/Sound toggle on acc visibility
|
|
bool visible = Owner.Calamity().arcFlashRingVisual;
|
|
colorValue = MathHelper.Lerp(colorValue, 50, 0.025f);
|
|
Color usedColor = Color.Lerp(Color.Cyan, Color.Orchid, Utils.GetLerpValue(0, 50, colorValue));
|
|
|
|
if (time == 0)
|
|
{
|
|
colorValue += Main.rand.Next(0, 20);
|
|
sizeMult = 1;
|
|
if (visible)
|
|
{
|
|
SoundStyle fire = new("CalamityMod/Sounds/Item/ArcFlash");
|
|
SoundEngine.PlaySound(fire with { Volume = 0.6f, Pitch = Main.rand.NextFloat(-0.1f, 0.1f) }, Owner.Center);
|
|
}
|
|
}
|
|
|
|
// If the target is dead, remove them as a target and hit anything
|
|
NPC target = (invalidTarget ? null : Main.npc[(int)Projectile.ai[0]]);
|
|
if (target == null || !target.active || target.life <= 0)
|
|
Projectile.ai[0] = -1;
|
|
|
|
float targetDist = Vector2.Distance(Owner.Center, Projectile.Center);
|
|
|
|
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2;
|
|
if (targetDist < 1400f)
|
|
{
|
|
Vector2 pos = Projectile.Center - Projectile.velocity * 15;
|
|
if (Projectile.timeLeft % 4 == 0)
|
|
{
|
|
Particle spark2 = new BoltParticle(pos, -Projectile.velocity * 0.05f, false, 30, 0.6f * sizeMult, usedColor * (visible ? 1 : 0.25f), new Vector2(1.8f, 0.8f), true, true, false, 0.3f);
|
|
GeneralParticleHandler.SpawnParticle(spark2);
|
|
}
|
|
if (Main.rand.NextBool(35))
|
|
{
|
|
Particle spark2 = new BoltParticle(pos, Projectile.velocity.RotatedByRandom(0.6f) * Main.rand.NextFloat(0.3f, 1.9f), false, 23, Main.rand.NextFloat(0.2f, 0.25f) * sizeMult, usedColor * (visible ? 1 : 0.3f), new Vector2(1.8f, 0.8f), true, true, false, 0.3f);
|
|
GeneralParticleHandler.SpawnParticle(spark2);
|
|
}
|
|
if (Main.rand.NextBool(10) && visible)
|
|
{
|
|
Particle spark2 = new CustomSpark(pos, Projectile.velocity * Main.rand.NextFloat(-0.4f, 0.4f), "CalamityMod/Particles/DrainLineBloom", false, 80, Main.rand.NextFloat(1.2f, 1.3f) * sizeMult, usedColor * (visible ? 1 : 0.3f), new Vector2(1, 4), true, true);
|
|
GeneralParticleHandler.SpawnParticle(spark2);
|
|
}
|
|
if (time % 5 == 0 && visible)
|
|
{
|
|
Dust dust = Dust.NewDustPerfect(pos, 278, new Vector2(5, 5).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1f), 0, default, Main.rand.NextFloat(0.45f, 0.6f));
|
|
dust.noGravity = true;
|
|
dust.color = usedColor;
|
|
}
|
|
}
|
|
if (Projectile.numHits > 0)
|
|
{
|
|
sizeMult *= 0.97f;
|
|
}
|
|
time++;
|
|
}
|
|
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
|
{
|
|
// Stops the projectile from deleting itself, while maintaining the masquerade
|
|
Projectile.penetrate++;
|
|
|
|
//colorValue = Main.rand.Next(0, 10);
|
|
target.AddBuff(BuffID.Electrified, 180);
|
|
Projectile.timeLeft = 25;
|
|
Player Owner = Main.player[Projectile.owner];
|
|
if (Owner.Calamity().arcFlashRingVisual && Projectile.numHits == 0)
|
|
{
|
|
Vector2 pos = target.Center;
|
|
for (int i = 0; i < 10; i++)
|
|
{
|
|
Particle spark2 = new BoltParticle(pos, new Vector2(8, 8).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1.9f), true, 13, Main.rand.NextFloat(0.2f, 0.3f) * sizeMult, Main.rand.NextBool(5) ? Color.Cyan : Color.Orchid, new Vector2(1.8f, 0.8f), true, true, false, 0.8f);
|
|
GeneralParticleHandler.SpawnParticle(spark2);
|
|
Dust dust = Dust.NewDustPerfect(pos, 278, new Vector2(14, 14).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1f), 0, default, Main.rand.NextFloat(0.8f, 0.9f));
|
|
dust.noGravity = false;
|
|
dust.color = Main.rand.NextBool(5) ? Color.Cyan : Color.Orchid;
|
|
}
|
|
Particle pulse2 = new CustomPulse(pos, Vector2.Zero, Color.Orchid, "CalamityMod/Particles/HighResFoggyCircleHardEdge", new Vector2(1, 1), 0, 0f, 0.0715f, 10);
|
|
GeneralParticleHandler.SpawnParticle(pulse2);
|
|
Particle orb = new CustomPulse(pos, Vector2.Zero, Color.Orchid, "CalamityMod/Particles/LargeBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0.78f, 0.5f, 14);
|
|
GeneralParticleHandler.SpawnParticle(orb);
|
|
Particle orb2 = new CustomPulse(pos, Vector2.Zero, Color.White, "CalamityMod/Particles/LargeBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0.325f, 0.2f, 14);
|
|
GeneralParticleHandler.SpawnParticle(orb2);
|
|
}
|
|
}
|
|
public override bool? CanHitNPC(NPC target)
|
|
{
|
|
if (invalidTarget || Projectile.ai[0] == target.whoAmI)
|
|
return null;
|
|
return false;
|
|
}
|
|
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => Projectile.numHits > 0 ? false : CalamityUtils.CircularHitboxCollision(Projectile.Center, 60 * sizeMult, targetHitbox);
|
|
public override bool? CanCutTiles() => false;
|
|
}
|
|
}
|