Ability to teleport other units
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.
-
- Posts: 4
- Joined: June 30th, 2013, 9:05 pm
Ability to teleport other units
Hi people, I'm making a campaign with some custom units and I ran into some questions related to WML synthax.
Principally I would like to know if it is possible to make a unit teleport another (enemy) unit? Do any of you have an idea how I could make this work?
I'm very greatful for any (even negative) answer.
Principally I would like to know if it is possible to make a unit teleport another (enemy) unit? Do any of you have an idea how I could make this work?
I'm very greatful for any (even negative) answer.
Re: Ability to teleport other units
Define how you want the unit to be able to teleport the other unit, please.
I'm just... a guy...
I'm back for now, I might get started on some work again.
I'm back for now, I might get started on some work again.
-
- Posts: 4
- Joined: June 30th, 2013, 9:05 pm
Re: Ability to teleport other units
I thought about the teleport ability being part of an attack. The unit is supposed to be very weak, but to have some special abbilities, for example surprisingly teleporting away the opponent if it hits.
I managed to teleport the unit self away using an event in the unit_type description.
But I wonder if it would work the other way around (the unit teleports away the opponent) and how this could be coded.
I managed to teleport the unit self away using an event in the unit_type description.
Code: Select all
[event]
name=attacker hits
first_time_only=no
[filter_attack]
name=teleport
[/filter_attack]
[teleport]
[filter_second]
side=$enemy_sides
[filter_adjacent]
id=Green Puck
is_enemy=no
[/filter_adjacent]
[/filter_second]
x=28
y=23
[/teleport]
[redraw]
[/redraw]
[/event]
Re: Ability to teleport other units
[filter_second] doesn't go in [teleport]. Use [filter] instead.
I'm just... a guy...
I'm back for now, I might get started on some work again.
I'm back for now, I might get started on some work again.
-
- Posts: 4
- Joined: June 30th, 2013, 9:05 pm
Re: Ability to teleport other units
I don't know why, but it doesn't teleport any unit when I use [filter] tags.
Using [filter_second] at least my unit is teleported, even if I still don't know how to teleport his hitten opponent.
Using [filter_second] at least my unit is teleported, even if I still don't know how to teleport his hitten opponent.
Re: Ability to teleport other units
Try
instead of your [filter_second]. (IDs tend to be the most reliable way to IDentify units.)
Code: Select all
[filter]
id=$second_unit.id
[/filter]
-
- Posts: 4
- Joined: June 30th, 2013, 9:05 pm
Re: Ability to teleport other units
@JaMiT: You're right, ID's are the most reliable way to IDentify units.
Ravana pointed out to me, that something similar was done in the Ageless era with the knockback weapon special.
The following code in the unit_type descrition does exactly wat I want, teleporting the hitten opponent within a random radius.
Ravana pointed out to me, that something similar was done in the Ageless era with the knockback weapon special.
The following code in the unit_type descrition does exactly wat I want, teleporting the hitten opponent within a random radius.
Code: Select all
[event]
name=turn refresh
first_time_only=no
{RANDOM_COORDS X Y}
[/event]
[event]
name=attacker hits
first_time_only=no
[filter_attack]
name=missile
[/filter_attack]
[if]
[variable]
name=second_unit.hitpoints
greater_than=0
[/variable]
[then]
[store_locations]
[not]
[filter]
[/filter]
[/not]
[and]
x,y=$x2,$y2
radius=$X
[/and]
variable=knockback_target_hex
[/store_locations]
[if]
[variable]
name=knockback_target_hex.length
greater_than=0
[/variable]
[then]
[teleport]
[filter]
id=$second_unit.id
[/filter]
x,y=$knockback_target_hex.x,$knockback_target_hex.y
ignore_passability=no
[/teleport]
[redraw]
[/redraw]
[if]
[have_unit]
x,y=$knockback_target_hex.x,$knockback_target_hex.y
[/have_unit]
[then]
[sound]
name=fist.ogg
[/sound]
# the knockbacked unit doesn't seem to receive experience by default,
# so we need to add it manually
[store_unit]
[filter]
x,y=$knockback_target_hex.x,$knockback_target_hex.y
[/filter]
kill=yes
variable=knockbacked
[/store_unit]
{VARIABLE_OP knockbacked.experience add $unit.level}
[unstore_unit]
variable=knockbacked
text= _ "knockback"
{COLOR_HARM}
advance=true
[/unstore_unit]
{CLEAR_VARIABLE knockbacked}
[/then]
[/if]
[/then]
[/if]
{CLEAR_VARIABLE knockback_target_hex}
[/then]
[/if]
[/event]
Re: Ability to teleport other units
Missile sounds like common attack name, sure that is doesnt apply to wrong attacks as well? Also you can change knockback to something else, at least for player visible content.
Re: Ability to teleport other units
Code: Select all
[filter_adjacent]
id=Green Puck
is_enemy=no
[/filter_adjacent]
I'm just... a guy...
I'm back for now, I might get started on some work again.
I'm back for now, I might get started on some work again.
Re: Ability to teleport other units
Here is the code i've used for my teleportaway weaponspecial.
Maybe this is helpful. You might need to add a radius, though.
Maybe this is helpful. You might need to add a radius, though.
Code: Select all
[event]
name=attack
first_time_only=no
[filter_attack]
special=teleportaway
[/filter_attack]
[store_unit]
[filter]
x,y=$x1,$y1
[/filter]
variable=teleporter1
[/store_unit]
[set_variable]
name=teleporter1.variables.teleportedaway
value=no
[/set_variable]
[unstore_unit]
variable=teleporter1
[/unstore_unit]
{CLEAR_VARIABLE teleporter1}
[/event]
[event]
name=attacker_hits
first_time_only=no
[filter_attack]
special=teleportaway
[/filter_attack]
[store_unit]
[filter]
x,y=$x1,$y1
[/filter]
variable=teleporter2
[/store_unit]
{VARIABLE teleporter2.variables.teleportedaway yes}
[unstore_unit]
variable=teleporter2
[/unstore_unit]
{CLEAR_VARIABLE teleporter2}
[/event]
[event]
name=attack_end
first_time_only=no
[filter_attack]
special=teleportaway
[/filter_attack]
[filter_second]
canrecruit=no
[and]
[not]
{FILTEREXCEPTION}
[/not]
[/and]
[/filter_second]
[store_unit]
[filter]
x,y=$x1,$y1
[/filter]
variable=porter
[/store_unit]
[store_unit]
[filter]
x,y=$x2,$y2
[/filter]
variable=ported
[/store_unit]
[if]
[variable]
name=porter.variables.teleportedaway
equals=no
[/variable]
[then]
[unstore_unit]
variable=porter
text="Failed!"
{COLOR_HARM}
[/unstore_unit]
[/then]
[else]
[store_map_dimensions]
[/store_map_dimensions]
[set_variable]
name=x3
rand=1..$map_size.width
[/set_variable]
[set_variable]
name=y3
rand=1..$map_size.height
[/set_variable]
[kill]
id=$ported.id
[/kill]
[set_variable]
name=ported.x
rand=$x3
[/set_variable]
[set_variable]
name=ported.y
rand=$y3
[/set_variable]
[unit_overlay]
x,y=$x3,$y3
image=projectiles/icemissile-n-7.png
[/unit_overlay]
[delay]
time=500
[/delay]
[remove_unit_overlay]
x,y=$x3,$y3
image=projectiles/icemissile-n-7.png
[/remove_unit_overlay]
[unstore_unit]
variable=ported
find_vacant=no
text= _ "Teleported"
red,green,blue=0,50,155
[/unstore_unit]
[unstore_unit]
variable=ported
text="Ported!"
{COLOR_HEAL}
[/unstore_unit]
[/else]
[/if]
{CLEAR_VARIABLE porter}
{CLEAR_VARIABLE ported}
[/event]
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer