[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-wiki-changes] MoveExistingUnit
From: |
wiki |
Subject: |
[Wesnoth-wiki-changes] MoveExistingUnit |
Date: |
Tue, 16 Nov 2004 21:14 +0100 |
UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/125.4
(KHTML, like Gecko) Safari/125.9
IP: 66.189.14.56
URI: http://wesnoth.slack.it/?MoveExistingUnit
- - - - -
||MoveExistingUnit||
Examples of usage:
#quick victory in The Elves Besieged!
{MOVE_EXISTING_UNIT description=Konrad 1 1}
#move the unit at 4,5 to 13,7
{MOVE_EXISTING_UNIT x,y=4,5 13 7}
#move a predetermined unit to a predetermined location
{MOVE_EXISTING_UNIT role=Advisor $to_x $to_y}
Notes:
* If a legal path cannot be found, no movement will be displayed, but the unit
will still be moved. However beware: moving through cavewall is considered
legal, but displays extremely slowly when the accelerated speed option is not
enabled.
* If there is a unit at the destination location, a nearby location to move to
will be chosen. If that is a problem, you can make sure that location is empty
before using this macro.
#usual version
#define MOVE_EXISTING_UNIT FILTER X Y
{_MOVE_EXISTING_UNIT ({FILTER}) ({X}) ({Y}) ( )}
#enddef
#This is in case you need to make another unit type to display moving.
#For example, if the movement has to go through deep water or cavewall,
#you could make a unit whose id was the original's with "Fake " at the
beginning,
#which would have a [movement costs] tag with cavewall=1. Skirmisher ability
is also useful to give here.
#HINT: undeadfly movetype takes only 1 move through anything except cavewall.
#define MOVE_EXISTING_UNIT_WITH_FAKE_VERSION FILTER X Y
{_MOVE_EXISTING_UNIT ({FILTER}) ({X}) ({Y}) ([set_variable]
name=mover_type
format="Fake $mover_type"
[/set_variable])}
#enddef
#don't use this directly, unless you really need to
#define _MOVE_EXISTING_UNIT FILTER X Y EXTRA_COMMANDS
[store_unit]
[filter]
{FILTER}
[/filter]
variable=mover_store
[/store_unit]
{VARIABLE_OP temp_x1 to_variable mover_store.x}
{VARIABLE_OP temp_y1 to_variable mover_store.y}
#if it's really a unit on the map, never mind whether it has HP<=0
#(in which case [have_unit] wouldn't detect it)
[if]
[variable]
name=temp_x1
greater_than=0
[/variable]
[variable]
name=temp_y1
greater_than=0
[/variable]
[then]
#kill the original
[kill]
x=$temp_x1
y=$temp_y1
[/kill]
[unit]
type=Invisible
x={X}
y={Y}
side=1
role=temp_location_tester
[/unit]
[store_unit]
[filter]
role=temp_location_tester
[/filter]
kill=yes
variable=temp_store
[/store_unit]
{VARIABLE_OP temp_x2 to_variable temp_store.x}
{VARIABLE_OP temp_y2 to_variable temp_store.y}
{VARIABLE_OP mover_store.x to_variable temp_x2}
{VARIABLE_OP mover_store.y to_variable temp_y2}
#make it face the right direction
#this may be unnecessary/bad; I don't think it's totally
reliable
#if a unit goes a long way around
[if]
[variable]
name=temp_x1
greater_than=$temp_x2
[/variable]
[then]
{VARIABLE mover_store.facing reverse}
[/then]
[/if]
[if]
[variable]
name=temp_x2
greater_than=$temp_x1
[/variable]
[then]
{VARIABLE mover_store.facing normal}
[/then]
[/if]
#don't move to the same place!
#it would go one hex away and back
[if]
[or]
[variable]
name=temp_x1
not_equals=$temp_x2
[/variable]
[/or]
[or]
[variable]
name=temp_y1
not_equals=$temp_y2
[/variable]
[/or]
[then]
{VARIABLE_OP mover_type to_variable mover_store.type}
{VARIABLE_OP mover_side to_variable mover_store.side}
{VARIABLE_OP mover_gender to_variable mover_store.side}
{VARIABLE_OP movement_x format (|$temp_x1|,$temp_x2)}
{VARIABLE_OP movement_y format (|$temp_y1|,$temp_y2)}
{EXTRA_COMMANDS}
[move_unit_fake]
type=$mover_type
side=$mover_side
gender=$mover_gender
x=$movement_x
y=$movement_y
[/move_unit_fake]
[unstore_unit]
variable=mover_store
[/unstore_unit]
[redraw]
[/redraw]
{CLEAR_VARIABLE mover_type}
{CLEAR_VARIABLE mover_side}
{CLEAR_VARIABLE mover_gender}
{CLEAR_VARIABLE movement_y}
{CLEAR_VARIABLE movement_x}
[/then]
[else]
[unstore_unit]
variable=mover_store
[/unstore_unit]
[redraw]
[/redraw]
[/else]
[/if]
{CLEAR_VARIABLE temp_x2}
{CLEAR_VARIABLE temp_y2}
{CLEAR_VARIABLE temp_store}
[/then]
[/if]
{CLEAR_VARIABLE temp_x1}
{CLEAR_VARIABLE temp_y1}
{CLEAR_VARIABLE mover_store}
#enddef
||See Also||
* UsefulWMLFragments
- [Wesnoth-wiki-changes] MoveExistingUnit,
wiki <=