Files
CalamityModPublic/Projectiles/Melee/Yoyos/FaultLineYoyo.cs
T
2023-08-13 15:16:20 +07:00

68 lines
2.8 KiB
C#

using CalamityMod.Projectiles.Typeless;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Melee.Yoyos
{
public class FaultLineYoyo : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Melee";
public const int MaxUpdates = 2;
public override void SetStaticDefaults()
{
ProjectileID.Sets.YoyosLifeTimeMultiplier[Projectile.type] = -1f;
ProjectileID.Sets.YoyosMaximumRange[Projectile.type] = 480f;
ProjectileID.Sets.YoyosTopSpeed[Projectile.type] = 40f / MaxUpdates;
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 4;
ProjectileID.Sets.TrailingMode[Projectile.type] = 0;
}
public override void SetDefaults()
{
Projectile.aiStyle = ProjAIStyleID.Yoyo;
Projectile.width = Projectile.height = 16;
Projectile.friendly = true;
Projectile.DamageType = DamageClass.MeleeNoSpeed;
Projectile.penetrate = -1;
Projectile.MaxUpdates = MaxUpdates;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 10 * MaxUpdates;
}
public override void AI()
{
if (Main.rand.NextBool(5))
Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, Main.rand.NextBool(3) ? 16 : 127, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f);
if (Main.rand.NextBool(8) && Main.netMode != NetmodeID.Server)
{
int smoke = Gore.NewGore(Projectile.GetSource_FromAI(), Projectile.position, default, Main.rand.Next(375, 378), 0.5f);
Main.gore[smoke].behindTiles = true;
}
if ((Projectile.position - Main.player[Projectile.owner].position).Length() > 3200f) //200 blocks
Projectile.Kill();
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
target.AddBuff(BuffID.OnFire3, 240);
if (Projectile.owner == Main.myPlayer)
{
int boom = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType<FuckYou>(), (int)(Projectile.damage * 0.5f), Projectile.knockBack, Projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f);
if (boom.WithinBounds(Main.maxProjectiles))
Main.projectile[boom].DamageType = DamageClass.MeleeNoSpeed;
}
}
public override bool PreDraw(ref Color lightColor)
{
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1);
return false;
}
}
}