Can't get sides' income.

The place to post your WML questions and answers.

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.
Post Reply
User avatar
Xara
Posts: 270
Joined: December 26th, 2014, 12:23 am
Location: Beijing

Can't get sides' income.

Post by Xara »

I couldn't figure out how to retrieve the income modifier information of a side. The only way I know to do it is by using [store_side], but I get a income number that varies with the captured village number.
I was merely trying to do some simple things like modify a side's income by a permanent number, say +4. But I can't make it.
It pronounces Sha'ha, not Zara.

Feedback Thread of my Add-ons
User avatar
watbesh
Posts: 55
Joined: August 29th, 2012, 2:21 am
Location: Kanagawa, Japan

Re: Can't get sides' income.

Post by watbesh »

Xara wrote:I couldn't figure out how to retrieve the income modifier information of a side. The only way I know to do it is by using [store_side], but I get a income number that varies with the captured village number.
I was merely trying to do some simple things like modify a side's income by a permanent number, say +4. But I can't make it.
[store_side] and [modify_side]'s incomes seem to behave differently. [store_side] gets TOTAL income, and [modify_side] seems to require "BASE income minus 2" (set it to 0 and you have 2 income). If what I did for my mod can help...

[store_side] gets those income_related variables;
- side.income: the side's total income.
- side.village_gold: the side's gold per village (2 in most of MP games, 1 in most of campaigns)
- side.village_support: the side's upkeep support per village (almost always 1)

I couldn't get the side's base income, so I used [store_villages] and location.owner_side (there could be a better solution). I'm not sure this would work with upkeep.

Here's a (modified) copy of the relevant part.

Code: Select all

        [store_side]
            side=$side_number
            variable=current_side
        [/store_side]

        {VARIABLE current_income $current_side.income}
        {VARIABLE current_village_gold $current_side.village_gold}
        {VARIABLE current_village_support $current_side.village_support}

        {VARIABLE village_gold_neg $current_village_gold}
        {VARIABLE_OP village_gold_neg multiply -1}
        [store_villages]
            variable=villages_map
        [/store_villages]
        {FOREACH villages_map i}
            [if]
                [variable]
                    name=villages_map[$i].owner_side
                    equals=$current_side.side
                [/variable]
                [then]
                    {VARIABLE_OP current_income add $village_gold_neg}
                [/then]
            [/if]
        {NEXT i}
If this works well, it gets variables into current_income, current_village_gold and current_village_support, so change them and use [modify_side]. My code adds "-2" to current_income right before [modify_side] to work properly.
My MP Eras and Mods with core units and unusual gameplay (version 1.3.1 for Wesnoth 1.12)
User avatar
Xara
Posts: 270
Joined: December 26th, 2014, 12:23 am
Location: Beijing

Re: Can't get sides' income.

Post by Xara »

Many thanks! I thought about calculating the true value, but I think it's too troublesome. Very nice to be able to use your codes.
It pronounces Sha'ha, not Zara.

Feedback Thread of my Add-ons
Post Reply