Teleport Formula

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
ArcdeSeel
Posts: 9
Joined: October 25th, 2016, 1:32 am

Teleport Formula

Post by ArcdeSeel » October 14th, 2018, 6:16 pm

The tunnel in abilities.cfg teleport is this:

Code: Select all

        [tunnel]
            id=village_teleport
            [source]
                terrain=*^V*
                formula="
                    owner = teleport_unit.side and (unit = teleport_unit or not unit)
                where
                    unit = unit_at(loc)
                "
            [/source]
            [target]
                terrain=*^V*
                formula="owner = teleport_unit.side and not unit_at(loc)"
            [/target]
            [filter]
                ability=teleport
            [/filter]
        [/tunnel]
I'd like to write my own teleport ability that allows a unit to move from anywhere to a space next to its leader. However, the formula above notably uses "owner" instead of the standard location filter "owner_side". Thus it seems like the formula uses different keys. How can I use those keys?
Note:
Spoiler:

josteph
Developer
Posts: 129
Joined: August 19th, 2017, 6:58 pm

Re: Teleport Formula

Post by josteph » October 14th, 2018, 8:00 pm

I'm not sure where you'd find the reference for formulas, but this does work:

Code: Select all

    [teleport]
        [tunnel]
            id=to_leader_teleport
            [source]
            [/source]
            [target]
                [filter_adjacent_location]
                    [filter]
                        canrecruit=yes
                        side=$teleport_unit.side
                    [/filter]
                [/filter_adjacent_location]
            [/target]
            [filter]
            [/filter]
        [/tunnel]
    [/teleport]

ArcdeSeel
Posts: 9
Joined: October 25th, 2016, 1:32 am

Re: Teleport Formula

Post by ArcdeSeel » October 14th, 2018, 9:32 pm

I'm testing in Wesnoth 1.14.5.. That teleportation definitely is not working.

josteph
Developer
Posts: 129
Joined: August 19th, 2017, 6:58 pm

Re: Teleport Formula

Post by josteph » October 14th, 2018, 10:07 pm

I'm using 1.14 from git and it definitely does work. Here's a complete example:

Code: Select all

diff --git a/data/scenario-test.cfg b/data/scenario-test.cfg
index 18af4e47c66..e6afacf630b 100644
--- a/data/scenario-test.cfg
+++ b/data/scenario-test.cfg
@@ -342,16 +342,23 @@ Xu, Xu, Qxu, Qxu, Ql, Ql, Ql, Xu, Xu, Xu, Xu, Xu, Xu, Xu, Xu, Gg, Gg, Gg, Gg, Gg
                     [effect]
                         apply_to=new_ability
                         [abilities]
-                            [illuminates]
-                                id=illumination
-                                value=-25
-                                min_value=-25
-                                cumulative=no
-                                name= "darkens"
-                                female_name= "female^darkens"
-                                description= "darkens and stuff"
-                                affect_self=yes
-                            [/illuminates]
+    [teleport]
+        [tunnel]
+            id=to_leader_teleport
+            [source]
+            [/source]
+            [target]
+                [filter_adjacent_location]
+                    [filter]
+                        canrecruit=yes
+                        side=$teleport_unit.side
+                    [/filter]
+                [/filter_adjacent_location]
+            [/target]
+            [filter]
+            [/filter]
+        [/tunnel]
+    [/teleport]
                         [/abilities]
                     [/effect]
                     [effect]

User avatar
Celtic_Minstrel
Developer
Posts: 1246
Joined: August 3rd, 2012, 11:26 pm
Contact:

Re: Teleport Formula

Post by Celtic_Minstrel » October 28th, 2018, 11:44 pm

The formula in a location filter is passed a terrain object, which has these keys available. For an example of how to detect adjacency, see the backstab formula.
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.

Post Reply