MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / getActionTUs

Method getActionTUs

src/Savegame/BattleUnit.cpp:1103–1149  ·  view source on GitHub ↗

* Get the number of time units a certain action takes. * @param actionType * @param item * @return TUs */

Source from the content-addressed store, hash-verified

1101 * @return TUs
1102 */
1103int BattleUnit::getActionTUs(BattleActionType actionType, BattleItem *item)
1104{
1105 if (item == 0)
1106 {
1107 return 0;
1108 }
1109
1110 int cost = 0;
1111 switch (actionType)
1112 {
1113 case BA_PRIME:
1114 cost = 50; // maybe this should go in the ruleset
1115 break;
1116 case BA_THROW:
1117 cost = 25;
1118 break;
1119 case BA_AUTOSHOT:
1120 cost = item->getRules()->getTUAuto();
1121 break;
1122 case BA_SNAPSHOT:
1123 cost = item->getRules()->getTUSnap();
1124 break;
1125 case BA_STUN:
1126 case BA_HIT:
1127 cost = item->getRules()->getTUMelee();
1128 break;
1129 case BA_LAUNCH:
1130 case BA_AIMEDSHOT:
1131 cost = item->getRules()->getTUAimed();
1132 break;
1133 case BA_USE:
1134 case BA_MINDCONTROL:
1135 case BA_PANIC:
1136 cost = item->getRules()->getTUUse();
1137 break;
1138 default:
1139 cost = 0;
1140 }
1141
1142 // if it's a percentage, apply it to unit TUs
1143 if (!item->getRules()->getFlatRate() || actionType == BA_THROW || actionType == BA_PRIME)
1144 {
1145 cost = (int)floor(getStats()->tu * cost / 100.0f);
1146 }
1147
1148 return cost;
1149}
1150
1151
1152/**

Callers 15

openDoorMethod · 0.80
addItemMethod · 0.80
thinkMethod · 0.80
setupPatrolMethod · 0.80
meleeActionMethod · 0.80
wayPointActionMethod · 0.80
selectFireMethodMethod · 0.80
grenadeActionMethod · 0.80
initMethod · 0.80
postPathProceduresMethod · 0.80
checkReservedTUMethod · 0.80
handlePanickingUnitMethod · 0.80

Calls 7

getTUAutoMethod · 0.80
getTUSnapMethod · 0.80
getTUMeleeMethod · 0.80
getTUAimedMethod · 0.80
getTUUseMethod · 0.80
getFlatRateMethod · 0.80
getRulesMethod · 0.45

Tested by

no test coverage detected