Help with event synthax

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

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.
Zydin
Posts: 12
Joined: June 24th, 2012, 3:42 pm

Help with event synthax

Post by Zydin » June 17th, 2013, 4:09 pm

Hi people!

I'm making a multiplayer scenario to play with some friends but ran into a few problems with events, probably related to synthax.

The first one is with a enter_hex event. I want a message to be displayed when a unit from side 1 or 2 passes by a range of hexes.
The code I wrote for it is:

Code: Select all

    [event]
        name=enter_hex
        [filter]
            side=1,2
            x=5,6,7,8,9,10,11
            y=8,8,9,9,10,10,11
        [/filter]
                [message]
                    speaker=unit
                    message= _ "Sire! These ruins appear to have once been a gate. There is a carved inscription that looks recent!"
                [/message]
                [message]
                    speaker=unit
                    message= _ "It reads «The sentinels guard the only way through the dimensional rift. No human shall pass while they stand.»"
                [/message]
    [/event]
However, as I test it, it only halts the unit, asks me to press T if I want it to keep moving, but shows no message. A moveto event will not do, because it will only work if the unit lands on the array of hexes and will not trigger if the unit is simply passing through them. Can anyone help with this?

Another issue is that I want a surprise boss to appear just when all the canrecruit=yes enemies are defeated. For that I wrote:

Code: Select all

[event]
name=enemies defeated
		[volume]
		sound=100
		[/volume]
		[sound]
		name="dragonstick.ogg"
		[/sound]
                [terrain]
                    x=23-27,25
                    y=27,28
                    terrain=Uu^Dr
                [/terrain]
		
[sound]
name="drake-hit-2.ogg"
[/sound]
[unit]
side=5
type=Fire Dragon
x,y=25,28
max_hitpoints=500
max_experience=2000
[/unit]
                [message]
                    speaker=narrator
                    message= _ "And thus the true overlord showed itself. An ancient Fire Dragon emerged from the depths of the mountain and stood as the final guardian of the curse."
                [/message]
[/event]
Despite working, it immediately jumps to victory and the game ends there. How can I make it so that the game ends in victory only after the dragon is killed?

Thanks a lot for your help!

User avatar
Ravana
Forum Moderator
Posts: 2261
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Help with event synthax

Post by Ravana » June 17th, 2013, 4:25 pm

http://wiki.wesnoth.org/EventWML
name=enter_hex >> name=moveto
As you havent included whether you use 1.10 or 1.11 that might be cause.

Zydin
Posts: 12
Joined: June 24th, 2012, 3:42 pm

Re: Help with event synthax

Post by Zydin » June 17th, 2013, 4:31 pm

Ravana wrote:http://wiki.wesnoth.org/EventWML
name=enter_hex >> name=moveto
As you havent included whether you use 1.10 or 1.11 that might be cause.
Hi Ravana and thanks for the reply.

I use 1.10 (stable) so for that first one that might be it, yes. Do you reccomend an alternate way to do this effect with 1.10?

User avatar
Dugi
Posts: 4931
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: Help with event synthax

Post by Dugi » June 17th, 2013, 4:44 pm

It is obligatory to use name=moveto on 1.10, because enter_hex works only on 1.11.

And your problem with enemies defeated is that it is fired just before you win the scenario by defeating the enemies, and spawning more enemies will not stop the player from winning. There is no good workaround for this, but I think that using victory_when_enemies_defeated=no, a die event on leaders that checks whether some leaders of enemy sides are surviving via [have_unit] and spawning the enemy then should do the trick.

Zydin
Posts: 12
Joined: June 24th, 2012, 3:42 pm

Re: Help with event synthax

Post by Zydin » June 17th, 2013, 5:02 pm

Dugi wrote:It is obligatory to use name=moveto on 1.10, because enter_hex works only on 1.11.

And your problem with enemies defeated is that it is fired just before you win the scenario by defeating the enemies, and spawning more enemies will not stop the player from winning. There is no good workaround for this, but I think that using victory_when_enemies_defeated=no, a die event on leaders that checks whether some leaders of enemy sides are surviving via [have_unit] and spawning the enemy then should do the trick.
Hi Dugi!

I found a workable sollution to use moveto instead of enter_hex. Basically I placed an impassable overlay on the hexes next to the array I set the trigger on, forcing the units to stop there, triggering the event. When the event is triggered, the impassable overlay is removed and the same regular terrain is put in its place:

Code: Select all

[event]
        name=moveto
        [filter]
            side=1,2
            x=5,6,7,8,9,10,11
            y=8,8,9,9,10,10,11
        [/filter]
                [message]
                    speaker=unit
                    message= _ "Sire! These ruins appear to have once been a gate. There is a carved inscription that looks recent!"
                [/message]
                [message]
                    speaker=unit
                    message= _ "It reads «The sentinels guard the only way through the dimensional rift. No human shall pass while they stand.»"
                [/message]
                [terrain]
                    x=5,8,11
                    y=7,8,10
                    terrain=Cdr
                [/terrain]
                [terrain]
                    x=6,7,9,10
                    y=7,8,9,9
                    terrain=Hd^Dr
                [/terrain]
    [/event]
