1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

wczytywanie tabliczek, potworów, bohaterów i seer hutów (na razie niestety jeszcze bez nagród)

ilość wykomentowanych linii w CAmbarCendamo.cpp wzrosła do około 450 ;]
This commit is contained in:
mateuszb 2007-06-15 16:50:02 +00:00
parent 66529e4249
commit 6b812b847b
3 changed files with 323 additions and 9 deletions

View File

@ -405,8 +405,8 @@ void CAmbarCendamo::deh3m()
}
THC std::cout<<"Wczytywanie defow: "<<th.getDif()<<std::endl;
////loading objects
int howManyObjs = readNormalNr(i, 4); i+=4;
/*for(int ww=0; ww<howManyObjs; ++ww) //comment this line to turn loading objects off
/*int howManyObjs = readNormalNr(i, 4); i+=4;
for(int ww=0; ww<howManyObjs; ++ww) //comment this line to turn loading objects off
{
CObjectInstance nobj; //we will read this object
nobj.id = CGameInfo::mainObj->objh->objInstances.size();
@ -690,22 +690,281 @@ void CAmbarCendamo::deh3m()
{
if((i-ist)*8+yy < CGameInfo::mainObj->spellh->spells.size())
{
if(c != (c|((unsigned char)intPow(2, yy))))
spec->spells.push_back(&(CGameInfo::mainObj->spellh->spells[(i-ist)*8+yy]))
if(c == (c|((unsigned char)intPow(2, yy))))
spec->spells.push_back(&(CGameInfo::mainObj->spellh->spells[(i-ist)*8+yy]));
}
}
}
i+=9;
}
//spells loaded
spec->defaultMianStats = bufor[i]; ++i;
if(spec->defaultMianStats)
{
spec->attack = bufor[i]; ++i;
spec->defence = bufor[i]; ++i;
spec->power = bufor[i]; ++i;
spec->knowledge = bufor[i]; ++i;
}
i+=16;
nobj.info = spec;
break;
}
case CREATURES_DEF:
{
CCreatureObjInfo * spec = new CCreatureObjInfo;
spec->bytes[0] = bufor[i]; ++i;
spec->bytes[1] = bufor[i]; ++i;
spec->bytes[2] = bufor[i]; ++i;
spec->bytes[3] = bufor[i]; ++i;
spec->number = readNormalNr(i, 2); i+=2;
spec->character = bufor[i]; ++i;
bool isMesTre = bufor[i]; ++i; //true if there is message or treasury
if(isMesTre)
{
int messLength = readNormalNr(i); i+=4;
if(messLength>0)
{
for(int tt=0; tt<messLength; ++tt)
{
spec->message += bufor[i]; ++i;
}
}
spec->wood = readNormalNr(i); i+=4;
spec->mercury = readNormalNr(i); i+=4;
spec->ore = readNormalNr(i); i+=4;
spec->sulfur = readNormalNr(i); i+=4;
spec->crytal = readNormalNr(i); i+=4;
spec->gems = readNormalNr(i); i+=4;
spec->gold = readNormalNr(i); i+=4;
int artID = readNormalNr(i, 2); i+=2;
if(artID!=0xffff)
spec->gainedArtifact = &(CGameInfo::mainObj->arth->artifacts[artID]);
else
spec->gainedArtifact = NULL;
}
spec->neverFlees = bufor[i]; ++i;
spec->notGrowingTeam = bufor[i]; ++i;
i+=2;
nobj.info = spec;
break;
}
case EDefType::SIGN_DEF:
{
CSignObjInfo * spec = new CSignObjInfo;
int length = readNormalNr(i); i+=4;
for(int rr=0; rr<length; ++rr)
{
spec->message += bufor[i]; ++i;
}
i+=4;
nobj.info = spec;
break;
}
case EDefType::SEERHUT_DEF:
{
CSeerHutObjInfo * spec = new CSeerHutObjInfo;
spec->missionType = bufor[i]; ++i;
switch(spec->missionType)
{
case 1:
{
spec->m1level = readNormalNr(i); i+=4;
int limit = readNormalNr(i); i+=4;
if(limit == ((int)0xffffffff))
{
spec->isDayLimit = false;
spec->lastDay = -1;
}
else
{
spec->isDayLimit = true;
spec->lastDay = limit;
}
break;
}
case 2:
{
spec->m2attack = bufor[i]; ++i;
spec->m2defence = bufor[i]; ++i;
spec->m2power = bufor[i]; ++i;
spec->m2knowledge = bufor[i]; ++i;
int limit = readNormalNr(i); i+=4;
if(limit == ((int)0xffffffff))
{
spec->isDayLimit = false;
spec->lastDay = -1;
}
else
{
spec->isDayLimit = true;
spec->lastDay = limit;
}
break;
}
case 3:
{
spec->m3bytes[0] = bufor[i]; ++i;
spec->m3bytes[1] = bufor[i]; ++i;
spec->m3bytes[2] = bufor[i]; ++i;
spec->m3bytes[3] = bufor[i]; ++i;
int limit = readNormalNr(i); i+=4;
if(limit == ((int)0xffffffff))
{
spec->isDayLimit = false;
spec->lastDay = -1;
}
else
{
spec->isDayLimit = true;
spec->lastDay = limit;
}
break;
}
case 4:
{
spec->m4bytes[0] = bufor[i]; ++i;
spec->m4bytes[1] = bufor[i]; ++i;
spec->m4bytes[2] = bufor[i]; ++i;
spec->m4bytes[3] = bufor[i]; ++i;
int limit = readNormalNr(i); i+=4;
if(limit == ((int)0xffffffff))
{
spec->isDayLimit = false;
spec->lastDay = -1;
}
else
{
spec->isDayLimit = true;
spec->lastDay = limit;
}
break;
}
case 5:
{
int artNumber = bufor[i]; ++i;
for(int yy=0; yy<artNumber; ++yy)
{
int artid = readNormalNr(i, 2); i+=2;
spec->m5arts.push_back(&(CGameInfo::mainObj->arth->artifacts[artid]));
}
int limit = readNormalNr(i); i+=4;
if(limit == ((int)0xffffffff))
{
spec->isDayLimit = false;
spec->lastDay = -1;
}
else
{
spec->isDayLimit = true;
spec->lastDay = limit;
}
break;
}
case 6:
{
int typeNumber = bufor[i]; ++i;
for(int hh=0; hh<typeNumber; ++hh)
{
int creType = readNormalNr(i, 2); i+=2;
int creNumb = readNormalNr(i, 2); i+=2;
spec->m6cre.push_back(&(CGameInfo::mainObj->creh->creatures[creType]));
spec->m6number.push_back(creNumb);
}
int limit = readNormalNr(i); i+=4;
if(limit == ((int)0xffffffff))
{
spec->isDayLimit = false;
spec->lastDay = -1;
}
else
{
spec->isDayLimit = true;
spec->lastDay = limit;
}
break;
}
case 7:
{
spec->m7wood = readNormalNr(i); i+=4;
spec->m7mercury = readNormalNr(i); i+=4;
spec->m7ore = readNormalNr(i); i+=4;
spec->m7sulfur = readNormalNr(i); i+=4;
spec->m7crystal = readNormalNr(i); i+=4;
spec->m7gems = readNormalNr(i); i+=4;
spec->m7gold = readNormalNr(i); i+=4;
int limit = readNormalNr(i); i+=4;
if(limit == ((int)0xffffffff))
{
spec->isDayLimit = false;
spec->lastDay = -1;
}
else
{
spec->isDayLimit = true;
spec->lastDay = limit;
}
break;
}
case 8:
{
int heroType = bufor[i]; ++i;
spec->m8hero = &(CGameInfo::mainObj->heroh->heroes[heroType]);
int limit = readNormalNr(i); i+=4;
if(limit == ((int)0xffffffff))
{
spec->isDayLimit = false;
spec->lastDay = -1;
}
else
{
spec->isDayLimit = true;
spec->lastDay = limit;
}
break;
}
case 9:
{
spec->m9player = bufor[i]; ++i;
int limit = readNormalNr(i); i+=4;
if(limit == ((int)0xffffffff))
{
spec->isDayLimit = false;
spec->lastDay = -1;
}
else
{
spec->isDayLimit = true;
spec->lastDay = limit;
}
break;
}
}//internal switch end (seer huts)
int len1 = readNormalNr(i); i+=4;
for(int ee=0; ee<len1; ++ee)
{
spec->firstVisitText += bufor[i]; ++i;
}
int len2 = readNormalNr(i); i+=4;
for(int ee=0; ee<len2; ++ee)
{
spec->nextVisitText += bufor[i]; ++i;
}
int len3 = readNormalNr(i); i+=4;
for(int ee=0; ee<len3; ++ee)
{
spec->completedText += bufor[i]; ++i;
}
nobj.info = spec;
break;
}
}
} //end of main switch
CGameInfo::mainObj->objh->objInstances.push_back(nobj);
//TODO - dokoñczyæ, du¿o do zrobienia - trzeba patrzeæ, co def niesie
}//*/ //end of loading objects; commented to making application work until it will be finished
}//*/ //end of loading objects; commented to make application work until it will be finished
////objects loaded
//todo: read events
}
@ -754,12 +1013,18 @@ EDefType CAmbarCendamo::getDefType(DefInfo &a)
{
switch(a.bytes[16])
{
case 5:
return EDefType::ARTIFACT_DEF;
case 26:
return EDefType::EVENTOBJ_DEF;
case 33:
return EDefType::GARRISON_DEF;
case 34:
return EDefType::HERO_DEF;
case 54:
return EDefType::CREATURES_DEF;
case 59:
return EDefType::SIGN_DEF;
case 79:
return EDefType::RESOURCE_DEF;
case 83:

View File

@ -10,7 +10,7 @@
#include "CSemiDefHandler.h"
#include "CCreatureHandler.h"
enum EDefType {TOWN_DEF, HERO_DEF, CREATURES_DEF, SEERHUT_DEF, RESOURCE_DEF, TERRAINOBJ_DEF, EVENTOBJ_DEF, SIGN_DEF, GARRISON_DEF};
enum EDefType {TOWN_DEF, HERO_DEF, CREATURES_DEF, SEERHUT_DEF, RESOURCE_DEF, TERRAINOBJ_DEF, EVENTOBJ_DEF, SIGN_DEF, GARRISON_DEF, ARTIFACT_DEF};
class CAmbarCendamo
{

View File

@ -42,7 +42,7 @@ public:
class CHeroObjInfo : public CSpecObjInfo
{
public:
char bytes[4]; //mysterius bytes identifying hero in a strange way
unsigned char bytes[4]; //mysterius bytes identifying hero in a strange way
int player;
CHero * type;
std::string name; //if nonstandard
@ -59,6 +59,55 @@ public:
unsigned int experience; //hero's experience points
std::vector<CAbility *> abilities; //hero's abilities
std::vector<int> abilityLevels; //hero ability levels
bool defaultMianStats; //if true attack, defence, power and knowledge are typical
};
class CCreatureObjInfo : public CSpecObjInfo
{
public:
unsigned char bytes[4]; //mysterious bytes identifying creature
unsigned int number; //number of units (0 - random)
unsigned char character; //chracter of this set of creatures (0 - the most friendly, 4 - the most hostile)
std::string message; //message printed for attacking hero
int wood, mercury, ore, sulfur, crytal, gems, gold; //resources gained to hero that has won with monsters
CArtifact * gainedArtifact; //artifact gained to hero
bool neverFlees; //if true, the troops will never flee
bool notGrowingTeam; //if true, number of units won't grow
};
class CSignObjInfo : public CSpecObjInfo
{
public:
std::string message; //message
};
class CSeerHutObjInfo : public CSpecObjInfo
{
public:
char missionType; //type of mission: 0 - no mission; 1 - reach level; 2 - reach main statistics values; 3 - win with a certain hero; 4 - win with a certain creature; 5 - collect some atifacts; 6 - have certain troops in army; 7 - collect resources; 8 - be a certain hero; 9 - be a certain player
bool isDayLimit; //if true, there is a day limit
int lastDay; //after this day (first day is 0) mission cannot be completed
//for mission 1
int m1level;
//for mission 2
int m2attack, m2defence, m2power, m2knowledge;
//for mission 3
unsigned char m3bytes[4];
//for mission 4
unsigned char m4bytes[4];
//for mission 5
std::vector<CArtifact *> m5arts;
//for mission 6
std::vector<CCreature *> m6cre;
std::vector<int> m6number;
//for mission 7
int m7wood, m7mercury, m7ore, m7sulfur, m7crystal, m7gems, m7gold;
//for mission 8
CHero * m8hero;
//for mission 9
int m9player; //number; from 0 to 7
std::string firstVisitText, nextVisitText, completedText;
};
class CObject //typical object that can be encountered on a map