Fixing minor bugs
This commit is contained in:
parent
cc2eba1352
commit
08e1174eaf
34
src/Game.cpp
34
src/Game.cpp
@ -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
|
||||||
|
|||||||
@ -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
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user