Help with sighted events

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.
User avatar
turin
Lord of the East
Posts: 11662
Joined: January 11th, 2004, 7:17 pm
Location: Texas
Contact:

Help with sighted events

Post by turin »

I really dislike the syntax of sighted events. However, they are very useful for plot purposes, so I'm going to keep trying this.

Lets say I have a side A, and then two more sides, B and C. (There are also sides D, E and F in the scenario, but let's not worry about them). I want an event that triggers whenever a sighted event occurs between 1), A and B, 2), B and A, 3), A and C, and 4), C and A. Is there a simple way to do this? I was thinking of using the [or] tag, but apparently that only works for [if] statements, not event filters...

Also, sighted events don't seem to trigger when one side can see the hexes on a castle, but not the keep, and then the other sides recruits a unit onto the castle hex. However, this makes it so the sighted criteria (have never seen each other before that scenario) is invalidated, so no later sighteds work. Is there any way to fix this?
For I am Turin Turambar - Master of Doom, by doom mastered. On permanent Wesbreak. Will not respond to private messages. Sorry!
And I hate stupid people.
The World of Orbivm
GregorR
Posts: 51
Joined: September 26th, 2005, 9:19 pm
Location: Portland, OR
Contact:

Post by GregorR »

Seems to me like the easiest would be to #define it ...

#define DO_SIGHTED_EVENT A B
...
side=A
...
side=B
...
#enddef

then
{DO_SIGHTED_EVENT 1 2}
{DO_SIGHTED_EVENT 2 1}
etc...
User avatar
turin
Lord of the East
Posts: 11662
Joined: January 11th, 2004, 7:17 pm
Location: Texas
Contact:

Post by turin »

That would most definitely not work. It would make it trigger twice, once when you see them and once when they see you. :roll:

I'm pretty sure that I've considered all of the obvious solutions, so don't post something until you're sure it works, and it isn't just a guess. ;)

Right now, I actually don't care if it's elegant or not, just find something that works. Then I'll elegant-ize it myself.
For I am Turin Turambar - Master of Doom, by doom mastered. On permanent Wesbreak. Will not respond to private messages. Sorry!
And I hate stupid people.
The World of Orbivm
GregorR
Posts: 51
Joined: September 26th, 2005, 9:19 pm
Location: Portland, OR
Contact:

Post by GregorR »

turin wrote:That would most definitely not work. It would make it trigger twice, once when you see them and once when they see you. :roll:

I'm pretty sure that I've considered all of the obvious solutions, so don't post something until you're sure it works, and it isn't just a guess. ;)

Right now, I actually don't care if it's elegant or not, just find something that works. Then I'll elegant-ize it myself.
I'm actually not sitting in front of Wesnoth right now, so I can't test this, sorry, just throwing stuff out :P

Oh, OK, so you need to set a variable.

[event]
name=start
[set_variable]
name=donesighted
value=0
[/set_variable]
[/event]

(I never remember [if] syntax right, so you may need to fine-tune this :P)

#define DO_SIGHTED_EVENT A B
[event]
name=sighted
[if]
[variable]
name=donesighted
not_equals=1
[/variable]
[then]
...
side=A
...
side=B
...
[set_variable]
name=donesighted
value=1
[/set_variable]
...
[/then]
[/if]
[/event]
#enddef

EDIT: Missed the #enddef
User avatar
turin
Lord of the East
Posts: 11662
Joined: January 11th, 2004, 7:17 pm
Location: Texas
Contact:

Post by turin »

Well, it's ugly, but it willl work...

Any other ideas?
For I am Turin Turambar - Master of Doom, by doom mastered. On permanent Wesbreak. Will not respond to private messages. Sorry!
And I hate stupid people.
The World of Orbivm
bruno
Inactive Developer
Posts: 293
Joined: June 26th, 2005, 8:39 pm
Contact:

Re: Help with sighted events

Post by bruno »

turin wrote: I was thinking of using the [or] tag, but apparently that only works for [if] statements, not event filters...
In some cases you can use [not] to do this. Using DeMorgan's law, a or b <=> not(not a and not b). I have an example of this documented in the wiki for SUFs.
See http://www.wesnoth.org/wiki/FilterWML#Filtering_Units
User avatar
turin
Lord of the East
Posts: 11662
Joined: January 11th, 2004, 7:17 pm
Location: Texas
Contact:

Post by turin »

Here is the set-up I need:

Code: Select all

[or]
[filter]
side=1
[/filter]
[filter_second]
side=3,4
[/filter_second]
[/or]
[or]
[filter]
side=3,4
[/filter]
[filter_second]
side=1
[/filter_second]
[/or]
How would I set that up using [not]s? :?
For I am Turin Turambar - Master of Doom, by doom mastered. On permanent Wesbreak. Will not respond to private messages. Sorry!
And I hate stupid people.
The World of Orbivm
bruno
Inactive Developer
Posts: 293
Joined: June 26th, 2005, 8:39 pm
Contact:

Post by bruno »

I don't think it will work in your case because the standard unit filter and second unit filters are separate and to use the [not] idea you need to be able to not a combination of both.
If I am wrong and you can use a second unit filter inside a standard unit filter than there would be a way to do it.
User avatar
turin
Lord of the East
Posts: 11662
Joined: January 11th, 2004, 7:17 pm
Location: Texas
Contact:

Post by turin »

OK, I'm not sure why, but this code does not work.

Suggestions?

Code: Select all

	[event]
	name=sighted
		[filter_second]
		side=1
		[/filter_second]
		[filter]
		side=3,4
		[/filter]
		[if]
			[variable]
			name=sightedyet
			equals=1
			[/variable]
			[then]
			[/then]
			[else]
				{BLAH}
				[set_variable]
				name=sightedyet
				value=1
				[/set_variable]
			[/else]
		[/if]
	[/event]

	[event]
	name=sighted
		[filter_second]
		side=3,4
		[/filter_second]
		[filter]
		side=1
		[/filter]
		[if]
			[variable]
			name=sightedyet
			equals=1
			[/variable]
			[/or]
			[then]
			[/then]
			[else]
				{BLAH}
				[set_variable]
				name=sightedyet
				value=1
				[/set_variable]
			[/else]
		[/if]
	[/event]
For I am Turin Turambar - Master of Doom, by doom mastered. On permanent Wesbreak. Will not respond to private messages. Sorry!
And I hate stupid people.
The World of Orbivm
User avatar
turin
Lord of the East
Posts: 11662
Joined: January 11th, 2004, 7:17 pm
Location: Texas
Contact:

Post by turin »

Well, I've decided that having it trigger when 3,4 see 1 is not really necessary... however, this code still doesnt' work. :evil:

Code: Select all

	#seeing the trapped orcs
	[event]
	name=sighted
		[filter_second]
		side=3
		[/filter_second]
		[filter]
		side=1
		[/filter]
		[if]
			[variable]
			name=overlayturn
			equals=0
			[/variable]
			[then]
			{STUFF}
			[/then]
		[/if]
	[/event]
(overlayturn was set to 0 earlier in the scenario).
For I am Turin Turambar - Master of Doom, by doom mastered. On permanent Wesbreak. Will not respond to private messages. Sorry!
And I hate stupid people.
The World of Orbivm
scott
Posts: 5243
Joined: May 12th, 2004, 12:35 am
Location: San Pedro, CA

Post by scott »

try numerical_equals in place of equals
Hope springs eternal.
Wesnoth acronym guide.
User avatar
turin
Lord of the East
Posts: 11662
Joined: January 11th, 2004, 7:17 pm
Location: Texas
Contact:

Post by turin »

Well, I've simplified it a bit. I'm pretty sure that's not the problem... all I need now is for this event to actually trigger once you see a unitn from sides 3 or 4:

Code: Select all

[event]
name=sighted
[filter_second]
side=3,4
[/filter_second]
[filter]
side=1
[/filter]
{DEBUG_MSG blah}
[/event]
It doesn't. And when you take out the [filter_second], it triggers immediately upon starting the scenario, even before the start event.[/code]
For I am Turin Turambar - Master of Doom, by doom mastered. On permanent Wesbreak. Will not respond to private messages. Sorry!
And I hate stupid people.
The World of Orbivm
bruno
Inactive Developer
Posts: 293
Joined: June 26th, 2005, 8:39 pm
Contact:

Post by bruno »

turin wrote: It doesn't. And when you take out the [filter_second], it triggers immediately upon starting the scenario, even before the start event.
Maybe it is triggering on units spotting themselves or other units on the same side. I would expect that to happen very early on.
User avatar
turin
Lord of the East
Posts: 11662
Joined: January 11th, 2004, 7:17 pm
Location: Texas
Contact:

Post by turin »

bruno wrote:
turin wrote: It doesn't. And when you take out the [filter_second], it triggers immediately upon starting the scenario, even before the start event.
Maybe it is triggering on units spotting themselves or other units on the same side. I would expect that to happen very early on.
:?

That would be odd. But, you're probably right

Well, any suggestions on how to fix it? I'm stuck.
For I am Turin Turambar - Master of Doom, by doom mastered. On permanent Wesbreak. Will not respond to private messages. Sorry!
And I hate stupid people.
The World of Orbivm
User avatar
turin
Lord of the East
Posts: 11662
Joined: January 11th, 2004, 7:17 pm
Location: Texas
Contact:

Post by turin »

I think I (kind of) figured it out. Sighted events with [filter] side=1 [/filter] never work. At least, I can't get them to. Can anyone else?

With most sighted events this can be bypassed, but not really with the one I have here, so I'd like to get htis fixed... if no one can show me how to do it, I'll submit a bug report...
For I am Turin Turambar - Master of Doom, by doom mastered. On permanent Wesbreak. Will not respond to private messages. Sorry!
And I hate stupid people.
The World of Orbivm
Post Reply