1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-17 01:32:21 +02:00

radical cleanups

This commit is contained in:
Michał W. Urbańczyk
2008-06-08 00:58:29 +00:00
parent feaa2396a6
commit 798fd11f65
15 changed files with 323 additions and 727 deletions

View File

@ -991,20 +991,20 @@ void CScriptCallback::giveHeroArtifact(int artid, int hid, int position) //pos==
{
if(!h->artifacts[i])
{
h->artifacts[i] = &CGI->arth->artifacts[artid];
h->artifacts[i] = artid;
return;
}
}
h->artifacts.push_back(&CGI->arth->artifacts[artid]);
h->artifacts.push_back(artid);
return;
}
else
{
if(h->artifWorn[position]) //slot is occupied
{
giveHeroArtifact(h->artifWorn[position]->id,hid,-1);
giveHeroArtifact(h->artifWorn[position],hid,-1);
}
h->artifWorn[position] = &CGI->arth->artifacts[artid];
h->artifWorn[position] = artid;
}
}

View File

@ -12,6 +12,8 @@
#include "hch\CObjectHandler.h"
#include "CMessage.h"
#include "CCallback.h"
#include "hch/CArtHandler.h"
#include "hch\CAbilityHandler.h"
#include <sstream>
extern SDL_Surface * screen;
@ -181,8 +183,9 @@ void CHeroWindow::show(SDL_Surface *to)
}
}
void CHeroWindow::setHero(const CGHeroInstance *hero)
void CHeroWindow::setHero(const CGHeroInstance *Hero)
{
CGHeroInstance *hero = const_cast<CGHeroInstance*>(Hero); //but don't modify hero! - it's only for easy map reading
if(!hero) //something strange... no hero? it shouldn't happen
{
return;
@ -259,7 +262,7 @@ void CHeroWindow::setHero(const CGHeroInstance *hero)
artWorn[8]->pos.y = 295;
artWorn[8]->pos.h = artWorn[8]->pos.w = 44;
if(hero->artifWorn[8])
artWorn[8]->text = hero->artifWorn[8]->description;
artWorn[8]->text = hero->getArt(8)->description;
else
artWorn[8]->text = std::string();
artWorn[8]->ourWindow = this;
@ -270,7 +273,7 @@ void CHeroWindow::setHero(const CGHeroInstance *hero)
artWorn[0]->pos.y = 30;
artWorn[0]->pos.h = artWorn[0]->pos.w = 44;
if(hero->artifWorn[0])
artWorn[0]->text = hero->artifWorn[0]->description;
artWorn[0]->text = hero->getArt(0)->description;
else
artWorn[0]->text = std::string();
artWorn[0]->ourWindow = this;
@ -281,7 +284,7 @@ void CHeroWindow::setHero(const CGHeroInstance *hero)
artWorn[4]->pos.y = 183;
artWorn[4]->pos.h = artWorn[4]->pos.w = 44;
if(hero->artifWorn[4])
artWorn[4]->text = hero->artifWorn[4]->description;
artWorn[4]->text = hero->getArt(4)->description;
else
artWorn[4]->text = std::string();
artWorn[4]->ourWindow = this;
@ -292,7 +295,7 @@ void CHeroWindow::setHero(const CGHeroInstance *hero)
artWorn[7]->pos.y = 183;
artWorn[7]->pos.h = artWorn[7]->pos.w = 44;
if(hero->artifWorn[7])
artWorn[7]->text = hero->artifWorn[7]->description;
artWorn[7]->text = hero->getArt(7)->description;
else
artWorn[7]->text = std::string();
artWorn[7]->ourWindow = this;
@ -303,7 +306,7 @@ void CHeroWindow::setHero(const CGHeroInstance *hero)
artWorn[13]->pos.y = 30;
artWorn[13]->pos.h = artWorn[13]->pos.w = 44;
if(hero->artifWorn[13])
artWorn[13]->text = hero->artifWorn[13]->description;
artWorn[13]->text = hero->getArt(13)->description;
else
artWorn[13]->text = std::string();
artWorn[13]->ourWindow = this;
@ -314,7 +317,7 @@ void CHeroWindow::setHero(const CGHeroInstance *hero)
artWorn[14]->pos.y = 30;
artWorn[14]->pos.h = artWorn[14]->pos.w = 44;
if(hero->artifWorn[14])
artWorn[14]->text = hero->artifWorn[14]->description;
artWorn[14]->text = hero->getArt(14)->description;
else
artWorn[14]->text = std::string();
artWorn[14]->ourWindow = this;
@ -325,7 +328,7 @@ void CHeroWindow::setHero(const CGHeroInstance *hero)
artWorn[15]->pos.y = 76;
artWorn[15]->pos.h = artWorn[15]->pos.w = 44;
if(hero->artifWorn[15])
artWorn[15]->text = hero->artifWorn[15]->description;
artWorn[15]->text = hero->getArt(15)->description;
else
artWorn[15]->text = std::string();
artWorn[15]->ourWindow = this;
@ -336,7 +339,7 @@ void CHeroWindow::setHero(const CGHeroInstance *hero)
artWorn[16]->pos.y = 122;
artWorn[16]->pos.h = artWorn[16]->pos.w = 44;
if(hero->artifWorn[16])
artWorn[16]->text = hero->artifWorn[16]->description;
artWorn[16]->text = hero->getArt(16)->description;
else
artWorn[16]->text = std::string();
artWorn[16]->ourWindow = this;
@ -347,7 +350,7 @@ void CHeroWindow::setHero(const CGHeroInstance *hero)
artWorn[9]->pos.y = 143;
artWorn[9]->pos.h = artWorn[9]->pos.w = 44;
if(hero->artifWorn[9])
artWorn[9]->text = hero->artifWorn[9]->description;
artWorn[9]->text = hero->getArt(9)->description;
else
artWorn[9]->text = std::string();
artWorn[9]->ourWindow = this;
@ -358,7 +361,7 @@ void CHeroWindow::setHero(const CGHeroInstance *hero)
artWorn[10]->pos.y = 194;
artWorn[10]->pos.h = artWorn[10]->pos.w = 44;
if(hero->artifWorn[10])
artWorn[10]->text = hero->artifWorn[10]->description;
artWorn[10]->text = hero->getArt(10)->description;
else
artWorn[10]->text = std::string();
artWorn[10]->ourWindow = this;
@ -369,7 +372,7 @@ void CHeroWindow::setHero(const CGHeroInstance *hero)
artWorn[11]->pos.y = 245;
artWorn[11]->pos.h = artWorn[11]->pos.w = 44;
if(hero->artifWorn[11])
artWorn[11]->text = hero->artifWorn[11]->description;
artWorn[11]->text = hero->getArt(11)->description;
else
artWorn[11]->text = std::string();
artWorn[11]->ourWindow = this;
@ -380,7 +383,7 @@ void CHeroWindow::setHero(const CGHeroInstance *hero)
artWorn[12]->pos.y = 296;
artWorn[12]->pos.h = artWorn[12]->pos.w = 44;
if(hero->artifWorn[12])
artWorn[12]->text = hero->artifWorn[12]->description;
artWorn[12]->text = hero->getArt(12)->description;
else
artWorn[12]->text = std::string();
artWorn[12]->ourWindow = this;
@ -391,7 +394,7 @@ void CHeroWindow::setHero(const CGHeroInstance *hero)
artWorn[18]->pos.y = 296;
artWorn[18]->pos.h = artWorn[18]->pos.w = 44;
if(hero->artifWorn[18])
artWorn[18]->text = hero->artifWorn[18]->description;
artWorn[18]->text = hero->getArt(18)->description;
else
artWorn[18]->text = std::string();
artWorn[18]->ourWindow = this;
@ -402,7 +405,7 @@ void CHeroWindow::setHero(const CGHeroInstance *hero)
artWorn[2]->pos.y = 79;
artWorn[2]->pos.h = artWorn[2]->pos.w = 44;
if(hero->artifWorn[2])
artWorn[2]->text = hero->artifWorn[2]->description;
artWorn[2]->text = hero->getArt(2)->description;
else
artWorn[2]->text = std::string();
artWorn[2]->ourWindow = this;
@ -413,7 +416,7 @@ void CHeroWindow::setHero(const CGHeroInstance *hero)
artWorn[3]->pos.y = 68;
artWorn[3]->pos.h = artWorn[3]->pos.w = 44;
if(hero->artifWorn[3])
artWorn[3]->text = hero->artifWorn[3]->description;
artWorn[3]->text = hero->getArt(3)->description;
else
artWorn[3]->text = std::string();
artWorn[3]->ourWindow = this;
@ -424,7 +427,7 @@ void CHeroWindow::setHero(const CGHeroInstance *hero)
artWorn[6]->pos.y = 68;
artWorn[6]->pos.h = artWorn[6]->pos.w = 44;
if(hero->artifWorn[6])
artWorn[6]->text = hero->artifWorn[6]->description;
artWorn[6]->text = hero->getArt(6)->description;
else
artWorn[6]->text = std::string();
artWorn[6]->ourWindow = this;
@ -435,7 +438,7 @@ void CHeroWindow::setHero(const CGHeroInstance *hero)
artWorn[1]->pos.y = 240;
artWorn[1]->pos.h = artWorn[1]->pos.w = 44;
if(hero->artifWorn[1])
artWorn[1]->text = hero->artifWorn[1]->description;
artWorn[1]->text = hero->getArt(1)->description;
else
artWorn[1]->text = std::string();
artWorn[1]->ourWindow = this;
@ -446,7 +449,7 @@ void CHeroWindow::setHero(const CGHeroInstance *hero)
artWorn[17]->pos.y = 310;
artWorn[17]->pos.h = artWorn[17]->pos.w = 44;
if(hero->artifWorn[17])
artWorn[17]->text = hero->artifWorn[17]->description;
artWorn[17]->text = hero->getArt(17)->description;
else
artWorn[17]->text = std::string();
artWorn[17]->ourWindow = this;
@ -457,7 +460,7 @@ void CHeroWindow::setHero(const CGHeroInstance *hero)
artWorn[5]->pos.y = 130;
artWorn[5]->pos.h = artWorn[5]->pos.w = 44;
if(hero->artifWorn[5])
artWorn[5]->text = hero->artifWorn[5]->description;
artWorn[5]->text = hero->getArt(5)->description;
else
artWorn[5]->text = std::string();
artWorn[5]->ourWindow = this;
@ -484,7 +487,7 @@ void CHeroWindow::setHero(const CGHeroInstance *hero)
add->pos.y = 365;
add->pos.h = add->pos.w = 44;
if(s<hero->artifacts.size() && hero->artifacts[s])
add->text = hero->artifacts[s]->description;
add->text = hero->getArt(s)->description;
else
add->text = std::string();
add->ourWindow = this;
@ -674,7 +677,7 @@ void CHeroWindow::leftArtRoller()
for(int s=0; s<5 && s<curHero->artifacts.size(); ++s) //set new data
{
backpack[s]->ourArt = curHero->artifacts[(s+backpackPos) % curHero->artifacts.size() ];
backpack[s]->ourArt = &CGI->arth->artifacts[curHero->artifacts[(s+backpackPos) % curHero->artifacts.size() ]];
if(backpack[s]->ourArt)
backpack[s]->text = backpack[s]->ourArt->description;
else
@ -691,7 +694,7 @@ void CHeroWindow::rightArtRoller()
for(int s=0; s<5 && s<curHero->artifacts.size(); ++s) //set new data
{
backpack[s]->ourArt = curHero->artifacts[(s+backpackPos) % curHero->artifacts.size() ];
backpack[s]->ourArt = &CGI->arth->artifacts[curHero->artifacts[(s+backpackPos) % curHero->artifacts.size() ] ];
if(backpack[s]->ourArt)
backpack[s]->text = backpack[s]->ourArt->description;
else
@ -873,7 +876,7 @@ void CHeroWindow::redrawCurBack()
CSDL_Ext::printAt(manastr.str(), 212, 247, GEOR16, zwykly, curBack);
}
CArtPlace::CArtPlace(const CArtifact * const & art): ourArt(art), active(false), clicked(false),
CArtPlace::CArtPlace(int Art): ourArt(&CGI->arth->artifacts[Art]), active(false), clicked(false),
spellBook(false), warMachine1(false), warMachine2(false), warMachine3(false),
warMachine4(false),misc1(false), misc2(false), misc3(false), misc4(false),
misc5(false), feet(false), lRing(false), rRing(false), torso(false),

View File

@ -70,7 +70,7 @@ public:
bool clicked;
CHeroWindow * ourWindow;
const CArtifact * ourArt;
CArtPlace(const CArtifact * const & art);
CArtPlace(int Art);
void clickLeft (tribool down);
void clickRight (tribool down);
void activate();
@ -117,7 +117,7 @@ public:
int player;
CHeroWindow(int playerColor); //c-tor
~CHeroWindow(); //d-tor
void setHero(const CGHeroInstance * hero); //sets main displayed hero
void setHero(const CGHeroInstance * Hero); //sets main displayed hero
void activate(); //activates hero window;
void deactivate(); //activates hero window;
virtual void show(SDL_Surface * to = NULL); //shows hero window

View File

@ -13,6 +13,7 @@
#include <sstream>
#include "hch/CObjectHandler.h"
#include "hch/CTownHandler.h"
#include "hch/CArtHandler.h"
#include "CCallback.h"
#include "hch/CGeneralTextHandler.h"
#include <sstream>

View File

@ -163,11 +163,11 @@ void initGameState(CGameInfo * cgi)
switch (pom)
{
case 145: //catapult
vhi->artifWorn[16] = &CGI->arth->artifacts[3];
vhi->artifWorn[16] = 3;
break;
default:
pom-=145;
vhi->artifWorn[13+pom] = &CGI->arth->artifacts[4+pom];
vhi->artifWorn[13+pom] = 4+pom;
break;
}
continue;

View File

@ -12,6 +12,7 @@
#include "hch/CLodHandler.h"
#include "CPathfinder.h"
#include <sstream>
#include "hch/CAbilityHandler.h"
#include "hch/CHeroHandler.h"
#include "hch/CTownHandler.h"
#include "SDL_framerate.h"

View File

@ -53,6 +53,7 @@ const int SKILL_QUANTITY=28;
const int SKILL_PER_HERO=8;
const int ARTIFACTS_QUANTITY=171;
const int HEROES_QUANTITY=156;
const int SPELLS_QUANTITY=70;
const int RESOURCE_QUANTITY=8;
const int TERRAIN_TYPES=10;
const int PRIMARY_SKILLS=4;

File diff suppressed because it is too large Load Diff

View File

@ -28,5 +28,7 @@ public:
void deh3m(); // decode file, results are stored in map
EDefType getDefType(CGDefInfo * a); //returns type of object in def
CCreatureSet readCreatureSet(int number = 7); //reads creature set in most recently encountered format; reades number units (default is 7)
char readChar();
std::string readString();
};
#endif //CAMBARCENDAMO_H

View File

@ -17,11 +17,6 @@ CGDefInfo::CGDefInfo()
{
visitDir = (8|16|32|64|128); //4,5,6,7,8 - any not-from-up direction
}
bool DefObjInfo::operator==(const std::string & por) const
{
return this->defName == por;
}
void CDefObjInfoHandler::load()
{
nodrze<int> ideki;
@ -73,13 +68,3 @@ void CDefObjInfoHandler::load()
castles[nobj->subid]=nobj;
}
}
bool DefObjInfo::isVisitable() const
{
for(int g=0; g<6; ++g)
{
if(visitMap[g]!=0)
return true;
}
return false;
}

View File

@ -27,18 +27,6 @@ public:
}
CGDefInfo();
};
struct DefObjInfo
{
std::string defName;
int priority;
int type, subtype;
int objType;
unsigned char visitMap[6];
unsigned char blockMap[6];
bool operator==(const std::string & por) const;
bool isVisitable() const;
};
class CDefObjInfoHandler
{
public:

View File

@ -10,6 +10,7 @@
#include "CHeroHandler.h"
#include <boost/algorithm/string/replace.hpp>
#include "CTownHandler.h"
#include "CArtHandler.h"
void CObjectHandler::loadObjects()
{
int ID=0;
@ -239,7 +240,10 @@ int CGHeroInstance::getSecSkillLevel(const int & ID) const
return secSkills[i].second;
return -1;
}
const CArtifact * CGHeroInstance::getArt(int pos)
{
return &CGI->arth->artifacts[artifWorn[pos]];
}
int CGTownInstance::getSightDistance() const //returns sight distance
{
@ -326,7 +330,6 @@ CGTownInstance::CGTownInstance()
garrisonHero=NULL;
//state->owner=-1;
town=NULL;
income = 500;
visitingHero = NULL;
}

View File

@ -3,10 +3,8 @@
#include <string>
#include <vector>
#include <set>
#include <map>
#include "CCreatureHandler.h"
#include "CArtHandler.h"
#include "CAbilityHandler.h"
#include "CSpellHandler.h"
//#include "CHeroHandler.h"
using boost::logic::tribool;
class CCPPObjectScript;
@ -19,6 +17,7 @@ class CHero;
class CBuilding;
class CSpell;
class CGTownInstance;
class CArtifact;
class CSpecObjInfo //class with object - specific info (eg. different information for creatures and heroes); use inheritance to make object - specific classes
{
};
@ -39,40 +38,40 @@ public:
unsigned int defence; //added defence points
unsigned int power; //added power points
unsigned int knowledge; //added knowledge points
std::vector<CAbility *> abilities; //gained abilities
std::vector<int> abilities; //gained abilities
std::vector<int> abilityLevels; //levels of gained abilities
std::vector<CArtifact *> artifacts; //gained artifacts
std::vector<CSpell *> spells; //gained spells
std::vector<int> artifacts; //gained artifacts
std::vector<int> spells; //gained spells
CCreatureSet creatures; //gained creatures
unsigned char availableFor; //players whom this event is available for
bool computerActivate; //true if computre player can activate this event
bool humanActivate; //true if human player can activate this event
};
class CHeroObjInfo : public CSpecObjInfo
{
public:
unsigned char bytes[4]; //mysterius bytes identifying hero in a strange way
int player;
CHero * type;
std::string name; //if nonstandard
bool standardGarrison; //true if hero has standard garrison
CCreatureSet garrison; //hero's army
std::vector<CArtifact *> artifacts; //hero's artifacts from bag
//CArtifact * artHead, * artLRing, * artRRing, * artLHand, * artRhand, * artFeet, * artSpellBook, * artMach1, * artMach2, * artMach3, * artMach4, * artMisc1, * artMisc2, * artMisc3, * artMisc4, * artMisc5, * artTorso, * artNeck, * artShoulders; //working artifactsstd::vector<CArtifact *> artifWorn; // 0 - head; 1 - shoulders; 2 - neck; 3 - right hand; 4 - left hand; 5 - torso; 6 - right ring; 7 - left ring; 8 - feet; 9 - misc1; 10 - misc2; 11 - misc3; 12 - misc4; 13 - mach1; 14 - mach2; 15 - mach3; 16 - mach4; 17 - spellbook; 18 - misc5
std::vector<CArtifact *> artifWorn; // 0 - head; 1 - shoulders; 2 - neck; 3 - right hand; 4 - left hand; 5 - torso; 6 - right ring; 7 - left ring; 8 - feet; 9 - misc1; 10 - misc2; 11 - misc3; 12 - misc4; 13 - mach1; 14 - mach2; 15 - mach3; 16 - mach4; 17 - spellbook; 18 - misc5
bool isGuarding;
int guardRange; //range of hero's guard
std::string biography; //if nonstandard
bool sex; //if true, reverse hero's sex
std::vector<CSpell *> spells; //hero's spells
int attack, defence, power, knowledge; //main hero's attributes
unsigned int experience; //hero's experience points
std::vector<CAbility *> abilities; //hero's abilities
std::vector<int> abilityLevels; //hero ability levels
bool defaultMainStats; //if true attack, defence, power and knowledge are typical
CGHeroInstance * myInstance; //pointer to appropriate hero instance
};
//class CHeroObjInfo : public CSpecObjInfo
//{
//public:
// unsigned char bytes[4]; //mysterius bytes identifying hero in a strange way
// int player;
// CHero * type;
// std::string name; //if nonstandard
// bool standardGarrison; //true if hero has standard garrison
// CCreatureSet garrison; //hero's army
// std::vector<int> artifacts; //hero's artifacts from bag
// //CArtifact * artHead, * artLRing, * artRRing, * artLHand, * artRhand, * artFeet, * artSpellBook, * artMach1, * artMach2, * artMach3, * artMach4, * artMisc1, * artMisc2, * artMisc3, * artMisc4, * artMisc5, * artTorso, * artNeck, * artShoulders; //working artifactsstd::vector<CArtifact *> artifWorn; // 0 - head; 1 - shoulders; 2 - neck; 3 - right hand; 4 - left hand; 5 - torso; 6 - right ring; 7 - left ring; 8 - feet; 9 - misc1; 10 - misc2; 11 - misc3; 12 - misc4; 13 - mach1; 14 - mach2; 15 - mach3; 16 - mach4; 17 - spellbook; 18 - misc5
// std::map<int,int> artifWorn; // keys: 0 - head; 1 - shoulders; 2 - neck; 3 - right hand; 4 - left hand; 5 - torso; 6 - right ring; 7 - left ring; 8 - feet; 9 - misc1; 10 - misc2; 11 - misc3; 12 - misc4; 13 - mach1; 14 - mach2; 15 - mach3; 16 - mach4; 17 - spellbook; 18 - misc5
// bool isGuarding;
// int guardRange; //range of hero's guard
// std::string biography; //if nonstandard
// bool sex; //if true, reverse hero's sex
// std::vector<int> spells; //hero's spells
// int attack, defence, power, knowledge; //main hero's attributes
// unsigned int experience; //hero's experience points
// std::vector<int> abilities; //hero's abilities
// std::vector<int> abilityLevels; //hero ability levels
// bool defaultMainStats; //if true attack, defence, power and knowledge are typical
// CGHeroInstance * myInstance; //pointer to appropriate hero instance
//};
class CCreatureObjInfo : public CSpecObjInfo
{
@ -82,7 +81,7 @@ public:
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
int gainedArtifact; //ID of artifact gained to hero
bool neverFlees; //if true, the troops will never flee
bool notGrowingTeam; //if true, number of units won't grow
};
@ -99,25 +98,16 @@ public:
unsigned 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;
int m1level; //for mission 1
int m2attack, m2defence, m2power, m2knowledge;//for mission 2
unsigned char m3bytes[4];//for mission 3
unsigned char m4bytes[4];//for mission 4
std::vector<int> m5arts;//for mission 5 - artifact ID
std::vector<CCreature *> m6cre;//for mission 6
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
int m7wood, m7mercury, m7ore, m7sulfur, m7crystal, m7gems, m7gold; //for mission 7
CHero * m8hero;//for mission 8
int m9player; //for mission 9 - number; from 0 to 7
std::string firstVisitText, nextVisitText, completedText;
@ -137,21 +127,21 @@ public:
unsigned char r6type; //0 - attack, 1 - defence, 2 - power, 3 - knowledge
int r6amount;
//for reward 7
CAbility * r7ability;
int r7ability; //ability id
unsigned char r7level; //1 - basic, 2 - advanced, 3 - expert
//for reward 8
CArtifact * r8art;
int r8art;//artifact id
//for reward 9
CSpell * r9spell;
int r9spell;//spell id
//for reward 10
CCreature * r10creature;
int r10creature; //creature id
int r10amount;
};
class CWitchHutObjInfo : public CSpecObjInfo
{
public:
std::vector<CAbility *> allowedAbilities;
std::vector<int> allowedAbilities;
};
class CScholarObjInfo : public CSpecObjInfo
@ -160,8 +150,8 @@ public:
unsigned char bonusType; //255 - random, 0 - primary skill, 1 - secondary skill, 2 - spell
unsigned char r0type;
CAbility * r1;
CSpell * r2;
int r1; //Ability ID
int r2; //Spell ID
};
class CGarrisonObjInfo : public CSpecObjInfo
@ -206,7 +196,7 @@ class CSpellScrollObjinfo : public CSpecObjInfo
{
public:
std::string message;
CSpell * spell;
int spell;
bool areGuarders;
CCreatureSet guarders;
};
@ -225,10 +215,10 @@ public:
int luckDiff;
int wood, mercury, ore, sulfur, crystal, gems, gold;
int attack, defence, power, knowledge;
std::vector<CAbility *> abilities;
std::vector<int> abilities;
std::vector<int> abilityLevels;
std::vector<CArtifact *> artifacts;
std::vector<CSpell *> spells;
std::vector<int> artifacts;
std::vector<int> spells;
CCreatureSet creatures;
};
@ -279,7 +269,7 @@ public:
//for mission 4
unsigned char m4bytes[4];
//for mission 5
std::vector<CArtifact *> m5arts;
std::vector<int> m5arts; //artifacts id
//for mission 6
std::vector<CCreature *> m6cre;
std::vector<int> m6number;
@ -352,12 +342,16 @@ public:
std::vector<int> primSkills; //0-attack, 1-defence, 2-spell power, 3-knowledge
std::vector<std::pair<int,int> > secSkills; //first - ID of skill, second - level of skill (0 - basic, 1 - adv., 2 - expert)
int movement; //remaining movement points
int identifier; //from the map file
int patrolRadious; //-1 - no patrol
bool sex;
bool inTownGarrison; // if hero is in town garrison
CGTownInstance * visitedTown; //set if hero is visiting town or in the town garrison
std::vector<CArtifact *> artifacts; //hero's artifacts from bag
std::vector<CArtifact *> artifWorn; // 0 - head; 1 - shoulders; 2 - neck; 3 - right hand; 4 - left hand; 5 - torso; 6 - right ring; 7 - left ring; 8 - feet; 9 - misc1; 10 - misc2; 11 - misc3; 12 - misc4; 13 - mach1; 14 - mach2; 15 - mach3; 16 - mach4; 17 - spellbook; 18 - misc5
std::vector<int> artifacts; //hero's artifacts from bag
std::map<int,int> artifWorn; //map<position,artifact_id>; positions: 0 - head; 1 - shoulders; 2 - neck; 3 - right hand; 4 - left hand; 5 - torso; 6 - right ring; 7 - left ring; 8 - feet; 9 - misc1; 10 - misc2; 11 - misc3; 12 - misc4; 13 - mach1; 14 - mach2; 15 - mach3; 16 - mach4; 17 - spellbook; 18 - misc5
std::set<int> spells; //known spells (spell IDs)
virtual bool isHero() const;
unsigned int getTileCost(const EterrainType & ttype, const Eroad & rdtype, const Eriver & rvtype) const;
@ -373,6 +367,7 @@ public:
int getCurrentLuck() const;
int getCurrentMorale() const;
int getSecSkillLevel(const int & ID) const; //-1 - no skill
const CArtifact * getArt(int pos);
CGHeroInstance();
virtual ~CGHeroInstance();
};
@ -384,13 +379,12 @@ public:
std::string name; // name of town
int builded; //how many buildings has been built this turn
int destroyed; //how many buildings has been destroyed this turn
int identifier;
int income;
int identifier; //special identifier from h3m (only > RoE maps)
int alignment;
struct StrInfo
{
public:
std::map<int,int> creatures; //level - available amount
} strInfo;
@ -398,7 +392,7 @@ public:
const CGHeroInstance * garrisonHero, *visitingHero;
std::vector<CSpell *> possibleSpells, obligatorySpells, availableSpells;
std::vector<int> possibleSpells, obligatorySpells, availableSpells;
int getSightDistance() const; //returns sight distance

