Added animation for Elvish Fighter attacking from long range

This commit is contained in:
Dave White 2003-09-24 12:46:52 +00:00
parent 0736d9a9b1
commit 77506335bb
13 changed files with 68 additions and 10 deletions

View file

@ -2,6 +2,7 @@
name=Elvish Fighter
image=elvish-fighter.png
image_defensive=elvish-fighter-defend.png
image_defensive_long=elvish-fighter-bow-defend.png
hitpoints=32
movement_type=woodland
movement=5
@ -57,6 +58,30 @@ in the forest."
sound_miss=arrow-miss.wav
[/sound]
[frame]
begin=-600
end=-450
image=elvish-fighter-bow.png
[/frame]
[frame]
begin=-450
end=-300
image=elvish-fighter-bow-attack1.png
[/frame]
[frame]
begin=-300
end=0
image=elvish-fighter-bow-attack2.png
[/frame]
[frame]
begin=0
end=100
image=elvish-fighter-bow.png
[/frame]
[missile_frame]
begin=-100
end=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -515,7 +515,13 @@ std::vector<std::string> config::split(const std::string& val)
std::string& config::strip(std::string& str)
{
str.erase(str.begin(),std::find_if(str.begin(),str.end(),isgraph));
//if all the string contains is whitespace, then the whitespace may
//have meaning, so don't strip it
const std::string::iterator it=std::find_if(str.begin(),str.end(),isgraph);
if(it == str.end())
return str;
str.erase(str.begin(),it);
str.erase(std::find_if(str.rbegin(),str.rend(),isgraph).base(),str.end());
return str;

View file

@ -1591,6 +1591,8 @@ bool display::unit_attack_ranged(const gamemap::location& a,
{
const unit_map::iterator def = units_.find(b);
def->second.set_defending(true,attack_type::LONG_RANGE);
//the missile frames are based around the time when the missile impacts.
//the 'real' frames are based around the time when the missile launches.
const int first_missile = minimum<int>(-100,
@ -1716,6 +1718,8 @@ bool display::unit_attack_ranged(const gamemap::location& a,
update_display();
}
def->second.set_defending(false);
if(dead) {
unit_die(b);
}
@ -1779,7 +1783,7 @@ bool display::unit_attack(const gamemap::location& a,
const int time_resolution = 20;
def->second.set_defending(true);
def->second.set_defending(true,attack_type::SHORT_RANGE);
const int begin_at = minimum<int>(-200,attack.get_first_frame());
const int end_at = maximum<int>((damage+1)*time_resolution,

View file

@ -22,6 +22,6 @@ namespace game_config
const int cure_amount = 8;
const int curer_heals_per_turn = 18;
const int recall_cost = 20;
const std::string version = "0.4.8 RC1";
const std::string version = "0.4.8 RC3";
bool debug = false;
}

View file

@ -732,6 +732,10 @@ int show_dialog(display& disp, SDL_Surface* image,
if(!key_down && key[KEY_ENTER] &&
(type == YES_NO || type == OK_CANCEL)) {
if(text_widget_text != NULL && use_textbox)
*text_widget_text = text_widget.text();
if(menu_.height() == 0) {
return 0;
} else {

View file

@ -479,7 +479,10 @@ const std::string& unit::image() const
{
switch(state_) {
case STATE_NORMAL: return type_->image();
case STATE_DEFENDING: return type_->image_defensive();
case STATE_DEFENDING_LONG:
return type_->image_defensive(attack_type::LONG_RANGE);
case STATE_DEFENDING_SHORT:
return type_->image_defensive(attack_type::SHORT_RANGE);
case STATE_ATTACKING: {
if(attackType_ == NULL)
return type_->image();
@ -496,9 +499,10 @@ const std::string& unit::image() const
}
}
void unit::set_defending(bool newval)
void unit::set_defending(bool newval, attack_type::RANGE range)
{
state_ = newval ? STATE_DEFENDING : STATE_NORMAL;
state_ = newval ? (range == attack_type::LONG_RANGE ? STATE_DEFENDING_LONG :
STATE_DEFENDING_SHORT): STATE_NORMAL;
}
void unit::set_attacking(bool newval, const attack_type* type, int ms)

View file

@ -80,7 +80,8 @@ public:
//(could be in the middle of an attack etc)
const std::string& image() const;
void set_defending(bool newval);
void set_defending(bool newval,
attack_type::RANGE range=attack_type::LONG_RANGE);
void set_attacking(bool newval, const attack_type* type=NULL, int ms=0);
bool facing_left() const;
@ -100,7 +101,8 @@ public:
private:
const unit_type* type_;
enum STATE { STATE_NORMAL, STATE_ATTACKING, STATE_DEFENDING };
enum STATE { STATE_NORMAL, STATE_ATTACKING,
STATE_DEFENDING_LONG, STATE_DEFENDING_SHORT };
STATE state_;
const attack_type* attackType_;
int attackingMilliseconds_;

View file

@ -396,8 +396,21 @@ const std::string& unit_type::image() const
return cfg_.values["image"];
}
const std::string& unit_type::image_defensive() const
const std::string& unit_type::image_defensive(attack_type::RANGE range) const
{
{
static const std::string short_range("image_defensive_short");
static const std::string long_range("image_defensive_long");
const std::string& str = range == attack_type::LONG_RANGE ?
long_range : short_range;
const std::string& val = cfg_.values[str];
if(!val.empty())
return val;
}
const std::string& val = cfg_.values["image_defensive"];
if(val.empty())
return cfg_.values["image"];

View file

@ -129,7 +129,7 @@ public:
const std::string& name() const;
const std::string& image() const;
const std::string& image_profile() const;
const std::string& image_defensive() const;
const std::string& image_defensive(attack_type::RANGE range) const;
const std::string& unit_description() const;
int hitpoints() const;
std::vector<attack_type> attacks() const;