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):
|
BattleActionsController::BattleActionsController(BattleInterface & owner):
|
||||||
owner(owner),
|
owner(owner),
|
||||||
|
selectedStack(nullptr),
|
||||||
heroSpellToCast(nullptr)
|
heroSpellToCast(nullptr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -177,7 +178,7 @@ void BattleActionsController::enterCreatureCastingMode()
|
|||||||
if (isCastingPossible)
|
if (isCastingPossible)
|
||||||
{
|
{
|
||||||
owner.giveCommand(EActionType::MONSTER_SPELL, BattleHex::INVALID, spell->getId());
|
owner.giveCommand(EActionType::MONSTER_SPELL, BattleHex::INVALID, spell->getId());
|
||||||
owner.stacksController->setSelectedStack(nullptr);
|
selectedStack = nullptr;
|
||||||
|
|
||||||
CCS->curh->set(Cursor::Combat::POINTER);
|
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);
|
return isCastingPossibleHere(action.spell().toSpell(), owner.stacksController->getActiveStack(), targetStack, targetHex);
|
||||||
|
|
||||||
case PossiblePlayerBattleAction::AIMED_SPELL_CREATURE:
|
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:
|
case PossiblePlayerBattleAction::RANDOM_GENIE_SPELL:
|
||||||
if(targetStack && targetStackOwned && targetStack != owner.stacksController->getActiveStack() && targetStack->alive()) //only positive spells for other allied creatures
|
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:
|
case PossiblePlayerBattleAction::TELEPORT:
|
||||||
{
|
{
|
||||||
ui8 skill = getCurrentSpellcaster()->getEffectLevel(SpellID(SpellID::TELEPORT).toSpell());
|
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
|
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::OBSTACLE:
|
||||||
case PossiblePlayerBattleAction::FREE_LOCATION:
|
case PossiblePlayerBattleAction::FREE_LOCATION:
|
||||||
@ -697,14 +698,14 @@ void BattleActionsController::actionRealize(PossiblePlayerBattleAction action, B
|
|||||||
{
|
{
|
||||||
heroSpellToCast->aimToHex(targetHex);
|
heroSpellToCast->aimToHex(targetHex);
|
||||||
possibleActions.push_back({PossiblePlayerBattleAction::SACRIFICE, action.spell()});
|
possibleActions.push_back({PossiblePlayerBattleAction::SACRIFICE, action.spell()});
|
||||||
owner.stacksController->setSelectedStack(targetStack);
|
selectedStack = targetStack;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (action.spell() == SpellID::TELEPORT)
|
if (action.spell() == SpellID::TELEPORT)
|
||||||
{
|
{
|
||||||
heroSpellToCast->aimToUnit(targetStack);
|
heroSpellToCast->aimToUnit(targetStack);
|
||||||
possibleActions.push_back({PossiblePlayerBattleAction::TELEPORT, action.spell()});
|
possibleActions.push_back({PossiblePlayerBattleAction::TELEPORT, action.spell()});
|
||||||
owner.stacksController->setSelectedStack(targetStack);
|
selectedStack = targetStack;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -735,7 +736,7 @@ void BattleActionsController::actionRealize(PossiblePlayerBattleAction action, B
|
|||||||
owner.curInt->cb->battleMakeAction(heroSpellToCast.get());
|
owner.curInt->cb->battleMakeAction(heroSpellToCast.get());
|
||||||
endCastingSpell();
|
endCastingSpell();
|
||||||
}
|
}
|
||||||
owner.stacksController->setSelectedStack(nullptr);
|
selectedStack = nullptr;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,9 @@ class BattleActionsController
|
|||||||
/// if true, active stack could possibly cast some target spell
|
/// if true, active stack could possibly cast some target spell
|
||||||
std::vector<const CSpell *> creatureSpells;
|
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 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
|
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
|
std::vector<PossiblePlayerBattleAction> getPossibleActionsForStack (const CStack *stack) const; //called when stack gets its turn
|
||||||
|
@ -74,7 +74,6 @@ BattleStacksController::BattleStacksController(BattleInterface & owner):
|
|||||||
owner(owner),
|
owner(owner),
|
||||||
activeStack(nullptr),
|
activeStack(nullptr),
|
||||||
stackToActivate(nullptr),
|
stackToActivate(nullptr),
|
||||||
selectedStack(nullptr),
|
|
||||||
animIDhelper(0)
|
animIDhelper(0)
|
||||||
{
|
{
|
||||||
//preparing graphics for displaying amounts of creatures
|
//preparing graphics for displaying amounts of creatures
|
||||||
@ -734,16 +733,6 @@ void BattleStacksController::activateStack()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattleStacksController::setSelectedStack(const CStack *stack)
|
|
||||||
{
|
|
||||||
selectedStack = stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
const CStack* BattleStacksController::getSelectedStack() const
|
|
||||||
{
|
|
||||||
return selectedStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
const CStack* BattleStacksController::getActiveStack() const
|
const CStack* BattleStacksController::getActiveStack() const
|
||||||
{
|
{
|
||||||
return activeStack;
|
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
|
///when animation is playing, we should wait till the end to make the next stack active; nullptr of none
|
||||||
const CStack *stackToActivate;
|
const CStack *stackToActivate;
|
||||||
|
|
||||||
/// stack that was selected for multi-target spells - Teleport / Sacrifice
|
|
||||||
const CStack *selectedStack;
|
|
||||||
|
|
||||||
/// for giving IDs for animations
|
/// for giving IDs for animations
|
||||||
ui32 animIDhelper;
|
ui32 animIDhelper;
|
||||||
|
|
||||||
@ -126,7 +123,6 @@ public:
|
|||||||
void activateStack(); //copy stackToActivate to activeStack to enable controls of the stack
|
void activateStack(); //copy stackToActivate to activeStack to enable controls of the stack
|
||||||
|
|
||||||
void setActiveStack(const CStack *stack);
|
void setActiveStack(const CStack *stack);
|
||||||
void setSelectedStack(const CStack *stack);
|
|
||||||
|
|
||||||
void showAliveStack(Canvas & canvas, const CStack * stack);
|
void showAliveStack(Canvas & canvas, const CStack * stack);
|
||||||
void showStack(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
|
void addNewAnim(BattleAnimation *anim); //adds new anim to pendingAnims
|
||||||
|
|
||||||
const CStack* getActiveStack() const;
|
const CStack* getActiveStack() const;
|
||||||
const CStack* getSelectedStack() const;
|
|
||||||
const std::vector<uint32_t> getHoveredStacksUnitIds() const;
|
const std::vector<uint32_t> getHoveredStacksUnitIds() const;
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user