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

@ -2652,7 +2652,8 @@ void GameHandler::handleUpdateObject(network::Packet& packet) {
auto unit = std::static_pointer_cast<Unit>(entity);
for (const auto& [key, val] : block.fields) {
switch (key) {
case 24:
case 24: {
uint32_t oldHealth = unit->getHealth();
unit->setHealth(val);
if (val == 0) {
if (block.guid == autoAttackTarget) {
@ -2662,8 +2663,14 @@ void GameHandler::handleUpdateObject(network::Packet& packet) {
if (entity->getType() == ObjectType::UNIT && npcDeathCallback_) {
npcDeathCallback_(block.guid);
}
} else if (oldHealth == 0 && val > 0) {
// Respawn: health went from 0 to >0, reset animation
if (entity->getType() == ObjectType::UNIT && npcRespawnCallback_) {
npcRespawnCallback_(block.guid);
}
}
break;
}
case 25: unit->setPower(val); break;
case 32: unit->setMaxHealth(val); break;
case 33: unit->setMaxPower(val); break;

View file

@ -736,12 +736,34 @@ void NpcManager::initialize(pipeline::AssetManager* am,
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); // Faction (parent)
break;
}
}
// Second pass: classify each faction template
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);
// Hostile only if creature's enemy groups overlap player's faction/friend groups
// Check group-level hostility
bool hostile = (enemyGroup & playerFriendGroup) != 0;
// Check if creature is a Monster type (factionGroup bit 4)
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;
}
}
}
factionHostile[id] = hostile;
}
LOG_INFO("NpcManager: loaded ", dbc->getRecordCount(),