1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Implemented placement sound for obstacles

This commit is contained in:
Ivan Savenko 2022-12-12 21:17:15 +02:00
parent 2148b76911
commit e791323502
12 changed files with 43 additions and 37 deletions

View File

@ -790,9 +790,9 @@ void CCatapultAnimation::nextFrame()
Point shotTarget = owner.stacksController->getStackPositionAtHex(dest, attackedStack) + Point(225, 225) - Point(126, 105);
if(catapultDamage > 0)
owner.stacksController->addNewAnim( new CPointEffectAnimation(owner, soundBase::WALLHIT, "SGEXPL.DEF", shotTarget));
owner.stacksController->addNewAnim( new CPointEffectAnimation(owner, "WALLHIT", "SGEXPL.DEF", shotTarget));
else
owner.stacksController->addNewAnim( new CPointEffectAnimation(owner, soundBase::WALLMISS, "CSGRCK.DEF", shotTarget));
owner.stacksController->addNewAnim( new CPointEffectAnimation(owner, "WALLMISS", "CSGRCK.DEF", shotTarget));
}
void CCatapultAnimation::createProjectile(const Point & from, const Point & dest) const
@ -868,10 +868,10 @@ uint32_t CCastAnimation::getAttackClimaxFrame() const
return 0;
}
CPointEffectAnimation::CPointEffectAnimation(BattleInterface & owner, soundBase::soundID sound, std::string animationName, int effects):
CPointEffectAnimation::CPointEffectAnimation(BattleInterface & owner, std::string soundName, std::string animationName, int effects):
CBattleAnimation(owner),
animation(std::make_shared<CAnimation>(animationName)),
sound(sound),
soundName(soundName),
effectFlags(effects),
soundPlayed(false),
soundFinished(false),
@ -880,33 +880,33 @@ CPointEffectAnimation::CPointEffectAnimation(BattleInterface & owner, soundBase:
logAnim->info("CPointEffectAnimation::init: effect %s", animationName);
}
CPointEffectAnimation::CPointEffectAnimation(BattleInterface & owner, soundBase::soundID sound, std::string animationName, std::vector<BattleHex> hex, int effects):
CPointEffectAnimation(owner, sound, animationName, effects)
CPointEffectAnimation::CPointEffectAnimation(BattleInterface & owner, std::string soundName, std::string animationName, std::vector<BattleHex> hex, int effects):
CPointEffectAnimation(owner, soundName, animationName, effects)
{
battlehexes = hex;
}
CPointEffectAnimation::CPointEffectAnimation(BattleInterface & owner, soundBase::soundID sound, std::string animationName, BattleHex hex, int effects):
CPointEffectAnimation(owner, sound, animationName, effects)
CPointEffectAnimation::CPointEffectAnimation(BattleInterface & owner, std::string soundName, std::string animationName, BattleHex hex, int effects):
CPointEffectAnimation(owner, soundName, animationName, effects)
{
assert(hex.isValid());
battlehexes.push_back(hex);
}
CPointEffectAnimation::CPointEffectAnimation(BattleInterface & owner, soundBase::soundID sound, std::string animationName, std::vector<Point> pos, int effects):
CPointEffectAnimation(owner, sound, animationName, effects)
CPointEffectAnimation::CPointEffectAnimation(BattleInterface & owner, std::string soundName, std::string animationName, std::vector<Point> pos, int effects):
CPointEffectAnimation(owner, soundName, animationName, effects)
{
positions = pos;
}
CPointEffectAnimation::CPointEffectAnimation(BattleInterface & owner, soundBase::soundID sound, std::string animationName, Point pos, int effects):
CPointEffectAnimation(owner, sound, animationName, effects)
CPointEffectAnimation::CPointEffectAnimation(BattleInterface & owner, std::string soundName, std::string animationName, Point pos, int effects):
CPointEffectAnimation(owner, soundName, animationName, effects)
{
positions.push_back(pos);
}
CPointEffectAnimation::CPointEffectAnimation(BattleInterface & owner, soundBase::soundID sound, std::string animationName, Point pos, BattleHex hex, int effects):
CPointEffectAnimation(owner, sound, animationName, effects)
CPointEffectAnimation::CPointEffectAnimation(BattleInterface & owner, std::string soundName, std::string animationName, Point pos, BattleHex hex, int effects):
CPointEffectAnimation(owner, soundName, animationName, effects)
{
assert(hex.isValid());
battlehexes.push_back(hex);
@ -1020,13 +1020,13 @@ void CPointEffectAnimation::playSound()
return;
soundPlayed = true;
if (sound == soundBase::invalid)
if (soundName.empty())
{
onSoundFinished();
return;
}
int channel = CCS->soundh->playSound(sound);
int channel = CCS->soundh->playSound(soundName);
if (!waitForSound() || channel == -1)
onSoundFinished();

View File

@ -287,7 +287,7 @@ struct CPointEffectParameters
/// Class that plays effect at one or more positions along with (single) sound effect
class CPointEffectAnimation : public CBattleAnimation
{
soundBase::soundID sound;
std::string soundName;
bool soundPlayed;
bool soundFinished;
bool effectFinished;
@ -319,17 +319,17 @@ public:
};
/// Create animation with screen-wide effect
CPointEffectAnimation(BattleInterface & owner, soundBase::soundID sound, std::string animationName, int effects = 0);
CPointEffectAnimation(BattleInterface & owner, std::string soundName, std::string animationName, int effects = 0);
/// Create animation positioned at point(s). Note that positions must be are absolute, including battleint position offset
CPointEffectAnimation(BattleInterface & owner, soundBase::soundID sound, std::string animationName, Point pos , int effects = 0);
CPointEffectAnimation(BattleInterface & owner, soundBase::soundID sound, std::string animationName, std::vector<Point> pos , int effects = 0);
CPointEffectAnimation(BattleInterface & owner, std::string soundName, std::string animationName, Point pos , int effects = 0);
CPointEffectAnimation(BattleInterface & owner, std::string soundName, std::string animationName, std::vector<Point> pos , int effects = 0);
/// Create animation positioned at certain hex(es)
CPointEffectAnimation(BattleInterface & owner, soundBase::soundID sound, std::string animationName, BattleHex hex , int effects = 0);
CPointEffectAnimation(BattleInterface & owner, soundBase::soundID sound, std::string animationName, std::vector<BattleHex> hex, int effects = 0);
CPointEffectAnimation(BattleInterface & owner, std::string soundName, std::string animationName, BattleHex hex , int effects = 0);
CPointEffectAnimation(BattleInterface & owner, std::string soundName, std::string animationName, std::vector<BattleHex> hex, int effects = 0);
CPointEffectAnimation(BattleInterface & owner, soundBase::soundID sound, std::string animationName, Point pos, BattleHex hex, int effects = 0);
CPointEffectAnimation(BattleInterface & owner, std::string soundName, std::string animationName, Point pos, BattleHex hex, int effects = 0);
~CPointEffectAnimation();
bool init() override;

View File

@ -44,7 +44,7 @@ void BattleEffectsController::displayEffect(EBattleEffect::EBattleEffect effect,
{
std::string customAnim = graphics->battleACToDef[effect][0];
owner.stacksController->addNewAnim(new CPointEffectAnimation(owner, soundBase::soundID(soundID), customAnim, destTile));
owner.stacksController->addNewAnim(new CPointEffectAnimation(owner, soundBase::stringsList()[soundID], customAnim, destTile));
}
void BattleEffectsController::displayCustomEffects(const std::vector<CustomEffectInfo> & customEffects)

View File

@ -575,8 +575,8 @@ void BattleInterface::spellCast(const BattleSpellCast * sc)
bool side = sc->side;
executeOnAnimationCondition(EAnimationEvents::AFTER_HIT, true, [=](){
stacksController->addNewAnim(new CPointEffectAnimation(*this, soundBase::invalid, side ? "SP07_A.DEF" : "SP07_B.DEF", leftHero));
stacksController->addNewAnim(new CPointEffectAnimation(*this, soundBase::invalid, side ? "SP07_B.DEF" : "SP07_A.DEF", rightHero));
stacksController->addNewAnim(new CPointEffectAnimation(*this, "", side ? "SP07_A.DEF" : "SP07_B.DEF", leftHero));
stacksController->addNewAnim(new CPointEffectAnimation(*this, "", side ? "SP07_B.DEF" : "SP07_A.DEF", rightHero));
});
}
}
@ -632,9 +632,9 @@ void BattleInterface::displaySpellAnimationQueue(const CSpell::TAnimationQueue &
flags |= CPointEffectAnimation::SCREEN_FILL;
if (!destinationTile.isValid())
stacksController->addNewAnim(new CPointEffectAnimation(*this, soundBase::invalid, animation.resourceName, flags));
stacksController->addNewAnim(new CPointEffectAnimation(*this, "", animation.resourceName, flags));
else
stacksController->addNewAnim(new CPointEffectAnimation(*this, soundBase::invalid, animation.resourceName, destinationTile, flags));
stacksController->addNewAnim(new CPointEffectAnimation(*this, "", animation.resourceName, destinationTile, flags));
}
}
}

