WML questions: invalid wml
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.
- battlestar
- Posts: 690
- Joined: January 1st, 2007, 7:12 am
WML questions: invalid wml
Is it possible to create a walking corpse unit with a specified variation with wml? thanks.
Last edited by battlestar on March 6th, 2014, 11:33 pm, edited 24 times in total.
LUA: Llama Under Apprenticeship
Hell faction: completed
Hell faction: completed
- Elvish_Hunter
- Posts: 1575
- Joined: September 4th, 2009, 2:39 pm
- Location: Lintanir Forest...
Re: walking corpse creation
Yes. In the [unit] tag, just add the variation= key, like stated at http://wiki.wesnoth.org/SingleUnitWML :
variation: the variation of itself the unit should be created as.
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
- Alarantalara
- Art Contributor
- Posts: 786
- Joined: April 23rd, 2010, 8:17 pm
- Location: Canada
Re: walking corpse creation
Yes, just include the variation key in the unit creation code.
e.g.
If you're asking about doing for recruiting, check out the code for Muff Malal's peninsula from Heir to the Throne.
e.g.
Code: Select all
{UNIT side (Walking Corpse) x y (variation=swimmer)}
- battlestar
- Posts: 690
- Joined: January 1st, 2007, 7:12 am
Re: walking corpse creation
cool, missed it when reading that lol, thanks.
LUA: Llama Under Apprenticeship
Hell faction: completed
Hell faction: completed
- battlestar
- Posts: 690
- Joined: January 1st, 2007, 7:12 am
Re: Something strange between different directions
Two problems with the following code I've found:
1. GET_ADJACENT_HEX here gets every direction but it leaves out "s" (south)... I've tried putting it at different places but south is always the one that gets tossed out.
2. Something's wrong... tested it a dozen times and more confused than ever because it doesn't consistently do what it's supposed to do...
???
These codes are supposed to do this: any unit that killed adjacent to the unit with id=Valia will be turned into a zombie.
But it sometimes doesn't happen.
1. GET_ADJACENT_HEX here gets every direction but it leaves out "s" (south)... I've tried putting it at different places but south is always the one that gets tossed out.
2. Something's wrong... tested it a dozen times and more confused than ever because it doesn't consistently do what it's supposed to do...
???
These codes are supposed to do this: any unit that killed adjacent to the unit with id=Valia will be turned into a zombie.
But it sometimes doesn't happen.
Code: Select all
#define GET_ADJACENT_HEX ORIGIN_X ORIGIN_Y DIRECTION RESULT_STORE
[store_locations]
[filter_adjacent_location]
x={ORIGIN_X}
y={ORIGIN_Y}
adjacent="-{DIRECTION}"
[/filter_adjacent_location]
variable={RESULT_STORE}
[/store_locations]
#enddef
#define AURA_OF_REANIMATION_DYING
[event]
name=last breath
first_time_only=yes
[filter]
x,y=$valia_aura_location[1].x,$valia_aura_location[1].y
[or]
x,y=$valia_aura_location[2].x,$valia_aura_location[2].y
[/or]
[or]
x,y=$valia_aura_location[3].x,$valia_aura_location[3].y
[/or]
[or]
x,y=$valia_aura_location[4].x,$valia_aura_location[4].y
[/or]
[or]
x,y=$valia_aura_location[5].x,$valia_aura_location[5].y
[/or]
[or]
x,y=$valia_aura_location[6].x,$valia_aura_location[6].y
[/or]
[not]
race=undead
[or]
race=mechanical
[/or]
[/not]
[/filter]
[if]
[variable]
name=aura_of_reanimation
numerical_equals=1
[/variable]
[then]
{MESSAGE narrator () "caption" "message"}
[store_unit]
[filter]
x,y=$x1,$y1
[/filter]
variable=valia_resurrection_storage
kill=no
[/store_unit]
[kill]
x,y=$x1,$y1
animate=yes
fire_event=yes
[/kill]
[unit]
type=Walking Corpse
side=1
x,y=$valia_resurrection_storage.x,$valia_resurrection_storage.y
variation=$valia_resurrection_storage.undead_variation
name="$valia_resurrection_storage.name"
facing=$valia_resurrection_storage.facing
[/unit]
[/then]
[/if]
[/event]
#enddef
#define AURA_OF_REANIMATION
# need to allow undo movements?
[event]
name=moveto
first_time_only=no
[filter]
id=Valia
[filter_location]
[/filter_location]
[/filter]
{GET_ADJACENT_HEX $x1 $y1 (n,nw,ne,sw,se,s) valia_aura_location}
[/event]
{AURA_OF_REANIMATION_DYING}
[event]
name=die
first_time_only=no
[filter]
x,y=$valia_aura_location[0].x,$valia_aura_location[0].y
[or]
x,y=$valia_aura_location[1].x,$valia_aura_location[2].y
[/or]
[or]
x,y=$valia_aura_location[2].x,$valia_aura_location[2].y
[/or]
[or]
x,y=$valia_aura_location[3].x,$valia_aura_location[3].y
[/or]
[or]
x,y=$valia_aura_location[4].x,$valia_aura_location[4].y
[/or]
[or]
x,y=$valia_aura_location[5].x,$valia_aura_location[5].y
[/or]
[or]
x,y=$valia_aura_location[6].x,$valia_aura_location[6].y
[/or]
[/filter]
{AURA_OF_REANIMATION_DYING}
[/event]
#enddef
[event]
name=prestart
[set_variable]
name=aura_of_reanimation
value=1
[/set_variable]
[/event]
{AURA_OF_REANIMATION}
LUA: Llama Under Apprenticeship
Hell faction: completed
Hell faction: completed
Re: Something strange between different directions
Look at your indices. They should go from 0 to 5, not 1 to 6. There is also at least one line where you don't have the same index for the x and y coordinate.
You should also be able to do this entirely without indices, simply by using
You should also be able to do this entirely without indices, simply by using
[filter_adjacent]
.SP campaigns: Galuldur's First Journey (1.12 & 1.14) & Grnk the Mighty (1.10 & 1.12)
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
- battlestar
- Posts: 690
- Joined: January 1st, 2007, 7:12 am
Re: Something strange between different directions
Thanks, those two changes made it act like it's intended. Filter adjacent works great here.
Still interested to know why the following code ignores the south direction though
Wonder if it can be:
Still interested to know why the following code ignores the south direction though
Code: Select all
#define GET_ADJACENT_HEX ORIGIN_X ORIGIN_Y DIRECTION RESULT_STORE
[store_locations]
[filter_adjacent_location]
x={ORIGIN_X}
y={ORIGIN_Y}
adjacent="-{DIRECTION}"
[/filter_adjacent_location]
variable={RESULT_STORE}
[/store_locations]
#enddef
Code: Select all
[store_locations]
x,y={X},{Y}
radius=1
variable={RESULT_STORE}
[/store_locations]
LUA: Llama Under Apprenticeship
Hell faction: completed
Hell faction: completed
Re: Something strange between different directions
That macro was only intended to handle a single direction, not a list of directions. It uses a minus sign to reverse the direction, thus when you supply a list only the first one gets reversed. Therefore "n,nw,ne,sw,se,s" becomes "-n,nw,ne,sw,se,s". As you can see the "s" or "-n" is duplicated but you have no "-s" or "n".
Another problem with that macro is that it will break when the supplied argument uses quotes.
Instead, I should have written adjacent="-"+{DIRECTION}
Another problem with that macro is that it will break when the supplied argument uses quotes.
Instead, I should have written adjacent="-"+{DIRECTION}
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
Re: Something strange between different directions
battlestar: Since
The other example you give with the
Note that the
adjacent
in [filter_adjacent_location] defaults to "n,ne,se,s,sw,nw", you can simply leave out the adjacent
line from the macro if all you want to use it for is for getting all adjacent hexes (rather than it also to be used with different individual directions). [Or, of course, you could call the macro as is with some combination like (n,n,nw,ne,sw,se) for the reasons Sapient explained.]The other example you give with the
radius
should work, except that you also get the center hex itself from it. If you just want the adjacent hexes, you'd need something like this:
Code: Select all
[store_locations]
[and]
x,y={X},{Y}
radius=1
[and]
[not]
x,y={X},{Y}
[/not]
variable={RESULT_STORE}
[/store_locations]
[and]
is not optional in this case because of the way how radius
works.SP campaigns: Galuldur's First Journey (1.12 & 1.14) & Grnk the Mighty (1.10 & 1.12)
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
- battlestar
- Posts: 690
- Joined: January 1st, 2007, 7:12 am
Re: Something strange between different directions
Thanks for the explainations.
This is what I have now for the spell.
Works exactly like planned
But something's not working again when I try to convert it to an ability:
I wonder if it's because ability= is not valid in filter_adjacent, this was the only change in first macro besides taking out a set of if-then which is pretty unlikely to cause the problem. Second macro only has its name changed, and third macro and the event seem to work fine.
This is what I have now for the spell.
Code: Select all
#define AURA_OF_REANIMATION_DYING
[event]
name=last breath
first_time_only=yes
[filter]
[filter_adjacent]
id=Valia
[/filter_adjacent]
[not]
race=undead
[or]
race=mechanical
[/or]
[/not]
[/filter]
[if]
[variable]
name=aura_of_reanimation
numerical_equals=1
[/variable]
[then]
[store_unit]
[filter]
x,y=$x1,$y1
[/filter]
variable=valia_reanimation_storage
kill=no
[/store_unit]
[kill]
x,y=$x1,$y1
animate=yes
fire_event=yes
[/kill]
[set_variable]
name=success_valia_reanimation
rand=1,1,0,0,0,0
# 40%
[/set_variable]
[if]
[variable]
name=success_valia_reanimation
numerical_equals=1
[/variable]
[then]
[unit]
type=Walking Corpse
side=1
x,y=$valia_reanimation_storage.x,$valia_reanimation_storage.y
variation=$valia_reanimation_storage.undead_variation
name="$valia_reanimation_storage.name"
facing=$valia_reanimation_storage.facing
moves=0
[/unit]
[/then]
[/if]
[if]
[variable]
name=success_valia_reanimation
numerical_equals=0
[/variable]
[then]
[floating_text]
x,y=$valia_reanimation_storage.x,$valia_reanimation_storage.y
text= _ "failed"
[/floating_text]
[/then]
[/if]
[/then]
[/if]
[/event]
#enddef
#define AURA_OF_REANIMATION
# need to allow undo movements?
# [event]
# name=moveto
# first_time_only=no
# [filter]
# id=Valia
# [filter_location]
# [/filter_location]
# [/filter]
# {GET_ADJACENT_HEX $x1 $y1 1 valia_aura_location}
# [/event]
{AURA_OF_REANIMATION_DYING}
[event]
name=die
first_time_only=no
[filter]
[filter_adjacent]
id=Valia
[/filter_adjacent]
[/filter]
{AURA_OF_REANIMATION_DYING}
[/event]
#enddef
But something's not working again when I try to convert it to an ability:
Code: Select all
#define AURA_OF_REANIMATION_DYING_ABILITY
[event]
name=last breath
first_time_only=yes
[filter]
[filter_adjacent]
ability=aura_of_reanimation
[/filter_adjacent]
[not]
race=undead
[or]
race=mechanical
[/or]
[/not]
[/filter]
[store_unit]
[filter]
x,y=$x1,$y1
[/filter]
variable=valia_reanimation_storage
kill=no
[/store_unit]
[kill]
x,y=$x1,$y1
animate=yes
fire_event=yes
[/kill]
[set_variable]
name=success_valia_reanimation
rand=1,1,0,0,0,0
# 40%
[/set_variable]
[if]
[variable]
name=success_valia_reanimation
numerical_equals=1
[/variable]
[then]
[unit]
type=Walking Corpse
side=1
x,y=$valia_reanimation_storage.x,$valia_reanimation_storage.y
variation=$valia_reanimation_storage.undead_variation
name="$valia_reanimation_storage.name"
facing=$valia_reanimation_storage.facing
moves=0
[/unit]
[/then]
[/if]
[if]
[variable]
name=success_valia_reanimation
numerical_equals=0
[/variable]
[then]
[floating_text]
x,y=$valia_reanimation_storage.x,$valia_reanimation_storage.y
text= _ "failed"
[/floating_text]
[/then]
[/if]
[/event]
#enddef
#define AURA_OF_REANIMATION_ABILITY
{AURA_OF_REANIMATION_DYING_ABILITY}
[event]
name=die
first_time_only=no
[filter]
[filter_adjacent]
ability=aura_of_reanimation
[/filter_adjacent]
[/filter]
{AURA_OF_REANIMATION_DYING_ABILITY}
[/event]
#enddef
[b][/b]
#define ABILITY_AURA_OF_REANIMATION
[dummy]
id=aura_of_reanimation
name= _ "aura of reanimation"
description= _ "Aura of reanimation:
this unit is covered by an aura, where all units killed will have a 40% chance to become a zombie."
[/dummy]
[/abilities]
{AURA_OF_REANIMATION_ABILITY}
[+abilities]
#enddef
[event]
name=prestart
[modify_unit]
[filter]
id=Valia,Terach
[/filter]
[abilities]
{ABILITY_AURA_OF_REANIMATION}
[/abilities]
[/modify_unit]
[/event]
LUA: Llama Under Apprenticeship
Hell faction: completed
Hell faction: completed
Re: Something strange between different directions
bs:
Also note that the way you have coded it, the chance of this event is 33%, not 40%
[filter_adjacent]
is a SUF and takes ability
just fine. I think the problem is that the tags and macro calls in your code are somewhat strangely arranged. You have events defined inside [modify_unit]
tags. I'm not sure that your units ever get the aura ability, the way it is set up. You also have a 'last_breath' event inside a 'die' event etc. Here's a somewhat cleaner version of your code that, I think, should work. (I've also renamed your macros, just to make it clearer to myself what they are, not because I'm saying that you should use them in this way.)
Code: Select all
#define AURA_OF_REANIMATION_DEATH_EVENT
[event]
name=die
first_time_only=no
[filter]
[filter_adjacent]
ability=aura_of_reanimation
[/filter_adjacent]
[not]
race=undead
[or]
race=mechanical
[/or]
[/not]
[/filter]
[store_unit]
[filter]
x,y=$x1,$y1
[/filter]
variable=valia_reanimation_storage
kill=no
[/store_unit]
[kill]
x,y=$x1,$y1
animate=yes
[/kill]
[set_variable]
name=success_valia_reanimation
rand=1,1,0,0,0,0
# 40%
[/set_variable]
[if]
[variable]
name=success_valia_reanimation
numerical_equals=1
[/variable]
[then]
[unit]
type=Walking Corpse
side=1
x,y=$valia_reanimation_storage.x,$valia_reanimation_storage.y
variation=$valia_reanimation_storage.undead_variation
name="$valia_reanimation_storage.name"
facing=$valia_reanimation_storage.facing
moves=0
[/unit]
[/then]
[/if]
[if]
[variable]
name=success_valia_reanimation
numerical_equals=0
[/variable]
[then]
[floating_text]
x,y=$valia_reanimation_storage.x,$valia_reanimation_storage.y
text= _ "failed"
[/floating_text]
[/then]
[/if]
[/event]
#enddef
#define ABILITY_AURA_OF_REANIMATION
[dummy]
id=aura_of_reanimation
name= _ "aura of reanimation"
description= _ "Aura of reanimation:
this unit is covered by an aura, where all units killed will have a 40% chance to become a zombie."
[/dummy]
#enddef
{AURA_OF_REANIMATION_DEATH_EVENT}
[event]
name=prestart
[modify_unit]
[filter]
id=Valia,Terach
[/filter]
[abilities]
{ABILITY_AURA_OF_REANIMATION}
[/abilities]
[/modify_unit]
[/event]
SP campaigns: Galuldur's First Journey (1.12 & 1.14) & Grnk the Mighty (1.10 & 1.12)
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
- battlestar
- Posts: 690
- Joined: January 1st, 2007, 7:12 am
Re: Ability: morphing- gryphon form
reply to above posts
Ability: When a unit with this ability is selected, right click menu displays option of "transform", and that unit will become a gryphon to prowl the sky. It allows a unit to change to a gryphon and cross mountains before changing back to original form to strike its enemies, or strike in gryphon's form. Note: if there are abilities or items added onto the unit by wml, transforming will revert them back to basic units without them.
Is there a way to save a unit's list of abilities and attacks into an array?
Gryphon From Ability
Call of the Wild
LUA: Llama Under Apprenticeship
Hell faction: completed
Hell faction: completed
Re: Ability: temporary summons- call of the wild
Did you add the new attacks and abilities via objects or by using direct modification of the unit's variable?
They should be preserved if added via objects.
They should be preserved if added via objects.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
- battlestar
- Posts: 690
- Joined: January 1st, 2007, 7:12 am
Re: Ability: temporary summons- call of the wild
The original problem that prompted me to ask was this:
I directly modified a unit's variable to add the Gryphon form ability, during testing I reallized whenever [modify_unit] changes the unit type, it looses the added ability and reverts back to the basic unit without the ability. I added the gryphon form ability back to the unit every time after transforming, but any other abilities or attacks this unit picked up during the course of an imaginary campaign would be lost at this point.
What you said reminded me about another "spell" I was writing, for that one an ability is added then removed later automatically, by the look of how Objects use effectWML... an ability could be removed by using EffectWML (remove_ability) right? Where do I find an example of this?
Weapon special: Petrification
Weapons with this special ability turns its victim into a stone for the remainder of the turn. The attack defend retaliation sequence of the current attack still plays out like normal.
I directly modified a unit's variable to add the Gryphon form ability, during testing I reallized whenever [modify_unit] changes the unit type, it looses the added ability and reverts back to the basic unit without the ability. I added the gryphon form ability back to the unit every time after transforming, but any other abilities or attacks this unit picked up during the course of an imaginary campaign would be lost at this point.
What you said reminded me about another "spell" I was writing, for that one an ability is added then removed later automatically, by the look of how Objects use effectWML... an ability could be removed by using EffectWML (remove_ability) right? Where do I find an example of this?
Spoiler:
Weapon special: Petrification
Weapons with this special ability turns its victim into a stone for the remainder of the turn. The attack defend retaliation sequence of the current attack still plays out like normal.
Petrification weaponry
LUA: Llama Under Apprenticeship
Hell faction: completed
Hell faction: completed
- pyrophorus
- Posts: 533
- Joined: December 1st, 2010, 12:54 pm
Re: Ability: temporary summons- call of the wild
attacks_left=0 should do the trick. See here where to insert it in your code:battlestar wrote: Weapon special: Petrification
Weapons with this special ability turns its victim into a stone for the remainder of the turn. The attack defend retaliation sequence of the current attack still plays out like normal.
Code: Select all
#define WEAPON_SPECIAL_PETRIFICATION_EVENT
[event]
name=attacker hits
first_time_only=no
[filter_attack]
id=valia_petrification
[/filter_attack]
[store_unit]
[filter]
x,y=$x2,$y2
[/filter]
variable=petrified_temp_save
[/store_unit]
[modify_unit]
[filter]
x,y=$x2,$y2
[/filter]
[status]
petrified=yes
[/status]
# --- this should avoid new attacks
attacks_left=0
[/modify_unit]
LS
HowTos: WML filtering, WML variables