mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Added new BattleSpellCastParameters support to TELEPORT spell.
This commit is contained in:
parent
57e5b768e8
commit
939a9180e2
@ -668,14 +668,43 @@ void SummonMechanics::applyBattleEffects(const SpellCastEnvironment * env, const
|
|||||||
void TeleportMechanics::applyBattleEffects(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, SpellCastContext & ctx) const
|
void TeleportMechanics::applyBattleEffects(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, SpellCastContext & ctx) const
|
||||||
{
|
{
|
||||||
//todo: check legal teleport
|
//todo: check legal teleport
|
||||||
|
if(parameters.destinations.size() == 2)
|
||||||
BattleStackMoved bsm;
|
{
|
||||||
bsm.distance = -1;
|
//first destination creature to move
|
||||||
bsm.stack = parameters.selectedStack->ID;//todo: use destinations
|
const CStack * target = parameters.destinations[0].stackValue;
|
||||||
std::vector<BattleHex> tiles;
|
if(nullptr == target)
|
||||||
tiles.push_back(parameters.getFirstDestinationHex());
|
{
|
||||||
bsm.tilesToMove = tiles;
|
env->complain("TeleportMechanics: no stack to teleport");
|
||||||
bsm.teleporting = true;
|
return;
|
||||||
env->sendAndApply(&bsm);
|
}
|
||||||
|
//second destination hex to move to
|
||||||
|
const BattleHex destination = parameters.destinations[1].hexValue;
|
||||||
|
if(!destination.isValid())
|
||||||
|
{
|
||||||
|
env->complain("TeleportMechanics: invalid teleport destination");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BattleStackMoved bsm;
|
||||||
|
bsm.distance = -1;
|
||||||
|
bsm.stack = target->ID;
|
||||||
|
std::vector<BattleHex> tiles;
|
||||||
|
tiles.push_back(destination);
|
||||||
|
bsm.tilesToMove = tiles;
|
||||||
|
bsm.teleporting = true;
|
||||||
|
env->sendAndApply(&bsm);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//todo: remove and report error
|
||||||
|
BattleStackMoved bsm;
|
||||||
|
bsm.distance = -1;
|
||||||
|
bsm.stack = parameters.selectedStack->ID;
|
||||||
|
std::vector<BattleHex> tiles;
|
||||||
|
tiles.push_back(parameters.getFirstDestinationHex());
|
||||||
|
bsm.tilesToMove = tiles;
|
||||||
|
bsm.teleporting = true;
|
||||||
|
env->sendAndApply(&bsm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user