View File

@ -97,14 +97,10 @@ void BattleObstacleController::obstaclePlaced(const std::vector<std::shared_ptr<
continue;
}
//TODO: sound
//soundBase::QUIKSAND
//soundBase::LANDMINE
//we assume here that effect graphics have the same size as the usual obstacle image
// -> if we know how to blit obstacle, let's blit the effect in the same place
Point whereTo = getObstaclePosition(first, *oi);
owner.stacksController->addNewAnim(new CPointEffectAnimation(owner, soundBase::invalid, spellObstacle->appearAnimation, whereTo, oi->pos, CPointEffectAnimation::WAIT_FOR_SOUND));
owner.stacksController->addNewAnim(new CPointEffectAnimation(owner, spellObstacle->appearSound, spellObstacle->appearAnimation, whereTo, oi->pos));
//so when multiple obstacles are added, they show up one after another
owner.waitForAnimationCondition(EAnimationEvents::ACTION, false);

View File

@ -347,7 +347,7 @@ void BattleSiegeController::stackIsCatapulting(const CatapultAttack & ca)
for (auto attackInfo : ca.attackedParts)
positions.push_back(owner.stacksController->getStackPositionAtHex(attackInfo.destinationTile, nullptr) + Point(99, 120));
owner.stacksController->addNewAnim(new CPointEffectAnimation(owner, soundBase::WALLHIT, "SGEXPL.DEF", positions));
owner.stacksController->addNewAnim(new CPointEffectAnimation(owner, "WALLHIT", "SGEXPL.DEF", positions));
}
owner.waitForAnimationCondition(EAnimationEvents::ACTION, false);

