Working out with "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
Kadel_007
Posts: 16
Joined: November 21st, 2021, 9:14 pm

Working out with "sighted: event

Post by Kadel_007 »

Welcome again (or not).
I am still a newcomer to WML and I am working out with tag [event] and trying to make such a situation:

When my unit first time sees any other side unit, I make two branches. The first branch must show the unique response of the unit with side = 2, the second- another response of the unit with side = 3.

So, the question is, how should I check variable side in if statement, or is there any simpler method to do this with only filters?

[Below] My code:

Code: Select all

[event]
		name=sighted
		first_time_only=yes
		
		[filter]
			side=1
		[/filter]
		
		[filter_second]
			side=2,3
		
		[message]
			speaker=unit
			message= _"Oh! I see someone!"
		[/message]
		
		[if] 
			[variable]
				name=side
				equals=2
			[/variable]
		[then]
			[message]
				speaker=second_unit
				message= _"Retain your swords. We don't want to fight!"
			[/message]
			[message]
				speaker=Duncan
				message= _"(Ok no matter what happens). Agreed. So, what's goi..."
			[/message]
		[/then]
		
		[elseif] 
			[variable]
				name=side
				equals=3
			[/variable]
		[then]
			[message]
				speaker=second_unit
				message= _"Ooppss... Those are not elves!"
			[/message]
			[message]
				speaker=Duncan
				message= _"We... Elves? ... What..?"
			[/message]
		[/then]
		[/elseif]
		
		[/if]
		
	[/event]
User avatar
Straff
Posts: 86
Joined: September 27th, 2020, 2:53 pm

Re: Working out with "sighted: event

Post by Straff »

Why not simply split that code into two different events?
Kadel_007
Posts: 16
Joined: November 21st, 2021, 9:14 pm

Re: Working out with "sighted: event

Post by Kadel_007 »

Straff wrote: November 23rd, 2021, 9:54 pm Why not simply split that code into two different events?
Yea, I have been thinking about it, but just was curious to do it in same event (maybe to avoid repetitions)
User avatar
Straff
Posts: 86
Joined: September 27th, 2020, 2:53 pm

Re: Working out with "sighted: event

Post by Straff »

Why do people always answer with quotes?
Everybody can read one line higher what I have written, why the repetition ?

Edit: I think the easiest solution is to use two events. Keep it simple.

Edit 2: the variable in your example must be variable=second_unit.side
Last edited by Straff on November 23rd, 2021, 10:05 pm, edited 1 time in total.
Kadel_007
Posts: 16
Joined: November 21st, 2021, 9:14 pm

Re: Working out with "sighted: event

Post by Kadel_007 »

Sorry(
User avatar
skeptical_troll
Posts: 500
Joined: August 31st, 2015, 11:06 pm

Re: Working out with "sighted: event

Post by skeptical_troll »

You're almost there. What you need to change is that the variable 'side' is not defined in the 'sighted' event, but you have the 'unit' and 'secon_unit' variables. So you need to use

Code: Select all

	[variable]
		name = second_unit.side
		equals = 2
	[/variable]
instead of what you have, and I believe it should work. You can read the documentation about events to check this kind of things.

Also, I think you are better off posting this kind of questions in the 'WML workshop' section of the forum, which is more code-centered, rather than the scenario/campaign development.
Kadel_007
Posts: 16
Joined: November 21st, 2021, 9:14 pm

Re: Working out with "sighted: event

Post by Kadel_007 »

Also, I didn't mention, after one of these two events has been triggered, the other should not fire never.
It means, I need to use [remove] in both of them, to avoid executing of remaining event?
Kadel_007
Posts: 16
Joined: November 21st, 2021, 9:14 pm

Re: Working out with "sighted: event

Post by Kadel_007 »

skeptical_troll, thank you too.
Now I know what to do))
User avatar
skeptical_troll
Posts: 500
Joined: August 31st, 2015, 11:06 pm

Re: Working out with "sighted: event

Post by skeptical_troll »

Also note that with first time only = yes, the event will only trigger for the first one of the two sides. If you want it to trigger for both, you need two events as Straff suggests, or set it to 'no', but it would trigger multiple times for the same side.

Finally, note that according to the documentation, the sighting unit is the secondary one, and the unit who is sighted is the primary (the 'unit' variable).
Kadel_007
Posts: 16
Joined: November 21st, 2021, 9:14 pm

Re: Working out with "sighted: event

Post by Kadel_007 »

skeptical_troll wrote: November 23rd, 2021, 10:10 pm Also note that with first time only = yes, the event will only trigger for the first one of the two sides. If you want it to trigger for both, you need two events as Straff suggests, or set it to 'no', but it would trigger multiple times for the same side.

Finally, note that according to the documentation, the sighting unit is the secondary one, and the unit who is sighted is the primary (the 'unit' variable).
Yeah, I know about first time only. That's why I wished to do event in one [event], because if i use two events, it will be harder to define whether one of them is executed.
Kadel_007
Posts: 16
Joined: November 21st, 2021, 9:14 pm

Re: Working out with "sighted: event

Post by Kadel_007 »

And i also wanted to avoid creating additional flags...
Kadel_007
Posts: 16
Joined: November 21st, 2021, 9:14 pm

Re: Working out with "sighted: event

Post by Kadel_007 »

In any case, thanks anyone for help. I will not forget all helpers and even will mention them in credits (when the time comes)...
Post Reply