mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-19 21:10:12 +02:00
Added horseSoundPenalty for terrains (for movement outside of roads)
This commit is contained in:
parent
64885bdf6b
commit
f3985d205b
@ -435,7 +435,7 @@ void CPlayerInterface::heroKilled(const CGHeroInstance* hero)
|
|||||||
adventureInt->select(newSelection, true);
|
adventureInt->select(newSelection, true);
|
||||||
else if (adventureInt->selection == hero)
|
else if (adventureInt->selection == hero)
|
||||||
adventureInt->selection = nullptr;
|
adventureInt->selection = nullptr;
|
||||||
|
|
||||||
if (vstd::contains(paths, hero))
|
if (vstd::contains(paths, hero))
|
||||||
paths.erase(hero);
|
paths.erase(hero);
|
||||||
}
|
}
|
||||||
@ -2373,6 +2373,7 @@ void CPlayerInterface::doMoveHero(const CGHeroInstance * h, CGPath path)
|
|||||||
|
|
||||||
TerrainId currentTerrain = ETerrainId::BORDER; // not init yet
|
TerrainId currentTerrain = ETerrainId::BORDER; // not init yet
|
||||||
TerrainId newTerrain;
|
TerrainId newTerrain;
|
||||||
|
bool wasOnRoad = true;
|
||||||
int sh = -1;
|
int sh = -1;
|
||||||
|
|
||||||
auto canStop = [&](CGPathNode * node) -> bool
|
auto canStop = [&](CGPathNode * node) -> bool
|
||||||
@ -2388,13 +2389,18 @@ void CPlayerInterface::doMoveHero(const CGHeroInstance * h, CGPath path)
|
|||||||
|
|
||||||
for (i=(int)path.nodes.size()-1; i>0 && (stillMoveHero.data == CONTINUE_MOVE || !canStop(&path.nodes[i])); i--)
|
for (i=(int)path.nodes.size()-1; i>0 && (stillMoveHero.data == CONTINUE_MOVE || !canStop(&path.nodes[i])); i--)
|
||||||
{
|
{
|
||||||
int3 currentCoord = path.nodes[i].coord;
|
int3 prevCoord = path.nodes[i].coord;
|
||||||
int3 nextCoord = path.nodes[i-1].coord;
|
int3 nextCoord = path.nodes[i-1].coord;
|
||||||
|
|
||||||
auto currentObject = getObj(currentCoord, currentCoord == h->pos);
|
auto prevRoad = cb->getTile(h->convertToVisitablePos(prevCoord))->roadType;
|
||||||
|
auto nextRoad = cb->getTile(h->convertToVisitablePos(nextCoord))->roadType;
|
||||||
|
|
||||||
|
bool movingOnRoad = prevRoad->getId() != Road::NO_ROAD && nextRoad->getId() != Road::NO_ROAD;
|
||||||
|
|
||||||
|
auto prevObject = getObj(prevCoord, prevCoord == h->pos);
|
||||||
auto nextObjectTop = getObj(nextCoord, false);
|
auto nextObjectTop = getObj(nextCoord, false);
|
||||||
auto nextObject = getObj(nextCoord, true);
|
auto nextObject = getObj(nextCoord, true);
|
||||||
auto destTeleportObj = getDestTeleportObj(currentObject, nextObjectTop, nextObject);
|
auto destTeleportObj = getDestTeleportObj(prevObject, nextObjectTop, nextObject);
|
||||||
if (isTeleportAction(path.nodes[i-1].action) && destTeleportObj != nullptr)
|
if (isTeleportAction(path.nodes[i-1].action) && destTeleportObj != nullptr)
|
||||||
{
|
{
|
||||||
CCS->soundh->stopSound(sh);
|
CCS->soundh->stopSound(sh);
|
||||||
@ -2409,7 +2415,10 @@ void CPlayerInterface::doMoveHero(const CGHeroInstance * h, CGPath path)
|
|||||||
}
|
}
|
||||||
if(i != path.nodes.size() - 1)
|
if(i != path.nodes.size() - 1)
|
||||||
{
|
{
|
||||||
sh = CCS->soundh->playSound(VLC->terrainTypeHandler->getById(currentTerrain)->horseSound, -1);
|
if (movingOnRoad)
|
||||||
|
sh = CCS->soundh->playSound(VLC->terrainTypeHandler->getById(currentTerrain)->horseSound, -1);
|
||||||
|
else
|
||||||
|
sh = CCS->soundh->playSound(VLC->terrainTypeHandler->getById(currentTerrain)->horseSoundPenalty, -1);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -2427,12 +2436,16 @@ void CPlayerInterface::doMoveHero(const CGHeroInstance * h, CGPath path)
|
|||||||
sh = CCS->soundh->playSound(soundBase::horseFlying, -1);
|
sh = CCS->soundh->playSound(soundBase::horseFlying, -1);
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
newTerrain = cb->getTile(h->convertToVisitablePos(currentCoord))->terType->id;
|
newTerrain = cb->getTile(h->convertToVisitablePos(prevCoord))->terType->id;
|
||||||
if(newTerrain != currentTerrain)
|
if(newTerrain != currentTerrain || wasOnRoad != movingOnRoad)
|
||||||
{
|
{
|
||||||
CCS->soundh->stopSound(sh);
|
CCS->soundh->stopSound(sh);
|
||||||
sh = CCS->soundh->playSound(VLC->terrainTypeHandler->getById(newTerrain)->horseSound, -1);
|
if (movingOnRoad)
|
||||||
|
sh = CCS->soundh->playSound(VLC->terrainTypeHandler->getById(newTerrain)->horseSound, -1);
|
||||||
|
else
|
||||||
|
sh = CCS->soundh->playSound(VLC->terrainTypeHandler->getById(newTerrain)->horseSoundPenalty, -1);
|
||||||
currentTerrain = newTerrain;
|
currentTerrain = newTerrain;
|
||||||
|
wasOnRoad = movingOnRoad;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,8 @@
|
|||||||
"river" : "mudRiver",
|
"river" : "mudRiver",
|
||||||
"battleFields" : ["dirt_birches", "dirt_hills", "dirt_pines"],
|
"battleFields" : ["dirt_birches", "dirt_hills", "dirt_pines"],
|
||||||
"terrainViewPatterns" : "dirt",
|
"terrainViewPatterns" : "dirt",
|
||||||
"horseSound" : "horseDirt"
|
"horseSound" : "horse00",
|
||||||
|
"horseSoundPenalty" : "horse20"
|
||||||
},
|
},
|
||||||
"sand" :
|
"sand" :
|
||||||
{
|
{
|
||||||
@ -26,7 +27,8 @@
|
|||||||
"battleFields" : ["sand_mesas"],
|
"battleFields" : ["sand_mesas"],
|
||||||
"transitionRequired" : true,
|
"transitionRequired" : true,
|
||||||
"terrainViewPatterns" : "sand",
|
"terrainViewPatterns" : "sand",
|
||||||
"horseSound" : "horseSand"
|
"horseSound" : "horse01",
|
||||||
|
"horseSoundPenalty" : "horse21"
|
||||||
},
|
},
|
||||||
"grass" :
|
"grass" :
|
||||||
{
|
{
|
||||||
@ -39,7 +41,8 @@
|
|||||||
"shortIdentifier" : "gr",
|
"shortIdentifier" : "gr",
|
||||||
"river" : "waterRiver",
|
"river" : "waterRiver",
|
||||||
"battleFields" : ["grass_hills", "grass_pines"],
|
"battleFields" : ["grass_hills", "grass_pines"],
|
||||||
"horseSound" : "horseGrass"
|
"horseSound" : "horse02",
|
||||||
|
"horseSoundPenalty" : "horse22"
|
||||||
},
|
},
|
||||||
"snow" :
|
"snow" :
|
||||||
{
|
{
|
||||||
@ -52,7 +55,8 @@
|
|||||||
"shortIdentifier" : "sn",
|
"shortIdentifier" : "sn",
|
||||||
"river" : "iceRiver",
|
"river" : "iceRiver",
|
||||||
"battleFields" : ["snow_mountains", "snow_trees"],
|
"battleFields" : ["snow_mountains", "snow_trees"],
|
||||||
"horseSound" : "horseSnow"
|
"horseSound" : "horse03",
|
||||||
|
"horseSoundPenalty" : "horse23"
|
||||||
},
|
},
|
||||||
"swamp" :
|
"swamp" :
|
||||||
{
|
{
|
||||||
@ -65,7 +69,8 @@
|
|||||||
"shortIdentifier" : "sw",
|
"shortIdentifier" : "sw",
|
||||||
"river" : "waterRiver",
|
"river" : "waterRiver",
|
||||||
"battleFields" : ["swamp_trees"],
|
"battleFields" : ["swamp_trees"],
|
||||||
"horseSound" : "horseSwamp"
|
"horseSound" : "horse04",
|
||||||
|
"horseSoundPenalty" : "horse24"
|
||||||
},
|
},
|
||||||
"rough" :
|
"rough" :
|
||||||
{
|
{
|
||||||
@ -78,7 +83,8 @@
|
|||||||
"shortIdentifier" : "rg",
|
"shortIdentifier" : "rg",
|
||||||
"river" : "mudRiver",
|
"river" : "mudRiver",
|
||||||
"battleFields" : ["rough"],
|
"battleFields" : ["rough"],
|
||||||
"horseSound" : "horseRough"
|
"horseSound" : "horse05",
|
||||||
|
"horseSoundPenalty" : "horse25"
|
||||||
},
|
},
|
||||||
"subterra" :
|
"subterra" :
|
||||||
{
|
{
|
||||||
@ -93,7 +99,8 @@
|
|||||||
"river" : "waterRiver",
|
"river" : "waterRiver",
|
||||||
"battleFields" : ["subterranean"],
|
"battleFields" : ["subterranean"],
|
||||||
"rockTerrain" : "rock",
|
"rockTerrain" : "rock",
|
||||||
"horseSound" : "horseSubterranean"
|
"horseSound" : "horse06",
|
||||||
|
"horseSoundPenalty" : "horse26"
|
||||||
},
|
},
|
||||||
"lava" :
|
"lava" :
|
||||||
{
|
{
|
||||||
@ -108,7 +115,8 @@
|
|||||||
"river" : "lavaRiver",
|
"river" : "lavaRiver",
|
||||||
"battleFields" : ["lava"],
|
"battleFields" : ["lava"],
|
||||||
"rockTerrain" : "rock",
|
"rockTerrain" : "rock",
|
||||||
"horseSound" : "horseLava"
|
"horseSound" : "horse07",
|
||||||
|
"horseSoundPenalty" : "horse27"
|
||||||
},
|
},
|
||||||
"water" :
|
"water" :
|
||||||
{
|
{
|
||||||
@ -123,7 +131,8 @@
|
|||||||
"battleFields" : ["ship"],
|
"battleFields" : ["ship"],
|
||||||
"transitionRequired" : true,
|
"transitionRequired" : true,
|
||||||
"terrainViewPatterns" : "water",
|
"terrainViewPatterns" : "water",
|
||||||
"horseSound" : "horseWater",
|
"horseSound" : "horse08",
|
||||||
|
"horseSoundPenalty" : "horse28"
|
||||||
"sounds": {
|
"sounds": {
|
||||||
"ambient": ["LOOPOCEA"]
|
"ambient": ["LOOPOCEA"]
|
||||||
}
|
}
|
||||||
@ -141,6 +150,7 @@
|
|||||||
"battleFields" : ["rocklands"],
|
"battleFields" : ["rocklands"],
|
||||||
"transitionRequired" : true,
|
"transitionRequired" : true,
|
||||||
"terrainViewPatterns" : "rock",
|
"terrainViewPatterns" : "rock",
|
||||||
"horseSound" : "horseRock"
|
"horseSound" : "horse09",
|
||||||
|
"horseSoundPenalty" : "horse29"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,7 @@ TerrainType * TerrainTypeHandler::loadFromJson( const std::string & scope, const
|
|||||||
info->musicFilename = json["music"].String();
|
info->musicFilename = json["music"].String();
|
||||||
info->tilesFilename = json["tiles"].String();
|
info->tilesFilename = json["tiles"].String();
|
||||||
info->horseSound = json["horseSound"].String();
|
info->horseSound = json["horseSound"].String();
|
||||||
|
info->horseSoundPenalty = json["horseSoundPenalty"].String();
|
||||||
info->transitionRequired = json["transitionRequired"].Bool();
|
info->transitionRequired = json["transitionRequired"].Bool();
|
||||||
info->terrainViewPatterns = json["terrainViewPatterns"].String();
|
info->terrainViewPatterns = json["terrainViewPatterns"].String();
|
||||||
info->nameTranslated = json["nameTranslated"].String();
|
info->nameTranslated = json["nameTranslated"].String();
|
||||||
@ -201,8 +202,8 @@ RoadType * RoadTypeHandler::loadFromJson(
|
|||||||
|
|
||||||
info->id = RoadId(index);
|
info->id = RoadId(index);
|
||||||
info->identifier = identifier;
|
info->identifier = identifier;
|
||||||
info->tilesFilename = json["animation"].String();
|
info->tilesFilename = json["tilesFilename"].String();
|
||||||
info->shortIdentifier = json["code"].String();
|
info->shortIdentifier = json["shortIdentifier"].String();
|
||||||
info->movementCost = json["moveCost"].Integer();
|
info->movementCost = json["moveCost"].Integer();
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
|
@ -49,6 +49,7 @@ public:
|
|||||||
std::string nameTranslated;
|
std::string nameTranslated;
|
||||||
std::string terrainViewPatterns;
|
std::string terrainViewPatterns;
|
||||||
std::string horseSound;
|
std::string horseSound;
|
||||||
|
std::string horseSoundPenalty;
|
||||||
|
|
||||||
TerrainId id;
|
TerrainId id;
|
||||||
TerrainId rockTerrain;
|
TerrainId rockTerrain;
|
||||||
@ -86,6 +87,7 @@ public:
|
|||||||
h & id;
|
h & id;
|
||||||
h & moveCost;
|
h & moveCost;
|
||||||
h & horseSound;
|
h & horseSound;
|
||||||
|
h & horseSoundPenalty;
|
||||||
h & passabilityType;
|
h & passabilityType;
|
||||||
h & transitionRequired;
|
h & transitionRequired;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user