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

Method fallUnconscious

game/state/battle/battleunit.cpp:4839–4878  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4837}
4838
4839void BattleUnit::fallUnconscious(GameState &state, StateRef<BattleUnit> attacker)
4840{
4841 // Adjust relationships
4842 if (attacker)
4843 {
4844 if (config().getBool("OpenApoc.Mod.StunHostileAction"))
4845 {
4846 auto attackerOrg = attacker->agent->owner;
4847 auto ourOrg = agent->owner;
4848
4849 // If we're hostile to attacker - lose 3 points
4850 if (ourOrg->isRelatedTo(attackerOrg) == Organisation::Relation::Hostile)
4851 {
4852 ourOrg->adjustRelationTo(state, attackerOrg, -3.0f);
4853 }
4854 // If we're not hostile to attacker - lose 20 points
4855 else
4856 {
4857 ourOrg->adjustRelationTo(state, attackerOrg, -20.0f);
4858 }
4859 // Our allies lose 3 points, enemies gain 1.5 points
4860 for (auto &org : state.organisations)
4861 {
4862 if (org.first != attackerOrg.id && org.first != state.getCivilian().id)
4863 {
4864 if (org.second->isRelatedTo(ourOrg) == Organisation::Relation::Hostile)
4865 {
4866 org.second->adjustRelationTo(state, attackerOrg, 1.5f);
4867 }
4868 else if (org.second->isRelatedTo(ourOrg) == Organisation::Relation::Allied)
4869 {
4870 org.second->adjustRelationTo(state, attackerOrg, -3.0f);
4871 }
4872 }
4873 }
4874 }
4875 }
4876 sendAgentEvent(state, GameEventType::AgentUnconscious, true);
4877 dropDown(state);
4878}
4879
4880void BattleUnit::beginBodyStateChange(GameState &state, BodyState bodyState)
4881{

Callers

nothing calls this directly

Calls 4

getBoolMethod · 0.80
isRelatedToMethod · 0.80
adjustRelationToMethod · 0.80
getCivilianMethod · 0.80

Tested by

no test coverage detected