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

Method applyMoraleDamage

game/state/battle/battleunit.cpp:1820–1835  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1818}
1819
1820void BattleUnit::applyMoraleDamage(int moraleDamage, int psiAttackPower, GameState &state)
1821{
1822 LogWarning("Psionic damageType");
1823 const int random = randBoundsExclusive(state.rng, 0, 100);
1824 const int chance =
1825 getPsiAttackChance(psiAttackPower, agent->modified_stats.psi_defence, PsiStatus::Panic);
1826
1827 LogWarning("Chance: %i Random: %i", chance, random);
1828
1829 if (random < chance)
1830 {
1831 LogWarning("Psionic damage passed the defence of %s", agent->name);
1832 agent->modified_stats.loseMorale(moraleDamage);
1833 LogWarning("morale: %d", agent->modified_stats.bravery);
1834 }
1835}
1836
1837BodyPart BattleUnit::determineBodyPartHit(StateRef<DamageType> damageType, Vec3<float> cposition,
1838 Vec3<float> direction)

Callers

nothing calls this directly

Calls 3

randBoundsExclusiveFunction · 0.85
getPsiAttackChanceFunction · 0.85
loseMoraleMethod · 0.80

Tested by

no test coverage detected