Next question: how to trigger a "sighted" event.

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
malthaussen
Posts: 36
Joined: April 6th, 2024, 11:05 pm

Next question: how to trigger a "sighted" event.

Post by malthaussen »

I'd like to have a short dialogue when Side 1 first spots an enemy unit.

Used the following code, but the event triggers as soon as a unit is recruited, even though there are no enemies in sight.

Code: Select all

[event]
		name=sighted
		first_time_only=yes
		[filter]
			side=1
		[/filter]
			[message]
				speaker=unit
				message= _ "Enemy in sight!"
			[/message]
		
			[message]
				speaker=Farnsworth
				message= _ "Damn, I knew we weren't alone out here."
			[/message]
		
	[/event]
Is there some sort of if...then I need to use to trigger it when I want it to fire?

-- Mal
"Of two choices, I always take the third."
white_haired_uncle
Posts: 1226
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: Next question: how to trigger a "sighted" event.

Post by white_haired_uncle »

https://wiki.wesnoth.org/EventWML#sighted
The primary unit is the unit that became visible, and the secondary unit belongs to the side that now sees the primary unit.
Sounds like you want to make sure that a unit not on side 1 is seen by a unit on side 1.

JUST GUESSING HERE, but something like:

Code: Select all

[filter]
   [not]
        side=1
   [/not]
[/filter]
[filter_second]
    side=1
[/filter_second]
Speak softly, and carry Doombringer.
User avatar
malthaussen
Posts: 36
Joined: April 6th, 2024, 11:05 pm

Re: Next question: how to trigger a "sighted" event.

Post by malthaussen »

I'll try that. Thanks.

On edit: triggers when a side 2 unit spots a side 1 unit. So Side 2 is reporting contact to Side 1's commander. Still, it looks to be in the ballpark.

-- Mal
"Of two choices, I always take the third."
User avatar
lhybrideur
Posts: 369
Joined: July 9th, 2019, 1:46 pm

Re: Next question: how to trigger a "sighted" event.

Post by lhybrideur »

Just swap side=1 and side=2 then.
User avatar
beetlenaut
Developer
Posts: 2827
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Next question: how to trigger a "sighted" event.

Post by beetlenaut »

No, the posted code was correct. Don't swap it. In a "sighted" event, the primary unit (stored in the unit variable) is the unit that just got seen. The secondary unit (stored in the variable second_unit) is the unit who did the seeing. It sounds like you put the wrong speaker in [message].
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
white_haired_uncle
Posts: 1226
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: Next question: how to trigger a "sighted" event.

Post by white_haired_uncle »

Actually, I made the assumption that any side != 1 is an enemy of side 1.

I have a hard time keeping the filter rules straight, I always have to look for an example, but something like this?

Code: Select all

[filter]
   [enemy_of]
        side=1
   [/enemy_of]
[/filter]
[filter_second]
    side=1
[/filter_second]
Speak softly, and carry Doombringer.
Post Reply