Does {MODIFY_UNIT (type=whatever) canrecruit yes} work?

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
ialdabaoth
Posts: 9
Joined: November 22nd, 2013, 5:57 pm

Does {MODIFY_UNIT (type=whatever) canrecruit yes} work?

Post by ialdabaoth »

Here's what I'm trying to do:

Code: Select all

[event]
  name=post advance
  {MODIFY_UNIT (type=Elvish Lord) canrecruit yes}
[/event]
In plain English, whenever any unit advances to an Elvish Lord, I want that Elvish Lord to gain the canrecruit=yes property. (I'm settling for ALL Elvish Lords gaining the canrecruit=yes property; I'm not picky.)

I appear to be doing it wrong, though. Right now, whenever a unit advances to an Elvish Lord, exactly zero Elvish Lords gain the canrecruit=yes property.

I've also tried:

Code: Select all

[event]
  name=post advance
  first_time_only=no
  [filter]
    type=Elvish Lord
  [/filter]
  [modify_unit]
    [filter]
      type=Elvish Lord
    [/filter]
    canrecruit=yes
  [/modify_unit]
[/event]
Which also doesn't work.
Halp?
User avatar
Iris
Site Administrator
Posts: 6744
Joined: November 14th, 2006, 5:54 pm
Location: Chile
Contact:

Re: Does {MODIFY_UNIT (type=whatever) canrecruit yes} work?

Post by Iris »

The first sample will work exactly once (because first_time_only=no isn’t specified and alter all Elvish Lords on the map, which is inefficient and pointless as odds are that they already have canrecruit=yes once their number is not singular. The second sample should work correctly but it’s also going to modify all Elvish Lords on the map. A more efficient filter for the action should be x,y=$x1,$y1, which will match the location of the primary unit for which the event was triggered:

Code: Select all

[event]
    name=post advance
    first_time_only=no
    [filter]
        type=Elvish Lord
    [/filter]

    [modify_unit]
        [filter]
            x,y=$x1,$y1
        [/filter]
        canrecruit=yes
    [/modify_unit]
[/event]
Tested successfully with an Elvish Archer → Ranger level-up sequence.

So, where (file and parent tag) are you placing this code that currently doesn’t work?
Author of the unofficial UtBS sequels Invasion from the Unknown and After the Storm (now available for Wesnoth 1.14.x and 1.15.4+).
ialdabaoth
Posts: 9
Joined: November 22nd, 2013, 5:57 pm

Re: Does {MODIFY_UNIT (type=whatever) canrecruit yes} work?

Post by ialdabaoth »

shadowm wrote:The first sample will work exactly once (because first_time_only=no isn’t specified and alter all Elvish Lords on the map, which is inefficient and pointless as odds are that they already have canrecruit=yes once their number is not singular. The second sample should work correctly but it’s also going to modify all Elvish Lords on the map. A more efficient filter for the action should be x,y=$x1,$y1, which will match the location of the primary unit for which the event was triggered:
Awesome, thank you!
So, where (file and parent tag) are you placing this code that currently doesn’t work?
... outside of the [unit_type] block, instead of inside it, like a dummy. Putting it inside the [unit_type] block like I THOUGHT I was doing fixes it, and changing the filter to x,y=$x1,$y1 makes it much more efficient.

Thank you so much!
Post Reply