1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-10-31 00:07:39 +02:00

Fixed Remove Obstacle. TODO: limit its working on spell-created obstacles depending on spell school level.

This commit is contained in:
Michał W. Urbańczyk
2013-07-21 10:25:12 +00:00
parent a148c39e0a
commit 1e11904d8a
2 changed files with 30 additions and 8 deletions

View File

@@ -1778,6 +1778,32 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastThisSpell
if(spell->getTargetType() == CSpell::OBSTACLE)
{
if(spell->id == SpellID::REMOVE_OBSTACLE)
{
if(auto obstacle = battleGetObstacleOnPos(dest, false))
{
switch (obstacle->obstacleType)
{
case CObstacleInstance::ABSOLUTE_OBSTACLE: //cliff-like obstacles cant be removed
case CObstacleInstance::MOAT:
return ESpellCastProblem::NO_APPROPRIATE_TARGET;
case CObstacleInstance::USUAL:
return ESpellCastProblem::OK;
// //TODO FIRE_WALL only for ADVANCED level casters
// case CObstacleInstance::FIRE_WALL:
// return
// //TODO other magic obstacles for EXPERT
// case CObstacleInstance::QUICKSAND:
// case CObstacleInstance::LAND_MINE:
// case CObstacleInstance::FORCE_FIELD:
// return
default:
// assert(0);
return ESpellCastProblem::OK;
}
}
}
//isObstacleOnTile(dest)
//
//

View File

@@ -4299,18 +4299,14 @@ void CGameHandler::handleSpellCasting( SpellID spellID, int spellLvl, BattleHex
break;
case SpellID::REMOVE_OBSTACLE:
{
ObstaclesRemoved obr;
for(auto &obstacle : battleGetAllObstacles())
if(auto obstacleToRemove = battleGetObstacleOnPos(destination, false))
{
if(vstd::contains(obstacle->getBlockedTiles(), destination))
obr.obstacles.insert(obstacle->uniqueID);
}
if(!obr.obstacles.empty())
ObstaclesRemoved obr;
obr.obstacles.insert(obstacleToRemove->uniqueID);
sendAndApply(&obr);
}
else
complain("There's no obstacle to remove!");
break;
}
break;
case SpellID::DEATH_STARE: //handled in a bit different way