MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / startAttackPsi

Method startAttackPsi

game/state/battle/battleunit.cpp:1056–1084  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1054}
1055
1056bool 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
1086bool BattleUnit::startAttackPsiInternal(GameState &state, StateRef<BattleUnit> target,
1087 PsiStatus status, StateRef<AEquipmentType> item)

Callers 1

orderPsiAttackMethod · 0.80

Calls 4

getPsiCostFunction · 0.85
pickRandomFunction · 0.85
applyPsiAttackMethod · 0.80
playSampleMethod · 0.45

Tested by

no test coverage detected