コード例 #1
0
ファイル: BattleUnit.cpp プロジェクト: ben0x539/OpenXcom
/**
* Check if unit eligible for squaddie promotion. If yes, promote the unit.
* Increase the mission counter. Calculate the experience increases.
* @return True if the soldier was eligible for squaddie promotion.
*/
bool BattleUnit::postMissionProcedures()
{
	Soldier *s = dynamic_cast<Soldier*>(_unit);
	if (s == 0)
	{
		return false;
	}

	s->addMissionCount();

	UnitStats *stats = s->getCurrentStats();

	if (_expBravery && stats->bravery < 100)
	{
		if (_expBravery > RNG::generate(0,10)) stats->bravery += 10;
	}
	if (_expReactions && stats->reactions < 100)
	{
		stats->reactions += improveStat(_expReactions);
	}
	if (_expFiring && stats->firing < 120)
	{
		stats->firing += improveStat(_expFiring);
	}
	if (_expMelee && stats->melee < 120)
	{
		stats->melee += improveStat(_expMelee);
	}
	if (_expThrowing && stats->throwing < 120)
	{
		stats->throwing += improveStat(_expThrowing);
	}
	if (_expPsiSkill && stats->psiSkill < 100)
	{
		stats->psiSkill += improveStat(_expPsiSkill);
	}

	/* TODO wound recovery :  Soldier->Wound_Recovery_Days = v / 2 + randmod(v) (v = UnitRef->BaseHPs - UnitRef->CurHP) */

	if (_expBravery || _expReactions || _expFiring || _expPsiSkill || _expMelee)
	{
		if (s->getRank() == RANK_ROOKIE)
			s->promoteRank();
		int v;
		v = 80 - stats->tu;
		if (v > 0) stats->tu += RNG::generate(0, v/10 + 2);
		v = 60 - stats->health;
		if (v > 0) stats->health += RNG::generate(0, v/10 + 2);
		v = 70 - stats->strength;
		if (v > 0) stats->strength += RNG::generate(0, v/10 + 2);
		v = 100 - stats->stamina;
		if (v > 0) stats->stamina += RNG::generate(0, v/10 + 2);
		return true;
	}
	else
	{
		return false;
	}
}
コード例 #2
0
ファイル: BattleUnit.cpp プロジェクト: Munkeylord/OpenXcom
/**
* Check if unit eligible for squaddie promotion. If yes, promote the unit.
* Increase the mission counter. Calculate the experience increases.
* @return True if the soldier was eligible for squaddie promotion.
*/
bool BattleUnit::postMissionProcedures(SavedGame *geoscape)
{
	Soldier *s = geoscape->getSoldier(_id);
	if (s == 0)
	{
		return false;
	}

	s->addMissionCount();
	s->addKillCount(_kills);

	UnitStats *stats = s->getCurrentStats();
	int healthLoss = stats->health - _health;

	s->setWoundRecovery(RNG::generate((healthLoss*0.5),(healthLoss*1.5)));

	if (_expBravery && stats->bravery < 100)
	{
		if (_expBravery > RNG::generate(0,10)) stats->bravery += 10;
	}
	if (_expReactions && stats->reactions < 100)
	{
		stats->reactions += improveStat(_expReactions);
	}
	if (_expFiring && stats->firing < 120)
	{
		stats->firing += improveStat(_expFiring);
	}
	if (_expMelee && stats->melee < 120)
	{
		stats->melee += improveStat(_expMelee);
	}
	if (_expThrowing && stats->throwing < 120)
	{
		stats->throwing += improveStat(_expThrowing);
	}
	if (_expPsiSkill && stats->psiSkill < 100)
	{
		stats->psiSkill += improveStat(_expPsiSkill);
	}

	if (_expBravery || _expReactions || _expFiring || _expPsiSkill || _expMelee)
	{
		if (s->getRank() == RANK_ROOKIE)
			s->promoteRank();
		int v;
		v = 80 - stats->tu;
		if (v > 0) stats->tu += RNG::generate(0, v/10 + 2);
		v = 60 - stats->health;
		if (v > 0) stats->health += RNG::generate(0, v/10 + 2);
		v = 70 - stats->strength;
		if (v > 0) stats->strength += RNG::generate(0, v/10 + 2);
		v = 100 - stats->stamina;
		if (v > 0) stats->stamina += RNG::generate(0, v/10 + 2);
		return true;
	}
	else
	{
		return false;
	}
}