| 1054 | } |
| 1055 | |
| 1056 | bool BattleUnit::startAttackPsi(GameState &state, StateRef<BattleUnit> target, PsiStatus status, |
| 1057 | StateRef<AEquipmentType> item) |
| 1058 | { |
| 1059 | bool realTime = state.current_battle->mode == Battle::Mode::RealTime; |
| 1060 | if (agent->modified_stats.psi_energy < getPsiCost(status)) |
| 1061 | { |
| 1062 | return false; |
| 1063 | } |
| 1064 | bool success = startAttackPsiInternal(state, target, status, item); |
| 1065 | agent->modified_stats.psi_energy -= getPsiCost(status); |
| 1066 | if (success) |
| 1067 | { |
| 1068 | fw().soundBackend->playSample(pickRandom(state.rng, *psiSuccessSounds), position); |
| 1069 | if (!realTime) |
| 1070 | { |
| 1071 | psiTarget->applyPsiAttack(state, *this, psiStatus, psiItem, false); |
| 1072 | if (psiStatus != PsiStatus::Control) |
| 1073 | { |
| 1074 | stopAttackPsi(state); |
| 1075 | } |
| 1076 | } |
| 1077 | return true; |
| 1078 | } |
| 1079 | else |
| 1080 | { |
| 1081 | fw().soundBackend->playSample(pickRandom(state.rng, *psiFailSounds), position); |
| 1082 | return false; |
| 1083 | } |
| 1084 | } |
| 1085 | |
| 1086 | bool BattleUnit::startAttackPsiInternal(GameState &state, StateRef<BattleUnit> target, |
| 1087 | PsiStatus status, StateRef<AEquipmentType> item) |
no test coverage detected