WML questions: invalid wml

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
User avatar
battlestar
Posts: 690
Joined: January 1st, 2007, 7:12 am

Re: WML questions: invalid wml

Post by battlestar »

Hmm that sounds complicated...

Also, I'm wondering what's wrong with this syntax. I'm scratching my head into a rash:

Code: Select all

[event]
    id=BS_ability_spiritual_residue
    name=die
    first_time_only=no
	[filter]
		ability=BS_spiritual_residue
	[/filter]
	[animate_unit]
		[filter]
			id=$unit.id
		[/filter]
		flag=death
	[/animate_unit]
	{VARIABLE unit.hitpoints 1}
	[set_variable]
		name=unit.image
		value=$("$unit.image" + "~B(4)~O(60%)")
		# "$unit.image|~B(4)~O(60%):100,$unit.image|~B(4)~O(40%):100,$unit.image|~B(4)~O(20%):100,$unit.image|~B(4)~O(40%):100"
	[/set_variable]
	[animate_unit]
		[filter]
			id=$unit.id
		[/filter]
		flag=recruited
	[/animate_unit]
	[unstore_unit]
		variable=unit
		find_vacant=no
		check_passability=no
	[/unstore_unit]
	[petrify]
		id=$unit.id
	[/petrify]
	{MESSAGE narrator () () "$unit.image|~B(4)~O(60%)"}
# displays "~B(4)~O(60%)"}"
	{MESSAGE narrator () () "$turn_number"}
# displays "1"
	{MESSAGE narrator () () "$(turn $turn_number + 1)"}
# displays nothing...
	[event]
		name="$(turn $turn_number + 1)"
		{MESSAGE narrator () () "uh... not working"}
		[unpetrify]
			id=$unit.id
		[/unpetrify]
		[kill]
			id=$unit.id
			animate=yes
		[/kill]
	[/event]
[/event]
Thanks.
LUA: Llama Under Apprenticeship
Hell faction: completed
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: WML questions: invalid wml

Post by zookeeper »

It didn't produce any errors for me, so I doubt there's anything wrong with the syntax as such.

EDIT: Regarding the conditional disablement of attacks, I remembered wrong; there's nothing directly in [attack] to do that, but you can use the [disable] weapon special for that.
User avatar
tekelili
Posts: 1039
Joined: August 19th, 2009, 9:28 pm

Re: WML questions: invalid wml

Post by tekelili »

battlestar wrote:Hmm that sounds complicated...

Also, I'm wondering what's wrong with this syntax. I'm scratching my head into a rash:
I dont know it for sure, but after a brief glance to event nature, try this:

Code: Select all

      [filter]
         id=$|unit.id
      [/filter]
The pipeline will make it delayed variable substitution, something you could need (but I may be wrong). I mostly had this issue when using events inside units or with insert tag.

Edit: The problem could be also in nested event if above doesnt work, I would try:

Code: Select all

   [event]
      name="$(turn $turn_number + 1)"
      delayed_variable_substitution=no
      {MESSAGE narrator () () "uh... not working"}
      [unpetrify]
         id=$unit.id
      [/unpetrify]
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
User avatar
battlestar
Posts: 690
Joined: January 1st, 2007, 7:12 am

Re: WML questions: invalid wml

Post by battlestar »

so, for the nested event I needed delayed substitution set to no and "turn $($turn_number + 1)"

I still can't get "$unit.image|~B(4)~O(60%)" to stay inside image of a unit.

I got unit.image to be "units/demons/blade-demon.png~B(4)~O(60%)", confirmed with a message output, unloaded the unit, then in game unit variable inspection showed image to still be "units/demons/blade-demon.png". Tried various code combinations and still the same.

So I modified original unit file to be image=units/demons/blade-demon.png~B(4)~O(60%), which apparently affects the side bar's unit image, but the on-map appearance is still full opacity and no blue.

What I'm trying to do is when a unit with this particular ability dies, it resurrects into a unit with 60% opacity and appears bluish.
LUA: Llama Under Apprenticeship
Hell faction: completed
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: WML questions: invalid wml

Post by zookeeper »

battlestar wrote:What I'm trying to do is when a unit with this particular ability dies, it resurrects into a unit with 60% opacity and appears bluish.
Then you should give the unit an object with an apply_to=image_mod [effect].
User avatar
battlestar
Posts: 690
Joined: January 1st, 2007, 7:12 am

