From fb5c26437cc4b0de7a32af5f202a4a5b513d7d28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=2E=20Urba=C5=84czyk?= Date: Mon, 14 Apr 2008 17:45:01 +0000 Subject: [PATCH] * correctly calculated growths (including castles and horde structures) * giving daily income --- CCallback.cpp | 12 ++++-------- config/building_horde.txt | 18 ++++++++++++++++++ hch/CObjectHandler.cpp | 21 +++++++++++++++++---- hch/CTownHandler.cpp | 9 +++++++++ hch/CTownHandler.h | 1 + 5 files changed, 49 insertions(+), 12 deletions(-) create mode 100644 config/building_horde.txt diff --git a/CCallback.cpp b/CCallback.cpp index fe4fd591a..28dd65420 100644 --- a/CCallback.cpp +++ b/CCallback.cpp @@ -61,16 +61,12 @@ void CCallback::newTurn() { for(int k=0;ksecond.towns[j]->creatureDwelling(k))//basic growth - 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(i->second.towns[j]->creatureDwelling(k))//there is dwelling + i->second.towns[j]->strInfo.creatures[k]+=i->second.towns[j]->creatureGrowth(k); } } + if((gs->day>1) && i->firstsecond.resources[6]+=i->second.towns[j]->dailyIncome(); } } } diff --git a/config/building_horde.txt b/config/building_horde.txt new file mode 100644 index 000000000..2972638aa --- /dev/null +++ b/config/building_horde.txt @@ -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 \ No newline at end of file diff --git a/hch/CObjectHandler.cpp b/hch/CObjectHandler.cpp index 4c3437ea4..8b5958b67 100644 --- a/hch/CObjectHandler.cpp +++ b/hch/CObjectHandler.cpp @@ -9,6 +9,7 @@ #include "../CLua.h" #include "CHeroHandler.h" #include +#include "CTownHandler.h" void CObjectHandler::loadObjects() { 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 { - //TODO: write - return -1; + return town->hordeLvl[HID]; } int CGTownInstance::creatureGrowth(int level) const { - //TODO: write - return -1; + int ret = CGI->creh->creatures[town->basicCreatures[level]].growth; + 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 { diff --git a/hch/CTownHandler.cpp b/hch/CTownHandler.cpp index 119dc7128..80fda64c0 100644 --- a/hch/CTownHandler.cpp +++ b/hch/CTownHandler.cpp @@ -240,6 +240,15 @@ void CTownHandler::loadNames() of.close(); 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"); while(!of.eof()) diff --git a/hch/CTownHandler.h b/hch/CTownHandler.h index 5706adacb..64fcd5b27 100644 --- a/hch/CTownHandler.h +++ b/hch/CTownHandler.h @@ -19,6 +19,7 @@ public: std::vector names; //names of the town instances std::vector basicCreatures; //level (from 0) -> ID std::vector upgradedCreatures; //level (from 0) -> ID + std::map hordeLvl; //[0] - first horde building creature level; [1] - second horde building (-1 if not present) int bonus; //pic number int typeID; };