Display current village upkeep information?

Brainstorm ideas of possible additions to the game. Read this before posting!

Moderator: Forum Moderators

Forum rules
Before posting a new idea, you must read the following:
Post Reply
kurt751
Posts: 398
Joined: June 4th, 2016, 11:17 pm

Display current village upkeep information?

Post by kurt751 »

Hi, what I miss a lot on the game's top information bar is how many unit levels my current villages can support (i.e. how many unit levels will be free according to the number of villages I currently own).
I can only keep recruiting till the expenses counter stops showing "0/xx"...

I think that would be easy to implement, there is enough space available on that top bar.
User avatar
Ravana
Forum Moderator
Posts: 3562
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Display current village upkeep information?

Post by Ravana »

That is just number of village x village support. If you miss it you can implement it in your addon.
kurt751
Posts: 398
Joined: June 4th, 2016, 11:17 pm

Re: Display current village upkeep information?

Post by kurt751 »

Except that the players don't necessarily know what the scenario creator decided to set as "village support". Could be anything... :)
So it's still useful information for the player, something they would like to know to be able to plan their recruiting.

Besides, AFAIK it's not 1:1, it's "unit levels":village (isn't it?), which means that it will change every time one of your units levels. For this reason ideally it should display something like "owned unit levels"/"village supported unit levels".
User avatar
Ravana
Forum Moderator
Posts: 3562
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Display current village upkeep information?

Post by Ravana »

kurt751
Posts: 398
Joined: June 4th, 2016, 11:17 pm

Re: Display current village upkeep information?

Post by kurt751 »

Lua is definitely a bridge too far for me. You have seen the level of difficulties I already have to ask for help with... :roll: :oops:

I'm not a developer, just somebody who dabbles in WML (mostly copying and adapting stuff seen elsewhere)...
User avatar
Ravana
Forum Moderator
Posts: 3562
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Display current village upkeep information?

Post by Ravana »

Fair enough. Example how you can implement seeing how many levels worth of support there are still left.

Code: Select all

-- wesnoth.interface.game_display.upkeep = _G.old_upkeep

local old_upkeep = wesnoth.interface.game_display.upkeep
function wesnoth.interface.game_display.upkeep()
    local s = old_upkeep()
    --print(wml.tostring(s))
    
    local village_support = #wesnoth.map.find{owner_side=wesnoth.current.side} * wesnoth.sides[wesnoth.current.side].village_support
    local total_upkeep = #wesnoth.units.find{side=wesnoth.current.side, upkeep=1}+ 2* #wesnoth.units.find{side=wesnoth.current.side, upkeep=2}+ 3* #wesnoth.units.find{side=wesnoth.current.side, upkeep=3}+4* #wesnoth.units.find{side=wesnoth.current.side, upkeep=4}
    --print(village_support)
    --print(total_upkeep)
    --_s = s
    --wesnoth.interface.game_display.upkeep = old_upkeep
    
    s[1][2].text = "&" .. tostring(village_support-total_upkeep)
    --print(s[1][2].text)
    return s
end
If you want to test it, find in hotkeys show lua console, give it hotkey, and you can enter this.
User avatar
Spannerbag
Posts: 952
Joined: December 18th, 2016, 6:14 pm
Location: Yes

Re: Display current village upkeep information?

Post by Spannerbag »

kurt751 wrote: August 2nd, 2026, 10:09 am Hi, what I miss a lot on the game's top information bar is how many unit levels my current villages can support (i.e. how many unit levels will be free according to the number of villages I currently own).
I can only keep recruiting till the expenses counter stops showing "0/xx"...

I think that would be easy to implement, there is enough space available on that top bar.
If you want a "dirty hack" in WML (I'm good at those ;) ) this might help?

DISCLAIMER: I've never done this so can't guarantee it'll work as I expect.

[store_side] is your friend.
village_support: The number of unit levels this side is able to support (does not pay upkeep on) per village it controls.
(Or you could use the game_config defaults of 1 if you haven't changed anything - but as my idea involves storing side(s) every turn you might as well use the actual value?)



To calculate the number of levels supported each turn.

Sadly I think you'll need to store each side of interest every side turn refresh plus that side's owned villages (because the number of villages changes).
[store_location] or [store_villages] can do this.

The number of levels that can be supported is (I guess) simply:
Number of villages owned (i.e. array length) * side's village_support
This could then be displayed in a number of ways such as label.

The whole thing could be wrapped in a macro that basically sets a few variables and calls an event (done this way to reduce bloat).
It'd probably be prudent to explain/clarify to the player (at very least on easiest difficulty?) that this is the number of Level 1 units that can be supported and that higher level units cost their level number in 1st level units. Also might be worth saying that leaders, loyals and zero levels do not incur upkeep. (How you do this I'll leave to you. :) )
From there it's easy (and maybe more useful) to display the available/unused upkeep (or not) so the player knows how many more levels that can recruit without going to negative gold (on current village holding) - or how many units they need to lose to stop losing gold each turn.

Other side variables you might find useful:
income: Income for this side (base income + all village income. AKA gross income. Note that this is different from the [side] income key).
village_gold: The amount of gold given to this side per village it controls per turn.
Hope this helps!
Cheers!
SP Campaigns: After EI (v1.14) Leafsea Burning (v1.18, v1.16)
I suspect the universe is simpler than we think and stranger than we can know.
Also, I fear that beyond a certain point more intelligence does not necessarily benefit a species...
kurt751
Posts: 398
Joined: June 4th, 2016, 11:17 pm

Re: Display current village upkeep information?

Post by kurt751 »

Guys, guys, thank you both, but I can (and prefer to) live without it. Life (and Wesnoth) is already complicated enough... :lol:

I saw this forum as a kind of wish list for future "The Battle for Wesnoth" game features, and thought I'd suggest this feature, because it's actually the only thing I'm missing. (That, and a better, faster, smoother scrolling.)
Unfortunately I'm no developer (have I mentioned it?...), so I'm definitely not the one who will implement it. :mrgreen:
User avatar
Ravana
Forum Moderator
Posts: 3562
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Display current village upkeep information?

Post by Ravana »

You can wrap Lua in modification to select it as addon.

Code: Select all

[modification]
    id=t60876
    name=_"t60876"
    description=_"https://forums.wesnoth.org/viewtopic.php?t=60876"
    require_modification=no
    type=hybrid

    [event]
        name=preload
        first_time_only=no
        [lua]
            code=<<
local old_upkeep = wesnoth.interface.game_display.upkeep
function wesnoth.interface.game_display.upkeep()
    local s = old_upkeep()
    local village_support = #wesnoth.map.find{owner_side=wesnoth.current.side} * wesnoth.sides[wesnoth.current.side].village_support
    local total_upkeep = #wesnoth.units.find{side=wesnoth.current.side, upkeep=1}+ 2* #wesnoth.units.find{side=wesnoth.current.side, upkeep=2}+ 3* #wesnoth.units.find{side=wesnoth.current.side, upkeep=3}+4* #wesnoth.units.find{side=wesnoth.current.side, upkeep=4}
    s[1][2].tooltip = s[1][2].tooltip .. " / " .. s[1][2].text
    s[1][2].text = "&" .. tostring(village_support-total_upkeep)
    return s
end
			>>
        [/lua]
    [/event]
[/modification]
kurt751
Posts: 398
Joined: June 4th, 2016, 11:17 pm

Re: Display current village upkeep information?

Post by kurt751 »

Ravana wrote: August 2nd, 2026, 3:33 pm You can wrap Lua in modification to select it as addon.
I understand all the individual words, but not the phrase. :shock: :lol:
How does that work?
The Wiki is once again particularly vague: "A modification is, practically speaking, a bunch of events which get included into the scenario if the modification is enabled.". That description does fit anything in a scenario (except the map and the side definitions)... :roll:
User avatar
Ravana
Forum Moderator
Posts: 3562
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Display current village upkeep information?

Post by Ravana »

Basically if you put what I wrote to _main.cfg you can enable it in game.
kurt751
Posts: 398
Joined: June 4th, 2016, 11:17 pm

Re: Display current village upkeep information?

Post by kurt751 »

I see, thanks.
I'll try it tomorrow.
Post Reply