add draw and sheath animations
This commit is contained in:
parent
bb6759e8ac
commit
119c65de4d
5 changed files with 85 additions and 0 deletions
|
@ -73,6 +73,8 @@ Version 1.7.5+svn:
|
|||
* Started with the a new event handler for gui2
|
||||
* Fix unit facings after moving (bug #14336)
|
||||
* Improved the teamcoloring script for images.
|
||||
* Animations
|
||||
* new animations to help drakes to take off and land : pre-movement post-movement draw_weapon sheath_weapon
|
||||
|
||||
Version 1.7.5:
|
||||
* Campaigns:
|
||||
|
|
|
@ -1036,6 +1036,8 @@ attack::attack(const map_location &attacker, const map_location &defender,
|
|||
|
||||
LOG_NG << "Fight: (" << a_.loc_ << ") vs (" << d_.loc_ << ") ATT: " << a_stats_->weapon->name() << " " << a_stats_->damage << "-" << a_stats_->num_blows << "(" << a_stats_->chance_to_hit << "%) vs DEF: " << (d_stats_->weapon ? d_stats_->weapon->name() : "none") << " " << d_stats_->damage << "-" << d_stats_->num_blows << "(" << d_stats_->chance_to_hit << "%)" << (defender_strikes_first ? " defender first-strike" : "") << "\n";
|
||||
|
||||
// Play the pre-fight animation
|
||||
unit_display::unit_draw_weapon(a_.loc_,a_.get_unit(),a_stats_->weapon,d_stats_->weapon,d_.loc_,&d_.get_unit());
|
||||
while(a_.n_attacks_ > 0 || d_.n_attacks_ > 0) {
|
||||
DBG_NG << "start of attack loop...\n";
|
||||
abs_n_attack_++;
|
||||
|
@ -1622,6 +1624,8 @@ attack::attack(const map_location &attacker, const map_location &defender,
|
|||
if(d_.xp_)
|
||||
d_.get_unit().get_experience(d_.xp_);
|
||||
}
|
||||
unit_display::unit_sheath_weapon(a_.loc_,a_.valid()?&a_.get_unit():NULL,a_stats_->weapon,
|
||||
d_stats_->weapon,d_.loc_,d_.valid()?&d_.get_unit():NULL);
|
||||
|
||||
if (update_display_){
|
||||
resources::screen->invalidate_unit();
|
||||
|
|
|
@ -47,6 +47,8 @@ struct tag_name_manager {
|
|||
names.push_back("teleport_anim");
|
||||
names.push_back("pre_movement_anim");
|
||||
names.push_back("post_movement_anim");
|
||||
names.push_back("draw_weapon_anim");
|
||||
names.push_back("sheath_weapon_anim");
|
||||
names.push_back("victory_anim");
|
||||
}
|
||||
std::vector<std::string> names;
|
||||
|
@ -624,6 +626,25 @@ void unit_animation::add_anims( std::vector<unit_animation> & animations, const
|
|||
}
|
||||
}
|
||||
|
||||
expanded_cfg = unit_animation::prepare_animation(cfg,"draw_weapon_anim");
|
||||
foreach (config &anim, expanded_cfg.child_range("draw_weapon_anim"))
|
||||
{
|
||||
anim["apply_to"] = "draw_weapon";
|
||||
if (anim["layer"].empty()) anim["layer"] = move_layer;
|
||||
animations.push_back(unit_animation(anim));
|
||||
}
|
||||
|
||||
|
||||
|
||||
expanded_cfg = unit_animation::prepare_animation(cfg,"sheath_weapon_anim");
|
||||
foreach (config &anim, expanded_cfg.child_range("sheath_weapon_anim"))
|
||||
{
|
||||
anim["apply_to"] = "sheath_weapon";
|
||||
if (anim["layer"].empty()) anim["layer"] = move_layer;
|
||||
animations.push_back(unit_animation(anim));
|
||||
}
|
||||
|
||||
|
||||
expanded_cfg = unit_animation::prepare_animation(cfg,"attack_anim");
|
||||
foreach (config &anim, expanded_cfg.child_range("attack_anim"))
|
||||
{
|
||||
|
|
|
@ -215,6 +215,52 @@ void move_unit(const std::vector<map_location>& path, unit& u, const std::vector
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void unit_draw_weapon(const map_location& loc, unit& attacker,
|
||||
const attack_type* attack,const attack_type* secondary_attack, const map_location& defender_loc,unit* defender)
|
||||
{
|
||||
game_display* disp = game_display::get_singleton();
|
||||
if(!disp ||disp->video().update_locked() || disp->video().faked() || disp->fogged(loc) || preferences::show_combat() == false) {
|
||||
return;
|
||||
}
|
||||
unit_animator animator;
|
||||
animator.add_animation(&attacker,"draw_weapon",loc,defender_loc,0,false,false,"",0,unit_animation::HIT,attack,secondary_attack,0);
|
||||
animator.add_animation(defender,"draw_weapon",defender_loc,loc,0,false,false,"",0,unit_animation::MISS,secondary_attack,attack,0);
|
||||
animator.start_animations();
|
||||
animator.wait_for_end();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void unit_sheath_weapon(const map_location& primary_loc, unit* primary_unit,
|
||||
const attack_type* primary_attack,const attack_type* secondary_attack, const map_location& secondary_loc,unit* secondary_unit)
|
||||
{
|
||||
game_display* disp = game_display::get_singleton();
|
||||
if(!disp ||disp->video().update_locked() || disp->video().faked() || disp->fogged(primary_loc) || preferences::show_combat() == false) {
|
||||
return;
|
||||
}
|
||||
unit_animator animator;
|
||||
if(primary_unit) {
|
||||
animator.add_animation(primary_unit,"sheath_weapon",primary_loc,secondary_loc,0,false,false,"",0,unit_animation::INVALID,primary_attack,secondary_attack,0);
|
||||
}
|
||||
if(secondary_unit) {
|
||||
animator.add_animation(secondary_unit,"sheath_weapon",secondary_loc,primary_loc,0,false,false,"",0,unit_animation::INVALID,secondary_attack,primary_attack,0);
|
||||
}
|
||||
|
||||
if(primary_unit || secondary_unit) {
|
||||
animator.start_animations();
|
||||
animator.wait_for_end();
|
||||
}
|
||||
if(primary_unit) {
|
||||
primary_unit->set_standing();
|
||||
}
|
||||
if(secondary_unit) {
|
||||
secondary_unit->set_standing();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void unit_die(const map_location& loc, unit& loser,
|
||||
const attack_type* attack,const attack_type* secondary_attack, const map_location& winner_loc,unit* winner)
|
||||
{
|
||||
|
|
|
@ -40,6 +40,18 @@ namespace unit_display
|
|||
/** Display a unit moving along a given path. */
|
||||
void move_unit(const std::vector<map_location>& path, unit& u, const std::vector<team>& teams);
|
||||
|
||||
/**
|
||||
* Play a pre-fight animation
|
||||
* First unit is the attacker, second unit the defender
|
||||
*/
|
||||
void unit_draw_weapon( const map_location& loc, unit& u, const attack_type* attack=NULL, const attack_type*secondary_attack=NULL,const map_location& defender_loc = map_location::null_location, unit * defender=NULL);
|
||||
|
||||
/**
|
||||
* Play a post-fight animation
|
||||
* Both unit can be set to null, only valid units will play their animation
|
||||
*/
|
||||
void unit_sheath_weapon( const map_location& loc, unit* u=NULL, const attack_type* attack=NULL, const attack_type*secondary_attack=NULL,const map_location& defender_loc = map_location::null_location, unit * defender=NULL);
|
||||
|
||||
/**
|
||||
* Show a unit fading out.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue