Scanning area for certain terrain
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.
Scanning area for certain terrain
I attempt the following: If a unit, ID=Builder, is on a hexagon with woods there is an Option in the right-click menu displayed and he can recruit a transport galleon. My code is working. However, I struggle with the summoning position of the galleon which is not working. What I try to do, is that the galleon Spans in a 3x3 area below the keep of my leader, ID=Barbarossa, if there is tropical shallow water. But I can't geht this part to work. I think this is due to a failure in filtering for that area.
Code: Select all
#define Barbarossa_Startlocation
[store_unit]
[filter]
id=Barbarossa
[/filter]
variable=Barbarossa_Start
kill=no
[/store_unit]
#enddef
#Building galleon
#define BUILD_GALLEON
[set_menu_item]
id=build_galleon
description="Build a Transport Galleon"
#Option Menu
[show_if]
[have_unit]
id=Builder
[filter_location]
terrain=Gs^Fds
[/filter_location]
[/have_unit]
[/show_if]
#Filter Builder's Location
[filter_location]
terrain=Gs^Fds
[/filter_location]
[command]
[store_unit]
[filter]
id=Builder
[/filter]
variable=Builder_Store
kill=no
[/store_unit]
[terrain]
x=$Builder_Store.x
y=$Builder_Store.y
terrain=Gg
[/terrain]
#Summon Unit
[store_unit]
[filter]
id=Barbarossa
[/filter]
variable=Barbarossa_Start
kill=no
[/store_unit]
[set_variable]
name=Barbarossa_new.x
value="$(3 + $Barbarossa_Start.x)"
[/set_variable]
[set_variable]
name=Barbarossa_new.y
value="$(3 + $Barbarossa_Start.y)"
[/set_variable]
[store_locations]
terrain=Wwt
x=$Barbarossa_Start.x-$Barbarossa_new.x
variable=terrain_x
[/store_locations]
[store_locations]
terrain=Wwt
y=$Barbarossa_Start.y-$Barbarossa_new.y
variable=terrain_y
[/store_locations]
[unit]
side=1
type=Transport Galleon
x,y=$terrain_x,$terrain_y
[/unit]
#Price for galleon
[gold]
amount=-20
[/gold]
[/command]
[/set_menu_item]
#enddef
Re: Scanning area for certain terrain
Pointing out that is never reached.
Filter says that if builder is on tree, all trees can be clicked.
[store_locations] stores location, not x or y. You might need to use radius. There is no guarantee Barbarossa_Start represents start location, its stored when menu item is used.
Code: Select all
#define Barbarossa_Startlocation
[store_unit]
[filter]
id=Barbarossa
[/filter]
variable=Barbarossa_Start
kill=no
[/store_unit]
#enddef
Filter says that if builder is on tree, all trees can be clicked.
[store_locations] stores location, not x or y. You might need to use radius. There is no guarantee Barbarossa_Start represents start location, its stored when menu item is used.
- beetlenaut
- Developer
- Posts: 2827
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: Scanning area for certain terrain
I don't think so. I think all you need to do is put the x and y lines into one [store_locations] tag. If I understand correctly, that will store the locations you want. That will store 9 hexes in a 3x3 area. Each location will have an x and y in it. I'm pretty sure the fifth one -- which would be
$location[5].x
and $location[5].y
-- will be the center, and you can spawn your ship there.Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide