How to stone a unit ?

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
User avatar
Noyga
Inactive Developer
Posts: 1790
Joined: September 26th, 2005, 5:56 pm
Location: France

How to stone a unit ?

Post by Noyga »

I'm working on a scenario where ice appear randomly on a river.
When there is an unit on the hex to be iced, it would be stoned, and unstoned when the ice would melt...
My random terrain generation works, i figured how to unstone a unit, but didn't find how to stone a unit.
I tried something like this, but it doesn't work :

Code: Select all

	[if]
		[have_unit]
			x=$xtarget
			y=$ytarget
		[/have_unit]
	[then]
		[store_unit]
			x=$xtarget
			y=$ytarget
			variable=frozen_unit
		[/store_unit]
		[set_variable]
			name=frozen_unit.status.stone
			value=yes
		[/set_variable]
		[unstore_unit]
			variable=frozen_unit
		[/unstore_unit]
	[/then]
	[/if]
($xtarget,$ytarget) is the location of the hex being frozen

Does anybody knows how to do this ?
scott
Posts: 5243
Joined: May 12th, 2004, 12:35 am
Location: San Pedro, CA

Post by scott »

try 'on' instead of 'yes' in the set variable tag
Hope springs eternal.
Wesnoth acronym guide.
User avatar
Noyga
Inactive Developer
Posts: 1790
Joined: September 26th, 2005, 5:56 pm
Location: France

Post by Noyga »

Hum ... I could make it work with 'frozen_unit.status.poisoned', but it wouldn't work with 'frozen_unit.status.stone'
I tried with 'frozen_unit.status.stoned' too, but it doesn't work too :(
It seems that the stoned status variable name is not as described in the Wiki :(
User avatar
Tomsik
Posts: 1401
Joined: February 7th, 2005, 7:04 am
Location: Poland

Post by Tomsik »

Try [stone] tag, im not sure how it works, but i remember i seen this somewhere on the wiki.
User avatar
Noyga
Inactive Developer
Posts: 1790
Joined: September 26th, 2005, 5:56 pm
Location: France

Post by Noyga »

I tried [stone] to with a standand unit filter (like [unstone]), but it doesn't work too :(
Well i think there is a bug in Wesnoth since it works well with status.poisoned and it wouldn't work with status.stone. :( :( :(
scott
Posts: 5243
Joined: May 12th, 2004, 12:35 am
Location: San Pedro, CA

Post by scott »

This code worked just fine for me. I'm not sure where your problem occured, but it wasn't with the stone variable syntax. Try saving the game after you store the unit and seeing if it's actually getting a unit.

Code: Select all

[event]
name=turn 2

[store_unit]
variable=stone_store
	[filter]
	description=Scott
	[/filter]
[/store_unit]

{VARIABLE stone_store.status.stone on}

[unstore_unit]
variable=stone_store
[/unstore_unit]

[/event]
Hope springs eternal.
Wesnoth acronym guide.
User avatar
Noyga
Inactive Developer
Posts: 1790
Joined: September 26th, 2005, 5:56 pm
Location: France

Post by Noyga »

Basically i use this code :

Code: Select all

#define FREEZE
	[set_variable]
		name=xtarget
		random=9..15
	[/set_variable]
	[set_variable]
		name=ytarget
		random=1..22
	[/set_variable]
	[terrain]
		x=$xtarget
		y=$ytarget
		letter=i
	[/terrain]
	[if]
		[have_unit]
			x=$xtarget
			y=$ytarget
		[/have_unit]
	[then]
		#debug
		[message]
			speaker=narrator
			message="Unit frozen at ($xtarget,$ytarget)"
		[/message]
		[store_unit]
			[filter]
				x=$xtarget
				y=$ytarget
			[/filter]
			variable=frozen_unit
			kill=yes
		[/store_unit]
		[set_variable]
			name=frozen_unit.status.stone
			value=on
		[/set_variable]
		[unstore_unit]
			variable=frozen_unit
		[/unstore_unit]
	[/then]
	[/if]
#enddef
And then this macro is called several times on every side turn :

Code: Select all

[event]
	name=side turn
	first_time_only=no
	
	{FREEZE}
	{FREEZE}
	{FREEZE}
	{FREEZE}
	{FREEZE}
	{FREEZE}
	{FREEZE}

	{UNFREEZE k}
	{UNFREEZE k}
	{UNFREEZE k}
	{UNFREEZE c}
	{UNFREEZE c}
	{UNFREEZE c}
	{UNFREEZE c}
	{UNFREEZE s}
	{UNFREEZE s}
	{UNFREEZE s}
	{UNFREEZE s}
	{UNFREEZE s}
[/event]
This works ok for me if i replace status.stone with status.poisoned, but it wouldn't work with stone ... Any idea ?
User avatar
Tomsik
Posts: 1401
Joined: February 7th, 2005, 7:04 am
Location: Poland

Post by Tomsik »

maybe its "stoned" not "stone"?
scott
Posts: 5243
Joined: May 12th, 2004, 12:35 am
Location: San Pedro, CA

Post by scott »

Your macro worked for me when I removed the UNFREEZE macros (since I don't have them). Perhaps they are messing up the freezing process.
Hope springs eternal.
Wesnoth acronym guide.
User avatar
Noyga
Inactive Developer
Posts: 1790
Joined: September 26th, 2005, 5:56 pm
Location: France

Post by Noyga »

Thanks, it comes from there :

Code: Select all

#define UNFREEZE TERRAIN
	[set_variable]
		name=xtarget
		random=9..15
	[/set_variable]
	[set_variable]
		name=ytarget
		random=1..21
	[/set_variable]
	[terrain]
		x=$xtarget
		y=$ytarget
		letter={TERRAIN}
	[/terrain]
	[unstone]
		x=$xtarget
		y=$ytarget
	[/unstone]
#enddef
Variable name conflicts ? :oops:
User avatar
Tomsik
Posts: 1401
Joined: February 7th, 2005, 7:04 am
Location: Poland

Post by Tomsik »

Uhh.. thats not functions like in c++ and such, every variable can be used in _every_ place of code.
scott
Posts: 5243
Joined: May 12th, 2004, 12:35 am
Location: San Pedro, CA

Post by scott »

I don't think [unstone] takes a standard unit filter. You should consider filing a bug report.

In the only places I remember seeing the tag, it was used without any keys whatsoever (Valley of Statues and Fallen Lich Point).

You can work around this issue by storing the unit and setting "stone" to "off".
Hope springs eternal.
Wesnoth acronym guide.
User avatar
Noyga
Inactive Developer
Posts: 1790
Joined: September 26th, 2005, 5:56 pm
Location: France

Post by Noyga »

I made all the things work ...
Here is how i use [unstone] :

Code: Select all

        [unstone]
                [filter]
                        x=$xunfreeze
                        y=$yunfreeze
                [/filter]
        [/unstone]
(i took different variables for the unfreeze code too).
I also made a MP scenario from this, but bad things happen in MP.
scott
Posts: 5243
Joined: May 12th, 2004, 12:35 am
Location: San Pedro, CA

Post by scott »

Hey great. I'll update the wiki.
Hope springs eternal.
Wesnoth acronym guide.
bruno
Inactive Developer
Posts: 293
Joined: June 26th, 2005, 8:39 pm
Contact:

Post by bruno »

Some commands have an implicit SUF and for others you need to use a filter tag. I think the common case is that you use a filter tag to do a location filter if there is an assumed unit filter or vice versa, but unstone doesn't seem to have an implied filter, so it is an exception.
Post Reply