mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
Added feature #111 - external dwellings increase town growth.
This commit is contained in:
parent
7471372074
commit
e4417e9204
@ -1201,8 +1201,6 @@ void CGHeroInstance::recreateArtBonuses()
|
||||
|
||||
void CGDwelling::initObj()
|
||||
{
|
||||
if (getOwner() != 255)
|
||||
cb->gameState()->players[getOwner()].dwellings.push_back (this);
|
||||
switch(ID)
|
||||
{
|
||||
case 17:
|
||||
@ -1218,6 +1216,8 @@ void CGDwelling::initObj()
|
||||
army.slots[0].first = crs->idNumber;
|
||||
army.slots[0].second = (8 - crs->level) * 3;
|
||||
}
|
||||
if (getOwner() != 255)
|
||||
cb->gameState()->players[getOwner()].dwellings.push_back (this);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1258,6 +1258,25 @@ void CGDwelling::initObj()
|
||||
}
|
||||
}
|
||||
|
||||
void CGDwelling::setProperty(ui8 what, ui32 val)
|
||||
{
|
||||
switch (what)
|
||||
{
|
||||
case 1: //change owner
|
||||
if (ID == 17) //single generators
|
||||
{
|
||||
if (tempOwner != NEUTRAL_PLAYER)
|
||||
{
|
||||
std::vector<CGDwelling *>* dwellings = &cb->gameState()->players[tempOwner].dwellings;
|
||||
dwellings->erase (std::find(dwellings->begin(), dwellings->end(), this));
|
||||
}
|
||||
if (val != NEUTRAL_PLAYER) //can new owner be neutral?
|
||||
cb->gameState()->players[val].dwellings.push_back (this);
|
||||
}
|
||||
tempOwner = val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
void CGDwelling::onHeroVisit( const CGHeroInstance * h ) const
|
||||
{
|
||||
if(h->tempOwner != tempOwner && army.slots.size() > 0) //object is guarded
|
||||
@ -1275,12 +1294,7 @@ void CGDwelling::onHeroVisit( const CGHeroInstance * h ) const
|
||||
|
||||
if(h->tempOwner != tempOwner)
|
||||
{
|
||||
std::vector<CGDwelling *>* dwellings = &(cb->gameState()->players[tempOwner].dwellings);
|
||||
dwellings->erase (std::find(dwellings->begin(), dwellings->end(), this));
|
||||
cb->setOwner(id, h->tempOwner);
|
||||
dwellings = &(cb->gameState()->players[h->tempOwner].dwellings);
|
||||
//dwellings->push_back (this);
|
||||
//cb->gameState()->players[getOwner()].dwellings.push_back (this);
|
||||
}
|
||||
|
||||
BlockingDialog bd;
|
||||
@ -1497,7 +1511,11 @@ int CGTownInstance::creatureGrowth(const int & level) const
|
||||
ret += garrisonHero->valOfBonuses(HeroBonus::CREATURE_GROWTH, level);
|
||||
if(visitingHero)
|
||||
ret += visitingHero->valOfBonuses(HeroBonus::CREATURE_GROWTH, level);
|
||||
|
||||
for (std::vector<CGDwelling*>::const_iterator it = cb->gameState()->players[tempOwner].dwellings.begin(); it != cb->gameState()->players[tempOwner].dwellings.end(); ++it)
|
||||
{ //foreach?!
|
||||
if (VLC->creh->creatures[town->basicCreatures[level]].idNumber == (*it)->creatures[0].second[0])
|
||||
++ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int CGTownInstance::dailyIncome() const
|
||||
@ -4119,7 +4137,7 @@ void CBank::setPropertyDer (ui8 what, ui32 val)
|
||||
}
|
||||
break;
|
||||
default:
|
||||
tlog1 << "Error: Unexpected army data: " << bc->guards.size() <<" items found";
|
||||
tlog2 << "Error: Unexpected army data: " << bc->guards.size() <<" items found";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -329,6 +329,7 @@ public:
|
||||
}
|
||||
|
||||
void initObj();
|
||||
void setProperty(ui8 what, ui32 val);
|
||||
void onHeroVisit(const CGHeroInstance * h) const;
|
||||
void newTurn() const;
|
||||
void heroAcceptsCreatures(const CGHeroInstance *h, ui32 answer) const;
|
||||
|
@ -960,20 +960,30 @@ CGTownInstance *CGameState::getTown(int objid)
|
||||
return NULL;
|
||||
return static_cast<CGTownInstance *>(map->objects[objid]);
|
||||
}
|
||||
std::pair<int,int> CGameState::pickObject(CGObjectInstance *obj)
|
||||
std::pair<int,int> CGameState::pickObject (CGObjectInstance *obj)
|
||||
{
|
||||
switch(obj->ID)
|
||||
{
|
||||
case 65: //random artifact
|
||||
return std::pair<int,int>(5,(ran()%136)+7); //the only reasonable range - there are siege weapons and blanks we must ommit
|
||||
case 66: //random treasure artifact
|
||||
return std::pair<int,int>(5,VLC->arth->treasures[ran()%VLC->arth->treasures.size()]->id);
|
||||
return std::pair<int,int>(5,VLC->arth->treasures[ran()%VLC->arth->treasures.size()]->id);
|
||||
case 67: //random minor artifact
|
||||
return std::pair<int,int>(5,VLC->arth->minors[ran()%VLC->arth->minors.size()]->id);
|
||||
return std::pair<int,int>(5,VLC->arth->minors[ran()%VLC->arth->minors.size()]->id);
|
||||
case 68: //random major artifact
|
||||
return std::pair<int,int>(5,VLC->arth->majors[ran()%VLC->arth->majors.size()]->id);
|
||||
case 69: //random relic artifact
|
||||
return std::pair<int,int>(5,VLC->arth->relics[ran()%VLC->arth->relics.size()]->id);
|
||||
/*case 65: //random artifact //TODO: apply new randndomization system
|
||||
return std::pair<int,int>(5, cb.getRandomArt (CArtifact::ART_TREASURE | CArtifact::ART_MINOR | CArtifact::ART_MAJOR | CArtifact::ART_RELIC));
|
||||
case 66: //random treasure artifact
|
||||
return std::pair<int,int>(5, cb.getRandomArt (CArtifact::ART_TREASURE));
|
||||
case 67: //random minor artifact
|
||||
return std::pair<int,int>(5, cb.getRandomArt (CArtifact::ART_MINOR));
|
||||
case 68: //random major artifact
|
||||
return std::pair<int,int>(5, cb.getRandomArt (CArtifact::ART_MAJOR));
|
||||
case 69: //random relic artifact
|
||||
return std::pair<int,int>(5, cb.getRandomArt (CArtifact::ART_RELIC));*/
|
||||
case 70: //random hero
|
||||
{
|
||||
return std::pair<int,int>(HEROI_TYPE,pickHero(obj->tempOwner));
|
||||
|
Loading…
x
Reference in New Issue
Block a user