fix bug #9019 make [animate_unit] actually usefull

This commit is contained in:
Jérémy Rosen 2008-01-16 21:26:00 +00:00
parent d3ef748372
commit 5ecae2cc57
4 changed files with 1097 additions and 274 deletions

View File

@ -7,6 +7,8 @@ Version 1.3.14+svn:
* Fixed boost test compile with 1.34.1
* Make wesnoth work properly again if the datadir contains ../
* Fixed some type of addon not being uninstallable (bug #10788)
* some filtering was added to the [animate_unit] action to actually make it
usefull
Version 1.3.14:
* campaigns:

View File

@ -200,6 +200,26 @@ Xu ,Xu , Qxu , Qxu , Ql , Ql
x,y=4,4
image="items/orcish-flag.png"
[/item]
[label]
x,y=10,9
text="Let's fight"
[/label]
[event]
name=moveto
first_time_only=no
[filter]
x=10
y=9
side=1
[/filter]
[animate_unit]
flag=attack
hit=hit
[primary_attack]
[/primary_attack]
[/animate_unit]
[/event]
[label]
x,y=4,4
text="Open, Sesame!"

File diff suppressed because it is too large Load Diff

View File

@ -2393,7 +2393,7 @@ bool event_handler::handle_event_command(const queued_event& event_info,
// Search for a valid unit filter,
// and if we have one, look for the matching unit
const vconfig filter = cfg.child("filter");
vconfig filter = cfg.child("filter");
if(!filter.null()) {
for(u = units->begin(); u != units->end(); ++u){
if(game_events::unit_matches_filter(u, filter))
@ -2403,9 +2403,48 @@ bool event_handler::handle_event_command(const queued_event& event_info,
// We have found a unit that matches the filter
if(u != units->end() && ! screen->fogged(u->first)) {
attack_type *primary = NULL;
attack_type *secondary = NULL;
Uint32 text_color = 0;
unit_animation::hit_type hits= unit_animation::INVALID;
std::vector<attack_type> attacks = u->second.attacks();
std::vector<attack_type>::iterator itor;
filter = cfg.child("primary_attack");
if(!filter.null()) {
for(itor = attacks.begin(); itor != attacks.end(); ++itor){
if(itor->matches_filter(filter.get_config())) {
primary = &*itor;
break;
}
}
}
filter = cfg.child("secondary_attack");
if(!filter.null()) {
for(itor = attacks.begin(); itor != attacks.end(); ++itor){
if(itor->matches_filter(filter.get_config())) {
secondary = &*itor;
break;
}
}
}
if(cfg["hit"] == "yes" || cfg["hit"] == "hit") {
hits = unit_animation::HIT;
}
if(cfg["hit"] == "no" || cfg["hit"] == "miss") {
hits = unit_animation::MISS;
}
if( cfg["hit"] == "kill" ) {
hits = unit_animation::KILL;
}
std::vector<std::string> tmp_string_vect=utils::split(cfg["text_color"]);
if(tmp_string_vect.size() ==3) text_color = display::rgb(atoi(tmp_string_vect[0].c_str()),atoi(tmp_string_vect[1].c_str()),atoi(tmp_string_vect[2].c_str()));
screen->scroll_to_tile(u->first);
unit_animator animator;
animator.add_animation(&u->second,cfg["flag"],u->first);
animator.add_animation(&u->second,cfg["flag"],u->first,lexical_cast_default<int>(cfg["value"]),utils::string_bool(cfg["with_bars"]),
false,cfg["text"],text_color, hits,primary,secondary,0);
animator.start_animations();
animator.wait_for_end();
u->second.set_standing(u->first);