1
0
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:
Ivan Savenko 2022-12-24 16:48:24 +02:00
parent 64885bdf6b
commit f3985d205b
4 changed files with 46 additions and 20 deletions

View File

@ -2373,6 +2373,7 @@ void CPlayerInterface::doMoveHero(const CGHeroInstance * h, CGPath path)
TerrainId currentTerrain = ETerrainId::BORDER; // not init yet
TerrainId newTerrain;
bool wasOnRoad = true;
int sh = -1;
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--)
{
int3 currentCoord = path.nodes[i].coord;
int3 prevCoord = path.nodes[i].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 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)
{
CCS->soundh->stopSound(sh);
@ -2409,7 +2415,10 @@ void CPlayerInterface::doMoveHero(const CGHeroInstance * h, CGPath path)
}
if(i != path.nodes.size() - 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;
}
@ -2427,12 +2436,16 @@ void CPlayerInterface::doMoveHero(const CGHeroInstance * h, CGPath path)
sh = CCS->soundh->playSound(soundBase::horseFlying, -1);
#endif
{
newTerrain = cb->getTile(h->convertToVisitablePos(currentCoord))->terType->id;
if(newTerrain != currentTerrain)
newTerrain = cb->getTile(h->convertToVisitablePos(prevCoord))->terType->id;
if(newTerrain != currentTerrain || wasOnRoad != movingOnRoad)
{
CCS->soundh->stopSound(sh);
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;
wasOnRoad = movingOnRoad;
}
}

View File

@ -11,7 +11,8 @@
"river" : "mudRiver",
"battleFields" : ["dirt_birches", "dirt_hills", "dirt_pines"],
"terrainViewPatterns" : "dirt",
"horseSound" : "horseDirt"
"horseSound" : "horse00",
"horseSoundPenalty" : "horse20"
},
"sand" :
{
@ -26,7 +27,8 @@
"battleFields" : ["sand_mesas"],
"transitionRequired" : true,
"terrainViewPatterns" : "sand",
"horseSound" : "horseSand"
"horseSound" : "horse01",
"horseSoundPenalty" : "horse21"
},
"grass" :
{
@ -39,7 +41,8 @@
"shortIdentifier" : "gr",
"river" : "waterRiver",
"battleFields" : ["grass_hills", "grass_pines"],
"horseSound" : "horseGrass"
"horseSound" : "horse02",
"horseSoundPenalty" : "horse22"
},
"snow" :
{
@ -52,7 +55,8 @@
"shortIdentifier" : "sn",
"river" : "iceRiver",
"battleFields" : ["snow_mountains", "snow_trees"],
"horseSound" : "horseSnow"
"horseSound" : "horse03",
"horseSoundPenalty" : "horse23"
},
"swamp" :
{
@ -65,7 +69,8 @@
"shortIdentifier" : "sw",
"river" : "waterRiver",
"battleFields" : ["swamp_trees"],
"horseSound" : "horseSwamp"
"horseSound" : "horse04",
"horseSoundPenalty" : "horse24"
},
"rough" :
{
@ -78,7 +83,8 @@
"shortIdentifier" : "rg",
"river" : "mudRiver",
"battleFields" : ["rough"],
"horseSound" : "horseRough"
"horseSound" : "horse05",
"horseSoundPenalty" : "horse25"
},
"subterra" :
{
@ -93,7 +99,8 @@
"river" : "waterRiver",
"battleFields" : ["subterranean"],
"rockTerrain" : "rock",
"horseSound" : "horseSubterranean"
"horseSound" : "horse06",
"horseSoundPenalty" : "horse26"
},
"lava" :
{
@ -108,7 +115,8 @@
"river" : "lavaRiver",
"battleFields" : ["lava"],
"rockTerrain" : "rock",
"horseSound" : "horseLava"
"horseSound" : "horse07",
"horseSoundPenalty" : "horse27"
},
"water" :
{
@ -123,7 +131,8 @@
"battleFields" : ["ship"],
"transitionRequired" : true,
"terrainViewPatterns" : "water",
"horseSound" : "horseWater",
"horseSound" : "horse08",
"horseSoundPenalty" : "horse28"
"sounds": {
"ambient": ["LOOPOCEA"]
}
@ -141,6 +150,7 @@
"battleFields" : ["rocklands"],
"transitionRequired" : true,
"terrainViewPatterns" : "rock",
"horseSound" : "horseRock"
"horseSound" : "horse09",
"horseSoundPenalty" : "horse29"
}
}

View File

@ -44,6 +44,7 @@ TerrainType * TerrainTypeHandler::loadFromJson( const std::string & scope, const
info->musicFilename = json["music"].String();
info->tilesFilename = json["tiles"].String();
info->horseSound = json["horseSound"].String();
info->horseSoundPenalty = json["horseSoundPenalty"].String();
info->transitionRequired = json["transitionRequired"].Bool();
info->terrainViewPatterns = json["terrainViewPatterns"].String();
info->nameTranslated = json["nameTranslated"].String();
@ -201,8 +202,8 @@ RoadType * RoadTypeHandler::loadFromJson(
info->id = RoadId(index);
info->identifier = identifier;
info->tilesFilename = json["animation"].String();
info->shortIdentifier = json["code"].String();
info->tilesFilename = json["tilesFilename"].String();
info->shortIdentifier = json["shortIdentifier"].String();
info->movementCost = json["moveCost"].Integer();
return info;

View File

@ -49,6 +49,7 @@ public:
std::string nameTranslated;
std::string terrainViewPatterns;
std::string horseSound;
std::string horseSoundPenalty;
TerrainId id;
TerrainId rockTerrain;
@ -86,6 +87,7 @@ public:
h & id;
h & moveCost;
h & horseSound;
h & horseSoundPenalty;
h & passabilityType;
h & transitionRequired;
}