mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
* support for prison
* updated changelog
This commit is contained in:
parent
99aef852be
commit
adf5c052f9
@ -821,6 +821,20 @@ void CGameState::applyNL(IPack * pack)
|
||||
h->inTownGarrison = false;
|
||||
break;
|
||||
}
|
||||
case 516:
|
||||
{
|
||||
GiveHero *sha = static_cast<GiveHero*>(pack);
|
||||
CGHeroInstance *h = getHero(sha->id);
|
||||
map->removeBlockVisTiles(h,true);
|
||||
h->setOwner(sha->player);
|
||||
h->movement = h->maxMovePoints(true);
|
||||
h->initHeroDefInfo();
|
||||
map->heroes.push_back(h);
|
||||
players[h->tempOwner].heroes.push_back(h);
|
||||
map->addBlockVisTiles(h);
|
||||
h->inTownGarrison = false;
|
||||
break;
|
||||
}
|
||||
case 1001://set object property
|
||||
{
|
||||
SetObjectProperty *p = static_cast<SetObjectProperty*>(pack);
|
||||
@ -1559,7 +1573,11 @@ void CGameState::init(StartInfo * si, Mapa * map, int Seed)
|
||||
}
|
||||
|
||||
for(int i=0; i<map->objects.size(); i++)
|
||||
{
|
||||
map->objects[i]->initObj();
|
||||
if(map->objects[i]->ID == 62) //prison also needs to initialize hero
|
||||
static_cast<CGHeroInstance*>(map->objects[i])->initHero();
|
||||
}
|
||||
}
|
||||
|
||||
bool CGameState::battleShootCreatureStack(int ID, int dest)
|
||||
@ -1761,6 +1779,9 @@ void CGameState::setObjProperty( SetObjectProperty * p )
|
||||
case 5:
|
||||
static_cast<CGVisitableOPW*>(obj)->visited = p->val;
|
||||
break;
|
||||
case 6:
|
||||
obj->ID = p->val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
10
ChangeLog
10
ChangeLog
@ -9,6 +9,8 @@ GENERAL:
|
||||
* fixed crash when there was no hero available to hire for some player
|
||||
* fixed problems with 1024x600 screen resolution
|
||||
* updating blockmap/visitmap of randomized objects
|
||||
* fixed crashes on loading maps with flag all mines/dwelling victory condition
|
||||
* further fixes for leveling-up (stability and identical offered skills bug)
|
||||
|
||||
ADVENTURE INTERFACE:
|
||||
* added missing path arrows
|
||||
@ -16,19 +18,22 @@ ADVENTURE INTERFACE:
|
||||
* recalculating hero path after reselecting hero
|
||||
* further changes in pathfinder making it more like original one
|
||||
* orientation of hero can't be change if movement points are exhausted
|
||||
* campfire, borderguard, bordergate, questguard will be accessible from the top
|
||||
* campfire, borderguard, bordergate, questguard will be accessible from the top
|
||||
* new movement cost calculation algorithm
|
||||
|
||||
BATTLES:
|
||||
* partial support for battle obstacles
|
||||
* spells not known by hero can't be casted
|
||||
* spell books won't be placed in War Machine slots after battle
|
||||
* attack is now possible when hex under cursor is not displayed
|
||||
* fixes for two-hex creatures attacks
|
||||
* fixes for two-hex creatures actions
|
||||
* a few tweaks in battle path/available hexes calculation (more of them is needed)
|
||||
* fixed positions of stack queue and battle result window when resolution is != 800x600
|
||||
* corrected duration of frenzy spell which was incorrect in certain cases
|
||||
* corrected hero spell casting animation
|
||||
* better support for battle backgrounds
|
||||
* blocked "save" command during battle
|
||||
* spellbook displays only spells known by Hero
|
||||
New spells supported:
|
||||
- Mirth
|
||||
- Sorrow
|
||||
@ -52,6 +57,7 @@ PREGAME:
|
||||
|
||||
OBJECTS:
|
||||
New objects supported:
|
||||
* Prison
|
||||
* Magic Well
|
||||
* Faerie Ring
|
||||
* Swan Pond
|
||||
|
@ -377,6 +377,19 @@ void CClient::process(int what)
|
||||
playerint[h->tempOwner]->heroInGarrisonChange(gs->getTown(hr.tid));
|
||||
break;
|
||||
}
|
||||
case 516:
|
||||
{
|
||||
GiveHero hr;
|
||||
*serv >> hr;
|
||||
tlog5 << "Players receives hero\n";
|
||||
CGHeroInstance *h = gs->getHero(hr.id);
|
||||
CGI->mh->hideObject(h);
|
||||
gs->apply(&hr);
|
||||
CGI->mh->initHeroDef(h);
|
||||
CGI->mh->printObject(h);
|
||||
playerint[h->tempOwner]->heroCreated(h);
|
||||
break;
|
||||
}
|
||||
case 1001:
|
||||
{
|
||||
SetObjectProperty sop;
|
||||
|
@ -88,6 +88,7 @@ public:
|
||||
void giveHeroBonus(GiveBonus * bonus){};
|
||||
void setMovePoints(SetMovePoints * smp){};
|
||||
void setManaPoints(int hid, int val){};
|
||||
void giveHero(int id, int player){};
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
friend class CCallback; //handling players actions
|
||||
friend void processCommand(const std::string &message, CClient *&client); //handling console
|
||||
|
@ -434,7 +434,8 @@ void CGHeroInstance::initHero(int SUBID)
|
||||
|
||||
void CGHeroInstance::initHero()
|
||||
{
|
||||
initHeroDefInfo();
|
||||
if(ID == 34)
|
||||
initHeroDefInfo();
|
||||
if(!type)
|
||||
type = VLC->heroh->heroes[subID];
|
||||
artifWorn[16] = 3;
|
||||
@ -504,7 +505,7 @@ void CGHeroInstance::initHero()
|
||||
|
||||
void CGHeroInstance::initHeroDefInfo()
|
||||
{
|
||||
if(!defInfo)
|
||||
if(!defInfo || defInfo->id != 34)
|
||||
{
|
||||
defInfo = new CGDefInfo();
|
||||
defInfo->id = 34;
|
||||
@ -531,20 +532,43 @@ bool CGHeroInstance::needsLastStack() const
|
||||
}
|
||||
void CGHeroInstance::onHeroVisit(const CGHeroInstance * h) const
|
||||
{
|
||||
//TODO: check for allies
|
||||
if(tempOwner == h->tempOwner) //our hero
|
||||
if (ID == 34) //hero
|
||||
{
|
||||
//exchange
|
||||
//TODO: check for allies
|
||||
if(tempOwner == h->tempOwner) //our hero
|
||||
{
|
||||
//exchange
|
||||
}
|
||||
else
|
||||
{
|
||||
cb->startBattleI(
|
||||
&h->army,
|
||||
&army,
|
||||
h->pos,
|
||||
h,
|
||||
this,
|
||||
0);
|
||||
}
|
||||
}
|
||||
else
|
||||
else if(ID == 62) //prison
|
||||
{
|
||||
cb->startBattleI(
|
||||
&h->army,
|
||||
&army,
|
||||
h->pos,
|
||||
h,
|
||||
this,
|
||||
0);
|
||||
if(cb->getHeroCount(h->tempOwner,false) < 8) //free hero slot
|
||||
{
|
||||
cb->setObjProperty(id,6,34); //set ID to 34
|
||||
cb->giveHero(id,h->tempOwner); //recreates def and adds hero to player
|
||||
|
||||
InfoWindow iw;
|
||||
iw.player = h->tempOwner;
|
||||
iw.text << std::pair<ui8,ui32>(11,102);
|
||||
cb->showInfoDialog(&iw);
|
||||
}
|
||||
else //already 8 wandering heroes
|
||||
{
|
||||
InfoWindow iw;
|
||||
iw.player = h->tempOwner;
|
||||
iw.text << std::pair<ui8,ui32>(11,103);
|
||||
cb->showInfoDialog(&iw);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,4 +39,16 @@ const CGHeroInstance* IGameCallback::getSelectedHero( int player )
|
||||
const PlayerSettings * IGameCallback::getPlayerSettings( int color )
|
||||
{
|
||||
return &gs->scenarioOps->getIthPlayersSettings(color);
|
||||
}
|
||||
|
||||
int IGameCallback::getHeroCount( int player, bool includeGarrisoned )
|
||||
{
|
||||
int ret = 0;
|
||||
if(includeGarrisoned)
|
||||
return gs->players[player].heroes.size();
|
||||
else
|
||||
for(int i=0; i < gs->players[player].heroes.size(); i++)
|
||||
if(!gs->players[player].heroes[i]->inTownGarrison)
|
||||
ret++;
|
||||
return ret;
|
||||
}
|
@ -37,6 +37,7 @@ public:
|
||||
virtual int getCurrentPlayer()=0;
|
||||
virtual int getSelectedHero()=0;
|
||||
virtual const PlayerSettings * getPlayerSettings(int color);
|
||||
virtual int getHeroCount(int player, bool includeGarrisoned);
|
||||
|
||||
//do sth
|
||||
virtual void changeSpells(int hid, bool give, const std::set<ui32> &spells)=0;
|
||||
@ -62,5 +63,6 @@ public:
|
||||
virtual void giveHeroBonus(GiveBonus * bonus)=0;
|
||||
virtual void setMovePoints(SetMovePoints * smp)=0;
|
||||
virtual void setManaPoints(int hid, int val)=0;
|
||||
virtual void giveHero(int id, int player)=0;
|
||||
};
|
||||
#endif // __IGAMECALLBACK_H__
|
@ -311,6 +311,19 @@ struct HeroRecruited : public CPack<HeroRecruited> //515
|
||||
h & hid & tid & tile & player;
|
||||
}
|
||||
};
|
||||
|
||||
struct GiveHero : public CPack<GiveHero> //516
|
||||
{
|
||||
GiveHero(){type = 516;};
|
||||
ui32 id; //object id
|
||||
ui8 player;
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & id & player;
|
||||
}
|
||||
};
|
||||
|
||||
struct NewTurn : public CPack<NewTurn> //101
|
||||
{
|
||||
struct Hero
|
||||
@ -376,7 +389,7 @@ struct InfoWindow : public CPack<InfoWindow> //103 - displays simple info windo
|
||||
struct SetObjectProperty : public CPack<SetObjectProperty>//1001
|
||||
{
|
||||
ui32 id;
|
||||
ui8 what; //1 - owner; 2 - blockvis
|
||||
ui8 what; //1 - owner; 2 - blockvis; 3 - first stack count; 4 - visitors; 5 - visited; 6 - ID (if 34 then also def is replaced)
|
||||
ui32 val;
|
||||
SetObjectProperty(){type = 1001;};
|
||||
SetObjectProperty(ui32 ID, ui8 What, ui32 Val):id(ID),what(What),val(Val){type = 1001;};
|
||||
|
6
map.cpp
6
map.cpp
@ -477,7 +477,7 @@ void Mapa::initFromBytes(unsigned char * bufor)
|
||||
}
|
||||
tlog0<<"\tCalculating blocked/visitable tiles: "<<th.getDif()<<std::endl;
|
||||
}
|
||||
void Mapa::removeBlockVisTiles(CGObjectInstance * obj)
|
||||
void Mapa::removeBlockVisTiles(CGObjectInstance * obj, bool total)
|
||||
{
|
||||
for(int fx=0; fx<8; ++fx)
|
||||
{
|
||||
@ -489,12 +489,12 @@ void Mapa::removeBlockVisTiles(CGObjectInstance * obj)
|
||||
if(xVal>=0 && xVal<width && yVal>=0 && yVal<height)
|
||||
{
|
||||
TerrainTile & curt = terrain[xVal][yVal][zVal];
|
||||
if(((obj->defInfo->visitMap[fy] >> (7 - fx)) & 1))
|
||||
if(total || ((obj->defInfo->visitMap[fy] >> (7 - fx)) & 1))
|
||||
{
|
||||
curt.visitableObjects -= obj;
|
||||
curt.visitable = curt.visitableObjects.size();
|
||||
}
|
||||
if(!((obj->defInfo->blockMap[fy] >> (7 - fx)) & 1))
|
||||
if(total || !((obj->defInfo->blockMap[fy] >> (7 - fx)) & 1))
|
||||
{
|
||||
curt.blockingObjects -= obj;
|
||||
curt.blocked = curt.blockingObjects.size();
|
||||
|
2
map.h
2
map.h
@ -322,7 +322,7 @@ struct DLL_EXPORT Mapa : public CMapHeader
|
||||
|
||||
|
||||
void addBlockVisTiles(CGObjectInstance * obj);
|
||||
void removeBlockVisTiles(CGObjectInstance * obj);
|
||||
void removeBlockVisTiles(CGObjectInstance * obj, bool total=false);
|
||||
Mapa(std::string filename); //creates map structure from .h3m file
|
||||
Mapa();
|
||||
~Mapa();
|
||||
|
@ -2314,4 +2314,12 @@ void CGameHandler::setManaPoints( int hid, int val )
|
||||
sm.hid = hid;
|
||||
sm.val = val;
|
||||
sendAndApply(&sm);
|
||||
}
|
||||
|
||||
void CGameHandler::giveHero( int id, int player )
|
||||
{
|
||||
GiveHero gh;
|
||||
gh.id = id;
|
||||
gh.player = player;
|
||||
sendAndApply(&gh);
|
||||
}
|
@ -106,6 +106,7 @@ public:
|
||||
void giveHeroBonus(GiveBonus * bonus);
|
||||
void setMovePoints(SetMovePoints * smp);
|
||||
void setManaPoints(int hid, int val);
|
||||
void giveHero(int id, int player);
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void init(StartInfo *si, int Seed);
|
||||
|
Loading…
Reference in New Issue
Block a user