CAttackAnimation.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include "StdInc.h"
  2. #include "CAttackAnimation.h"
  3. #include "../CMusicHandler.h"
  4. #include "../CGameInfo.h"
  5. #include "CBattleInterface.h"
  6. #include "CCreatureAnimation.h"
  7. #include "../../lib/BattleState.h"
  8. #include "../CPlayerInterface.h"
  9. #include "../../CCallback.h"
  10. void CAttackAnimation::nextFrame()
  11. {
  12. if(myAnim()->getType() != group)
  13. myAnim()->setType(group);
  14. if(myAnim()->onFirstFrameInGroup())
  15. {
  16. if(shooting)
  17. CCS->soundh->playSound(battle_sound(attackingStack->getCreature(), shoot));
  18. else
  19. CCS->soundh->playSound(battle_sound(attackingStack->getCreature(), attack));
  20. }
  21. else if(myAnim()->onLastFrameInGroup())
  22. {
  23. myAnim()->setType(CCreatureAnim::HOLDING);
  24. endAnim();
  25. return; //execution of endAnim deletes this !!!
  26. }
  27. }
  28. bool CAttackAnimation::checkInitialConditions()
  29. {
  30. return isEarliest(false);
  31. }
  32. CAttackAnimation::CAttackAnimation(CBattleInterface *_owner, const CStack *attacker, SBattleHex _dest, const CStack *defender)
  33. : CBattleStackAnimation(_owner, attacker), dest(_dest), attackedStack(defender), attackingStack(attacker)
  34. {
  35. assert(attackingStack && "attackingStack is NULL in CBattleAttack::CBattleAttack !\n");
  36. if(attackingStack->getCreature()->idNumber != 145) //catapult is allowed to attack not-creature
  37. {
  38. assert(attackedStack && "attackedStack is NULL in CBattleAttack::CBattleAttack !\n");
  39. }
  40. else //catapult can attack walls only
  41. {
  42. assert(owner->curInt->cb->battleGetWallUnderHex(_dest) >= 0);
  43. }
  44. attackingStackPosBeforeReturn = attackingStack->position;
  45. }