From 6b812b847bea1ce7084b4ebd7975019f371b70a4 Mon Sep 17 00:00:00 2001 From: mateuszb Date: Fri, 15 Jun 2007 16:50:02 +0000 Subject: [PATCH] =?UTF-8?q?wczytywanie=20tabliczek,=20potwor=C3=B3w,=20boh?= =?UTF-8?q?ater=C3=B3w=20i=20seer=20hut=C3=B3w=20(na=20razie=20niestety=20?= =?UTF-8?q?jeszcze=20bez=20nagr=C3=B3d)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ilość wykomentowanych linii w CAmbarCendamo.cpp wzrosÅ‚a do okoÅ‚o 450 ;] --- CAmbarCendamo.cpp | 279 ++++++++++++++++++++++++++++++++++++++++++++-- CAmbarCendamo.h | 2 +- CObjectHandler.h | 51 ++++++++- 3 files changed, 323 insertions(+), 9 deletions(-) diff --git a/CAmbarCendamo.cpp b/CAmbarCendamo.cpp index 0f5a067b4..b5a2253d8 100644 --- a/CAmbarCendamo.cpp +++ b/CAmbarCendamo.cpp @@ -405,8 +405,8 @@ void CAmbarCendamo::deh3m() } THC std::cout<<"Wczytywanie defow: "<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; ttmessage += 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; rrmessage += 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; yym5arts.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; hhm6cre.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; eefirstVisitText += bufor[i]; ++i; + } + + int len2 = readNormalNr(i); i+=4; + for(int ee=0; eenextVisitText += bufor[i]; ++i; + } + + int len3 = readNormalNr(i); i+=4; + for(int ee=0; eecompletedText += 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: diff --git a/CAmbarCendamo.h b/CAmbarCendamo.h index c5721a301..de7f35e0c 100644 --- a/CAmbarCendamo.h +++ b/CAmbarCendamo.h @@ -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 { diff --git a/CObjectHandler.h b/CObjectHandler.h index 8cf6d4aa8..abd0914fc 100644 --- a/CObjectHandler.h +++ b/CObjectHandler.h @@ -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 abilities; //hero's abilities std::vector 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 m5arts; + //for mission 6 + std::vector m6cre; + std::vector 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