Bladeren bron

Better handling of default cursor action for SPELL_LIKE_ATTACK

Dydzio 1 jaar geleden
bovenliggende
commit
50b412b35b
1 gewijzigde bestanden met toevoegingen van 14 en 1 verwijderingen
  1. 14 1
      client/battle/BattleActionsController.cpp

+ 14 - 1
client/battle/BattleActionsController.cpp

@@ -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;