Some weird error

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
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Some weird error

Post by toms »

When the scenario starts, both leaders disappear. (visibly)
When I end the turn then, I lose.

The problematic code:

Code: Select all

[event]
name=new turn
first_time_only=no
	[store_unit]
	variable=mudcrawlers
		[filter]
		type=Mudcrawler
		[/filter]
	kill=no
	[/store_unit]
	
	{FOREACH mudcrawlers i}
		#If the mudcrawler i is not marked as a fusion part, check for an adjacent mudcrawler
		[if]
		[variable]
		name=mudcrawlers[$i].role
		not_equals="fusion"
		[/variable]
			[then]
			{VARIABLE_OP tmp_x format $mudcrawlers[$i].x}
			{VARIABLE_OP tmp_y format $mudcrawlers[$i].y}
			[store_locations]
			variable=surround
			x,y=$tmp_x,$tmp_y
			radius=1
			[/store_locations]
				{FOREACH surround k}
					#debu note seem to work till here
					{VARIABLE_OP tmp_x2 format $mudcrawlers[$i].x}
					{VARIABLE_OP tmp_y2 format $mudcrawlers[$i].y}
					[if]
					[have_unit]
						[filter]
						type=Mudcrawler
						x,y=$tmp_x2,$tmp_y2
						[/filter]
					[/have_unit]
						[then]
						#mark adjacent as fusion part
						[store_unit]
						variable=adjacent
							[filter]
							x,y=$tmp_x2,$tmp_y2
							[/filter]
						kill=no
						[/store_unit]
							[if]
							[and]
								[variable]
								name=adjacent.role
								not_equals=fusion
								[/variable]
								[variable]
								name=adjacent.role
								not_equals=found
								[/variable]
							[/and]
								[then] #found an adjacent non-fusion
								[set_variable]
								name=adjacent[$k].role
								value=fusion
								[/set_variable]
								[set_variable]
								name=mudcrawlers[$i].role
								value=found
								[/set_variable]
								[/then]
							[/if]
						[/then]
					[/if]
				{NEXT k}
			[/then]
		[/if]
	{NEXT i}
	#kill those who fusionate with others (role=fusion)
	[kill]
	fire_event=no
		[filter]
		role=fusion
		[/filter]
	[/kill]
	#make found-s to Giant Mudcrawler
	{MODIFY_UNIT (role=found) type (Giant Mudcrawler)}
[/event]
And another question, is it even possible to abuse the role for a unit specific flag?
(I think it is, but I better ask)
Last edited by toms on June 27th, 2007, 2:54 pm, edited 1 time in total.
First read, then think. Read again, think again. And then post!
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Some weird error

Post by zookeeper »

Maybe you could show where the problem is more exactly, instead of the whole scenario?

EDIT: Nevermind, this one caught my eye and is probably the cause of it:

Code: Select all

[kill]
   fire_event=no
      [filter]
      role=fusion
      [/filter]
[/kill] 
toms wrote:And another question, is it even possible to abuse the role for a unit specific flag?
(I think it is, but I better ask)
Sure.
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Post by toms »

Ok, with removing code I found out that the new turn event with the complex code is causing the error.
(as I suspected)

I'll reduce the code in the previous post to the specific event.
First read, then think. Read again, think again. And then post!
User avatar
Noyga
Inactive Developer
Posts: 1790
Joined: September 26th, 2005, 5:56 pm
Location: France

Post by Noyga »

I see some #ifdef without a #endif
"Ooh, man, my mage had a 30% chance to miss, but he still managed to hit! Awesome!" ;) -- xtifr
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Post by toms »

Noyga wrote:I see some #ifdef without a #endif
That can't be...
these are the only #ifdef-s in the scenario (checked via search)

Code: Select all

#ifdef EASY
{VARIABLE spawn 5}#endif
#ifdef NORMAL
{VARIABLE spawn 7}#endif
#ifdef HARD
{VARIABLE spawn 9}#endif
First read, then think. Read again, think again. And then post!
Rhuvaen
Inactive Developer
Posts: 1272
Joined: August 27th, 2004, 8:05 am
Location: Berlin, Germany

Re: Some weird error

Post by Rhuvaen »

You're checking the original coordinates twice (always storing the original mudcrawler), then marking some none-existing array element for "fusion". :wink:

Look at this part:

Code: Select all

...
	{FOREACH mudcrawlers i}
		#If the mudcrawler i is not marked as a fusion part, check for an adjacent mudcrawler
		[if]
		[variable]
		name=mudcrawlers[$i].role
		not_equals="fusion"
		[/variable]
			[then]
			{VARIABLE_OP tmp_x format $mudcrawlers[$i].x}

			{VARIABLE_OP tmp_y format $mudcrawlers[$i].y}
			[store_locations]
			variable=surround
			x,y=$tmp_x,$tmp_y
			radius=1
			[/store_locations]
				{FOREACH surround k}
					###  DUPLICATE COORDINATES FOLLOW!! ###
					{VARIABLE_OP tmp_x2 format $mudcrawlers[$i].x}
					{VARIABLE_OP tmp_y2 format $mudcrawlers[$i].y}
                                        ### DUPLICATE COORDINATES ABOVE!! ###
					[if]
					[have_unit]
						[filter]
						type=Mudcrawler
						x,y=$tmp_x2,$tmp_y2
                                                ### FILTERING ON _ORIGINAL_ UNIT'S COORDINATES ###
						[/filter]
					[/have_unit]
						[then]
						### STORING ORIGINAL UNIT AGAIN ###
						[store_unit]
						variable=adjacent
							[filter]
							x,y=$tmp_x2,$tmp_y2
							[/filter]
						kill=no
						[/store_unit]
							[if]
							[and]
								[variable]
								name=adjacent.role
								not_equals=fusion
								[/variable]
								[variable]
								name=adjacent.role
								not_equals=found
								[/variable]
							[/and]
								[then]
								[set_variable]
                                                                ### WHAT'S THE MEANING OF ADJACENT[$K] ??? ###
								name=adjacent[$k].role
								value=fusion
								[/set_variable]
								[set_variable]
								name=mudcrawlers[$i].role
								value=found
								[/set_variable]
								[/then]
							[/if]
