mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
Support for #448. Few code tweaks.
This commit is contained in:
parent
57b4bc6c67
commit
1159750bb6
@ -1564,6 +1564,11 @@ int CGTownInstance::creatureGrowth(const int & level) const
|
||||
if(tempOwner != NEUTRAL_PLAYER)
|
||||
{
|
||||
ret *= (1 + cb->gameState()->players[tempOwner].valOfBonuses(Bonus::CREATURE_GROWTH_PERCENT)/100); //Statue of Legion
|
||||
for (std::vector<CGDwelling*>::const_iterator it = cb->gameState()->players[tempOwner].dwellings.begin(); it != cb->gameState()->players[tempOwner].dwellings.end(); ++it)
|
||||
{ //+1 for each dwelling
|
||||
if (VLC->creh->creatures[town->basicCreatures[level]]->idNumber == (*it)->creatures[0].second[0])
|
||||
++ret;
|
||||
}
|
||||
}
|
||||
if(getHordeLevel(0)==level)
|
||||
if((builtBuildings.find(18)!=builtBuildings.end()) || (builtBuildings.find(19)!=builtBuildings.end()))
|
||||
@ -1577,11 +1582,6 @@ int CGTownInstance::creatureGrowth(const int & level) const
|
||||
ret += garrisonHero->valOfBonuses(Bonus::CREATURE_GROWTH, level);
|
||||
if(visitingHero)
|
||||
ret += visitingHero->valOfBonuses(Bonus::CREATURE_GROWTH, level);
|
||||
for (std::vector<CGDwelling*>::const_iterator it = cb->gameState()->players[tempOwner].dwellings.begin(); it != cb->gameState()->players[tempOwner].dwellings.end(); ++it)
|
||||
{ //+1 for each dwelling
|
||||
if (VLC->creh->creatures[town->basicCreatures[level]]->idNumber == (*it)->creatures[0].second[0])
|
||||
++ret;
|
||||
}
|
||||
if(builtBuildings.find(26)!=builtBuildings.end()) //grail - +50% to ALL growth
|
||||
ret*=1.5;
|
||||
return ret;//check CCastleInterface.cpp->CCastleInterface::CCreaInfo::clickRight if this one will be modified
|
||||
@ -1766,6 +1766,54 @@ void CGTownInstance::newTurn() const
|
||||
if ((*i)->ID == 21)
|
||||
cb->setObjProperty (id, 12, (*i)->id); //reset visitors for Mana Vortex
|
||||
}
|
||||
|
||||
if (tempOwner == NEUTRAL_PLAYER) //garrison growth for neutral towns
|
||||
{
|
||||
TSlots slt = Slots(); //meh, waste of time
|
||||
std::vector<ui8> nativeCrits; //slots
|
||||
for (TSlots::const_iterator it = slt.begin(); it != slt.end(); it++)
|
||||
{
|
||||
if (it->second.type->faction == subID) //native
|
||||
{
|
||||
nativeCrits.push_back(it->first); //collect matching slots
|
||||
}
|
||||
}
|
||||
if (nativeCrits.size())
|
||||
{
|
||||
int pos = nativeCrits[rand() % nativeCrits.size()];
|
||||
if (rand()%100 < 90 || slt[pos].type->upgrades.empty()) //increase number if no upgrade avaliable
|
||||
{
|
||||
SetGarrisons sg;
|
||||
sg.garrs[id] = getArmy();
|
||||
sg.garrs[id].slots[pos].count += slt[pos].type->growth;
|
||||
cb->sendAndApply(&sg);
|
||||
}
|
||||
else //upgrade
|
||||
{
|
||||
SetGarrisons sg; //somewhat better upgrade pack would come in handy
|
||||
sg.garrs[id] = getArmy();
|
||||
sg.garrs[id].setCreature(pos, *slt[pos].type->upgrades.begin(), slt[pos].count);
|
||||
cb->sendAndApply(&sg);
|
||||
}
|
||||
}
|
||||
if ((stacksCount() < ARMY_SIZE && rand()%100 < 25) || slt.empty()) //add new stack
|
||||
{
|
||||
int n, i = rand() % std::min (ARMY_SIZE, cb->getDate(3)<<1);
|
||||
{//no lower tiers or above current month
|
||||
|
||||
if (n = getSlotFor(town->basicCreatures[i], ARMY_SIZE));
|
||||
{
|
||||
SetGarrisons sg;
|
||||
sg.garrs[id] = getArmy();
|
||||
if (slotEmpty(n))
|
||||
sg.garrs[id].setCreature (n, town->basicCreatures[i], creatureGrowth(i)); //if the stack is not yet present
|
||||
else
|
||||
sg.garrs[id].addToSlot(n, town->basicCreatures[i], creatureGrowth(i)); //add to existing
|
||||
cb->sendAndApply(&sg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1125,23 +1125,23 @@ int CGameState::getDate(int mode) const
|
||||
int temp;
|
||||
switch (mode)
|
||||
{
|
||||
case 0:
|
||||
case 0: //day number
|
||||
return day;
|
||||
break;
|
||||
case 1:
|
||||
case 1: //day of week
|
||||
temp = (day)%7;
|
||||
if (temp)
|
||||
return temp;
|
||||
else return 7;
|
||||
break;
|
||||
case 2:
|
||||
case 2: //current week
|
||||
temp = ((day-1)/7)+1;
|
||||
if (!(temp%4))
|
||||
return 4;
|
||||
else
|
||||
return (temp%4);
|
||||
break;
|
||||
case 3:
|
||||
case 3: //current month
|
||||
return ((day-1)/28)+1;
|
||||
break;
|
||||
}
|
||||
|
@ -992,9 +992,9 @@ void CGameHandler::newTurn()
|
||||
ui8 player = (*j)->tempOwner;
|
||||
if(gs->getDate(1)==7) //first day of week
|
||||
{
|
||||
if ( (**j).subID == 1 && gs->getDate(0) && player < PLAYER_LIMIT
|
||||
&& vstd::contains((**j).builtBuildings,22) )//dwarven treasury
|
||||
if ((**j).subID == 1 && gs->getDate(0) && player < PLAYER_LIMIT && vstd::contains((**j).builtBuildings, 22))//dwarven treasury
|
||||
n.res[player][6] += hadGold[player]/10; //give 10% of starting gold
|
||||
|
||||
SetAvailableCreatures sac;
|
||||
sac.tid = (**j).id;
|
||||
sac.creatures = (**j).creatures;
|
||||
|
Loading…
Reference in New Issue
Block a user