mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
Fix target selection for teleport
This commit is contained in:
parent
4c6dbb5037
commit
e9aed2761c
@ -113,6 +113,7 @@ static std::string formatRangedAttack(const DamageEstimation & estimation, const
|
||||
|
||||
BattleActionsController::BattleActionsController(BattleInterface & owner):
|
||||
owner(owner),
|
||||
selectedStack(nullptr),
|
||||
heroSpellToCast(nullptr)
|
||||
{}
|
||||
|
||||
@ -177,7 +178,7 @@ void BattleActionsController::enterCreatureCastingMode()
|
||||
if (isCastingPossible)
|
||||
{
|
||||
owner.giveCommand(EActionType::MONSTER_SPELL, BattleHex::INVALID, spell->getId());
|
||||
owner.stacksController->setSelectedStack(nullptr);
|
||||
selectedStack = nullptr;
|
||||
|
||||
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);
|
||||
|
||||
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:
|
||||
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:
|
||||
{
|
||||
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
|
||||
return targetStack && targetStack != owner.stacksController->getSelectedStack() && targetStackOwned && targetStack->alive();
|
||||
return targetStack && targetStack != selectedStack && targetStackOwned && targetStack->alive();
|
||||
|
||||
case PossiblePlayerBattleAction::OBSTACLE:
|
||||
case PossiblePlayerBattleAction::FREE_LOCATION:
|
||||
@ -697,14 +698,14 @@ void BattleActionsController::actionRealize(PossiblePlayerBattleAction action, B
|
||||
{
|
||||
heroSpellToCast->aimToHex(targetHex);
|
||||
possibleActions.push_back({PossiblePlayerBattleAction::SACRIFICE, action.spell()});
|
||||
owner.stacksController->setSelectedStack(targetStack);
|
||||
selectedStack = targetStack;
|
||||
return;
|
||||
}
|
||||
if (action.spell() == SpellID::TELEPORT)
|
||||
{
|
||||
heroSpellToCast->aimToUnit(targetStack);
|
||||
possibleActions.push_back({PossiblePlayerBattleAction::TELEPORT, action.spell()});
|
||||
owner.stacksController->setSelectedStack(targetStack);
|
||||
selectedStack = targetStack;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -735,7 +736,7 @@ void BattleActionsController::actionRealize(PossiblePlayerBattleAction action, B
|
||||
owner.curInt->cb->battleMakeAction(heroSpellToCast.get());
|
||||
endCastingSpell();
|
||||
}
|
||||
owner.stacksController->setSelectedStack(nullptr);
|
||||
selectedStack = nullptr;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,9 @@ class BattleActionsController
|
||||
/// if true, active stack could possibly cast some target spell
|
||||
std::vector<const CSpell *> creatureSpells;
|
||||
|
||||
/// stack that has been selected as first target for multi-target spells (Teleport & Sacrifice)
|
||||
const CStack * selectedStack;
|
||||
|
||||
bool isCastingPossibleHere (const CSpell * spell, const CStack *sactive, const CStack *shere, BattleHex myNumber);
|
||||
bool canStackMoveHere (const CStack *sactive, BattleHex MyNumber) const; //TODO: move to BattleState / callback
|
||||
std::vector<PossiblePlayerBattleAction> getPossibleActionsForStack (const CStack *stack) const; //called when stack gets its turn
|
||||
|
@ -74,7 +74,6 @@ BattleStacksController::BattleStacksController(BattleInterface & owner):
|
||||
owner(owner),
|
||||
activeStack(nullptr),
|
||||
stackToActivate(nullptr),
|
||||
selectedStack(nullptr),
|
||||
animIDhelper(0)
|
||||
{
|
||||
//preparing graphics for displaying amounts of creatures
|
||||
@ -734,16 +733,6 @@ void BattleStacksController::activateStack()
|
||||
return;
|
||||
}
|
||||
|
||||
void BattleStacksController::setSelectedStack(const CStack *stack)
|
||||
{
|
||||
selectedStack = stack;
|
||||
}
|
||||
|
||||
const CStack* BattleStacksController::getSelectedStack() const
|
||||
{
|
||||
return selectedStack;
|
||||
}
|
||||
|
||||
const CStack* BattleStacksController::getActiveStack() const
|
||||
{
|
||||
return activeStack;
|
||||
|
@ -79,9 +79,6 @@ class BattleStacksController
|
||||
///when animation is playing, we should wait till the end to make the next stack active; nullptr of none
|
||||
const CStack *stackToActivate;
|
||||
|
||||
/// stack that was selected for multi-target spells - Teleport / Sacrifice
|
||||
const CStack *selectedStack;
|
||||
|
||||
/// for giving IDs for animations
|
||||
ui32 animIDhelper;
|
||||
|
||||
@ -126,7 +123,6 @@ public:
|
||||
void activateStack(); //copy stackToActivate to activeStack to enable controls of the stack
|
||||
|
||||
void setActiveStack(const CStack *stack);
|
||||
void setSelectedStack(const CStack *stack);
|
||||
|
||||
void showAliveStack(Canvas & canvas, const CStack * stack);
|
||||
void showStack(Canvas & canvas, const CStack * stack);
|
||||
@ -140,7 +136,6 @@ public:
|
||||
void addNewAnim(BattleAnimation *anim); //adds new anim to pendingAnims
|
||||
|
||||
const CStack* getActiveStack() const;
|
||||
const CStack* getSelectedStack() const;
|
||||
const std::vector<uint32_t> getHoveredStacksUnitIds() const;
|
||||
|
||||
void update();
|
||||
|
Loading…
x
Reference in New Issue
Block a user