animated DS bestiaries since resprite wont be in brainstorm

This commit is contained in:
GinYuH committed 2026-01-04 22:37:45 -08:00
1 parent c8a6b655e2
commit 40f058771d
5 files changed
+74 -12

No files matched your search

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

+42 -7
View File
@@ -3,8 +3,10 @@ using System.IO;
using CalamityMod.Events;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Audio;
using Terraria.GameContent;
using Terraria.GameContent.Bestiary;
using Terraria.ID;
using Terraria.ModLoader;
@@ -36,14 +38,13 @@ namespace CalamityMod.NPCs.DesertScourge
NPCID.Sets.BossBestiaryPriority.Add(Type);
NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers()
{
Scale = 0.6f,
PortraitScale = 0.6f,
CustomTexturePath = "CalamityMod/ExtraTextures/Bestiary/DesertNuisance_Bestiary",
PortraitPositionXOverride = 40,
PortraitPositionYOverride = 40
Scale = 0.65f,
PortraitScale = 0.7f,
PortraitPositionXOverride = 0,
PortraitPositionYOverride = 0
};
value.Position.X += 45;
value.Position.Y += 30;
value.Position.X += 0;
value.Position.Y -= 20;
NPCID.Sets.NPCBestiaryDrawOffset[Type] = value;
NPCID.Sets.MPAllowedEnemies[Type] = true;
NPCID.Sets.CantTakeLunchMoney[Type] = true;
@@ -574,6 +575,40 @@ namespace CalamityMod.NPCs.DesertScourge
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
{
if (NPC.IsABestiaryIconDummy)
{
Texture2D texture = TextureAssets.Npc[NPC.type].Value;
NPC.Opacity = 1f;
// Reimplementation of CalamityUtils.DrawAnimatedBestiaryWorm but tweaked due to this entity' animations
NPC.frame = texture.Frame();
// Buffers the segment position and rotations
float offset = -0.2f;
float startX = 60;
float startY = 70;
int segmentSpacing = 50;
int animationSpeed = 8;
float wormTimer = NPC.Calamity().bestiaryWormTimer;
int segCount = 3;
// Draw the body segments
for (int i = segCount; i > 0; i--)
{
// The first segment is slightly closer to keep up with the head
float bodyOffset = i * segmentSpacing - segmentSpacing * 0.5f;
Texture2D toUse = i == 1 ? TextureAssets.Npc[ModContent.NPCType<DesertNuisanceBody>()].Value : DesertNuisanceBody.BodyTexture2.Value;
int frameCount = i == 1 ? 7 : 1;
spriteBatch.Draw(toUse, NPC.position + new Vector2(startX + bodyOffset, MathF.Sin((wormTimer + offset * i) * animationSpeed) * 2 + startY), toUse.Frame(1, frameCount, 0, 0), NPC.GetAlpha(drawColor), NPC.rotation - MathHelper.PiOver2 - MathF.Cos((wormTimer + offset * i) * animationSpeed) * MathHelper.PiOver4 * 0.075f, new Vector2(toUse.Width / 2, toUse.Height / (frameCount * 2)), NPC.scale, SpriteEffects.None, 0f);
}
// Draw the head
spriteBatch.Draw(texture, NPC.position + new Vector2(startX + 18, MathF.Sin(wormTimer * animationSpeed) * 2 + startY), texture.Frame(1, 7, 0, 0), NPC.GetAlpha(drawColor), NPC.rotation - MathHelper.PiOver2 - MathF.Cos(wormTimer * animationSpeed) * MathHelper.PiOver4 * 0.075f, new Vector2(texture.Width * 0.5f, texture.Height / 7), NPC.scale, SpriteEffects.None, 0f);
return false;
}
return true;
}
public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment)
{
NPC.lifeMax = (int)(NPC.lifeMax * 0.7f * balance);
+32 -5
View File
@@ -16,12 +16,14 @@ using CalamityMod.Items.Weapons.Ranged;
using CalamityMod.Items.Weapons.Rogue;
using CalamityMod.Items.Weapons.Summon;
using CalamityMod.NPCs.AquaticScourge;
using CalamityMod.NPCs.ExoMechs.Thanatos;
using CalamityMod.Projectiles.Boss;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Audio;
using Terraria.GameContent;
using Terraria.GameContent.Bestiary;
using Terraria.GameContent.ItemDropRules;
using Terraria.ID;
@@ -72,12 +74,11 @@ namespace CalamityMod.NPCs.DesertScourge
{
Scale = 0.65f,
PortraitScale = 0.7f,
CustomTexturePath = "CalamityMod/ExtraTextures/Bestiary/DesertScourge_Bestiary",
PortraitPositionXOverride = 40,
PortraitPositionYOverride = 40
PortraitPositionXOverride = 0,
PortraitPositionYOverride = 0
};
value.Position.X += 65;
value.Position.Y += 35;
value.Position.X += 20;
value.Position.Y -= 15;
NPCID.Sets.NPCBestiaryDrawOffset[Type] = value;
NPCID.Sets.MPAllowedEnemies[Type] = true;
}
@@ -1033,8 +1034,34 @@ namespace CalamityMod.NPCs.DesertScourge
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
{
if (NPC.IsABestiaryIconDummy)
{
Texture2D texture = TextureAssets.Npc[NPC.type].Value;
NPC.Opacity = 1f;
// Reimplementation of CalamityUtils.DrawAnimatedBestiaryWorm but tweaked due to this entity' animations
NPC.frame = texture.Frame();
// Buffers the segment position and rotations
float offset = -0.2f;
float startX = 60;
float startY = 70;
int segmentSpacing = 50;
int animationSpeed = 4;
float wormTimer = NPC.Calamity().bestiaryWormTimer;
int segCount = 3;
// Draw the body segments
for (int i = segCount; i > 0; i--)
{
// The first segment is slightly closer to keep up with the head
float bodyOffset = i * segmentSpacing - segmentSpacing * 0.5f;
Texture2D toUse = i == 1 ? TextureAssets.Npc[ModContent.NPCType<DesertScourgeBody>()].Value : DesertScourgeBody.BodyTexture2.Value;
int frameCount = i == 1 ? 7 : 1;
spriteBatch.Draw(toUse, NPC.position + new Vector2(startX + bodyOffset, MathF.Sin((wormTimer + offset * i) * animationSpeed) * 2 + startY), toUse.Frame(1, frameCount, 0, 0), NPC.GetAlpha(drawColor), NPC.rotation - MathHelper.PiOver2 - MathF.Cos((wormTimer + offset * i) * animationSpeed) * MathHelper.PiOver4 * 0.075f, new Vector2(toUse.Width / 2, toUse.Height / (frameCount * 2)), NPC.scale, SpriteEffects.None, 0f);
}
// Draw the head
spriteBatch.Draw(texture, NPC.position + new Vector2(startX + 18, MathF.Sin(wormTimer * animationSpeed) * 2 + startY), texture.Frame(1, 7, 0, 0), NPC.GetAlpha(drawColor), NPC.rotation - MathHelper.PiOver2 - MathF.Cos(wormTimer * animationSpeed) * MathHelper.PiOver4 * 0.075f, new Vector2(texture.Width * 0.5f, texture.Height / 7), NPC.scale, SpriteEffects.None, 0f);
return false;
}
return true;
}