Przeglądaj źródła

Fix cast animation for Genie and heroes

Ivan Savenko 2 lat temu
rodzic
commit
3693184e51

+ 4 - 1
client/battle/BattleAnimationClasses.cpp

@@ -1123,10 +1123,13 @@ bool HeroCastAnimation::init()
 
 void HeroCastAnimation::initializeProjectile()
 {
-	//spell has no projectile to play, ignore this step
+	// spell has no projectile to play, ignore this step
 	if (spell->animationInfo.projectile.empty())
 		return;
 
+	// targeted spells should have well, target
+	assert(tile.isValid());
+
 	Point srccoord = hero->pos.center();
 	Point destcoord = owner.stacksController->getStackPositionAtHex(tile, target); //position attacked by projectile
 

+ 5 - 2
client/battle/BattleInterface.cpp

@@ -492,7 +492,11 @@ void BattleInterface::spellCast(const BattleSpellCast * sc)
 
 	if (!castSoundPath.empty())
 	{
-		executeOnAnimationCondition(EAnimationEvents::BEFORE_HIT, true, [=]() {
+		auto group = spell->animationInfo.projectile.empty() ?
+					EAnimationEvents::HIT:
+					EAnimationEvents::BEFORE_HIT;//FIXME: should be on projectile spawning
+
+		executeOnAnimationCondition(group, true, [=]() {
 			CCS->soundh->playSound(castSoundPath);
 		});
 	}
@@ -510,7 +514,6 @@ void BattleInterface::spellCast(const BattleSpellCast * sc)
 			});
 		}
 		else
-		if (targetedTile.isValid())
 		{
 			auto hero = sc->side ? defendingHero : attackingHero;
 			assert(hero);