1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-03 00:46:55 +02:00

Initial unconditionally working version

This commit is contained in:
Dydzio
2024-09-22 15:07:44 +02:00
parent 894c88defc
commit 1a2d349267
5 changed files with 92 additions and 21 deletions

View File

@ -175,6 +175,18 @@ void BattleActionsController::enterCreatureCastingMode()
if (!owner.stacksController->getActiveStack())
return;
if(owner.getBattle()->battleCanTargetEmptyHex(owner.stacksController->getActiveStack()))
{
auto actionFilterPredicate = [](const PossiblePlayerBattleAction x)
{
return x.get() != PossiblePlayerBattleAction::SHOOT;
};
vstd::erase_if(possibleActions, actionFilterPredicate);
GH.fakeMouseMove();
return;
}
if (!isActiveStackSpellcaster())
return;
@ -263,6 +275,9 @@ void BattleActionsController::reorderPossibleActionsPriority(const CStack * stac
return 2;
break;
case PossiblePlayerBattleAction::SHOOT:
if(targetStack == nullptr || targetStack->unitSide() == stack->unitSide())
return 100; //bottom priority
return 4;
break;
case PossiblePlayerBattleAction::ATTACK_AND_RETURN:
@ -514,6 +529,13 @@ std::string BattleActionsController::actionGetStatusMessage(PossiblePlayerBattle
case PossiblePlayerBattleAction::SHOOT:
{
if(targetStack == nullptr) //should be true only for spell-like attack
{
auto spellLikeAttackBonus = owner.stacksController->getActiveStack()->getBonus(Selector::type()(BonusType::SPELL_LIKE_ATTACK));
assert(bonus != nullptr);
return boost::str(boost::format(CGI->generaltexth->allTexts[26]) % spellLikeAttackBonus->subtype.as<SpellID>().toSpell()->getNameTranslated());
}
const auto * shooter = owner.stacksController->getActiveStack();
DamageEstimation retaliation;
@ -1020,7 +1042,7 @@ void BattleActionsController::onHexRightClicked(BattleHex clickedHex)
{
auto spellcastActionPredicate = [](PossiblePlayerBattleAction & action)
{
return action.spellcast();
return action.spellcast() || action.get() == PossiblePlayerBattleAction::SHOOT;
};
bool isCurrentStackInSpellcastMode = !possibleActions.empty() && std::all_of(possibleActions.begin(), possibleActions.end(), spellcastActionPredicate);