* Calculates the effects of the explosion. */
| 203 | * Calculates the effects of the explosion. |
| 204 | */ |
| 205 | void ExplosionBState::explode() |
| 206 | { |
| 207 | bool terrainExplosion = false; |
| 208 | SavedBattleGame *save = _parent->getSave(); |
| 209 | // last minute adjustment: determine if we actually |
| 210 | if (_parent->getCurrentAction()->type == BA_HIT || _parent->getCurrentAction()->type == BA_STUN) |
| 211 | { |
| 212 | save->getBattleGame()->getCurrentAction()->type = BA_NONE; |
| 213 | BattleUnit *targetUnit = save->getTile(_center / Position(16, 16, 24))->getUnit(); |
| 214 | if (_unit && !_unit->isOut()) |
| 215 | { |
| 216 | _unit->aim(false); |
| 217 | _unit->setCache(0); |
| 218 | } |
| 219 | if (!RNG::percent(_unit->getFiringAccuracy(BA_HIT, _item))) |
| 220 | { |
| 221 | _parent->getMap()->cacheUnits(); |
| 222 | _parent->popState(); |
| 223 | return; |
| 224 | } |
| 225 | else if (targetUnit && targetUnit->getOriginalFaction() == FACTION_HOSTILE && |
| 226 | _unit->getOriginalFaction() == FACTION_PLAYER) |
| 227 | { |
| 228 | _unit->addMeleeExp(); |
| 229 | } |
| 230 | if (_item->getRules()->getMeleeHitSound() != -1) |
| 231 | { |
| 232 | _parent->getResourcePack()->getSound("BATTLE.CAT", _item->getRules()->getMeleeHitSound())->play(); |
| 233 | } |
| 234 | } |
| 235 | // after the animation is done, the real explosion/hit takes place |
| 236 | if (_item) |
| 237 | { |
| 238 | if (!_unit && _item->getPreviousOwner()) |
| 239 | { |
| 240 | _unit = _item->getPreviousOwner(); |
| 241 | } |
| 242 | |
| 243 | if (_areaOfEffect) |
| 244 | { |
| 245 | save->getTileEngine()->explode(_center, _power, _item->getRules()->getDamageType(), _item->getRules()->getExplosionRadius(), _unit); |
| 246 | } |
| 247 | else |
| 248 | { |
| 249 | ItemDamageType type = _item->getRules()->getDamageType(); |
| 250 | if (_pistolWhip) |
| 251 | { |
| 252 | type = DT_STUN; |
| 253 | } |
| 254 | BattleUnit *victim = save->getTileEngine()->hit(_center, _power, type, _unit); |
| 255 | // check if this unit turns others into zombies |
| 256 | if (!_item->getRules()->getZombieUnit().empty() |
| 257 | && victim |
| 258 | && victim->getArmor()->getSize() == 1 |
| 259 | && victim->getSpawnUnit().empty() |
| 260 | && victim->getOriginalFaction() != FACTION_HOSTILE) |
| 261 | { |
| 262 | // converts the victim to a zombie on death |
nothing calls this directly
no test coverage detected