Slight improvements to squash and stretch + rotational drawing changes
This commit is contained in:
1 parent
af21165f84
commit
e134375cfd
5 files changed
+104
-22
No files matched your search
@@ -38,7 +38,7 @@ namespace CalamityMod.NPCs.SlimeGod
|
||||
NPC.BossBar = Main.BigBossProgressBar.NeverValid;
|
||||
NPC.knockBackResist = 0f;
|
||||
NPC.value = 0f;
|
||||
NPC.Opacity = 0.8f;
|
||||
NPC.Opacity = 1f;
|
||||
NPC.lavaImmune = false;
|
||||
NPC.noGravity = false;
|
||||
NPC.noTileCollide = false;
|
||||
@@ -822,11 +822,16 @@ namespace CalamityMod.NPCs.SlimeGod
|
||||
Vector2 scaleStretch = new Vector2(1f - stretch, 1f + stretch) * NPC.scale;
|
||||
float yOffset = stretch * 0.5f * NPC.height;
|
||||
|
||||
spriteBatch.Draw(texture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY - yOffset), NPC.frame, drawColorAlpha, NPC.rotation, NPC.frame.Size() * 0.5f, scaleStretch, spriteEffects, 0f);
|
||||
spriteBatch.Draw(texture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY - yOffset), NPC.frame, drawColorAlpha, NPC.rotation + SlimeRotationFactor(NPC), NPC.frame.Size() * 0.5f, scaleStretch, spriteEffects, 0f);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static float SlimeRotationFactor(NPC npc)
|
||||
{
|
||||
return MathHelper.ToRadians(npc.velocity.X * (-npc.velocity.Y / 10));
|
||||
}
|
||||
|
||||
public override void HitEffect(NPC.HitInfo hit)
|
||||
{
|
||||
Color dustColor = Color.Crimson;
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace CalamityMod.NPCs.SlimeGod
|
||||
AIType = -1;
|
||||
NPC.knockBackResist = 0f;
|
||||
NPC.value = 0f;
|
||||
NPC.Opacity = 0.8f;
|
||||
NPC.Opacity = 1f;
|
||||
NPC.HitSound = SoundID.NPCHit1;
|
||||
NPC.DeathSound = SoundID.NPCDeath1;
|
||||
NPC.Calamity().VulnerableToHeat = true;
|
||||
@@ -449,8 +449,6 @@ namespace CalamityMod.NPCs.SlimeGod
|
||||
NPC.velocity.X *= 0.98f;
|
||||
}
|
||||
|
||||
NPC.rotation = MathHelper.Clamp(NPC.velocity.X * 0.05f, -0.5f, 0.5f);
|
||||
|
||||
if (bossLife == 0f && NPC.life > 0)
|
||||
bossLife = NPC.lifeMax;
|
||||
|
||||
@@ -628,16 +626,21 @@ namespace CalamityMod.NPCs.SlimeGod
|
||||
Color drawColorAlpha = NPC.GetAlpha(drawColor);
|
||||
|
||||
// Stretch based on Y velocity.
|
||||
float stretch = NPC.velocity.Y * 0.015f;
|
||||
stretch = Math.Abs(stretch) + addedStretch;
|
||||
float vel = NPC.velocity.Length();
|
||||
|
||||
float stretch = addedStretch;
|
||||
|
||||
float rot = MathHelper.Lerp(0f, MathHelper.WrapAngle(Vector2.Zero.AngleTo(NPC.velocity) + MathHelper.ToRadians(90f)), Math.Clamp(vel / 10f, 0f, 1f));
|
||||
|
||||
NPC.rotation = MathHelper.Lerp(NPC.rotation, rot, 0.1f);
|
||||
|
||||
// Stretch rapidly if about to jump or teleport.
|
||||
if (NPC.aiAction == 1)
|
||||
stretch += MathHelper.Lerp(0f, 0.32f, (float)Math.Sin(Main.GlobalTimeWrappedHourly * 10f) / 2f + 0.5f);
|
||||
stretch += MathHelper.Lerp(-0.24f, 0.24f, (float)Math.Sin(Main.GlobalTimeWrappedHourly * 10f) / 2f + 0.5f) * (vel / 30);
|
||||
|
||||
// Stretch while idle.
|
||||
else
|
||||
stretch += MathHelper.Lerp(0f, 0.16f, (float)Math.Sin(Main.GlobalTimeWrappedHourly * 2f) / 2f + 0.5f);
|
||||
stretch += MathHelper.Lerp(-0.1f, 0.1f, (float)Math.Sin(Main.GlobalTimeWrappedHourly * 2f) / 2f + 0.5f) * (vel / 30);
|
||||
|
||||
if (stretch > 0.5f)
|
||||
stretch = 0.5f;
|
||||
@@ -667,13 +670,21 @@ namespace CalamityMod.NPCs.SlimeGod
|
||||
if (wingFrameDrawn >= TotalWingFrames)
|
||||
wingFrameDrawn = 0;
|
||||
}
|
||||
Rectangle wingFrame = new Rectangle(0, wingTexture.Height / TotalWingFrames * wingFrameDrawn, wingTexture.Width, wingTexture.Height / TotalWingFrames);
|
||||
Vector2 wingOrigin = new Vector2(wingTexture.Width, wingTexture.Height / TotalWingFrames) * 0.5f;
|
||||
Rectangle wingFrame1 = new Rectangle(0, wingTexture.Height / TotalWingFrames * wingFrameDrawn, wingTexture.Width / 2, wingTexture.Height / TotalWingFrames);
|
||||
Rectangle wingFrame2 = new Rectangle(wingTexture.Width / 2, wingTexture.Height / TotalWingFrames * wingFrameDrawn, wingTexture.Width / 2, wingTexture.Height / TotalWingFrames);
|
||||
|
||||
Vector2 wingOrigin1 = new Vector2(wingTexture.Width, wingTexture.Height / TotalWingFrames) * 0.5f;
|
||||
Vector2 wingOrigin2 = new Vector2(0, wingTexture.Height / TotalWingFrames) * 0.5f;
|
||||
|
||||
Vector2 wingOffset1 = Vector2.Zero;
|
||||
Vector2 wingOffset2 = Vector2.Zero;
|
||||
|
||||
// Draw the wings.
|
||||
spriteBatch.Draw(wingTexture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY), wingFrame, drawColorAlpha, NPC.rotation, wingOrigin, scaleStretch, spriteEffects, 0f);
|
||||
spriteBatch.Draw(wingTexture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY) + wingOffset1, wingFrame1, drawColorAlpha, 0f, wingOrigin1, 1f, spriteEffects, 0f);
|
||||
spriteBatch.Draw(wingTexture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY) + wingOffset2, wingFrame2, drawColorAlpha, 0f, wingOrigin2, 1f, spriteEffects, 0f);
|
||||
|
||||
spriteBatch.Draw(texture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY), NPC.frame, drawColorAlpha, NPC.rotation, NPC.frame.Size() * 0.5f, scaleStretch, spriteEffects, 0f);
|
||||
// Draw the actual paladin.
|
||||
spriteBatch.Draw(texture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY) + new Vector2(0, 16), NPC.frame, drawColorAlpha, NPC.rotation, NPC.frame.Size() * 0.5f + new Vector2(0, 8), scaleStretch, spriteEffects, 0f);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -121,6 +121,57 @@ namespace CalamityMod.NPCs.SlimeGod
|
||||
});
|
||||
}
|
||||
|
||||
public static bool ShouldDespawn(NPC npc)
|
||||
{
|
||||
return (!EbonianPaladinAlive(npc) && !CrimulanPaladinAlive(npc)) || npc.Calamity().newAI[3] == 1f || npc.ai[3] == 1f;
|
||||
}
|
||||
|
||||
public static bool EbonianPaladinAlive(NPC npc)
|
||||
{
|
||||
if (CalamityGlobalNPC.slimeGodPurple != -1)
|
||||
{
|
||||
if (Main.npc[CalamityGlobalNPC.slimeGodPurple].active)
|
||||
{
|
||||
if ((npc.ModNPC as SlimeGodCore).buffedSlime == 1)
|
||||
Main.npc[CalamityGlobalNPC.slimeGodPurple].localAI[1] = 1f;
|
||||
else
|
||||
Main.npc[CalamityGlobalNPC.slimeGodPurple].localAI[1] = 0f;
|
||||
|
||||
npc.Calamity().newAI[0] = Main.npc[CalamityGlobalNPC.slimeGodPurple].Center.X;
|
||||
npc.Calamity().newAI[1] = Main.npc[CalamityGlobalNPC.slimeGodPurple].Center.Y;
|
||||
|
||||
// Despawn check
|
||||
npc.Calamity().newAI[3] = Main.npc[CalamityGlobalNPC.slimeGodPurple].ai[0] == 4f ? 1f : 0f;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool CrimulanPaladinAlive(NPC npc)
|
||||
{
|
||||
if (CalamityGlobalNPC.slimeGodRed != -1)
|
||||
{
|
||||
if (Main.npc[CalamityGlobalNPC.slimeGodRed].active)
|
||||
{
|
||||
if ((npc.ModNPC as SlimeGodCore).buffedSlime == 2)
|
||||
Main.npc[CalamityGlobalNPC.slimeGodRed].localAI[1] = 1f;
|
||||
else
|
||||
Main.npc[CalamityGlobalNPC.slimeGodRed].localAI[1] = 0f;
|
||||
|
||||
npc.ai[1] = Main.npc[CalamityGlobalNPC.slimeGodRed].Center.X;
|
||||
npc.ai[2] = Main.npc[CalamityGlobalNPC.slimeGodRed].Center.Y;
|
||||
|
||||
// Despawn check
|
||||
npc.Calamity().newAI[3] = Main.npc[CalamityGlobalNPC.slimeGodRed].ai[0] == 3f ? 1f : 0f;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void SendExtraAI(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(slimesSpawned);
|
||||
@@ -207,7 +258,7 @@ namespace CalamityMod.NPCs.SlimeGod
|
||||
|
||||
NPC.ai[1] = Main.npc[CalamityGlobalNPC.slimeGodRed].Center.X;
|
||||
NPC.ai[2] = Main.npc[CalamityGlobalNPC.slimeGodRed].Center.Y;
|
||||
|
||||
|
||||
// Despawn check
|
||||
calamityGlobalNPC.newAI[3] = Main.npc[CalamityGlobalNPC.slimeGodRed].ai[0] == 3f ? 1f : 0f;
|
||||
|
||||
@@ -219,7 +270,7 @@ namespace CalamityMod.NPCs.SlimeGod
|
||||
bool phase2 = !purpleSlimeAlive || !redSlimeAlive;
|
||||
|
||||
// Vanish phase
|
||||
if ((!purpleSlimeAlive && !redSlimeAlive) || calamityGlobalNPC.newAI[3] == 1f || NPC.ai[3] == 1f)
|
||||
if (ShouldDespawn(NPC))
|
||||
{
|
||||
// Avoid cheap bullshit
|
||||
NPC.damage = 0;
|
||||
@@ -594,12 +645,27 @@ namespace CalamityMod.NPCs.SlimeGod
|
||||
|
||||
public override Color? GetAlpha(Color drawColor)
|
||||
{
|
||||
Color newColor = buffedSlime == 0 ? new Color(255, 255, 255, drawColor.A) : drawColor;
|
||||
Color newColor = new Color(255, 255, 255, 255);
|
||||
return newColor * NPC.Opacity;
|
||||
}
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
|
||||
{
|
||||
float sc = 1f;
|
||||
if (!ShouldDespawn(NPC))
|
||||
{
|
||||
if (buffedSlime != 0f)
|
||||
{
|
||||
NPC.scale = MathHelper.Lerp(NPC.scale, 0f, 0.2f);
|
||||
NPC.Opacity = MathHelper.Lerp(NPC.Opacity, 0.7f, 0.4f);
|
||||
}
|
||||
else
|
||||
{
|
||||
NPC.scale = MathHelper.Lerp(NPC.scale, sc, 0.2f);
|
||||
NPC.Opacity = MathHelper.Lerp(NPC.Opacity, 1f, 0.4f);
|
||||
}
|
||||
}
|
||||
|
||||
SpriteEffects spriteEffects = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
|
||||
Color drawColorAlpha = NPC.GetAlpha(drawColor);
|
||||
Vector2 origin = NPC.frame.Size() * 0.5f;
|
||||
@@ -654,7 +720,7 @@ namespace CalamityMod.NPCs.SlimeGod
|
||||
spriteBatch.Draw(texture, drawPosition, NPC.frame, drawColorAlpha, NPC.rotation, origin, NPC.scale, spriteEffects, 0f);
|
||||
|
||||
// Draw the eye texture afterimages
|
||||
spriteBatch.Draw(eyeTexture, drawPosition, eyeFrame, drawColorAlpha, NPC.rotation, eyeOrigin, NPC.scale, spriteEffects, 0f);
|
||||
spriteBatch.Draw(eyeTexture, drawPosition, eyeFrame, drawColorAlpha, 0f, eyeOrigin, 1f, spriteEffects, 0f);
|
||||
|
||||
// Draw the overlay texture afterimages
|
||||
spriteBatch.Draw(overlayTexture, drawPosition, NPC.frame, drawColorAlpha, NPC.rotation, origin, NPC.scale, spriteEffects, 0f);
|
||||
@@ -670,7 +736,7 @@ namespace CalamityMod.NPCs.SlimeGod
|
||||
spriteBatch.Draw(texture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY), NPC.frame, drawColorAlpha, NPC.rotation, origin, NPC.scale, spriteEffects, 0f);
|
||||
|
||||
// Draw the eye
|
||||
spriteBatch.Draw(eyeTexture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY), eyeFrame, drawColorAlpha, NPC.rotation, eyeOrigin, NPC.scale, spriteEffects, 0f);
|
||||
spriteBatch.Draw(eyeTexture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY), eyeFrame, drawColorAlpha, 0f, eyeOrigin, 1f, spriteEffects, 0f);
|
||||
|
||||
// Draw the overlay
|
||||
spriteBatch.Draw(overlayTexture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY), NPC.frame, drawColorAlpha, NPC.rotation, origin, NPC.scale, spriteEffects, 0f);
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace CalamityMod.NPCs.SlimeGod
|
||||
NPC.defense = 10;
|
||||
NPC.knockBackResist = 0f;
|
||||
NPC.value = Item.buyPrice(0, 1, 0, 0);
|
||||
NPC.Opacity = 0.8f;
|
||||
NPC.Opacity = 1f;
|
||||
NPC.lavaImmune = false;
|
||||
NPC.noGravity = false;
|
||||
NPC.noTileCollide = false;
|
||||
@@ -802,7 +802,7 @@ namespace CalamityMod.NPCs.SlimeGod
|
||||
Vector2 scaleStretch = new Vector2(1f - stretch, 1f + stretch) * NPC.scale;
|
||||
float yOffset = stretch * 0.5f * NPC.height;
|
||||
|
||||
spriteBatch.Draw(texture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY - yOffset), NPC.frame, drawColorAlpha, NPC.rotation, NPC.frame.Size() * 0.5f, scaleStretch, spriteEffects, 0f);
|
||||
spriteBatch.Draw(texture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY - yOffset), NPC.frame, drawColorAlpha, NPC.rotation + CrimulanPaladin.SlimeRotationFactor(NPC), NPC.frame.Size() * 0.5f, scaleStretch, spriteEffects, 0f);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace CalamityMod.NPCs.SlimeGod
|
||||
AIType = -1;
|
||||
NPC.knockBackResist = 0f;
|
||||
NPC.value = Item.buyPrice(0, 1, 0, 0);
|
||||
NPC.Opacity = 0.8f;
|
||||
NPC.Opacity = 1f;
|
||||
NPC.lavaImmune = false;
|
||||
NPC.noGravity = false;
|
||||
NPC.noTileCollide = false;
|
||||
@@ -846,7 +846,7 @@ namespace CalamityMod.NPCs.SlimeGod
|
||||
Vector2 scaleStretch = new Vector2(1f - stretch, 1f + stretch) * NPC.scale;
|
||||
float yOffset = stretch * 0.5f * NPC.height;
|
||||
|
||||
spriteBatch.Draw(texture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY - yOffset), NPC.frame, drawColorAlpha, NPC.rotation, NPC.frame.Size() * 0.5f, scaleStretch, spriteEffects, 0f);
|
||||
spriteBatch.Draw(texture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY - yOffset), NPC.frame, drawColorAlpha, NPC.rotation + CrimulanPaladin.SlimeRotationFactor(NPC), NPC.frame.Size() * 0.5f, scaleStretch, spriteEffects, 0f);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user