Skip to content

Commit

Permalink
Make [heal_unit] respect the unhealable status unless explicitly told…
Browse files Browse the repository at this point in the history
… not to respect it
  • Loading branch information
Dugy committed May 26, 2024
1 parent 1bf7645 commit 23660aa
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 52 deletions.
69 changes: 69 additions & 0 deletions lua/hacks.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@

--! #textdomain "wesnoth-loti"

local _ = wesnoth.textdomain "wesnoth-loti"

local old_unit_status = wesnoth.interface.game_display.unit_status
function wesnoth.interface.game_display.unit_status()
local u = wesnoth.interface.get_displayed_unit()
if not u then return {} end
local s = old_unit_status()
if u.status.infected then
table.insert(s, { "element", {
image = "misc/infected.png",
tooltip = _"infected: This unit is infected. It will become undead after death, unless cured by a healer or by standing on a village."
} })
end
if u.status.incinerated then
table.insert(s, { "element", {
image = "misc/incinerated.png",
tooltip = _"in flames: This unit is in flames. It will lose 16 HP per turn, unless cured by a healer or by standing on a village."
} })
end
if u.status.unslowable then
table.insert(s, { "element", {
image = "misc/unslowable.png",
tooltip = _"unslowable: This unit cannot be affected by slow."
} })
end
if u.status.unpoisonable then
table.insert(s, { "element", {
image = "misc/unpoisonable.png",
tooltip = _"unpoisonable: This unit cannot be affected by poison."
} })
end
if u.status.undrainable then
table.insert(s, { "element", {
image = "misc/undrainable.png",
tooltip = _"undrainable: This unit cannot be drained."
} })
end
if u.status.unplagueable then
table.insert(s, { "element", {
image = "misc/unplagueable.png",
tooltip = _"unplagueable: This unit will not return as undead when killed by a plague weapon special."
} })
end
if #s > 2 then -- Too long to fit the line
local entire_string = s[2][2].tooltip
for i = 3,#s do
entire_string = entire_string .. "\n ----------\n\n" .. s[i][2].tooltip
end
local old_statuses = s
s = {old_statuses[1], {"element", { image = "misc/icon-ellipsis.png", tooltip = entire_string }}}
end
return s
end

local old_heal_unit = wesnoth.wml_actions.heal_unit
function wesnoth.wml_actions.heal_unit(cfg)
cfg = cfg.__parsed
if cfg.respect_unhealable == false then
old_heal_unit(cfg)
return
end

local filter = wml.get_child(cfg, "filter")
table.insert(filter, {"not", {status = "unhealable"}})
old_heal_unit(cfg)
end
53 changes: 1 addition & 52 deletions lua/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ T = wml.tag

wesnoth.dofile("~add-ons/Legend_of_the_Invincibles/lua/debug.lua")
wesnoth.dofile("~add-ons/Legend_of_the_Invincibles/lua/utils.lua")
wesnoth.dofile("~add-ons/Legend_of_the_Invincibles/lua/hacks.lua")
wesnoth.dofile("~add-ons/Legend_of_the_Invincibles/lua/items.lua")
wesnoth.dofile("~add-ons/Legend_of_the_Invincibles/lua/item_pick.lua")
wesnoth.dofile("~add-ons/Legend_of_the_Invincibles/lua/inventory/dialog.lua")
Expand All @@ -22,58 +23,6 @@ wesnoth.dofile("~add-ons/Legend_of_the_Invincibles/lua/stats.lua")

local _ = wesnoth.textdomain "wesnoth-loti"

local old_unit_status = wesnoth.interface.game_display.unit_status
function wesnoth.interface.game_display.unit_status()
local u = wesnoth.interface.get_displayed_unit()
if not u then return {} end
local s = old_unit_status()
if u.status.infected then
table.insert(s, { "element", {
image = "misc/infected.png",
tooltip = _"infected: This unit is infected. It will become undead after death, unless cured by a healer or by standing on a village."
} })
end
if u.status.incinerated then
table.insert(s, { "element", {
image = "misc/incinerated.png",
tooltip = _"in flames: This unit is in flames. It will lose 16 HP per turn, unless cured by a healer or by standing on a village."
} })
end
if u.status.unslowable then
table.insert(s, { "element", {
image = "misc/unslowable.png",
tooltip = _"unslowable: This unit cannot be affected by slow."
} })
end
if u.status.unpoisonable then
table.insert(s, { "element", {
image = "misc/unpoisonable.png",
tooltip = _"unpoisonable: This unit cannot be affected by poison."
} })
end
if u.status.undrainable then
table.insert(s, { "element", {
image = "misc/undrainable.png",
tooltip = _"undrainable: This unit cannot be drained."
} })
end
if u.status.unplagueable then
table.insert(s, { "element", {
image = "misc/unplagueable.png",
tooltip = _"unplagueable: This unit will not return as undead when killed by a plague weapon special."
} })
end
if #s > 2 then -- Too long to fit the line
local entire_string = s[2][2].tooltip
for i = 3,#s do
entire_string = entire_string .. "\n ----------\n\n" .. s[i][2].tooltip
end
local old_statuses = s
s = {old_statuses[1], {"element", { image = "misc/icon-ellipsis.png", tooltip = entire_string }}}
end
return s
end

function wesnoth.wml_actions.get_unit_resistance(cfg)
local damage_type = cfg.damage_type or wml.error "[get_unit_resistance] has no damage type specified"
local to_variable = cfg.to_variable or "resistance_obtained"
Expand Down

0 comments on commit 23660aa

Please sign in to comment.