replaced all (i think?) instances of global iframes on projectiles that damage enemies with an equivalent amount of static iframes. Some projectile types, such as Bees and Giant bees, I gave shared static iframes to. About 650 projectiles were changed here.
63 lines
2.5 KiB
C#
63 lines
2.5 KiB
C#
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.ModLoader;
|
|
namespace CalamityMod.Projectiles.Magic
|
|
{
|
|
public class NightsRayBeam : ModProjectile, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Projectiles.Magic";
|
|
public ref float Time => ref Projectile.ai[0];
|
|
public bool HasFiredSideBeams
|
|
{
|
|
get => Projectile.ai[1] == 1f;
|
|
set => Projectile.ai[1] = value.ToInt();
|
|
}
|
|
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 4;
|
|
Projectile.height = 4;
|
|
Projectile.friendly = true;
|
|
Projectile.DamageType = DamageClass.Magic;
|
|
Projectile.ignoreWater = true;
|
|
Projectile.penetrate = 10;
|
|
Projectile.extraUpdates = 100;
|
|
Projectile.timeLeft = 150;
|
|
Projectile.usesIDStaticNPCImmunity = true;
|
|
Projectile.idStaticNPCHitCooldown = 10;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
Time++;
|
|
if (Time >= 10f)
|
|
{
|
|
for (int i = 0; i < 2; i++)
|
|
{
|
|
Vector2 dustSpawnPos = Projectile.position - Projectile.velocity * i / 2f;
|
|
Dust corruptMagic = Dust.NewDustPerfect(dustSpawnPos, 27);
|
|
corruptMagic.color = Color.Lerp(Color.Fuchsia, Color.Magenta, Main.rand.NextFloat(0.6f));
|
|
corruptMagic.scale = Main.rand.NextFloat(0.96f, 1.04f);
|
|
corruptMagic.noGravity = true;
|
|
corruptMagic.velocity *= 0.1f;
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
|
{
|
|
if (!HasFiredSideBeams && Projectile.owner == Main.myPlayer)
|
|
{
|
|
Vector2 baseSpawnPositionOffset = Main.rand.NextVector2CircularEdge(40f, 40f);
|
|
for (int i = 0; i < 4; i++)
|
|
{
|
|
Vector2 spawnPosition = target.Center + baseSpawnPositionOffset.RotatedBy(MathHelper.TwoPi * i / 4f);
|
|
Projectile.NewProjectile(Projectile.GetSource_FromThis(), spawnPosition, Vector2.Zero, ModContent.ProjectileType<NightOrb>(), (int)(Projectile.damage * 0.8), Projectile.knockBack, Projectile.owner);
|
|
}
|
|
HasFiredSideBeams = true;
|
|
Projectile.netUpdate = true;
|
|
}
|
|
}
|
|
}
|
|
}
|