Fixing minor bugs

This commit is contained in:
Vladislav Khorev 2026-04-16 13:44:40 +03:00
parent cc2eba1352
commit 08e1174eaf
2 changed files with 20 additions and 18 deletions

View File

@ -953,32 +953,34 @@ namespace ZL
std::cout << "[CLICK] Player moving to object..." << std::endl; std::cout << "[CLICK] Player moving to object..." << std::endl;
} }
else { else {
// Check if we clicked on an NPC // Check if we clicked on an NPC
Character* clickedNpc = raycastNpcs(camPos, rayDir); Character* clickedNpc = raycastNpcs(camPos, rayDir);
if (clickedNpc && player) { if (clickedNpc && player) {
float distance = (player->position - clickedNpc->position).norm(); float distance = (player->position - clickedNpc->position).norm();
if (distance <= clickedNpc->interactionRadius) { int npcIndex = -1;
int npcIndex = -1; for (size_t i = 0; i < npcs.size(); ++i) {
for (size_t i = 0; i < npcs.size(); ++i) { if (npcs[i].get() == clickedNpc) {
if (npcs[i].get() == clickedNpc) { npcIndex = static_cast<int>(i);
npcIndex = static_cast<int>(i); break;
break;
}
} }
if (npcIndex != -1) { }
if (npcIndex != -1) {
if (distance <= clickedNpc->interactionRadius) {
std::cout << "[CLICK] *** SUCCESS: Clicked on NPC index: " << npcIndex << " ***" << std::endl; std::cout << "[CLICK] *** SUCCESS: Clicked on NPC index: " << npcIndex << " ***" << std::endl;
scriptEngine.callNpcInteractCallback(npcIndex); scriptEngine.callNpcInteractCallback(npcIndex);
}
else {
std::cout << "[CLICK] Too far from NPC (distance " << distance
<< " > " << clickedNpc->interactionRadius << ")" << std::endl;
}
if (clickedNpc->canAttack) if (clickedNpc->canAttack)
{ {
player->attackTarget = clickedNpc; player->attackTarget = clickedNpc;
}
} }
} }
else {
std::cout << "[CLICK] Too far from NPC (distance " << distance
<< " > " << clickedNpc->interactionRadius << ")" << std::endl;
}
} }
else if (rayDir.y() < -0.001f && player) { else if (rayDir.y() < -0.001f && player) {
// Otherwise, unproject click to ground plane for Viola's walk target // Otherwise, unproject click to ground plane for Viola's walk target

View File

@ -348,9 +348,9 @@ namespace ZL {
} }
try { try {
if (npcData.animationIdlePath.substr(npcData.animationIdlePath.size() - 5) == ".anim") if (npcData.animationWalkPath.substr(npcData.animationWalkPath.size() - 5) == ".anim")
{ {
npc->loadBinaryAnimation(AnimationState::WALK, npcData.animationIdlePath, zipPath); npc->loadBinaryAnimation(AnimationState::WALK, npcData.animationWalkPath, zipPath);
} }
else else
{ {