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

Method applyDamage

game/state/battle/battlemappart.cpp:179–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177}
178
179bool 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
216bool BattleMapPart::handleCollision(GameState &state, Collision &c)
217{

Callers 1

updateFallingMethod · 0.45

Calls 2

randDamage050150Function · 0.85
dealDamageMethod · 0.80

Tested by

no test coverage detected