Re: WML questions: invalid wml

Post by battlestar »

Thanks, that worked great.

Next problems:

1. trying to make an event that happens when an adjacent enemy is trying to leave, instead I ended up with something that happens when an enemy comes to adjacent hex. So instead of preemptive strike I intended to make a interception ability. I thought about exit_hex, but think it'll cause units passing by to be intercepted also.

Code: Select all

#define ABILITIES_PREEMPTIVE_STRIKE
    # Canned definition of the Alluring ability to be included in an
    # [abilities] clause.  Note: this is deliberately unbalanced WML,
    # in order to close the abilities clause then insert the event
    # then reopen the abilities clause.
    [dummy]
        id=BS_preemptive_strike
        name= _ "preemptive strike"
        female_name= _ "female^preemptive strike"
        description=_ "Preemptive strike:
This unit will attack any enemy unit moving adjacent to it."
    [/dummy] # a hack to please wmlxgettext (using a bug in wmlxgettext!): dummy tag start: [abilities]
[/abilities]
[event]
    id=BS_preemptive_strike
    name=moveto
    first_time_only=no
   [filter] # victim moves
      [filter_adjacent]
         ability=BS_preemptive_strike
      [/filter_adjacent]
   [/filter]
   [store_unit] # stores adjacent interceptors, store if adjacent to victim, has intercept ability, not victim's (active) side
      [filter]
         ability=BS_preemptive_strike
         [not]
            side=$side_number
         [/not]
         [filter_adjacent]
            id=$unit.id
         [/filter_adjacent]
      [/filter]
      variable=temp_unit
   [/store_unit]
   {FOREACH temp_unit i}
   # for each interceptor, attack victim once.
      [harm_unit]
         [filter]
            id=$unit.id
         [/filter]
         [filter_second]
            id=$temp_unit[$i].id
         [/filter_second]
         amount=$temp_unit[$i].attack[0].damage
         alignment=$temp_unit[$i].alignment
         damage_type=$temp_unit[$i].attack[0].type
         kill=yes
         fire_event=yes
         animate=yes
         experience=yes
      [/harm_unit]
   {NEXT i}
   {CLEAR_VARIABLE temp_unit}
[/event]
[+abilities] # a hack to please wmlxgettext (using a bug in wmlxgettext!): dummy tag end: [/abilities]
#enddef
2. Killer unit becomes killed unit in every way except for remaining in same side, same id, same facing. However I couldn't get the id to stay the same, it always becomes the victim's id...

Code: Select all

#define ABILITIES_MIMICK
    # Canned definition of the Alluring ability to be included in an
    # [abilities] clause.  Note: this is deliberately unbalanced WML,
    # in order to close the abilities clause then insert the event
    # then reopen the abilities clause.
    [dummy]
        id=BS_mimick
        name= _ "mimick"
        female_name= _ "female^mimick"
        description=_ "This unit will become a replica of the unit that it has just killed."
    [/dummy] # a hack to please wmlxgettext (using a bug in wmlxgettext!): dummy tag start: [abilities]
[/abilities]
[event]
    id=BS_mimick
    name=die
    first_time_only=no
	[filter]
	[/filter]
	[filter_second]
		ability=BS_mimick
	[/filter_second]
	{VARIABLE temp_id $second_unit.id}
	{VARIABLE unit.id $second_unit.id}
	{VARIABLE unit.side $second_unit.side}
	{VARIABLE unit.hitpoints $second_unit.hitpoints}
	{VARIABLE unit.attacks_left 0}
	{VARIABLE unit.moves 0}
	{VARIABLE unit.facing $second_unit.facing}
	[unstore_unit]
		variable=unit
		x,y=$second_unit.x,$second_unit.y
	[/unstore_unit]
	{MESSAGE narrator () $unit.id $temp_id}
	[modify_unit]
		[filter]
			id=$unit.id
		[/filter]
		id=$temp_id
	[/modify_unit]
	{CLEAR_VARIABLE temp_id}
[/event]
[+abilities] # a hack to please wmlxgettext (using a bug in wmlxgettext!): dummy tag end: [/abilities]
#enddef
LUA: Llama Under Apprenticeship
Hell faction: completed
Post Reply