* Calculate firing accuracy. * Formula = accuracyStat * weaponAccuracy * kneelingbonus(1.15) * one-handPenalty(0.8) * woundsPenalty(% health) * critWoundsPenalty (-10%/wound) * @param actionType * @param item * @return firing Accuracy */
| 1285 | * @return firing Accuracy |
| 1286 | */ |
| 1287 | int BattleUnit::getFiringAccuracy(BattleActionType actionType, BattleItem *item) |
| 1288 | { |
| 1289 | |
| 1290 | int weaponAcc = item->getRules()->getAccuracySnap(); |
| 1291 | if (actionType == BA_AIMEDSHOT || actionType == BA_LAUNCH) |
| 1292 | weaponAcc = item->getRules()->getAccuracyAimed(); |
| 1293 | else if (actionType == BA_AUTOSHOT) |
| 1294 | weaponAcc = item->getRules()->getAccuracyAuto(); |
| 1295 | else if (actionType == BA_HIT || actionType == BA_STUN) |
| 1296 | { |
| 1297 | if (item->getRules()->isSkillApplied()) |
| 1298 | { |
| 1299 | return (getStats()->melee * item->getRules()->getAccuracyMelee() / 100) * getAccuracyModifier(item) / 100; |
| 1300 | } |
| 1301 | return item->getRules()->getAccuracyMelee() * getAccuracyModifier(item) / 100; |
| 1302 | } |
| 1303 | |
| 1304 | int result = getStats()->firing * weaponAcc / 100; |
| 1305 | |
| 1306 | if (_kneeled) |
| 1307 | { |
| 1308 | result = result * 115 / 100; |
| 1309 | } |
| 1310 | |
| 1311 | if (item->getRules()->isTwoHanded()) |
| 1312 | { |
| 1313 | // two handed weapon, means one hand should be empty |
| 1314 | if (getItem("STR_RIGHT_HAND") != 0 && getItem("STR_LEFT_HAND") != 0) |
| 1315 | { |
| 1316 | result = result * 80 / 100; |
| 1317 | } |
| 1318 | } |
| 1319 | |
| 1320 | return result * getAccuracyModifier(item) / 100; |
| 1321 | } |
| 1322 | |
| 1323 | /** |
| 1324 | * To calculate firing accuracy. Takes health and fatal wounds into account. |
no test coverage detected