소스 검색

(partially) fix catapult explosion effect

Ivan Savenko 2 년 전
부모
커밋
055824654e
3개의 변경된 파일31개의 추가작업 그리고 24개의 파일을 삭제
  1. 29 15
      client/battle/CBattleAnimations.cpp
  2. 2 0
      client/battle/CBattleAnimations.h
  3. 0 9
      client/battle/CBattleProjectileController.cpp

+ 29 - 15
client/battle/CBattleAnimations.cpp

@@ -731,7 +731,8 @@ CRangedAttackAnimation::CRangedAttackAnimation(CBattleInterface * owner_, const
 CShootingAnimation::CShootingAnimation(CBattleInterface * _owner, const CStack * attacker, BattleHex _dest, const CStack * _attacked, bool _catapult, int _catapultDmg)
 	: CRangedAttackAnimation(_owner, attacker, _dest, _attacked),
 	catapultDamage(_catapultDmg),
-	projectileEmitted(false)
+	projectileEmitted(false),
+	explosionEmitted(false)
 {
 	logAnim->debug("Created shooting anim for %s", stack->getName());
 }
@@ -841,7 +842,10 @@ void CShootingAnimation::nextFrame()
 			return;
 		}
 		else
+		{
 			stackAnimation(attackingStack)->play();
+			emitExplosion();
+		}
 	}
 
 	CAttackAnimation::nextFrame();
@@ -861,6 +865,30 @@ void CShootingAnimation::nextFrame()
 	}
 }
 
+void CShootingAnimation::emitExplosion()
+{
+	if (attackedStack)
+		return;
+
+	if (explosionEmitted)
+		return;
+
+	explosionEmitted = true;
+
+	Point shotTarget = owner->stacksController->getStackPositionAtHex(dest, attackedStack) + Point(225, 225) - Point(126, 105);
+
+	owner->stacksController->addNewAnim( new CEffectAnimation(owner, catapultDamage ? "SGEXPL.DEF" : "CSGRCK.DEF", shotTarget.x, shotTarget.y));
+
+	if(catapultDamage > 0)
+	{
+		CCS->soundh->playSound("WALLHIT");
+	}
+	else
+	{
+		CCS->soundh->playSound("WALLMISS");
+	}
+}
+
 void CShootingAnimation::endAnim()
 {
 	assert(!owner->projectilesController->hasActiveProjectile(attackingStack));
@@ -872,20 +900,6 @@ void CShootingAnimation::endAnim()
 		logAnim->warn("Shooting animation has finished but projectile was not emitted! Emitting it now...");
 		emitProjectile();
 	}
-
-	// play wall hit/miss sound for catapult attack
-	if(!attackedStack)
-	{
-		if(catapultDamage > 0)
-		{
-			CCS->soundh->playSound("WALLHIT");
-		}
-		else
-		{
-			CCS->soundh->playSound("WALLMISS");
-		}
-	}
-
 	CAttackAnimation::endAnim();
 	delete this;
 }

+ 2 - 0
client/battle/CBattleAnimations.h

@@ -210,11 +210,13 @@ class CShootingAnimation : public CRangedAttackAnimation
 {
 private:
 	bool projectileEmitted;
+	bool explosionEmitted;
 	int catapultDamage;
 
 	void setAnimationGroup();
 	void initializeProjectile();
 	void emitProjectile();
+	void emitExplosion();
 public:
 	bool init() override;
 	void nextFrame() override;

+ 0 - 9
client/battle/CBattleProjectileController.cpp

@@ -78,15 +78,6 @@ void ProjectileCatapult::show(std::shared_ptr<CCanvas> canvas)
 		canvas->draw(image, pos);
 
 		frameNum = (frameNum + 1) % animation->size(0);
-
-		if (step == steps)
-		{
-			//TODO: re-enable. Move to ShootingAnimation? What about spells?
-			// last step - explosion effect
-			//Point explosion_pos = pos + image->dimensions() / 2 - Point(126, 105);
-
-			//owner->addNewAnim( new CEffectAnimation(owner, catapultDamage ? "SGEXPL.DEF" : "CSGRCK.DEF", animPos.x, animPos.y));
-		}
 	}
 	++step;
 }