[Solved]Beginner WML error problem and how to set max scenario starting gold?

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
Khornyflakes
Posts: 2
Joined: January 14th, 2019, 2:31 pm

[Solved]Beginner WML error problem and how to set max scenario starting gold?

Post by Khornyflakes »

SOLVED

How to set a maximum starting gold for a campaign scenario?



Completely seperate from that problem I get an error when starting the campaign. If I get into the scenario from the previous scenarios save, I get "unknown scenario" message.

Picture of error: https://i.imgur.com/AbTfJtX.png
My scenario file:

Code: Select all

#textdomain wesnoth-COLDEST_JOURNEY


[scenario]

	id=3B_SCENARIO
    next_scenario=4B_SCENARIO
	name= _ "Forest"
	map_data="{~add-ons/COLDEST_JOURNEY/maps/3B_SCENARIO.map}"
    {TURNS 32 28 28}

    {DEFAULT_SCHEDULE_DUSK}

        [objectives]
            side=1
            [objective]
                description= _ "Defeat all enemy leaders"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Mor Kan"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}

            [gold_carryover]
                bonus=yes
                carryover_percentage=10
            [/gold_carryover]
        [/objectives]



	[side]
		side=1
		controller=human
		team_name=1
		user_team_name= _ "Drakes"

		type=Drake Warrior
		id=Morkan
		name= _ "Mor Kan"
		canrecruit=yes
		fog=yes

		recruit=Drake Fighter,Drake Glider,Drake Burner,Cavalryman,Horseman

		{GOLD 75 65 55}
		{INCOME 0 0 0}
	[/side] 
  
  
  
	[side]
		side=2
		controller=ai
		team_name=2
		user_team_name= _ "Elves"

		type=Elvish Druid
		id=ELVISHDRUIDLEADER1
		generate_name=yes
		canrecruit=yes

		recruit=Elvish Shaman

		{GOLD 27 27 27}
		{INCOME 2 3 4}
		[ai]
			leader_aggression="-4.0
		[/ai]
	[/side] 

	[side]
		side=3
		controller=ai
		team_name=2
		user_team_name= _ "Elves"

		type=Elvish Captain
		id=ELVISHCAPTAINLEADER1
		generate_name=yes
		canrecruit=yes
		recruit=Elvish Fighter
		
		{GOLD 35 45 55}
		{INCOME 2 3 5}
		[ai]
			leader_aggression="-4.0
		[/ai]
	[/side] 

	[side]
		side=4
		controller=ai
		team_name=2
		user_team_name= _ "Elves"

		type=Elvish Marksman
		id=ELVISHMARKSMANLEADER1
		generate_name=yes
		canrecruit=yes

		recruit=Elvish Archer

		{GOLD 40 45 45}
		{INCOME 2 3 5}
		[ai]
			leader_aggression="-4.0
		[/ai]
	[/side] 
	[event]
		name=prestart
        [unit]
            type=Dragoon
            id=Mann
            name= _ "Mann"
            side=1
            x=8
            y=13
            [modifications]
                {TRAIT_LOYAL}
				{TRAIT_INTELLIGENT}
            [/modifications]
            {IS_LOYAL}
        [/unit]
		[unit]
            type=Horseman
            id=Guyy
            name= _ "Guyy"
            side=1
            x=7
            y=13
            [modifications]
                {TRAIT_LOYAL}
				{TRAIT_INTELLIGENT}
            [/modifications]
            {IS_LOYAL}
        [/unit]
	[/event]
	
	
	[event]
        name=start
		[message]
            speaker=Morkan
            message= _ "Halt! Who are you?"
        [/message]
		[message]
			speaker=Mann
            message= _ "We are friendly cavalrymen."
        [/message]
		[message]
			speaker=Mann
            message= _ "Our mission is to travel northeast to destroy the source of an undead plague."
        [/message]
		[message]
			speaker=Mann
            message= _ "This forest is swarming with hostile elves and our horses are slowed down by this terrain."
        [/message]
		[message]
			speaker=Mann
            message= _ "We should join our forces to fight a common enemy!"
        [/message]
		[message]
            speaker=Morkan
            message= _ "Very well."
        [/message]
		[message]
            speaker=narrator
            image="wesnoth-icon.png"
            message= _ "New units available!"
        [/message]
	[/event]
	
	[event]
		name=victory
		[endlevel]
            result=victory
            bonus=yes
            {NEW_GOLD_CARRYOVER 10}
        [/endlevel]
    [/event]
	

[/scenario]
The error points to {GOLD 35 45 55} on line 87 in scenario file. and to utils.cfg in Wesnoths core.

That part in utils.cfg:

Code: Select all

#define GOLD EASY_AMOUNT NORMAL_AMOUNT HARD_AMOUNT
    # Macro which will let you say {GOLD x y z} to set
    # starting gold depending on easy/medium/hard - x/y/z
    {QUANTITY gold {EASY_AMOUNT} {NORMAL_AMOUNT} {HARD_AMOUNT}}
#enddef
I removed the {GOLD 35 45 55} line and then it points to next {} thing. {INCOME 2 3 5}.
Last edited by Khornyflakes on January 22nd, 2019, 4:16 pm, edited 2 times in total.
User avatar
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: Beginner WML {error} problem and how to set max scenario starting gold?

Post by WhiteWolf »

You are missing several quotation marks (") at leader_aggression="-4. All of them if I see correctly.
Usually any error message that starts with "too many nested stuff" and points to funny locations usually mean a missing " or }.

Setting maximum gold for a side is pretty straightforward, at the start of the scenario you can check whether its gold is too high. If it is, set it to the maximum.

Code: Select all

[event]
    name=start
    [store_gold]
        side= ... the relevant side
        variable=gold
    [/store_gold]
    [if]
        [variable]
            name=gold
            greater_than=  your maximum here
        [/variable]
        [then]
            [modify_side]
                side= ... the side
                gold= ... the maximum
            [/modify_side]
        [/then]
    [/if]
    {CLEAR_VARIABLE gold}
[/event]
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Khornyflakes
Posts: 2
Joined: January 14th, 2019, 2:31 pm

Re: Beginner WML {error} problem and how to set max scenario starting gold?

Post by Khornyflakes »

Thanks for the help! Problem solved.

Thats what I get for lazy ctrl c ctrl v.
Post Reply