Files
CalamityModPublic/Projectiles/Magic/Ancient.cs
T
Xyk 7aa44ad7d9 Changed all ~640 instances of Main.rand.NextBool(2) to remove the unnecessary 2
Also I forgot to push my reality rupture and ichor spear minor tweaks before hand so they're in here too.
Reality rupture stealth hit sound is louder.
Reality rupture stealth visual always has at least one big crack, cracks fade out.
There's more consistency in the spark particles on realty rupture stealth and ichor spear on hit sparks.
Reality Rupture stealth produces light.
2023-09-26 01:58:55 -07:00

133 lines
5.5 KiB
C#

using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Buffs.StatDebuffs;
using CalamityMod.DataStructures;
using Microsoft.Xna.Framework;
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Magic
{
public class Ancient : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Magic";
public override void SetStaticDefaults()
{
Main.projFrames[Projectile.type] = 6;
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 10;
ProjectileID.Sets.TrailingMode[Projectile.type] = 2;
}
public override void SetDefaults()
{
Projectile.width = 100;
Projectile.height = 100;
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.DamageType = DamageClass.Magic;
Projectile.tileCollide = false;
Projectile.penetrate = 6;
Projectile.extraUpdates = 6;
Projectile.timeLeft = 151;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 6;
}
public override void AI()
{
Lighting.AddLight(Projectile.Center, 0.6f, 0.5f, 0f);
if (Projectile.timeLeft % 30 == 0)
{
int numProj = 3;
float randomSpread = Main.rand.NextFloat(3f, 18f);
float rotation = MathHelper.ToRadians(randomSpread);
if (Projectile.owner == Main.myPlayer)
{
for (int i = -1; i < numProj - 1; i++)
{
Vector2 perturbedSpeed = Projectile.velocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i));
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, perturbedSpeed, ModContent.ProjectileType<Ancient2>(), (int)(Projectile.damage * 0.5), Projectile.knockBack * 0.5f, Projectile.owner, 0f, Projectile.ai[1]);
}
}
}
Projectile.rotation += (Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y)) * 0.01f * (float)Projectile.direction;
Projectile.frameCounter++;
if (Projectile.frameCounter > 3)
{
Projectile.frame++;
Projectile.frameCounter = 0;
}
if (Projectile.frame >= Main.projFrames[Projectile.type])
{
Projectile.frame = 0;
}
if (Projectile.ai[0] > 4f && Projectile.numUpdates % 2 == 0)
{
int dustType = 22;
int idx = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f);
Dust dust = Main.dust[idx];
if (Main.rand.NextBool())
{
dust.noGravity = true;
dust.scale *= 2f;
dust.velocity.X *= 3f;
dust.velocity.Y *= 3f;
}
else
{
dust.scale *= 1.25f;
}
dust.velocity.X *= 2f;
dust.velocity.Y *= 2f;
idx = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f);
if (Main.rand.NextBool(3))
{
dust.noGravity = true;
dust.scale *= 1.5f;
dust.velocity.X *= 2f;
dust.velocity.Y *= 2f;
}
else
{
dust.scale *= 1.1f;
}
dust.velocity.X *= 1.5f;
dust.velocity.Y *= 1.5f;
}
Projectile.ai[0] += 1f;
Projectile.rotation += 0.3f * (float)Projectile.direction;
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType<ArmorCrunch>(), 180);
public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType<ArmorCrunch>(), 180);
public override bool PreDraw(ref Color lightColor)
{
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1);
// Dust effects
Circle dustCircle = new Circle(Projectile.Center, Projectile.width / 2);
for (int i = 0; i < 20; i++)
{
// Dust
Vector2 dustPos = dustCircle.RandomPointInCircle();
if ((dustPos - Projectile.Center).Length() > 48)
{
int dustIndex = Dust.NewDust(dustPos, 1, 1, 22);
Main.dust[dustIndex].noGravity = true;
Main.dust[dustIndex].fadeIn = 1f;
Vector2 dustVelocity = Projectile.Center - Main.dust[dustIndex].position;
float distToCenter = dustVelocity.Length();
dustVelocity.Normalize();
dustVelocity = dustVelocity.RotatedBy(MathHelper.ToRadians(-90f));
dustVelocity *= distToCenter * 0.04f;
Main.dust[dustIndex].velocity = dustVelocity;
}
}
return false;
}
}
}