[SOLVED] Multi-condition event: units alive x and after turn x

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
Xindage
Posts: 21
Joined: August 2nd, 2018, 12:56 am
Location: Brazil

[SOLVED] Multi-condition event: units alive x and after turn x

Post by Xindage »

my question is pretty simple probably but i found no solutions in wesnoth wiki so i'll ask here.
i want have a event that check 2 conditions at same time to give to side 2 gold if both is true at any turn after 11 in game, because i want a side that keep pressuring the player after the first wave is about to be defeated:

If side 2 amount of units alife is aquals/less than 6 only if turn is aquals/more than 12 give side 2, 100 gold amount (first_time_only=yes).

Note: it'll count the leader as unit too? just to know.
Last edited by Xindage on September 23rd, 2018, 5:51 pm, edited 1 time in total.
Tad_Carlucci
Inactive Developer
Posts: 503
Joined: April 24th, 2016, 4:18 pm

Re: Multi-condition event: units alive x and after turn x

Post by Tad_Carlucci »

The wiki is the wrong place to look. If you check, you'll probably find examples similar to what you need someplace the mainline scenario. What I see you asking for is how to encourage the player to win in 10 turns or less because, at 11 turns a new wave will arrive. And, yes, I'm pretty sure I've seen that. Just not sure where ATM. Basically, you want an event on turn 12 which checks the number of units on the map and, if fewer than 7, gives a gold boost to allow a couple more units to be recruited.
I forked real life and now I'm getting merge conflicts.
User avatar
Ravana
Forum Moderator
Posts: 2934
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Multi-condition event: units alive x and after turn x

Post by Ravana »

That can be best done with [event] first_time_only=yes [filter_condtion]. Turn number is found in autostored variable and for unit count you can use [have_unit].
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: Multi-condition event: units alive x and after turn x

Post by Sapient »

Code: Select all

[event]
  name=new turn
  first_time_only=yes
  [filter_condition]
    [variable]
      name=turn_number
      greater_than=11
    [/variable]
    [have_unit]
      side=2
      count=0-6
      # leader is also counted here
    [/have_unit]    
  [/filter_condition]
  [gold]
    amount=100
    side=2
  [/gold]
[/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."
Shiki
Developer
Posts: 344
Joined: July 13th, 2015, 9:53 pm
Location: Germany

Re: Multi-condition event: units alive x and after turn x

Post by Shiki »

If you don't want to include the leader for counting you can add canrecruit=no to the filter above.
Try out the dark board theme.
Xindage
Posts: 21
Joined: August 2nd, 2018, 12:56 am
Location: Brazil

Re: Multi-condition event: units alive x and after turn x

Post by Xindage »

i have used a variable to make action to not repeat but something is not working, this tigger is working aways at the start of turn 1, what's happening?
Note: he's starting gold is 130 but he has 195 at starting of game... (130 + 65 from normal skill)

Code: Select all

	# Make Ragan keep recruiting after the first wave is about to be defeat.
	[event]
		name = new turn
		first_time_only = no
		[if]
			[variable]
				name = reinforcements
				equals = no
			[/variable]
			[then]
				{VARIABLE reinforcements yes}
				[filter_condition]
					[variable]
						name = turn_number
						greater_than = 11
					[/variable]
					[have_unit]
						side = 2
						count = 0-7
						# leader is also counted here
					[/have_unit]    
				[/filter_condition]
				[gold]
					#ifdef EASY
					amount = 40
					#endif
					#ifdef NORMAL
					amount = 65
					#endif
					#ifdef HARD
					amount = 80
					#endif
					side = 2
				[/gold]
			[/then]
		[/if]
	[/event]
Edit: I noticed the "{VARIABLE reinforcements yes}" is in wrong place too.
User avatar
josteph
Inactive Developer
Posts: 741
Joined: August 19th, 2017, 6:58 pm

Re: Multi-condition event: units alive x and after turn x

Post by josteph »

[filter_condition] shouldn't be a child of [then] but of [event], as Sapient showed. That's also why he didn't need an auxiliary variable. Didn't his example work for you?

Also you can use {QUANTITY amount 40 65 80} instead of ifdefs.
Xindage
Posts: 21
Joined: August 2nd, 2018, 12:56 am
Location: Brazil

Re: Multi-condition event: units alive x and after turn x

Post by Xindage »

thanks josteph, and yes this time the event worked perfectly, thanks everyone for the support.
Post Reply