Regarding your suggestion for the other issue, I can't quite follow you as I'm a newbie when it comes to coding my own scenarios. Can you please, if possible, be more explicit as to what I have to do? I actually had already tried using the [have_unit] tag but never got it to work. All the help you can offer is most appreciated as I'm still learning how to find my way around scenario coding. :D

User avatar
Dugi
Posts: 4931
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: Help with event synthax

Post by Dugi » June 17th, 2013, 5:15 pm

Haven't tested it, tried to add comments to explain how it works. It should be possible to write in an easier way.

Code: Select all

victory_when_enemies_defeated=no   #The player would win when defeating the last leader otherwise
[event]
name=die
first_time_only=no   #Not only one enemy leader will die
id=activate_dragon  #This is just to mark this event somehow, because of its later removal.
 [filter]
  canrecruit=yes   #Activate only if a leader dies, otherwise it would be fired uselessly.
 [/filter]
 [if]
  [have_unit]   #Checks if at least one of enemy sides have a leader remaining.
   canrecruit=yes
   side=3,4,5 #List the enemy sides here, 3,4,5 is just a guess from my side
  [/have_unit]
  [else]  #If the condition above fails, therefore there is no enemy leader, the following will be fired 
   [event]
    id=activate_dragon   #Removing this event, to prevent it from firing again and creating another dragon
    remove=yes
   [/event]
      [volume]   #Your code.
      sound=100
      [/volume]
      [sound]
      name="dragonstick.ogg"
      [/sound]
                [terrain]
                    x=23-27,25
                    y=27,28
                    terrain=Uu^Dr
                [/terrain]
      
[sound]
name="drake-hit-2.ogg"
[/sound]
[unit]
side=5
type=Fire Dragon
x,y=25,28
max_hitpoints=500
max_experience=2000
[/unit]
                [message]
                    speaker=narrator
                    message= _ "And thus the true overlord showed itself. An ancient Fire Dragon emerged from the depths of the mountain and stood as the final guardian of the curse."
                [/message]
  [/else]
 [/if]
[/event]

Max
Posts: 1449
Joined: April 13th, 2008, 12:41 am

Re: Help with event synthax

Post by Max » June 17th, 2013, 5:43 pm


Zydin
Posts: 12
Joined: June 24th, 2012, 3:42 pm

Re: Help with event synthax

Post by Zydin » June 17th, 2013, 6:15 pm

Dugi wrote:Haven't tested it, tried to add comments to explain how it works. It should be possible to write in an easier way.

Code: Select all

victory_when_enemies_defeated=no   #The player would win when defeating the last leader otherwise
[event]
name=die
first_time_only=no   #Not only one enemy leader will die
id=activate_dragon  #This is just to mark this event somehow, because of its later removal.
 [filter]
  canrecruit=yes   #Activate only if a leader dies, otherwise it would be fired uselessly.
 [/filter]
 [if]
  [have_unit]   #Checks if at least one of enemy sides have a leader remaining.
   canrecruit=yes
   side=3,4,5 #List the enemy sides here, 3,4,5 is just a guess from my side
  [/have_unit]
  [else]  #If the condition above fails, therefore there is no enemy leader, the following will be fired 
   [event]
    id=activate_dragon   #Removing this event, to prevent it from firing again and creating another dragon
    remove=yes
   [/event]
      [volume]   #Your code.
      sound=100
      [/volume]
      [sound]
      name="dragonstick.ogg"
      [/sound]
                [terrain]
                    x=23-27,25
                    y=27,28
                    terrain=Uu^Dr
                [/terrain]
      
[sound]
name="drake-hit-2.ogg"
[/sound]
[unit]
side=5
type=Fire Dragon
x,y=25,28
max_hitpoints=500
max_experience=2000
[/unit]
                [message]
                    speaker=narrator
                    message= _ "And thus the true overlord showed itself. An ancient Fire Dragon emerged from the depths of the mountain and stood as the final guardian of the curse."
                [/message]
  [/else]
 [/if]
[/event]
Ahhh! I see. So I can use the [have_unit] tag to check whether those enemy sides have any unit that canrecruit=yes? Interesting! I thought the canrecruit was only used to define sides who had leaders and not to single out units that could recruit.

I also thought that to use the [if] you were forced to use both a [then] and a [else]. Some things like these are not very explicit in the wiki pages.

Thanks a lot! I'll give it a go and tell you how it went.

User avatar
8680
Moderator Emeritus
Posts: 742
Joined: March 20th, 2011, 11:45 pm
Location: The past

Re: Help with event synthax

Post by 8680 » June 17th, 2013, 6:39 pm

Merged cross-posted [Posting Guidelines §1f] thread from Scenario & Campaign Development.

Zydin
Posts: 12
Joined: June 24th, 2012, 3:42 pm

