Fixing minor bugs
This commit is contained in:
parent
cc2eba1352
commit
08e1174eaf
14
src/Game.cpp
14
src/Game.cpp
@ -953,11 +953,11 @@ namespace ZL
|
||||
std::cout << "[CLICK] Player moving to object..." << std::endl;
|
||||
}
|
||||
else {
|
||||
|
||||
// Check if we clicked on an NPC
|
||||
Character* clickedNpc = raycastNpcs(camPos, rayDir);
|
||||
if (clickedNpc && player) {
|
||||
float distance = (player->position - clickedNpc->position).norm();
|
||||
if (distance <= clickedNpc->interactionRadius) {
|
||||
int npcIndex = -1;
|
||||
for (size_t i = 0; i < npcs.size(); ++i) {
|
||||
if (npcs[i].get() == clickedNpc) {
|
||||
@ -966,19 +966,21 @@ namespace ZL
|
||||
}
|
||||
}
|
||||
if (npcIndex != -1) {
|
||||
if (distance <= clickedNpc->interactionRadius) {
|
||||
std::cout << "[CLICK] *** SUCCESS: Clicked on NPC index: " << npcIndex << " ***" << std::endl;
|
||||
scriptEngine.callNpcInteractCallback(npcIndex);
|
||||
}
|
||||
else {
|
||||
std::cout << "[CLICK] Too far from NPC (distance " << distance
|
||||
<< " > " << clickedNpc->interactionRadius << ")" << std::endl;
|
||||
}
|
||||
|
||||
if (clickedNpc->canAttack)
|
||||
{
|
||||
player->attackTarget = clickedNpc;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
std::cout << "[CLICK] Too far from NPC (distance " << distance
|
||||
<< " > " << clickedNpc->interactionRadius << ")" << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
else if (rayDir.y() < -0.001f && player) {
|
||||
// Otherwise, unproject click to ground plane for Viola's walk target
|
||||
|
||||
@ -348,9 +348,9 @@ namespace ZL {
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user