1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-06 09:09:40 +02:00

Better handling of default cursor action for SPELL_LIKE_ATTACK

This commit is contained in:
Dydzio
2024-09-22 21:14:24 +02:00
parent f90405a41d
commit 50b412b35b

View File

@@ -653,7 +653,20 @@ bool BattleActionsController::actionIsLegal(PossiblePlayerBattleAction action, B
return false;
case PossiblePlayerBattleAction::SHOOT:
return owner.getBattle()->battleCanShoot(owner.stacksController->getActiveStack(), targetHex);
{
auto currentStack = owner.stacksController->getActiveStack();
if(!owner.getBattle()->battleCanShoot(currentStack, targetHex))
return false;
if(targetStack == nullptr && owner.getBattle()->battleCanTargetEmptyHex(currentStack))
{
auto spellLikeAttackBonus = currentStack->getBonus(Selector::type()(BonusType::SPELL_LIKE_ATTACK));
const CSpell * spellDataToCheck = spellLikeAttackBonus->subtype.as<SpellID>().toSpell();
return isCastingPossibleHere(spellDataToCheck, nullptr, targetHex);
}
return true;
}
case PossiblePlayerBattleAction::NO_LOCATION:
return false;