Apply patch #3210: Add [object]duration=turn
This commit is contained in:
parent
0029e953df
commit
8418f05e8c
3 changed files with 36 additions and 0 deletions
|
@ -194,6 +194,7 @@ Version 1.11.0-svn:
|
|||
* Replaced variable i by TRANSFORM_UNIT_i in macro TRANSFORM_UNIT
|
||||
* Fix $owner_side in capture events fired due to unit movement
|
||||
* Introduce [item]redraw=yes|no (def yes) parameter
|
||||
* Added [object]duration=turn
|
||||
* Miscellaneous and bug fixes:
|
||||
* Fix wrong preferences path suffix (1.1 instead of 1.10) on Linux and other
|
||||
platforms using XDG layout (no compiled-in preferences path override,
|
||||
|
|
|
@ -1797,6 +1797,18 @@ Also, 0..9 = $below_ten, one,two,three = $ascii and the bonus answer is $mixed."
|
|||
[/filter]
|
||||
{LOG "$unit.name (id $unit.id|) requested health insurance!"}
|
||||
{FULL_HEAL (x,y=$x1|,$y1)}
|
||||
[object]
|
||||
id=brief_health
|
||||
silent=yes
|
||||
duration=turn
|
||||
[filter]
|
||||
x,y=14,12
|
||||
[/filter]
|
||||
[effect]
|
||||
apply_to=hitpoints
|
||||
increase_total=50%
|
||||
[/effect]
|
||||
[/object]
|
||||
[/event]
|
||||
|
||||
[label]
|
||||
|
|
23
src/unit.cpp
23
src/unit.cpp
|
@ -1054,6 +1054,29 @@ void unit::new_turn()
|
|||
attacks_left_ = max_attacks_;
|
||||
set_state(STATE_UNCOVERED, false);
|
||||
|
||||
bool rebuild_from_type = false;
|
||||
for(unsigned int i = 0; i != NumModificationTypes; ++i) {
|
||||
const std::string& mod_name = ModificationTypes[i];
|
||||
for (int j = modifications_.child_count(mod_name) - 1; j >= 0; --j)
|
||||
{
|
||||
const config &mod = modifications_.child(mod_name, j);
|
||||
const std::string& duration = mod["duration"];
|
||||
if (duration == "turn") {
|
||||
if (const config::attribute_value *v = mod.get("prev_type")) {
|
||||
type_ = v->str();
|
||||
}
|
||||
modifications_.remove_child(mod_name, j);
|
||||
rebuild_from_type = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(rebuild_from_type) {
|
||||
int old_hp = hit_points_;
|
||||
advance_to(type());
|
||||
if(hit_points_ > old_hp)
|
||||
hit_points_ = old_hp;
|
||||
}
|
||||
|
||||
if (hold_position_) {
|
||||
end_turn_ = true;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue