Teleport Formula
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.
Teleport Formula
The tunnel in abilities.cfg teleport is this:
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:
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]
Note:
Spoiler:
Re: Teleport Formula
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]
Re: Teleport Formula
I'm testing in Wesnoth 1.14.5.. That teleportation definitely is not working.
Re: Teleport Formula
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]
- Celtic_Minstrel
- Developer
- Posts: 2166
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Teleport Formula
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.