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 26ab046413
commit fff1fc5266

View file

@ -110,9 +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)
--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