Modify unit's displayed stats
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Modify unit's displayed stats
This is a rather odd question but I assume it is possible.
It is rather easy to modify a units stats with an
So what I thought is instead I can set 12MP and
So then I thought all I need is an event that makes the units MP stat display as only 6 instead of 12mp.
This is the stat I want to change:
The reason I ask is because I assume it is possible to modify the display because I can add an icon to the menu bar like this:
Here with this code I am able to insert an element into the display table so I assume with some other code (which I currently have no idea about ) I might be able to modify the displayed MP.
It is rather easy to modify a units stats with an
[object]
and [effect]
. But what if you don't want to change the stats, only change the displayed stats.The situation is that I want a unit to have 6MP on water and 4MP on land. But that is not possible because if I set it to 6MP (movement cost water =1, movement cost land = 1.5)
That is clearly going to break. So what I thought is instead I can set 12MP and
movement cost water = 2, movement cost land = 3
. Then by setting vision = 6 it acts exactly how I want to. However, then the player sees the number 12MP on the unit bar. Which is weird So then I thought all I need is an event that makes the units MP stat display as only 6 instead of 12mp.
This is the stat I want to change:
The reason I ask is because I assume it is possible to modify the display because I can add an icon to the menu bar like this:
Code: Select all
[event]
name=turn refresh
#first_time_only=no
[lua]
code=<<
local _ = wesnoth.textdomain "wesnoth-ROTL"
local old_unit_status = wesnoth.theme_items.unit_status
function wesnoth.theme_items.unit_status()
local u = wesnoth.get_displayed_unit()
if not u then return {} end
local s = old_unit_status()
if u.status.ROTLensnared then
table.insert(s, { "element", {
image = "misc/web-status.png",
tooltip = _"ensnared: This unit is ensnared. Ensnared units' defenses are reduced to 10% making them vanurable to enemy attacks. Units remain ensnared for 1 round."
} })
end
return s
end
>>
[/lua]
[/event]
Creator of: The Reign of The Lords Era,The Gnats Franken Dungeon.
Re: Modify unit's displayed stats
It is not really documented, but wesnoth.theme_items should have all the elements you need.
Re: Modify unit's displayed stats
Okay great I will see if I can find out about that!
Creator of: The Reign of The Lords Era,The Gnats Franken Dungeon.
Re: Modify unit's displayed stats
I think you want wesnoth.theme_items.unit_moves and .selected_unit_moves too. See https://github.com/wesnoth/wesnoth/blob ... #L684-L693.