add filtering on SUF to animations

This commit is contained in:
Jérémy Rosen 2006-09-10 17:04:26 +00:00
parent 3c29bebd7f
commit c889b4364e
8 changed files with 103 additions and 71 deletions

View file

@ -55,6 +55,7 @@ Version 1.3-svn:
* units now have idle animations when they arn't used for some time
* units now have levelin animations when they level into this unit
* units now have levelout animations when they level out of this unit
* animations can now use standard unit filters
* multiplayer game management
* client now tells the server if a game ended in victory or defeat
* configurable castle size for random map generator (patch #598, FR #3232)

View file

@ -1581,7 +1581,7 @@ void unit::set_standing(const display &disp,const gamemap::location& loc, bool w
delete anim_;
anim_ = NULL;
}
anim_ = new standing_animation(stand_animation(disp.get_map().underlying_union_terrain(loc),facing_));
anim_ = new standing_animation(stand_animation(disp,loc));
anim_->start_animation(anim_->get_first_frame_time(),unit_animation::INFINITE_CYCLES,disp.turbo_speed());
frame_begin_time = anim_->get_first_frame_time() -1;
anim_->update_current_frame();
@ -1603,7 +1603,7 @@ void unit::set_defending(const display &disp,const gamemap::location& loc, int d
}else {
hit_type = fighting_animation::MISS;
}
anim_ = new defensive_animation(defend_animation(disp.get_map().underlying_union_terrain(loc),hit_type,attack,swing_num));
anim_ = new defensive_animation(defend_animation(disp,loc,hit_type,attack,swing_num));
// add a blink on damage effect
int anim_time = anim_->get_last_frame_time();
@ -1626,11 +1626,11 @@ void unit::set_extra_anim(const display &disp,const gamemap::location& loc, std:
delete anim_;
anim_ = NULL;
}
if(!extra_animation(disp.get_map().underlying_union_terrain(loc),flag)) {
if(!extra_animation(disp,loc,flag)) {
set_standing(disp,loc);
return;
}
anim_ = new unit_animation(*(extra_animation(disp.get_map().underlying_union_terrain(loc),flag)));
anim_ = new unit_animation(*(extra_animation(disp,loc,flag)));
anim_->start_animation(anim_->get_first_frame_time(), 1, disp.turbo_speed());
frame_begin_time = anim_->get_first_frame_time() -1;
anim_->update_current_frame();
@ -1652,7 +1652,7 @@ const unit_animation & unit::set_attacking(const display &disp,const gamemap::lo
}else {
hit_type = fighting_animation::MISS;
}
anim_ = new attack_animation(type.animation(disp.get_map().underlying_union_terrain(loc),hit_type,facing_,swing_num));
anim_ = new attack_animation(type.animation(disp,loc,this,hit_type,swing_num));
anim_->start_animation(anim_->get_first_frame_time(), 1, disp.turbo_speed());
frame_begin_time = anim_->get_first_frame_time() -1;
anim_->update_current_frame();
@ -1666,7 +1666,7 @@ void unit::set_leading(const display &disp,const gamemap::location& loc)
delete anim_;
anim_ = NULL;
}
anim_ = new leading_animation(lead_animation(disp.get_map().underlying_union_terrain(loc),facing_));
anim_ = new leading_animation(lead_animation(disp,loc));
anim_->start_animation(anim_->get_first_frame_time(), 1, disp.turbo_speed());
frame_begin_time = anim_->get_first_frame_time() -1;
anim_->update_current_frame();
@ -1679,7 +1679,7 @@ void unit::set_leveling_in(const display &disp,const gamemap::location& loc)
delete anim_;
anim_ = NULL;
}
anim_ = new levelin_animation(levelingin_animation(disp.get_map().underlying_union_terrain(loc),facing_));
anim_ = new levelin_animation(levelingin_animation(disp,loc));
anim_->start_animation(anim_->get_first_frame_time(), 1, disp.turbo_speed());
frame_begin_time = anim_->get_first_frame_time() -1;
anim_->update_current_frame();
@ -1692,7 +1692,7 @@ void unit::set_leveling_out(const display &disp,const gamemap::location& loc)
delete anim_;
anim_ = NULL;
}
anim_ = new levelout_animation(levelingout_animation(disp.get_map().underlying_union_terrain(loc),facing_));
anim_ = new levelout_animation(levelingout_animation(disp,loc));
anim_->start_animation(anim_->get_first_frame_time(), 1, disp.turbo_speed());
frame_begin_time = anim_->get_first_frame_time() -1;
anim_->update_current_frame();
@ -1705,7 +1705,7 @@ void unit::set_recruited(const display &disp,const gamemap::location& loc)
delete anim_;
anim_ = NULL;
}
anim_ = new recruit_animation(recruiting_animation(disp.get_map().underlying_union_terrain(loc),facing_));
anim_ = new recruit_animation(recruiting_animation(disp,loc));
// add a fade in effect
anim_->start_animation(anim_->get_first_frame_time(), 1, disp.turbo_speed());
frame_begin_time = anim_->get_first_frame_time() -1;
@ -1738,7 +1738,7 @@ void unit::set_poisoned(const display &disp,const gamemap::location& /*loc*/, in
anim_->update_current_frame();
}
void unit::set_teleporting(const display &disp,const gamemap::location& /*loc*/)
void unit::set_teleporting(const display &disp,const gamemap::location& loc)
{
state_ = STATE_TELEPORT;
draw_bars_ = false;
@ -1746,7 +1746,7 @@ void unit::set_teleporting(const display &disp,const gamemap::location& /*loc*/)
delete anim_;
anim_ = NULL;
}
anim_ = new unit_animation(teleport_animation());
anim_ = new unit_animation(teleport_animation(disp,loc));
anim_->start_animation(anim_->get_first_frame_time(),1,disp.turbo_speed());
frame_begin_time = anim_->get_first_frame_time() -1;
anim_->update_current_frame();
@ -1760,7 +1760,7 @@ void unit::set_dying(const display &disp,const gamemap::location& loc,const atta
delete anim_;
anim_ = NULL;
}
anim_ = new death_animation(die_animation(disp.get_map().underlying_union_terrain(loc),fighting_animation::KILL,attack));
anim_ = new death_animation(die_animation(disp,loc,fighting_animation::KILL,attack));
std::string tmp_image = anim_->get_last_frame().image();
int anim_time =anim_->get_last_frame_time();
anim_->add_frame(0,unit_frame(tmp_image,anim_time,anim_time+600,"1~0:600"));
@ -1777,7 +1777,7 @@ void unit::set_healing(const display &disp,const gamemap::location& loc)
delete anim_;
anim_ = NULL;
}
anim_ = new healing_animation(heal_animation(disp.get_map().underlying_union_terrain(loc),facing_));
anim_ = new healing_animation(heal_animation(disp,loc));
anim_->start_animation(anim_->get_first_frame_time(), 1, disp.turbo_speed());
frame_begin_time = anim_->get_first_frame_time() -1;
anim_->update_current_frame();
@ -1786,7 +1786,7 @@ void unit::set_healing(const display &disp,const gamemap::location& loc)
void unit::set_walking(const display &disp,const gamemap::location& loc)
{
movement_animation* const anim = dynamic_cast<movement_animation*>(anim_);
if(state_ == STATE_WALKING && anim != NULL && anim->matches(disp.get_map().underlying_union_terrain(loc),facing_) >=0) {
if(state_ == STATE_WALKING && anim != NULL && anim->matches(disp,loc,this) >=0) {
return; // finish current animation, don't start a new one
}
state_ = STATE_WALKING;
@ -1795,7 +1795,7 @@ void unit::set_walking(const display &disp,const gamemap::location& loc)
delete anim_;
anim_ = NULL;
}
anim_ = new movement_animation(move_animation(disp.get_map().underlying_union_terrain(loc),facing_));
anim_ = new movement_animation(move_animation(disp,loc));
anim_->start_animation(anim_->get_first_frame_time(), 1, disp.turbo_speed());
frame_begin_time = anim_->get_first_frame_time() -1;
}
@ -1809,7 +1809,7 @@ void unit::set_idling(const display &disp,const gamemap::location& loc)
delete anim_;
anim_ = NULL;
}
anim_ = new idle_animation(idling_animation(disp.get_map().underlying_union_terrain(loc),facing_));
anim_ = new idle_animation(idling_animation(disp,loc));
anim_->start_animation(anim_->get_first_frame_time(), 1, disp.turbo_speed());
frame_begin_time = anim_->get_first_frame_time() -1;
anim_->update_current_frame();
@ -2766,14 +2766,14 @@ const std::string& unit::race() const
return race_->name();
}
const defensive_animation& unit::defend_animation(const std::string &terrain,
const defensive_animation& unit::defend_animation(const display& disp, const gamemap::location& loc,
fighting_animation::hit_type hits, const attack_type* attack,int swing_num) const
{
//select one of the matching animations at random
std::vector<const defensive_animation*> options;
int max_val = -1;
for(std::vector<defensive_animation>::const_iterator i = defensive_animations_.begin(); i != defensive_animations_.end(); ++i) {
int matching = i->matches(terrain,facing_,hits,attack,swing_num);
int matching = i->matches(disp,loc,this,hits,attack,swing_num);
if(matching == max_val) {
options.push_back(&*i);
} else if(matching > max_val) {
@ -2786,18 +2786,33 @@ const defensive_animation& unit::defend_animation(const std::string &terrain,
wassert(!options.empty());
return *options[rand()%options.size()];
}
const unit_animation& unit::teleport_animation() const
const unit_animation& unit::teleport_animation(const display& disp, const gamemap::location& loc) const
{
return teleport_animations_[rand() % teleport_animations_.size()];
//select one of the matching animations at random
std::vector<const unit_animation*> options;
int max_val = -1;
for(std::vector<unit_animation>::const_iterator i = teleport_animations_.begin(); i != teleport_animations_.end(); ++i) {
int matching = i->matches(disp,loc,this);
if(matching == max_val) {
options.push_back(&*i);
} else if(matching > max_val) {
max_val = matching;
options.erase(options.begin(),options.end());
options.push_back(&*i);
}
}
wassert(!options.empty());
return *options[rand()%options.size()];
}
const unit_animation* unit::extra_animation(const std::string &terrain,const std::string &flag) const
const unit_animation* unit::extra_animation(const display& disp, const gamemap::location& loc,const std::string &flag) const
{
//select one of the matching animations at random
std::vector<const unit_animation*> options;
int max_val = -1;
std::multimap<std::string,unit_animation>::const_iterator i;
for(i = extra_animations_.lower_bound(flag); i != extra_animations_.upper_bound(flag); ++i) {
int matching = i->second.matches(terrain,facing_);
int matching = i->second.matches(disp,loc,this);
if(matching == max_val) {
options.push_back(&i->second);
} else if(matching > max_val) {
@ -2810,14 +2825,14 @@ const unit_animation* unit::extra_animation(const std::string &terrain,const std
return options[rand()%options.size()];
}
const death_animation& unit::die_animation(const std::string &terrain,
const death_animation& unit::die_animation(const display& disp, const gamemap::location& loc,
fighting_animation::hit_type hits,const attack_type* attack) const
{
//select one of the matching animations at random
std::vector<const death_animation*> options;
int max_val = -1;
for(std::vector<death_animation>::const_iterator i = death_animations_.begin(); i != death_animations_.end(); ++i) {
int matching = i->matches(terrain,facing_,hits,attack,0);
int matching = i->matches(disp,loc,this,hits,attack,0);
if(matching == max_val) {
options.push_back(&*i);
} else if(matching > max_val) {
@ -2830,13 +2845,13 @@ const death_animation& unit::die_animation(const std::string &terrain,
wassert(!options.empty());
return *options[rand()%options.size()];
}
const movement_animation& unit::move_animation(const std::string terrain,gamemap::location::DIRECTION dir) const
const movement_animation& unit::move_animation(const display& disp, const gamemap::location& loc) const
{
//select one of the matching animations at random
std::vector<const movement_animation*> options;
int max_val = -1;
for(std::vector<movement_animation>::const_iterator i = movement_animations_.begin(); i != movement_animations_.end(); ++i) {
int matching = i->matches(terrain,dir);
int matching = i->matches(disp,loc,this);
if(matching == max_val) {
options.push_back(&*i);
} else if(matching > max_val) {
@ -2850,13 +2865,13 @@ const movement_animation& unit::move_animation(const std::string terrain,gamemap
return *options[rand()%options.size()];
}
const standing_animation& unit::stand_animation(const std::string terrain,gamemap::location::DIRECTION dir) const
const standing_animation& unit::stand_animation(const display& disp, const gamemap::location& loc) const
{
//select one of the matching animations at random
std::vector<const standing_animation*> options;
int max_val = -1;
for(std::vector<standing_animation>::const_iterator i = standing_animations_.begin(); i != standing_animations_.end(); ++i) {
int matching = i->matches(terrain,dir);
int matching = i->matches(disp,loc,this);
if(matching == max_val) {
options.push_back(&*i);
} else if(matching > max_val) {
@ -2870,13 +2885,13 @@ const standing_animation& unit::stand_animation(const std::string terrain,gamema
return *options[rand()%options.size()];
}
const leading_animation& unit::lead_animation(const std::string terrain,gamemap::location::DIRECTION dir) const
const leading_animation& unit::lead_animation(const display& disp, const gamemap::location& loc) const
{
//select one of the matching animations at random
std::vector<const leading_animation*> options;
int max_val = -1;
for(std::vector<leading_animation>::const_iterator i = leading_animations_.begin(); i != leading_animations_.end(); ++i) {
int matching = i->matches(terrain,dir);
int matching = i->matches(disp,loc,this);
if(matching == max_val) {
options.push_back(&*i);
} else if(matching > max_val) {
@ -2891,13 +2906,13 @@ const leading_animation& unit::lead_animation(const std::string terrain,gamemap:
}
const healing_animation& unit::heal_animation(const std::string terrain,gamemap::location::DIRECTION dir) const
const healing_animation& unit::heal_animation(const display& disp, const gamemap::location& loc) const
{
//select one of the matching animations at random
std::vector<const healing_animation*> options;
int max_val = -1;
for(std::vector<healing_animation>::const_iterator i = healing_animations_.begin(); i != healing_animations_.end(); ++i) {
int matching = i->matches(terrain,dir);
int matching = i->matches(disp,loc,this);
if(matching == max_val) {
options.push_back(&*i);
} else if(matching > max_val) {
@ -2911,13 +2926,13 @@ const healing_animation& unit::heal_animation(const std::string terrain,gamemap:
return *options[rand()%options.size()];
}
const recruit_animation& unit::recruiting_animation(const std::string terrain,gamemap::location::DIRECTION dir) const
const recruit_animation& unit::recruiting_animation(const display& disp, const gamemap::location& loc) const
{
//select one of the matching animations at random
std::vector<const recruit_animation*> options;
int max_val = -1;
for(std::vector<recruit_animation>::const_iterator i = recruit_animations_.begin(); i != recruit_animations_.end(); ++i) {
int matching = i->matches(terrain,dir);
int matching = i->matches(disp,loc,this);
if(matching == max_val) {
options.push_back(&*i);
} else if(matching > max_val) {
@ -2931,13 +2946,13 @@ const recruit_animation& unit::recruiting_animation(const std::string terrain,ga
return *options[rand()%options.size()];
}
const idle_animation& unit::idling_animation(const std::string terrain,gamemap::location::DIRECTION dir) const
const idle_animation& unit::idling_animation(const display& disp, const gamemap::location& loc) const
{
//select one of the matching animations at random
std::vector<const idle_animation*> options;
int max_val = -1;
for(std::vector<idle_animation>::const_iterator i = idle_animations_.begin(); i != idle_animations_.end(); ++i) {
int matching = i->matches(terrain,dir);
int matching = i->matches(disp,loc,this);
if(matching == max_val) {
options.push_back(&*i);
} else if(matching > max_val) {
@ -2951,13 +2966,13 @@ const idle_animation& unit::idling_animation(const std::string terrain,gamemap::
return *options[rand()%options.size()];
}
const levelin_animation& unit::levelingin_animation(const std::string terrain,gamemap::location::DIRECTION dir) const
const levelin_animation& unit::levelingin_animation(const display& disp, const gamemap::location& loc) const
{
//select one of the matching animations at random
std::vector<const levelin_animation*> options;
int max_val = -1;
for(std::vector<levelin_animation>::const_iterator i = levelin_animations_.begin(); i != levelin_animations_.end(); ++i) {
int matching = i->matches(terrain,dir);
int matching = i->matches(disp,loc,this);
if(matching == max_val) {
options.push_back(&*i);
} else if(matching > max_val) {
@ -2971,13 +2986,13 @@ const levelin_animation& unit::levelingin_animation(const std::string terrain,ga
return *options[rand()%options.size()];
}
const levelout_animation& unit::levelingout_animation(const std::string terrain,gamemap::location::DIRECTION dir) const
const levelout_animation& unit::levelingout_animation(const display& disp, const gamemap::location& loc) const
{
//select one of the matching animations at random
std::vector<const levelout_animation*> options;
int max_val = -1;
for(std::vector<levelout_animation>::const_iterator i = levelout_animations_.begin(); i != levelout_animations_.end(); ++i) {
int matching = i->matches(terrain,dir);
int matching = i->matches(disp,loc,this);
if(matching == max_val) {
options.push_back(&*i);
} else if(matching > max_val) {

View file

@ -237,20 +237,20 @@ class unit
unit_type::ALIGNMENT alignment() const;
const std::string& race() const;
const defensive_animation& defend_animation(const std::string &terrain,
const defensive_animation& defend_animation(const display& disp, const gamemap::location& loc,
fighting_animation::hit_type hits,const attack_type* attack,int swing_num) const;
const unit_animation& teleport_animation() const;
const unit_animation* extra_animation(const std::string &terrain,const std::string &flag) const;
const death_animation& die_animation(const std::string &terrain,
const unit_animation& teleport_animation(const display& disp, const gamemap::location& loc) const;
const unit_animation* extra_animation(const display& disp, const gamemap::location& loc,const std::string &flag) const;
const death_animation& die_animation(const display& disp, const gamemap::location& loc,
fighting_animation::hit_type hits,const attack_type* attack) const;
const movement_animation& move_animation(const std::string terrain,gamemap::location::DIRECTION) const;
const standing_animation& stand_animation(const std::string terrain,gamemap::location::DIRECTION) const;
const leading_animation& lead_animation(const std::string terrain,gamemap::location::DIRECTION) const;
const healing_animation& heal_animation(const std::string terrain,gamemap::location::DIRECTION) const;
const recruit_animation& recruiting_animation(const std::string terrain,gamemap::location::DIRECTION) const;
const idle_animation& idling_animation(const std::string terrain,gamemap::location::DIRECTION) const;
const levelin_animation& levelingin_animation(const std::string terrain,gamemap::location::DIRECTION) const;
const levelout_animation& levelingout_animation(const std::string terrain,gamemap::location::DIRECTION) const;
const movement_animation& move_animation(const display& disp, const gamemap::location& loc) const;
const standing_animation& stand_animation(const display& disp, const gamemap::location& loc) const;
const leading_animation& lead_animation(const display& disp, const gamemap::location& loc) const;
const healing_animation& heal_animation(const display& disp, const gamemap::location& loc) const;
const recruit_animation& recruiting_animation(const display& disp, const gamemap::location& loc) const;
const idle_animation& idling_animation(const display& disp, const gamemap::location& loc) const;
const levelin_animation& levelingin_animation(const display& disp, const gamemap::location& loc) const;
const levelout_animation& levelingout_animation(const display& disp, const gamemap::location& loc) const;
bool get_ability_bool(const std::string& ability, const gamemap::location& loc) const;
unit_ability_list get_abilities(const std::string& ability, const gamemap::location& loc) const;

View file

@ -22,6 +22,8 @@
#include "wassert.hpp"
#include "serialization/string_utils.hpp"
#include "color_range.hpp"
#include "unit.hpp"
#include "display.hpp"
#include <algorithm>
#include <cstdlib>
@ -110,6 +112,10 @@ unit_animation::unit_animation(const config& cfg,const std::string frame_string
const gamemap::location::DIRECTION d = gamemap::location::parse_direction(*i);
directions.push_back(d);
}
config::const_child_iterator itor;
for(itor = cfg.child_range("unit_filter").first; itor <cfg.child_range("unit_filter").second;itor++) {
unit_filter_.push_back(**itor);
}
/* warn on deprecated WML */
if(cfg.child("sound")) {
@ -119,24 +125,34 @@ unit_animation::unit_animation(const config& cfg,const std::string frame_string
}
int unit_animation::matches(const std::string &terrain,const gamemap::location::DIRECTION dir) const
int unit_animation::matches(const display& disp, const gamemap::location& loc,const unit* my_unit) const
{
int result = 0;
if(terrain_types.empty()== false) {
if (std::find(terrain_types.begin(),terrain_types.end(),terrain)== terrain_types.end()) {
if (std::find(terrain_types.begin(),terrain_types.end(),disp.get_map().underlying_union_terrain(loc))== terrain_types.end()) {
return -1;
} else {
result ++;
}
}
if(directions.empty()== false) {
if (std::find(directions.begin(),directions.end(),dir)== directions.end()) {
return -1;
} else {
result ++;
if(my_unit) {
if(directions.empty()== false) {
if (std::find(directions.begin(),directions.end(),my_unit->facing())== directions.end()) {
return -1;
} else {
result ++;
}
}
}
std::vector<config>::const_iterator myitor;
for(myitor = unit_filter_.begin(); myitor != unit_filter_.end(); myitor++) {
printf("trying\n");
myitor->debug();
if(!my_unit->matches_filter(*myitor,loc)) return -1;
printf("done\n");
result++;
}
} else if (!unit_filter_.empty()) return -1;
return result;
}
@ -165,9 +181,9 @@ fighting_animation::fighting_animation(const config& cfg) :unit_animation(cfg),
}
int fighting_animation::matches(const std::string &terrain,gamemap::location::DIRECTION dir,hit_type hit,const attack_type* attack, int swing) const
int fighting_animation::matches(const display& disp, const gamemap::location & loc,const unit* my_unit,hit_type hit,const attack_type* attack, int swing) const
{
int result = unit_animation::matches(terrain,dir);
int result = unit_animation::matches(disp,loc,my_unit);
if(!attack) {
if(damage_type.empty() && special.empty())
return result;

View file

@ -25,6 +25,7 @@
#include "unit_frame.hpp"
class display;
class unit_animation:public animated<unit_frame>
{
@ -34,12 +35,11 @@ class unit_animation:public animated<unit_frame>
unit_animation(){};
explicit unit_animation(const config& cfg,const std::string frame_string ="frame");
explicit unit_animation(const unit_frame &frame);
int matches(const std::string &terrain,const gamemap::location::DIRECTION dir) const;
enum FRAME_DIRECTION { VERTICAL, DIAGONAL };
int matches(const display &disp,const gamemap::location& loc,const unit* my_unit) const;
private:
std::vector<std::string> terrain_types;
std::vector<config> unit_filter_;
std::vector<gamemap::location::DIRECTION> directions;
};
@ -54,7 +54,7 @@ class fighting_animation:public unit_animation
explicit fighting_animation(const config& cfg);
explicit fighting_animation(const unit_frame &frame, const std::string &range=""):
unit_animation(frame),range(utils::split(range)) {};
int matches(const std::string &terrain,gamemap::location::DIRECTION dir,hit_type hit,const attack_type* attack,int swing_num) const;
int matches(const display &disp,const gamemap::location& loc,const unit* my_unit,hit_type hit,const attack_type* attack,int swing_num) const;
private:
std::vector<hit_type> hits;

View file

@ -265,7 +265,7 @@ bool unit_attack_ranged(display& disp, unit_map& units,
orientation = halo::NORMAL;
break;
}
const unit_animation::FRAME_DIRECTION dir = (a.x == b.x) ? unit_animation::VERTICAL:unit_animation::DIAGONAL;
const bool vertical_dir = (a.x == b.x) ? true:false;
defender.set_defending(disp,b,damage,&attack,swing);
// min of attacker, defender, missile and -200
@ -311,7 +311,7 @@ bool unit_attack_ranged(display& disp, unit_map& units,
std::string missile_image= missile_frame.image();
const int d = disp.hex_size() / 2;
if(dir == unit_animation::VERTICAL) {
if(vertical_dir) {
missile_image = missile_frame.image();
} else {
missile_image = missile_frame.image_diagonal();

View file

@ -154,13 +154,13 @@ int attack_type::movement_used() const
return cfg_["movement_used"] == "" ? 100000 : lexical_cast_default<int>(cfg_["movement_used"]);
}
const attack_animation& attack_type::animation(const std::string &terrain,const fighting_animation::hit_type hit,const gamemap::location::DIRECTION dir,int swing_num) const
const attack_animation& attack_type::animation(const display& disp, const gamemap::location& loc,const unit* my_unit,const fighting_animation::hit_type hit,int swing_num) const
{
//select one of the matching animations at random
std::vector<const attack_animation*> options;
int max_val = -1;
for(std::vector<attack_animation>::const_iterator i = animation_.begin(); i != animation_.end(); ++i) {
int matching = i->matches(terrain,dir,hit,this,swing_num);
int matching = i->matches(disp,loc,my_unit,hit,this,swing_num);
if(matching == max_val) {
options.push_back(&*i);
} else if(matching > max_val) {

View file

@ -86,7 +86,7 @@ public:
bool special_affects_self(const config& cfg) const;
config cfg_;
const attack_animation& animation(const std::string &terrain,const fighting_animation::hit_type hit,const gamemap::location::DIRECTION dir,int swing_num) const;
const attack_animation& animation(const display& disp, const gamemap::location& loc,const unit* my_unit,const fighting_animation::hit_type hit,int swing_num) const;
private:
std::vector<attack_animation> animation_;
t_string description_;