Re: Help with event synthax

Post by Zydin » June 17th, 2013, 6:52 pm

Zydin wrote:
Dugi wrote:Haven't tested it, tried to add comments to explain how it works. It should be possible to write in an easier way.

Code: Select all

victory_when_enemies_defeated=no   #The player would win when defeating the last leader otherwise
[event]
name=die
first_time_only=no   #Not only one enemy leader will die
id=activate_dragon  #This is just to mark this event somehow, because of its later removal.
 [filter]
  canrecruit=yes   #Activate only if a leader dies, otherwise it would be fired uselessly.
 [/filter]
 [if]
  [have_unit]   #Checks if at least one of enemy sides have a leader remaining.
   canrecruit=yes
   side=3,4,5 #List the enemy sides here, 3,4,5 is just a guess from my side
  [/have_unit]
  [else]  #If the condition above fails, therefore there is no enemy leader, the following will be fired 
   [event]
    id=activate_dragon   #Removing this event, to prevent it from firing again and creating another dragon
    remove=yes
   [/event]
      [volume]   #Your code.
      sound=100
      [/volume]
      [sound]
      name="dragonstick.ogg"
      [/sound]
                [terrain]
                    x=23-27,25
                    y=27,28
                    terrain=Uu^Dr
                [/terrain]
      
[sound]
name="drake-hit-2.ogg"
[/sound]
[unit]
side=5
type=Fire Dragon
x,y=25,28
max_hitpoints=500
max_experience=2000
[/unit]
                [message]
                    speaker=narrator
                    message= _ "And thus the true overlord showed itself. An ancient Fire Dragon emerged from the depths of the mountain and stood as the final guardian of the curse."
                [/message]
  [/else]
 [/if]
[/event]
Ahhh! I see. So I can use the [have_unit] tag to check whether those enemy sides have any unit that canrecruit=yes? Interesting! I thought the canrecruit was only used to define sides who had leaders and not to single out units that could recruit.

I also thought that to use the [if] you were forced to use both a [then] and a [else]. Some things like these are not very explicit in the wiki pages.

Thanks a lot! I'll give it a go and tell you how it went.
It worked, yes, but I had to include the following code to trigger victory when the dragon was defeated (I gave a name to the dragon unit: "Ancient Fire Dragon"):

Code: Select all

[event]
name=die
first_time_only=no
[filter]
name=Ancient Fire Dragon
[/filter]
[endlevel]
result=victory
[/endlevel]
[/event]
Thanks you so much for your help. I do try to go through the wiki first, but I was stuck with some unclear points.

User avatar
Dugi
Posts: 4931
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: Help with event synthax

Post by Dugi » June 17th, 2013, 6:57 pm

I considered it obvious that the dragon will have to have a die event in order to make the players win. Sorry for it.
Anyway, I am glad that it worked. Good luck in further writing of WML codes.

Zydin
Posts: 12
Joined: June 24th, 2012, 3:42 pm

Re: Help with event synthax

Post by Zydin » June 17th, 2013, 7:05 pm

Dugi wrote:I considered it obvious that the dragon will have to have a die event in order to make the players win. Sorry for it.
Anyway, I am glad that it worked. Good luck in further writing of WML codes.
Yeah, being new to all this WML thingy (even though I learn quickly) I miss the obvious.

Thanks Dugi and Ravana for helping me out!

Zydin
Posts: 12
Joined: June 24th, 2012, 3:42 pm

Re: Help with event synthax

Post by Zydin » June 18th, 2013, 1:54 am

Zydin wrote:
Dugi wrote:I considered it obvious that the dragon will have to have a die event in order to make the players win. Sorry for it.
Anyway, I am glad that it worked. Good luck in further writing of WML codes.
Yeah, being new to all this WML thingy (even though I learn quickly) I miss the obvious.

Thanks Dugi and Ravana for helping me out!
Since it's ready and you guys helped me out, here are the files to play it, should you ever fell like it.
It's a 2 sides Loyalist alliance against all other 4 sides, one of them merely composed of unmoving guardians.

Of course it goes without saying, but it's supposed to be played with the scenario side settings.

I hope you enjoy and thanks once again.
Attachments
Desert_Curse.map
Map file
(26.29 KiB) Downloaded 83 times
Desert_Curse.cfg
Scenario file
(9.28 KiB) Downloaded 85 times

fabi
Developer
Posts: 1223
Joined: March 21st, 2004, 2:42 pm
Location: Germany

Re: Help with event synthax

Post by fabi » June 22nd, 2013, 10:18 pm

You might also want to consider uploading it to the addon server.

Zydin
Posts: 12
Joined: June 24th, 2012, 3:42 pm

Re: Help with event synthax

Post by Zydin » June 22nd, 2013, 11:27 pm

fabi wrote:You might also want to consider uploading it to the addon server.
Thanks for the suggestion.

Well, it's just a single and simple mp scenario, but anyway, how do I do that?

Regards!

Post Reply