Skip to content

Commit

Permalink
Removed human enemy dead body lookup.
Browse files Browse the repository at this point in the history
Don't think overriding is really a thing in the original game and it adds complexity to support it, so not going to.
  • Loading branch information
afritz1 committed Dec 30, 2024
1 parent 70cfb8a commit a84e378
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 24 deletions.
26 changes: 6 additions & 20 deletions OpenTESArena/src/Assets/ArenaAnimUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,23 +511,12 @@ namespace ArenaAnimUtils
return true;
}

bool tryAddDynamicEntityHumanDeathAnimState(const INFFile &inf, TextureManager &textureManager, EntityAnimationDefinition *outAnimDef)
bool tryAddDynamicEntityHumanDeathAnimState(TextureManager &textureManager, EntityAnimationDefinition *outAnimDef)
{
constexpr bool isMirrored = false;

// Humans use a single dead body image.
const std::string animName = [&inf]()
{
constexpr ArenaTypes::ItemIndex corpseItemIndex = 2;
const INFFlat *corpseFlat = inf.getFlatWithItemIndex(corpseItemIndex);
DebugAssertMsg(corpseFlat != nullptr, "Missing human corpse flat.");
const int corpseFlatTextureIndex = corpseFlat->textureIndex;
const BufferView<const INFFlatTexture> flatTextures = inf.getFlatTextures();
DebugAssertIndex(flatTextures, corpseFlatTextureIndex);
const INFFlatTexture &flatTextureData = flatTextures[corpseFlatTextureIndex];
return String::toUppercase(flatTextureData.filename);
}();

const std::string &animName = ArenaAnimUtils::HumanDeathFilename;
const std::optional<TextureFileMetadataID> metadataID = textureManager.tryGetMetadataID(animName.c_str());
if (!metadataID.has_value())
{
Expand Down Expand Up @@ -989,10 +978,8 @@ bool ArenaAnimUtils::tryMakeDynamicEntityCreatureAnims(int creatureID, const Exe
return true;
}

bool ArenaAnimUtils::tryMakeDynamicEntityHumanAnims(int charClassIndex, bool isMale,
const CharacterClassLibrary &charClassLibrary, const INFFile &inf,
const BinaryAssetLibrary &binaryAssetLibrary, TextureManager &textureManager,
EntityAnimationDefinition *outAnimDef)
bool ArenaAnimUtils::tryMakeDynamicEntityHumanAnims(int charClassIndex, bool isMale, const CharacterClassLibrary &charClassLibrary,
const BinaryAssetLibrary &binaryAssetLibrary, TextureManager &textureManager, EntityAnimationDefinition *outAnimDef)
{
// Basic states are idle and walk. Human enemies don't have look animations.
if (!ArenaAnimUtils::tryAddDynamicEntityHumanBasicAnimState(charClassIndex, isMale, EntityAnimationUtils::STATE_IDLE.c_str(),
Expand All @@ -1018,7 +1005,7 @@ bool ArenaAnimUtils::tryMakeDynamicEntityHumanAnims(int charClassIndex, bool isM
}

// Death state.
if (!ArenaAnimUtils::tryAddDynamicEntityHumanDeathAnimState(inf, textureManager, outAnimDef))
if (!ArenaAnimUtils::tryAddDynamicEntityHumanDeathAnimState(textureManager, outAnimDef))
{
DebugLogWarning("Couldn't add death anim for character class \"" + std::to_string(charClassIndex) + "\".");
return false;
Expand Down Expand Up @@ -1057,8 +1044,7 @@ bool ArenaAnimUtils::tryMakeDynamicEntityAnims(ArenaTypes::FlatIndex flatIndex,
{
DebugAssert(isMale.has_value());
const int charClassIndex = ArenaAnimUtils::getCharacterClassIndexFromItemIndex(itemIndex);
return ArenaAnimUtils::tryMakeDynamicEntityHumanAnims(charClassIndex, *isMale, charClassLibrary, inf,
binaryAssetLibrary, textureManager, outAnimDef);
return ArenaAnimUtils::tryMakeDynamicEntityHumanAnims(charClassIndex, *isMale, charClassLibrary, binaryAssetLibrary, textureManager, outAnimDef);
}
else
{
Expand Down
7 changes: 3 additions & 4 deletions OpenTESArena/src/Assets/ArenaAnimUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ namespace ArenaAnimUtils
constexpr bool HumanDeathLoop = CreatureDeathLoop;
constexpr int HumanIdleIndices[] = { 0 };
constexpr int HumanWalkIndices[] = { 0, 1, 2, 3, 4, 5 };
const std::string HumanDeathFilename = "DEADBODY.IMG";

// Animation values for citizens with .CFA files.
constexpr double CitizenIdleSecondsPerFrame = 1.0 / 4.0;
Expand Down Expand Up @@ -155,10 +156,8 @@ namespace ArenaAnimUtils
TextureManager &textureManager, EntityAnimationDefinition *outAnimDef);

// Writes out human enemy animation data to animation states.
bool tryMakeDynamicEntityHumanAnims(int charClassIndex, bool isMale,
const CharacterClassLibrary &charClassLibrary, const INFFile &inf,
const BinaryAssetLibrary &binaryAssetLibrary, TextureManager &textureManager,
EntityAnimationDefinition *outAnimDef);
bool tryMakeDynamicEntityHumanAnims(int charClassIndex, bool isMale, const CharacterClassLibrary &charClassLibrary,
const BinaryAssetLibrary &binaryAssetLibrary, TextureManager &textureManager, EntityAnimationDefinition *outAnimDef);

// Writes out dynamic entity animation data to animation states. Use this when the dynamic
// entity type (creature, human, etc.) is unknown.
Expand Down

0 comments on commit a84e378

Please sign in to comment.