Note: Does not include item rarities, and appears to shown nonexistant using directive movement in the commit. This does not really affect anything, however.
173 lines
8.3 KiB
C#
173 lines
8.3 KiB
C#
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using System;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
namespace CalamityMod.Projectiles.Magic
|
|
{
|
|
public class GranitePulse : ModProjectile
|
|
{
|
|
public float count = 0f;
|
|
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Pulse");
|
|
Main.projFrames[projectile.type] = 6;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
projectile.width = 40;
|
|
projectile.height = 46;
|
|
projectile.friendly = true;
|
|
projectile.ignoreWater = true;
|
|
projectile.tileCollide = false;
|
|
projectile.magic = true;
|
|
projectile.penetrate = -1;
|
|
projectile.timeLeft = 1200;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
projectile.velocity = new Vector2(0f, (float)Math.Sin((double)(6.28318548f * projectile.ai[0] / 300f)) * 0.5f);
|
|
projectile.ai[0] += 1f;
|
|
if (projectile.ai[0] >= 300f)
|
|
{
|
|
projectile.ai[0] = 0f;
|
|
projectile.netUpdate = true;
|
|
}
|
|
|
|
projectile.frameCounter++;
|
|
if (projectile.frameCounter > 4)
|
|
{
|
|
projectile.frame++;
|
|
projectile.frameCounter = 0;
|
|
}
|
|
if (projectile.frame >= Main.projFrames[projectile.type])
|
|
{
|
|
projectile.frame = 0;
|
|
}
|
|
projectile.ai[1] += 1f;
|
|
if (projectile.ai[1] >= 7200f)
|
|
{
|
|
projectile.alpha += 5;
|
|
if (projectile.alpha > 255)
|
|
{
|
|
projectile.alpha = 255;
|
|
projectile.Kill();
|
|
}
|
|
}
|
|
projectile.localAI[0] += 1f;
|
|
if (projectile.localAI[0] >= 10f)
|
|
{
|
|
projectile.localAI[0] = 0f;
|
|
int num416 = 0;
|
|
int num417 = 0;
|
|
float num418 = 0f;
|
|
int num419 = projectile.type;
|
|
for (int num420 = 0; num420 < Main.maxProjectiles; num420++)
|
|
{
|
|
if (Main.projectile[num420].active && Main.projectile[num420].owner == projectile.owner && Main.projectile[num420].type == num419 && Main.projectile[num420].ai[1] < 3600f)
|
|
{
|
|
num416++;
|
|
if (Main.projectile[num420].ai[1] > num418)
|
|
{
|
|
num417 = num420;
|
|
num418 = Main.projectile[num420].ai[1];
|
|
}
|
|
}
|
|
}
|
|
if (num416 > 1)
|
|
{
|
|
Main.projectile[num417].netUpdate = true;
|
|
Main.projectile[num417].ai[1] = 36000f;
|
|
return;
|
|
}
|
|
}
|
|
if (count == 0f)
|
|
{
|
|
Main.PlaySound(SoundID.NPCHit53, projectile.position);
|
|
projectile.position.X = projectile.position.X + (float)(projectile.width / 2);
|
|
projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2);
|
|
projectile.width = 20;
|
|
projectile.height = 20;
|
|
projectile.position.X = projectile.position.X - (float)(projectile.width / 2);
|
|
projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2);
|
|
for (int num621 = 0; num621 < 5; num621++)
|
|
{
|
|
int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 229, 0f, 0f, 100, default, 0.5f);
|
|
Main.dust[num622].velocity *= 3f;
|
|
if (Main.rand.NextBool(2))
|
|
{
|
|
Main.dust[num622].scale = 0.5f;
|
|
Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f;
|
|
}
|
|
}
|
|
for (int num623 = 0; num623 < 10; num623++)
|
|
{
|
|
int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 206, 0f, 0f, 100, default, 1f);
|
|
Main.dust[num624].noGravity = true;
|
|
Main.dust[num624].velocity *= 5f;
|
|
num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 206, 0f, 0f, 100, default, 0.5f);
|
|
Main.dust[num624].velocity *= 2f;
|
|
}
|
|
count += 1f;
|
|
}
|
|
if (projectile.timeLeft % 50 == 49)
|
|
{
|
|
Main.PlaySound(SoundID.NPCHit53, projectile.position);
|
|
projectile.position.X = projectile.position.X + (float)(projectile.width / 2);
|
|
projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2);
|
|
projectile.width = 20;
|
|
projectile.height = 20;
|
|
projectile.position.X = projectile.position.X - (float)(projectile.width / 2);
|
|
projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2);
|
|
for (int num621 = 0; num621 < 5; num621++)
|
|
{
|
|
int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 229, 0f, 0f, 100, default, 0.5f);
|
|
Main.dust[num622].velocity *= 3f;
|
|
if (Main.rand.NextBool(2))
|
|
{
|
|
Main.dust[num622].scale = 0.5f;
|
|
Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f;
|
|
}
|
|
}
|
|
for (int num623 = 0; num623 < 10; num623++)
|
|
{
|
|
int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 206, 0f, 0f, 100, default, 1f);
|
|
Main.dust[num624].noGravity = true;
|
|
Main.dust[num624].velocity *= 5f;
|
|
num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 206, 0f, 0f, 100, default, 0.5f);
|
|
Main.dust[num624].velocity *= 2f;
|
|
}
|
|
float spread = 45f * 0.0174f;
|
|
double startAngle = Math.Atan2(projectile.velocity.X, projectile.velocity.Y) - spread / 2;
|
|
double deltaAngle = spread / 8f;
|
|
double offsetAngle;
|
|
if (projectile.owner == Main.myPlayer)
|
|
{
|
|
for (int i = 0; i < 4; i++)
|
|
{
|
|
offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i;
|
|
Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType<GraniteEnergy>(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f);
|
|
Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType<GraniteEnergy>(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
|
{
|
|
Texture2D texture = Main.projectileTexture[projectile.type];
|
|
int height = texture.Height / Main.projFrames[projectile.type];
|
|
int frameHeight = height * projectile.frame;
|
|
SpriteEffects spriteEffects = SpriteEffects.None;
|
|
if (projectile.spriteDirection == -1)
|
|
spriteEffects = SpriteEffects.FlipHorizontally;
|
|
Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, frameHeight, texture.Width, height)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture.Width / 2f, (float)height / 2f), projectile.scale, spriteEffects, 0f);
|
|
return false;
|
|
}
|
|
}
|
|
}
|