Next question: how to trigger a "sighted" event.
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.
- malthaussen
- Posts: 37
- Joined: April 6th, 2024, 11:05 pm
Next question: how to trigger a "sighted" event.
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.
Is there some sort of if...then I need to use to trigger it when I want it to fire?
-- Mal
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]
-- Mal
"Of two choices, I always take the third."
-
- Posts: 1280
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: Next question: how to trigger a "sighted" event.
https://wiki.wesnoth.org/EventWML#sighted
JUST GUESSING HERE, but something like:
Sounds like you want to make sure that a unit not on side 1 is seen by a unit on side 1.The primary unit is the unit that became visible, and the secondary unit belongs to the side that now sees the primary unit.
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.
- malthaussen
- Posts: 37
- Joined: April 6th, 2024, 11:05 pm
Re: Next question: how to trigger a "sighted" event.
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
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."
- lhybrideur
- Posts: 376
- Joined: July 9th, 2019, 1:46 pm
Re: Next question: how to trigger a "sighted" event.
Just swap side=1 and side=2 then.
- beetlenaut
- Developer
- Posts: 2828
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: Next question: how to trigger a "sighted" event.
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
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
-
- Posts: 1280
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: Next question: how to trigger a "sighted" event.
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?
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.