unit_display.hpp

Go to the documentation of this file.
00001 /* $Id: unit_display.hpp 54055 2012-05-01 04:00:58Z brilliand $ */
00002 /*
00003    Copyright (C) 2003 - 2012 by David White <dave@whitevine.net>
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY.
00012 
00013    See the COPYING file for more details.
00014 */
00015 
00016 /**
00017  *  @file
00018  *  Display units performing various actions: moving, attacking, and dying.
00019  */
00020 
00021 #ifndef UNIT_DISPLAY_HPP_INCLUDED
00022 #define UNIT_DISPLAY_HPP_INCLUDED
00023 
00024 #include "unit_map.hpp"
00025 #include "gamestatus.hpp"
00026 
00027 class attack_type;
00028 class team;
00029 class unit;
00030 
00031 /**
00032  *  Contains a number of free functions which display units
00033  *
00034  *  performing various on-screen actions - moving, attacking, and dying.
00035  */
00036 namespace unit_display
00037 {
00038 
00039 /**
00040  * Display a unit moving along a given path.
00041  *
00042  * Note: Hide the unit in its current location,
00043  * but don't actually remove it until the move is done,
00044  * so that while the unit is moving status etc.
00045  * will still display the correct number of units.
00046  *
00047  * @param path
00048  * @param u
00049  * @param teams
00050  * @param animate If set to false, only side-effects of move
00051  *        are applied (correct unit facing, path hexes redrawing).
00052  * @param dir Unit will be set facing this direction after move.
00053  *        If nothing passed, direction will be set based on path.
00054  */
00055 void move_unit(const std::vector<map_location>& path, unit& u,
00056     const std::vector<team>& teams, bool animate=true,
00057     map_location::DIRECTION dir=map_location::NDIRECTIONS);
00058 void move_unit_start(const std::vector<map_location>& path, unit& temp_unit,
00059     const team& tm);
00060 void move_unit_step(const std::vector<map_location>& path, size_t i,
00061     unit& temp_unit, const team& tm);
00062 void move_unit_finish(const std::vector<map_location>& path, unit& temp_unit);
00063 
00064 /**
00065  * Play a pre-fight animation
00066  * First unit is the attacker, second unit the defender
00067  */
00068 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);
00069 
00070 /**
00071  * Play a post-fight animation
00072  * Both unit can be set to null, only valid units will play their animation
00073  */
00074 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);
00075 
00076 /**
00077  * Show a unit fading out.
00078  *
00079  * Note: this only shows the effect, it doesn't actually kill the unit.
00080  */
00081  void unit_die( const map_location& loc, unit& u,
00082     const attack_type* attack=NULL, const attack_type* secondary_attack=NULL,
00083     const map_location& winner_loc=map_location::null_location,
00084     unit* winner=NULL);
00085 
00086 
00087 /**
00088  *  Make the unit on tile 'a' attack the unit on tile 'b'.
00089  *
00090  *  The 'damage' will be subtracted from the unit's hitpoints,
00091  *  and a die effect will be displayed if the unit dies.
00092  *
00093  *  @retval true                  if the defending unit is dead, should be
00094  *                                removed from the playing field.
00095  */
00096 void unit_attack(const map_location& a, const map_location& b, int damage,
00097     const attack_type& attack, const attack_type* secondary_attack,
00098     int swing, std::string hit_text, int drain_amount, std::string att_text);
00099 
00100 
00101 void unit_recruited(const map_location& loc,
00102     const map_location& leader_loc=map_location::null_location);
00103 
00104 /**
00105  * This will use a poisoning anim if healing<0.
00106  */
00107 void unit_healing(unit &healed, const map_location &healed_loc,
00108     const std::vector<unit *> &healers, int healing);
00109 
00110 
00111 /**
00112  * Parse a standard WML for animations and play the corresponding animation.
00113  * Returns once animation is played.
00114  *
00115  * This is used for the animate_unit action, but can easily be generalized if
00116  * other wml-decribed animations are needed.
00117  */
00118 void wml_animation(const vconfig &cfg,
00119     const map_location& default_location=map_location::null_location);
00120 
00121 }
00122 
00123 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:03:13 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs