Difference between revisions of "BuildingScenariosSamples"

From The Battle for Wesnoth Wiki
 
Line 4: Line 4:
 
to flash the screen red for a moment, we might go,
 
to flash the screen red for a moment, we might go,
  
  [colour_adjust]
+
[colour_adjust]
  red=200
+
    red=200
  [/colour_adjust]
+
[/colour_adjust]
  [delay]
+
  time=20
+
[delay]
  [/delay]
+
    time=20
  [colour_adjust]
+
[/delay]
  red=0
+
  [/colour_adjust]
+
[colour_adjust]
 +
    red=0
 +
[/colour_adjust]
  
 
A unit remarking what a tough fight it was when they kill an Ogre:
 
A unit remarking what a tough fight it was when they kill an Ogre:
  
  [event]
+
[event]
  name=die
+
    name=die
    [filter]
+
    [filter]
    type=Ogre
+
        type=Ogre
    [/filter]
+
    [/filter]
    [message]
+
    speaker=second_unit
+
    [message]
    message= _ "Whew! That was a tough fight!"
+
        speaker=second_unit
    [/message]
+
          message= _ "Whew! That was a tough fight!"
  [/event]
+
    [/message]
 +
[/event]
  
 
Konrad remarks that he is scared at the start of a scenario:
 
Konrad remarks that he is scared at the start of a scenario:
  
  [event]
+
[event]
  name=start
+
    name=start
    [message]
+
    [message]
    speaker=Konrad
+
        speaker=Konrad
    message= _ "I feel uneasy about this place"
+
        message= _ "I feel uneasy about this place"
    [/message]
+
    [/message]
  [/event]
+
[/event]
  
 
A selection of which way they should go at the end of a scenario:
 
A selection of which way they should go at the end of a scenario:
  
  [event]
+
[event]
  name=victory
+
    name=victory
    [message]
+
    [message]
    speaker=narrator
+
        speaker=narrator
    message= _ "Which way do you wish to go?"
+
        message= _ "Which way do you wish to go?"
      [option]
+
        [option]
      message= _ "North"
+
            message= _ "North"
        [command]
+
            [command]
          [endlevel]
+
                [endlevel]
          result=victory
+
                    result=victory
          next_scenario="Northern Advance"
+
                    next_scenario="Northern Advance"
          [/endlevel]
+
                [/endlevel]
        [/command]
+
            [/command]
      [/option]
+
        [/option]
      [option]
+
        [option]
      message= _ "South"
+
            message= _ "South"
        [command]
+
            [command]
          [endlevel]
+
                [endlevel]
          result=victory
+
                    result=victory
          next_scenario="Southern Citadel"
+
                    next_scenario="Southern Citadel"
          [/endlevel]
+
                [/endlevel]
        [/command]
+
            [/command]
      [/option]
+
        [/option]
    [/message]
+
    [/message]
  [/event]
+
[/event]
  
 
Suppose you want to make it so that if a certain character, we will call him Fred the Peasant, survives in a certain
 
Suppose you want to make it so that if a certain character, we will call him Fred the Peasant, survives in a certain
Line 69: Line 72:
 
but return in a later scenario. We can do this in the first scenario:
 
but return in a later scenario. We can do this in the first scenario:
  
  [event]
+
[event]
    name=victory
+
    name=victory
    [if]
+
    [if]
      [have_unit]
+
        [have_unit]
      id=Fred
+
            id=Fred
      [/have_unit]
+
        [/have_unit]
      [then]
+
        [then]
        [message]
+
            [message]
        speaker=Fred
+
                speaker=Fred
        message= _ "I must go now, friends, but will return later!"
+
                message= _ "I must go now, friends, but will return later!"
        [/message]
+
            [/message]
        [kill]
+
        id=Fred
+
            [kill]
        [/kill]
+
                id=Fred
        [set_variable]
+
            [/kill]
        name=fred_is_alive
+
        value=yes
+
            [set_variable]
        [/set_variable]
+
                name=fred_is_alive
      [/then]
+
                value=yes
 +
            [/set_variable]
 +
        [/then]
 
     [/if]
 
     [/if]
  [/event]
+
[/event]
  
 
This makes it so that if Fred is alive, he says something, then is removed from the game, and the variable
 
This makes it so that if Fred is alive, he says something, then is removed from the game, and the variable
Line 96: Line 101:
 
In a later scenario, we can use the following code:
 
In a later scenario, we can use the following code:
  
  [event]
+
[event]
    name=turn 7
+
    name=turn 7
    [if]
+
    [if]
      [variable]
+
        [variable]
      name=fred_is_alive
+
            name=fred_is_alive
      equals=yes
+
            equals=yes
      [/variable]
+
        [/variable]
      [then]
+
        [then]
        [unit]
+
            [unit]
        type=Peasant
+
                id=Fred
        id=Fred
+
                name= _ "Fred"
        name= _ "Fred"
+
                side=1
        side=1
