| 177 | } |
| 178 | |
| 179 | bool BattleMapPart::applyDamage(GameState &state, int power, StateRef<DamageType> damageType) |
| 180 | { |
| 181 | if (!this->tileObject) |
| 182 | { |
| 183 | // It's possible multiple projectiles hit the same tile in the same |
| 184 | // tick, so if the object has already been destroyed just NOP this. |
| 185 | // The projectile will still 'hit' this tile though. |
| 186 | return false; |
| 187 | } |
| 188 | if (this->falling) |
| 189 | { |
| 190 | // Already falling, just continue |
| 191 | return false; |
| 192 | } |
| 193 | |
| 194 | int damage; |
| 195 | if (damageType->explosive) |
| 196 | { |
| 197 | // Apparently Apoc uses 100% explosive damage instead of 50% like in UFO1&2 |
| 198 | damage = damageType->dealDamage(power, type->damageModifier); |
| 199 | } |
| 200 | else |
| 201 | { |
| 202 | // Apparently Apoc uses 50-150 damage model for shots vs terrain, |
| 203 | // unlike UFO1&2, which used 25-75 |
| 204 | damage = randDamage050150(state.rng, damageType->dealDamage(power, type->damageModifier)); |
| 205 | } |
| 206 | if (damage <= type->constitution) |
| 207 | { |
| 208 | return false; |
| 209 | } |
| 210 | |
| 211 | // If we came this far, map part has been damaged and must cease to be |
| 212 | die(state, damageType->explosive); |
| 213 | return false; |
| 214 | } |
| 215 | |
| 216 | bool BattleMapPart::handleCollision(GameState &state, Collision &c) |
| 217 | { |
no test coverage detected