mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
Fix Ice Ring target selection
This commit is contained in:
parent
e9e549148d
commit
53f6b7bd32
@ -233,19 +233,50 @@ std::set<BattleHex> BattleFieldController::getHighlightedHexesSpellRange()
|
||||
result.insert(shadedHex);
|
||||
}
|
||||
}
|
||||
else if(owner.active) //always highlight pointed hex
|
||||
{
|
||||
if(hoveredHex.getX() != 0 && hoveredHex.getX() != GameConstants::BFIELD_WIDTH - 1)
|
||||
result.insert(hoveredHex);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::set<BattleHex> BattleFieldController::getHighlightedHexesMovementTarget()
|
||||
{
|
||||
const CStack * stack = owner.stacksController->getActiveStack();
|
||||
std::set<BattleHex> result;
|
||||
auto hoveredHex = getHoveredHex();
|
||||
|
||||
if (stack)
|
||||
{
|
||||
std::vector<BattleHex> v = owner.curInt->cb->battleGetAvailableHexes(stack, false, nullptr);
|
||||
|
||||
if (vstd::contains(v,hoveredHex))
|
||||
{
|
||||
result.insert(hoveredHex);
|
||||
if (stack->doubleWide())
|
||||
result.insert(stack->occupiedHex(hoveredHex));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (stack->doubleWide())
|
||||
{
|
||||
for (auto const & hex : v)
|
||||
{
|
||||
if (stack->occupiedHex(hex) == hoveredHex)
|
||||
{
|
||||
result.insert(hoveredHex);
|
||||
result.insert(hex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void BattleFieldController::showHighlightedHexes(Canvas & canvas)
|
||||
{
|
||||
std::set<BattleHex> hoveredStack = getHighlightedHexesStackRange();
|
||||
std::set<BattleHex> hoveredMouse = getHighlightedHexesSpellRange();
|
||||
std::set<BattleHex> hoveredSpell = getHighlightedHexesSpellRange();
|
||||
std::set<BattleHex> hoveredMove = getHighlightedHexesMovementTarget();
|
||||
|
||||
auto const & hoveredMouse = owner.actionsController->spellcastingModeActive() ? hoveredSpell : hoveredMove;
|
||||
|
||||
for(int b=0; b<GameConstants::BFIELD_SIZE; ++b)
|
||||
{
|
||||
|
@ -56,6 +56,7 @@ class BattleFieldController : public CIntObject
|
||||
|
||||
std::set<BattleHex> getHighlightedHexesStackRange();
|
||||
std::set<BattleHex> getHighlightedHexesSpellRange();
|
||||
std::set<BattleHex> getHighlightedHexesMovementTarget();
|
||||
|
||||
void showBackground(Canvas & canvas);
|
||||
void showBackgroundImage(Canvas & canvas);
|
||||
|
@ -114,10 +114,11 @@ EffectTarget UnitEffect::transformTargetByRange(const Mechanics * m, const Targe
|
||||
|
||||
Target spellTargetCopy(spellTarget);
|
||||
|
||||
//make sure that we have valid target with valid aim, even if spell have invalid range configured
|
||||
//TODO: check than spell range is actually not valid
|
||||
//also hackfix for banned creature massive spells
|
||||
if(!aimPoint.empty())
|
||||
// make sure that we have valid target with valid aim, even if spell have invalid range configured
|
||||
// TODO: check than spell range is actually not valid
|
||||
// also hackfix for banned creature massive spells
|
||||
// FIXME: potentially breaking change: aimPoint may NOT be in Target - example: frost ring
|
||||
if(!aimPoint.empty() && spellTarget.empty())
|
||||
spellTargetCopy.insert(spellTargetCopy.begin(), Destination(aimPoint.front()));
|
||||
|
||||
std::set<const battle::Unit *> targets;
|
||||
|
Loading…
Reference in New Issue
Block a user