Blueknights Questions

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
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Blueknights Questions

Post by zookeeper »

Should be pretty straightforward:

Code: Select all

[event]
    name=prestart
    
    {VARIABLE_OP village rand "a,b,c"}
    
    [switch]
        variable=village
        
        [case]
            value=a
            
            {VARIABLE village_x 5}
            {VARIABLE village_y 7}
        [/case]
        
        [case]
            value=b
            
            {VARIABLE village_x 9}
            {VARIABLE village_y 6}
        [/case]
        
        [case]
            value=c
            
            {VARIABLE village_x 10}
            {VARIABLE village_y 4}
        [/case]
    [/switch]
[/event]

[event]
    name=moveto
    
    [filter]
        side=1
        x,y=$village_x,$village_y
    [/filter]
    
    # ...
    
    {CLEAR_VARIABLE village,village_x,village_y}
[/event]
Untested, though.
blueknight1758
Posts: 252
Joined: March 30th, 2011, 8:38 pm
Location: The UK

Re: Blueknights Questions

Post by blueknight1758 »

Thank you zookeeper I'll test this very soon.
Also I've noticed that more complicated WML has $ signs in it and as in aspiring to get better at WML I wondered what the $ sign actually means, does anyone know?
User avatar
lipk
Posts: 637
Joined: July 18th, 2011, 1:42 pm

Re: Blueknights Questions

Post by lipk »

The $ sign before a variable name means substitute-the-variable's-value-here.
So while

Code: Select all

[set_variable]
  name=hello_message
  value=_ "Welcome!"
[/set_variable]
[message]
  speaker=narrator
  message="hello_message"
[/message]
will display 'hello_message'

Code: Select all

[set_variable]
  name=hello_message
  value=_ "Welcome!"
[/set_variable]
[message]
  speaker=narrator
  message="$hello_message"
[/message]
will display 'Welcome!'.

I wonder how could you get by without this for so long :)
blueknight1758
Posts: 252
Joined: March 30th, 2011, 8:38 pm
Location: The UK

Re: Blueknights Questions

Post by blueknight1758 »

Thanks again zookeeper that does work and very well.
Lipk thanks for that information it was very helpful and I wrote some code alongside Zookeeper's using $ and it works great.
Regarding the Catapult WML it does not work in the [scenario] tag with a unit that's attack id and name is catapult.
Do you have any ideas what might be causing it?
User avatar
lipk
Posts: 637
Joined: July 18th, 2011, 1:42 pm

Re: Blueknights Questions

Post by lipk »

I'm not sure what do you mean by the unit's 'attack id and name', but this code works for a unit of the type Catapult (there's no such unit of course). You can replace that with Great Troll, Spearman, or anything you wish.
blueknight1758
Posts: 252
Joined: March 30th, 2011, 8:38 pm
Location: The UK

Re: Blueknights Questions

Post by blueknight1758 »

Ohhh sorry I read the code as the attack name needing to be Catapult not the unit type sorry.

Also another dilema I would like to make it so that when youuncover the mage hiding in the derilict village some dialog occurs then Side 2 targets the mage with value 100 and the scenario is won 10 turns after that. So far I have got the attached file below (the concerned code is 97-216) and when the event fires it's all good until the [side] tag where I get the in-game error invalid <WML> [side] or something, could anyone:
a. Point out how to correctly do what I have done.
b. Tell me the code for the game ending 10 turns after the event.

Thanks in advance.

EDIT: removed file
Last edited by blueknight1758 on September 9th, 2011, 2:54 pm, edited 2 times in total.
Ceres
Forum Regular
Posts: 620
Joined: September 18th, 2010, 7:56 pm
Location: Germany

Re: Blueknights Questions

Post by Ceres »

It's [modify_side], not [side]. Or, if you just want to change ai behaviour, use [modify_ai].
blueknight1758
Posts: 252
Joined: March 30th, 2011, 8:38 pm
Location: The UK

Re: Blueknights Questions

Post by blueknight1758 »

Lipk yes that Catapult works a treatnow thanks!
Yes Ceres that has definitely got rid of the error so I can assume the ai is targeting the Monk now.
So does anyone know how to make the scenarioend with a victory 10 turns after this event?
Ceres
Forum Regular
Posts: 620
Joined: September 18th, 2010, 7:56 pm
Location: Germany

Re: Blueknights Questions

Post by Ceres »

Code: Select all

[set_variable]
   name=guy_found
   value=$turn_number  # when finding the monk
[set_variable]
...
[event]
   name=side 1 turn
   first_time_only=no
   [if]
      [variable]
         name=turn_number
         equals="$($guy_found+10)"
      [/variable]
      [then]
         <do stuff>
blueknight1758
Posts: 252
Joined: March 30th, 2011, 8:38 pm
Location: The UK

Re: Blueknights Questions

Post by blueknight1758 »

So that code how does it work because I can't fathom where to put it exactly.
(also it looks like i'd need to have an exact turn the monk is 'found' but in the scenario that depends on how the player plays and is random: I might be wrong with this statement though.)
Ceres
Forum Regular
Posts: 620
Joined: September 18th, 2010, 7:56 pm
Location: Germany

Re: Blueknights Questions

Post by Ceres »

turn_number is automatically storing the current turn number.
Put the [set_variable] part into the mage finding village moveto event.
Put the [event] somewhere in your [scenario] tag.

How this code works? You're storing the current turn in a variable (you need to save it in another variable because otherwise it'd be overwritten next turn). Every time it's your turn, Wesnoth checks if the current turn number equals the turn number when finding the mage plus ten. If yes, the code in the [event] is executed (an [endlevel] tag for example).
blueknight1758
Posts: 252
Joined: March 30th, 2011, 8:38 pm
Location: The UK

Re: Blueknights Questions

Post by blueknight1758 »

i've tried that but I get an error when thegame has loaded saying invalid <WML> [then] not supported. Also I hadto put a [/if] at the end of [/set_variable] is that the right place?
Do you know why this is?
I'm on 1.9.7 if that helps.
Ceres
Forum Regular
Posts: 620
Joined: September 18th, 2010, 7:56 pm
Location: Germany

Re: Blueknights Questions

Post by Ceres »

I can't exactly figure out how your code looks, so you'll have to post it.

(you know that the code I posted wasn't fully complete, namely missing the closing tags, as I only wanted to show which tags to use, right?)
blueknight1758
Posts: 252
Joined: March 30th, 2011, 8:38 pm
Location: The UK

Re: Blueknights Questions

Post by blueknight1758 »

Ceres wrote: (you know that the code I posted wasn't fully complete, namely missing the closing tags, as I only wanted to show which tags to use, right?)
Yes I know and I closed them before launching the game, the game loads up and is all fine until the scenario the code is in loads and I get the error.
I'll post the scenario.cfg ASAP
EDIT: Uploaded scenario file, the code regarded is lines 132-233
Attachments
01_Template.cfg
(7.76 KiB) Downloaded 104 times
uncleshelby
Posts: 427
Joined: May 10th, 2011, 7:20 pm

Re: Blueknights Questions

Post by uncleshelby »

I think you want this:

Code: Select all

[event]
        name=new turn
        first_time_only=no
        [filter]
          side=1
        [/filter]
        [if]
          [variable]
             name=turn_number
             equals="$($guy_found+10)"
          [/variable]
          [/if]
          [then]
          [endlevel]
             result=victory
          [/endlevel]
          [/then]
[/event]
I'm not super good with wml, but I think this is it.
Timshel
Post Reply