| 752 | } |
| 753 | |
| 754 | void Building::detect(GameState &state, bool forced) |
| 755 | { |
| 756 | if (ticksDetectionTimeOut > 0) |
| 757 | { |
| 758 | return; |
| 759 | } |
| 760 | if (!forced) |
| 761 | { |
| 762 | bool alien_spotted = false; |
| 763 | int detectionValue = 0; |
| 764 | for (auto &pair : current_crew) |
| 765 | { |
| 766 | if (pair.second == 0) |
| 767 | { |
| 768 | continue; |
| 769 | } |
| 770 | if (randBoundsExclusive(state.rng, 0, 100) < 100 / (pair.second + 1)) |
| 771 | { |
| 772 | alien_spotted = true; |
| 773 | } |
| 774 | detectionValue += pair.first->detectionWeight * pair.second; |
| 775 | } |
| 776 | if (!alien_spotted) |
| 777 | { |
| 778 | return; |
| 779 | } |
| 780 | detectionValue *= function->detectionWeight - 2 * state.difficulty; |
| 781 | detectionValue /= 100; |
| 782 | if (owner->isRelatedTo(state.getAliens()) == Organisation::Relation::Allied) |
| 783 | { |
| 784 | detectionValue /= 2; |
| 785 | } |
| 786 | if (owner->isRelatedTo(state.getPlayer()) == Organisation::Relation::Hostile) |
| 787 | { |
| 788 | detectionValue /= 2; |
| 789 | } |
| 790 | if (owner->takenOver) |
| 791 | { |
| 792 | detectionValue /= 2; |
| 793 | } |
| 794 | if (randBoundsExclusive(state.rng, 0, 100) >= detectionValue - 10) |
| 795 | { |
| 796 | return; |
| 797 | } |
| 798 | } |
| 799 | else |
| 800 | { |
| 801 | bool alien_spotted = false; |
| 802 | for (auto &pair : current_crew) |
| 803 | { |
| 804 | if (pair.second == 0) |
| 805 | { |
| 806 | continue; |
| 807 | } |
| 808 | alien_spotted = true; |
| 809 | break; |
| 810 | } |
| 811 | if (!alien_spotted) |
nothing calls this directly
no test coverage detected