mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
Implemented neutral army growth by 10% weekly, up to 4000.
This commit is contained in:
parent
2a99bc76da
commit
627a1a5905
2
global.h
2
global.h
@ -100,6 +100,8 @@ const int NAMES_PER_TOWN=16;
|
||||
const int CREATURES_PER_TOWN = 7; //without upgrades
|
||||
const int MAX_BUILDING_PER_TURN = 1;
|
||||
const int SPELL_LEVELS = 5;
|
||||
const int CREEP_SIZE = 4000; // neutral stacks won't grow beyon this number
|
||||
const int WEEKLY_GROWTH = 10; //percent
|
||||
|
||||
#define BFIELD_WIDTH (17)
|
||||
#define BFIELD_HEIGHT (11)
|
||||
|
@ -2433,6 +2433,7 @@ void CGCreature::endBattle( BattleResult *result ) const
|
||||
pom = 174 + 3*pom + 1;
|
||||
ms << std::pair<ui8,ui32>(6,pom) << " " << std::pair<ui8,ui32>(7,subID);
|
||||
cb->setHoverName(id,&ms);
|
||||
cb->setObjProperty(id, 11, slots.begin()->second.count * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2472,6 +2473,28 @@ void CGCreature::initObj()
|
||||
pom = 174 + 3*pom + 1;
|
||||
ms << std::pair<ui8,ui32>(6,pom) << " " << std::pair<ui8,ui32>(7,subID);
|
||||
ms.toString(hoverName);
|
||||
temppower = slots[0].count * 1000;
|
||||
}
|
||||
void CGCreature::newTurn() const
|
||||
{//Works only for stacks of single type of size up to 2 millions
|
||||
if (slots.begin()->second.count < CREEP_SIZE && cb->getDate(1) == 1)
|
||||
{
|
||||
ui32 power = temppower * (100 + WEEKLY_GROWTH)/100;
|
||||
cb->setObjProperty(id, 10, std::min (power/1000 , (ui32)CREEP_SIZE)); //set new amount
|
||||
cb->setObjProperty(id, 11, power); //increase temppower
|
||||
}
|
||||
}
|
||||
void CGCreature::setPropertyDer(ui8 what, ui32 val)
|
||||
{
|
||||
switch (what)
|
||||
{
|
||||
case 10:
|
||||
slots[0].count = val;
|
||||
break;
|
||||
case 11:
|
||||
temppower = val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int CGCreature::takenAction(const CGHeroInstance *h, bool allowJoin) const
|
||||
@ -5560,10 +5583,15 @@ int3 IBoatGenerator::bestLocation() const
|
||||
getOutOffsets(offsets);
|
||||
|
||||
TerrainTile *tile;
|
||||
for(int i = 0; i < offsets.size(); i++)
|
||||
if((tile = IObjectInterface::cb->getTile(o->pos + offsets[i])) && tile->tertype == TerrainTile::water) //tile is in the map and is water
|
||||
return o->pos + offsets[i];
|
||||
return int3(-1,-1,-1);
|
||||
for (int i = 0; i < offsets.size(); ++i)
|
||||
{
|
||||
if (tile = IObjectInterface::cb->getTile(o->pos + offsets[i])) //tile is in the map
|
||||
{
|
||||
if (tile->tertype == TerrainTile::water) //and is water
|
||||
return o->pos + offsets[i];
|
||||
}
|
||||
}
|
||||
return int3 (-1,-1,-1);
|
||||
}
|
||||
|
||||
int IBoatGenerator::state() const
|
||||
@ -5633,8 +5661,8 @@ CGShipyard::CGShipyard()
|
||||
|
||||
void CGShipyard::getOutOffsets( std::vector<int3> &offsets ) const
|
||||
{
|
||||
offsets += int3(1,0,0), int3(-3,0,0), int3(1,1,0), int3(-3,1,0), int3(1,-1,0), int3(-3,-1,0),
|
||||
int3(-2,-1,0), int3(0,-1,0), int3(-1,-1,0), int3(-2,1,0), int3(0,1,0), int3(-1,1,0);
|
||||
offsets += int3(1,0,0), int3(-3,0,0), int3(-3,1,0), int3(-2,1,0), int3(1,1,0), int3(1,-1,0), int3(-3,-1,0),
|
||||
int3(-2,-1,0), int3(0,-1,0), int3(-1,-1,0), int3(0,1,0), int3(-1,1,0);
|
||||
}
|
||||
|
||||
void CGShipyard::onHeroVisit( const CGHeroInstance * h ) const
|
||||
|
@ -609,6 +609,7 @@ public:
|
||||
si32 gainedArtifact; //ID of artifact gained to hero, -1 if none
|
||||
ui8 neverFlees; //if true, the troops will never flee
|
||||
ui8 notGrowingTeam; //if true, number of units won't grow
|
||||
ui32 temppower; //used to handle fractional stack growth for tiny stacks
|
||||
|
||||
void fight(const CGHeroInstance *h) const;
|
||||
void onHeroVisit(const CGHeroInstance * h) const;
|
||||
@ -619,12 +620,14 @@ public:
|
||||
void fleeDecision(const CGHeroInstance *h, ui32 pursue) const;
|
||||
void joinDecision(const CGHeroInstance *h, int cost, ui32 accept) const;
|
||||
void initObj();
|
||||
void newTurn() const;
|
||||
void setPropertyDer(ui8 what, ui32 val);
|
||||
int takenAction(const CGHeroInstance *h, bool allowJoin=true) const; //action on confrontation: -2 - fight, -1 - flee, >=0 - will join for given value of gold (may be 0)
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & static_cast<CArmedInstance&>(*this);
|
||||
h & identifier & character & message & resources & gainedArtifact & neverFlees & notGrowingTeam;
|
||||
h & identifier & character & message & resources & gainedArtifact & neverFlees & notGrowingTeam & temppower;
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user