Permalink
Browse files

fix some medkit behaviour

apply "soldiersRevived" when using stimulants

don't apply "soldiersRevived" multiple times
when healing wounds on unconscious units and waking them up

exit the screen if an unconscious unit has had
all wounds healed and was woken up in the process
  • Loading branch information...
Warboy1982 committed Jan 21, 2018
1 parent 92495e5 commit 2eaaf484c8580564497962f159e17918cd2307a8
Showing with 15 additions and 4 deletions.
  1. +14 −4 src/Battlescape/MedikitState.cpp
  2. +1 −0 src/Battlescape/MedikitState.h
@@ -119,7 +119,7 @@ MedikitButton::MedikitButton(int y) : InteractiveSurface(30, 20, 190, y)
* @param targetUnit The wounded unit.
* @param action The healing action.
*/
MedikitState::MedikitState (BattleUnit *targetUnit, BattleAction *action) : _targetUnit(targetUnit), _action(action)
MedikitState::MedikitState (BattleUnit *targetUnit, BattleAction *action) : _targetUnit(targetUnit), _action(action), _revivedTarget(false)
{
if (Options::maximizeInfoScreens)
{
@@ -228,11 +228,20 @@ void MedikitState::onHealClick(Action *)
_medikitView->updateSelectedPart();
_medikitView->invalidate();
update();
if (_targetUnit->getStatus() == STATUS_UNCONSCIOUS && _targetUnit->getStunlevel() < _targetUnit->getHealth() && _targetUnit->getHealth() > 0)
{
_targetUnit->setTimeUnits(0);
_action->actor->getStatistics()->revivedSoldier++;
if (!_revivedTarget)
{
_targetUnit->setTimeUnits(0);
_action->actor->getStatistics()->revivedSoldier++;
_revivedTarget = true;
}
// if the unit has revived and has no more wounds, we quit this screen automatically
if (_targetUnit->getFatalWounds() == 0)
{
onEndClick(0);
}
}
_unit->getStatistics()->woundsHealed++;
}
@@ -266,6 +275,7 @@ void MedikitState::onStimulantClick(Action *)
if (_targetUnit->getStatus() == STATUS_UNCONSCIOUS && _targetUnit->getStunlevel() < _targetUnit->getHealth() && _targetUnit->getHealth() > 0)
{
_targetUnit->setTimeUnits(0);
_action->actor->getStatistics()->revivedSoldier++;
onEndClick(0);
}
}
@@ -42,6 +42,7 @@ class MedikitState : public State
BattleItem *_item;
BattleAction *_action;
int _tu;
bool _revivedTarget;
/// Handler for the end button.
void onEndClick(Action *action);
/// Handler for the heal button.

0 comments on commit 2eaaf48

Please sign in to comment.