Resting stuff ...
This commit is contained in:
parent
a1cf9c00a6
commit
65801a8c66
3 changed files with 19 additions and 8 deletions
|
@ -21,7 +21,7 @@
|
|||
healer_heals_per_turn=8
|
||||
cure_amount=8
|
||||
curer_heals_per_turn=18
|
||||
rest_heal_amount=1
|
||||
rest_heal_amount=2
|
||||
recall_cost=20
|
||||
kill_experience=8
|
||||
|
||||
|
|
|
@ -344,6 +344,7 @@ void attack(display& gui, const gamemap& map,
|
|||
int defenderxp = a->second.type().level();
|
||||
|
||||
a->second.set_attacked();
|
||||
d->second.set_resting(false);
|
||||
|
||||
//if the attacker was invisible, she isn't anymore!
|
||||
static const std::string forest_invisible("ambush");
|
||||
|
@ -722,21 +723,28 @@ void calculate_healing(display& disp, const gamemap& map,
|
|||
std::map<gamemap::location,int> healed_units, max_healing;
|
||||
|
||||
std::map<gamemap::location,unit>::iterator i;
|
||||
int amount_healed;
|
||||
for(i = units.begin(); i != units.end(); ++i) {
|
||||
amount_healed = 0;
|
||||
|
||||
//the unit heals if it's on this side, and it's on a tower or
|
||||
//it has regeneration, and it is wounded
|
||||
if(i->second.side() == side &&
|
||||
(map.underlying_terrain(map[i->first.x][i->first.y]) == gamemap::TOWER ||
|
||||
if(i->second.side() == side) {
|
||||
if((map.underlying_terrain(map[i->first.x][i->first.y]) == gamemap::TOWER ||
|
||||
i->second.type().regenerates()) &&
|
||||
i->second.hitpoints() < i->second.max_hitpoints()) {
|
||||
healed_units.insert(std::pair<gamemap::location,int>(
|
||||
i->first, game_config::cure_amount));
|
||||
|
||||
amount_healed = game_config::cure_amount;
|
||||
} else if(i->second.is_resting()){
|
||||
amount_healed = game_config::rest_heal_amount;
|
||||
}
|
||||
i->second.set_resting(true);
|
||||
if(amount_healed != 0)
|
||||
healed_units.insert(std::pair<gamemap::location,int>(
|
||||
i->first, amount_healed));
|
||||
}
|
||||
|
||||
//otherwise find the maximum healing for the unit
|
||||
else {
|
||||
if(amount_healed == 0) {
|
||||
int max_heal = 0;
|
||||
gamemap::location adjacent[6];
|
||||
get_adjacent_tiles(i->first,adjacent);
|
||||
|
|
|
@ -243,6 +243,9 @@ void unit::new_turn()
|
|||
void unit::end_turn()
|
||||
{
|
||||
remove_flag("slowed");
|
||||
if(moves_ != total_movement()){
|
||||
resting_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
void unit::new_level()
|
||||
|
@ -272,7 +275,7 @@ void unit::set_resting(bool resting)
|
|||
resting_ = resting;
|
||||
}
|
||||
|
||||
bool is_resting() const
|
||||
bool unit::is_resting() const
|
||||
{
|
||||
return resting_;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue