diff --git a/Projectiles/DraedonsArsenal/MassivePlasmaExplosion.cs b/Projectiles/DraedonsArsenal/MassivePlasmaExplosion.cs index 517389e439..4bc568a214 100644 --- a/Projectiles/DraedonsArsenal/MassivePlasmaExplosion.cs +++ b/Projectiles/DraedonsArsenal/MassivePlasmaExplosion.cs @@ -1,5 +1,6 @@ using System; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ModLoader; @@ -12,7 +13,15 @@ namespace CalamityMod.Projectiles.DraedonsArsenal get => projectile.ai[0]; set => projectile.ai[0] = value; } - public const int Lifetime = 25; + private float lightAmt = 1f; + + public int frameX = 0; + public int frameY = 0; + private const int horizontalFrames = 4; + private const int verticalFrames = 5; + private const int frameLength = 5; + private const float radius = 191.5f; + public override void SetStaticDefaults() { DisplayName.SetDefault("Plasma Explosion"); @@ -20,28 +29,72 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public override void SetDefaults() { - projectile.width = projectile.height = 840; + projectile.width = projectile.height = 383; projectile.friendly = true; projectile.penetrate = -1; - projectile.timeLeft = 37; projectile.tileCollide = false; projectile.Calamity().rogue = true; projectile.usesIDStaticNPCImmunity = true; - projectile.idStaticNPCHitCooldown = 12; + projectile.idStaticNPCHitCooldown = frameLength * horizontalFrames * verticalFrames / 3; } public override void AI() { - Lighting.AddLight(projectile.Center, Color.White.ToVector3() * 4f * projectile.scale); + projectile.frameCounter++; + if (projectile.frameCounter % frameLength == frameLength - 1) + { + frameY++; + if (frameY >= verticalFrames) + { + frameX++; + frameY = 0; + } + if (frameX >= horizontalFrames) + { + projectile.Kill(); + } + } + + Lighting.AddLight(projectile.Center, Color.White.ToVector3() * 4f * lightAmt); if (projectile.localAI[0] == 0f) { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/FlareSound"), projectile.Center); projectile.localAI[0] = 1f; } - projectile.scale = (float)Math.Sin(Time / 37 * MathHelper.Pi) * 2f; - if (projectile.scale > 1f) - projectile.scale = 1f; + lightAmt = (float)Math.Sin(Time / 37 * MathHelper.Pi) * 2f; + if (lightAmt > 1f) + lightAmt = 1f; Time++; } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + float dist1 = Vector2.Distance(projectile.Center, targetHitbox.TopLeft()); + float dist2 = Vector2.Distance(projectile.Center, targetHitbox.TopRight()); + float dist3 = Vector2.Distance(projectile.Center, targetHitbox.BottomLeft()); + float dist4 = Vector2.Distance(projectile.Center, targetHitbox.BottomRight()); + + float minDist = dist1; + if (dist2 < minDist) + minDist = dist2; + if (dist3 < minDist) + minDist = dist3; + if (dist4 < minDist) + minDist = dist4; + + return minDist <= radius; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + int length = texture.Width / horizontalFrames; + int height = texture.Height / verticalFrames; + Vector2 drawPos = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); + Rectangle frame = new Rectangle(frameX * length, frameY * height, length, height); + Vector2 origin = new Vector2(length / 2f, height / 2f); + spriteBatch.Draw(texture, drawPos, frame, Color.White, projectile.rotation, origin, projectile.scale, SpriteEffects.None, 0f); + return false; + } } } diff --git a/Projectiles/DraedonsArsenal/MassivePlasmaExplosion.png b/Projectiles/DraedonsArsenal/MassivePlasmaExplosion.png index 5eaa600e71..0124fd3bcd 100644 Binary files a/Projectiles/DraedonsArsenal/MassivePlasmaExplosion.png and b/Projectiles/DraedonsArsenal/MassivePlasmaExplosion.png differ diff --git a/Projectiles/DraedonsArsenal/PlasmaGrenadeProjectile.cs b/Projectiles/DraedonsArsenal/PlasmaGrenadeProjectile.cs index 21822a2fb7..0c05f3c94b 100644 --- a/Projectiles/DraedonsArsenal/PlasmaGrenadeProjectile.cs +++ b/Projectiles/DraedonsArsenal/PlasmaGrenadeProjectile.cs @@ -74,9 +74,10 @@ namespace CalamityMod.Projectiles.DraedonsArsenal else { CalamityGlobalProjectile.ExpandHitboxBy(projectile, 360); - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - projectile.Damage(); + if (Main.myPlayer == projectile.owner) + { + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); + } if (!Main.dedServ) { for (int i = 0; i < 120; i++) diff --git a/Projectiles/DraedonsArsenal/PlasmaGrenadeSmallExplosion.cs b/Projectiles/DraedonsArsenal/PlasmaGrenadeSmallExplosion.cs new file mode 100644 index 0000000000..2fb0536bf7 --- /dev/null +++ b/Projectiles/DraedonsArsenal/PlasmaGrenadeSmallExplosion.cs @@ -0,0 +1,88 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.DraedonsArsenal +{ + public class PlasmaGrenadeSmallExplosion : ModProjectile + { + public float Time + { + get => projectile.ai[0]; + set => projectile.ai[0] = value; + } + + public int frameX = 0; + public int frameY = 0; + private const int horizontalFrames = 2; + private const int verticalFrames = 7; + private const int frameLength = 5; + private const float radius = 139.5f; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Plasma Explosion"); + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 279; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.Calamity().rogue = true; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = -1; + } + + public override void AI() + { + projectile.frameCounter++; + if (projectile.frameCounter % frameLength == frameLength - 1) + { + frameY++; + if (frameY >= verticalFrames) + { + frameX++; + frameY = 0; + } + if (frameX >= horizontalFrames) + { + projectile.Kill(); + } + } + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + float dist1 = Vector2.Distance(projectile.Center, targetHitbox.TopLeft()); + float dist2 = Vector2.Distance(projectile.Center, targetHitbox.TopRight()); + float dist3 = Vector2.Distance(projectile.Center, targetHitbox.BottomLeft()); + float dist4 = Vector2.Distance(projectile.Center, targetHitbox.BottomRight()); + + float minDist = dist1; + if (dist2 < minDist) + minDist = dist2; + if (dist3 < minDist) + minDist = dist3; + if (dist4 < minDist) + minDist = dist4; + + return minDist <= radius; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + int length = texture.Width / horizontalFrames; + int height = texture.Height / verticalFrames; + Vector2 drawPos = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); + Rectangle frame = new Rectangle(frameX * length, frameY * height, length, height); + Vector2 origin = new Vector2(length / 2f, height / 2f); + spriteBatch.Draw(texture, drawPos, frame, Color.White, projectile.rotation, origin, projectile.scale, SpriteEffects.None, 0f); + return false; + } + } +} diff --git a/Projectiles/DraedonsArsenal/PlasmaGrenadeSmallExplosion.png b/Projectiles/DraedonsArsenal/PlasmaGrenadeSmallExplosion.png new file mode 100644 index 0000000000..9c3928fb75 Binary files /dev/null and b/Projectiles/DraedonsArsenal/PlasmaGrenadeSmallExplosion.png differ diff --git a/Projectiles/Rogue/SupernovaBoom.cs b/Projectiles/Rogue/SupernovaBoom.cs index 70a7b89f4a..fbd18025d9 100644 --- a/Projectiles/Rogue/SupernovaBoom.cs +++ b/Projectiles/Rogue/SupernovaBoom.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Projectiles.Rogue private const int horizontalFrames = 5; private const int verticalFrames = 4; private const int frameLength = 5; - private const float radius = 409f; + private const float radius = 204.5f; public override void SetStaticDefaults() {