Fixing some stuff related to attacks
This commit is contained in:
1 parent
9d03b52c2a
commit
92929118d5
7 files changed
+32
-7
No files matched your search
+18
-1
@@ -744,8 +744,25 @@ namespace ZL
|
||||
// Wire HP-change callbacks so all player instances update the health bar HUD.
|
||||
for (auto& [name, loc] : gameState.locations) {
|
||||
if (loc->player) {
|
||||
loc->player->state.onHpChanged = [this](float hp, float maxHp) {
|
||||
loc->player->state.onHpChanged = [this, loc](float hp, float maxHp, int attackerIndex) {
|
||||
menuManager.updateHealthBar(hp, maxHp);
|
||||
|
||||
if (attackerIndex != CharacterState::kNoTarget) {
|
||||
//Someone attacked, cancel dialogue and agro the player
|
||||
|
||||
if (loc->dialogueSystem.isDialogueActive()) {
|
||||
loc->dialogueSystem.stopDialogue();
|
||||
}
|
||||
|
||||
if ((loc->player->state.attackTargetIndex == CharacterState::kNoTarget ||
|
||||
((loc->player->state.attackTargetIndex >= 0) &&
|
||||
(loc->npcs[loc->player->state.attackTargetIndex]->state.hp <= 0)))
|
||||
&&
|
||||
loc->player->isMoving() == false) {
|
||||
loc->player->state.attackTargetIndex = attackerIndex;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user