Event not working properly

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

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
tribes55
Posts: 119
Joined: June 10th, 2012, 4:29 am

Event not working properly

Post by tribes55 » August 1st, 2018, 1:43 pm

Hi,

I have two events, one which sets a variable, and one that looks for said variable in the next scenario.
For some reason, despite the [then] tag being met, the second event always resorts to the [else] tag.

What's supposed to happen: If the player chooses to retreat immediately, it sets troublechoice (variable) value to 1. Then, in the next scenario, for event start, the [then] tag is supposed to be triggered.
This happens correctly, as when I inspect in the next scenario, troublechoice=1. However, despite this being the condition of the then tag and it is met, the [else] tag fires.


Here are the two events, in order:

The event which sets the variable, given you select the appropriate choice (which was done in testing.)

Code: Select all

[event]
	name=turn 11
	{FAKE_UNIT_MOVE 38 30 32 29 4 (Dwarvish Pathfinder) ()}
	{NAMED_UNIT 4 (Dwarvish Pathfinder) 30 29 Peltit "Peltit" ()}
	[gold]
	amount=60
	side=2
	[/gold]
	[message]
		speaker=Peltit
		message= _ "Gandfal, Landfal! The Great Hall is under siege by Orcs! They've broken through the Eastern Gate! We're holding them back now."
	[/message]
	[message]
		speaker=Angrithang
		message= _ "Gandfal, I know what yer thinkin', but if we leave now, we'll have to fight on two fronts. We need to deal with this problem first."
	[/message]
	{MOVE_UNIT id=Peltit 38 32}
	[kill]
	id=Peltit
	[/kill]
	[message]
		speaker=Gandfal
		message= _ "Hmm.."
		[option]
			label = _ "Stay and defeat the Orcs"
			
			[command]
				[set_variable]
					name=troublechoice
					value=0
				[/set_variable]	
				[message]
					speaker=Gandfal
					message= _ "Nar, we cannot afford to risk fighting on two fronts. We must defeat these Orcs before we return to the aid of the Great Hall."
				[/message]
				[message]
					speaker=Landfal
					message= _ "I hope yer right, Gandfal, or we'll all be payin' the price."
				[/message]
			[/command]
		[/option]
			
			
		[option]
			label = _ "Retreat to aid in the defense of the Great Hall"
			
			[command]
				[set_variable]
					name=troublechoice
					value=1
				[/set_variable]	
				[message]
					speaker=Gandfal
					message= _ "Aye, I hear you Angrithang. I witnessed first hand the strength of the Orcs at Holl-- I am not sure how long they can withstand an assault."
				[/message]
				[message]
					speaker=Angrithang
					message= _ "Hmm.. I trust your intuition, Gandfal. Upon our exit, we should close the gates. They should hold off the Orcs long enough for us to return the Hall, that is, if the humans cannot repel them."
				[/message]
				[message]
					speaker=Cane
					message= _ "You damn midgets are just going to leave us to die? You'll pay for this you stubborn clanclangs!"
				[/message]
				[message]
					speaker=Albeit
					message= _ "JUST SAY THE WORD GANFAL AND I'LL RIP 'EM TO SHREDS!"
				[/message]
				{MOVE_UNIT id=Cane 1 15}
				[kill]
					id=Cane
				[/kill]	
				[message]
					speaker=Landfal
					message= _ "The coward leaves his home and his own people to die."
				[/message]
				[message]
					speaker=Gandfal
					message= _ "I hope we're not guilty of the same. We better get goin'."
				[/message]
				[endlevel]
				result=victory
				carryover_percentage=100
				bonus=no
				next_scenario=05_Return
				[/endlevel]
			[/command]
		[/option]		
		
	[/message]
	
	
[/event]
And the second event, which looks for the variable's value being 1.

Code: Select all

