Improving the battle, fixing bugs

This commit is contained in:
Vladislav Khorev committed 2026-07-12 18:35:46 +03:00
1 parent 92929118d5
commit 33c2b313af
4 files changed
+36 -1

No files matched your search

+12
View File
@@ -1661,6 +1661,8 @@ namespace ZL
return;
}
int lastPlayerAttackTarget = player->state.attackTargetIndex;
player->state.attackTargetIndex = CharacterState::kNoTarget;
// Unproject click to ground plane (y=0) for Viola's walk target
@@ -1723,6 +1725,7 @@ namespace ZL
}
else {
//std::cout << "Raycast npc step 1" << std::endl;
// Check if we clicked on an NPC
Character* clickedNpc = raycastNpcs(camPos, rayDir);
if (clickedNpc && player) {
@@ -1735,11 +1738,20 @@ namespace ZL
}
}
if (npcIndex != -1) {
//std::cout << "Raycast npc step 2" << std::endl;
state.targetInteractiveObjectIndex = -1;
state.targetTeleportZoneIndex = -1;
if (clickedNpc->state.canAttack) {
//std::cout << "Raycast npc step 3" << std::endl;
//std::cout << "player->state.attackTargetIndex=" << player->state.attackTargetIndex << std::endl;
//std::cout << "npcIndex=" << npcIndex << std::endl;
// Hostile NPC: combat logic walks the player in via attackTargetIndex.
if (lastPlayerAttackTarget == npcIndex)
{
//std::cout << "Raycast npc step 4" << std::endl;
player->tryAttackCombo();
}
player->state.attackTargetIndex = npcIndex;
state.targetInteractNpcIndex = -1;