Unlimited moves and attacks
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.
Unlimited moves and attacks
One of my scenarios requires unlimited moves and attacks. The following events work perfectly for me (no crashes), but someone reported that it crashes randomly after either moving or attacking.
Can anyone tell me what the problem might be?
Code: Select all
[event]
name=moveto
first_time_only=no
[filter]
description=Randalf
#Not an entrance bridge
[not]
x,y=25,13
[/not]
[not]
x,y=31,16
[/not]
[not]
x,y=39,20
[/not]
[/filter]
#This might be the culprit
{MODIFY_UNIT (description=Randalf) moves 6}
[/event]
[event]
name=attack_end
first_time_only=no
[filter]
description=Randalf
[/filter]
[filter_second]
type=Baby Spider
[/filter_second]
#The spider should not die
[if]
[not]
[have_unit]
type=Baby Spider
x=$x2
y=$y2
[/have_unit]
[/not]
[then]
{MODIFY_UNIT (
x=$x2
y=$y2) hitpoints 10}
[/then]
[/if]
#Find the direction the spider should move
[store_locations]
variable=locs
x=$x1
y=$y1
radius=1
[/store_locations]
{FOREACH locs i}
{VARIABLE_OP x to_variable locs[$i].x}
{VARIABLE_OP y to_variable locs[$i].y}
[if]
[variable]
name=x
equals=$x2
[/variable]
[variable]
name=y
equals=$y2
[/variable]
[then]
{VARIABLE index $i}
{VARIABLE i 100}
[/then]
[/if]
{NEXT i}
[store_locations]
variable=locs
x=$x2
y=$y2
radius=1
[/store_locations]
{VARIABLE_OP x to_variable locs[$index].x}
{VARIABLE_OP y to_variable locs[$index].y}
{CLEAR_VARIABLE index}
[if]
[have_location]
x=$x
y=$y
terrain=Uu
[/have_location]
[then]
#Move the spider in the direction it was attacked
{MOVE_UNIT (
x=$x2
y=$y2) $x $y}
#If all 8 spiders on webs, go to 8-puzzle
{STORE_UNITS store (
type=Baby Spider
x=31,33,33,35,36,37,38,39
y=17,16,19,20,16,20,17,19) no}
[if]
[variable]
name=store.length
equals=8
[/variable]
[then]
#Get rid of spiders
[kill]
type=Baby Spider
animate=yes
[/kill]
#Move Randalf to the bridge
{MOVE_UNIT (description=Randalf) 31 16}
#Start eight-puzzle
{NEXT_PUZZLE}
{INIT_EIGHT_PUZZLE}
[/then]
[/if]
{CLEAR_VARIABLE store}
[/then]
[/if]
{MODIFY_UNIT (description=Randalf) moves 6}
{MODIFY_UNIT (description=Randalf) attacks_left 1}
{CLEAR_VARIABLE locs}
{CLEAR_VARIABLE x}
{CLEAR_VARIABLE y}
[/event]
Re: Unlimited moves and attacks
I would probably get more information from the person who reported the crash. This person appears to be using an old or broken wesnoth client.