Teleport Formula

The place to post your WML questions and answers.

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

Teleport Formula

Post by ArcdeSeel »

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:
User avatar
josteph
Inactive Developer
Posts: 741
Joined: August 19th, 2017, 6:58 pm

Re: Teleport Formula

Post by josteph »

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

Re: Teleport Formula

Post by ArcdeSeel »

I'm testing in Wesnoth 1.14.5.. That teleportation definitely is not working.
User avatar
josteph
Inactive Developer
Posts: 741
Joined: August 19th, 2017, 6:58 pm

Re: Teleport Formula

Post by josteph »

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: 2158
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Teleport Formula

Post by Celtic_Minstrel »

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.
Former maintainer of Steelhive.
Post Reply