7
map.h
View File

@ -13,7 +13,7 @@ struct Sresource
std::string resName; //name of this resource
int amount; //it can be greater and lesser than 0
};
class CGHeroInstance;
struct TimeEvent
{
std::string eventName;
@ -156,7 +156,7 @@ struct Mapa
TerrainTile** undergroungTerrain; // used only if there is underground level
std::vector<Rumor> rumors;
std::vector<DisposedHero> disposedHeroes;
std::vector<CHeroObjInfo*> predefinedHeroes;
std::vector<CGHeroInstance*> predefinedHeroes;
std::vector<CGDefInfo *> defy; // list of .def files
PlayerInfo players[8]; // info about players
std::vector<int> teams; // teams[i] = team of player no i
@ -164,6 +164,9 @@ struct Mapa
EvictoryConditions victoryCondition; //victory conditions
CspecificVictoryConidtions * vicConDetails; // used only if vistory conditions aren't standard
int howManyTeams;
std::vector<bool> allowedSpell; //allowedSpell[spell_ID] - if the spell is allowed
std::vector<bool> allowedArtifact; //allowedArtifact[artifact_ID] - if the artifact is allowed
std::vector<bool> allowedAbilities; //allowedAbilities[ability_ID] - if the ability is allowed
std::vector<CMapEvent> events;
};
class CMapHeader

