WC: Fix objects increasing hp not working.
The code keeps record of the previous hp to prevent unit:transform form changing it. But it reads it before the object was added which prevented the object from increasing the units hp.
This commit is contained in:
parent
d5b7972c6f
commit
c9e8a166aa
1 changed files with 3 additions and 3 deletions
|
@ -110,10 +110,12 @@ function artifacts.give_item(unit, index, visualize)
|
|||
for i, effect in ipairs(aftifact_data.effect) do
|
||||
table.insert(object, wml.tag.effect (effect) )
|
||||
end
|
||||
local unit_initial_hp = unit.hitpoints
|
||||
unit:add_modification("object", object)
|
||||
local unit_initial_hp = unit.hitpoints
|
||||
--rebuild unit, to reduce savefile size.
|
||||
unit:transform(unit.type)
|
||||
-- restore unit hitpoints to before they picked up the artifact
|
||||
unit.hitpoints = unit_initial_hp
|
||||
|
||||
-- slot in traits if any artifacts grant any
|
||||
for trait in wml.child_range(artifacts.list[index], "trait") do
|
||||
|
@ -122,8 +124,6 @@ function artifacts.give_item(unit, index, visualize)
|
|||
end
|
||||
end
|
||||
|
||||
-- restore unit hitpoints to before they picked up the artifact
|
||||
unit.hitpoints = unit_initial_hp
|
||||
-- the artifact might reduce the max xp.
|
||||
unit:advance(true, true)
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue