How to stone a unit ?

A place to post your WML questions and answers for multiplayer/single player scenarios.

Moderators: Forum Moderators, Developers

How to stone a unit ?

Postby Noyga » November 4th, 2005, 12:01 am

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

Postby scott » November 4th, 2005, 12:29 am

try 'on' instead of 'yes' in the set variable tag
Hope springs eternal.
Wesnoth acronym guide.
scott
Forum Regular
 
Posts: 5281
Joined: May 12th, 2004, 12:35 am
Location: Dulles, VA

Postby Noyga » November 4th, 2005, 12:54 am

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

Postby Tomsik » November 4th, 2005, 1:58 pm

Try [stone] tag, im not sure how it works, but i remember i seen this somewhere on the wiki.
"Think for yourself, schmuck!"
User avatar
Tomsik
Forum Regular
 
Posts: 1402
Joined: February 7th, 2005, 7:04 am
Location: Poland

Postby Noyga » November 4th, 2005, 3:07 pm

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

Postby scott » November 4th, 2005, 4:04 pm

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.
scott
Forum Regular
 
Posts: 5281
Joined: May 12th, 2004, 12:35 am
Location: Dulles, VA

Postby Noyga » November 4th, 2005, 6:43 pm

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

Postby Tomsik » November 4th, 2005, 6:51 pm

maybe its "stoned" not "stone"?
"Think for yourself, schmuck!"
User avatar
Tomsik
Forum Regular
 
Posts: 1402
Joined: February 7th, 2005, 7:04 am
Location: Poland

Postby scott » November 4th, 2005, 7:02 pm

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.
scott
Forum Regular
 
Posts: 5281
Joined: May 12th, 2004, 12:35 am
Location: Dulles, VA

Postby Noyga » November 4th, 2005, 7:30 pm

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

Postby Tomsik » November 4th, 2005, 7:49 pm

Uhh.. thats not functions like in c++ and such, every variable can be used in _every_ place of code.
"Think for yourself, schmuck!"
User avatar
Tomsik
Forum Regular
 
Posts: 1402
Joined: February 7th, 2005, 7:04 am
Location: Poland

Postby scott » November 4th, 2005, 7:57 pm

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.
scott
Forum Regular
 
Posts: 5281
Joined: May 12th, 2004, 12:35 am
Location: Dulles, VA

Postby Noyga » November 4th, 2005, 10:44 pm

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

Postby scott » November 4th, 2005, 10:50 pm

Hey great. I'll update the wiki.
Hope springs eternal.
Wesnoth acronym guide.
scott
Forum Regular
 
Posts: 5281
Joined: May 12th, 2004, 12:35 am
Location: Dulles, VA

Postby bruno » November 6th, 2005, 4:17 am

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.
bruno
Developer
 
Posts: 294
Joined: June 26th, 2005, 8:39 pm


Return to WML Workshop

Who is online

Users browsing this forum: No registered users and 0 guests