just need a little bit of help prevent an event from firing

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
Huston
Posts: 1070
Joined: April 29th, 2009, 8:26 pm
Location: Somewhere in this World(I Think)

just need a little bit of help prevent an event from firing

Post by Huston »

can someone please modify my coding so that this moveto event doesn't fire unless the lich in my scenario has been defeated already. i checked the mainline campaigns and the wml reference page and didn't fully understand how to do it. the lich's name is "Mal Addraer" Thanks in advance

Code: Select all

    [event]
        name=moveto
        [filter]
            x=24
            y=33
            id=Horatio
        [/filter]

        [message]
            speaker=Horatio
            message= _ "We have defeated the lich and made it to the other side of the swamp. 
Onwards to the Greywoods."
        [/message]

	[endlevel]
	    result=victory
	    bonus=no
	    {NEW_GOLD_CARRYOVER 60}
	[/endlevel]
    [/event]
Exasperation
Posts: 462
Joined: June 8th, 2006, 3:25 am

Re: just need a little bit of help prevent an event from firing

Post by Exasperation »

I believe that what you're looking for is a nested event that looks something like this:

Code: Select all

[event]
	name=die
	[filter]
		id=Mal Addraer
	[/filter]
	
	[event]
		name=moveto
		[filter]
			id=Horatio
			[and]
				x,y=24,33
			[/and]
		[/filter]
		
		[message]
			<put your message here>
		[/message]
		[endlevel]
			<put your victory stuff here>
		[/endlevel]
	[/event]
[/event]
The outer die event adds the inner moveto event to the scenario when it's triggered, so before the die event is triggered, the moveto event isn't part of the scenario, and thus can't be triggered early.
User avatar
Huston
Posts: 1070
Joined: April 29th, 2009, 8:26 pm
Location: Somewhere in this World(I Think)

Re: just need a little bit of help prevent an event from firing

Post by Huston »

thank you very much for your help and for explaining it.
User avatar
CountPenguin
Posts: 132
Joined: May 25th, 2007, 1:13 am
Location: USA

Re: just need a little bit of help prevent an event from firing

Post by CountPenguin »

I don't think that will work. If it does, great! If it doesn't, here's what I think you need to do: First set a variable (let's call it lich_dead). This goes somewhere in the scenario, just on its own (not inside an event or side tag):

{VARIABLE lich_dead no}

Then change it when Mal Addraer dies:

Code: Select all

[event]
	name=die
	[filter]
		id=Mal Addraer
	[/filter]
	[set_variable]
		name=lich_dead
		value=yes
	[/set_variable]
[/event]
Then you can make your moveto event only end the scenario if the lich is dead (you need first_time_only=no because otherwise if you move there while the lich is still alive, you won't be able refire the event, meaning you can't win):

Code: Select all

[event]
	name=moveto
	first_time_only=no
	[filter]
		x,y=24,33
		id=Horatio
	[/filter]
	[if]
		[variable]
			name=lich_dead
			boolean_equals=yes
		[/variable]
		[then]
			##put your message
			##then your endlevel
		[/then]
	[/if]
[/event]
I hope that works, I'm just learning WML too.
Last edited by CountPenguin on May 2nd, 2009, 9:09 pm, edited 1 time in total.
CountPenguin

Currently working on Siege of Soradoc. Except not anymore, but you can take over if you want!
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: just need a little bit of help prevent an event from firing

Post by Sapient »

I find it simpler to add first_time_only=no and put the relevant actions inside an [if][then] conditional statement. You can use the [have_unit] condition rather than setting a flag...

Code: Select all

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x=24
            y=33
            id=Horatio
        [/filter]
        [if]
                [not]
                        [have_unit]
                                type=Lich
                        [/have_unit]
                [/not]
        [/if]
        [then]
                [message]
                    speaker=Horatio
                    message= _ "We have defeated the lich and made it to the other side of the swamp. 
Onwards to the Greywoods."
                [/message]
        	[endlevel]
	            result=victory
	            bonus=no
	            {NEW_GOLD_CARRYOVER 60}
	        [/endlevel]
        [/then]
    [/event]
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
User avatar
CountPenguin
Posts: 132
Joined: May 25th, 2007, 1:13 am
Location: USA

Re: just need a little bit of help prevent an event from firing

Post by CountPenguin »

ya, that probably would be simpler
CountPenguin

Currently working on Siege of Soradoc. Except not anymore, but you can take over if you want!
User avatar
Huston
Posts: 1070
Joined: April 29th, 2009, 8:26 pm
Location: Somewhere in this World(I Think)

Re: just need a little bit of help prevent an event from firing

Post by Huston »

Thanks everyone
coded Rebellion During the Dark Age
Currently working on:
Era of the Future
Post Reply