mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
* correctly calculated growths (including castles and horde structures)
* giving daily income
This commit is contained in:
parent
a729484dde
commit
fb5c26437c
@ -61,16 +61,12 @@ void CCallback::newTurn()
|
|||||||
{
|
{
|
||||||
for(int k=0;k<CREATURES_PER_TOWN;k++)
|
for(int k=0;k<CREATURES_PER_TOWN;k++)
|
||||||
{
|
{
|
||||||
int growth;
|
if(i->second.towns[j]->creatureDwelling(k))//there is dwelling
|
||||||
if(i->second.towns[j]->creatureDwelling(k))//basic growth
|
i->second.towns[j]->strInfo.creatures[k]+=i->second.towns[j]->creatureGrowth(k);
|
||||||
growth=CGI->creh->creatures[i->second.towns[j]->town->basicCreatures[k]].growth;
|
|
||||||
if(i->second.towns[j]->builtBuildings.find(9)!=i->second.towns[j]->builtBuildings.end()) //castle +100%
|
|
||||||
growth*=2;
|
|
||||||
else if(i->second.towns[j]->builtBuildings.find(9)!=i->second.towns[j]->builtBuildings.end()) //castle +100%
|
|
||||||
growth*=1.5;
|
|
||||||
i->second.towns[j]->strInfo.creatures[k]+=growth;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if((gs->day>1) && i->first<PLAYER_LIMIT)
|
||||||
|
i->second.resources[6]+=i->second.towns[j]->dailyIncome();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
18
config/building_horde.txt
Normal file
18
config/building_horde.txt
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
0 1 2
|
||||||
|
0 2 -1
|
||||||
|
1 1 1
|
||||||
|
1 2 4
|
||||||
|
2 1 1
|
||||||
|
2 2 -1
|
||||||
|
3 1 0
|
||||||
|
3 2 2
|
||||||
|
4 1 0
|
||||||
|
4 2 -1
|
||||||
|
5 1 0
|
||||||
|
5 2 -1
|
||||||
|
6 1 0
|
||||||
|
6 2 -1
|
||||||
|
7 1 0
|
||||||
|
7 2 -1
|
||||||
|
8 1 0
|
||||||
|
8 2 -1
|
@ -9,6 +9,7 @@
|
|||||||
#include "../CLua.h"
|
#include "../CLua.h"
|
||||||
#include "CHeroHandler.h"
|
#include "CHeroHandler.h"
|
||||||
#include <boost/algorithm/string/replace.hpp>
|
#include <boost/algorithm/string/replace.hpp>
|
||||||
|
#include "CTownHandler.h"
|
||||||
void CObjectHandler::loadObjects()
|
void CObjectHandler::loadObjects()
|
||||||
{
|
{
|
||||||
int ID=0;
|
int ID=0;
|
||||||
@ -272,13 +273,25 @@ bool CGTownInstance::creatureDwelling(int level, bool upgraded) const
|
|||||||
}
|
}
|
||||||
int CGTownInstance::getHordeLevel(int HID) const//HID - 0 or 1; returns creature level or -1 if that horde structure is not present
|
int CGTownInstance::getHordeLevel(int HID) const//HID - 0 or 1; returns creature level or -1 if that horde structure is not present
|
||||||
{
|
{
|
||||||
//TODO: write
|
return town->hordeLvl[HID];
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
int CGTownInstance::creatureGrowth(int level) const
|
int CGTownInstance::creatureGrowth(int level) const
|
||||||
{
|
{
|
||||||
//TODO: write
|
int ret = CGI->creh->creatures[town->basicCreatures[level]].growth;
|
||||||
return -1;
|
switch(fortLevel())
|
||||||
|
{
|
||||||
|
case 3:
|
||||||
|
ret*=2;break;
|
||||||
|
case 2:
|
||||||
|
ret*=(1.5); break;
|
||||||
|
}
|
||||||
|
if(getHordeLevel(0)==level)
|
||||||
|
if((builtBuildings.find(18)!=builtBuildings.end()) || (builtBuildings.find(19)!=builtBuildings.end()))
|
||||||
|
ret+=CGI->creh->creatures[town->basicCreatures[level]].hordeGrowth;
|
||||||
|
if(getHordeLevel(1)==level)
|
||||||
|
if((builtBuildings.find(24)!=builtBuildings.end()) || (builtBuildings.find(25)!=builtBuildings.end()))
|
||||||
|
ret+=CGI->creh->creatures[town->basicCreatures[level]].hordeGrowth;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
int CGTownInstance::dailyIncome() const
|
int CGTownInstance::dailyIncome() const
|
||||||
{
|
{
|
||||||
|
@ -240,6 +240,15 @@ void CTownHandler::loadNames()
|
|||||||
of.close();
|
of.close();
|
||||||
of.clear();
|
of.clear();
|
||||||
|
|
||||||
|
of.open("config/building_horde.txt");
|
||||||
|
while(!of.eof())
|
||||||
|
{
|
||||||
|
int tid, lid, cid; //town,horde serial,creature level
|
||||||
|
of >> tid >> lid >> cid;
|
||||||
|
towns[tid].hordeLvl[--lid] = cid;
|
||||||
|
}
|
||||||
|
of.close();
|
||||||
|
of.clear();
|
||||||
|
|
||||||
of.open("config/requirements.txt");
|
of.open("config/requirements.txt");
|
||||||
while(!of.eof())
|
while(!of.eof())
|
||||||
|
@ -19,6 +19,7 @@ public:
|
|||||||
std::vector<std::string> names; //names of the town instances
|
std::vector<std::string> names; //names of the town instances
|
||||||
std::vector<int> basicCreatures; //level (from 0) -> ID
|
std::vector<int> basicCreatures; //level (from 0) -> ID
|
||||||
std::vector<int> upgradedCreatures; //level (from 0) -> ID
|
std::vector<int> upgradedCreatures; //level (from 0) -> ID
|
||||||
|
std::map<int,int> hordeLvl; //[0] - first horde building creature level; [1] - second horde building (-1 if not present)
|
||||||
int bonus; //pic number
|
int bonus; //pic number
|
||||||
int typeID;
|
int typeID;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user