Replaced all of its use cases with Frozen, which inherits exactly its old effects
128 lines
5.2 KiB
C#
128 lines
5.2 KiB
C#
using CalamityMod.Buffs.StatDebuffs;
|
|
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Projectiles.Rogue
|
|
{
|
|
public class FrostyFlareProj : ModProjectile, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Projectiles.Rogue";
|
|
public override string Texture => "CalamityMod/Items/Weapons/Rogue/FrostyFlare";
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 10;
|
|
Projectile.height = 10;
|
|
Projectile.coldDamage = true;
|
|
Projectile.friendly = true;
|
|
Projectile.penetrate = -1;
|
|
Projectile.timeLeft = 300;
|
|
Projectile.DamageType = RogueDamageClass.Instance;
|
|
Projectile.usesIDStaticNPCImmunity = true;
|
|
Projectile.idStaticNPCHitCooldown = 10;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
if (Projectile.owner != Main.myPlayer)
|
|
return;
|
|
|
|
bool shoot = false;
|
|
if (Projectile.timeLeft % 30f == 0f)
|
|
{
|
|
if (Projectile.owner == Main.myPlayer)
|
|
shoot = true;
|
|
}
|
|
|
|
if (Projectile.ai[0] == 0f)
|
|
{
|
|
Projectile.velocity.X *= 0.99f;
|
|
Projectile.velocity.Y += 0.25f;
|
|
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2;
|
|
|
|
if (shoot)
|
|
{
|
|
Vector2 pos = Projectile.Center - new Vector2(Main.rand.Next(-300, 301), Main.rand.Next(500, 751));
|
|
Vector2 vel = Utils.DirectionTo(pos, Projectile.Center) * 30f;
|
|
vel.X += Main.rand.NextFloat(-4f, 4f);
|
|
int shard = Projectile.NewProjectile(Projectile.GetSource_FromThis(), pos, vel + Projectile.velocity / 4f, ModContent.ProjectileType<FrostShardFriendly>(), (int)(Projectile.damage * 0.75f), Projectile.knockBack, Projectile.owner);
|
|
Main.projectile[shard].alpha = Projectile.alpha;
|
|
}
|
|
|
|
int index2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.DungeonWater);
|
|
Main.dust[index2].noGravity = true;
|
|
|
|
if (Projectile.ai[2] == 1f)
|
|
CalamityUtils.HomeInOnSelectedNPC(Projectile, CalamityUtils.ClosestNPCAt(Projectile.Center, 400f, false), false, 5f, 30f, 0.99f);
|
|
}
|
|
else
|
|
{
|
|
Projectile.ignoreWater = true;
|
|
Projectile.tileCollide = false;
|
|
int id = (int)Projectile.ai[1];
|
|
if (id >= 0 && id < Main.maxNPCs && Main.npc[id].active && !Main.npc[id].dontTakeDamage)
|
|
{
|
|
Projectile.Center = Main.npc[id].Center - Projectile.velocity * 2f;
|
|
Projectile.gfxOffY = Main.npc[id].gfxOffY;
|
|
|
|
if (shoot)
|
|
{
|
|
Vector2 pos = Projectile.Center - new Vector2(Main.rand.Next(-300, 301), Main.rand.Next(500, 751));
|
|
Vector2 vel = Utils.DirectionTo(pos, Projectile.Center) * 30f;
|
|
vel.X += Main.rand.NextFloat(-4f, 4f);
|
|
int shard = Projectile.NewProjectile(Projectile.GetSource_FromThis(), pos, vel + Main.npc[id].velocity, ModContent.ProjectileType<FrostShardFriendly>(), (int)(Projectile.damage * 0.75f), Projectile.knockBack, Projectile.owner);
|
|
Main.projectile[shard].alpha = Projectile.alpha;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Projectile.Kill();
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
|
{
|
|
target.AddBuff(BuffID.Frostburn2, 180);
|
|
target.AddBuff(BuffID.Frozen, 30);
|
|
Projectile.ai[0] = 1f;
|
|
Projectile.ai[1] = target.whoAmI;
|
|
Projectile.velocity = target.Center - Projectile.Center;
|
|
Projectile.velocity *= 0.75f;
|
|
Projectile.netUpdate = true;
|
|
|
|
const int maxFlares = 5;
|
|
int flaresFound = 0;
|
|
int oldestFlare = -1;
|
|
int oldestFlareTimeLeft = 300;
|
|
foreach (Projectile p in Main.ActiveProjectiles)
|
|
{
|
|
if (p.owner == Main.myPlayer && p.type == Projectile.type && p.whoAmI != Projectile.whoAmI && p.ai[1] == target.whoAmI)
|
|
{
|
|
flaresFound++;
|
|
if (p.timeLeft < oldestFlareTimeLeft)
|
|
{
|
|
oldestFlareTimeLeft = p.timeLeft;
|
|
oldestFlare = p.whoAmI;
|
|
}
|
|
if (flaresFound >= maxFlares)
|
|
break;
|
|
}
|
|
}
|
|
if (flaresFound >= maxFlares && oldestFlare >= 0)
|
|
{
|
|
Main.projectile[oldestFlare].Kill();
|
|
}
|
|
}
|
|
|
|
public override void OnHitPlayer(Player target, Player.HurtInfo info)
|
|
{
|
|
target.AddBuff(BuffID.Frostburn2, 180);
|
|
}
|
|
|
|
public override bool? CanDamage() => Projectile.ai[0] == 0f ? null : false;
|
|
}
|
|
}
|