Make units appear next to others
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.
-
- Retired Developer
- Posts: 1086
- Joined: September 16th, 2005, 5:44 am
- Location: Hamburg, Germany
Make units appear next to others
Hi,
i have a unit (Robert) and by triggering a certain event i want another unit appear next to it. Here is what i tried so far:
[store_unit]
variable=robert_store
kill=yes
[filter]
description=Robert
[/filter]
[/store_unit]
[unit]
description=Slinger
user_description= _ "Slinger"
type=Thief
x=22
y=36
side=2
[/unit]
[store_unit]
[filter]
description=Slinger
[/filter]
kill=yes
variable=tempthief
[/store_unit]
[set_variable]
name=tempthief.x
value=robert_store.x - 2
[/set_variable]
[set_variable]
name=tempthief.y
value=robert_store.y - 2
[/set_variable]
[unstore_unit]
variable=tempthief
find_vacant=yes
[/unstore_unit]
[unstore_unit]
variable=robert_store
description=Robert
[/unstore_unit]
Obviously this does not work . In fact, the thief does not appear at all (he does so if i just remove all that store/unstore stuff but i have to fix his position then). What's the trick with this?
i have a unit (Robert) and by triggering a certain event i want another unit appear next to it. Here is what i tried so far:
[store_unit]
variable=robert_store
kill=yes
[filter]
description=Robert
[/filter]
[/store_unit]
[unit]
description=Slinger
user_description= _ "Slinger"
type=Thief
x=22
y=36
side=2
[/unit]
[store_unit]
[filter]
description=Slinger
[/filter]
kill=yes
variable=tempthief
[/store_unit]
[set_variable]
name=tempthief.x
value=robert_store.x - 2
[/set_variable]
[set_variable]
name=tempthief.y
value=robert_store.y - 2
[/set_variable]
[unstore_unit]
variable=tempthief
find_vacant=yes
[/unstore_unit]
[unstore_unit]
variable=robert_store
description=Robert
[/unstore_unit]
Obviously this does not work . In fact, the thief does not appear at all (he does so if i just remove all that store/unstore stuff but i have to fix his position then). What's the trick with this?
Smart persons learn out of their mistakes, wise persons learn out of others mistakes!
Just create the unit at Robert's coordinates, and it'll be placed at an adjacent hex:
The STORE_UNIT_VAR macro from here.
Or a simpler (probably preferred) version:
Code: Select all
[event]
name=turn 4
{STORE_UNIT_VAR description=Robert x rob_x}
{STORE_UNIT_VAR description=Robert y rob_y}
[unit]
description=Slinger
type=Thief
x,y=$rob_x,$rob_y
side=1
[/unit]
[/event]
Or a simpler (probably preferred) version:
Code: Select all
[store_unit]
[filter]
description=Robert
[/filter]
variable=robert_store
kill=no
[/store_unit]
[unit]
description=Slinger
type=Thief
x,y=$robert_store.x,$robert_store.y
side=1
[/unit]
Last edited by zookeeper on February 17th, 2006, 2:39 pm, edited 1 time in total.
Don't know if it helps or not... But I am trying to... Are you sure... That you need to put kill=yes?
Also, maybe use [teleport] instead of changing x and y of the unit.
I really do hope it helps...
EDIT: Zookeeper got there before me, so ignore this post.
From my understanding of the wiki, kill=yes don't seem to be needed, when you are only modifying units.kill if 'yes' the units that are stored will be removed from play. This is useful for instance to remove access to a player's recall list, with the intent to restore the recall list later."
Also, maybe use [teleport] instead of changing x and y of the unit.
I really do hope it helps...
EDIT: Zookeeper got there before me, so ignore this post.
Why did the fish laugh? Because the sea weed.
Code: Select all
value=robert_store.x - 2
Code: Select all
value=$robert_store.x - 2
Code: Select all
value=robert_store.x - 2
No. Take
Code: Select all
[set_variable]
name=tempthief.x
value=robert_store.x
[/set_variable]
[set_variable]
name=tempthief.x
add=-2
[/set_variable]
Code: Select all
{VARIABLE tempthief.x $robert_store.x}
{VARIABLE_OP tempthief.x add -2}
First read, then think. Read again, think again. And then post!