plasma grenade explosion & supernova radius fix
This commit is contained in:
1 parent
c56fb8c09d
commit
bd032e47b5
6 files changed
+154
-12
No files matched your search
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 46 KiB |
@@ -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<PlasmaGrenadeSmallExplosion>(), projectile.damage, projectile.knockBack, projectile.owner);
|
||||
}
|
||||
if (!Main.dedServ)
|
||||
{
|
||||
for (int i = 0; i < 120; i++)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
@@ -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()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user