world conquest: fix for hp glitch when picking up items

This commit is contained in:
Tahsin Jahin Khalid 2022-01-18 20:35:15 +06:00
parent fe1f46c320
commit cebcd653fb

View file

@ -111,9 +111,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)
--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
-- the artifact might reduce the max xp.
unit:advance(true, true)
end