}
}
+AttackChoice &BattleState::CurrentAttackAttackChoice() {
+ if (CurrentAttack().isMonster) {
+ return monsterAttacks[CurrentAttack().index];
+ } else {
+ return AttackChoiceAt(CurrentAttack().index);
+ }
+}
+
void BattleState::ClearAllAttacks() {
attackCursor = -1;
activeHero = -1;
void CalculateDamage();
void ApplyDamage();
const Order &CurrentAttack() const { assert(attackCursor >= 0 && attackCursor < int(attackOrder.size())); return attackOrder[attackCursor]; };
+ AttackChoice &CurrentAttackAttackChoice();
void ClearAllAttacks();
bool Victory() const;
const /* Script */ void *AttackScript() { return attackScript; }
const /* Script */ void *DefenseScript() { return defenseScript; }
+ graphics::Animation *MeleeAnimation() { return meleeAnimation; }
+ const graphics::Animation *MeleeAnimation() const { return meleeAnimation; }
graphics::Animation *AttackAnimation() { return attackAnimation; }
const graphics::Animation *AttackAnimation() const { return attackAnimation; }
graphics::Animation *SpellAnimation() { return spellAnimation; }
void SetStats(const Stats &s) { stats = s; }
void SetReward(Uint16 exp, Uint16 gold) { expReward = exp; goldReward = gold; }
+ void SetMeleeAnimation(graphics::Animation *a) { meleeAnimation = a; }
void SetAttackAnimation(graphics::Animation *a) { attackAnimation = a; }
void SetSpellAnimation(graphics::Animation *a) { spellAnimation = a; }
/* Script */ void *attackScript;
/* Script */ void *defenseScript;
+ graphics::Animation *meleeAnimation;
graphics::Animation *attackAnimation;
graphics::Animation *spellAnimation;
Monster &monster(battle->MonsterAt(battle->CurrentAttack().index));
titleBarText = monster.Name();
moveAnimation = monster.AttackAnimation();
+ targetAnimation = monster.MeleeAnimation();
+ // TODO: add number animations
} else {
Hero &hero(battle->HeroAt(battle->CurrentAttack().index));
const AttackChoice &ac(battle->AttackChoiceAt(battle->CurrentAttack().index));
void PerformAttacks::RenderTargetAnimation(SDL_Surface *screen, const geometry::Vector<int> &offset) const {
if (!targetAnimation || !targetAnimation->Running()) return;
- if (battle->CurrentAttack().isMonster) return; // no monsters for now
- const TargetSelection &ts(battle->AttackChoiceAt(battle->CurrentAttack().index).Selection());
+ const TargetSelection &ts(battle->CurrentAttackAttackChoice().Selection());
const vector<Point<int> > &positions(ts.TargetsHeroes() ? battle->HeroesPositions() : battle->MonsterPositions());
for (vector<Point<int> >::size_type i(0), end(positions.size()); i < end; ++i) {
if (ts.IsSelected(i)) {
monsterAttackAnimation.AddFrame(0, 0, Vector<int>(16, 0));
monsterAttackAnimation.AddFrame(0, 1, Vector<int>(16, 0));
monster.SetAttackAnimation(&monsterAttackAnimation);
+ SDL_Surface *monsterMeleeImg(IMG_Load("test-data/attack-monster.png"));
+ Sprite monsterMeleeSprite(monsterMeleeImg, 96, 64);
+ SimpleAnimation monsterMeleeAnimation(&monsterMeleeSprite, framerate, 14);
+ monster.SetMeleeAnimation(&monsterMeleeAnimation);
SDL_Surface *maximImg(IMG_Load("test-data/maxim.png"));
Sprite maximSprite(maximImg, 64, 64);