|
@@ -113,6 +113,7 @@ static std::string formatRangedAttack(const DamageEstimation & estimation, const
|
|
|
|
|
|
BattleActionsController::BattleActionsController(BattleInterface & owner):
|
|
BattleActionsController::BattleActionsController(BattleInterface & owner):
|
|
owner(owner),
|
|
owner(owner),
|
|
|
|
+ selectedStack(nullptr),
|
|
heroSpellToCast(nullptr)
|
|
heroSpellToCast(nullptr)
|
|
{}
|
|
{}
|
|
|
|
|
|
@@ -177,7 +178,7 @@ void BattleActionsController::enterCreatureCastingMode()
|
|
if (isCastingPossible)
|
|
if (isCastingPossible)
|
|
{
|
|
{
|
|
owner.giveCommand(EActionType::MONSTER_SPELL, BattleHex::INVALID, spell->getId());
|
|
owner.giveCommand(EActionType::MONSTER_SPELL, BattleHex::INVALID, spell->getId());
|
|
- owner.stacksController->setSelectedStack(nullptr);
|
|
|
|
|
|
+ selectedStack = nullptr;
|
|
|
|
|
|
CCS->curh->set(Cursor::Combat::POINTER);
|
|
CCS->curh->set(Cursor::Combat::POINTER);
|
|
}
|
|
}
|
|
@@ -568,7 +569,7 @@ bool BattleActionsController::actionIsLegal(PossiblePlayerBattleAction action, B
|
|
return isCastingPossibleHere(action.spell().toSpell(), owner.stacksController->getActiveStack(), targetStack, targetHex);
|
|
return isCastingPossibleHere(action.spell().toSpell(), owner.stacksController->getActiveStack(), targetStack, targetHex);
|
|
|
|
|
|
case PossiblePlayerBattleAction::AIMED_SPELL_CREATURE:
|
|
case PossiblePlayerBattleAction::AIMED_SPELL_CREATURE:
|
|
- return targetStack && isCastingPossibleHere(action.spell().toSpell(), owner.stacksController->getActiveStack(), targetStack, targetHex);
|
|
|
|
|
|
+ return !selectedStack && targetStack && isCastingPossibleHere(action.spell().toSpell(), owner.stacksController->getActiveStack(), targetStack, targetHex);
|
|
|
|
|
|
case PossiblePlayerBattleAction::RANDOM_GENIE_SPELL:
|
|
case PossiblePlayerBattleAction::RANDOM_GENIE_SPELL:
|
|
if(targetStack && targetStackOwned && targetStack != owner.stacksController->getActiveStack() && targetStack->alive()) //only positive spells for other allied creatures
|
|
if(targetStack && targetStackOwned && targetStack != owner.stacksController->getActiveStack() && targetStack->alive()) //only positive spells for other allied creatures
|
|
@@ -581,11 +582,11 @@ bool BattleActionsController::actionIsLegal(PossiblePlayerBattleAction action, B
|
|
case PossiblePlayerBattleAction::TELEPORT:
|
|
case PossiblePlayerBattleAction::TELEPORT:
|
|
{
|
|
{
|
|
ui8 skill = getCurrentSpellcaster()->getEffectLevel(SpellID(SpellID::TELEPORT).toSpell());
|
|
ui8 skill = getCurrentSpellcaster()->getEffectLevel(SpellID(SpellID::TELEPORT).toSpell());
|
|
- return owner.curInt->cb->battleCanTeleportTo(owner.stacksController->getSelectedStack(), targetHex, skill);
|
|
|
|
|
|
+ return owner.curInt->cb->battleCanTeleportTo(selectedStack, targetHex, skill);
|
|
}
|
|
}
|
|
|
|
|
|
case PossiblePlayerBattleAction::SACRIFICE: //choose our living stack to sacrifice
|
|
case PossiblePlayerBattleAction::SACRIFICE: //choose our living stack to sacrifice
|
|
- return targetStack && targetStack != owner.stacksController->getSelectedStack() && targetStackOwned && targetStack->alive();
|
|
|
|
|
|
+ return targetStack && targetStack != selectedStack && targetStackOwned && targetStack->alive();
|
|
|
|
|
|
case PossiblePlayerBattleAction::OBSTACLE:
|
|
case PossiblePlayerBattleAction::OBSTACLE:
|
|
case PossiblePlayerBattleAction::FREE_LOCATION:
|
|
case PossiblePlayerBattleAction::FREE_LOCATION:
|
|
@@ -697,14 +698,14 @@ void BattleActionsController::actionRealize(PossiblePlayerBattleAction action, B
|
|
{
|
|
{
|
|
heroSpellToCast->aimToHex(targetHex);
|
|
heroSpellToCast->aimToHex(targetHex);
|
|
possibleActions.push_back({PossiblePlayerBattleAction::SACRIFICE, action.spell()});
|
|
possibleActions.push_back({PossiblePlayerBattleAction::SACRIFICE, action.spell()});
|
|
- owner.stacksController->setSelectedStack(targetStack);
|
|
|
|
|
|
+ selectedStack = targetStack;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
if (action.spell() == SpellID::TELEPORT)
|
|
if (action.spell() == SpellID::TELEPORT)
|
|
{
|
|
{
|
|
heroSpellToCast->aimToUnit(targetStack);
|
|
heroSpellToCast->aimToUnit(targetStack);
|
|
possibleActions.push_back({PossiblePlayerBattleAction::TELEPORT, action.spell()});
|
|
possibleActions.push_back({PossiblePlayerBattleAction::TELEPORT, action.spell()});
|
|
- owner.stacksController->setSelectedStack(targetStack);
|
|
|
|
|
|
+ selectedStack = targetStack;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -735,7 +736,7 @@ void BattleActionsController::actionRealize(PossiblePlayerBattleAction action, B
|
|
owner.curInt->cb->battleMakeAction(heroSpellToCast.get());
|
|
owner.curInt->cb->battleMakeAction(heroSpellToCast.get());
|
|
endCastingSpell();
|
|
endCastingSpell();
|
|
}
|
|
}
|
|
- owner.stacksController->setSelectedStack(nullptr);
|
|
|
|
|
|
+ selectedStack = nullptr;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|