mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
* hopefully resolved bugs 19 and 20 reported by Zamolxis
This commit is contained in:
parent
ba9b58d3a4
commit
811e6c0945
@ -180,8 +180,8 @@ void CPathfinder::convertPath(CPath * path, unsigned int mode) //mode=0 -> from
|
||||
void CPathfinder::processNode(CPathNode & dp, const CGHeroInstance * hero, std::queue<CPathNode> & mq, const CPathNode & cp, const int3 & src, bool diagonal)
|
||||
{
|
||||
const TerrainTile * tinfo = CGI->mh->ttiles[dp.coord.x][dp.coord.y][src.z].tileInfo;
|
||||
int cost = hero->getTileCost(tinfo->tertype, tinfo->malle, tinfo->nuine);
|
||||
if(diagonal)
|
||||
int cost = hero->getTileCost(tinfo->tertype, tinfo->malle, tinfo->nuine, hero->movement - cp.dist);
|
||||
if(diagonal && (hero->movement - cp.dist) > 145) //second condition - workaround for strange behaviour manifested by Heroes III
|
||||
cost *= std::sqrt(2.0);
|
||||
if((dp.dist==-1 || (dp.dist > cp.dist + cost)) && dp.accesible && checkForVisitableDir(cp.coord, dp.coord) && checkForVisitableDir(dp.coord, cp.coord))
|
||||
{
|
||||
|
@ -2506,7 +2506,17 @@ void CHeroList::select(int which)
|
||||
selected = which;
|
||||
LOCPLINT->adventureInt->centerOn(items[which].first->pos);
|
||||
LOCPLINT->adventureInt->selection = items[which].first;
|
||||
LOCPLINT->adventureInt->terrain.currentPath = items[which].second;
|
||||
//recalculationg path in case of something has changed on map
|
||||
if(items[which].second)
|
||||
{
|
||||
CPath * newPath = CGI->pathf->getPath(items[which].second->startPos(), items[which].second->endPos(), items[which].first);
|
||||
LOCPLINT->adventureInt->terrain.currentPath = items[which].second = newPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOCPLINT->adventureInt->terrain.currentPath = NULL;
|
||||
}
|
||||
//recalculated and assigned
|
||||
draw();
|
||||
LOCPLINT->adventureInt->townList.draw();
|
||||
LOCPLINT->adventureInt->infoBar.draw(NULL);
|
||||
|
@ -195,8 +195,9 @@ int lowestSpeed(const CGHeroInstance * chi)
|
||||
return ret;
|
||||
}
|
||||
|
||||
unsigned int CGHeroInstance::getTileCost(const EterrainType & ttype, const Eroad & rdtype, const Eriver & rvtype) const
|
||||
unsigned int CGHeroInstance::getTileCost(const EterrainType & ttype, const Eroad & rdtype, const Eriver & rvtype, const int & remaingMP) const
|
||||
{
|
||||
if(remaingMP <= 100) return 100; //workaround for strange behaviour manifested by Heroes III
|
||||
unsigned int ret = type->heroClass->terrCosts[ttype];
|
||||
//applying pathfinding skill
|
||||
switch(getSecSkillLevel(0))
|
||||
|
@ -207,7 +207,7 @@ public:
|
||||
const HeroBonus *getBonus(int from, int id) const;
|
||||
const std::string &getBiography() const;
|
||||
bool needsLastStack()const;
|
||||
unsigned int getTileCost(const EterrainType & ttype, const Eroad & rdtype, const Eriver & rvtype) const;
|
||||
unsigned int getTileCost(const EterrainType & ttype, const Eroad & rdtype, const Eriver & rvtype, const int & remaingMP) const;
|
||||
unsigned int getLowestCreatureSpeed() const;
|
||||
unsigned int getAdditiveMoveBonus() const;
|
||||
float getMultiplicativeMoveBonus() const;
|
||||
|
@ -495,7 +495,9 @@ void CGameHandler::handleConnection(std::set<int> players, CConnection &c)
|
||||
int3 hmpos = end + int3(-1,0,0);
|
||||
TerrainTile t = gs->map->terrain[hmpos.x][hmpos.y][hmpos.z];
|
||||
CGHeroInstance *h = static_cast<CGHeroInstance *>(gs->map->objects[id]);
|
||||
int cost = (int)((double)h->getTileCost(t.tertype,t.malle,t.nuine) * distance(start,end));
|
||||
double dist = distance(start,end);
|
||||
if(h->movement <= 145) dist = 1.0f; //workaround for strange behaviour manifested by Heroes III
|
||||
int cost = (int)((double)h->getTileCost(t.tertype,t.malle,t.nuine, h->movement) * dist);
|
||||
|
||||
TryMoveHero tmh;
|
||||
tmh.id = id;
|
||||
|
Loading…
Reference in New Issue
Block a user