1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

* new spell: remove obstacle

* minor changes
This commit is contained in:
mateuszb
2009-08-19 10:59:42 +00:00
parent af1a55e063
commit c4b0bd9d7e
13 changed files with 122 additions and 12 deletions

View File

@@ -1014,6 +1014,7 @@ void CGameHandler::setupBattle( BattleInfo * curB, int3 tile, const CCreatureSet
while(toBlock>0)
{
CObstacleInstance coi;
coi.uniqueID = curB->obstacles.size();
coi.ID = possibleObstacles[rand()%possibleObstacles.size()];
coi.pos = rand()%BFIELD_SIZE;
std::vector<int> block = VLC->heroh->obstacles[coi.ID].getBlocked(coi.pos);
@@ -2869,6 +2870,23 @@ bool CGameHandler::makeCustomAction( BattleAction &ba )
sendAndApply(&shr);
break;
}
case 64: //remove obstacle
{
ObstaclesRemoved obr;
for(int g=0; g<gs->curB->obstacles.size(); ++g)
{
std::vector<int> blockedHexes = VLC->heroh->obstacles[gs->curB->obstacles[g].ID].getBlocked(gs->curB->obstacles[g].pos);
if(vstd::contains(blockedHexes, ba.destinationTile)) //this obstacle covers given hex
{
obr.obstacles.insert(gs->curB->obstacles[g].uniqueID);
}
}
if(!obr.obstacles.empty())
sendAndApply(&obr);
break;
}
}
sendAndApply(&EndAction());
return true;