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

Method trainPsi

src/Savegame/Soldier.cpp:465–484  ·  view source on GitHub ↗

* Trains a soldier's Psychic abilities after 1 month. */

Source from the content-addressed store, hash-verified

463 * Trains a soldier's Psychic abilities after 1 month.
464 */
465void Soldier::trainPsi()
466{
467 _improvement = 0;
468 // -10 days - tolerance threshold for switch from anytimePsiTraining option.
469 // If soldier has psiskill -10..-1, he was trained 20..59 days. 81.7% probability, he was trained more that 30 days.
470 if (_currentStats.psiSkill < -10 + _rules->getMinStats().psiSkill)
471 _currentStats.psiSkill = _rules->getMinStats().psiSkill;
472 else if(_currentStats.psiSkill <= _rules->getMaxStats().psiSkill)
473 {
474 int max = _rules->getMaxStats().psiSkill + _rules->getMaxStats().psiSkill / 2;
475 _improvement = RNG::generate(_rules->getMaxStats().psiSkill, max);
476 }
477 else if(_currentStats.psiSkill <= (_rules->getStatCaps().psiSkill / 2))
478 _improvement = RNG::generate(5, 12);
479 else if(_currentStats.psiSkill < _rules->getStatCaps().psiSkill)
480 _improvement = RNG::generate(1, 3);
481 _currentStats.psiSkill += _improvement;
482 if(_currentStats.psiSkill > 100)
483 _currentStats.psiSkill = 100;
484}
485
486/**
487 * Trains a soldier's Psychic abilities after 1 day.

Callers 1

time1MonthMethod · 0.80

Calls 4

generateFunction · 0.85
getMinStatsMethod · 0.80
getMaxStatsMethod · 0.80
getStatCapsMethod · 0.80

Tested by

no test coverage detected