Teleporting in a radius around a center

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

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
User avatar
Devotation
Posts: 13
Joined: September 9th, 2016, 9:22 pm

Teleporting in a radius around a center

Post by Devotation » February 20th, 2018, 5:35 pm

Hello,

I have written a ability which should allow units with the ability 'symbiosis' to teleport to any hex around a center unit in a specified radius.
It does absolutly nothing.

Code: Select all

#define ABILITY_SYMBIOSIS_CENTER RADIUS
    [teleport]
        id=Symbiosis_center_{RADIUS}
        name= _ "Symbiosis Center"
        female_name= _ "female^Symbiosis Center"
        description= _ "This Ability grants plants to teleport between two hexes in a "+{RADIUS}+" hex radius around this unit."
        [tunnel]
            [source]
				[and]
				[filter]
					ability=Symbiosis_center_{RADIUS}
				[/filter]
				radius={RADIUS}
				[/and]
				[not]
					terrain=X*,*^X*,Q*
				[/not]
            [/source]

			[target]
				[and]
				[filter]
					ability=Symbiosis_center_{RADIUS}
				[/filter]
				radius={RADIUS}
				[/and]
				[not]
					terrain=X*,*^X*,Q*
				[/not]
			[/target]

            [filter]
                ability=symbiosis
            [/filter]
        [/tunnel]
    [/teleport]
#enddef
#define ABILITY_SYMBIOSIS
	[dummy]
		id=symbiosis
        name= _ "Symbiosis"
        female_name= _ "female^Symbiosis"
        description= _ "This Ability grants plants to teleport between two hexes in a n hex radius around a center unit."
	[/dummy]
#enddef
Thank you in advance.
No cost too great.

User avatar
beetlenaut
Developer
Posts: 2205
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Teleporting in a radius around a center

Post by beetlenaut » February 21st, 2018, 2:30 pm

I see some things that are suspicious, but I'm not sure what your problem is yet. You could narrow it down though. Move the [tunnel] into a start or moveto event with an empty [filter], and see if it works there. If it does, put the filter back and try again. If not, try [store_location] with the [source] location filters and a variable, and use :inspect to see if the right hexes are being stored in the first place, etc.

Basically, move things around to find the simplest configuration that does something, then put things back until it stops working. Then you'll know where the problem is.
Campaigns: Dead Water
The Founding of Borstep
Secrets of the Ancients

User avatar
zookeeper
WML Wizard
Posts: 9734
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Teleporting in a radius around a center

Post by zookeeper » February 21st, 2018, 5:10 pm

Using [teleport][tunnel] specifies how the unit with that ability may teleport. It can't create tunnels for unrelated units to use. So it's the symbiosis ability which needs to be the [teleport] ability, while the center ability can be a dummy.

User avatar
Devotation
Posts: 13
Joined: September 9th, 2016, 9:22 pm

Re: Teleporting in a radius around a center

Post by Devotation » February 22nd, 2018, 2:35 pm

zookeeper wrote:Using [teleport][tunnel] specifies how the unit with that ability may teleport. It can't create tunnels for unrelated units to use. So it's the symbiosis ability which needs to be the [teleport] ability, while the center ability can be a dummy.
Well i did it that way because my other ability which doesn't use radia does work that way.

Code: Select all

#define ABILITY_RIFT
    [teleport]
	id=NWRift
	name= _ "Rift"
	description= _ "Adjacent allies can teleport between two or more units with this ability"
	affect_self=no
	affect_allies=yes
	affect_enemies=no
	[affect_adjacent]
	adjacent=n,ne,se,s,sw,nw
	[/affect_adjacent]
	    [tunnel]
			bidirectional=yes
			[source]
				[filter_adjacent_location]
					[filter]
						ability=NWRift
					is_enemy=no
					[/filter]
				[/filter_adjacent_location]
			[/source]
			[target]
				[filter_adjacent_location]
					[filter]
						ability=NWRift
						is_enemy=no
					[/filter]
				[/filter_adjacent_location]
			[/target]
			[filter]
				[filter_adjacent]
					ability=NWRift
					is_enemy=no
				[/filter_adjacent]
			[/filter]
		[/tunnel]
	[/teleport]
#enddef
But it works when swapping it around.
Just have to work out how to seperate the centers from another. Thank you.
Last edited by Celtic_Minstrel on February 27th, 2018, 1:19 am, edited 2 times in total.
Reason: Fix broken markup (presumably caused by forum upgrade?)
No cost too great.

Post Reply