mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-28 23:06:24 +02:00
* added "Next hero" button functionality
* minor improvement for prison (hero appears at proper tile) * only one spell can be casted per turn * minor changes
This commit is contained in:
parent
c1109452d6
commit
6a3bfbee46
@ -1259,6 +1259,18 @@ void CAdvMapInt::fsystemOptions()
|
||||
}
|
||||
void CAdvMapInt::fnextHero()
|
||||
{
|
||||
if(!heroList.items.size()) //no wandering heroes
|
||||
return;
|
||||
|
||||
int start = heroList.selected;
|
||||
int i = start;
|
||||
do
|
||||
{
|
||||
i++;
|
||||
if(i >= heroList.items.size())
|
||||
i = 0;
|
||||
} while (!heroList.items[i].first->movement && i!=start);
|
||||
heroList.select(i);
|
||||
}
|
||||
void CAdvMapInt::fendTurn()
|
||||
{
|
||||
|
@ -673,6 +673,20 @@ void CGameState::applyNL(IPack * pack)
|
||||
h->bonuses.back().description = toString(rh->bdescr);
|
||||
break;
|
||||
}
|
||||
case 116:
|
||||
{
|
||||
ChangeObjPos *rh = static_cast<ChangeObjPos*>(pack);
|
||||
CGObjectInstance *obj = map->objects[rh->objid];
|
||||
if(!obj)
|
||||
{
|
||||
tlog1 << "Wrong ChangeObjPos: object " << rh->objid << " doesn't exist!\n";
|
||||
return;
|
||||
}
|
||||
map->removeBlockVisTiles(obj);
|
||||
obj->pos = rh->nPos;
|
||||
map->addBlockVisTiles(obj);
|
||||
break;
|
||||
}
|
||||
case 500:
|
||||
{
|
||||
RemoveObject *rh = static_cast<RemoveObject*>(pack);
|
||||
@ -862,6 +876,7 @@ void CGameState::applyNL(IPack * pack)
|
||||
case 3001:
|
||||
{
|
||||
BattleNextRound *ns = static_cast<BattleNextRound*>(pack);
|
||||
curB->castedSpells[0] = curB->castedSpells[1] = 0;
|
||||
curB->round = ns->round;
|
||||
for(int i=0; i<curB->stacks.size();i++)
|
||||
{
|
||||
@ -951,8 +966,14 @@ void CGameState::applyNL(IPack * pack)
|
||||
SpellCasted *sc = static_cast<SpellCasted*>(pack);
|
||||
CGHeroInstance *h = (sc->side) ? getHero(curB->hero2) : getHero(curB->hero1);
|
||||
if(h)
|
||||
{
|
||||
h->mana -= VLC->spellh->spells[sc->id].costs[sc->skill];
|
||||
//TODO: counter
|
||||
if(h->mana < 0) h->mana = 0;
|
||||
}
|
||||
if(sc->side >= 0 && sc->side < 2)
|
||||
{
|
||||
curB->castedSpells[sc->side]++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3010:
|
||||
@ -1803,49 +1824,49 @@ void CGameState::getNeighbours(int3 tile, std::vector<int3> &vec, bool onLand)
|
||||
if(tile.x > 0)
|
||||
{
|
||||
hlp = int3(tile.x-1,tile.y,tile.z);
|
||||
if((weAreOnLand == map->getTile(hlp).tertype!=8) && map->getTile(hlp).tertype!=9)
|
||||
if((weAreOnLand == (map->getTile(hlp).tertype!=8)) && map->getTile(hlp).tertype!=9)
|
||||
vec.push_back(hlp);
|
||||
}
|
||||
if(tile.y > 0)
|
||||
{
|
||||
hlp = int3(tile.x,tile.y-1,tile.z);
|
||||
if((weAreOnLand == map->getTile(hlp).tertype!=8) && map->getTile(hlp).tertype!=9)
|
||||
if((weAreOnLand == (map->getTile(hlp).tertype!=8)) && map->getTile(hlp).tertype!=9)
|
||||
vec.push_back(hlp);
|
||||
}
|
||||
if(tile.x > 0 && tile.y > 0)
|
||||
{
|
||||
hlp = int3(tile.x-1,tile.y-1,tile.z);
|
||||
if((weAreOnLand == map->getTile(hlp).tertype!=8) && map->getTile(hlp).tertype!=9)
|
||||
if((weAreOnLand == (map->getTile(hlp).tertype!=8)) && map->getTile(hlp).tertype!=9)
|
||||
vec.push_back(hlp);
|
||||
}
|
||||
if(tile.x > 0 && tile.y < map->height-1)
|
||||
{
|
||||
hlp = int3(tile.x-1,tile.y+1,tile.z);
|
||||
if((weAreOnLand == map->getTile(hlp).tertype!=8) && map->getTile(hlp).tertype!=9)
|
||||
if((weAreOnLand == (map->getTile(hlp).tertype!=8)) && map->getTile(hlp).tertype!=9)
|
||||
vec.push_back(hlp);
|
||||
}
|
||||
if(tile.y < map->height-1)
|
||||
{
|
||||
hlp = int3(tile.x,tile.y+1,tile.z);
|
||||
if((weAreOnLand == map->getTile(hlp).tertype!=8) && map->getTile(hlp).tertype!=9)
|
||||
if((weAreOnLand == (map->getTile(hlp).tertype!=8)) && map->getTile(hlp).tertype!=9)
|
||||
vec.push_back(hlp);
|
||||
}
|
||||
if(tile.x < map->width-1)
|
||||
{
|
||||
hlp = int3(tile.x+1,tile.y,tile.z);
|
||||
if((weAreOnLand == map->getTile(hlp).tertype!=8) && map->getTile(hlp).tertype!=9)
|
||||
if((weAreOnLand == (map->getTile(hlp).tertype!=8)) && map->getTile(hlp).tertype!=9)
|
||||
vec.push_back(hlp);
|
||||
}
|
||||
if(tile.x < map->width-1 && tile.y > 0)
|
||||
{
|
||||
hlp = int3(tile.x+1,tile.y-1,tile.z);
|
||||
if((weAreOnLand == map->getTile(hlp).tertype!=8) && map->getTile(hlp).tertype!=9)
|
||||
if((weAreOnLand == (map->getTile(hlp).tertype!=8)) && map->getTile(hlp).tertype!=9)
|
||||
vec.push_back(hlp);
|
||||
}
|
||||
if(tile.x < map->width-1 && tile.y < map->height-1)
|
||||
{
|
||||
hlp = int3(tile.x+1,tile.y+1,tile.z);
|
||||
if((weAreOnLand == map->getTile(hlp).tertype!=8) && map->getTile(hlp).tertype!=9)
|
||||
if((weAreOnLand == (map->getTile(hlp).tertype!=8)) && map->getTile(hlp).tertype!=9)
|
||||
vec.push_back(hlp);
|
||||
}
|
||||
}
|
||||
|
@ -104,10 +104,12 @@ struct DLL_EXPORT BattleInfo
|
||||
CCreatureSet army1, army2;
|
||||
std::vector<CStack*> stacks;
|
||||
std::vector<CObstacleInstance> obstacles;
|
||||
ui8 castedSpells[2];
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & side1 & side2 & round & activeStack & siege & tile & stacks & army1 & army2 & hero1 & hero2 & obstacles;
|
||||
h & side1 & side2 & round & activeStack & siege & tile & stacks & army1 & army2 & hero1 & hero2 & obstacles
|
||||
& castedSpells;
|
||||
}
|
||||
CStack * getNextStack(); //which stack will have turn after current one
|
||||
std::vector<CStack> getStackQueue(); //returns stack in order of their movement action
|
||||
|
@ -217,6 +217,22 @@ void CClient::process(int what)
|
||||
playerint[h->tempOwner]->heroBonusChanged(h,h->bonuses.back(),true);
|
||||
break;
|
||||
}
|
||||
case 116:
|
||||
{
|
||||
ChangeObjPos sav;
|
||||
*serv >> sav;
|
||||
tlog5 << "Changing pos of object "<< sav.objid << std::endl;
|
||||
CGObjectInstance *obj = gs->map->objects[sav.objid];
|
||||
//TODO: redraw if neeeded
|
||||
if(sav.flags & 1)
|
||||
CGI->mh->hideObject(obj);
|
||||
|
||||
gs->apply(&sav);
|
||||
|
||||
if(sav.flags & 1)
|
||||
CGI->mh->printObject(obj);
|
||||
break;
|
||||
}
|
||||
case 500:
|
||||
{
|
||||
RemoveObject rh;
|
||||
|
@ -89,6 +89,7 @@ public:
|
||||
void setMovePoints(SetMovePoints * smp){};
|
||||
void setManaPoints(int hid, int val){};
|
||||
void giveHero(int id, int player){};
|
||||
void changeObjPos(int objid, int3 newPos, ui8 flags){};
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
friend class CCallback; //handling players actions
|
||||
friend void processCommand(const std::string &message, CClient *&client); //handling console
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "../CGameState.h"
|
||||
#include "../lib/NetPacks.h"
|
||||
#include "../StartInfo.h"
|
||||
#include "../Map.h"
|
||||
#include "../map.h"
|
||||
|
||||
std::map<int,std::map<int, std::vector<int> > > CGTeleport::objs;
|
||||
IGameCallback * IObjectInterface::cb = NULL;
|
||||
@ -554,6 +554,7 @@ void CGHeroInstance::onHeroVisit(const CGHeroInstance * h) const
|
||||
{
|
||||
if(cb->getHeroCount(h->tempOwner,false) < 8) //free hero slot
|
||||
{
|
||||
cb->changeObjPos(id,pos+int3(1,0,0),0);
|
||||
cb->setObjProperty(id,6,34); //set ID to 34
|
||||
cb->giveHero(id,h->tempOwner); //recreates def and adds hero to player
|
||||
|
||||
|
@ -64,5 +64,6 @@ public:
|
||||
virtual void setMovePoints(SetMovePoints * smp)=0;
|
||||
virtual void setManaPoints(int hid, int val)=0;
|
||||
virtual void giveHero(int id, int player)=0;
|
||||
virtual void changeObjPos(int objid, int3 newPos, ui8 flags)=0;
|
||||
};
|
||||
#endif // __IGAMECALLBACK_H__
|
@ -206,6 +206,20 @@ struct GiveBonus : public CPack<GiveBonus> //115
|
||||
}
|
||||
};
|
||||
|
||||
struct ChangeObjPos : public CPack<ChangeObjPos> //116
|
||||
{
|
||||
ChangeObjPos(){type = 116;};
|
||||
|
||||
ui32 objid;
|
||||
int3 nPos;
|
||||
ui8 flags; //bit flags: 1 - redraw
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & objid & nPos & flags;
|
||||
}
|
||||
};
|
||||
|
||||
struct RemoveObject : public CPack<RemoveObject> //500
|
||||
{
|
||||
RemoveObject(){type = 500;};
|
||||
|
5
map.cpp
5
map.cpp
@ -305,10 +305,7 @@ void CMapHeader::loadPlayerInfo( int &pom, unsigned char * bufor, int &i )
|
||||
if(players[pom].p9!=0xff)
|
||||
{
|
||||
players[pom].mainHeroPortrait = bufor[i++];
|
||||
int nameLength = bufor[i++];
|
||||
i+=3;
|
||||
for (int pp=0;pp<nameLength;pp++)
|
||||
players[pom].mainHeroName+=bufor[i++];
|
||||
players[pom].mainHeroName = readString(bufor,i);
|
||||
}
|
||||
|
||||
if(version != RoE)
|
||||
|
@ -1323,10 +1323,11 @@ upgend:
|
||||
|
||||
//TODO: skill level may be different on special terrain
|
||||
|
||||
if( !vstd::contains(h->spells,ba.additionalInfo) //hero doesn't know this spell
|
||||
if( !(vstd::contains(h->spells,ba.additionalInfo)) //hero doesn't know this spell
|
||||
|| (h->mana < s->costs[skill]) //not enough mana
|
||||
|| (ba.additionalInfo < 10) //it's adventure spell (not combat)
|
||||
|| 0 )//TODO: hero has already casted a spell in this round
|
||||
|| (gs->curB->castedSpells[ba.side])
|
||||
)
|
||||
{
|
||||
tlog2 << "Spell cannot be casted!\n";
|
||||
goto customactionend;
|
||||
@ -2322,4 +2323,13 @@ void CGameHandler::giveHero( int id, int player )
|
||||
gh.id = id;
|
||||
gh.player = player;
|
||||
sendAndApply(&gh);
|
||||
}
|
||||
|
||||
void CGameHandler::changeObjPos( int objid, int3 newPos, ui8 flags )
|
||||
{
|
||||
ChangeObjPos cop;
|
||||
cop.objid = objid;
|
||||
cop.nPos = newPos;
|
||||
cop.flags = flags;
|
||||
sendAndApply(&cop);
|
||||
}
|
@ -107,6 +107,7 @@ public:
|
||||
void setMovePoints(SetMovePoints * smp);
|
||||
void setManaPoints(int hid, int val);
|
||||
void giveHero(int id, int player);
|
||||
void changeObjPos(int objid, int3 newPos, ui8 flags);
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void init(StartInfo *si, int Seed);
|
||||
|
Loading…
Reference in New Issue
Block a user