Files
CalamityModPublic/Projectiles/Rogue/FantasyTalismanStealth.cs
T

89 lines
3.4 KiB
C#

using CalamityMod.NPCs;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Rogue
{
[PierceResistException]
public class FantasyTalismanStealth : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Rogue";
public override string Texture => "CalamityMod/Projectiles/Rogue/FantasyTalismanProj";
public override void SetStaticDefaults()
{
ProjectileID.Sets.TrailCacheLength[Type] = 3;
ProjectileID.Sets.TrailingMode[Type] = 0;
}
public override void SetDefaults()
{
Projectile.width = 10;
Projectile.height = 10;
Projectile.friendly = true;
Projectile.DamageType = RogueDamageClass.Instance;
Projectile.ignoreWater = true;
Projectile.aiStyle = ProjAIStyleID.Arrow;
AIType = ProjectileID.BulletHighVelocity;
Projectile.penetrate = -1;
Projectile.extraUpdates = 1;
Projectile.timeLeft = 600;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = -1;
}
public override void AI()
{
Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X > 0).ToDirectionInt();
Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == 1 ? 0f : MathHelper.Pi);
if (Main.rand.NextBool(3))
{
Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.SpectreStaff, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f);
}
Projectile.StickyProjAI(4);
if (Projectile.ai[0] == 1f)
{
if (Projectile.timeLeft % 20 == 0)
{
Projectile ghost = CalamityUtils.SpawnOrb(Projectile, (int)(Projectile.damage * 0.3f), ProjectileID.SpectreWrath, 1000f, 4f);
if (ghost.whoAmI.WithinBounds(Main.maxProjectiles))
{
ghost.DamageType = RogueDamageClass.Instance;
ghost.penetrate = 1;
}
}
}
}
public override bool PreDraw(ref Color lightColor)
{
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 2);
return false;
}
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => Projectile.ModifyHitNPCSticky(6);
public override void OnKill(int timeLeft)
{
if (Projectile.owner == Main.myPlayer)
{
for (int j = 0; j <= 3; j++)
{
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Main.rand.NextVector2Circular(12f, 12f), ModContent.ProjectileType<LostSoulFriendly>(), Projectile.damage / 2, Projectile.knockBack, Projectile.owner, 0f, 0f);
}
}
}
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox)
{
if (targetHitbox.Width > 8 && targetHitbox.Height > 8)
{
targetHitbox.Inflate(-targetHitbox.Width / 8, -targetHitbox.Height / 8);
}
return null;
}
}
}