View File

@ -12,6 +12,7 @@
#include "hch\CCastleHandler.h"
#include "hch\CHeroHandler.h"
#include "hch\CTownHandler.h"
#include "hch\CArtHandler.h"
#include <iomanip>
#include <sstream>
extern SDL_Surface * screen;
@ -149,7 +150,7 @@ std::pair<int,int> CMapHandler::pickObject(CGObjectInstance *obj)
return std::pair<int,int>(79,rand()%7); //now it's OH3 style, use %8 for mithril
case 77: //random town
{
int align = ((CCastleObjInfo*)obj->info)->alignment,
int align = ((CGTownInstance*)obj)->alignment,
f;
if(align>PLAYER_LIMIT-1)//same as owner / random
{
@ -1484,9 +1485,8 @@ CGObjectInstance * CMapHandler::createObject(int id, int subid, int3 pos, int ow
nobj->defInfo->handler=NULL;
nobj->defInfo->blockMap[5] = 253;
nobj->defInfo->visitMap[5] = 2;
nobj->artifWorn.resize(20);
nobj->artifacts.resize(20);
nobj->artifWorn[16] = &CGI->arth->artifacts[3];
nobj->artifWorn[16] = 3;
nobj->primSkills.resize(4);
nobj->primSkills[0] = nobj->type->heroClass->initialAttack;
nobj->primSkills[1] = nobj->type->heroClass->initialDefence;