| 3682 | } |
| 3683 | } |
| 3684 | void BattleUnit::updatePsi(GameState &state, unsigned int ticks) |
| 3685 | { |
| 3686 | bool realTime = state.current_battle->mode == Battle::Mode::RealTime; |
| 3687 | if (psiStatus != PsiStatus::NotEngaged) |
| 3688 | { |
| 3689 | auto e1 = agent->getFirstItemInSlot(EquipmentSlotType::RightHand); |
| 3690 | auto e2 = agent->getFirstItemInSlot(EquipmentSlotType::LeftHand); |
| 3691 | if (e1 && e1->type != psiItem) |
| 3692 | { |
| 3693 | e1 = nullptr; |
| 3694 | } |
| 3695 | if (e2 && e2->type != psiItem) |
| 3696 | { |
| 3697 | e2 = nullptr; |
| 3698 | } |
| 3699 | auto bender = e1 ? e1 : e2; |
| 3700 | if (!bender) |
| 3701 | { |
| 3702 | stopAttackPsi(state); |
| 3703 | } |
| 3704 | else if (realTime) |
| 3705 | { |
| 3706 | ticksAccumulatedToNextPsiCheck += ticks; |
| 3707 | while (ticksAccumulatedToNextPsiCheck >= TICKS_PER_PSI_CHECK) |
| 3708 | { |
| 3709 | ticksAccumulatedToNextPsiCheck -= TICKS_PER_PSI_CHECK; |
| 3710 | auto cost = getPsiCost(psiStatus, false); |
| 3711 | if (cost > agent->modified_stats.psi_energy) |
| 3712 | { |
| 3713 | stopAttackPsi(state); |
| 3714 | } |
| 3715 | else |
| 3716 | { |
| 3717 | agent->modified_stats.psi_energy -= cost; |
| 3718 | psiTarget->applyPsiAttack(state, *this, psiStatus, psiItem, false); |
| 3719 | } |
| 3720 | } |
| 3721 | } |
| 3722 | } |
| 3723 | } |
| 3724 | |
| 3725 | void BattleUnit::updateAI(GameState &state, unsigned int) |
| 3726 | { |
nothing calls this directly
no test coverage detected