Problems with DroppableItem macro

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.
User avatar
Tomsik
Posts: 1401
Joined: February 7th, 2005, 7:04 am
Location: Poland

Problems with DroppableItem macro

Post by Tomsik »

i want to use DroppableItem macro from wiki, but i get errors... :?

Code: Select all

########################## MACRO DEFINE PART #############################

#define DROPPABLE_ITEM X Y XVAR YVAR NAME IMAGE
[event]
name=prestart
	
	{VARIABLE {XVAR} {X}}
	{VARIABLE {YVAR} {Y}}

	[item]
	x=${XVAR}
	y=${YVAR}
	image={IMAGE}
	[/item]

	[event]
	name=moveto
	first_time_only=no
		[filter]
		x=${XVAR}
		y=${YVAR}
		[/filter]
		
		[event]
		name=die
		first_time_only=no
		[store_unit]
		[filter]
		x=$x1
		y=$y1
		[/filter]
		variable=itemstore
		[/store_unit]
		[if]
		[variable]
		name=itemstore.variables.{XVAR}
		equals=on
		[/variable]
			[then]
			{VARIABLE_OP {XVAR} to_variable x1}
			{VARIABLE_OP {YVAR} to_variable y1}
			[item]
			x=$x1
			y=$y1
			image={IMAGE}
			[/item]
			[/then]
		[/if]
		[/event]
		
		[removeitem]
		x=${XVAR}
		y=${YVAR}
		[/removeitem]
		[store_unit]
		variable=itemstore
		[filter]
		x=${XVAR}
		y=${YVAR}
		[/filter]
		[/store_unit]
 		{VARIABLE itemstore.variables.{XVAR} on}
		[unstore_unit]
		variable=itemstore
		[/unstore_unit]
		
		{VARIABLE {XVAR} 0}
		{VARIABLE {YVAR} 0}
		
		[object]
		name={NAME}
		image={IMAGE}
		duration=forever
			[filter]
			x=${XVAR}
			y=${YVAR}
			[/filter]
#enddef
		
#All this should be between the DROPPABLE_ITEM macro and /DROPPABLE_ITEM
		description="-the description-"
		cannot_use_message="-cannot use message-"
			[effect]
			apply_to=new_atack
			 [atack]
			 name="Wand"
			 type=cold
			 special=plague(Walking Corpse)
			 icon=dark-missile.png
			 range=long
			 damage=10
			 number=2
			[/atack]
			[/effect]

#define /DROPPABLE_ITEM
		[/object]
	[/event]
[/event]
#enddef

######################## MACRO DEFINE PART END ###########################

{DROPPABLE_ITEM 20 20 XBLAH YBLAH ("Wand") (attacks/darkstaff.png)}
User avatar
Tomsik
Posts: 1401
Joined: February 7th, 2005, 7:04 am
Location: Poland

Post by Tomsik »

Help me, please!
claus
Posts: 186
Joined: April 4th, 2005, 5:51 am

Post by claus »

I think attack is spelled with two 't' not one. ( new_attack, [attack] and [/attack] )

You forgot the effect of the object (makes no sense to put it between the definition of the macros) and {/DROPPABLE_ITEM}:

{DROPPABLE_ITEM 20 20 XBLAH YBLAH ("Wand") (attacks/darkstaff.png)}

description="-the description-"
cannot_use_message="-cannot use message-"
[effect]
apply_to=new_attack
[attack]
name="Wand"
type=cold
special=plague(Walking Corpse)
icon=dark-missile.png
range=long
damage=10
number=2
[/attack]
[/effect]

{/DROPPABLE_ITEM}
User avatar
Tomsik
Posts: 1401
Joined: February 7th, 2005, 7:04 am
Location: Poland

Post by Tomsik »

now it works, but when unit try to take it i get cannot use message :?
claus
Posts: 186
Joined: April 4th, 2005, 5:51 am

Post by claus »

Looks like something with the [filter] inside of [object] does not work.
I guess it is the following code in front of [object] (inside the definition of DROPPABLE_ITEM):
{VARIABLE {XVAR} 0}
{VARIABLE {YVAR} 0}