+
                type=Peasant
        x=8
+
                x,y=8,1
        y=1
+
            [/unit]
        [/unit]
+
        [message]
+
            [message]
        speaker=Fred
+
                speaker=Fred
        message= _ "I have returned to aid you friends!"
+
                message= _ "I have returned to aid you friends!"
        [/message]
+
            [/message]
      [/then]
+
        [/then]
      [else]
+
        [else]
        [message]
+
            [message]
        speaker=Konrad
+
                speaker=Konrad
        message= _ "I wish Fred were still alive. He would know what to do!"
+
                message= _ "I wish Fred were still alive. He would know what to do!"
        [/message]
+
            [/message]
      [/else]
+
        [/else]
    [/if]
+
    [/if]
  [/event]
+
[/event]
  
 
If the variable 'fred_is_alive' equals 'yes' then this will create a unit, Fred, a Peasant, at (8,1), and he will give a
 
If the variable 'fred_is_alive' equals 'yes' then this will create a unit, Fred, a Peasant, at (8,1), and he will give a
Line 132: Line 137:
 
hate the undead, and if so, and get it to say something:
 
hate the undead, and if so, and get it to say something:
  
  [role]
+
[role]
  role=undead_hater
+
    role=undead_hater
  type=Mage of Light,Paladin,White Mage
+
    type=Mage of Light,Paladin,White Mage
  [/role]
+
[/role]
  [message]
+
  role=undead_hater
+
[message]
  message= _ "The foul hordes of the undead approach, this battle will surely be tough!"
+
    role=undead_hater
  [/message]
+
    message= _ "The foul hordes of the undead approach, this battle will surely be tough!"
 
+
[/message]
  
 
== See Also ==
 
== See Also ==

Latest revision as of 18:49, 11 March 2014

This page contains basic examples of WML. For more examples, you can look at the data of Wesnoth using a text editor.

to flash the screen red for a moment, we might go,

[colour_adjust]
    red=200
[/colour_adjust]

[delay]
    time=20
[/delay]

[colour_adjust]
    red=0
[/colour_adjust]

A unit remarking what a tough fight it was when they kill an Ogre:

[event]
    name=die
    [filter]
        type=Ogre
    [/filter]

    [message]
        speaker=second_unit
         message= _ "Whew! That was a tough fight!"
    [/message]
[/event]

Konrad remarks that he is scared at the start of a scenario:

[event]
    name=start
    [message]
        speaker=Konrad
        message= _ "I feel uneasy about this place"
    [/message]
[/event]

A selection of which way they should go at the end of a scenario:

[event]
    name=victory
    [message]
        speaker=narrator
        message= _ "Which way do you wish to go?"
        [option]
            message= _ "North"
            [command]
                [endlevel]
                    result=victory
                    next_scenario="Northern Advance"
                [/endlevel]
            [/command]
        [/option]
        [option]
            message= _ "South"
            [command]
                [endlevel]
                    result=victory
                    next_scenario="Southern Citadel"
                [/endlevel]
            [/command]
        [/option]
    [/message]
[/event]

Suppose you want to make it so that if a certain character, we will call him Fred the Peasant, survives in a certain scenario, he will leave, but return in a later scenario. We can do this in the first scenario:

[event]
    name=victory
    [if]
        [have_unit]
            id=Fred
        [/have_unit]
        [then]
            [message]
                speaker=Fred
                message= _ "I must go now, friends, but will return later!"
            [/message]

            [kill]
                id=Fred
            [/kill]

            [set_variable]
                name=fred_is_alive
                value=yes
            [/set_variable]
        [/then]
    [/if]
[/event]

This makes it so that if Fred is alive, he says something, then is removed from the game, and the variable 'fred_is_alive' is set to yes.

In a later scenario, we can use the following code:

[event]
    name=turn 7
    [if]
        [variable]
            name=fred_is_alive
            equals=yes
        [/variable]
        [then]
            [unit]
                id=Fred
                name= _ "Fred"
                side=1
                type=Peasant
                x,y=8,1
            [/unit]

            [message]
                speaker=Fred
                message= _ "I have returned to aid you friends!"
            [/message]
        [/then]
        [else]
            [message]
                speaker=Konrad
                message= _ "I wish Fred were still alive. He would know what to do!"
            [/message]
        [/else]
    [/if]
[/event]

If the variable 'fred_is_alive' equals 'yes' then this will create a unit, Fred, a Peasant, at (8,1), and he will give a greeting message. Otherwise, Konrad will lament Fred being dead.

Suppose the player has just come across some undead, you might like to find if the player has a unit that would truly hate the undead, and if so, and get it to say something:

[role]
    role=undead_hater
    type=Mage of Light,Paladin,White Mage
[/role]

[message]
    role=undead_hater
    message= _ "The foul hordes of the undead approach, this battle will surely be tough!"
[/message]

See Also

This page was last edited on 11 March 2014, at 18:49.