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

Method spendTU

game/state/battle/battleunit.cpp:1298–1319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1296}
1297
1298bool BattleUnit::spendTU(GameState &state, int cost, bool ignoreKneelReserve,
1299 bool ignoreShootReserve, bool allowInterrupt)
1300{
1301 if (state.current_battle->mode == Battle::Mode::RealTime || !isConscious() || cost == 0)
1302 {
1303 return true;
1304 }
1305 if (!canAfford(state, cost, ignoreKneelReserve, ignoreShootReserve))
1306 {
1307 return false;
1308 }
1309 agent->modified_stats.time_units -= cost;
1310 state.current_battle->notifyAction(position, {&state, id});
1311 // If doing any action other than moving that triggers reaction, we give interrupt chance here
1312 // If moving we do not give it here, and instead give interrupt chance when changing tiles
1313 if (allowInterrupt)
1314 {
1315 state.current_battle->giveInterruptChanceToUnits(state, {&state, id},
1316 agent->getReactionValue());
1317 }
1318 return true;
1319}
1320
1321void BattleUnit::spendRemainingTU(GameState &state, bool allowInterrupt)
1322{

Callers 3

spendAgentTUsMethod · 0.80
tryPlaceItemMethod · 0.80
orderDropMethod · 0.80

Calls 3

notifyActionMethod · 0.80
getReactionValueMethod · 0.80

Tested by

no test coverage detected