Know the filter inside the object should check wether a unit stands on (0,0) or not, can not find one and the can not use message of the object is displayed. You can try what happens when you move
{VARIABLE {XVAR} 0}
{VARIABLE {YVAR} 0}
into the definition of /DROPPABLE_ITEM (behind [/object])
User avatar
Tomsik
Posts: 1401
Joined: February 7th, 2005, 7:04 am
Location: Poland

Post by Tomsik »

i tried it, when i run i get error "unexpected chars after name of variable, expected '=' or ',' " but it runs, when i take item it shows description(good), but in place where should be "10-2 Wand(cold) plague" i have... translation info! when i try to atack it is 1-0 atack :?
User avatar
Elvish_Pillager
Posts: 8137
Joined: May 28th, 2004, 10:21 am
Location: Everywhere you think, nowhere you can possibly imagine.
Contact:

Post by Elvish_Pillager »

Urgh. I discovered some problems in this a while ago, but forgot to update the wiki. It is now updated.

There is also now an ADDITIONAL_FILTERS parameter, which should be set to "" in general.
It's all fun and games until someone loses a lawsuit. Oh, and by the way, sending me private messages won't work. :/ If you must contact me, there's an e-mail address listed on the website in my profile.
User avatar
Tomsik
Posts: 1401
Joined: February 7th, 2005, 7:04 am
Location: Poland

Post by Tomsik »

now i get "missing closing tag for 'unit_overlay' ", but that tag is here and i dont see any missing tags, what the heck... :?
User avatar
Tomsik
Posts: 1401
Joined: February 7th, 2005, 7:04 am
Location: Poland

Post by Tomsik »

nobody can help?

P.S.: EP: that macro works for you?
claus
Posts: 186
Joined: April 4th, 2005, 5:51 am

Post by claus »

Try to remove the entire [unit_overlay] part (or comment it out). (it is not really necessary for the code (it only adds the image used for the object as overlay to the unit and i think it is close to impossible to create a item image which fits for all units) )
User avatar
Tomsik
Posts: 1401
Joined: February 7th, 2005, 7:04 am
Location: Poland

Post by Tomsik »

still dont works, error is now 'missing closing tag for [event]', when i try to make one big macro(droppableitem+effect part+ /droppableitem) i get errors from other files. :?
claus
Posts: 186
Joined: April 4th, 2005, 5:51 am

Post by claus »

I guess that it is a missing " or } or something similar.
User avatar
Tomsik
Posts: 1401
Joined: February 7th, 2005, 7:04 am
Location: Poland

Post by Tomsik »

i dont see any unclosed " } ) or '
code:

Code: Select all

[multiplayer]
	id= WfW
	name= _ "War For Wand"
	map_data="cccccZcccccckkgggggggFFFVFSVSF
cZcccccccZcckkggcggggFFFFnSSFF
cccQQQcccccckkgggcggFFVFn4nVFF
cccQ5QccccckkkgcggggFFFgnnnFFF
ccccQccccckkkgggggggggFggggFFF
cccckccZckcckkggggggggggggFFFg
kkcckcccckkkcckkgggHHHgggggggg
kkkkkcckkkkgkkckgggHHHVggggggg
gfkkkkkkkggggkckggggHggggggggg
ffggkkkggggggkckgggggggggggggf
ffffgfgccfgggkcckkggggggffggff
ggtCfgcffffgggkkckgggggfffgwfw
ggC3CgtfffffgggkckggggggfwwwwY
tgCCCggfffgggkkcckgggfgggwYwww
ffggggfffggkkcckkgggffgwwwwqww
ffftgffffggkckkgggggffgwwwq2qw
gffffffggggkckggggggffgwwwqqqw
ggfgfgfggggkckggggggggggwwwwww
gggtgggggggkcckggggggggggwwYww
gfffggggggggkckgggggggfffgwwwY
gffffhhmggggkckgggggggffffggww
ggfgfghhmhggkckggkkkggggfggggg
ggggggaghgggkckkkccckkgggggffg
gmmmmmggggggkkccckkkcckggggggg
mmmWmmmgggggggkkkggkkckggggggg
mWWuWumggggkkkgggkkcckkggggggg
WDuouuumggkccckkkcckkggggIIIgg
uuo1ouWmmgkckkccckkggggIIIPIgg
DuoooDWmmgkckgkkkggggggIUIIgIg
uDuuuWWmmgkckgggggggggggIggggg"
	description= _ ""
	turns=50

	{DAWN}
	{MORNING}
	{AFTERNOON}
	{DUSK}
	{FIRST_WATCH}
	{SECOND_WATCH}

	[side]
	side=1
	enemy=2
	canrecruit=1
	controller=human
	[/side]
	[side]
	side=2
	enemy=1
	canrecruit=1
	controller=human
	[/side]