View File

@ -21,11 +21,13 @@
"attacker" :{
"animation" : "C17SPE1",
"appearAnimation" : "C17SPE0",
"appearSound" : "QUIKSAND",
"offsetY" : -42
},
"defender" :{
"animation" : "C17SPE1",
"appearAnimation" : "C17SPE0",
"appearSound" : "QUIKSAND",
"offsetY" : -42
}
}
@ -72,11 +74,13 @@
"turnsRemaining" : -1,
"attacker" :{
"animation" : "C09SPF1",
"appearAnimation" : "C09SPF0"
"appearAnimation" : "C09SPF0",
"appearSound" : "LANDMINE"
},
"defender" :{
"animation" : "C09SPF1",
"appearAnimation" : "C09SPF0"
"appearAnimation" : "C09SPF0",
"appearSound" : "LANDMINE"
}
},
"damage":{

View File

@ -32,7 +32,7 @@ public:
Obstacle obstacle;
si32 iconIndex;
std::string identifier;
std::string appearAnimation, animation, dissapearAnimation;
std::string appearSound, appearAnimation, animation, dissapearAnimation;
std::vector<TerrainId> allowedTerrains;
std::vector<std::string> allowedSpecialBfields;
@ -61,6 +61,7 @@ public:
h & iconIndex;
h & identifier;
h & animation;
h & appearSound;
h & appearAnimation;
h & dissapearAnimation;
h & allowedTerrains;

View File

@ -176,6 +176,7 @@ void SpellCreatedObstacle::serializeJson(JsonSerializeFormat & handler)
handler.serializeBool("trap", trap);
handler.serializeBool("removeOnTrigger", removeOnTrigger);
handler.serializeString("appearSound", appearSound);
handler.serializeString("appearAnimation", appearAnimation);
handler.serializeString("animation", animation);

View File

@ -79,6 +79,7 @@ struct DLL_LINKAGE SpellCreatedObstacle : CObstacleInstance
bool revealed;
std::string appearSound;
std::string appearAnimation;
std::string animation;

View File

@ -41,6 +41,7 @@ void ObstacleSideOptions::serializeJson(JsonSerializeFormat & handler)
serializeRelativeShape(handler, "shape", shape);
serializeRelativeShape(handler, "range", range);
handler.serializeString("appearSound", appearSound);
handler.serializeString("appearAnimation", appearAnimation);
handler.serializeString("animation", animation);
@ -313,6 +314,7 @@ void Obstacle::placeObstacles(ServerCallback * server, const Mechanics * m, cons
obstacle.trap = trap;
obstacle.removeOnTrigger = removeOnTrigger;
obstacle.appearSound = options.appearSound;
obstacle.appearAnimation = options.appearAnimation;
obstacle.animation = options.animation;

View File

@ -29,6 +29,7 @@ public:
RelativeShape shape; //shape of single obstacle relative to obstacle position
RelativeShape range; //position of obstacles relative to effect destination
std::string appearSound;
std::string appearAnimation;
std::string animation;