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.
83 lines
3.0 KiB
C#
83 lines
3.0 KiB
C#
using CalamityMod.Buffs.DamageOverTime;
|
|
using CalamityMod.Dusts;
|
|
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.Audio;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
namespace CalamityMod.Projectiles.Ranged
|
|
{
|
|
public class AstralRound : ModProjectile, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Projectiles.Ranged";
|
|
private float speed = 0f;
|
|
public override void SetStaticDefaults()
|
|
{
|
|
ProjectileID.Sets.CultistIsResistantTo[Type] = true;
|
|
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 6;
|
|
ProjectileID.Sets.TrailingMode[Projectile.type] = 0;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 4;
|
|
Projectile.height = 4;
|
|
Projectile.aiStyle = ProjAIStyleID.Arrow;
|
|
Projectile.friendly = true;
|
|
Projectile.DamageType = DamageClass.Ranged;
|
|
Projectile.penetrate = 1;
|
|
Projectile.timeLeft = 600;
|
|
Projectile.light = 0.25f;
|
|
Projectile.extraUpdates = 2;
|
|
AIType = ProjectileID.Bullet;
|
|
Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration;
|
|
}
|
|
|
|
public override bool OnTileCollide(Vector2 oldVelocity)
|
|
{
|
|
Collision.HitTiles(Projectile.position, Projectile.velocity, Projectile.width, Projectile.height);
|
|
SoundEngine.PlaySound(SoundID.Dig, Projectile.position);
|
|
return true;
|
|
}
|
|
|
|
public override bool PreDraw(ref Color lightColor)
|
|
{
|
|
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1);
|
|
return false;
|
|
}
|
|
|
|
public override bool PreAI()
|
|
{
|
|
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.ToRadians(90f);
|
|
Projectile.spriteDirection = Projectile.direction;
|
|
|
|
Projectile.localAI[0] += 1f;
|
|
if (Projectile.localAI[0] > 4f)
|
|
{
|
|
if (Main.rand.NextBool())
|
|
{
|
|
int randomDust = Utils.SelectRandom(Main.rand, new int[]
|
|
{
|
|
ModContent.DustType<AstralOrange>(),
|
|
ModContent.DustType<AstralBlue>()
|
|
});
|
|
int astral = Dust.NewDust(Projectile.position, 1, 1, randomDust, 0f, 0f, 0, default, 0.5f);
|
|
Main.dust[astral].alpha = Projectile.alpha;
|
|
Main.dust[astral].velocity *= 0f;
|
|
Main.dust[astral].noGravity = true;
|
|
}
|
|
}
|
|
|
|
if (speed == 0f)
|
|
speed = Projectile.velocity.Length();
|
|
|
|
CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 200f, speed, 12f);
|
|
return false;
|
|
}
|
|
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
|
{
|
|
target.AddBuff(ModContent.BuffType<AstralInfectionDebuff>(), 120);
|
|
}
|
|
}
|
|
}
|