########################## MACRO DEFINE PART #############################

#define DROPPABLE_ITEM X Y XVAR YVAR NAME IMAGE ADDITIONAL_FILTERS
[label]
x={X}
y={Y}
text="{NAME}"
[/label]
[event]
name=prestart
	
	{VARIABLE {XVAR} {X}}
	{VARIABLE {YVAR} {Y}}

	[item]
	x=${XVAR}
	y=${YVAR}
	image={IMAGE}
	[/item]
		
	[event]
	name=die
	first_time_only=no
	[store_unit]
	[filter]
	x=$x1
	y=$y1
	[/filter]
	variable=itemstore
	[/store_unit]
	[if]
	[variable]
	name=itemstore.variables.{XVAR}
	equals=on
	[/variable]
		[then]
		{VARIABLE_OP {XVAR} to_variable x1}
		{VARIABLE_OP {YVAR} to_variable y1}
		[item]
		x=$x1
		y=$y1
		image={IMAGE}
		[/item]
		[/then]
	[/if]
	[/event]

	[event]
	name=moveto
	first_time_only=no
		[filter]
		x=${XVAR}
		y=${YVAR}
		{ADDITIONAL_FILTERS}
		[/filter]
		
		[removeitem]
		x=${XVAR}
		y=${YVAR}
		[/removeitem]
		[store_unit]
		variable=itemstore
		[filter]
		x=${XVAR}
		y=${YVAR}
		[/filter]
		[/store_unit]
		{VARIABLE itemstore.variables.{XVAR} on}
		[unstore_unit]
		variable=itemstore
		[/unstore_unit]
		
		[unit_overlay]
		x=${XVAR}
		y=${YVAR}
		image={IMAGE}
		[/unit_overlay]
		
		[object]
		name={NAME}
		image={IMAGE}
		duration=forever
		cannot_use_message="-cannot use message-"
			[filter]
			x=${XVAR}
			y=${YVAR}
			[/filter]
#enddef

#define /DROPPABLE_ITEM XVAR YVAR
		[/object]
		
		{VARIABLE {XVAR} 0}
		{VARIABLE {YVAR} 0}
	[/event]
[/event]
#enddef

######################## MACRO DEFINE PART END ###########################

{DROPPABLE_ITEM 30 30 XBLAH YBLAH ("Wand") (attacks/darkstaff.png) ("")} 
description="blah blah"
cannot_use_message="-cannot use message-"
[effect]
apply_to=new_attack
[attack]
name="Wand"
type=cold
special=plague(Walking Corpse)
icon=dark-missile.png
range=long
damage=10
number=2
[/attack]
[/effect] 

{/DROPPABLE_ITEM}


[/multiplayer]
claus
Posts: 186
Joined: April 4th, 2005, 5:51 am

Post by claus »

You should use {/DROPPABLE_ITEM XBLAH YBLAH} instead of {/DROPPABLE_ITEM} ( the new definition requires two arguments, because
{VARIABLE {XVAR} 0}
{VARIABLE {YVAR} 0}
is know inside of the /DROPPABLE_ITEM Macro )
Are you sure that the enemy=2 and enemy=1 inside your side tags has any effect?
User avatar
Tomsik
Posts: 1401
Joined: February 7th, 2005, 7:04 am
Location: Poland

Post by Tomsik »

now i get error 'unexpected chars on begin of line 157' its line where is {DROPPABLE_ITEM 30 30 XBLAH YBLAH ("Wand") (attacks/darkstaff.png) ("")} , what the... :?

P.S.: i think [side] tags dont affect multiplayer, its 5 player map and i have here [side] tags only for two.. but scenaro runs with 5(when i comment out dont working lines)
Post Reply