[event]
	name=start
	[if]
	
		[variable]
			variable=troublechoice
			equals=1
		[/variable]
		
		[then]
			{NAMED_UNIT 4	"Dwarvish Stalwart" 25 7 (Joe) "Joe" hitpoints=37} {GUARDIAN}
			{NAMED_UNIT 4	"Dwarvish Guardsman" 26 8 (Jim) "Jim" hitpoints=29} {GUARDIAN}
			[unit]
				id=Nekleng
				name= _ "Nekleng"
				type=Dwarvish Stalwart
				side=4
				random_traits=yes
				max_moves=0
				x,y=23,18
			[/unit]
			
				##The following IF conditions are just for recalling old not-picked units.
					[if]
					[variable]
						name=barolvar
						equals=1
					[/variable]
					[then]
					[unit]
						id=Barol
						name= _ "Barol Blackhand"
						type=Dwarvish Annalist
						x,y=11,13
						random_traits=yes
						profile=data/add-ons/AFriendshipTested/images/portraits/angarthing.png
						side=4
						{IS_LOYAL}
					[/unit]	
					[/then]
					[/if]
					[if]
						[variable]
							name=shokulasvar
							equals=1
						[/variable]
						[then]
						{NAMED_LOYAL_UNIT 4 "Dwarvish Thunderguard" 14 27 Shokulas "Shokulas"}
						[/then]
					[/if]
					[if]
						[variable]
							name=aiglantvar
							equals=1
						[/variable]
						[then]
						{NAMED_LOYAL_UNIT 4 "Dwarvish Steelclad" 11 22 Aiglant "Aiglant"}
						[/then]
					[/if]
					[if]
						[variable]
							name=dindermifvar
							equals=1
						[/variable]
						[then]
						{NAMED_UNIT 5 "Dwarvish Runesmith" 7 25 Dindermif "Dindermif" hitpoints=6}
						[/then]
					[/if]
					[if]
						[variable]
							name=albigathvar
							equals=1
						[/variable]
						[then]
							{NAMED_UNIT 4 "Dwarvish Stalwart" 25 20 Albigath "Albigath" hitpoints=29}
						[/then]
					[/if]
					[if]
						[variable]
							name=harlarvar
							equals=1
						[/variable]
						[then]
							{NAMED_UNIT 4 "Dwarvish Steelclad" 13 9 Harlar "Harlar the Quiet" hitpoints=38}
						[/then]
					[/if]
					
					
			{GENERIC_UNIT 2 "Orcish Warrior" 27 8}
			{NAMED_UNIT 2 "Orcish Warrior" 29 7 Narg "Narg" ()}
			{NAMED_UNIT 2 "Orcish Warrior" 28 5 Naet "Naet" ()}
			[message]
				speaker=Albeit
				message= _ "THOSE ORCS WON'T LEAVE HERE ALIVE!!! AHHHH!!!"
			[/message]
			[message]
				speaker=Shokulas
				message= _ "Uh oh."
			[/message]
			[message]
				speaker=Rake
				message = _ "More rock suckers and so soon? As if it'll make a difference!"
			[/message]
			[message]
			speaker=Boulder
			message = _ "Midget men SUCKED ROCK! ROCK DEAD! BOULDER KILL! NO MORE SUCK ROCK!"
			[/message]
			[message]
				speaker=Landfal
				message = _ "Uh... what?"
			[/message]
			
		[/then]
		
		[else]
		
		
			[gold]
				side=2
				amount=100
			[/gold]
			[gold]
				side=4
				amount=75
			[/gold]
			{GENERIC_UNIT 2 "Orcish Warrior" 23 7}
			{GENERIC_UNIT 2 "Orcish Grunt" 23 7}
			{NAMED_UNIT 2 "Orcish Grunt" 16 11 Narg "Narg" hitpoints=22}
			{NAMED_UNIT 2 "Orcish Grunt" 15 10 Naet "Naet" hitpoints=14}
			{GENERIC_UNIT 2 "Orcish Archer" 24 7}
			{GENERIC_UNIT 2 "Orcish Assassin" 26 7}
			{GENERIC_UNIT 4 "Dwarvish Thunderer" 22 10}
			{NAMED_UNIT 5 "Dwarvish Thunderer" 31 28 Rathiel "Rathiel" hitpoints=22}
			{NAMED_UNIT 5 "Dwarvish Steelclad" 32 22 Tungsten "Tungsten" hitpoints=42}
		
			[message]
				speaker=Dulatus
				message= _ "Gandfal! What in the hell took ye so long?"
			[/message]
			[message]
				speaker=Angrithang
				message= _ "Dulatus, we must save the conversation for later, there are more important matters facing us."
			[/message]
			[message]
				speaker=Rake
				message= _ "More axe-moles come out of their crack! Hah! Too little too late."
			[/message]
			[message]
				speaker=Shokulas
				message= _ "HAH!"
			[/message]
			[message]
				speaker=Boulder
				message = _ "Boulder SMASH little men like bug!"
			[/message]
			
		[/else]
		
	[/if]
	
		[message]
			speaker=Dulatus
			message = _ "I've stationed a garrison south, but I don't know much longer they can hold."
		[/message]	
		{SCROLL_TO 12 27}
		[delay]
			time=1750
			accelerate=no
		[/delay]
		[message]
			speaker=Locket
			message= _ "There aren't many of us left who can fight. But we'll fight until the end to kill those damn Orcs!"
		[/message]
		[message]
			speaker=Squid
			message= _ "They'll pay for destroying our home!"
		[/message]
		[message]
			speaker=Gandfal
			message = _ "Today, our axes will know Orcish blood in plenty."
		[/message]
		
[/event]

User avatar
Ravana
Moderator
Posts: 1832
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Event not working properly

Post by Ravana » August 1st, 2018, 1:48 pm

name not variable.

tribes55
Posts: 119
Joined: June 10th, 2012, 4:29 am

Re: Event not working properly

Post by tribes55 » August 1st, 2018, 1:55 pm

Thanks, Ravana. It works correctly now.

Post Reply