Fix respawned corpse movement, faction hostility, and add WoW-canonical mob level colors

Reset NPC animation to idle when health goes from 0 to >0 (respawn), prevent
dead NPCs from being moved by server movement packets. Fix faction hostility
to check factionGroup Monster bit and individual enemy arrays, not just
enemyGroup. Add level-based mob coloring: grey (no XP), green (easy), yellow
(even), orange (hard), red (very hard) for target frame and selection circle.
This commit is contained in:
Kelsi 2026-02-06 16:47:07 -08:00
parent 2aa8187562
commit 81166346ef
7 changed files with 127 additions and 9 deletions

View file

@ -638,11 +638,33 @@ void Application::setupUICallbacks() {
break;
}
}
// Find player's parent faction ID for individual enemy checks
uint32_t playerFactionId = 0;
for (uint32_t i = 0; i < dbc->getRecordCount(); i++) {
if (dbc->getUInt32(i, 0) == 1) {
playerFactionId = dbc->getUInt32(i, 1);
break;
}
}
std::unordered_map<uint32_t, bool> factionMap;
for (uint32_t i = 0; i < dbc->getRecordCount(); i++) {
uint32_t id = dbc->getUInt32(i, 0);
uint32_t factionGroup = dbc->getUInt32(i, 3);
uint32_t enemyGroup = dbc->getUInt32(i, 5);
bool hostile = (enemyGroup & playerFriendGroup) != 0;
// Monster factionGroup bit (4) = hostile to players
if (!hostile && (factionGroup & 4) != 0) {
hostile = true;
}
// Check individual enemy faction IDs (fields 6-9)
if (!hostile && playerFactionId > 0) {
for (int e = 6; e <= 9; e++) {
if (dbc->getUInt32(i, e) == playerFactionId) {
hostile = true;
break;
}
}
}
factionMap[id] = hostile;
}
gameHandler->setFactionHostileMap(std::move(factionMap));
@ -679,6 +701,14 @@ void Application::setupUICallbacks() {
}
});
// NPC respawn callback (online mode) - reset to idle animation
gameHandler->setNpcRespawnCallback([this](uint64_t guid) {
auto it = creatureInstances_.find(guid);
if (it != creatureInstances_.end() && renderer && renderer->getCharacterRenderer()) {
renderer->getCharacterRenderer()->playAnimation(it->second, 0, true); // Idle
}
});
// NPC swing callback (online mode) - play attack animation
gameHandler->setNpcSwingCallback([this](uint64_t guid) {
auto it = creatureInstances_.find(guid);
@ -1248,6 +1278,16 @@ void Application::spawnNpcs() {
cr->playAnimation(instanceId, 1, false); // animation ID 1 = Death
}
});
gameHandler->setNpcRespawnCallback([npcMgr, cr, app](uint64_t guid) {
uint32_t instanceId = npcMgr->findRenderInstanceId(guid);
if (instanceId == 0) {
auto it = app->creatureInstances_.find(guid);
if (it != app->creatureInstances_.end()) instanceId = it->second;
}
if (instanceId != 0 && cr) {
cr->playAnimation(instanceId, 0, true); // animation ID 0 = Idle
}
});
gameHandler->setNpcSwingCallback([npcMgr, cr, app](uint64_t guid) {
uint32_t instanceId = npcMgr->findRenderInstanceId(guid);
if (instanceId == 0) {