...
I think you want to set temp_x2 / temp_y2 like thus:

Code: Select all

{VARIABLE_OP tmp_x2 format $surround[$k].x}
{VARIABLE_OP tmp_y2 format $surround[$k].y}
I also think you just want to adjust adjacent.role instead of adjacent[$k].role.

What do you think :?:
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Post by toms »

Hmm...you seem to be right about the WML mistakes. I'll check out those tomorrow. :wink:

But why does this make the leaders disappear? :o
First read, then think. Read again, think again. And then post!
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

toms wrote:But why does this make the leaders disappear? :o
Didn't I point that out already?
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Post by toms »

zookeeper wrote:
toms wrote:But why does this make the leaders disappear? :o
Didn't I point that out already?
Whoops, yes. What is wrong, I don't see it.
First read, then think. Read again, think again. And then post!
User avatar
TL
Posts: 511
Joined: March 3rd, 2007, 3:02 am

Post by TL »

[kill] is a standard unit filter, the [filter] tag inside it is meaningless. Keys to filter on have to be directly inside [kill]. Since there are no keys to restrict the kill tag, it kills everything.
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Post by toms »

TL wrote:[kill] is a standard unit filter, the [filter] tag inside it is meaningless. Keys to filter on have to be directly inside [kill]. Since there are no keys to restrict the kill tag, it kills everything.
I found that already, and the same is true for [have_unit]...
First read, then think. Read again, think again. And then post!
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Post by toms »

I need help again. This just does nothing... :(

Code: Select all

[event]
name=new turn
first_time_only=no
### Fusion Mudcrawlers standing next to each other ###
	[store_unit]
	variable=mudcrawlers
		[filter]
		type=Mudcrawler
		[/filter]
	kill=no
	[/store_unit]
	
	{FOREACH mudcrawlers i}
		#If the mudcrawler i is not marked as a fusion part, check for an adjacent mudcrawler
		[if]
		[and]
		[variable]
		name=mudcrawlers[$i].role
		not_equals="fusion"
		[/variable]
		[/and]
		[and]
		[variable]
		name=mudcrawlers[$i].role
		not_equals="found"
		[/variable]
		[/and]
			[then]
			{VARIABLE_OP tmp_x format $mudcrawlers[$i].x}
			{VARIABLE_OP tmp_y format $mudcrawlers[$i].y}
			[store_locations]
			variable=surround
			x,y=$tmp_x,$tmp_y
			radius=1
			[/store_locations]
				#check surrounding hexes for other crawlers
				{FOREACH surround k}
					{VARIABLE_OP tmp_x2 format $surround[$k].x}
					{VARIABLE_OP tmp_y2 format $surround[$k].y}
					[if]
					[have_unit]
					type=Mudcrawler
					x,y=$tmp_x2,$tmp_y2
					[/have_unit]
						[then]
						{DEBUG_MSG (_"Found")}
						#mark adjacent as fusion part
						[store_unit]
						variable=adjacent
							[filter]
							type=Mudcrawler
							x,y=$tmp_x2,$tmp_y2
							[/filter]
						kill=no
						[/store_unit]
							[if]
							[and]
								[variable]
								name=adjacent.role
								not_equals=fusion
								[/variable]
							[and]
							[/and]
								[variable]
								name=adjacent.role
								not_equals=found
								[/variable]
							[/and]
								[then] 
								[set_variable]
								name=adjacent.role
								value=fusion
								[/set_variable]
								[unstore_unit]
								variable=adjacent
								[/unstore_unit]
								[set_variable]
								name=mudcrawlers[$i].role
								value=found
								[/set_variable]
								[/then]
							[/if]
						[/then]
					[/if]
				{NEXT k}
				{CLEAR_VARIABLE surround}
			[/then]
		[/if]
	{NEXT i}
	[unstore_unit]
	variable=mudcrawlers
	[/unstore_unit]
	{CLEAR_VARIABLE mudcrawlers}
#kill those who fusionate with others (role=fusion)
	[kill]
	role=fusion
	fire_event=no
	[/kill]
#convert found-s to Giant Mudcrawler
	{MODIFY_UNIT (role=found) type (Giant Mudcrawler)}
## code to spawn new mudcrawlers is left out because it works ##
[/event]
It seems like the [if] with the [have_unit] does not work right, but I'm not sure...
First read, then think. Read again, think again. And then post!
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

toms wrote:It seems like the [if] with the [have_unit] does not work right, but I'm not sure...
[have_unit] itself contains the SUF, not a [filter] which contains the SUF like you've done it here.
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Post by toms »

zookeeper wrote:
toms wrote:It seems like the [if] with the [have_unit] does not work right, but I'm not sure...
[have_unit] itself contains the SUF, not a [filter] which contains the SUF like you've done it here.
I'm sorry for being that dumb, but I do not get what you mean...
(I know that SUF=Standard Unit Filter)
First read, then think. Read again, think again. And then post!
Post Reply