Custom Scenario Error

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
Killer_Volt
Posts: 3
Joined: July 22nd, 2022, 10:03 am

Custom Scenario Error

Post by Killer_Volt »

Hello, I've been trying to get a custom scenario working, whenever I try to run it though I get an error of "Failed to Load Scenario". I mostly copied the code from the addon "WML Guide" but mine doesn't work.

_main.cfg

Code: Select all

#[textdomain]
#    name="Ghost"
#    path="~add-ons/Ghost/translations
#[/textdomain]

#textdomain Ghost

[campaign]
    id=Ghost
    define=CAMPAIGN_GHOST
    icon="units/undead/spectre.png~RC(magenta>black)"
    name= _ "Ghosts"
    abbrev= _ "Gh"
    first_scenario=Ghost_1
    {CAMPAIGN_DIFFICULTY EASY "units/undead/ghost-s-1.png~RC(magenta>red)" ( _ "Ghost") ( _ "Beginner")}
    {CAMPAIGN_DIFFICULTY NORMAL "units/undead/wraith-s.png~RC(magenta>red)" ( _ "Wraith") ( _ "Normal")}
    {DEFAULT_DIFFICULTY}
    {CAMPAIGN_DIFFICULTY HARD "units/undead/spectre.png~RC(magenta>red)" ( _ "Spectre") ( _ "Difficult")}
    description= _ "Help the poor misunderstood Ghosts"
[/campaign]

#ifdef GHOST
    [binary_path]
        path=data/add-ons/Ghost/
    [/binary_path]

    {~add-ons/Ghost/macros}
    {~add-ons/Ghost/utils}
 
    {~add-ons/Ghost/scenarios}

#endif
and the scenario

Code: Select all

#textdomain Ghost
[scenario]
    name= _ "Ghost_1"
    id=Ghost_1
    map_data="Ghost_1.map"
    next_scenario=null

    {DEFAULT_SCHEDULE}

    {TURNS 20 18 16}
    
    [side]
        side=1
        type=Ghost
        name= _ "Awoken"
        id=Aken
        controller=human
        user_team_name= _ "Ghosts"
        recruit=Ghost

        {GOLD 180 140 120}

    [/side]

    [side]
        side=2
        type=White Mage
        name= _ "Jhon Doe"
        id=pure
        controller=ai
        user_team_name= _ "Bad Guys"

#ifdef HARD

        recruit=Swordsman,Longbowman,Pikeman,magi
#else

        recruit=Spearmen,Bowman,Peasnt
#endif
        {GOLD 80 140 200}
    [/side]
    [event]
        name=prestart
        [objectives]
            side=1
            [objective]
                description= _ "Defeat the enemy leader"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Awoken"
                condition=lose
            [/objective]
            [objective]
                description= _ "Run out of Turns"
                condition=lose
            [/objective]
            [gold_carryover]
                bonus=yes
                carryover_percentage=40
            [/gold_carryover]
        [/objectives]

    [/event]
    
    [event]
        name=start
        [message]
            speaker=pure
            message= _ "Their are the ghosts the peasnt was takling about, kill them all."
        [/message]
        [message]
            speaker=Aken
            message= _ "uh-oh, alright my friends it seems we are under attack!"
        [/message]
    [/event]
    
    [event]
        name=enemies defeated
        [endlevel]
            result=victory
            bonus=yes
            {NEW_GOLD_CARRYOVER 40}
        [/endlevel]
    [/event]
[/scenario] 
All help is much appreciated :).
User avatar
Lord-Knightmare
Discord Moderator
Posts: 2340
Joined: May 24th, 2010, 5:26 pm
Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
Contact:

Re: Custom Scenario Error

Post by Lord-Knightmare »

Your define= and #ifdef are not matching
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
User avatar
Ravana
Forum Moderator
Posts: 2949
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Custom Scenario Error

Post by Ravana »

In map_data you need to put to map text representation. In map_file you can put filename instead.
Killer_Volt
Posts: 3
Joined: July 22nd, 2022, 10:03 am

Re: Custom Scenario Error

Post by Killer_Volt »

Thanks, now at least I'm getting an error message
"A terrain with a string with more than 4 characters has been found, the affected terrain is:Ghost_1.map

Condition 'str.size() <=4'failed at./src/terrain/translation.cpp:713 in function 'string_to_layer_'. "

However when the map is run on a multiplayer game, it works fine, it only bugs when loaded with the scenario.
User avatar
Celtic_Minstrel
Developer
Posts: 2166
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Custom Scenario Error

Post by Celtic_Minstrel »

Does it work if you replace `map_file="Ghost_1.map"` with just `{../maps/Ghost_1.map}`?

If that works, your map is not a map.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
Ravana
Forum Moderator
Posts: 2949
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Custom Scenario Error

Post by Ravana »

Ghost_1.map as longer than 4 symbols is not valid terrain code. Either use map_file or put map content into map_data.
User avatar
Celtic_Minstrel
Developer
Posts: 2166
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Custom Scenario Error

Post by Celtic_Minstrel »

Ah right, if you still have map_data="Ghost_1.map", that won't work.
Last edited by Celtic_Minstrel on February 4th, 2023, 9:25 pm, edited 1 time in total.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
beetlenaut
Developer
Posts: 2814
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Custom Scenario Error

Post by beetlenaut »

This discussion may have gotten a bit confusing. In case you would like some clear instructions, change this line: map_data="Ghost_1.map" into this: map_file="Ghost_1.map". That will fix this error. (If you did already figure it out, you should let us know that your problem is solved.)
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Killer_Volt
Posts: 3
Joined: July 22nd, 2022, 10:03 am

Re: Custom Scenario Error

Post by Killer_Volt »

Yes, thanks you all very much. The scenario now works!
Post Reply