瀏覽代碼

Fix ranged attack animations

Ivan Savenko 2 年之前
父節點
當前提交
2442d38b9a
共有 2 個文件被更改,包括 11 次插入12 次删除
  1. 6 7
      client/battle/CBattleAnimations.cpp
  2. 5 5
      client/battle/CBattleProjectileController.cpp

+ 6 - 7
client/battle/CBattleAnimations.cpp

@@ -738,7 +738,7 @@ bool CRangedAttackAnimation::init()
 void CRangedAttackAnimation::setAnimationGroup()
 {
 	Point shooterPos = stackAnimation(attackingStack)->pos.topLeft();
-	Point shotTarget = owner->stacksController->getStackPositionAtHex(dest, attackedStack) + Point(225, 225);
+	Point shotTarget = owner->stacksController->getStackPositionAtHex(dest, attackedStack);
 
 	//maximal angle in radians between straight horizontal line and shooting line for which shot is considered to be straight (absoulte value)
 	static const double straightAngle = 0.2;
@@ -761,17 +761,17 @@ void CRangedAttackAnimation::initializeProjectile()
 	Point shotOrigin = stackAnimation(attackingStack)->pos.topLeft() + Point(222, 265);
 	int multiplier = stackFacingRight(attackingStack) ? 1 : -1;
 
-	if (group == CCreatureAnim::SHOOT_UP)
+	if (group == getUpwardsGroup())
 	{
 		shotOrigin.x += ( -25 + shooterInfo->animation.upperRightMissleOffsetX ) * multiplier;
 		shotOrigin.y += shooterInfo->animation.upperRightMissleOffsetY;
 	}
-	else if (group == CCreatureAnim::SHOOT_DOWN)
+	else if (group == getDownwardsGroup())
 	{
 		shotOrigin.x += ( -25 + shooterInfo->animation.lowerRightMissleOffsetX ) * multiplier;
 		shotOrigin.y += shooterInfo->animation.lowerRightMissleOffsetY;
 	}
-	else if (group == CCreatureAnim::SHOOT_FRONT)
+	else if (group == getForwardGroup())
 	{
 		shotOrigin.x += ( -25 + shooterInfo->animation.rightMissleOffsetX ) * multiplier;
 		shotOrigin.y += shooterInfo->animation.rightMissleOffsetY;
@@ -819,8 +819,6 @@ void CRangedAttackAnimation::nextFrame()
 	{
 		const CCreature *shooterInfo = getCreature();
 
-		assert(stackAnimation(attackingStack)->isShooting());
-
 		logAnim->info("Ranged attack executing, %d / %d / %d",
 					  stackAnimation(attackingStack)->getCurrentFrame(),
 					  shooterInfo->animation.attackClimaxFrame,
@@ -967,7 +965,8 @@ CCreatureAnim::EAnimType CCastAnimation::getDownwardsGroup() const
 
 void CCastAnimation::createProjectile(const Point & from, const Point & dest) const
 {
-	owner->projectilesController->createSpellProjectile(attackingStack, attackedStack, from, dest, spell);
+	if (!spell->animationInfo.projectile.empty())
+		owner->projectilesController->createSpellProjectile(attackingStack, attackedStack, from, dest, spell);
 }
 
 CPointEffectAnimation::CPointEffectAnimation(CBattleInterface * _owner, soundBase::soundID sound, std::string animationName, int effects):

+ 5 - 5
client/battle/CBattleProjectileController.cpp

@@ -343,14 +343,14 @@ void CBattleProjectileController::createProjectile(const CStack * shooter, const
 		missileProjectile->animation = getProjectileImage(shooter);
 		missileProjectile->reverse  = !owner->stacksController->facingRight(shooter);
 		missileProjectile->frameNum = computeProjectileFrameID(from, dest, shooter);
-		missileProjectile->steps = computeProjectileFlightTime(from, dest, AnimationControls::getProjectileSpeed());
 	}
 
-	projectile->from     = from;
-	projectile->dest     = dest;
+	projectile->steps     = computeProjectileFlightTime(from, dest, AnimationControls::getProjectileSpeed());
+	projectile->from      = from;
+	projectile->dest      = dest;
 	projectile->shooterID = shooter->ID;
-	projectile->step     = 0;
-	projectile->playing  = false;
+	projectile->step      = 0;
+	projectile->playing   = false;
 
 	projectiles.push_back(projectile);
 }