mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-11 01:10:26 +02:00
Merge pull request #123 from ArseniyShestakov/mantis-1230
Okay, now we shouldn't get broken savegames. Merging.
This commit is contained in:
@ -369,6 +369,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"NO_TERRAIN_PENALTY":
|
||||||
|
{
|
||||||
|
"hidden": true
|
||||||
|
},
|
||||||
|
|
||||||
"NON_LIVING":
|
"NON_LIVING":
|
||||||
{
|
{
|
||||||
"graphics":
|
"graphics":
|
||||||
|
@ -475,6 +475,15 @@
|
|||||||
"index": 142,
|
"index": 142,
|
||||||
"level": 3,
|
"level": 3,
|
||||||
"faction": "neutral",
|
"faction": "neutral",
|
||||||
|
"abilities":
|
||||||
|
{
|
||||||
|
"sandWalker" :
|
||||||
|
{
|
||||||
|
"type" : "NO_TERRAIN_PENALTY",
|
||||||
|
"subtype" : 1,
|
||||||
|
"propagator" : "HERO"
|
||||||
|
}
|
||||||
|
},
|
||||||
"doubleWide" : true,
|
"doubleWide" : true,
|
||||||
"graphics" :
|
"graphics" :
|
||||||
{
|
{
|
||||||
|
@ -51,6 +51,7 @@ namespace GameConstants
|
|||||||
const int SPELLS_QUANTITY=70;
|
const int SPELLS_QUANTITY=70;
|
||||||
const int CREATURES_COUNT = 197;
|
const int CREATURES_COUNT = 197;
|
||||||
|
|
||||||
|
const ui32 BASE_MOVEMENT_COST = 100; //default cost for non-diagonal movement
|
||||||
}
|
}
|
||||||
|
|
||||||
class CArtifact;
|
class CArtifact;
|
||||||
|
@ -216,7 +216,9 @@ public:
|
|||||||
BONUS_NAME(SPOILS_OF_WAR) /*val * 10^-6 * gained exp resources of subtype will be given to hero after battle*/\
|
BONUS_NAME(SPOILS_OF_WAR) /*val * 10^-6 * gained exp resources of subtype will be given to hero after battle*/\
|
||||||
BONUS_NAME(BLOCK)\
|
BONUS_NAME(BLOCK)\
|
||||||
BONUS_NAME(DISGUISED) /* subtype - spell level */\
|
BONUS_NAME(DISGUISED) /* subtype - spell level */\
|
||||||
BONUS_NAME(VISIONS) /* subtype - spell level */
|
BONUS_NAME(VISIONS) /* subtype - spell level */\
|
||||||
|
BONUS_NAME(NO_TERRAIN_PENALTY) /* subtype - terrain type */\
|
||||||
|
/* end of list */
|
||||||
|
|
||||||
|
|
||||||
#define BONUS_SOURCE_LIST \
|
#define BONUS_SOURCE_LIST \
|
||||||
|
@ -58,56 +58,49 @@ static int lowestSpeed(const CGHeroInstance * chi)
|
|||||||
|
|
||||||
ui32 CGHeroInstance::getTileCost(const TerrainTile &dest, const TerrainTile &from) const
|
ui32 CGHeroInstance::getTileCost(const TerrainTile &dest, const TerrainTile &from) const
|
||||||
{
|
{
|
||||||
//base move cost
|
unsigned ret = GameConstants::BASE_MOVEMENT_COST;
|
||||||
unsigned ret = 100;
|
|
||||||
|
|
||||||
//if there is road both on dest and src tiles - use road movement cost
|
//if there is road both on dest and src tiles - use road movement cost
|
||||||
if(dest.roadType != ERoadType::NO_ROAD && from.roadType != ERoadType::NO_ROAD)
|
if(dest.roadType != ERoadType::NO_ROAD && from.roadType != ERoadType::NO_ROAD)
|
||||||
{
|
{
|
||||||
int road = std::min(dest.roadType,from.roadType); //used road ID
|
int road = std::min(dest.roadType,from.roadType); //used road ID
|
||||||
switch(road)
|
switch(road)
|
||||||
{
|
{
|
||||||
case ERoadType::DIRT_ROAD:
|
case ERoadType::DIRT_ROAD:
|
||||||
ret = 75;
|
ret = 75;
|
||||||
break;
|
break;
|
||||||
case ERoadType::GRAVEL_ROAD:
|
case ERoadType::GRAVEL_ROAD:
|
||||||
ret = 65;
|
ret = 65;
|
||||||
break;
|
break;
|
||||||
case ERoadType::COBBLESTONE_ROAD:
|
case ERoadType::COBBLESTONE_ROAD:
|
||||||
ret = 50;
|
ret = 50;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logGlobal->errorStream() << "Unknown road type: " << road << "... Something wrong!";
|
logGlobal->errorStream() << "Unknown road type: " << road << "... Something wrong!";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if(!hasBonusOfType(Bonus::NO_TERRAIN_PENALTY, from.terType))
|
||||||
{
|
{
|
||||||
//FIXME: in H3 presence of Nomad in army will remove terrain penalty for sand. Bonus not implemented in VCMI
|
|
||||||
|
|
||||||
// NOTE: in H3 neutral stacks will ignore terrain penalty only if placed as topmost stack(s) in hero army.
|
// NOTE: in H3 neutral stacks will ignore terrain penalty only if placed as topmost stack(s) in hero army.
|
||||||
// This is clearly bug in H3 however intended behaviour is not clear.
|
// This is clearly bug in H3 however intended behaviour is not clear.
|
||||||
// Current VCMI behaviour will ignore neutrals in calculations so army in VCMI
|
// Current VCMI behaviour will ignore neutrals in calculations so army in VCMI
|
||||||
// will always have best penalty without any influence from player-defined stacks order
|
// will always have best penalty without any influence from player-defined stacks order
|
||||||
|
|
||||||
bool nativeArmy = true;
|
|
||||||
for(auto stack : stacks)
|
for(auto stack : stacks)
|
||||||
{
|
{
|
||||||
int nativeTerrain = VLC->townh->factions[stack.second->type->faction]->nativeTerrain;
|
int nativeTerrain = VLC->townh->factions[stack.second->type->faction]->nativeTerrain;
|
||||||
|
if(nativeTerrain != -1 && nativeTerrain != from.terType)
|
||||||
if (nativeTerrain != -1 && nativeTerrain != from.terType)
|
|
||||||
{
|
{
|
||||||
nativeArmy = false;
|
ret = VLC->heroh->terrCosts[from.terType];
|
||||||
|
ret -= getSecSkillLevel(SecondarySkill::PATHFINDING) * 25;
|
||||||
|
if(ret < GameConstants::BASE_MOVEMENT_COST)
|
||||||
|
ret = GameConstants::BASE_MOVEMENT_COST;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!nativeArmy)
|
}
|
||||||
{
|
|
||||||
ret = VLC->heroh->terrCosts[from.terType];
|
|
||||||
ret-=getSecSkillLevel(SecondarySkill::PATHFINDING)*25;
|
|
||||||
ret = ret < 100 ? 100 : ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user