99 lines
3.4 KiB
C#
99 lines
3.4 KiB
C#
using System;
|
|
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Projectiles.Magic
|
|
{
|
|
public class HellwingBat : ModProjectile, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Projectiles.Magic";
|
|
public override void SetStaticDefaults()
|
|
{
|
|
Main.projFrames[Projectile.type] = 12;
|
|
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 4;
|
|
ProjectileID.Sets.TrailingMode[Projectile.type] = 0;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = Projectile.height = 36;
|
|
Projectile.friendly = true;
|
|
Projectile.ignoreWater = true;
|
|
Projectile.tileCollide = false;
|
|
Projectile.DamageType = DamageClass.Magic;
|
|
Projectile.penetrate = 1;
|
|
Projectile.extraUpdates = 3;
|
|
Projectile.timeLeft = 90;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
Projectile.frameCounter++;
|
|
if (Projectile.frameCounter > 5)
|
|
{
|
|
Projectile.frame++;
|
|
Projectile.frameCounter = 0;
|
|
}
|
|
if (Projectile.frame >= Main.projFrames[Projectile.type])
|
|
{
|
|
Projectile.frame = 0;
|
|
}
|
|
Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.25f / 255f, (255 - Projectile.alpha) * 0.05f / 255f, (255 - Projectile.alpha) * 0.05f / 255f);
|
|
if (Projectile.ai[0] > 7f)
|
|
{
|
|
float scalar = 1f;
|
|
if (Projectile.ai[0] == 8f)
|
|
{
|
|
scalar = 0.25f;
|
|
}
|
|
else if (Projectile.ai[0] == 9f)
|
|
{
|
|
scalar = 0.5f;
|
|
}
|
|
else if (Projectile.ai[0] == 10f)
|
|
{
|
|
scalar = 0.75f;
|
|
}
|
|
Projectile.ai[0] += 1f;
|
|
if (Main.rand.NextBool(3))
|
|
{
|
|
int flareDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Flare, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f);
|
|
Dust dust = Main.dust[flareDust];
|
|
if (Main.rand.NextBool(3))
|
|
{
|
|
dust.noGravity = true;
|
|
dust.scale *= 2f;
|
|
dust.velocity.X *= 2f;
|
|
dust.velocity.Y *= 2f;
|
|
}
|
|
else
|
|
{
|
|
dust.scale *= 1.5f;
|
|
}
|
|
dust.velocity.X *= 1.2f;
|
|
dust.velocity.Y *= 1.2f;
|
|
dust.scale *= scalar;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Projectile.ai[0] += 1f;
|
|
}
|
|
Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2;
|
|
}
|
|
|
|
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
|
{
|
|
target.AddBuff(BuffID.OnFire, 240);
|
|
}
|
|
|
|
public override bool PreDraw(ref Color lightColor)
|
|
{
|
|
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1);
|
|
return false;
|
|
}
|
|
}
|
|
}
|