1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-27 21:49:10 +02:00

- blocked retreating from castle. Escape Tunnel implemented.

- fixed crash when player have no hero (like castle defence)
- minor fixes
This commit is contained in:
Ivan Savenko 2010-08-19 11:03:33 +00:00
parent 8319e5e703
commit d732565002
6 changed files with 34 additions and 7 deletions

View File

@ -624,9 +624,9 @@ bool CCallback::battleCanCastSpell()
return false;
if(gs->curB->side1 == player)
return gs->curB->castSpells[0] == 0 && gs->curB->heroes[0]->getArt(17);
return gs->curB->castSpells[0] == 0 && gs->curB->heroes[0] && gs->curB->heroes[0]->getArt(17);
else
return gs->curB->castSpells[1] == 0 && gs->curB->heroes[1]->getArt(17);
return gs->curB->castSpells[1] == 0 && gs->curB->heroes[1] && gs->curB->heroes[1]->getArt(17);
}
bool CCallback::battleCanFlee()

View File

@ -1197,6 +1197,8 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
bOptions = new AdventureMapButton (CGI->generaltexth->zelp[381].first, CGI->generaltexth->zelp[381].second, boost::bind(&CBattleInterface::bOptionsf,this), 3 + pos.x, 561 + pos.y, "icm003.def", SDLK_o);
bSurrender = new AdventureMapButton (CGI->generaltexth->zelp[379].first, CGI->generaltexth->zelp[379].second, boost::bind(&CBattleInterface::bSurrenderf,this), 54 + pos.x, 561 + pos.y, "icm001.def", SDLK_s);
bFlee = new AdventureMapButton (CGI->generaltexth->zelp[380].first, CGI->generaltexth->zelp[380].second, boost::bind(&CBattleInterface::bFleef,this), 105 + pos.x, 561 + pos.y, "icm002.def", SDLK_r);
bSurrender->block(!curInt->cb->battleCanFlee());
bFlee->block(!curInt->cb->battleCanFlee());
bAutofight = new AdventureMapButton (CGI->generaltexth->zelp[382].first, CGI->generaltexth->zelp[382].second, boost::bind(&CBattleInterface::bAutofightf,this), 157 + pos.x, 561 + pos.y, "icm004.def", SDLK_a);
bSpell = new AdventureMapButton (CGI->generaltexth->zelp[385].first, CGI->generaltexth->zelp[385].second, boost::bind(&CBattleInterface::bSpellf,this), 645 + pos.x, 561 + pos.y, "icm005.def", SDLK_c);
bSpell->block(true);
@ -2915,6 +2917,8 @@ void CBattleInterface::activateStack()
//block cast spell button if hero doesn't have a spellbook
bSpell->block(!curInt->cb->battleCanCastSpell());
bSurrender->block(!curInt->cb->battleCanFlee());
bFlee->block(!curInt->cb->battleCanFlee());
GH.fakeMouseMove();

View File

@ -2161,6 +2161,14 @@ void CSplitWindow::keyPressed (const SDL_KeyboardEvent & key)
{
which = !which;
}
else if (k == SDLK_LEFT)
{
ncur--;
}
else if (k == SDLK_RIGHT)
{
ncur++;
}
else
{
int number = k - SDLK_0;

View File

@ -1830,8 +1830,23 @@ bool CGameState::battleCanFlee(int player)
if(!curB) //there is no battle
return false;
if(curB->heroes[0]->hasBonusOfType(Bonus::ENEMY_CANT_ESCAPE) //eg. one of heroes is wearing shakles of war
|| curB->heroes[0]->hasBonusOfType(Bonus::ENEMY_CANT_ESCAPE))
if (player == curB->side1)
{
if (!curB->heroes[0])
return false;//current player have no hero
}
else
{
if (!curB->heroes[1])
return false;
}
if( ( curB->heroes[0] && curB->heroes[0]->hasBonusOfType(Bonus::ENEMY_CANT_ESCAPE) ) //eg. one of heroes is wearing shakles of war
|| ( curB->heroes[1] && curB->heroes[1]->hasBonusOfType(Bonus::ENEMY_CANT_ESCAPE)))
return false;
if (player == curB->side2 && curB->siege //defender in siege
&& !(getTown(curB->tid)->subID == 6 && vstd::contains(getTown(curB->tid)->builtBuildings, 17)))//without escape tunnel
return false;
return true;

View File

@ -159,7 +159,7 @@ DLL_EXPORT void FoWChange::applyGs( CGameState *gs )
case 53://mine
case 98://town
case 220:
if(vstd::contains(team->players, player)) //check owned observators
if(vstd::contains(team->players, gs->map->objects[i]->tempOwner)) //check owned observators
gs->map->objects[i]->getSightTiles(tilesRevealed);
break;
}

View File

@ -251,14 +251,14 @@ void CGameHandler::levelUpHero(int ID)
hlu.skills.push_back(s);
basicAndAdv.erase(s);
}
else if(hero->secSkills.size() < hero->type->heroClass->skillLimit)
else if(none.size() && hero->secSkills.size() < hero->type->heroClass->skillLimit)
{
hlu.skills.push_back(hero->type->heroClass->chooseSecSkill(none)); //give new skill
none.erase(hlu.skills.back());
}
//second offered skill
if(hero->secSkills.size() < hero->type->heroClass->skillLimit) //hero have free skill slot
if(none.size() && hero->secSkills.size() < hero->type->heroClass->skillLimit) //hero have free skill slot
{
hlu.skills.push_back(hero->type->heroClass->chooseSecSkill(none)); //new skill
}