72 lines
2.5 KiB
C#
72 lines
2.5 KiB
C#
using Microsoft.Xna.Framework;
|
|
using System;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Projectiles.Magic
|
|
{
|
|
public class ForbiddenSunProjectile : ModProjectile
|
|
{
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Sun");
|
|
Main.projFrames[projectile.type] = 4;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
projectile.width = 26;
|
|
projectile.height = 26;
|
|
projectile.friendly = true;
|
|
projectile.penetrate = 1;
|
|
projectile.timeLeft = 600;
|
|
projectile.magic = true;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X);
|
|
projectile.frameCounter++;
|
|
if (projectile.frameCounter > 4)
|
|
{
|
|
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.2f / 255f, (255 - projectile.alpha) * 0.01f / 255f);
|
|
if (projectile.wet && !projectile.lavaWet)
|
|
{
|
|
projectile.Kill();
|
|
}
|
|
if (projectile.localAI[0] == 0f)
|
|
{
|
|
Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 20);
|
|
projectile.localAI[0] += 1f;
|
|
}
|
|
if (Main.rand.NextBool(4))
|
|
{
|
|
int num469 = Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, Main.rand.NextBool(3) ? 16 : 174, 0f, 0f);
|
|
Main.dust[num469].noGravity = true;
|
|
Main.dust[num469].velocity *= 0f;
|
|
}
|
|
}
|
|
|
|
public override void Kill(int timeLeft)
|
|
{
|
|
if (projectile.owner == Main.myPlayer)
|
|
{
|
|
Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType<ForbiddenSunburst>(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f);
|
|
}
|
|
}
|
|
|
|
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
|
|
{
|
|
target.AddBuff(BuffID.OnFire, 600);
|
|
}
|
|
}
|
|
}
|