Files
CalamityModPublic/Projectiles/Summon/EnergyOrb.cs
T
CongratsIsTrash e0e167346e Added ProjectileID.Sets.CultistIsResistantTo on every homing projectile in Calamity
This does nothing for Calamity since we disable Cultist's homing resist.
However, since this is effectively used as a homing projectile set, this will help with crossmod compatibility.
I ask that everyone else who changes homing projectiles in any way to help maintain this.
2024-09-09 23:52:07 -04:00

44 lines
1.7 KiB
C#

using CalamityMod.Buffs.DamageOverTime;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Summon
{
public class EnergyOrb : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Summon";
public override string Texture => "CalamityMod/Projectiles/Magic/BlueBubble";
public override void SetStaticDefaults() => ProjectileID.Sets.CultistIsResistantTo[Type] = true;
public override void SetDefaults()
{
Projectile.width = 14;
Projectile.height = 14;
Projectile.alpha = 100;
Projectile.friendly = true;
Projectile.penetrate = 1;
Projectile.tileCollide = false;
Projectile.timeLeft = 200;
Projectile.DamageType = DamageClass.Summon;
}
public override void AI()
{
Projectile.localAI[0] += 1f;
if (Projectile.localAI[0] > 4f)
{
int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Firework_Blue, 0f, 0f, 100, default, 1f);
if (!Main.rand.NextBool(6))
Main.dust[dust].noGravity = true;
Main.dust[dust].velocity *= 0f;
}
NPC potentialTarget = Projectile.Center.MinionHoming(400f, Main.player[Projectile.owner]);
if (potentialTarget != null)
Projectile.velocity = (Projectile.velocity * 20f + Projectile.SafeDirectionTo(potentialTarget.Center) * 10f) / 21f;
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType<StaticDischarge>(), 90);
}
}