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

Method applyEffect

game/state/battle/battlehazard.cpp:337–430  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

335}
336
337void BattleHazard::applyEffect(GameState &state)
338{
339 auto tile = tileObject->getOwningTile();
340
341 auto set = tile->ownedObjects;
342 for (auto &obj : set)
343 {
344 if (tile->ownedObjects.find(obj) == tile->ownedObjects.end())
345 {
346 continue;
347 }
348 if (obj->getType() == TileObject::Type::Ground ||
349 obj->getType() == TileObject::Type::Feature ||
350 obj->getType() == TileObject::Type::LeftWall ||
351 obj->getType() == TileObject::Type::RightWall)
352 {
353 auto mp = std::static_pointer_cast<TileObjectBattleMapPart>(obj)->getOwner();
354 switch (damageType->effectType)
355 {
356 case DamageType::EffectType::Fire:
357 if (mp->applyBurning(state, age))
358 {
359 // Map part burned and provided fuel for our fire, keep the fire raging
360 if (power < 0 && age > 10)
361 {
362 power = -power;
363 }
364 }
365 break;
366 default:
367 switch (damageType->blockType)
368 {
369 case DamageType::BlockType::Gas:
370 case DamageType::BlockType::Psionic:
371 break;
372 default:
373 mp->applyDamage(state, power, damageType);
374 break;
375 }
376 break;
377 }
378 }
379 else if (obj->getType() == TileObject::Type::Item)
380 {
381 if (damageType->effectType == DamageType::EffectType::Fire)
382 {
383 // It was observed that armor resists fire damage deal to it
384 // It also appears that damage is applied gradually at a rate of around 1 damage per
385 // second
386 // In tests, marsec armor (20% modifier) was hurt by fire but X-Com armor (10%
387 // modifier) was not
388 // If we apply damage once per turn, we apply 4 at once. Since we round down, 4 *
389 // 20% will be rounded to 0
390 // while it should be 1. So we add 1 here
391 auto i = std::static_pointer_cast<TileObjectBattleItem>(obj)->getItem();
392 i->applyDamage(state, 2 * TICKS_PER_HAZARD_UPDATE / TICKS_PER_SECOND + 1,
393 damageType);
394 }

Callers

nothing calls this directly

Calls 10

getOwningTileMethod · 0.80
endMethod · 0.80
applyBurningMethod · 0.80
getItemMethod · 0.80
getUnitMethod · 0.80
getCurrentHeightMethod · 0.80
determineBodyPartHitMethod · 0.80
getTypeMethod · 0.45
getOwnerMethod · 0.45
applyDamageMethod · 0.45

Tested by

no test coverage detected