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

Method postMissionProcedures

src/Savegame/BattleUnit.cpp:1902–1962  ·  view source on GitHub ↗

* Check if unit eligible for squaddie promotion. If yes, promote the unit. * Increase the mission counter. Calculate the experience increases. * @param geoscape Pointer to geoscape save. * @return True if the soldier was eligible for squaddie promotion. */

Source from the content-addressed store, hash-verified

1900 * @return True if the soldier was eligible for squaddie promotion.
1901 */
1902bool BattleUnit::postMissionProcedures(SavedGame *geoscape)
1903{
1904 Soldier *s = geoscape->getSoldier(_id);
1905 if (s == 0)
1906 {
1907 return false;
1908 }
1909
1910 updateGeoscapeStats(s);
1911
1912 UnitStats *stats = s->getCurrentStats();
1913 const UnitStats caps = s->getRules()->getStatCaps();
1914 int healthLoss = stats->health - _health;
1915
1916 s->setWoundRecovery(RNG::generate((healthLoss*0.5),(healthLoss*1.5)));
1917
1918 if (_expBravery && stats->bravery < caps.bravery)
1919 {
1920 if (_expBravery > RNG::generate(0,10)) stats->bravery += 10;
1921 }
1922 if (_expReactions && stats->reactions < caps.reactions)
1923 {
1924 stats->reactions += improveStat(_expReactions);
1925 }
1926 if (_expFiring && stats->firing < caps.firing)
1927 {
1928 stats->firing += improveStat(_expFiring);
1929 }
1930 if (_expMelee && stats->melee < caps.melee)
1931 {
1932 stats->melee += improveStat(_expMelee);
1933 }
1934 if (_expThrowing && stats->throwing < caps.throwing)
1935 {
1936 stats->throwing += improveStat(_expThrowing);
1937 }
1938 if (_expPsiSkill && stats->psiSkill < caps.psiSkill)
1939 {
1940 stats->psiSkill += improveStat(_expPsiSkill);
1941 }
1942
1943 if (_expBravery || _expReactions || _expFiring || _expPsiSkill || _expMelee)
1944 {
1945 if (s->getRank() == RANK_ROOKIE)
1946 s->promoteRank();
1947 int v;
1948 v = caps.tu - stats->tu;
1949 if (v > 0) stats->tu += RNG::generate(0, v/10 + 2);
1950 v = caps.health - stats->health;
1951 if (v > 0) stats->health += RNG::generate(0, v/10 + 2);
1952 v = caps.strength - stats->strength;
1953 if (v > 0) stats->strength += RNG::generate(0, v/10 + 2);
1954 v = caps.stamina - stats->stamina;
1955 if (v > 0) stats->stamina += RNG::generate(0, v/10 + 2);
1956 return true;
1957 }
1958 else
1959 {

Callers 1

prepareDebriefingMethod · 0.80

Calls 8

generateFunction · 0.85
getStatCapsMethod · 0.80
setWoundRecoveryMethod · 0.80
promoteRankMethod · 0.80
getSoldierMethod · 0.45
getCurrentStatsMethod · 0.45
getRulesMethod · 0.45
getRankMethod · 0.45

Tested by

no test coverage detected