mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-24 03:47:18 +02:00
* minor improvements for campaigns
This commit is contained in:
parent
4b8be22fb6
commit
9356ba15ef
@ -2804,6 +2804,13 @@ void CBonusSelection::startMap()
|
||||
void CBonusSelection::selectBonus( int id )
|
||||
{
|
||||
sInfo.choosenCampaignBonus = id;
|
||||
|
||||
const CCampaignScenario &scenario = ourCampaign->camp->scenarios[sInfo.whichMapInCampaign];
|
||||
const std::vector<CScenarioTravel::STravelBonus> & bonDescs = scenario.travelOptions.bonusesToChoose;
|
||||
if (bonDescs[id].type == 8) //hero crossover
|
||||
{
|
||||
setPlayer(sInfo.playerInfos[0], bonDescs[id].info1); //TODO: substitute with appropriate color
|
||||
}
|
||||
}
|
||||
|
||||
void CBonusSelection::changeDiff( bool increase )
|
||||
|
@ -355,6 +355,8 @@ class CBonusSelection : public CIntObject
|
||||
CHighlightableButtonsGroup * bonuses;
|
||||
|
||||
public:
|
||||
void bonusSelectionChanges(int choosenBonus);
|
||||
|
||||
StartInfo sInfo;
|
||||
CDefHandler *sFlags;
|
||||
|
||||
|
@ -470,6 +470,7 @@ bool CCampaignScenario::isNotVoid() const
|
||||
void CCampaignScenario::prepareCrossoverHeroes( std::vector<CGHeroInstance *> heroes )
|
||||
{
|
||||
crossoverHeroes = heroes;
|
||||
|
||||
|
||||
if (!(travelOptions.whatHeroKeeps & 1))
|
||||
{
|
||||
|
@ -1376,22 +1376,6 @@ CGameState::~CGameState()
|
||||
capitols.clear();
|
||||
}
|
||||
|
||||
namespace HHLP
|
||||
{
|
||||
class HeroRemoverHelper
|
||||
{
|
||||
public:
|
||||
si32 allowedplayer;
|
||||
HeroRemoverHelper(si32 player) : allowedplayer(player)
|
||||
{
|
||||
}
|
||||
bool operator()(const CGHeroInstance * cgh)
|
||||
{
|
||||
return cgh->tempOwner != allowedplayer;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
|
||||
{
|
||||
VLC->creh->globalEffects = &globalEffects;
|
||||
@ -1658,6 +1642,14 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
|
||||
CScenarioTravel::STravelBonus bonus =
|
||||
campaign->camp->scenarios[si->whichMapInCampaign].travelOptions.bonusesToChoose[si->choosenCampaignBonus];
|
||||
|
||||
|
||||
std::vector<CGHeroInstance *> Xheroes;
|
||||
if (bonus.type == 8) //hero crossover
|
||||
{
|
||||
Xheroes = campaign->camp->scenarios[bonus.info2].crossoverHeroes;
|
||||
}
|
||||
|
||||
//selecting heroes by type
|
||||
for(int g=0; g<map->objects.size(); ++g)
|
||||
{
|
||||
CGObjectInstance * obj = map->objects[g];
|
||||
@ -1668,31 +1660,43 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
|
||||
CGHeroPlaceholder * hp = static_cast<CGHeroPlaceholder*>(obj);
|
||||
CGHeroInstance * substitution = NULL;
|
||||
|
||||
std::vector<CGHeroInstance *> Xheroes;
|
||||
if (bonus.type == 8) //hero crossover
|
||||
{
|
||||
Xheroes = campaign->camp->scenarios[bonus.info2].crossoverHeroes;
|
||||
std::remove_if(Xheroes.begin(), Xheroes.end(), HHLP::HeroRemoverHelper(bonus.info1));
|
||||
}
|
||||
else if (bonus.type == 9) //starting hero
|
||||
{
|
||||
}
|
||||
|
||||
if (hp->subID == 0xFF) //select by power
|
||||
{
|
||||
std::sort(Xheroes.begin(), Xheroes.end(), HLP::heroPowerSorter);
|
||||
HLP::replaceHero(this, g, Xheroes[hp->power - 1]);
|
||||
}
|
||||
else //select by type
|
||||
if(hp->subID != 0xFF) //select by type
|
||||
{
|
||||
bool found = false;
|
||||
BOOST_FOREACH(CGHeroInstance * ghi, Xheroes)
|
||||
{
|
||||
if (ghi->subID == hp->subID)
|
||||
{
|
||||
found = true;
|
||||
HLP::replaceHero(this, g, ghi);
|
||||
Xheroes -= ghi;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
//TODO: create new hero of this type
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//selecting heroes by power
|
||||
|
||||
std::sort(Xheroes.begin(), Xheroes.end(), HLP::heroPowerSorter);
|
||||
for(int g=0; g<map->objects.size(); ++g)
|
||||
{
|
||||
CGObjectInstance * obj = map->objects[g];
|
||||
if (obj->ID != 214) //not a placeholder
|
||||
{
|
||||
continue;
|
||||
}
|
||||
CGHeroPlaceholder * hp = static_cast<CGHeroPlaceholder*>(obj);
|
||||
CGHeroInstance * substitution = NULL;
|
||||
|
||||
if (hp->subID == 0xFF) //select by power
|
||||
{
|
||||
HLP::replaceHero(this, g, Xheroes[hp->power - 1]);
|
||||
//we don't have to remove hero from Xheroes because it would destroy the order and duplicates shouldn't happen
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4757,7 +4757,15 @@ void CGameHandler::checkLossVictory( ui8 player )
|
||||
|
||||
if(gs->campaign)
|
||||
{
|
||||
gs->campaign->mapConquered(gs->map->heroes);
|
||||
std::vector<CGHeroInstance *> hes;
|
||||
BOOST_FOREACH(CGHeroInstance * ghi, gs->map->heroes)
|
||||
{
|
||||
if (ghi->tempOwner == 0 /*TODO: insert human player's color*/)
|
||||
{
|
||||
hes.push_back(ghi);
|
||||
}
|
||||
}
|
||||
gs->campaign->mapConquered(hes);
|
||||
|
||||
UpdateCampaignState ucs;
|
||||
ucs.camp = gs->campaign;
|
||||
|
Loading…
x
Reference in New Issue
Block a user