MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / deployCivilians

Method deployCivilians

src/Battlescape/BattlescapeGenerator.cpp:1808–1827  ·  view source on GitHub ↗

* Spawns 1-16 civilians on a terror mission. * @param max Maximum number of civilians to spawn. */

Source from the content-addressed store, hash-verified

1806 * @param max Maximum number of civilians to spawn.
1807 */
1808void BattlescapeGenerator::deployCivilians(int max)
1809{
1810 if (max)
1811 {
1812 // inevitably someone will point out that ufopaedia says 0-16 civilians.
1813 // to that person: i looked at the code and it says otherwise.
1814 // 0 civilians would only be a possibility if there were already 80 units,
1815 // or no spawn nodes for civilians.
1816 int number = RNG::generate(max/2, max);
1817
1818 if (number > 0)
1819 {
1820 for (int i = 0; i < number; ++i)
1821 {
1822 size_t pick = RNG::generate(0, _terrain->getCivilianTypes().size() -1);
1823 addCivilian(_game->getRuleset()->getUnit(_terrain->getCivilianTypes().at(pick)));
1824 }
1825 }
1826 }
1827}
1828
1829/**
1830 * Sets the alien base involved in the battle.

Callers

nothing calls this directly

Calls 4

generateFunction · 0.85
getCivilianTypesMethod · 0.80
getUnitMethod · 0.45
getRulesetMethod · 0.45

Tested by

no test coverage detected