Custom Scenario make the game crash when loaded

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
Archloucol
Posts: 3
Joined: September 20th, 2020, 4:02 pm

Custom Scenario make the game crash when loaded

Post by Archloucol »

I recently got into wml coding, but every time I want to test the first scenario of my campaign, the game crashes with the following error message:
Spoiler:
Here is the main code :

Code: Select all

[textdomain] wesnoth-corrupted_elves
text="wesnoth-corrupted_elves"
path=data/add-ons/Corrupted_Elves/translations
[/textdomain]

[campaign]
 #textdomain wesnoth-corrupted_elves
 
    id=corrupted_elves
    name=_"Corrupted Elves" 
    abbrev="CE"
    define=CAMPAIGN_Corrupted_Elves
    icon="units/elves-wood/avenger-sword-1.png~RC(magenta>purple)"
    image="data/add-ons/Corrupted_Elves/images/Wohael.png~RC"
    first_scenario="01_Shady_Battle"
    description=_"Follow the story of Wohael and his troops, corrupted by a demonic magic. 
Will their tale end as an epic or a tragedy?"
    difficulties=Medium
    difficulty_descriptions=_"Medium"
[/campaign]

[binary_path]
    path=data/add-ons/Corrupted_Elves
[/binary_path]

{~add-ons/Corrupted_Elves/scenarios}
{~add-ons/Corrupted_Elves/maps}
And the scenario one :

Code: Select all


#textdomain wesnoth-corrupted_elves

[scenario]
    id="01_Shady_Battle"
    next_scenario=null
    name=_"Shady Battle"
    map_data="{~add-ons/Corrupted_Elves/maps/Battle.map}"
    turns=20
[/scenario]


[side]
    side=1
    controller=player
    team_name="elvish_squad"
    user_team_name=_"Elvish Squad"
    id="WohaelLeader"
    name= "Wohael"
    type= "Lord"
    unrenameable=yes
    canrecruit=yes
    recruit="Archer, Fighter"
    gold=100
[/side]

[side]
    side=2
    controller=ai
    team_name="bad"
    user_team_name= _ "Bad Guys"
    id="EnemyLeader"
    name= _ "Batta"
    type= "Orcish Warrior"
    unrenameable=yes
    canrecruit=yes
    recruit="Orcish Grunt, Orcish Archer, Wolf Rider"
    gold=100
[/side]

[event]
    name=start
	
	[message]
      speaker=WohaelLeader
      message= _ "Give me a report, soldier."
    [/message]
	
	[message]
      speaker=Archer
      message= _ "Orcs have set up their base north, Commandant Wohael."
    [/message]
	
    [objectives]
	
        [objective]
            description= _ "Defeat the enemy leader"
            condition="win"
        [/objective]
        [objective]
            description= _ "Death of your leader"
            condition="lose"
        [/objective]
		[objective]
                description= _ "Turns run out"
                condition="lose"
            [/objective]
    [/objectives]
[/event]
thanks in advance for your help !
Last edited by WhiteWolf on September 20th, 2020, 4:39 pm, edited 1 time in total.
User avatar
Pentarctagon
Project Manager
Posts: 5564
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Custom Scenario make the game crash when loaded

Post by Pentarctagon »

To start with, [scenario] should surround all other tags you have there ([side], [event], etc).
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
Archloucol
Posts: 3
Joined: September 20th, 2020, 4:02 pm

Re: Custom Scenario make the game crash when loaded

Post by Archloucol »

Pentarctagon wrote: September 20th, 2020, 4:41 pm To start with, [scenario] should surround all other tags you have there ([side], [event], etc).

Thanks you, it worked !
Pilauli
Posts: 115
Joined: August 18th, 2020, 12:56 pm

Re: Custom Scenario make the game crash when loaded

Post by Pilauli »

- Put your [/scenario] at the very end of the scenario file, so that all of the sides, events, etc. are between [scenario] and [/scenario]. (This may fix the crash, or it may reveal new errors. Hard to tell until you try it!) Looks like Pentarctagon beat me to it!

- As general good practice, when you post code on the forum, please put it inside [code]...[/code] tags. Okay, it looks fine now, not sure why it didn't when I first saw it.

- As general good practice, your binary path and scenarios and stuff should be inside an ifdef statement. (Also, the CAMPAIGN_WHATEVER is traditionally all-uppercase. I'm not sure whether it's required to be, but it's easier to just go along with it.) That would make your main file look like this:

Code: Select all

[textdomain] wesnoth-corrupted_elves
    text="wesnoth-corrupted_elves"
    path=data/add-ons/Corrupted_Elves/translations
[/textdomain]

[campaign]
    #textdomain wesnoth-corrupted_elves

    id=corrupted_elves
    name=_"Corrupted Elves"
    abbrev="CE"
    define=CAMPAIGN_CORRUPTED_ELVES
    icon="units/elves-wood/avenger-sword-1.png~RC(magenta>purple)"
    image="data/add-ons/Corrupted_Elves/images/Wohael.png~RC"
    first_scenario="01_Shady_Battle"
    description=_"Follow the story of Wohael and his troops, corrupted by a demonic magic.
    Will their tale end as an epic or a tragedy?"
    difficulties=Medium
    difficulty_descriptions=_"Medium"
[/campaign]

#ifdef CAMPAIGN_CORRUPTED_ELVES
    [binary_path]
        path=data/add-ons/Corrupted_Elves
    [/binary_path]

    {~add-ons/Corrupted_Elves/scenarios}
    {~add-ons/Corrupted_Elves/maps}
 #endif
The difficulty definition you're using has also been "deprecated" (I think that means "try not to do this, but old stuff that does it will still work for a while"): try this instead:

Code: Select all

    # Other campaign stuff up here.
    description=_"Follow the story of Wohael and his troops, corrupted by a demonic magic.
    Will their tale end as an epic or a tragedy?"
    [difficulty]
        define=NORMAL  # Standardized difficulties are EASY, NORMAL, and HARD
        description="Medium"
    [/difficulty]
[/campaign]
I hope some of this helps, and if not, change these and come back with the new errors!
Archloucol
Posts: 3
Joined: September 20th, 2020, 4:02 pm

Re: Custom Scenario make the game crash when loaded

Post by Archloucol »

I wroted down and used your advice, and it worked well ! Slowly but surely i'm learning.

There is some things that I can't do now, but it's probably because I'm not looking hard enough into other campaigns.
Thank you for your answers and advices !
Post Reply