Movement Problem

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
Syath
Posts: 13
Joined: November 29th, 2009, 6:07 pm

Movement Problem

Post by Syath »

I am learning WML, and am making a custom scenario based on a board game.

I am trying to simulate the rolling of dice at the beginning of each player's turn (players only get a leader, no recruiting).

I've tried all I can think of, including putting this in a foreach to make it work, it simply will not however.

Code: Select all

[event]
  name=side turn
  first_time_only=no
  {RANDOM 2..12}
  
    [store_unit]
        [filter]
            canrecruit=yes
	    side=$side_number
        [/filter]
        variable=leader
    [/store_unit]

    [object]
	[filter]
	    name=$leader.name
	[/filter]
	[effect]
	    apply_to=movement
	    set=$random
	[/effect]
	silent=yes
    [/object]

  {CLEAR_VARIABLE leader}
  [unstore_unit]
    variable=leader
  [/unstore_unit]

[/event]
This WILL randomly generate movement points for side 1, bu never does for sides 2-6

Thank you for any help you can offer :D


EDIT: Forgot to mention, I run the current latest stable version using Linux.
Syath
Posts: 13
Joined: November 29th, 2009, 6:07 pm

Re: Movement Problem

Post by Syath »

I don't know exactly how I fixed it, but this seems to work for anyone who ends up searching for how to do this later on.

Code: Select all

[event]
  name=side turn
  first_time_only=no
  {RANDOM 2..12}
  
    [store_unit]
        [filter]
            canrecruit=yes
	    side=$side_number
        [/filter]
        variable=leaders
    [/store_unit]

    {FOREACH leaders i}
    [object]
	[filter]
	    id=$leaders[$i].id
	[/filter]
	[effect]
	    apply_to=movement
	    set=$random
	[/effect]
	[effect]
	    apply_to=moves
	    set=12
	[/effect]
	silent=yes
    [/object]
    {NEXT i}

  {CLEAR_VARIABLE leaders}
  [unstore_unit]
    variable=leaders
  [/unstore_unit]

[/event]
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Movement Problem

Post by zookeeper »

You store the unit into a variable, give the unit (not the stored unit in the variable) an object, and then overwrite the unit that just got the object by unstoring the stored unit on top of it. Just remove the [unstore_unit] and it'll probably work just fine.

And actually you don't even need to store the unit first, just put your [store_unit] [filter] contents into your [object] [filter].

Code: Select all

[event]
  name=side turn
  first_time_only=no
  {RANDOM 2..12}

  [object]
	[filter]
	    canrecruit=yes
	    side=$side_number
	[/filter]
	[effect]
	    apply_to=movement
	    set=$random
	[/effect]
	silent=yes
  [/object]
[/event]
User avatar
Xudo
Posts: 563
Joined: April 3rd, 2009, 5:26 pm

Re: Movement Problem

Post by Xudo »

Some message about number of allowed movement also be good. It can be pseudo-graphics with two cubes with numbers. Or some images, what you can paint and put to this message.
If you give player some button (context menu or two units, what looks like cobes(with event name=select)) to click to throw cubes, it will be +1 to your work.
Post Reply